summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/AllToLua.bat3
-rw-r--r--source/AllToLua.pkg41
-rw-r--r--source/Bindings.cpp15468
-rw-r--r--source/Bindings.h8
-rw-r--r--source/BlockID.h151
-rw-r--r--source/Defines.h129
-rw-r--r--source/Endianness.h51
-rw-r--r--source/FileDefine.h21
-rw-r--r--source/LuaFunctions.h17
-rw-r--r--source/MCSocket.h41
-rw-r--r--source/ManualBindings.cpp229
-rw-r--r--source/ManualBindings.h8
-rw-r--r--source/Matrix4f.cpp0
-rw-r--r--source/Matrix4f.h111
-rw-r--r--source/MemoryLeak.h18
-rw-r--r--source/PacketID.h52
-rw-r--r--source/Vector3d.cpp16
-rw-r--r--source/Vector3d.h40
-rw-r--r--source/Vector3f.cpp31
-rw-r--r--source/Vector3f.h47
-rw-r--r--source/Vector3i.cpp9
-rw-r--r--source/Vector3i.h37
-rw-r--r--source/cAuthenticator.cpp194
-rw-r--r--source/cAuthenticator.h13
-rw-r--r--source/cBlockEntity.h34
-rw-r--r--source/cBlockToPickup.cpp37
-rw-r--r--source/cBlockToPickup.h13
-rw-r--r--source/cBlockingTCPLink.cpp137
-rw-r--r--source/cBlockingTCPLink.h21
-rw-r--r--source/cChatColor.cpp25
-rw-r--r--source/cChatColor.h32
-rw-r--r--source/cChestEntity.cpp185
-rw-r--r--source/cChestEntity.h42
-rw-r--r--source/cChicken.cpp90
-rw-r--r--source/cChicken.h21
-rw-r--r--source/cChunk.cpp1388
-rw-r--r--source/cChunk.h127
-rw-r--r--source/cChunkLoader.cpp364
-rw-r--r--source/cChunkLoader.h32
-rw-r--r--source/cChunkMap.cpp714
-rw-r--r--source/cChunkMap.h91
-rw-r--r--source/cClientHandle.cpp1082
-rw-r--r--source/cClientHandle.h70
-rw-r--r--source/cCraftingWindow.cpp103
-rw-r--r--source/cCraftingWindow.h13
-rw-r--r--source/cCriticalSection.cpp60
-rw-r--r--source/cCriticalSection.h16
-rw-r--r--source/cCuboid.cpp10
-rw-r--r--source/cCuboid.h40
-rw-r--r--source/cEntity.cpp283
-rw-r--r--source/cEntity.h108
-rw-r--r--source/cEvent.cpp112
-rw-r--r--source/cEvent.h18
-rw-r--r--source/cFurnaceEntity.cpp372
-rw-r--r--source/cFurnaceEntity.h43
-rw-r--r--source/cFurnaceRecipe.cpp214
-rw-r--r--source/cFurnaceRecipe.h34
-rw-r--r--source/cFurnaceWindow.cpp42
-rw-r--r--source/cFurnaceWindow.h16
-rw-r--r--source/cGenSettings.cpp10
-rw-r--r--source/cGenSettings.h9
-rw-r--r--source/cGroup.cpp34
-rw-r--r--source/cGroup.h39
-rw-r--r--source/cGroupManager.cpp104
-rw-r--r--source/cGroupManager.h17
-rw-r--r--source/cHeartBeat.cpp119
-rw-r--r--source/cHeartBeat.h21
-rw-r--r--source/cInventory.cpp364
-rw-r--r--source/cInventory.h67
-rw-r--r--source/cItem.h33
-rw-r--r--source/cLadder.h43
-rw-r--r--source/cLog.cpp136
-rw-r--r--source/cLog.h30
-rw-r--r--source/cLuaCommandBinder.cpp106
-rw-r--r--source/cLuaCommandBinder.h36
-rw-r--r--source/cMCLogger.cpp155
-rw-r--r--source/cMCLogger.h39
-rw-r--r--source/cMakeDir.cpp24
-rw-r--r--source/cMakeDir.h7
-rw-r--r--source/cMonster.cpp609
-rw-r--r--source/cMonster.h85
-rw-r--r--source/cMonsterConfig.cpp93
-rw-r--r--source/cMonsterConfig.h18
-rw-r--r--source/cNoise.cpp253
-rw-r--r--source/cNoise.h33
-rw-r--r--source/cPawn.cpp96
-rw-r--r--source/cPawn.h31
-rw-r--r--source/cPickup.cpp229
-rw-r--r--source/cPickup.h34
-rw-r--r--source/cPlayer.cpp713
-rw-r--r--source/cPlayer.h96
-rw-r--r--source/cPlugin.cpp78
-rw-r--r--source/cPlugin.h76
-rw-r--r--source/cPluginManager.cpp423
-rw-r--r--source/cPluginManager.h68
-rw-r--r--source/cPlugin_Lua.cpp97
-rw-r--r--source/cPlugin_Lua.h34
-rw-r--r--source/cRecipeChecker.cpp458
-rw-r--r--source/cRecipeChecker.h39
-rw-r--r--source/cReferenceManager.cpp36
-rw-r--r--source/cReferenceManager.h22
-rw-r--r--source/cRoot.cpp162
-rw-r--r--source/cRoot.h52
-rw-r--r--source/cSemaphore.cpp96
-rw-r--r--source/cSemaphore.h17
-rw-r--r--source/cServer.cpp553
-rw-r--r--source/cServer.h53
-rw-r--r--source/cSign.h32
-rw-r--r--source/cSignEntity.cpp136
-rw-r--r--source/cSignEntity.h34
-rw-r--r--source/cSleep.cpp16
-rw-r--r--source/cSleep.h7
-rw-r--r--source/cSocket.cpp30
-rw-r--r--source/cSocket.h43
-rw-r--r--source/cSpider.cpp92
-rw-r--r--source/cSpider.h22
-rw-r--r--source/cStairs.h19
-rw-r--r--source/cStringMap.cpp16
-rw-r--r--source/cStringMap.h19
-rw-r--r--source/cTCPLink.cpp146
-rw-r--r--source/cTCPLink.h23
-rw-r--r--source/cThread.cpp75
-rw-r--r--source/cThread.h25
-rw-r--r--source/cTimer.cpp39
-rw-r--r--source/cTimer.h15
-rw-r--r--source/cTorch.h51
-rw-r--r--source/cTracer.cpp377
-rw-r--r--source/cTracer.h32
-rw-r--r--source/cWaterSimulator.cpp216
-rw-r--r--source/cWaterSimulator.h25
-rw-r--r--source/cWebAdmin.cpp309
-rw-r--r--source/cWebAdmin.h60
-rw-r--r--source/cWebPlugin.cpp22
-rw-r--r--source/cWebPlugin.h25
-rw-r--r--source/cWindow.cpp235
-rw-r--r--source/cWindow.h67
-rw-r--r--source/cWindowOwner.h16
-rw-r--r--source/cWorld.cpp764
-rw-r--r--source/cWorld.h158
-rw-r--r--source/main.cpp36
-rw-r--r--source/md5/md5.cpp366
-rw-r--r--source/md5/md5.h93
-rw-r--r--source/packets/cPacket.cpp223
-rw-r--r--source/packets/cPacket.h56
-rw-r--r--source/packets/cPacket_13.cpp10
-rw-r--r--source/packets/cPacket_13.h30
-rw-r--r--source/packets/cPacket_AddToInventory.cpp17
-rw-r--r--source/packets/cPacket_AddToInventory.h23
-rw-r--r--source/packets/cPacket_ArmAnim.cpp24
-rw-r--r--source/packets/cPacket_ArmAnim.h21
-rw-r--r--source/packets/cPacket_BlockChange.cpp19
-rw-r--r--source/packets/cPacket_BlockChange.h26
-rw-r--r--source/packets/cPacket_BlockDig.cpp29
-rw-r--r--source/packets/cPacket_BlockDig.h27
-rw-r--r--source/packets/cPacket_BlockPlace.cpp18
-rw-r--r--source/packets/cPacket_BlockPlace.h32
-rw-r--r--source/packets/cPacket_Chat.cpp23
-rw-r--r--source/packets/cPacket_Chat.h18
-rw-r--r--source/packets/cPacket_CollectItem.cpp16
-rw-r--r--source/packets/cPacket_CollectItem.h20
-rw-r--r--source/packets/cPacket_DestroyEntity.cpp23
-rw-r--r--source/packets/cPacket_DestroyEntity.h20
-rw-r--r--source/packets/cPacket_Disconnect.cpp22
-rw-r--r--source/packets/cPacket_Disconnect.h18
-rw-r--r--source/packets/cPacket_EntityEquipment.cpp42
-rw-r--r--source/packets/cPacket_EntityEquipment.h27
-rw-r--r--source/packets/cPacket_EntityLook.cpp28
-rw-r--r--source/packets/cPacket_EntityLook.h25
-rw-r--r--source/packets/cPacket_EntityStatus.cpp17
-rw-r--r--source/packets/cPacket_EntityStatus.h24
-rw-r--r--source/packets/cPacket_Flying.cpp8
-rw-r--r--source/packets/cPacket_Flying.h19
-rw-r--r--source/packets/cPacket_Handshake.cpp24
-rw-r--r--source/packets/cPacket_Handshake.h17
-rw-r--r--source/packets/cPacket_InventoryProgressBar.cpp18
-rw-r--r--source/packets/cPacket_InventoryProgressBar.h23
-rw-r--r--source/packets/cPacket_InventorySlot.cpp23
-rw-r--r--source/packets/cPacket_InventorySlot.h34
-rw-r--r--source/packets/cPacket_ItemSwitch.cpp23
-rw-r--r--source/packets/cPacket_ItemSwitch.h19
-rw-r--r--source/packets/cPacket_KeepAlive.cpp22
-rw-r--r--source/packets/cPacket_KeepAlive.h18
-rw-r--r--source/packets/cPacket_Login.cpp41
-rw-r--r--source/packets/cPacket_Login.h33
-rw-r--r--source/packets/cPacket_MapChunk.cpp69
-rw-r--r--source/packets/cPacket_MapChunk.h37
-rw-r--r--source/packets/cPacket_Metadata.cpp65
-rw-r--r--source/packets/cPacket_Metadata.h23
-rw-r--r--source/packets/cPacket_MultiBlock.cpp42
-rw-r--r--source/packets/cPacket_MultiBlock.h32
-rw-r--r--source/packets/cPacket_NamedEntitySpawn.cpp26
-rw-r--r--source/packets/cPacket_NamedEntitySpawn.h32
-rw-r--r--source/packets/cPacket_PickupSpawn.cpp40
-rw-r--r--source/packets/cPacket_PickupSpawn.h38
-rw-r--r--source/packets/cPacket_Ping.h16
-rw-r--r--source/packets/cPacket_PlayerLook.cpp36
-rw-r--r--source/packets/cPacket_PlayerLook.h25
-rw-r--r--source/packets/cPacket_PlayerMoveLook.cpp50
-rw-r--r--source/packets/cPacket_PlayerMoveLook.h33
-rw-r--r--source/packets/cPacket_PlayerPosition.cpp42
-rw-r--r--source/packets/cPacket_PlayerPosition.h29
-rw-r--r--source/packets/cPacket_PreChunk.cpp17
-rw-r--r--source/packets/cPacket_PreChunk.h22
-rw-r--r--source/packets/cPacket_RelativeEntityMove.cpp18
-rw-r--r--source/packets/cPacket_RelativeEntityMove.h25
-rw-r--r--source/packets/cPacket_RelativeEntityMoveLook.cpp20
-rw-r--r--source/packets/cPacket_RelativeEntityMoveLook.h29
-rw-r--r--source/packets/cPacket_Respawn.cpp31
-rw-r--r--source/packets/cPacket_Respawn.h28
-rw-r--r--source/packets/cPacket_SpawnMob.cpp60
-rw-r--r--source/packets/cPacket_SpawnMob.h27
-rw-r--r--source/packets/cPacket_TeleportEntity.cpp34
-rw-r--r--source/packets/cPacket_TeleportEntity.h31
-rw-r--r--source/packets/cPacket_TimeUpdate.cpp22
-rw-r--r--source/packets/cPacket_TimeUpdate.h20
-rw-r--r--source/packets/cPacket_UpdateHealth.cpp20
-rw-r--r--source/packets/cPacket_UpdateHealth.h24
-rw-r--r--source/packets/cPacket_UpdateSign.cpp41
-rw-r--r--source/packets/cPacket_UpdateSign.h28
-rw-r--r--source/packets/cPacket_UseEntity.cpp10
-rw-r--r--source/packets/cPacket_UseEntity.h23
-rw-r--r--source/packets/cPacket_WholeInventory.cpp68
-rw-r--r--source/packets/cPacket_WholeInventory.h31
-rw-r--r--source/packets/cPacket_WindowClick.cpp36
-rw-r--r--source/packets/cPacket_WindowClick.h41
-rw-r--r--source/packets/cPacket_WindowClose.cpp27
-rw-r--r--source/packets/cPacket_WindowClose.h20
-rw-r--r--source/packets/cPacket_WindowOpen.cpp18
-rw-r--r--source/packets/cPacket_WindowOpen.h24
-rw-r--r--source/tolua++.exebin0 -> 192000 bytes
-rw-r--r--source/tolua++.h186
-rw-r--r--source/tolua_base.h125
-rw-r--r--source/virtual_method_hooks.lua506
233 files changed, 35759 insertions, 0 deletions
diff --git a/source/AllToLua.bat b/source/AllToLua.bat
new file mode 100644
index 000000000..24f56a0e5
--- /dev/null
+++ b/source/AllToLua.bat
@@ -0,0 +1,3 @@
+"tolua++.exe" -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+PAUSE
+echo "tolua++.exe" -o Bindings.cpp -H Bindings.h AllToLua.pkg \ No newline at end of file
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg
new file mode 100644
index 000000000..8338f0088
--- /dev/null
+++ b/source/AllToLua.pkg
@@ -0,0 +1,41 @@
+$#include "tolua_base.h"
+
+$cfile "cTorch.h"
+$cfile "cStairs.h"
+$cfile "cLadder.h"
+
+$cfile "../iniFile/iniFile.h"
+
+$cfile "BlockID.h"
+$cfile "PacketID.h"
+$cfile "Defines.h"
+$cfile "LuaFunctions.h"
+$cfile "cStringMap.h"
+$cfile "cChatColor.h"
+$cfile "cClientHandle.h"
+$cfile "cEntity.h"
+$cfile "cPawn.h"
+$cfile "cPlayer.h"
+$cfile "cPluginManager.h"
+$cfile "cPlugin.h"
+$cfile "cPlugin_Lua.h"
+$cfile "cServer.h"
+$cfile "cWorld.h"
+$cfile "cInventory.h"
+$cfile "cItem.h"
+$cfile "cWebAdmin.h"
+$cfile "cWebPlugin.h"
+$cfile "cPickup.h"
+$cfile "cRoot.h"
+$cfile "cTCPLink.h"
+$cfile "Vector3f.h"
+$cfile "Vector3d.h"
+$cfile "Vector3i.h"
+$cfile "Matrix4f.h"
+$cfile "cCuboid.h"
+$cfile "cMCLogger.h"
+$cfile "cTracer.h"
+$cfile "cGroup.h"
+$cfile "packets/cPacket_Login.h"
+$cfile "packets/cPacket_BlockDig.h"
+$cfile "packets/cPacket_BlockPlace.h" \ No newline at end of file
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
new file mode 100644
index 000000000..7a0174852
--- /dev/null
+++ b/source/Bindings.cpp
@@ -0,0 +1,15468 @@
+/*
+** Lua binding: AllToLua
+** Generated automatically by tolua++-1.0.92 on 07/15/11 01:36:28.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua++.h"
+
+/* Exported function */
+TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
+
+#include "tolua_base.h"
+#include "cTorch.h"
+#include "cStairs.h"
+#include "cLadder.h"
+#include "../iniFile/iniFile.h"
+#include "BlockID.h"
+#include "PacketID.h"
+#include "Defines.h"
+#include "LuaFunctions.h"
+#include "cStringMap.h"
+#include "cChatColor.h"
+#include "cClientHandle.h"
+#include "cEntity.h"
+#include "cPawn.h"
+#include "cPlayer.h"
+#include "cPluginManager.h"
+#include "cPlugin.h"
+#include "cPlugin_Lua.h"
+#include "cServer.h"
+#include "cWorld.h"
+#include "cInventory.h"
+#include "cItem.h"
+#include "cWebAdmin.h"
+#include "cWebPlugin.h"
+#include "cPickup.h"
+#include "cRoot.h"
+#include "cTCPLink.h"
+#include "Vector3f.h"
+#include "Vector3d.h"
+#include "Vector3i.h"
+#include "Matrix4f.h"
+#include "cCuboid.h"
+#include "cMCLogger.h"
+#include "cTracer.h"
+#include "cGroup.h"
+#include "packets/cPacket_Login.h"
+#include "packets/cPacket_BlockDig.h"
+#include "packets/cPacket_BlockPlace.h"
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_cItem (lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_Vector3f (lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cIniFile (lua_State* tolua_S)
+{
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cPickup (lua_State* tolua_S)
+{
+ cPickup* self = (cPickup*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cPacket_BlockDig (lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cTracer (lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cPlugin (lua_State* tolua_S)
+{
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cMCLogger (lua_State* tolua_S)
+{
+ cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cCuboid (lua_State* tolua_S)
+{
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cWebPlugin (lua_State* tolua_S)
+{
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_Vector3i (lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cEntity (lua_State* tolua_S)
+{
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
+static int tolua_collect_cTCPLink (lua_State* tolua_S)
+{
+ cTCPLink* self = (cTCPLink*) 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);
+ Mtolua_delete(self);
+ return 0;
+}
+#endif
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+ tolua_usertype(tolua_S,"TakeDamageInfo");
+ tolua_usertype(tolua_S,"cPlugin");
+ tolua_usertype(tolua_S,"cStringMap");
+ tolua_usertype(tolua_S,"cServer");
+ tolua_usertype(tolua_S,"cRoot");
+ tolua_usertype(tolua_S,"cPlugin::CommandStruct");
+ tolua_usertype(tolua_S,"cPickup");
+ tolua_usertype(tolua_S,"cRecipeChecker");
+ tolua_usertype(tolua_S,"cPacket_Login");
+ tolua_usertype(tolua_S,"cClientHandle");
+ tolua_usertype(tolua_S,"Lua__cPacket_BlockDig");
+ tolua_usertype(tolua_S,"cFurnaceRecipe");
+ tolua_usertype(tolua_S,"cCuboid");
+ tolua_usertype(tolua_S,"cChatColor");
+ tolua_usertype(tolua_S,"cMCLogger");
+ tolua_usertype(tolua_S,"cPacket_PickupSpawn");
+ tolua_usertype(tolua_S,"Lua__cWebPlugin");
+ tolua_usertype(tolua_S,"Lua__cPawn");
+ tolua_usertype(tolua_S,"cGroup");
+ tolua_usertype(tolua_S,"cItem");
+ tolua_usertype(tolua_S,"Vector3f");
+ tolua_usertype(tolua_S,"cPlugin_Lua");
+ tolua_usertype(tolua_S,"cTracer");
+ tolua_usertype(tolua_S,"Lua__cPlayer");
+ tolua_usertype(tolua_S,"cPacket");
+ tolua_usertype(tolua_S,"cPacket_BlockDig");
+ tolua_usertype(tolua_S,"cWebAdmin");
+ tolua_usertype(tolua_S,"Vector3i");
+ tolua_usertype(tolua_S,"cBlockEntity");
+ tolua_usertype(tolua_S,"cWorld");
+ tolua_usertype(tolua_S,"Lua__cTCPLink");
+ tolua_usertype(tolua_S,"Lua__cPlugin");
+ tolua_usertype(tolua_S,"cTCPLink");
+ tolua_usertype(tolua_S,"cPacket_BlockPlace");
+ tolua_usertype(tolua_S,"cLadder");
+ tolua_usertype(tolua_S,"cGroupManager");
+ tolua_usertype(tolua_S,"cPluginManager");
+ tolua_usertype(tolua_S,"cIniFile");
+ tolua_usertype(tolua_S,"cWebPlugin");
+ tolua_usertype(tolua_S,"HTTPRequest");
+ tolua_usertype(tolua_S,"cPawn");
+ tolua_usertype(tolua_S,"cPlayer");
+ tolua_usertype(tolua_S,"cTorch");
+ tolua_usertype(tolua_S,"Lua__cPickup");
+ tolua_usertype(tolua_S,"cEntity");
+ tolua_usertype(tolua_S,"cInventory");
+ tolua_usertype(tolua_S,"Lua__cEntity");
+ tolua_usertype(tolua_S,"cStairs");
+ tolua_usertype(tolua_S,"Vector3d");
+}
+
+/* method: DirectionToMetaData of class cTorch */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_DirectionToMetaData00
+static int tolua_AllToLua_cTorch_DirectionToMetaData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char a_Direction = ((char) tolua_tonumber(tolua_S,2,0));
+ {
+ char tolua_ret = (char) cTorch::DirectionToMetaData(a_Direction);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: MetaDataToDirection of class cTorch */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_MetaDataToDirection00
+static int tolua_AllToLua_cTorch_MetaDataToDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0));
+ {
+ char tolua_ret = (char) cTorch::MetaDataToDirection(a_MetaData);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: RotationToMetaData of class cStairs */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cStairs_RotationToMetaData00
+static int tolua_AllToLua_cStairs_RotationToMetaData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cStairs",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ float a_Rotation = ((float) tolua_tonumber(tolua_S,2,0));
+ {
+ char tolua_ret = (char) cStairs::RotationToMetaData(a_Rotation);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'RotationToMetaData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DirectionToMetaData of class cLadder */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_DirectionToMetaData00
+static int tolua_AllToLua_cLadder_DirectionToMetaData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char a_Direction = ((char) tolua_tonumber(tolua_S,2,0));
+ {
+ char tolua_ret = (char) cLadder::DirectionToMetaData(a_Direction);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: MetaDataToDirection of class cLadder */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_MetaDataToDirection00
+static int tolua_AllToLua_cLadder_MetaDataToDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0));
+ {
+ char tolua_ret = (char) cLadder::MetaDataToDirection(a_MetaData);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new00
+static int tolua_AllToLua_cIniFile_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const std::string iniPath = ((const std::string) tolua_tocppstring(tolua_S,2,""));
+ {
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(iniPath));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new00_local
+static int tolua_AllToLua_cIniFile_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const std::string iniPath = ((const std::string) tolua_tocppstring(tolua_S,2,""));
+ {
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(iniPath));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CaseSensitive of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_CaseSensitive00
+static int tolua_AllToLua_cIniFile_CaseSensitive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CaseSensitive'", NULL);
+#endif
+ {
+ self->CaseSensitive();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CaseSensitive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CaseInsensitive of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_CaseInsensitive00
+static int tolua_AllToLua_cIniFile_CaseInsensitive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CaseInsensitive'", NULL);
+#endif
+ {
+ self->CaseInsensitive();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CaseInsensitive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Path of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Path00
+static int tolua_AllToLua_cIniFile_Path00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string newPath = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Path'", NULL);
+#endif
+ {
+ self->Path(newPath);
+ tolua_pushcppstring(tolua_S,(const char*)newPath);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Path'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Path of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Path01
+static int tolua_AllToLua_cIniFile_Path01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Path'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->Path();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_Path00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPath of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetPath00
+static int tolua_AllToLua_cIniFile_SetPath00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string newPath = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPath'", NULL);
+#endif
+ {
+ self->SetPath(newPath);
+ tolua_pushcppstring(tolua_S,(const char*)newPath);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPath'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ReadFile of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_ReadFile00
+static int tolua_AllToLua_cIniFile_ReadFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ReadFile'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->ReadFile();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ReadFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: WriteFile of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_WriteFile00
+static int tolua_AllToLua_cIniFile_WriteFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'WriteFile'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->WriteFile();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'WriteFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Erase of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Erase00
+static int tolua_AllToLua_cIniFile_Erase00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Erase'", NULL);
+#endif
+ {
+ self->Erase();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Erase'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Clear of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Clear00
+static int tolua_AllToLua_cIniFile_Clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+#endif
+ {
+ self->Clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Reset of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Reset00
+static int tolua_AllToLua_cIniFile_Reset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Reset'", NULL);
+#endif
+ {
+ self->Reset();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Reset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: FindKey of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_FindKey00
+static int tolua_AllToLua_cIniFile_FindKey00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FindKey'", NULL);
+#endif
+ {
+ long tolua_ret = (long) self->FindKey(keyname);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'FindKey'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: FindValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_FindValue00
+static int tolua_AllToLua_cIniFile_FindValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FindValue'", NULL);
+#endif
+ {
+ long tolua_ret = (long) self->FindValue(keyID,valuename);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'FindValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumKeys of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumKeys00
+static int tolua_AllToLua_cIniFile_NumKeys00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumKeys'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumKeys();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NumKeys'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetNumKeys of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetNumKeys00
+static int tolua_AllToLua_cIniFile_GetNumKeys00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNumKeys'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->GetNumKeys();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetNumKeys'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddKeyName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_AddKeyName00
+static int tolua_AllToLua_cIniFile_AddKeyName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddKeyName'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->AddKeyName(keyname);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddKeyName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KeyName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_KeyName00
+static int tolua_AllToLua_cIniFile_KeyName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KeyName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->KeyName(keyID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'KeyName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetKeyName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetKeyName00
+static int tolua_AllToLua_cIniFile_GetKeyName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetKeyName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetKeyName(keyID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetKeyName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumValues of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumValues00
+static int tolua_AllToLua_cIniFile_NumValues00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumValues'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumValues(keyname);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NumValues'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetNumValues of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetNumValues00
+static int tolua_AllToLua_cIniFile_GetNumValues00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNumValues'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->GetNumValues(keyname);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetNumValues'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumValues of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumValues01
+static int tolua_AllToLua_cIniFile_NumValues01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumValues'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumValues(keyID);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_NumValues00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetNumValues of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetNumValues01
+static int tolua_AllToLua_cIniFile_GetNumValues01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNumValues'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->GetNumValues(keyID);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_GetNumValues00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ValueName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_ValueName00
+static int tolua_AllToLua_cIniFile_ValueName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ValueName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->ValueName(keyname,valueID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ValueName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValueName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueName00
+static int tolua_AllToLua_cIniFile_GetValueName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValueName(keyname,valueID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetValueName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ValueName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_ValueName01
+static int tolua_AllToLua_cIniFile_ValueName01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ValueName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->ValueName(keyID,valueID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_ValueName00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValueName of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueName01
+static int tolua_AllToLua_cIniFile_GetValueName01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValueName(keyID,valueID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_GetValueName00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValue00
+static int tolua_AllToLua_cIniFile_GetValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValue(keyname,valuename);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValue01
+static int tolua_AllToLua_cIniFile_GetValue01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const std::string defValue = ((const std::string) tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValue(keyname,valuename,defValue);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ tolua_pushcppstring(tolua_S,(const char*)defValue);
+ }
+ }
+ return 4;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_GetValue00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValue02
+static int tolua_AllToLua_cIniFile_GetValue02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValue(keyID,valueID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_GetValue01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValue03
+static int tolua_AllToLua_cIniFile_GetValue03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+ const std::string defValue = ((const std::string) tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetValue(keyID,valueID,defValue);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)defValue);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_GetValue02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValueI of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueI00
+static int tolua_AllToLua_cIniFile_GetValueI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const int defValue = ((const int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueI'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetValueI(keyname,valuename,defValue);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetValueI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValueB of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueB00
+static int tolua_AllToLua_cIniFile_GetValueB00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const bool defValue = ((const bool) tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueB'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->GetValueB(keyname,valuename,defValue);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetValueB'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetValueF of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueF00
+static int tolua_AllToLua_cIniFile_GetValueF00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const double defValue = ((const double) tolua_tonumber(tolua_S,4,0.0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueF'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->GetValueF(keyname,valuename,defValue);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetValueF'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetValue00
+static int tolua_AllToLua_cIniFile_SetValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+ const std::string value = ((const std::string) tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValue'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->SetValue(keyID,valueID,value);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)value);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetValue01
+static int tolua_AllToLua_cIniFile_SetValue01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const std::string value = ((const std::string) tolua_tocppstring(tolua_S,4,0));
+ const bool create = ((const bool) tolua_toboolean(tolua_S,5,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValue'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->SetValue(keyname,valuename,value,create);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ tolua_pushcppstring(tolua_S,(const char*)value);
+ }
+ }
+ return 4;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_SetValue00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValueI of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetValueI00
+static int tolua_AllToLua_cIniFile_SetValueI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const int value = ((const int) tolua_tonumber(tolua_S,4,0));
+ const bool create = ((const bool) tolua_toboolean(tolua_S,5,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValueI'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->SetValueI(keyname,valuename,value,create);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetValueI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValueB of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetValueB00
+static int tolua_AllToLua_cIniFile_SetValueB00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const bool value = ((const bool) tolua_toboolean(tolua_S,4,0));
+ const bool create = ((const bool) tolua_toboolean(tolua_S,5,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValueB'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->SetValueB(keyname,valuename,value,create);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetValueB'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValueF of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_SetValueF00
+static int tolua_AllToLua_cIniFile_SetValueF00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+ const double value = ((const double) tolua_tonumber(tolua_S,4,0));
+ const bool create = ((const bool) tolua_toboolean(tolua_S,5,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValueF'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->SetValueF(keyname,valuename,value,create);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetValueF'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteValue of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteValue00
+static int tolua_AllToLua_cIniFile_DeleteValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteValue'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteValue(keyname,valuename);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)valuename);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteKey of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteKey00
+static int tolua_AllToLua_cIniFile_DeleteKey00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteKey'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteKey(keyname);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteKey'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumHeaderComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumHeaderComments00
+static int tolua_AllToLua_cIniFile_NumHeaderComments00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumHeaderComments'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumHeaderComments();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NumHeaderComments'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HeaderComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_HeaderComment00
+static int tolua_AllToLua_cIniFile_HeaderComment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string comment = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HeaderComment'", NULL);
+#endif
+ {
+ self->HeaderComment(comment);
+ tolua_pushcppstring(tolua_S,(const char*)comment);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'HeaderComment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HeaderComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_HeaderComment01
+static int tolua_AllToLua_cIniFile_HeaderComment01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned commentID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HeaderComment'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->HeaderComment(commentID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_HeaderComment00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteHeaderComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteHeaderComment00
+static int tolua_AllToLua_cIniFile_DeleteHeaderComment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ unsigned commentID = ((unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteHeaderComment'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteHeaderComment(commentID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteHeaderComment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteHeaderComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteHeaderComments00
+static int tolua_AllToLua_cIniFile_DeleteHeaderComments00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteHeaderComments'", NULL);
+#endif
+ {
+ self->DeleteHeaderComments();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteHeaderComments'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumKeyComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumKeyComments00
+static int tolua_AllToLua_cIniFile_NumKeyComments00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumKeyComments'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumKeyComments(keyID);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NumKeyComments'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NumKeyComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_NumKeyComments01
+static int tolua_AllToLua_cIniFile_NumKeyComments01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NumKeyComments'", NULL);
+#endif
+ {
+ unsigned tolua_ret = (unsigned) self->NumKeyComments(keyname);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_NumKeyComments00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_KeyComment00
+static int tolua_AllToLua_cIniFile_KeyComment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const std::string comment = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KeyComment'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->KeyComment(keyID,comment);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)comment);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'KeyComment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_KeyComment01
+static int tolua_AllToLua_cIniFile_KeyComment01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const std::string comment = ((const std::string) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KeyComment'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->KeyComment(keyname,comment);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ tolua_pushcppstring(tolua_S,(const char*)comment);
+ }
+ }
+ return 3;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_KeyComment00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_KeyComment02
+static int tolua_AllToLua_cIniFile_KeyComment02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned commentID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KeyComment'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->KeyComment(keyID,commentID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_KeyComment01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_KeyComment03
+static int tolua_AllToLua_cIniFile_KeyComment03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const unsigned commentID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KeyComment'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->KeyComment(keyname,commentID);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_KeyComment02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteKeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteKeyComment00
+static int tolua_AllToLua_cIniFile_DeleteKeyComment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned commentID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteKeyComment'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteKeyComment(keyID,commentID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteKeyComment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteKeyComment of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteKeyComment01
+static int tolua_AllToLua_cIniFile_DeleteKeyComment01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ const unsigned commentID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteKeyComment'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteKeyComment(keyname,commentID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_DeleteKeyComment00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteKeyComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteKeyComments00
+static int tolua_AllToLua_cIniFile_DeleteKeyComments00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteKeyComments'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteKeyComments(keyID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteKeyComments'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DeleteKeyComments of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteKeyComments01
+static int tolua_AllToLua_cIniFile_DeleteKeyComments01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteKeyComments'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteKeyComments(keyname);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)keyname);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_DeleteKeyComments00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: g_BlockLightValue */
+#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue
+static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)g_BlockLightValue[tolua_index]);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: g_BlockLightValue */
+#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockLightValue
+static int tolua_set_AllToLua_g_BlockLightValue(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ g_BlockLightValue[tolua_index] = ((char) tolua_tonumber(tolua_S,3,0));
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: g_BlockSpreadLightFalloff */
+#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockSpreadLightFalloff
+static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)g_BlockSpreadLightFalloff[tolua_index]);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: g_BlockSpreadLightFalloff */
+#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockSpreadLightFalloff
+static int tolua_set_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ g_BlockSpreadLightFalloff[tolua_index] = ((char) tolua_tonumber(tolua_S,3,0));
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: g_BlockTransparent */
+#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockTransparent
+static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ tolua_pushboolean(tolua_S,(bool)g_BlockTransparent[tolua_index]);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: g_BlockTransparent */
+#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockTransparent
+static int tolua_set_AllToLua_g_BlockTransparent(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ g_BlockTransparent[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0));
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: g_BlockOneHitDig */
+#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockOneHitDig
+static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ tolua_pushboolean(tolua_S,(bool)g_BlockOneHitDig[tolua_index]);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: g_BlockOneHitDig */
+#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockOneHitDig
+static int tolua_set_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
+{
+ int tolua_index;
+#ifndef TOLUA_RELEASE
+ {
+ tolua_Error tolua_err;
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ }
+#endif
+ tolua_index = (int)tolua_tonumber(tolua_S,2,0);
+#ifndef TOLUA_RELEASE
+ if (tolua_index<0)
+ tolua_error(tolua_S,"array indexing out of range.",NULL);
+#endif
+ g_BlockOneHitDig[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0));
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: IsValidBlock */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_IsValidBlock00
+static int tolua_AllToLua_IsValidBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isnumber(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_BlockID = ((int) tolua_tonumber(tolua_S,1,0));
+ {
+ bool tolua_ret = (bool) IsValidBlock(a_BlockID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsValidBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: isValidItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_isValidItem00
+static int tolua_AllToLua_isValidItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isnumber(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_ItemID = ((int) tolua_tonumber(tolua_S,1,0));
+ {
+ bool tolua_ret = (bool) isValidItem(a_ItemID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isValidItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: AddDirection */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_AddDirection00
+static int tolua_AllToLua_AddDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isnumber(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_X = ((int) tolua_tonumber(tolua_S,1,0));
+ char a_Y = ((char) tolua_tonumber(tolua_S,2,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,3,0));
+ char a_Direction = ((char) tolua_tonumber(tolua_S,4,0));
+ bool a_bInverse = ((bool) tolua_toboolean(tolua_S,5,false));
+ {
+ AddDirection(a_X,a_Y,a_Z,a_Direction,a_bInverse);
+ tolua_pushnumber(tolua_S,(lua_Number)a_X);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Y);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Z);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: GetTime */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_GetTime00
+static int tolua_AllToLua_GetTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isnoobj(tolua_S,1,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ unsigned int tolua_ret = (unsigned int) GetTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: GetChar */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_GetChar00
+static int tolua_AllToLua_GetChar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ std::string a_Str = ((std::string) tolua_tocppstring(tolua_S,1,0));
+ unsigned int a_Idx = ((unsigned int) tolua_tonumber(tolua_S,2,0));
+ {
+ std::string tolua_ret = (std::string) GetChar(a_Str,a_Idx);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_Str);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetChar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clear of class cStringMap */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cStringMap_clear00
+static int tolua_AllToLua_cStringMap_clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cStringMap",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cStringMap* self = (cStringMap*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clear'", NULL);
+#endif
+ {
+ self->clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: size of class cStringMap */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cStringMap_size00
+static int tolua_AllToLua_cStringMap_size00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cStringMap",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cStringMap* self = (const cStringMap*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'size'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->size();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'size'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: get of class cStringMap */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cStringMap_get00
+static int tolua_AllToLua_cStringMap_get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cStringMap",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cStringMap* self = (cStringMap*) tolua_tousertype(tolua_S,1,0);
+ const std::string index = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->get(index);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)index);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Color of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Color
+static int tolua_get_cChatColor_Color(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Color);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Black of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Black
+static int tolua_get_cChatColor_Black(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Black);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Navy of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Navy
+static int tolua_get_cChatColor_Navy(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Navy);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Green of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Green
+static int tolua_get_cChatColor_Green(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Green);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Blue of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Blue
+static int tolua_get_cChatColor_Blue(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Blue);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Red of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Red
+static int tolua_get_cChatColor_Red(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Red);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Purple of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Purple
+static int tolua_get_cChatColor_Purple(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Purple);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Gold of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Gold
+static int tolua_get_cChatColor_Gold(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Gold);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: LightGray of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_LightGray
+static int tolua_get_cChatColor_LightGray(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::LightGray);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Gray of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Gray
+static int tolua_get_cChatColor_Gray(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Gray);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: DarkPurple of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_DarkPurple
+static int tolua_get_cChatColor_DarkPurple(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::DarkPurple);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: LightGreen of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_LightGreen
+static int tolua_get_cChatColor_LightGreen(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::LightGreen);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: LightBlue of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_LightBlue
+static int tolua_get_cChatColor_LightBlue(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::LightBlue);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Rose of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Rose
+static int tolua_get_cChatColor_Rose(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Rose);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: LightPurple of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_LightPurple
+static int tolua_get_cChatColor_LightPurple(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::LightPurple);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Yellow of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Yellow
+static int tolua_get_cChatColor_Yellow(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Yellow);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: White of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_White
+static int tolua_get_cChatColor_White(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::White);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: MakeColor of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cChatColor_MakeColor00
+static int tolua_AllToLua_cChatColor_MakeColor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cChatColor",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char a_Color = ((char) tolua_tonumber(tolua_S,2,0));
+ {
+ const std::string tolua_ret = (const std::string) cChatColor::MakeColor(a_Color);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'MakeColor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPlayer of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_GetPlayer00
+static int tolua_AllToLua_cClientHandle_GetPlayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cClientHandle",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cClientHandle* self = (cClientHandle*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPlayer'", NULL);
+#endif
+ {
+ cPlayer* tolua_ret = (cPlayer*) self->GetPlayer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPlayer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPlayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Kick of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_Kick00
+static int tolua_AllToLua_cClientHandle_Kick00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cClientHandle",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cClientHandle* self = (cClientHandle*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Reason = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Kick'", NULL);
+#endif
+ {
+ self->Kick(a_Reason);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Kick'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_delete00
+static int tolua_AllToLua_cEntity_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Initialize of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_Initialize00
+static int tolua_AllToLua_cEntity_Initialize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL);
+#endif
+ {
+ self->Initialize();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Initialize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetEntityType of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetEntityType00
+static int tolua_AllToLua_cEntity_GetEntityType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEntityType'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->GetEntityType();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetEntityType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsA of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsA00
+static int tolua_AllToLua_cEntity_IsA00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const char* a_EntityType = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsA'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsA(a_EntityType);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsA'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetClass of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetClass00
+static int tolua_AllToLua_cEntity_GetClass00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetClass'", NULL);
+#endif
+ {
+ const char* tolua_ret = (const char*) self->GetClass();
+ tolua_pushstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetClass'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPosition of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPosition00
+static int tolua_AllToLua_cEntity_GetPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosition'", NULL);
+#endif
+ {
+ const Vector3d& tolua_ret = (const Vector3d&) self->GetPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const Vector3d");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPosX of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPosX00
+static int tolua_AllToLua_cEntity_GetPosX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosX'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetPosX();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPosX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPosY of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPosY00
+static int tolua_AllToLua_cEntity_GetPosY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosY'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetPosY();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPosY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPosZ of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPosZ00
+static int tolua_AllToLua_cEntity_GetPosZ00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosZ'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetPosZ();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPosZ'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetRot of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetRot00
+static int tolua_AllToLua_cEntity_GetRot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRot'", NULL);
+#endif
+ {
+ const Vector3f& tolua_ret = (const Vector3f&) self->GetRot();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const Vector3f");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetRot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetRotation of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetRotation00
+static int tolua_AllToLua_cEntity_GetRotation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRotation'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->GetRotation();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetRotation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPitch of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPitch00
+static int tolua_AllToLua_cEntity_GetPitch00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPitch'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->GetPitch();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPitch'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetRoll of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetRoll00
+static int tolua_AllToLua_cEntity_GetRoll00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRoll'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->GetRoll();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetRoll'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetLookVector of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetLookVector00
+static int tolua_AllToLua_cEntity_GetLookVector00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLookVector'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->GetLookVector();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetLookVector'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPosX of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPosX00
+static int tolua_AllToLua_cEntity_SetPosX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosX'", NULL);
+#endif
+ {
+ self->SetPosX(a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPosX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPosY of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPosY00
+static int tolua_AllToLua_cEntity_SetPosY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosY'", NULL);
+#endif
+ {
+ self->SetPosY(a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPosY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPosZ of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPosZ00
+static int tolua_AllToLua_cEntity_SetPosZ00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosZ'", NULL);
+#endif
+ {
+ self->SetPosZ(a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPosZ'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPosition of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPosition00
+static int tolua_AllToLua_cEntity_SetPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosition'", NULL);
+#endif
+ {
+ self->SetPosition(a_PosX,a_PosY,a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPosition of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPosition01
+static int tolua_AllToLua_cEntity_SetPosition01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* a_Pos = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosition'", NULL);
+#endif
+ {
+ self->SetPosition(*a_Pos);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_cEntity_SetPosition00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetRot of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetRot00
+static int tolua_AllToLua_cEntity_SetRot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* a_Rot = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRot'", NULL);
+#endif
+ {
+ self->SetRot(*a_Rot);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetRot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetRotation of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetRotation00
+static int tolua_AllToLua_cEntity_SetRotation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ float a_Rotation = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRotation'", NULL);
+#endif
+ {
+ self->SetRotation(a_Rotation);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetRotation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetPitch of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetPitch00
+static int tolua_AllToLua_cEntity_SetPitch00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ float a_Pitch = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPitch'", NULL);
+#endif
+ {
+ self->SetPitch(a_Pitch);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetPitch'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetRoll of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SetRoll00
+static int tolua_AllToLua_cEntity_SetRoll00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ float a_Roll = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRoll'", NULL);
+#endif
+ {
+ self->SetRoll(a_Roll);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetRoll'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetUniqueID of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetUniqueID00
+static int tolua_AllToLua_cEntity_GetUniqueID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetUniqueID'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetUniqueID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetUniqueID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsDestroyed of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsDestroyed00
+static int tolua_AllToLua_cEntity_IsDestroyed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsDestroyed'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsDestroyed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsDestroyed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Destroy of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_Destroy00
+static int tolua_AllToLua_cEntity_Destroy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Destroy'", NULL);
+#endif
+ {
+ self->Destroy();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Destroy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Tick of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_Tick00
+static int tolua_AllToLua_cEntity_Tick00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ float a_Dt = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Tick'", NULL);
+#endif
+ {
+ self->Tick(a_Dt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Tick'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SpawnOn of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_SpawnOn00
+static int tolua_AllToLua_cEntity_SpawnOn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cClientHandle",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ cClientHandle* a_Target = ((cClientHandle*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SpawnOn'", NULL);
+#endif
+ {
+ self->SpawnOn(a_Target);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SpawnOn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cEntity : public cEntity, public ToluaBase {
+public:
+ void Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ return ( void ) cEntity:: Initialize();
+ };
+ };
+ unsigned int GetEntityType( void ) {
+ if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return (unsigned int ) cEntity:: GetEntityType();
+ };
+ };
+ bool IsA( const char* a_EntityType) {
+ if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
+ tolua_pushstring(lua_state, (const char*)a_EntityType);
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cEntity:: IsA(a_EntityType);
+ };
+ };
+ const char* GetClass( void ) {
+ if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( const char* ) cEntity:: GetClass();
+ };
+ };
+ void Tick( float a_Dt) {
+ if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Dt);
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cEntity::Tick not implemented.");
+ else {
+ LOG("pure-virtual method cEntity::Tick called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+ void SpawnOn( cClientHandle* a_Target) {
+ if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
+ tolua_pushusertype(lua_state, (void*)a_Target, "cClientHandle");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cEntity::SpawnOn not implemented.");
+ else {
+ LOG("pure-virtual method cEntity::SpawnOn called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ void cEntity__Initialize( void ) {
+ return ( void )cEntity::Initialize();
+ };
+ unsigned int cEntity__GetEntityType( void ) {
+ return (unsigned int )cEntity::GetEntityType();
+ };
+ bool cEntity__IsA( const char* a_EntityType) {
+ return ( bool )cEntity::IsA(a_EntityType);
+ };
+ const char* cEntity__GetClass( void ) {
+ return ( const char* )cEntity::GetClass();
+ };
+ Lua__cEntity( const double& a_X, const double& a_Y, const double& a_Z): cEntity(a_X,a_Y,a_Z){};
+};
+
+/* method: tolua__set_instance of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_tolua__set_instance00
+static int tolua_AllToLua_Lua__cEntity_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cEntity__Initialize of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__Initialize00
+static int tolua_AllToLua_Lua__cEntity_cEntity__Initialize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__Initialize'", NULL);
+#endif
+ {
+ self->cEntity__Initialize();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cEntity__Initialize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cEntity__GetEntityType of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00
+static int tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__GetEntityType'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->cEntity__GetEntityType();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cEntity__GetEntityType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cEntity__IsA of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__IsA00
+static int tolua_AllToLua_Lua__cEntity_cEntity__IsA00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+ const char* a_EntityType = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__IsA'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cEntity__IsA(a_EntityType);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cEntity__IsA'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cEntity__GetClass of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__GetClass00
+static int tolua_AllToLua_Lua__cEntity_cEntity__GetClass00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__GetClass'", NULL);
+#endif
+ {
+ const char* tolua_ret = (const char*) self->cEntity__GetClass();
+ tolua_pushstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cEntity__GetClass'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_new00
+static int tolua_AllToLua_Lua__cEntity_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const double a_X = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_Y = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_Z = ((const double) tolua_tonumber(tolua_S,4,0));
+ {
+ Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity");
+ tolua_pushnumber(tolua_S,(lua_Number)a_X);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Y);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Z);
+ }
+ }
+ return 4;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_new00_local
+static int tolua_AllToLua_Lua__cEntity_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const double a_X = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_Y = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_Z = ((const double) tolua_tonumber(tolua_S,4,0));
+ {
+ Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ tolua_pushnumber(tolua_S,(lua_Number)a_X);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Y);
+ tolua_pushnumber(tolua_S,(lua_Number)a_Z);
+ }
+ }
+ return 4;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class Lua__cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_delete00
+static int tolua_AllToLua_Lua__cEntity_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cEntity (lua_State* tolua_S)
+{
+ Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* get function: Damage of class TakeDamageInfo */
+#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Damage
+static int tolua_get_TakeDamageInfo_Damage(lua_State* tolua_S)
+{
+ TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Damage'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->Damage);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Damage of class TakeDamageInfo */
+#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Damage
+static int tolua_set_TakeDamageInfo_Damage(lua_State* tolua_S)
+{
+ TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Damage'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Damage = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Instigator of class TakeDamageInfo */
+#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Instigator_ptr
+static int tolua_get_TakeDamageInfo_Instigator_ptr(lua_State* tolua_S)
+{
+ TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Instigator'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->Instigator,"cEntity");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Instigator of class TakeDamageInfo */
+#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Instigator_ptr
+static int tolua_set_TakeDamageInfo_Instigator_ptr(lua_State* tolua_S)
+{
+ TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Instigator'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Instigator = ((cEntity*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TeleportTo of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TeleportTo00
+static int tolua_AllToLua_cPawn_TeleportTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Entity = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL);
+#endif
+ {
+ self->TeleportTo(a_Entity);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'TeleportTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TeleportTo of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TeleportTo01
+static int tolua_AllToLua_cPawn_TeleportTo01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL);
+#endif
+ {
+ self->TeleportTo(a_PosX,a_PosY,a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 3;
+tolua_lerror:
+ return tolua_AllToLua_cPawn_TeleportTo00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Heal of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_Heal00
+static int tolua_AllToLua_cPawn_Heal00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+ int a_Health = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Heal'", NULL);
+#endif
+ {
+ self->Heal(a_Health);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Heal'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TakeDamage of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TakeDamage00
+static int tolua_AllToLua_cPawn_TakeDamage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+ int a_Damage = ((int) tolua_tonumber(tolua_S,2,0));
+ cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL);
+#endif
+ {
+ self->TakeDamage(a_Damage,a_Instigator);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'TakeDamage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KilledBy of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_KilledBy00
+static int tolua_AllToLua_cPawn_KilledBy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KilledBy'", NULL);
+#endif
+ {
+ self->KilledBy(a_Killer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'KilledBy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetHealth of class cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetHealth00
+static int tolua_AllToLua_cPawn_GetHealth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHealth'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetHealth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetHealth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cPawn : public cPawn, public ToluaBase {
+public:
+ void TeleportTo( cEntity* a_Entity) {
+ if (push_method("TeleportTo", tolua_AllToLua_cPawn_TeleportTo00)) {
+ tolua_pushusertype(lua_state, (void*)a_Entity, "cEntity");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPawn:: TeleportTo(a_Entity);
+ };
+ };
+ void TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) {
+ if (push_method("TeleportTo", tolua_AllToLua_cPawn_TeleportTo01)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_PosX);
+ tolua_pushnumber(lua_state, (lua_Number)a_PosY);
+ tolua_pushnumber(lua_state, (lua_Number)a_PosZ);
+ ToluaBase::dbcall(lua_state, 4, 0);
+ } else {
+ return ( void ) cPawn:: TeleportTo(a_PosX,a_PosY,a_PosZ);
+ };
+ };
+ void TakeDamage( int a_Damage, cEntity* a_Instigator) {
+ if (push_method("TakeDamage", tolua_AllToLua_cPawn_TakeDamage00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Damage);
+ tolua_pushusertype(lua_state, (void*)a_Instigator, "cEntity");
+ ToluaBase::dbcall(lua_state, 3, 0);
+ } else {
+ return ( void ) cPawn:: TakeDamage(a_Damage,a_Instigator);
+ };
+ };
+ void KilledBy( cEntity* a_Killer) {
+ if (push_method("KilledBy", tolua_AllToLua_cPawn_KilledBy00)) {
+ tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPawn:: KilledBy(a_Killer);
+ };
+ };
+ void Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ return ( void ) cPawn:: Initialize();
+ };
+ };
+ unsigned int GetEntityType( void ) {
+ if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return (unsigned int ) cPawn:: GetEntityType();
+ };
+ };
+ bool IsA( const char* a_EntityType) {
+ if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
+ tolua_pushstring(lua_state, (const char*)a_EntityType);
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPawn:: IsA(a_EntityType);
+ };
+ };
+ const char* GetClass( void ) {
+ if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( const char* ) cPawn:: GetClass();
+ };
+ };
+ void Tick( float a_Dt) {
+ if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Dt);
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPawn::Tick not implemented.");
+ else {
+ LOG("pure-virtual method cPawn::Tick called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+ void SpawnOn( cClientHandle* a_Target) {
+ if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
+ tolua_pushusertype(lua_state, (void*)a_Target, "cClientHandle");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPawn::SpawnOn not implemented.");
+ else {
+ LOG("pure-virtual method cPawn::SpawnOn called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ void cPawn__TeleportTo( cEntity* a_Entity) {
+ return ( void )cPawn::TeleportTo(a_Entity);
+ };
+ void cPawn__TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) {
+ return ( void )cPawn::TeleportTo(a_PosX,a_PosY,a_PosZ);
+ };
+ void cPawn__TakeDamage( int a_Damage, cEntity* a_Instigator) {
+ return ( void )cPawn::TakeDamage(a_Damage,a_Instigator);
+ };
+ void cPawn__KilledBy( cEntity* a_Killer) {
+ return ( void )cPawn::KilledBy(a_Killer);
+ };
+ void cPawn__Initialize( void ) {
+ return ( void )cPawn::Initialize();
+ };
+ unsigned int cPawn__GetEntityType( void ) {
+ return (unsigned int )cPawn::GetEntityType();
+ };
+ bool cPawn__IsA( const char* a_EntityType) {
+ return ( bool )cPawn::IsA(a_EntityType);
+ };
+ const char* cPawn__GetClass( void ) {
+ return ( const char* )cPawn::GetClass();
+ };
+};
+
+/* method: tolua__set_instance of class Lua__cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_tolua__set_instance00
+static int tolua_AllToLua_Lua__cPawn_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPawn__TeleportTo of class Lua__cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00
+static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Entity = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TeleportTo'", NULL);
+#endif
+ {
+ self->cPawn__TeleportTo(a_Entity);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPawn__TeleportTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPawn__TeleportTo of class Lua__cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo01
+static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TeleportTo'", NULL);
+#endif
+ {
+ self->cPawn__TeleportTo(a_PosX,a_PosY,a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 3;
+tolua_lerror:
+ return tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPawn__TakeDamage of class Lua__cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00
+static int tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0);
+ int a_Damage = ((int) tolua_tonumber(tolua_S,2,0));
+ cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TakeDamage'", NULL);
+#endif
+ {
+ self->cPawn__TakeDamage(a_Damage,a_Instigator);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPawn__TakeDamage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPawn__KilledBy of class Lua__cPawn */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00
+static int tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__KilledBy'", NULL);
+#endif
+ {
+ self->cPawn__KilledBy(a_Killer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPawn__KilledBy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetEyeHeight of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetEyeHeight00
+static int tolua_AllToLua_cPlayer_GetEyeHeight00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEyeHeight'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->GetEyeHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetEyeHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetEyePosition of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetEyePosition00
+static int tolua_AllToLua_cPlayer_GetEyePosition00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEyePosition'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->GetEyePosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetEyePosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetFlying of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetFlying00
+static int tolua_AllToLua_cPlayer_GetFlying00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFlying'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->GetFlying();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetFlying'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetStance of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetStance00
+static int tolua_AllToLua_cPlayer_GetStance00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetStance'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetStance();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetStance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetInventory of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetInventory00
+static int tolua_AllToLua_cPlayer_GetInventory00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetInventory'", NULL);
+#endif
+ {
+ cInventory& tolua_ret = (cInventory&) self->GetInventory();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cInventory");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetInventory'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TeleportTo of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TeleportTo00
+static int tolua_AllToLua_cPlayer_TeleportTo00(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,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Entity = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL);
+#endif
+ {
+ self->TeleportTo(a_Entity);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'TeleportTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TeleportTo of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TeleportTo01
+static int tolua_AllToLua_cPlayer_TeleportTo01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL);
+#endif
+ {
+ self->TeleportTo(a_PosX,a_PosY,a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 3;
+tolua_lerror:
+ return tolua_AllToLua_cPlayer_TeleportTo00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: MoveTo of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_MoveTo00
+static int tolua_AllToLua_cPlayer_MoveTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* a_NewPos = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'MoveTo'", NULL);
+#endif
+ {
+ self->MoveTo(*a_NewPos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'MoveTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetClientHandle of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetClientHandle00
+static int tolua_AllToLua_cPlayer_GetClientHandle00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetClientHandle'", NULL);
+#endif
+ {
+ cClientHandle* tolua_ret = (cClientHandle*) self->GetClientHandle();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cClientHandle");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetClientHandle'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SendMessage of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SendMessage00
+static int tolua_AllToLua_cPlayer_SendMessage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_Message = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendMessage'", NULL);
+#endif
+ {
+ self->SendMessage(a_Message);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SendMessage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetName of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetName00
+static int tolua_AllToLua_cPlayer_GetName00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL);
+#endif
+ {
+ const char* tolua_ret = (const char*) self->GetName();
+ tolua_pushstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetName of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetName00
+static int tolua_AllToLua_cPlayer_SetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_Name = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetName'", NULL);
+#endif
+ {
+ self->SetName(a_Name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddToGroup of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_AddToGroup00
+static int tolua_AllToLua_cPlayer_AddToGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_GroupName = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddToGroup'", NULL);
+#endif
+ {
+ self->AddToGroup(a_GroupName);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddToGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CanUseCommand of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_CanUseCommand00
+static int tolua_AllToLua_cPlayer_CanUseCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_Command = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CanUseCommand'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->CanUseCommand(a_Command);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CanUseCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HasPermission of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_HasPermission00
+static int tolua_AllToLua_cPlayer_HasPermission00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_Permission = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HasPermission'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->HasPermission(a_Permission);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'HasPermission'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsInGroup of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsInGroup00
+static int tolua_AllToLua_cPlayer_IsInGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isstring(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);
+ const char* a_Group = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsInGroup'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsInGroup(a_Group);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsInGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetColor of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetColor00
+static int tolua_AllToLua_cPlayer_GetColor00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetColor'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetColor();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetColor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TossItem of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TossItem00
+static int tolua_AllToLua_cPlayer_TossItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ bool a_bDraggingItem = ((bool) tolua_toboolean(tolua_S,2,0));
+ int a_Amount = ((int) tolua_tonumber(tolua_S,3,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TossItem'", NULL);
+#endif
+ {
+ self->TossItem(a_bDraggingItem,a_Amount);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'TossItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Heal of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Heal00
+static int tolua_AllToLua_cPlayer_Heal00(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 a_Health = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Heal'", NULL);
+#endif
+ {
+ self->Heal(a_Health);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Heal'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: TakeDamage of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TakeDamage00
+static int tolua_AllToLua_cPlayer_TakeDamage00(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_isusertype(tolua_S,3,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ int a_Damage = ((int) tolua_tonumber(tolua_S,2,0));
+ cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL);
+#endif
+ {
+ self->TakeDamage(a_Damage,a_Instigator);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'TakeDamage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: KilledBy of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_KilledBy00
+static int tolua_AllToLua_cPlayer_KilledBy00(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,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KilledBy'", NULL);
+#endif
+ {
+ self->KilledBy(a_Killer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'KilledBy'.",&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)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"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);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Respawn'", NULL);
+#endif
+ {
+ self->Respawn();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Respawn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetVisible of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetVisible00
+static int tolua_AllToLua_cPlayer_SetVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isboolean(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);
+ bool a_bVisible = ((bool) tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetVisible'", NULL);
+#endif
+ {
+ self->SetVisible(a_bVisible);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsVisible of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsVisible00
+static int tolua_AllToLua_cPlayer_IsVisible00(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)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsVisible'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsVisible();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cPlayer : public cPlayer, public ToluaBase {
+public:
+ void TeleportTo( cEntity* a_Entity) {
+ if (push_method("TeleportTo", tolua_AllToLua_cPlayer_TeleportTo00)) {
+ tolua_pushusertype(lua_state, (void*)a_Entity, "cEntity");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlayer:: TeleportTo(a_Entity);
+ };
+ };
+ void TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) {
+ if (push_method("TeleportTo", tolua_AllToLua_cPlayer_TeleportTo01)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_PosX);
+ tolua_pushnumber(lua_state, (lua_Number)a_PosY);
+ tolua_pushnumber(lua_state, (lua_Number)a_PosZ);
+ ToluaBase::dbcall(lua_state, 4, 0);
+ } else {
+ return ( void ) cPlayer:: TeleportTo(a_PosX,a_PosY,a_PosZ);
+ };
+ };
+ void MoveTo( const Vector3d& a_NewPos) {
+ if (push_method("MoveTo", tolua_AllToLua_cPlayer_MoveTo00)) {
+ tolua_pushusertype(lua_state, (void*)&a_NewPos, "const Vector3d");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlayer:: MoveTo(a_NewPos);
+ };
+ };
+ void TakeDamage( int a_Damage, cEntity* a_Instigator) {
+ if (push_method("TakeDamage", tolua_AllToLua_cPawn_TakeDamage00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Damage);
+ tolua_pushusertype(lua_state, (void*)a_Instigator, "cEntity");
+ ToluaBase::dbcall(lua_state, 3, 0);
+ } else {
+ return ( void ) cPlayer:: TakeDamage(a_Damage,a_Instigator);
+ };
+ };
+ void KilledBy( cEntity* a_Killer) {
+ if (push_method("KilledBy", tolua_AllToLua_cPawn_KilledBy00)) {
+ tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlayer:: KilledBy(a_Killer);
+ };
+ };
+ void Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ return ( void ) cPlayer:: Initialize();
+ };
+ };
+ unsigned int GetEntityType( void ) {
+ if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return (unsigned int ) cPlayer:: GetEntityType();
+ };
+ };
+ bool IsA( const char* a_EntityType) {
+ if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
+ tolua_pushstring(lua_state, (const char*)a_EntityType);
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlayer:: IsA(a_EntityType);
+ };
+ };
+ const char* GetClass( void ) {
+ if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( const char* ) cPlayer:: GetClass();
+ };
+ };
+ void Tick( float a_Dt) {
+ if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Dt);
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPlayer::Tick not implemented.");
+ else {
+ LOG("pure-virtual method cPlayer::Tick called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+ void SpawnOn( cClientHandle* a_Target) {
+ if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
+ tolua_pushusertype(lua_state, (void*)a_Target, "cClientHandle");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPlayer::SpawnOn not implemented.");
+ else {
+ LOG("pure-virtual method cPlayer::SpawnOn called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ void cPlayer__TeleportTo( cEntity* a_Entity) {
+ return ( void )cPlayer::TeleportTo(a_Entity);
+ };
+ void cPlayer__TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) {
+ return ( void )cPlayer::TeleportTo(a_PosX,a_PosY,a_PosZ);
+ };
+ void cPlayer__MoveTo( const Vector3d& a_NewPos) {
+ return ( void )cPlayer::MoveTo(a_NewPos);
+ };
+ void cPlayer__TakeDamage( int a_Damage, cEntity* a_Instigator) {
+ return ( void )cPlayer::TakeDamage(a_Damage,a_Instigator);
+ };
+ void cPlayer__KilledBy( cEntity* a_Killer) {
+ return ( void )cPlayer::KilledBy(a_Killer);
+ };
+ void cPlayer__Initialize( void ) {
+ return ( void )cPlayer::Initialize();
+ };
+ unsigned int cPlayer__GetEntityType( void ) {
+ return (unsigned int )cPlayer::GetEntityType();
+ };
+ bool cPlayer__IsA( const char* a_EntityType) {
+ return ( bool )cPlayer::IsA(a_EntityType);
+ };
+ const char* cPlayer__GetClass( void ) {
+ return ( const char* )cPlayer::GetClass();
+ };
+};
+
+/* method: tolua__set_instance of class Lua__cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_tolua__set_instance00
+static int tolua_AllToLua_Lua__cPlayer_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlayer* self = (Lua__cPlayer*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlayer__TeleportTo of class Lua__cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00
+static int tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlayer* self = (Lua__cPlayer*) tolua_tousertype(tolua_S,1,0);
+ cEntity* a_Entity = ((cEntity*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlayer__TeleportTo'", NULL);
+#endif
+ {
+ self->cPlayer__TeleportTo(a_Entity);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlayer__TeleportTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlayer__TeleportTo of class Lua__cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo01
+static int tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlayer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ Lua__cPlayer* self = (Lua__cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0));
+ const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0));
+ const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlayer__TeleportTo'", NULL);
+#endif
+ {
+ self->cPlayer__TeleportTo(a_PosX,a_PosY,a_PosZ);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_PosZ);
+ }
+ }
+ return 3;
+tolua_lerror:
+ return tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlayer__MoveTo of class Lua__cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00
+static int tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlayer",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlayer* self = (Lua__cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* a_NewPos = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlayer__MoveTo'", NULL);
+#endif
+ {
+ self->cPlayer__MoveTo(*a_NewPos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlayer__MoveTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPluginManager of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_GetPluginManager00
+static int tolua_AllToLua_cPluginManager_GetPluginManager00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cPluginManager* tolua_ret = (cPluginManager*) cPluginManager::GetPluginManager();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPluginManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPluginManager'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPlugin of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_GetPlugin00
+static int tolua_AllToLua_cPluginManager_GetPlugin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Plugin = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPlugin'", NULL);
+#endif
+ {
+ cPlugin* tolua_ret = (cPlugin*) self->GetPlugin(a_Plugin);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPlugin");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPlugin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ReloadPlugins of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_ReloadPlugins00
+static int tolua_AllToLua_cPluginManager_ReloadPlugins00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ReloadPlugins'", NULL);
+#endif
+ {
+ self->ReloadPlugins();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ReloadPlugins'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddPlugin of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_AddPlugin00
+static int tolua_AllToLua_cPluginManager_AddPlugin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ lua_State* a_LuaState = tolua_S;
+ cPlugin* a_Plugin = ((cPlugin*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddPlugin'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->AddPlugin(a_LuaState,a_Plugin);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddPlugin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddHook of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_AddHook00
+static int tolua_AllToLua_cPluginManager_AddHook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ cPlugin* a_Plugin = ((cPlugin*) tolua_tousertype(tolua_S,2,0));
+ cPluginManager::PluginHook a_Hook = ((cPluginManager::PluginHook) (int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddHook'", NULL);
+#endif
+ {
+ self->AddHook(a_Plugin,a_Hook);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddHook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetNumPlugins of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_GetNumPlugins00
+static int tolua_AllToLua_cPluginManager_GetNumPlugins00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNumPlugins'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->GetNumPlugins();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetNumPlugins'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: RemovePlugin of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_RemovePlugin00
+static int tolua_AllToLua_cPluginManager_RemovePlugin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlugin",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ cPlugin* a_Plugin = ((cPlugin*) tolua_tousertype(tolua_S,2,0));
+ bool a_bDelete = ((bool) tolua_toboolean(tolua_S,3,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RemovePlugin'", NULL);
+#endif
+ {
+ self->RemovePlugin(a_Plugin,a_bDelete);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'RemovePlugin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: RemoveLuaPlugin of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_RemoveLuaPlugin00
+static int tolua_AllToLua_cPluginManager_RemoveLuaPlugin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ std::string a_FileName = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RemoveLuaPlugin'", NULL);
+#endif
+ {
+ self->RemoveLuaPlugin(a_FileName);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'RemoveLuaPlugin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetLuaPlugin of class cPluginManager */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_GetLuaPlugin00
+static int tolua_AllToLua_cPluginManager_GetLuaPlugin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPluginManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ lua_State* a_State = tolua_S;
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLuaPlugin'", NULL);
+#endif
+ {
+ cPlugin_Lua* tolua_ret = (cPlugin_Lua*) self->GetLuaPlugin(a_State);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPlugin_Lua");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetLuaPlugin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_delete00
+static int tolua_AllToLua_cPlugin_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnDisable of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnDisable00
+static int tolua_AllToLua_cPlugin_OnDisable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnDisable'", NULL);
+#endif
+ {
+ self->OnDisable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnDisable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Initialize of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_Initialize00
+static int tolua_AllToLua_cPlugin_Initialize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Initialize();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Initialize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Tick of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_Tick00
+static int tolua_AllToLua_cPlugin_Tick00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ float a_Dt = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Tick'", NULL);
+#endif
+ {
+ self->Tick(a_Dt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Tick'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnCollectItem of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnCollectItem00
+static int tolua_AllToLua_cPlugin_OnCollectItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnCollectItem'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnCollectItem(a_Pickup,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnCollectItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnDisconnect of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnDisconnect00
+static int tolua_AllToLua_cPlugin_OnDisconnect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Reason = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnDisconnect'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnDisconnect(a_Reason,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnDisconnect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnBlockPlace of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockPlace00
+static int tolua_AllToLua_cPlugin_OnBlockPlace00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_BlockPlace",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_BlockPlace* a_PacketData = ((cPacket_BlockPlace*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockPlace'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnBlockPlace(a_PacketData,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnBlockPlace'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnBlockDig of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockDig00
+static int tolua_AllToLua_cPlugin_OnBlockDig00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_BlockDig* a_PacketData = ((cPacket_BlockDig*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+ cItem* a_PickupItem = ((cItem*) tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockDig'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnBlockDig(a_PacketData,a_Player,a_PickupItem);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnBlockDig'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnChat of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChat00
+static int tolua_AllToLua_cPlugin_OnChat00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Chat = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChat'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnChat(a_Chat,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnChat'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnLogin of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnLogin00
+static int tolua_AllToLua_cPlugin_OnLogin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_Login",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_Login* a_PacketData = ((cPacket_Login*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnLogin'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnLogin(a_PacketData);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnLogin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnPlayerSpawn of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerSpawn00
+static int tolua_AllToLua_cPlugin_OnPlayerSpawn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerSpawn'", NULL);
+#endif
+ {
+ self->OnPlayerSpawn(a_Player);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnPlayerSpawn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnPlayerJoin of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerJoin00
+static int tolua_AllToLua_cPlugin_OnPlayerJoin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerJoin'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnPlayerJoin(a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnPlayerJoin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnPlayerMove of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerMove00
+static int tolua_AllToLua_cPlugin_OnPlayerMove00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerMove'", NULL);
+#endif
+ {
+ self->OnPlayerMove(a_Player);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnPlayerMove'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnTakeDamage of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnTakeDamage00
+static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0));
+ TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnTakeDamage'", NULL);
+#endif
+ {
+ self->OnTakeDamage(a_Pawn,a_TakeDamageInfo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnTakeDamage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: OnKilled of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnKilled00
+static int tolua_AllToLua_cPlugin_OnKilled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPawn* a_Killed = ((cPawn*) tolua_tousertype(tolua_S,2,0));
+ cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnKilled'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnKilled(a_Killed,a_Killer);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnKilled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetName of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_GetName00
+static int tolua_AllToLua_cPlugin_GetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlugin* self = (const cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetName of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_SetName00
+static int tolua_AllToLua_cPlugin_SetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Name = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetName'", NULL);
+#endif
+ {
+ self->SetName(a_Name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetVersion of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_GetVersion00
+static int tolua_AllToLua_cPlugin_GetVersion00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlugin* self = (const cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetVersion'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetVersion();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetVersion'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetVersion of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_SetVersion00
+static int tolua_AllToLua_cPlugin_SetVersion00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ int a_Version = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetVersion'", NULL);
+#endif
+ {
+ self->SetVersion(a_Version);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetVersion'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Command of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_get_cPlugin__CommandStruct_Command
+static int tolua_get_cPlugin__CommandStruct_Command(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Command'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Command);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Command of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_set_cPlugin__CommandStruct_Command
+static int tolua_set_cPlugin__CommandStruct_Command(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Command'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Command = ((std::string) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Description of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_get_cPlugin__CommandStruct_Description
+static int tolua_get_cPlugin__CommandStruct_Description(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Description'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Description);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Description of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_set_cPlugin__CommandStruct_Description
+static int tolua_set_cPlugin__CommandStruct_Description(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Description'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Description = ((std::string) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Permission of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_get_cPlugin__CommandStruct_Permission
+static int tolua_get_cPlugin__CommandStruct_Permission(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Permission'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Permission);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Permission of class CommandStruct */
+#ifndef TOLUA_DISABLE_tolua_set_cPlugin__CommandStruct_Permission
+static int tolua_set_cPlugin__CommandStruct_Permission(lua_State* tolua_S)
+{
+ cPlugin::CommandStruct* self = (cPlugin::CommandStruct*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Permission'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Permission = ((std::string) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddCommand of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_AddCommand00
+static int tolua_AllToLua_cPlugin_AddCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Command = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ std::string a_Description = ((std::string) tolua_tocppstring(tolua_S,3,0));
+ std::string a_Permission = ((std::string) tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddCommand'", NULL);
+#endif
+ {
+ self->AddCommand(a_Command,a_Description,a_Permission);
+ tolua_pushcppstring(tolua_S,(const char*)a_Command);
+ tolua_pushcppstring(tolua_S,(const char*)a_Description);
+ tolua_pushcppstring(tolua_S,(const char*)a_Permission);
+ }
+ }
+ return 3;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cPlugin : public cPlugin, public ToluaBase {
+public:
+ void OnDisable( void ) {
+ if (push_method("OnDisable", tolua_AllToLua_cPlugin_OnDisable00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ return ( void ) cPlugin:: OnDisable();
+ };
+ };
+ bool Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cPlugin_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPlugin::Initialize not implemented.");
+ else {
+ LOG("pure-virtual method cPlugin::Initialize called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( bool )0;
+ };
+ };
+ void Tick( float a_Dt) {
+ if (push_method("Tick", tolua_AllToLua_cPlugin_Tick00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Dt);
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlugin:: Tick(a_Dt);
+ };
+ };
+ bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) {
+ if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) {
+ tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup");
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 3, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnCollectItem(a_Pickup,a_Player);
+ };
+ };
+ bool OnDisconnect( std::string a_Reason, cPlayer* a_Player) {
+ if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) {
+ tolua_pushcppstring(lua_state, (const char*)a_Reason);
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 3, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnDisconnect(a_Reason,a_Player);
+ };
+ };
+ bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) {
+ if (push_method("OnBlockPlace", tolua_AllToLua_cPlugin_OnBlockPlace00)) {
+ tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockPlace");
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 3, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnBlockPlace(a_PacketData,a_Player);
+ };
+ };
+ bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) {
+ if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) {
+ tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockDig");
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ tolua_pushusertype(lua_state, (void*)a_PickupItem, "cItem");
+ ToluaBase::dbcall(lua_state, 4, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnBlockDig(a_PacketData,a_Player,a_PickupItem);
+ };
+ };
+ bool OnChat( std::string a_Chat, cPlayer* a_Player) {
+ if (push_method("OnChat", tolua_AllToLua_cPlugin_OnChat00)) {
+ tolua_pushcppstring(lua_state, (const char*)a_Chat);
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 3, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnChat(a_Chat,a_Player);
+ };
+ };
+ bool OnLogin( cPacket_Login* a_PacketData) {
+ if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) {
+ tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_Login");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnLogin(a_PacketData);
+ };
+ };
+ void OnPlayerSpawn( cPlayer* a_Player) {
+ if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) {
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlugin:: OnPlayerSpawn(a_Player);
+ };
+ };
+ bool OnPlayerJoin( cPlayer* a_Player) {
+ if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) {
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnPlayerJoin(a_Player);
+ };
+ };
+ void OnPlayerMove( cPlayer* a_Player) {
+ if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) {
+ tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ return ( void ) cPlugin:: OnPlayerMove(a_Player);
+ };
+ };
+ void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) {
+ if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) {
+ tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn");
+ tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo");
+ ToluaBase::dbcall(lua_state, 3, 0);
+ } else {
+ return ( void ) cPlugin:: OnTakeDamage(a_Pawn,a_TakeDamageInfo);
+ };
+ };
+ bool OnKilled( cPawn* a_Killed, cEntity* a_Killer) {
+ if (push_method("OnKilled", tolua_AllToLua_cPlugin_OnKilled00)) {
+ tolua_pushusertype(lua_state, (void*)a_Killed, "cPawn");
+ tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity");
+ ToluaBase::dbcall(lua_state, 3, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnKilled(a_Killed,a_Killer);
+ };
+ };
+
+ void cPlugin__OnDisable( void ) {
+ return ( void )cPlugin::OnDisable();
+ };
+ void cPlugin__Tick( float a_Dt) {
+ return ( void )cPlugin::Tick(a_Dt);
+ };
+ bool cPlugin__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) {
+ return ( bool )cPlugin::OnCollectItem(a_Pickup,a_Player);
+ };
+ bool cPlugin__OnDisconnect( std::string a_Reason, cPlayer* a_Player) {
+ return ( bool )cPlugin::OnDisconnect(a_Reason,a_Player);
+ };
+ bool cPlugin__OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) {
+ return ( bool )cPlugin::OnBlockPlace(a_PacketData,a_Player);
+ };
+ bool cPlugin__OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) {
+ return ( bool )cPlugin::OnBlockDig(a_PacketData,a_Player,a_PickupItem);
+ };
+ bool cPlugin__OnChat( std::string a_Chat, cPlayer* a_Player) {
+ return ( bool )cPlugin::OnChat(a_Chat,a_Player);
+ };
+ bool cPlugin__OnLogin( cPacket_Login* a_PacketData) {
+ return ( bool )cPlugin::OnLogin(a_PacketData);
+ };
+ void cPlugin__OnPlayerSpawn( cPlayer* a_Player) {
+ return ( void )cPlugin::OnPlayerSpawn(a_Player);
+ };
+ bool cPlugin__OnPlayerJoin( cPlayer* a_Player) {
+ return ( bool )cPlugin::OnPlayerJoin(a_Player);
+ };
+ void cPlugin__OnPlayerMove( cPlayer* a_Player) {
+ return ( void )cPlugin::OnPlayerMove(a_Player);
+ };
+ void cPlugin__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) {
+ return ( void )cPlugin::OnTakeDamage(a_Pawn,a_TakeDamageInfo);
+ };
+ bool cPlugin__OnKilled( cPawn* a_Killed, cEntity* a_Killer) {
+ return ( bool )cPlugin::OnKilled(a_Killed,a_Killer);
+ };
+ Lua__cPlugin( void ): cPlugin(){};
+};
+
+/* method: tolua__set_instance of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_tolua__set_instance00
+static int tolua_AllToLua_Lua__cPlugin_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnDisable of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisable00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnDisable'", NULL);
+#endif
+ {
+ self->cPlugin__OnDisable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnDisable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__Tick of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__Tick00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__Tick00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ float a_Dt = ((float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__Tick'", NULL);
+#endif
+ {
+ self->cPlugin__Tick(a_Dt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__Tick'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnCollectItem of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnCollectItem'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnCollectItem(a_Pickup,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnCollectItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnDisconnect of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Reason = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnDisconnect'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnDisconnect(a_Reason,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnDisconnect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnBlockPlace of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_BlockPlace",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_BlockPlace* a_PacketData = ((cPacket_BlockPlace*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockPlace'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnBlockPlace(a_PacketData,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockPlace'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnBlockDig of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_BlockDig* a_PacketData = ((cPacket_BlockDig*) tolua_tousertype(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+ cItem* a_PickupItem = ((cItem*) tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockDig'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnBlockDig(a_PacketData,a_Player,a_PickupItem);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockDig'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnChat of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChat00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChat00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Chat = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChat'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnChat(a_Chat,a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChat'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnLogin of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_Login",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPacket_Login* a_PacketData = ((cPacket_Login*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnLogin'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnLogin(a_PacketData);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnLogin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnPlayerSpawn of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerSpawn'", NULL);
+#endif
+ {
+ self->cPlugin__OnPlayerSpawn(a_Player);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerSpawn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnPlayerJoin of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerJoin'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnPlayerJoin(a_Player);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerJoin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnPlayerMove of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerMove'", NULL);
+#endif
+ {
+ self->cPlugin__OnPlayerMove(a_Player);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerMove'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnTakeDamage of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0));
+ TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnTakeDamage'", NULL);
+#endif
+ {
+ self->cPlugin__OnTakeDamage(a_Pawn,a_TakeDamageInfo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnTakeDamage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPlugin__OnKilled of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPawn* a_Killed = ((cPawn*) tolua_tousertype(tolua_S,2,0));
+ cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnKilled'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnKilled(a_Killed,a_Killer);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnKilled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_new00
+static int tolua_AllToLua_Lua__cPlugin_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cPlugin* tolua_ret = (Lua__cPlugin*) Mtolua_new((Lua__cPlugin)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPlugin");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_new00_local
+static int tolua_AllToLua_Lua__cPlugin_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cPlugin* tolua_ret = (Lua__cPlugin*) Mtolua_new((Lua__cPlugin)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPlugin");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_delete00
+static int tolua_AllToLua_Lua__cPlugin_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cPlugin (lua_State* tolua_S)
+{
+ Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* method: GetFileName of class cPlugin_Lua */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_Lua_GetFileName00
+static int tolua_AllToLua_cPlugin_Lua_GetFileName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin_Lua",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlugin_Lua* self = (cPlugin_Lua*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFileName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetFileName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetFileName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetServer of class cServer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cServer_GetServer00
+static int tolua_AllToLua_cServer_GetServer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cServer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cServer* tolua_ret = (cServer*) cServer::GetServer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cServer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetServer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ServerCommand of class cServer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cServer_ServerCommand00
+static int tolua_AllToLua_cServer_ServerCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cServer",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cServer* self = (cServer*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Cmd = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ServerCommand'", NULL);
+#endif
+ {
+ self->ServerCommand(a_Cmd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ServerCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SendMessage of class cServer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cServer_SendMessage00
+static int tolua_AllToLua_cServer_SendMessage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cServer",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"cPlayer",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cServer* self = (cServer*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Message = ((const char*) tolua_tostring(tolua_S,2,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
+ bool a_bExclude = ((bool) tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendMessage'", NULL);
+#endif
+ {
+ self->SendMessage(a_Message,a_Player,a_bExclude);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SendMessage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWorld of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetWorld00
+static int tolua_AllToLua_cWorld_GetWorld00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cWorld* tolua_ret = (cWorld*) cWorld::GetWorld();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cWorld");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWorld'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetTime of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetTime00
+static int tolua_AllToLua_cWorld_GetTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ float tolua_ret = (float) cWorld::GetTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetWorldTime of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetWorldTime00
+static int tolua_AllToLua_cWorld_SetWorldTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ long long a_WorldTime = ((long long) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetWorldTime'", NULL);
+#endif
+ {
+ self->SetWorldTime(a_WorldTime);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetWorldTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetHeight of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetHeight00
+static int tolua_AllToLua_cWorld_GetHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHeight'", NULL);
+#endif
+ {
+ char tolua_ret = (char) self->GetHeight(a_X,a_Z);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetNumPlayers of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetNumPlayers00
+static int tolua_AllToLua_cWorld_GetNumPlayers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNumPlayers'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->GetNumPlayers();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetNumPlayers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPlayer of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetPlayer00
+static int tolua_AllToLua_cWorld_GetPlayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ const char* a_PlayerName = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPlayer'", NULL);
+#endif
+ {
+ cPlayer* tolua_ret = (cPlayer*) self->GetPlayer(a_PlayerName);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPlayer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPlayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetEntity of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetEntity00
+static int tolua_AllToLua_cWorld_GetEntity00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_UniqueID = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEntity'", NULL);
+#endif
+ {
+ cEntity* tolua_ret = (cEntity*) self->GetEntity(a_UniqueID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cEntity");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetEntity'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetBlock of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetBlock00
+static int tolua_AllToLua_cWorld_SetBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
+ char a_BlockMeta = ((char) tolua_tonumber(tolua_S,6,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlock'", NULL);
+#endif
+ {
+ self->SetBlock(a_X,a_Y,a_Z,a_BlockType,a_BlockMeta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: FastSetBlock of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_FastSetBlock00
+static int tolua_AllToLua_cWorld_FastSetBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
+ char a_BlockMeta = ((char) tolua_tonumber(tolua_S,6,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FastSetBlock'", NULL);
+#endif
+ {
+ self->FastSetBlock(a_X,a_Y,a_Z,a_BlockType,a_BlockMeta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'FastSetBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetBlock of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlock00
+static int tolua_AllToLua_cWorld_GetBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlock'", NULL);
+#endif
+ {
+ char tolua_ret = (char) self->GetBlock(a_X,a_Y,a_Z);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetBlockMeta of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlockMeta00
+static int tolua_AllToLua_cWorld_GetBlockMeta00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockMeta'", NULL);
+#endif
+ {
+ char tolua_ret = (char) self->GetBlockMeta(a_X,a_Y,a_Z);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetBlockMeta'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetBlockMeta of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetBlockMeta00
+static int tolua_AllToLua_cWorld_SetBlockMeta00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ char a_MetaData = ((char) tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlockMeta'", NULL);
+#endif
+ {
+ self->SetBlockMeta(a_X,a_Y,a_Z,a_MetaData);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetBlockMeta'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DigBlock of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_DigBlock00
+static int tolua_AllToLua_cWorld_DigBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ cItem* a_PickupItem = ((cItem*) tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DigBlock'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DigBlock(a_X,a_Y,a_Z,*a_PickupItem);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DigBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SendBlockTo of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SendBlockTo00
+static int tolua_AllToLua_cWorld_SendBlockTo00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendBlockTo'", NULL);
+#endif
+ {
+ self->SendBlockTo(a_X,a_Y,a_Z,a_Player);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SendBlockTo'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetSpawnX of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetSpawnX00
+static int tolua_AllToLua_cWorld_GetSpawnX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnX'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetSpawnX();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetSpawnX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetSpawnY of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetSpawnY00
+static int tolua_AllToLua_cWorld_GetSpawnY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnY'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetSpawnY();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetSpawnY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetSpawnZ of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetSpawnZ00
+static int tolua_AllToLua_cWorld_GetSpawnZ00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnZ'", NULL);
+#endif
+ {
+ const double tolua_ret = (const double) self->GetSpawnZ();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetSpawnZ'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetBlockEntity of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlockEntity00
+static int tolua_AllToLua_cWorld_GetBlockEntity00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockEntity'", NULL);
+#endif
+ {
+ cBlockEntity* tolua_ret = (cBlockEntity*) self->GetBlockEntity(a_X,a_Y,a_Z);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cBlockEntity");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetBlockEntity'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GrowTree of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GrowTree00
+static int tolua_AllToLua_cWorld_GrowTree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowTree'", NULL);
+#endif
+ {
+ self->GrowTree(a_X,a_Y,a_Z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GrowTree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWorldSeed of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetWorldSeed00
+static int tolua_AllToLua_cWorld_GetWorldSeed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWorldSeed'", NULL);
+#endif
+ {
+ unsigned int tolua_ret = (unsigned int) self->GetWorldSeed();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWorldSeed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Clear of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_Clear00
+static int tolua_AllToLua_cInventory_Clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+#endif
+ {
+ self->Clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddItem of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_AddItem00
+static int tolua_AllToLua_cInventory_AddItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ cItem* a_Item = ((cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddItem'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->AddItem(*a_Item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: RemoveItem of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_RemoveItem00
+static int tolua_AllToLua_cInventory_RemoveItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ cItem* a_Item = ((cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RemoveItem'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->RemoveItem(*a_Item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'RemoveItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetSlot of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetSlot00
+static int tolua_AllToLua_cInventory_GetSlot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSlot'", NULL);
+#endif
+ {
+ cItem* tolua_ret = (cItem*) self->GetSlot(a_SlotNum);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetSlot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetFromHotBar of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetFromHotBar00
+static int tolua_AllToLua_cInventory_GetFromHotBar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFromHotBar'", NULL);
+#endif
+ {
+ cItem* tolua_ret = (cItem*) self->GetFromHotBar(a_SlotNum);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetFromHotBar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetEquippedItem of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetEquippedItem00
+static int tolua_AllToLua_cInventory_GetEquippedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedItem'", NULL);
+#endif
+ {
+ cItem& tolua_ret = (cItem&) self->GetEquippedItem();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetEquippedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetEquippedSlot of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_SetEquippedSlot00
+static int tolua_AllToLua_cInventory_SetEquippedSlot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetEquippedSlot'", NULL);
+#endif
+ {
+ self->SetEquippedSlot(a_SlotNum);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetEquippedSlot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SendSlot of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_SendSlot00
+static int tolua_AllToLua_cInventory_SendSlot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendSlot'", NULL);
+#endif
+ {
+ self->SendSlot(a_SlotNum);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SendSlot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_new00
+static int tolua_AllToLua_cItem_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ ENUM_ITEM_ID a_ItemID = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,E_ITEM_EMPTY));
+ char a_ItemCount = ((char) tolua_tonumber(tolua_S,3,0));
+ short a_ItemHealth = ((short) tolua_tonumber(tolua_S,4,0));
+ {
+ cItem* tolua_ret = (cItem*) Mtolua_new((cItem)(a_ItemID,a_ItemCount,a_ItemHealth));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_new00_local
+static int tolua_AllToLua_cItem_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ ENUM_ITEM_ID a_ItemID = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,E_ITEM_EMPTY));
+ char a_ItemCount = ((char) tolua_tonumber(tolua_S,3,0));
+ short a_ItemHealth = ((short) tolua_tonumber(tolua_S,4,0));
+ {
+ cItem* tolua_ret = (cItem*) Mtolua_new((cItem)(a_ItemID,a_ItemCount,a_ItemHealth));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Empty of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_Empty00
+static int tolua_AllToLua_cItem_Empty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Empty'", NULL);
+#endif
+ {
+ self->Empty();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Empty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsEmpty of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_IsEmpty00
+static int tolua_AllToLua_cItem_IsEmpty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsEmpty'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsEmpty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsEmpty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Equals of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_Equals00
+static int tolua_AllToLua_cItem_Equals00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+ cItem* a_Item = ((cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Equals'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Equals(*a_Item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Equals'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_ItemID of class cItem */
+#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemID
+static int tolua_get_cItem_m_ItemID(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemID'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemID);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ItemID of class cItem */
+#ifndef TOLUA_DISABLE_tolua_set_cItem_m_ItemID
+static int tolua_set_cItem_m_ItemID(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemID'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ItemID = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_ItemCount of class cItem */
+#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemCount
+static int tolua_get_cItem_m_ItemCount(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemCount'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemCount);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ItemCount of class cItem */
+#ifndef TOLUA_DISABLE_tolua_set_cItem_m_ItemCount
+static int tolua_set_cItem_m_ItemCount(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemCount'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ItemCount = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_ItemHealth of class cItem */
+#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemHealth
+static int tolua_get_cItem_m_ItemHealth(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemHealth'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemHealth);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ItemHealth of class cItem */
+#ifndef TOLUA_DISABLE_tolua_set_cItem_m_ItemHealth
+static int tolua_set_cItem_m_ItemHealth(lua_State* tolua_S)
+{
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemHealth'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ItemHealth = ((short) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Method of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_get_HTTPRequest_Method
+static int tolua_get_HTTPRequest_Method(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Method'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Method);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Method of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_set_HTTPRequest_Method
+static int tolua_set_HTTPRequest_Method(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Method'",NULL);
+ 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))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Path of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_get_HTTPRequest_Path
+static int tolua_get_HTTPRequest_Path(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Path'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Path);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Path of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_set_HTTPRequest_Path
+static int tolua_set_HTTPRequest_Path(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Path'",NULL);
+ 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))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Params of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_get_HTTPRequest_Params_ptr
+static int tolua_get_HTTPRequest_Params_ptr(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Params'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->Params,"cStringMap");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Params of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_set_HTTPRequest_Params_ptr
+static int tolua_set_HTTPRequest_Params_ptr(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Params'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"cStringMap",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Params = ((cStringMap*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Username of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_get_HTTPRequest_Username
+static int tolua_get_HTTPRequest_Username(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Username'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Username);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Username of class HTTPRequest */
+#ifndef TOLUA_DISABLE_tolua_set_HTTPRequest_Username
+static int tolua_set_HTTPRequest_Username(lua_State* tolua_S)
+{
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Username'",NULL);
+ 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))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_delete00
+static int tolua_AllToLua_cWebPlugin_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetName of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_SetName00
+static int tolua_AllToLua_cWebPlugin_SetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Name = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetName'", NULL);
+#endif
+ {
+ self->SetName(a_Name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetName of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_GetName00
+static int tolua_AllToLua_cWebPlugin_GetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HandleRequest of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_HandleRequest00
+static int tolua_AllToLua_cWebPlugin_HandleRequest00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"HTTPRequest",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ HTTPRequest* a_Request = ((HTTPRequest*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HandleRequest'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->HandleRequest(a_Request);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'HandleRequest'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Initialize of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_Initialize00
+static int tolua_AllToLua_cWebPlugin_Initialize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL);
+#endif
+ {
+ self->Initialize();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Initialize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cWebPlugin : public cWebPlugin, public ToluaBase {
+public:
+ std::string HandleRequest( HTTPRequest* a_Request) {
+ if (push_method("HandleRequest", tolua_AllToLua_cWebPlugin_HandleRequest00)) {
+ tolua_pushusertype(lua_state, (void*)a_Request, "HTTPRequest");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ std::string tolua_ret = ( std::string )tolua_tocppstring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cWebPlugin::HandleRequest not implemented.");
+ else {
+ LOG("pure-virtual method cWebPlugin::HandleRequest called with no lua_state. Aborting");
+ ::abort();
+ };
+ return "";
+ };
+ };
+ void Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cWebPlugin_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cWebPlugin::Initialize not implemented.");
+ else {
+ LOG("pure-virtual method cWebPlugin::Initialize called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ Lua__cWebPlugin( lua_State* L): cWebPlugin(L){};
+};
+
+/* method: tolua__set_instance of class Lua__cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00
+static int tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cWebPlugin* self = (Lua__cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_new00
+static int tolua_AllToLua_Lua__cWebPlugin_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ lua_State* L = tolua_S;
+ {
+ Lua__cWebPlugin* tolua_ret = (Lua__cWebPlugin*) Mtolua_new((Lua__cWebPlugin)(L));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cWebPlugin");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_new00_local
+static int tolua_AllToLua_Lua__cWebPlugin_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ lua_State* L = tolua_S;
+ {
+ Lua__cWebPlugin* tolua_ret = (Lua__cWebPlugin*) Mtolua_new((Lua__cWebPlugin)(L));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cWebPlugin");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class Lua__cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_delete00
+static int tolua_AllToLua_Lua__cWebPlugin_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cWebPlugin* self = (Lua__cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cWebPlugin (lua_State* tolua_S)
+{
+ Lua__cWebPlugin* self = (Lua__cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* method: new of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new00
+static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,8,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,9,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
+ float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
+ float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
+ float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
+ {
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new00_local
+static int tolua_AllToLua_cPickup_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,8,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,9,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
+ float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
+ float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
+ float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
+ {
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new01
+static int tolua_AllToLua_cPickup_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
+ {
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_PickupSpawnPacket));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cPickup_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new01_local
+static int tolua_AllToLua_cPickup_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
+ {
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_PickupSpawnPacket));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cPickup_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_delete00
+static int tolua_AllToLua_cPickup_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPickup* self = (cPickup*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetItem of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_GetItem00
+static int tolua_AllToLua_cPickup_GetItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPickup* self = (cPickup*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+#endif
+ {
+ cItem* tolua_ret = (cItem*) self->GetItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CollectedBy of class cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_CollectedBy00
+static int tolua_AllToLua_cPickup_CollectedBy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPickup* self = (cPickup*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Dest = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CollectedBy'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->CollectedBy(a_Dest);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CollectedBy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cPickup : public cPickup, public ToluaBase {
+public:
+ bool CollectedBy( cPlayer* a_Dest) {
+ if (push_method("CollectedBy", tolua_AllToLua_cPickup_CollectedBy00)) {
+ tolua_pushusertype(lua_state, (void*)a_Dest, "cPlayer");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPickup:: CollectedBy(a_Dest);
+ };
+ };
+ void Initialize( void ) {
+ if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
+ ToluaBase::dbcall(lua_state, 1, 0);
+ } else {
+ return ( void ) cPickup:: Initialize();
+ };
+ };
+ unsigned int GetEntityType( void ) {
+ if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return (unsigned int ) cPickup:: GetEntityType();
+ };
+ };
+ bool IsA( const char* a_EntityType) {
+ if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
+ tolua_pushstring(lua_state, (const char*)a_EntityType);
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPickup:: IsA(a_EntityType);
+ };
+ };
+ const char* GetClass( void ) {
+ if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( const char* ) cPickup:: GetClass();
+ };
+ };
+ void Tick( float a_Dt) {
+ if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) {
+ tolua_pushnumber(lua_state, (lua_Number)a_Dt);
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPickup::Tick not implemented.");
+ else {
+ LOG("pure-virtual method cPickup::Tick called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+ void SpawnOn( cClientHandle* a_Target) {
+ if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
+ tolua_pushusertype(lua_state, (void*)a_Target, "cClientHandle");
+ ToluaBase::dbcall(lua_state, 2, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cPickup::SpawnOn not implemented.");
+ else {
+ LOG("pure-virtual method cPickup::SpawnOn called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ bool cPickup__CollectedBy( cPlayer* a_Dest) {
+ return ( bool )cPickup::CollectedBy(a_Dest);
+ };
+ void cPickup__Initialize( void ) {
+ return ( void )cPickup::Initialize();
+ };
+ unsigned int cPickup__GetEntityType( void ) {
+ return (unsigned int )cPickup::GetEntityType();
+ };
+ bool cPickup__IsA( const char* a_EntityType) {
+ return ( bool )cPickup::IsA(a_EntityType);
+ };
+ const char* cPickup__GetClass( void ) {
+ return ( const char* )cPickup::GetClass();
+ };
+ Lua__cPickup( int a_X, int a_Y, int a_Z, const cItem& a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f): cPickup(a_X,a_Y,a_Z,a_Item,a_SpeedX,a_SpeedY,a_SpeedZ){};
+ Lua__cPickup( cPacket_PickupSpawn* a_PickupSpawnPacket): cPickup(a_PickupSpawnPacket){};
+};
+
+/* method: tolua__set_instance of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_tolua__set_instance00
+static int tolua_AllToLua_Lua__cPickup_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPickup* self = (Lua__cPickup*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPickup__CollectedBy of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_cPickup__CollectedBy00
+static int tolua_AllToLua_Lua__cPickup_cPickup__CollectedBy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPickup* self = (Lua__cPickup*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* a_Dest = ((cPlayer*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPickup__CollectedBy'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPickup__CollectedBy(a_Dest);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPickup__CollectedBy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new00
+static int tolua_AllToLua_Lua__cPickup_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"cItem",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,8,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,9,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
+ float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
+ float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
+ float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
+ {
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new00_local
+static int tolua_AllToLua_Lua__cPickup_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"cItem",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,8,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,9,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_X = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
+ float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
+ float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
+ float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
+ {
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new01
+static int tolua_AllToLua_Lua__cPickup_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
+ {
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_PickupSpawnPacket));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Lua__cPickup_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new01_local
+static int tolua_AllToLua_Lua__cPickup_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
+ {
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_PickupSpawnPacket));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Lua__cPickup_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class Lua__cPickup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_delete00
+static int tolua_AllToLua_Lua__cPickup_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPickup* self = (Lua__cPickup*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cPickup (lua_State* tolua_S)
+{
+ Lua__cPickup* self = (Lua__cPickup*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* method: Get of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_Get00
+static int tolua_AllToLua_cRoot_Get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cRoot* tolua_ret = (cRoot*) cRoot::Get();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cRoot");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetServer of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetServer00
+static int tolua_AllToLua_cRoot_GetServer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetServer'", NULL);
+#endif
+ {
+ cServer* tolua_ret = (cServer*) self->GetServer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cServer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetServer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWorld of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetWorld00
+static int tolua_AllToLua_cRoot_GetWorld00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWorld'", NULL);
+#endif
+ {
+ cWorld* tolua_ret = (cWorld*) self->GetWorld();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cWorld");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWorld'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetGroupManager of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetGroupManager00
+static int tolua_AllToLua_cRoot_GetGroupManager00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetGroupManager'", NULL);
+#endif
+ {
+ cGroupManager* tolua_ret = (cGroupManager*) self->GetGroupManager();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cGroupManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetGroupManager'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetRecipeChecker of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetRecipeChecker00
+static int tolua_AllToLua_cRoot_GetRecipeChecker00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRecipeChecker'", NULL);
+#endif
+ {
+ cRecipeChecker* tolua_ret = (cRecipeChecker*) self->GetRecipeChecker();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cRecipeChecker");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetRecipeChecker'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetFurnaceRecipe of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetFurnaceRecipe00
+static int tolua_AllToLua_cRoot_GetFurnaceRecipe00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFurnaceRecipe'", NULL);
+#endif
+ {
+ cFurnaceRecipe* tolua_ret = (cFurnaceRecipe*) self->GetFurnaceRecipe();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cFurnaceRecipe");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetFurnaceRecipe'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWebAdmin of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetWebAdmin00
+static int tolua_AllToLua_cRoot_GetWebAdmin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWebAdmin'", NULL);
+#endif
+ {
+ cWebAdmin* tolua_ret = (cWebAdmin*) self->GetWebAdmin();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cWebAdmin");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWebAdmin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPluginManager of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetPluginManager00
+static int tolua_AllToLua_cRoot_GetPluginManager00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPluginManager'", NULL);
+#endif
+ {
+ cPluginManager* tolua_ret = (cPluginManager*) self->GetPluginManager();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPluginManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPluginManager'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ServerCommand of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_ServerCommand00
+static int tolua_AllToLua_cRoot_ServerCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Cmd = ((const char*) tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ServerCommand'", NULL);
+#endif
+ {
+ self->ServerCommand(a_Cmd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ServerCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTCPLink_delete00
+static int tolua_AllToLua_cTCPLink_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTCPLink* self = (cTCPLink*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Connect of class cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTCPLink_Connect00
+static int tolua_AllToLua_cTCPLink_Connect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTCPLink",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTCPLink* self = (cTCPLink*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Address = ((const char*) tolua_tostring(tolua_S,2,0));
+ unsigned int a_Port = ((unsigned int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Connect'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Connect(a_Address,a_Port);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Connect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Send of class cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTCPLink_Send00
+static int tolua_AllToLua_cTCPLink_Send00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTCPLink",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTCPLink* self = (cTCPLink*) tolua_tousertype(tolua_S,1,0);
+ char* a_Data = ((char*) tolua_tostring(tolua_S,2,0));
+ unsigned int a_Size = ((unsigned int) tolua_tonumber(tolua_S,3,0));
+ int a_Flags = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Send'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->Send(a_Data,a_Size,a_Flags);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Send'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SendMessage of class cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTCPLink_SendMessage00
+static int tolua_AllToLua_cTCPLink_SendMessage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTCPLink",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTCPLink* self = (cTCPLink*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Message = ((const char*) tolua_tostring(tolua_S,2,0));
+ int a_Flags = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendMessage'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->SendMessage(a_Message,a_Flags);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SendMessage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CloseSocket of class cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTCPLink_CloseSocket00
+static int tolua_AllToLua_cTCPLink_CloseSocket00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTCPLink* self = (cTCPLink*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CloseSocket'", NULL);
+#endif
+ {
+ self->CloseSocket();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CloseSocket'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cTCPLink : public cTCPLink, public ToluaBase {
+public:
+ void ReceivedData( char* a_Data, int a_Size) {
+ if (push_method("ReceivedData", NULL)) {
+ tolua_pushstring(lua_state, (const char*)a_Data);
+ tolua_pushnumber(lua_state, (lua_Number)a_Size);
+ ToluaBase::dbcall(lua_state, 3, 0);
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cTCPLink::ReceivedData not implemented.");
+ else {
+ LOG("pure-virtual method cTCPLink::ReceivedData called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( void )0;
+ };
+ };
+
+ Lua__cTCPLink( void ): cTCPLink(){};
+};
+
+/* method: tolua__set_instance of class Lua__cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cTCPLink_tolua__set_instance00
+static int tolua_AllToLua_Lua__cTCPLink_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cTCPLink* self = (Lua__cTCPLink*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cTCPLink_new00
+static int tolua_AllToLua_Lua__cTCPLink_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cTCPLink* tolua_ret = (Lua__cTCPLink*) Mtolua_new((Lua__cTCPLink)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cTCPLink");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cTCPLink_new00_local
+static int tolua_AllToLua_Lua__cTCPLink_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cTCPLink* tolua_ret = (Lua__cTCPLink*) Mtolua_new((Lua__cTCPLink)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cTCPLink");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class Lua__cTCPLink */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cTCPLink_delete00
+static int tolua_AllToLua_Lua__cTCPLink_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cTCPLink",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cTCPLink* self = (Lua__cTCPLink*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cTCPLink (lua_State* tolua_S)
+{
+ Lua__cTCPLink* self = (Lua__cTCPLink*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new00
+static int tolua_AllToLua_Vector3f_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new00_local
+static int tolua_AllToLua_Vector3f_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new01
+static int tolua_AllToLua_Vector3f_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new01_local
+static int tolua_AllToLua_Vector3f_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new02
+static int tolua_AllToLua_Vector3f_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new02_local
+static int tolua_AllToLua_Vector3f_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new03
+static int tolua_AllToLua_Vector3f_new03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new03_local
+static int tolua_AllToLua_Vector3f_new03_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new02_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new04
+static int tolua_AllToLua_Vector3f_new04(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new03(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new04_local
+static int tolua_AllToLua_Vector3f_new04_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new03_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new05
+static int tolua_AllToLua_Vector3f_new05(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ float a_x = ((float) tolua_tonumber(tolua_S,2,0));
+ float a_y = ((float) tolua_tonumber(tolua_S,3,0));
+ float a_z = ((float) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new04(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_new05_local
+static int tolua_AllToLua_Vector3f_new05_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ float a_x = ((float) tolua_tonumber(tolua_S,2,0));
+ float a_y = ((float) tolua_tonumber(tolua_S,3,0));
+ float a_z = ((float) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3f* tolua_ret = (Vector3f*) Mtolua_new((Vector3f)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_new04_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Set of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Set00
+static int tolua_AllToLua_Vector3f_Set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+ float a_x = ((float) tolua_tonumber(tolua_S,2,0));
+ float a_y = ((float) tolua_tonumber(tolua_S,3,0));
+ float a_z = ((float) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Set'", NULL);
+#endif
+ {
+ self->Set(a_x,a_y,a_z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Normalize of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Normalize00
+static int tolua_AllToLua_Vector3f_Normalize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Normalize'", NULL);
+#endif
+ {
+ self->Normalize();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Normalize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NormalizeCopy of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_NormalizeCopy00
+static int tolua_AllToLua_Vector3f_NormalizeCopy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NormalizeCopy'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->NormalizeCopy();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NormalizeCopy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NormalizeCopy of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_NormalizeCopy01
+static int tolua_AllToLua_Vector3f_NormalizeCopy01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ Vector3f* a_V = ((Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NormalizeCopy'", NULL);
+#endif
+ {
+ self->NormalizeCopy(*a_V);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f_NormalizeCopy00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Length of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Length00
+static int tolua_AllToLua_Vector3f_Length00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Length'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->Length();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Length'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SqrLength of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_SqrLength00
+static int tolua_AllToLua_Vector3f_SqrLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SqrLength'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->SqrLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SqrLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Dot of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Dot00
+static int tolua_AllToLua_Vector3f_Dot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* a_V = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Dot'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->Dot(*a_V);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Dot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Cross of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Cross00
+static int tolua_AllToLua_Vector3f_Cross00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Cross'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->Cross(*v);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Cross'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Equals of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f_Equals00
+static int tolua_AllToLua_Vector3f_Equals00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Equals'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Equals(*v);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Equals'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__add00
+static int tolua_AllToLua_Vector3f__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v2 = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator+(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__add01
+static int tolua_AllToLua_Vector3f__add01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v2 = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator+(v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f__add00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__sub00
+static int tolua_AllToLua_Vector3f__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v2 = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator-(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__sub01
+static int tolua_AllToLua_Vector3f__sub01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v2 = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator-(v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f__sub00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__mul00
+static int tolua_AllToLua_Vector3f__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const float f = ((const float) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator*(f);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3f__mul01
+static int tolua_AllToLua_Vector3f__mul01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3f",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* self = (const Vector3f*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* v2 = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL);
+#endif
+ {
+ Vector3f tolua_ret = (Vector3f) self->operator*(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3f)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3f));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3f");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3f__mul00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: x of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3f_x
+static int tolua_get_Vector3f_x(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->x);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: x of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3f_x
+static int tolua_set_Vector3f_x(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->x = ((float) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: y of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3f_y
+static int tolua_get_Vector3f_y(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->y);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: y of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3f_y
+static int tolua_set_Vector3f_y(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->y = ((float) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: z of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3f_z
+static int tolua_get_Vector3f_z(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->z);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: z of class Vector3f */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3f_z
+static int tolua_set_Vector3f_z(lua_State* tolua_S)
+{
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->z = ((float) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new00
+static int tolua_AllToLua_Vector3d_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new00_local
+static int tolua_AllToLua_Vector3d_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new01
+static int tolua_AllToLua_Vector3d_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new01_local
+static int tolua_AllToLua_Vector3d_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3f* v = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new02
+static int tolua_AllToLua_Vector3d_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new02_local
+static int tolua_AllToLua_Vector3d_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new03
+static int tolua_AllToLua_Vector3d_new03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ double a_x = ((double) tolua_tonumber(tolua_S,2,0));
+ double a_y = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_z = ((double) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_new03_local
+static int tolua_AllToLua_Vector3d_new03_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ double a_x = ((double) tolua_tonumber(tolua_S,2,0));
+ double a_y = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_z = ((double) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3d* tolua_ret = (Vector3d*) Mtolua_new((Vector3d)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_new02_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Set of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_Set00
+static int tolua_AllToLua_Vector3d_Set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+ double a_x = ((double) tolua_tonumber(tolua_S,2,0));
+ double a_y = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_z = ((double) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Set'", NULL);
+#endif
+ {
+ self->Set(a_x,a_y,a_z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Normalize of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_Normalize00
+static int tolua_AllToLua_Vector3d_Normalize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Normalize'", NULL);
+#endif
+ {
+ self->Normalize();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Normalize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NormalizeCopy of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_NormalizeCopy00
+static int tolua_AllToLua_Vector3d_NormalizeCopy00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NormalizeCopy'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->NormalizeCopy();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NormalizeCopy'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: NormalizeCopy of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_NormalizeCopy01
+static int tolua_AllToLua_Vector3d_NormalizeCopy01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+ Vector3d* a_V = ((Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'NormalizeCopy'", NULL);
+#endif
+ {
+ self->NormalizeCopy(*a_V);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d_NormalizeCopy00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Length of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_Length00
+static int tolua_AllToLua_Vector3d_Length00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Length'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->Length();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Length'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SqrLength of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_SqrLength00
+static int tolua_AllToLua_Vector3d_SqrLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SqrLength'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->SqrLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SqrLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Dot of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_Dot00
+static int tolua_AllToLua_Vector3d_Dot00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* a_V = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Dot'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->Dot(*a_V);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Dot'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Cross of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d_Cross00
+static int tolua_AllToLua_Vector3d_Cross00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Cross'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->Cross(*v);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Cross'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__add00
+static int tolua_AllToLua_Vector3d__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v2 = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator+(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__add01
+static int tolua_AllToLua_Vector3d__add01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v2 = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator+(v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d__add00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__sub00
+static int tolua_AllToLua_Vector3d__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v2 = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator-(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__sub01
+static int tolua_AllToLua_Vector3d__sub01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v2 = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator-(v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d__sub00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__mul00
+static int tolua_AllToLua_Vector3d__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const double f = ((const double) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator*(f);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__mul01
+static int tolua_AllToLua_Vector3d__mul01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v2 = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->operator*(*v2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3d__mul00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: x of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3d_x
+static int tolua_get_Vector3d_x(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->x);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: x of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3d_x
+static int tolua_set_Vector3d_x(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->x = ((double) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: y of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3d_y
+static int tolua_get_Vector3d_y(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->y);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: y of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3d_y
+static int tolua_set_Vector3d_y(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->y = ((double) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: z of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3d_z
+static int tolua_get_Vector3d_z(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->z);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: z of class Vector3d */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3d_z
+static int tolua_set_Vector3d_z(lua_State* tolua_S)
+{
+ Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->z = ((double) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new00
+static int tolua_AllToLua_Vector3i_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new00_local
+static int tolua_AllToLua_Vector3i_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)(*v));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new01
+static int tolua_AllToLua_Vector3i_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3i_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new01_local
+static int tolua_AllToLua_Vector3i_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3i_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new02
+static int tolua_AllToLua_Vector3i_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ int a_x = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_z = ((int) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3i_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_new02_local
+static int tolua_AllToLua_Vector3i_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ int a_x = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_z = ((int) tolua_tonumber(tolua_S,4,0));
+ {
+ Vector3i* tolua_ret = (Vector3i*) Mtolua_new((Vector3i)(a_x,a_y,a_z));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3i");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3i_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Set of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_Set00
+static int tolua_AllToLua_Vector3i_Set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Vector3i",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+ int a_x = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_y = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_z = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Set'", NULL);
+#endif
+ {
+ self->Set(a_x,a_y,a_z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Length of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_Length00
+static int tolua_AllToLua_Vector3i_Length00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3i* self = (const Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Length'", NULL);
+#endif
+ {
+ float tolua_ret = (float) self->Length();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Length'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SqrLength of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_SqrLength00
+static int tolua_AllToLua_Vector3i_SqrLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3i* self = (const Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SqrLength'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->SqrLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SqrLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Equals of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_Equals00
+static int tolua_AllToLua_Vector3i_Equals00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3i",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const Vector3i* self = (const Vector3i*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Equals'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Equals(*v);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Equals'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Equals of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3i_Equals01
+static int tolua_AllToLua_Vector3i_Equals01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const Vector3i",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* self = (const Vector3i*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Equals'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->Equals(v);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_Vector3i_Equals00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: x of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3i_x
+static int tolua_get_Vector3i_x(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->x);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: x of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3i_x
+static int tolua_set_Vector3i_x(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->x = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: y of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3i_y
+static int tolua_get_Vector3i_y(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->y);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: y of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3i_y
+static int tolua_set_Vector3i_y(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->y = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: z of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_get_Vector3i_z
+static int tolua_get_Vector3i_z(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->z);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: z of class Vector3i */
+#ifndef TOLUA_DISABLE_tolua_set_Vector3i_z
+static int tolua_set_Vector3i_z(lua_State* tolua_S)
+{
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->z = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new00
+static int tolua_AllToLua_cCuboid_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new00_local
+static int tolua_AllToLua_cCuboid_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new01
+static int tolua_AllToLua_cCuboid_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cCuboid",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cCuboid* a_Cuboid = ((const cCuboid*) tolua_tousertype(tolua_S,2,0));
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)(*a_Cuboid));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cCuboid_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new01_local
+static int tolua_AllToLua_cCuboid_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cCuboid",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cCuboid* a_Cuboid = ((const cCuboid*) tolua_tousertype(tolua_S,2,0));
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)(*a_Cuboid));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cCuboid_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new02
+static int tolua_AllToLua_cCuboid_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* a_p1 = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ const Vector3i* a_p2 = ((const Vector3i*) tolua_tousertype(tolua_S,3,0));
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)(*a_p1,*a_p2));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cCuboid_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_new02_local
+static int tolua_AllToLua_cCuboid_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const Vector3i* a_p1 = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ const Vector3i* a_p2 = ((const Vector3i*) tolua_tousertype(tolua_S,3,0));
+ {
+ cCuboid* tolua_ret = (cCuboid*) Mtolua_new((cCuboid)(*a_p1,*a_p2));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCuboid");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cCuboid_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: p1 of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_get_cCuboid_p1
+static int tolua_get_cCuboid_p1(lua_State* tolua_S)
+{
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'p1'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->p1,"Vector3i");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: p1 of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_set_cCuboid_p1
+static int tolua_set_cCuboid_p1(lua_State* tolua_S)
+{
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'p1'",NULL);
+ if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3i",0,&tolua_err)))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->p1 = *((Vector3i*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: p2 of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_get_cCuboid_p2
+static int tolua_get_cCuboid_p2(lua_State* tolua_S)
+{
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'p2'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->p2,"Vector3i");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: p2 of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_set_cCuboid_p2
+static int tolua_set_cCuboid_p2(lua_State* tolua_S)
+{
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'p2'",NULL);
+ if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3i",0,&tolua_err)))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->p2 = *((Vector3i*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Sort of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_Sort00
+static int tolua_AllToLua_cCuboid_Sort00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCuboid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Sort'", NULL);
+#endif
+ {
+ self->Sort();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Sort'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsInside of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_IsInside00
+static int tolua_AllToLua_cCuboid_IsInside00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCuboid* self = (const cCuboid*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* v = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsInside'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsInside(*v);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsInside'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsInside of class cCuboid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_IsInside01
+static int tolua_AllToLua_cCuboid_IsInside01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCuboid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3d",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const cCuboid* self = (const cCuboid*) tolua_tousertype(tolua_S,1,0);
+ const Vector3d* v = ((const Vector3d*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsInside'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsInside(*v);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cCuboid_IsInside00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cMCLogger */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cMCLogger_new00
+static int tolua_AllToLua_cMCLogger_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cMCLogger",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char* a_File = ((char*) tolua_tostring(tolua_S,2,0));
+ {
+ cMCLogger* tolua_ret = (cMCLogger*) Mtolua_new((cMCLogger)(a_File));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cMCLogger");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cMCLogger */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cMCLogger_new00_local
+static int tolua_AllToLua_cMCLogger_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cMCLogger",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ char* a_File = ((char*) tolua_tostring(tolua_S,2,0));
+ {
+ cMCLogger* tolua_ret = (cMCLogger*) Mtolua_new((cMCLogger)(a_File));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cMCLogger");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cMCLogger */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cMCLogger_delete00
+static int tolua_AllToLua_cMCLogger_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cMCLogger",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: LogSimple of class cMCLogger */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cMCLogger_LogSimple00
+static int tolua_AllToLua_cMCLogger_LogSimple00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cMCLogger",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
+ const char* a_Text = ((const char*) tolua_tostring(tolua_S,2,0));
+ int a_LogType = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'LogSimple'", NULL);
+#endif
+ {
+ self->LogSimple(a_Text,a_LogType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'LogSimple'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTracer_new00
+static int tolua_AllToLua_cTracer_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cTracer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0));
+ {
+ cTracer* tolua_ret = (cTracer*) Mtolua_new((cTracer)(a_World));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cTracer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTracer_new00_local
+static int tolua_AllToLua_cTracer_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cTracer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0));
+ {
+ cTracer* tolua_ret = (cTracer*) Mtolua_new((cTracer)(a_World));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cTracer");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: delete of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTracer_delete00
+static int tolua_AllToLua_cTracer_delete00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTracer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
+#endif
+ Mtolua_delete(self);
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Trace of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTracer_Trace00
+static int tolua_AllToLua_cTracer_Trace00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTracer",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* a_Start = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ const Vector3f* a_Direction = ((const Vector3f*) tolua_tousertype(tolua_S,3,0));
+ int a_Distance = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Trace'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->Trace(*a_Start,*a_Direction,a_Distance);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Trace'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetValues of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTracer_SetValues00
+static int tolua_AllToLua_cTracer_SetValues00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cTracer",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3f",0,&tolua_err)) ||
+ (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3f",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+ const Vector3f* a_Start = ((const Vector3f*) tolua_tousertype(tolua_S,2,0));
+ const Vector3f* a_Direction = ((const Vector3f*) tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetValues'", NULL);
+#endif
+ {
+ self->SetValues(*a_Start,*a_Direction);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetValues'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: BlockHitPosition of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_get_cTracer_BlockHitPosition_ptr
+static int tolua_get_cTracer_BlockHitPosition_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'BlockHitPosition'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->BlockHitPosition,"Vector3f");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: BlockHitPosition of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_set_cTracer_BlockHitPosition_ptr
+static int tolua_set_cTracer_BlockHitPosition_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'BlockHitPosition'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"Vector3f",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->BlockHitPosition = ((Vector3f*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: HitNormal of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_get_cTracer_HitNormal_ptr
+static int tolua_get_cTracer_HitNormal_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'HitNormal'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->HitNormal,"Vector3f");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: HitNormal of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_set_cTracer_HitNormal_ptr
+static int tolua_set_cTracer_HitNormal_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'HitNormal'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"Vector3f",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->HitNormal = ((Vector3f*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: RealHit of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_get_cTracer_RealHit_ptr
+static int tolua_get_cTracer_RealHit_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'RealHit'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->RealHit,"Vector3f");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: RealHit of class cTracer */
+#ifndef TOLUA_DISABLE_tolua_set_cTracer_RealHit_ptr
+static int tolua_set_cTracer_RealHit_ptr(lua_State* tolua_S)
+{
+ cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'RealHit'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"Vector3f",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->RealHit = ((Vector3f*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetName of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_SetName00
+static int tolua_AllToLua_cGroup_SetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Name = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetName'", NULL);
+#endif
+ {
+ self->SetName(a_Name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetName of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_GetName00
+static int tolua_AllToLua_cGroup_GetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cGroup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cGroup* self = (const cGroup*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL);
+#endif
+ {
+ const std::string tolua_ret = (const std::string) self->GetName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetColor of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_SetColor00
+static int tolua_AllToLua_cGroup_SetColor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Color = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetColor'", NULL);
+#endif
+ {
+ self->SetColor(a_Color);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetColor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddCommand of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_AddCommand00
+static int tolua_AllToLua_cGroup_AddCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Command = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddCommand'", NULL);
+#endif
+ {
+ self->AddCommand(a_Command);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: AddPermission of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_AddPermission00
+static int tolua_AllToLua_cGroup_AddPermission00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Permission = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddPermission'", NULL);
+#endif
+ {
+ self->AddPermission(a_Permission);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'AddPermission'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: InheritFrom of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_InheritFrom00
+static int tolua_AllToLua_cGroup_InheritFrom00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"cGroup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ cGroup* a_Group = ((cGroup*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'InheritFrom'", NULL);
+#endif
+ {
+ self->InheritFrom(a_Group);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'InheritFrom'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HasCommand of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_HasCommand00
+static int tolua_AllToLua_cGroup_HasCommand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cGroup",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cGroup* self = (cGroup*) tolua_tousertype(tolua_S,1,0);
+ std::string a_Command = ((std::string) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HasCommand'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->HasCommand(a_Command);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'HasCommand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetColor of class cGroup */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cGroup_GetColor00
+static int tolua_AllToLua_cGroup_GetColor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cGroup",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cGroup* self = (const cGroup*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetColor'", NULL);
+#endif
+ {
+ std::string tolua_ret = (std::string) self->GetColor();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetColor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_ProtocolVersion of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_ProtocolVersion
+static int tolua_get_cPacket_Login_m_ProtocolVersion(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ProtocolVersion'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ProtocolVersion);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ProtocolVersion of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_ProtocolVersion
+static int tolua_set_cPacket_Login_m_ProtocolVersion(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ProtocolVersion'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ProtocolVersion = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Username of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Username
+static int tolua_get_cPacket_Login_m_Username(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Username'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->m_Username);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Username of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Username
+static int tolua_set_cPacket_Login_m_Username(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Username'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Username = ((std::string) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_MapSeed of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_MapSeed
+static int tolua_get_cPacket_Login_m_MapSeed(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MapSeed'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_MapSeed);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_MapSeed of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_MapSeed
+static int tolua_set_cPacket_Login_m_MapSeed(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MapSeed'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_MapSeed = ((long long) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Dimension of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Dimension
+static int tolua_get_cPacket_Login_m_Dimension(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Dimension'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Dimension);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Dimension of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Dimension
+static int tolua_set_cPacket_Login_m_Dimension(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Dimension'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Dimension = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_new00
+static int tolua_AllToLua_cPacket_BlockDig_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cPacket_BlockDig* tolua_ret = (cPacket_BlockDig*) Mtolua_new((cPacket_BlockDig)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket_BlockDig");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_new00_local
+static int tolua_AllToLua_cPacket_BlockDig_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ cPacket_BlockDig* tolua_ret = (cPacket_BlockDig*) Mtolua_new((cPacket_BlockDig)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket_BlockDig");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Clone of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_Clone00
+static int tolua_AllToLua_cPacket_BlockDig_Clone00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPacket_BlockDig* self = (const cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clone'", NULL);
+#endif
+ {
+ cPacket* tolua_ret = (cPacket*) self->Clone();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clone'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Status of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_Status
+static int tolua_get_cPacket_BlockDig_m_Status(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Status'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Status);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Status of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_Status
+static int tolua_set_cPacket_BlockDig_m_Status(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Status'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Status = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_PosX of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosX
+static int tolua_get_cPacket_BlockDig_m_PosX(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosX);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosX of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosX
+static int tolua_set_cPacket_BlockDig_m_PosX(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosX = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_PosY of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosY
+static int tolua_get_cPacket_BlockDig_m_PosY(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosY);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosY of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosY
+static int tolua_set_cPacket_BlockDig_m_PosY(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosY = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_PosZ of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosZ
+static int tolua_get_cPacket_BlockDig_m_PosZ(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosZ);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosZ of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosZ
+static int tolua_set_cPacket_BlockDig_m_PosZ(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosZ = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Direction of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_Direction
+static int tolua_get_cPacket_BlockDig_m_Direction(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Direction);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Direction of class cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_Direction
+static int tolua_set_cPacket_BlockDig_m_Direction(lua_State* tolua_S)
+{
+ cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Direction = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+ class Lua__cPacket_BlockDig : public cPacket_BlockDig, public ToluaBase {
+public:
+ cPacket* Clone( void )const {
+ if (push_method("Clone", tolua_AllToLua_cPacket_BlockDig_Clone00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ cPacket* tolua_ret = ( cPacket* )tolua_tousertype(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( cPacket* ) cPacket_BlockDig:: Clone();
+ };
+ };
+
+ cPacket* cPacket_BlockDig__Clone( void ) {
+ return ( cPacket* )cPacket_BlockDig::Clone();
+ };
+ Lua__cPacket_BlockDig( void ): cPacket_BlockDig(){};
+};
+
+/* method: tolua__set_instance of class Lua__cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00
+static int tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+ lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
+#endif
+ {
+ self->tolua__set_instance(L,lo);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cPacket_BlockDig__Clone of class Lua__cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00
+static int tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPacket_BlockDig__Clone'", NULL);
+#endif
+ {
+ cPacket* tolua_ret = (cPacket*) self->cPacket_BlockDig__Clone();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPacket_BlockDig__Clone'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class Lua__cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_new00
+static int tolua_AllToLua_Lua__cPacket_BlockDig_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cPacket_BlockDig* tolua_ret = (Lua__cPacket_BlockDig*) Mtolua_new((Lua__cPacket_BlockDig)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPacket_BlockDig");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class Lua__cPacket_BlockDig */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_new00_local
+static int tolua_AllToLua_Lua__cPacket_BlockDig_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ Lua__cPacket_BlockDig* tolua_ret = (Lua__cPacket_BlockDig*) Mtolua_new((Lua__cPacket_BlockDig)());
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPacket_BlockDig");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_Lua__cPacket_BlockDig (lua_State* tolua_S)
+{
+ Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+/* get function: m_PosX of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosX
+static int tolua_get_cPacket_BlockPlace_m_PosX(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosX);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosX of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosX
+static int tolua_set_cPacket_BlockPlace_m_PosX(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosX = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_PosY of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosY
+static int tolua_get_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosY);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosY of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosY
+static int tolua_set_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosY = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_PosZ of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosZ
+static int tolua_get_cPacket_BlockPlace_m_PosZ(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_PosZ);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_PosZ of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosZ
+static int tolua_set_cPacket_BlockPlace_m_PosZ(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_PosZ = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Direction of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Direction
+static int tolua_get_cPacket_BlockPlace_m_Direction(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Direction);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Direction of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Direction
+static int tolua_set_cPacket_BlockPlace_m_Direction(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Direction = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_ItemType of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_ItemType
+static int tolua_get_cPacket_BlockPlace_m_ItemType(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ItemType of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_ItemType
+static int tolua_set_cPacket_BlockPlace_m_ItemType(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ItemType = ((short) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Count of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Count
+static int tolua_get_cPacket_BlockPlace_m_Count(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Count'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Count);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Count of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Count
+static int tolua_set_cPacket_BlockPlace_m_Count(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Count'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Count = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_Uses of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Uses
+static int tolua_get_cPacket_BlockPlace_m_Uses(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Uses'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Uses);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Uses of class cPacket_BlockPlace */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Uses
+static int tolua_set_cPacket_BlockPlace_m_Uses(lua_State* tolua_S)
+{
+ cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Uses'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Uses = ((short) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* Open function */
+TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,1);
+ tolua_beginmodule(tolua_S,NULL);
+ tolua_cclass(tolua_S,"cTorch","cTorch","",NULL);
+ tolua_beginmodule(tolua_S,"cTorch");
+ tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cTorch_DirectionToMetaData00);
+ tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cTorch_MetaDataToDirection00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cStairs","cStairs","",NULL);
+ tolua_beginmodule(tolua_S,"cStairs");
+ tolua_function(tolua_S,"RotationToMetaData",tolua_AllToLua_cStairs_RotationToMetaData00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cLadder","cLadder","",NULL);
+ tolua_beginmodule(tolua_S,"cLadder");
+ tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cLadder_DirectionToMetaData00);
+ tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cLadder_MetaDataToDirection00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cIniFile","cIniFile","",tolua_collect_cIniFile);
+ #else
+ tolua_cclass(tolua_S,"cIniFile","cIniFile","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cIniFile");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cIniFile_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cIniFile_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cIniFile_new00_local);
+ tolua_function(tolua_S,"CaseSensitive",tolua_AllToLua_cIniFile_CaseSensitive00);
+ tolua_function(tolua_S,"CaseInsensitive",tolua_AllToLua_cIniFile_CaseInsensitive00);
+ tolua_function(tolua_S,"Path",tolua_AllToLua_cIniFile_Path00);
+ tolua_function(tolua_S,"Path",tolua_AllToLua_cIniFile_Path01);
+ tolua_function(tolua_S,"SetPath",tolua_AllToLua_cIniFile_SetPath00);
+ tolua_function(tolua_S,"ReadFile",tolua_AllToLua_cIniFile_ReadFile00);
+ tolua_function(tolua_S,"WriteFile",tolua_AllToLua_cIniFile_WriteFile00);
+ tolua_function(tolua_S,"Erase",tolua_AllToLua_cIniFile_Erase00);
+ tolua_function(tolua_S,"Clear",tolua_AllToLua_cIniFile_Clear00);
+ tolua_function(tolua_S,"Reset",tolua_AllToLua_cIniFile_Reset00);
+ tolua_function(tolua_S,"FindKey",tolua_AllToLua_cIniFile_FindKey00);
+ tolua_function(tolua_S,"FindValue",tolua_AllToLua_cIniFile_FindValue00);
+ tolua_function(tolua_S,"NumKeys",tolua_AllToLua_cIniFile_NumKeys00);
+ tolua_function(tolua_S,"GetNumKeys",tolua_AllToLua_cIniFile_GetNumKeys00);
+ tolua_function(tolua_S,"AddKeyName",tolua_AllToLua_cIniFile_AddKeyName00);
+ tolua_function(tolua_S,"KeyName",tolua_AllToLua_cIniFile_KeyName00);
+ tolua_function(tolua_S,"GetKeyName",tolua_AllToLua_cIniFile_GetKeyName00);
+ tolua_function(tolua_S,"NumValues",tolua_AllToLua_cIniFile_NumValues00);
+ tolua_function(tolua_S,"GetNumValues",tolua_AllToLua_cIniFile_GetNumValues00);
+ tolua_function(tolua_S,"NumValues",tolua_AllToLua_cIniFile_NumValues01);
+ tolua_function(tolua_S,"GetNumValues",tolua_AllToLua_cIniFile_GetNumValues01);
+ tolua_function(tolua_S,"ValueName",tolua_AllToLua_cIniFile_ValueName00);
+ tolua_function(tolua_S,"GetValueName",tolua_AllToLua_cIniFile_GetValueName00);
+ tolua_function(tolua_S,"ValueName",tolua_AllToLua_cIniFile_ValueName01);
+ tolua_function(tolua_S,"GetValueName",tolua_AllToLua_cIniFile_GetValueName01);
+ tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue00);
+ tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue01);
+ tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue02);
+ tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue03);
+ tolua_function(tolua_S,"GetValueI",tolua_AllToLua_cIniFile_GetValueI00);
+ tolua_function(tolua_S,"GetValueB",tolua_AllToLua_cIniFile_GetValueB00);
+ tolua_function(tolua_S,"GetValueF",tolua_AllToLua_cIniFile_GetValueF00);
+ tolua_function(tolua_S,"SetValue",tolua_AllToLua_cIniFile_SetValue00);
+ tolua_function(tolua_S,"SetValue",tolua_AllToLua_cIniFile_SetValue01);
+ tolua_function(tolua_S,"SetValueI",tolua_AllToLua_cIniFile_SetValueI00);
+ tolua_function(tolua_S,"SetValueB",tolua_AllToLua_cIniFile_SetValueB00);
+ tolua_function(tolua_S,"SetValueF",tolua_AllToLua_cIniFile_SetValueF00);
+ tolua_function(tolua_S,"DeleteValue",tolua_AllToLua_cIniFile_DeleteValue00);
+ tolua_function(tolua_S,"DeleteKey",tolua_AllToLua_cIniFile_DeleteKey00);
+ tolua_function(tolua_S,"NumHeaderComments",tolua_AllToLua_cIniFile_NumHeaderComments00);
+ tolua_function(tolua_S,"HeaderComment",tolua_AllToLua_cIniFile_HeaderComment00);
+ tolua_function(tolua_S,"HeaderComment",tolua_AllToLua_cIniFile_HeaderComment01);
+ tolua_function(tolua_S,"DeleteHeaderComment",tolua_AllToLua_cIniFile_DeleteHeaderComment00);
+ tolua_function(tolua_S,"DeleteHeaderComments",tolua_AllToLua_cIniFile_DeleteHeaderComments00);
+ tolua_function(tolua_S,"NumKeyComments",tolua_AllToLua_cIniFile_NumKeyComments00);
+ tolua_function(tolua_S,"NumKeyComments",tolua_AllToLua_cIniFile_NumKeyComments01);
+ tolua_function(tolua_S,"KeyComment",tolua_AllToLua_cIniFile_KeyComment00);
+ tolua_function(tolua_S,"KeyComment",tolua_AllToLua_cIniFile_KeyComment01);
+ tolua_function(tolua_S,"KeyComment",tolua_AllToLua_cIniFile_KeyComment02);
+ tolua_function(tolua_S,"KeyComment",tolua_AllToLua_cIniFile_KeyComment03);
+ tolua_function(tolua_S,"DeleteKeyComment",tolua_AllToLua_cIniFile_DeleteKeyComment00);
+ tolua_function(tolua_S,"DeleteKeyComment",tolua_AllToLua_cIniFile_DeleteKeyComment01);
+ tolua_function(tolua_S,"DeleteKeyComments",tolua_AllToLua_cIniFile_DeleteKeyComments00);
+ tolua_function(tolua_S,"DeleteKeyComments",tolua_AllToLua_cIniFile_DeleteKeyComments01);
+ tolua_endmodule(tolua_S);
+ tolua_constant(tolua_S,"E_BLOCK_AIR",E_BLOCK_AIR);
+ tolua_constant(tolua_S,"E_BLOCK_STONE",E_BLOCK_STONE);
+ tolua_constant(tolua_S,"E_BLOCK_GRASS",E_BLOCK_GRASS);
+ tolua_constant(tolua_S,"E_BLOCK_DIRT",E_BLOCK_DIRT);
+ tolua_constant(tolua_S,"E_BLOCK_COBBLESTONE",E_BLOCK_COBBLESTONE);
+ tolua_constant(tolua_S,"E_BLOCK_WOOD",E_BLOCK_WOOD);
+ tolua_constant(tolua_S,"E_BLOCK_SAPLING",E_BLOCK_SAPLING);
+ tolua_constant(tolua_S,"E_BLOCK_BEDROCK",E_BLOCK_BEDROCK);
+ tolua_constant(tolua_S,"E_BLOCK_WATER",E_BLOCK_WATER);
+ tolua_constant(tolua_S,"E_BLOCK_STATIONARY_WATER",E_BLOCK_STATIONARY_WATER);
+ tolua_constant(tolua_S,"E_BLOCK_LAVA",E_BLOCK_LAVA);
+ tolua_constant(tolua_S,"E_BLOCK_STATIONARY_LAVA",E_BLOCK_STATIONARY_LAVA);
+ tolua_constant(tolua_S,"E_BLOCK_SAND",E_BLOCK_SAND);
+ tolua_constant(tolua_S,"E_BLOCK_GRAVEL",E_BLOCK_GRAVEL);
+ tolua_constant(tolua_S,"E_BLOCK_GOLD_ORE",E_BLOCK_GOLD_ORE);
+ tolua_constant(tolua_S,"E_BLOCK_IRON_ORE",E_BLOCK_IRON_ORE);
+ tolua_constant(tolua_S,"E_BLOCK_COAL_ORE",E_BLOCK_COAL_ORE);
+ tolua_constant(tolua_S,"E_BLOCK_LOG",E_BLOCK_LOG);
+ tolua_constant(tolua_S,"E_BLOCK_LEAVES",E_BLOCK_LEAVES);
+ tolua_constant(tolua_S,"E_BLOCK_SPONGE",E_BLOCK_SPONGE);
+ tolua_constant(tolua_S,"E_BLOCK_GLASS",E_BLOCK_GLASS);
+ tolua_constant(tolua_S,"E_BLOCK_WHITE_CLOTH",E_BLOCK_WHITE_CLOTH);
+ tolua_constant(tolua_S,"E_BLOCK_YELLOW_FLOWER",E_BLOCK_YELLOW_FLOWER);
+ tolua_constant(tolua_S,"E_BLOCK_RED_ROSE",E_BLOCK_RED_ROSE);
+ tolua_constant(tolua_S,"E_BLOCK_BROWN_MUSHROOM",E_BLOCK_BROWN_MUSHROOM);
+ tolua_constant(tolua_S,"E_BLOCK_RED_MUSHROOM",E_BLOCK_RED_MUSHROOM);
+ tolua_constant(tolua_S,"E_BLOCK_GOLD_BLOCK",E_BLOCK_GOLD_BLOCK);
+ tolua_constant(tolua_S,"E_BLOCK_IRON_BLOCK",E_BLOCK_IRON_BLOCK);
+ tolua_constant(tolua_S,"E_BLOCK_DOUBLE_STEP",E_BLOCK_DOUBLE_STEP);
+ tolua_constant(tolua_S,"E_BLOCK_STEP",E_BLOCK_STEP);
+ tolua_constant(tolua_S,"E_BLOCK_BRICK",E_BLOCK_BRICK);
+ tolua_constant(tolua_S,"E_BLOCK_TNT",E_BLOCK_TNT);
+ tolua_constant(tolua_S,"E_BLOCK_BOOKCASE",E_BLOCK_BOOKCASE);
+ tolua_constant(tolua_S,"E_BLOCK_MOSSY_COBBLESTONE",E_BLOCK_MOSSY_COBBLESTONE);
+ tolua_constant(tolua_S,"E_BLOCK_OBSIDIAN",E_BLOCK_OBSIDIAN);
+ tolua_constant(tolua_S,"E_BLOCK_TORCH",E_BLOCK_TORCH);
+ tolua_constant(tolua_S,"E_BLOCK_FIRE",E_BLOCK_FIRE);
+ tolua_constant(tolua_S,"E_BLOCK_MOB_SPAWNER",E_BLOCK_MOB_SPAWNER);
+ tolua_constant(tolua_S,"E_BLOCK_WOODEN_STAIRS",E_BLOCK_WOODEN_STAIRS);
+ tolua_constant(tolua_S,"E_BLOCK_CHEST",E_BLOCK_CHEST);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_WIRE",E_BLOCK_REDSTONE_WIRE);
+ tolua_constant(tolua_S,"E_BLOCK_DIAMOND_ORE",E_BLOCK_DIAMOND_ORE);
+ tolua_constant(tolua_S,"E_BLOCK_DIAMOND_BLOCK",E_BLOCK_DIAMOND_BLOCK);
+ tolua_constant(tolua_S,"E_BLOCK_WORKBENCH",E_BLOCK_WORKBENCH);
+ tolua_constant(tolua_S,"E_BLOCK_CROPS",E_BLOCK_CROPS);
+ tolua_constant(tolua_S,"E_BLOCK_SOIL",E_BLOCK_SOIL);
+ tolua_constant(tolua_S,"E_BLOCK_FURNACE",E_BLOCK_FURNACE);
+ tolua_constant(tolua_S,"E_BLOCK_BURNING_FURNACE",E_BLOCK_BURNING_FURNACE);
+ tolua_constant(tolua_S,"E_BLOCK_SIGN_POST",E_BLOCK_SIGN_POST);
+ tolua_constant(tolua_S,"E_BLOCK_WOODEN_DOOR",E_BLOCK_WOODEN_DOOR);
+ tolua_constant(tolua_S,"E_BLOCK_LADDER",E_BLOCK_LADDER);
+ tolua_constant(tolua_S,"E_BLOCK_MINECART_TRACKS",E_BLOCK_MINECART_TRACKS);
+ tolua_constant(tolua_S,"E_BLOCK_COBBLESTONE_STAIRS",E_BLOCK_COBBLESTONE_STAIRS);
+ tolua_constant(tolua_S,"E_BLOCK_WALLSIGN",E_BLOCK_WALLSIGN);
+ tolua_constant(tolua_S,"E_BLOCK_LEVER",E_BLOCK_LEVER);
+ tolua_constant(tolua_S,"E_BLOCK_STONE_PRESSURE_PLATE",E_BLOCK_STONE_PRESSURE_PLATE);
+ tolua_constant(tolua_S,"E_BLOCK_IRON_DOOR",E_BLOCK_IRON_DOOR);
+ tolua_constant(tolua_S,"E_BLOCK_WOODEN_PRESSURE_PLATE",E_BLOCK_WOODEN_PRESSURE_PLATE);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_ORE",E_BLOCK_REDSTONE_ORE);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_ORE_GLOWING",E_BLOCK_REDSTONE_ORE_GLOWING);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_TORCH_ON",E_BLOCK_REDSTONE_TORCH_ON);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_TORCH_OFF",E_BLOCK_REDSTONE_TORCH_OFF);
+ tolua_constant(tolua_S,"E_BLOCK_SNOW",E_BLOCK_SNOW);
+ tolua_constant(tolua_S,"E_BLOCK_ICE",E_BLOCK_ICE);
+ tolua_constant(tolua_S,"E_BLOCK_SNOW_BLOCK",E_BLOCK_SNOW_BLOCK);
+ tolua_constant(tolua_S,"E_BLOCK_CACTUS",E_BLOCK_CACTUS);
+ tolua_constant(tolua_S,"E_BLOCK_CLAY",E_BLOCK_CLAY);
+ tolua_constant(tolua_S,"E_BLOCK_REEDS",E_BLOCK_REEDS);
+ tolua_constant(tolua_S,"E_BLOCK_BLOODSTONE",E_BLOCK_BLOODSTONE);
+ tolua_constant(tolua_S,"E_BLOCK_SOULSAND",E_BLOCK_SOULSAND);
+ tolua_constant(tolua_S,"E_BLOCK_GLOWSTONE",E_BLOCK_GLOWSTONE);
+ tolua_constant(tolua_S,"E_BLOCK_PORT",E_BLOCK_PORT);
+ tolua_constant(tolua_S,"E_BLOCK_JACK_O_LANTERN",E_BLOCK_JACK_O_LANTERN);
+ tolua_constant(tolua_S,"E_BLOCK_CAKE",E_BLOCK_CAKE);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_REPEATER_OFF",E_BLOCK_REDSTONE_REPEATER_OFF);
+ tolua_constant(tolua_S,"E_BLOCK_REDSTONE_REPEATER_ON",E_BLOCK_REDSTONE_REPEATER_ON);
+ tolua_constant(tolua_S,"E_BLOCK_LOCKED_CHEST",E_BLOCK_LOCKED_CHEST);
+ tolua_constant(tolua_S,"E_BLOCK_TRAPDOOR",E_BLOCK_TRAPDOOR);
+ tolua_constant(tolua_S,"E_ITEM_EMPTY",E_ITEM_EMPTY);
+ tolua_constant(tolua_S,"E_ITEM_STONE",E_ITEM_STONE);
+ tolua_constant(tolua_S,"E_ITEM_GRASS",E_ITEM_GRASS);
+ tolua_constant(tolua_S,"E_ITEM_DIRT",E_ITEM_DIRT);
+ tolua_constant(tolua_S,"E_ITEM_COBBLESTONE",E_ITEM_COBBLESTONE);
+ tolua_constant(tolua_S,"E_ITEM_WOOD",E_ITEM_WOOD);
+ tolua_constant(tolua_S,"E_ITEM_SAPLING",E_ITEM_SAPLING);
+ tolua_constant(tolua_S,"E_ITEM_BEDROCK",E_ITEM_BEDROCK);
+ tolua_constant(tolua_S,"E_ITEM_WATER",E_ITEM_WATER);
+ tolua_constant(tolua_S,"E_ITEM_STATIONARY_WATER",E_ITEM_STATIONARY_WATER);
+ tolua_constant(tolua_S,"E_ITEM_LAVA",E_ITEM_LAVA);
+ tolua_constant(tolua_S,"E_ITEM_STATIONARY_LAVA",E_ITEM_STATIONARY_LAVA);
+ tolua_constant(tolua_S,"E_ITEM_SAND",E_ITEM_SAND);
+ tolua_constant(tolua_S,"E_ITEM_GRAVEL",E_ITEM_GRAVEL);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_ORE",E_ITEM_GOLD_ORE);
+ tolua_constant(tolua_S,"E_ITEM_IRON_ORE",E_ITEM_IRON_ORE);
+ tolua_constant(tolua_S,"E_ITEM_COAL_ORE",E_ITEM_COAL_ORE);
+ tolua_constant(tolua_S,"E_ITEM_LOG",E_ITEM_LOG);
+ tolua_constant(tolua_S,"E_ITEM_LEAVES",E_ITEM_LEAVES);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_BLOCK",E_ITEM_GOLD_BLOCK);
+ tolua_constant(tolua_S,"E_ITEM_IRON_BLOCK",E_ITEM_IRON_BLOCK);
+ tolua_constant(tolua_S,"E_ITEM_DIAMOND_BLOCK",E_ITEM_DIAMOND_BLOCK);
+ tolua_constant(tolua_S,"E_ITEM_FLINT_AND_STEEL",E_ITEM_FLINT_AND_STEEL);
+ tolua_constant(tolua_S,"E_ITEM_APPLE",E_ITEM_APPLE);
+ tolua_constant(tolua_S,"E_ITEM_BOW",E_ITEM_BOW);
+ tolua_constant(tolua_S,"E_ITEM_ARROW",E_ITEM_ARROW);
+ tolua_constant(tolua_S,"E_ITEM_COAL",E_ITEM_COAL);
+ tolua_constant(tolua_S,"E_ITEM_DIAMOND",E_ITEM_DIAMOND);
+ tolua_constant(tolua_S,"E_ITEM_IRON",E_ITEM_IRON);
+ tolua_constant(tolua_S,"E_ITEM_GOLD",E_ITEM_GOLD);
+ tolua_constant(tolua_S,"E_ITEM_MUSHROOM_SOUP",E_ITEM_MUSHROOM_SOUP);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_SWORD",E_ITEM_GOLD_SWORD);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_SHOVEL",E_ITEM_GOLD_SHOVEL);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_PICKAXE",E_ITEM_GOLD_PICKAXE);
+ tolua_constant(tolua_S,"E_ITEM_GOLD_AXE",E_ITEM_GOLD_AXE);
+ tolua_constant(tolua_S,"E_ITEM_STRING",E_ITEM_STRING);
+ tolua_constant(tolua_S,"E_ITEM_FEATHER",E_ITEM_FEATHER);
+ tolua_constant(tolua_S,"E_ITEM_BREAD",E_ITEM_BREAD);
+ tolua_constant(tolua_S,"E_ITEM_RAW_MEAT",E_ITEM_RAW_MEAT);
+ tolua_constant(tolua_S,"E_ITEM_COOKED_MEAT",E_ITEM_COOKED_MEAT);
+ tolua_constant(tolua_S,"E_ITEM_GOLDEN_APPLE",E_ITEM_GOLDEN_APPLE);
+ tolua_constant(tolua_S,"E_ITEM_SIGN",E_ITEM_SIGN);
+ tolua_constant(tolua_S,"E_ITEM_MILK",E_ITEM_MILK);
+ tolua_constant(tolua_S,"E_ITEM_EGG",E_ITEM_EGG);
+ tolua_constant(tolua_S,"E_ITEM_COMPASS",E_ITEM_COMPASS);
+ tolua_constant(tolua_S,"E_ITEM_FISHING_ROD",E_ITEM_FISHING_ROD);
+ tolua_constant(tolua_S,"E_ITEM_CLOCK",E_ITEM_CLOCK);
+ tolua_constant(tolua_S,"E_ITEM_GLOWSTONE_DUST",E_ITEM_GLOWSTONE_DUST);
+ tolua_constant(tolua_S,"E_ITEM_RAW_FISH",E_ITEM_RAW_FISH);
+ tolua_constant(tolua_S,"E_ITEM_COOKED_FISH",E_ITEM_COOKED_FISH);
+ tolua_constant(tolua_S,"E_ITEM_CAKE",E_ITEM_CAKE);
+ tolua_constant(tolua_S,"E_KEEP_ALIVE",E_KEEP_ALIVE);
+ tolua_constant(tolua_S,"E_LOGIN",E_LOGIN);
+ tolua_constant(tolua_S,"E_HANDSHAKE",E_HANDSHAKE);
+ tolua_constant(tolua_S,"E_CHAT",E_CHAT);
+ tolua_constant(tolua_S,"E_UPDATE_TIME",E_UPDATE_TIME);
+ tolua_constant(tolua_S,"E_ENTITY_EQUIPMENT",E_ENTITY_EQUIPMENT);
+ tolua_constant(tolua_S,"E_USE_ENTITY",E_USE_ENTITY);
+ tolua_constant(tolua_S,"E_UPDATE_HEALTH",E_UPDATE_HEALTH);
+ tolua_constant(tolua_S,"E_RESPAWN",E_RESPAWN);
+ tolua_constant(tolua_S,"E_FLYING",E_FLYING);
+ tolua_constant(tolua_S,"E_PLAYERPOS",E_PLAYERPOS);
+ tolua_constant(tolua_S,"E_PLAYERLOOK",E_PLAYERLOOK);
+ tolua_constant(tolua_S,"E_PLAYERMOVELOOK",E_PLAYERMOVELOOK);
+ tolua_constant(tolua_S,"E_BLOCK_DIG",E_BLOCK_DIG);
+ tolua_constant(tolua_S,"E_BLOCK_PLACE",E_BLOCK_PLACE);
+ tolua_constant(tolua_S,"E_ITEM_SWITCH",E_ITEM_SWITCH);
+ tolua_constant(tolua_S,"E_ADD_TO_INV",E_ADD_TO_INV);
+ tolua_constant(tolua_S,"E_ANIMATION",E_ANIMATION);
+ tolua_constant(tolua_S,"E_PACKET_13",E_PACKET_13);
+ tolua_constant(tolua_S,"E_NAMED_ENTITY_SPAWN",E_NAMED_ENTITY_SPAWN);
+ tolua_constant(tolua_S,"E_PICKUP_SPAWN",E_PICKUP_SPAWN);
+ tolua_constant(tolua_S,"E_COLLECT_ITEM",E_COLLECT_ITEM);
+ tolua_constant(tolua_S,"E_ADD_VEHICLE",E_ADD_VEHICLE);
+ tolua_constant(tolua_S,"E_SPAWN_MOB",E_SPAWN_MOB);
+ tolua_constant(tolua_S,"E_DESTROY_ENT",E_DESTROY_ENT);
+ tolua_constant(tolua_S,"E_ENTITY",E_ENTITY);
+ tolua_constant(tolua_S,"E_REL_ENT_MOVE",E_REL_ENT_MOVE);
+ tolua_constant(tolua_S,"E_ENT_LOOK",E_ENT_LOOK);
+ tolua_constant(tolua_S,"E_REL_ENT_MOVE_LOOK",E_REL_ENT_MOVE_LOOK);
+ tolua_constant(tolua_S,"E_ENT_TELEPORT",E_ENT_TELEPORT);
+ tolua_constant(tolua_S,"E_ENT_STATUS",E_ENT_STATUS);
+ tolua_constant(tolua_S,"E_METADATA",E_METADATA);
+ tolua_constant(tolua_S,"E_PRE_CHUNK",E_PRE_CHUNK);
+ tolua_constant(tolua_S,"E_MAP_CHUNK",E_MAP_CHUNK);
+ tolua_constant(tolua_S,"E_MULTI_BLOCK",E_MULTI_BLOCK);
+ tolua_constant(tolua_S,"E_BLOCK_CHANGE",E_BLOCK_CHANGE);
+ tolua_constant(tolua_S,"E_WINDOW_OPEN",E_WINDOW_OPEN);
+ tolua_constant(tolua_S,"E_WINDOW_CLOSE",E_WINDOW_CLOSE);
+ tolua_constant(tolua_S,"E_WINDOW_CLICK",E_WINDOW_CLICK);
+ tolua_constant(tolua_S,"E_INVENTORY_SLOT",E_INVENTORY_SLOT);
+ tolua_constant(tolua_S,"E_INVENTORY_WHOLE",E_INVENTORY_WHOLE);
+ tolua_constant(tolua_S,"E_INVENTORY_PROGRESS",E_INVENTORY_PROGRESS);
+ tolua_constant(tolua_S,"E_UPDATE_SIGN",E_UPDATE_SIGN);
+ tolua_constant(tolua_S,"E_DISCONNECT",E_DISCONNECT);
+ tolua_array(tolua_S,"g_BlockLightValue",tolua_get_AllToLua_g_BlockLightValue,tolua_set_AllToLua_g_BlockLightValue);
+ tolua_array(tolua_S,"g_BlockSpreadLightFalloff",tolua_get_AllToLua_g_BlockSpreadLightFalloff,tolua_set_AllToLua_g_BlockSpreadLightFalloff);
+ tolua_array(tolua_S,"g_BlockTransparent",tolua_get_AllToLua_g_BlockTransparent,tolua_set_AllToLua_g_BlockTransparent);
+ tolua_array(tolua_S,"g_BlockOneHitDig",tolua_get_AllToLua_g_BlockOneHitDig,tolua_set_AllToLua_g_BlockOneHitDig);
+ tolua_function(tolua_S,"IsValidBlock",tolua_AllToLua_IsValidBlock00);
+ tolua_function(tolua_S,"isValidItem",tolua_AllToLua_isValidItem00);
+ tolua_function(tolua_S,"AddDirection",tolua_AllToLua_AddDirection00);
+ tolua_function(tolua_S,"GetTime",tolua_AllToLua_GetTime00);
+ tolua_function(tolua_S,"GetChar",tolua_AllToLua_GetChar00);
+ tolua_cclass(tolua_S,"cStringMap","cStringMap","",NULL);
+ tolua_beginmodule(tolua_S,"cStringMap");
+ tolua_function(tolua_S,"clear",tolua_AllToLua_cStringMap_clear00);
+ tolua_function(tolua_S,"size",tolua_AllToLua_cStringMap_size00);
+ tolua_function(tolua_S,"get",tolua_AllToLua_cStringMap_get00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cChatColor","cChatColor","",NULL);
+ tolua_beginmodule(tolua_S,"cChatColor");
+ tolua_variable(tolua_S,"Color",tolua_get_cChatColor_Color,NULL);
+ tolua_variable(tolua_S,"Black",tolua_get_cChatColor_Black,NULL);
+ tolua_variable(tolua_S,"Navy",tolua_get_cChatColor_Navy,NULL);
+ tolua_variable(tolua_S,"Green",tolua_get_cChatColor_Green,NULL);
+ tolua_variable(tolua_S,"Blue",tolua_get_cChatColor_Blue,NULL);
+ tolua_variable(tolua_S,"Red",tolua_get_cChatColor_Red,NULL);
+ tolua_variable(tolua_S,"Purple",tolua_get_cChatColor_Purple,NULL);
+ tolua_variable(tolua_S,"Gold",tolua_get_cChatColor_Gold,NULL);
+ tolua_variable(tolua_S,"LightGray",tolua_get_cChatColor_LightGray,NULL);
+ tolua_variable(tolua_S,"Gray",tolua_get_cChatColor_Gray,NULL);
+ tolua_variable(tolua_S,"DarkPurple",tolua_get_cChatColor_DarkPurple,NULL);
+ tolua_variable(tolua_S,"LightGreen",tolua_get_cChatColor_LightGreen,NULL);
+ tolua_variable(tolua_S,"LightBlue",tolua_get_cChatColor_LightBlue,NULL);
+ tolua_variable(tolua_S,"Rose",tolua_get_cChatColor_Rose,NULL);
+ tolua_variable(tolua_S,"LightPurple",tolua_get_cChatColor_LightPurple,NULL);
+ tolua_variable(tolua_S,"Yellow",tolua_get_cChatColor_Yellow,NULL);
+ tolua_variable(tolua_S,"White",tolua_get_cChatColor_White,NULL);
+ tolua_function(tolua_S,"MakeColor",tolua_AllToLua_cChatColor_MakeColor00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cClientHandle","cClientHandle","",NULL);
+ tolua_beginmodule(tolua_S,"cClientHandle");
+ tolua_function(tolua_S,"GetPlayer",tolua_AllToLua_cClientHandle_GetPlayer00);
+ tolua_function(tolua_S,"Kick",tolua_AllToLua_cClientHandle_Kick00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cEntity","cEntity","",tolua_collect_cEntity);
+ #else
+ tolua_cclass(tolua_S,"cEntity","cEntity","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cEntity");
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cEntity_delete00);
+ tolua_function(tolua_S,"Initialize",tolua_AllToLua_cEntity_Initialize00);
+ tolua_constant(tolua_S,"E_ENTITY",cEntity::E_ENTITY);
+ tolua_constant(tolua_S,"E_PLAYER",cEntity::E_PLAYER);
+ tolua_constant(tolua_S,"E_PICKUP",cEntity::E_PICKUP);
+ tolua_function(tolua_S,"GetEntityType",tolua_AllToLua_cEntity_GetEntityType00);
+ tolua_function(tolua_S,"IsA",tolua_AllToLua_cEntity_IsA00);
+ tolua_function(tolua_S,"GetClass",tolua_AllToLua_cEntity_GetClass00);
+ tolua_function(tolua_S,"GetPosition",tolua_AllToLua_cEntity_GetPosition00);
+ tolua_function(tolua_S,"GetPosX",tolua_AllToLua_cEntity_GetPosX00);
+ tolua_function(tolua_S,"GetPosY",tolua_AllToLua_cEntity_GetPosY00);
+ tolua_function(tolua_S,"GetPosZ",tolua_AllToLua_cEntity_GetPosZ00);
+ tolua_function(tolua_S,"GetRot",tolua_AllToLua_cEntity_GetRot00);
+ tolua_function(tolua_S,"GetRotation",tolua_AllToLua_cEntity_GetRotation00);
+ tolua_function(tolua_S,"GetPitch",tolua_AllToLua_cEntity_GetPitch00);
+ tolua_function(tolua_S,"GetRoll",tolua_AllToLua_cEntity_GetRoll00);
+ tolua_function(tolua_S,"GetLookVector",tolua_AllToLua_cEntity_GetLookVector00);
+ tolua_function(tolua_S,"SetPosX",tolua_AllToLua_cEntity_SetPosX00);
+ tolua_function(tolua_S,"SetPosY",tolua_AllToLua_cEntity_SetPosY00);
+ tolua_function(tolua_S,"SetPosZ",tolua_AllToLua_cEntity_SetPosZ00);
+ tolua_function(tolua_S,"SetPosition",tolua_AllToLua_cEntity_SetPosition00);
+ tolua_function(tolua_S,"SetPosition",tolua_AllToLua_cEntity_SetPosition01);
+ tolua_function(tolua_S,"SetRot",tolua_AllToLua_cEntity_SetRot00);
+ tolua_function(tolua_S,"SetRotation",tolua_AllToLua_cEntity_SetRotation00);
+ tolua_function(tolua_S,"SetPitch",tolua_AllToLua_cEntity_SetPitch00);
+ tolua_function(tolua_S,"SetRoll",tolua_AllToLua_cEntity_SetRoll00);
+ tolua_function(tolua_S,"GetUniqueID",tolua_AllToLua_cEntity_GetUniqueID00);
+ tolua_function(tolua_S,"IsDestroyed",tolua_AllToLua_cEntity_IsDestroyed00);
+ tolua_function(tolua_S,"Destroy",tolua_AllToLua_cEntity_Destroy00);
+ tolua_function(tolua_S,"Tick",tolua_AllToLua_cEntity_Tick00);
+ tolua_function(tolua_S,"SpawnOn",tolua_AllToLua_cEntity_SpawnOn00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cEntity","Lua__cEntity","cEntity",tolua_collect_Lua__cEntity);
+ #else
+ tolua_cclass(tolua_S,"Lua__cEntity","Lua__cEntity","cEntity",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cEntity");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cEntity_tolua__set_instance00);
+ tolua_function(tolua_S,"cEntity__Initialize",tolua_AllToLua_Lua__cEntity_cEntity__Initialize00);
+ tolua_function(tolua_S,"cEntity__GetEntityType",tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00);
+ tolua_function(tolua_S,"cEntity__IsA",tolua_AllToLua_Lua__cEntity_cEntity__IsA00);
+ tolua_function(tolua_S,"cEntity__GetClass",tolua_AllToLua_Lua__cEntity_cEntity__GetClass00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cEntity_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cEntity_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cEntity_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cEntity_delete00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"TakeDamageInfo","TakeDamageInfo","",NULL);
+ tolua_beginmodule(tolua_S,"TakeDamageInfo");
+ tolua_variable(tolua_S,"Damage",tolua_get_TakeDamageInfo_Damage,tolua_set_TakeDamageInfo_Damage);
+ tolua_variable(tolua_S,"Instigator",tolua_get_TakeDamageInfo_Instigator_ptr,tolua_set_TakeDamageInfo_Instigator_ptr);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPawn","cPawn","cEntity",NULL);
+ tolua_beginmodule(tolua_S,"cPawn");
+ tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPawn_TeleportTo00);
+ tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPawn_TeleportTo01);
+ tolua_function(tolua_S,"Heal",tolua_AllToLua_cPawn_Heal00);
+ tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPawn_TakeDamage00);
+ tolua_function(tolua_S,"KilledBy",tolua_AllToLua_cPawn_KilledBy00);
+ tolua_function(tolua_S,"GetHealth",tolua_AllToLua_cPawn_GetHealth00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"Lua__cPawn","Lua__cPawn","cPawn",NULL);
+ tolua_beginmodule(tolua_S,"Lua__cPawn");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPawn_tolua__set_instance00);
+ tolua_function(tolua_S,"cPawn__TeleportTo",tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00);
+ tolua_function(tolua_S,"cPawn__TeleportTo",tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo01);
+ tolua_function(tolua_S,"cPawn__TakeDamage",tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00);
+ tolua_function(tolua_S,"cPawn__KilledBy",tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPlayer","cPlayer","cPawn",NULL);
+ tolua_beginmodule(tolua_S,"cPlayer");
+ tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00);
+ tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00);
+ tolua_function(tolua_S,"GetFlying",tolua_AllToLua_cPlayer_GetFlying00);
+ tolua_function(tolua_S,"GetStance",tolua_AllToLua_cPlayer_GetStance00);
+ tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00);
+ tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo00);
+ tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo01);
+ tolua_function(tolua_S,"MoveTo",tolua_AllToLua_cPlayer_MoveTo00);
+ tolua_function(tolua_S,"GetClientHandle",tolua_AllToLua_cPlayer_GetClientHandle00);
+ tolua_function(tolua_S,"SendMessage",tolua_AllToLua_cPlayer_SendMessage00);
+ tolua_function(tolua_S,"GetName",tolua_AllToLua_cPlayer_GetName00);
+ tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlayer_SetName00);
+ tolua_function(tolua_S,"AddToGroup",tolua_AllToLua_cPlayer_AddToGroup00);
+ tolua_function(tolua_S,"CanUseCommand",tolua_AllToLua_cPlayer_CanUseCommand00);
+ tolua_function(tolua_S,"HasPermission",tolua_AllToLua_cPlayer_HasPermission00);
+ tolua_function(tolua_S,"IsInGroup",tolua_AllToLua_cPlayer_IsInGroup00);
+ tolua_function(tolua_S,"GetColor",tolua_AllToLua_cPlayer_GetColor00);
+ tolua_function(tolua_S,"TossItem",tolua_AllToLua_cPlayer_TossItem00);
+ tolua_function(tolua_S,"Heal",tolua_AllToLua_cPlayer_Heal00);
+ tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPlayer_TakeDamage00);
+ tolua_function(tolua_S,"KilledBy",tolua_AllToLua_cPlayer_KilledBy00);
+ 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);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"Lua__cPlayer","Lua__cPlayer","cPlayer",NULL);
+ tolua_beginmodule(tolua_S,"Lua__cPlayer");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPlayer_tolua__set_instance00);
+ tolua_function(tolua_S,"cPlayer__TeleportTo",tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00);
+ tolua_function(tolua_S,"cPlayer__TeleportTo",tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo01);
+ tolua_function(tolua_S,"cPlayer__MoveTo",tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPluginManager","cPluginManager","",NULL);
+ tolua_beginmodule(tolua_S,"cPluginManager");
+ tolua_constant(tolua_S,"E_PLUGIN_TICK",cPluginManager::E_PLUGIN_TICK);
+ tolua_constant(tolua_S,"E_PLUGIN_CHAT",cPluginManager::E_PLUGIN_CHAT);
+ tolua_constant(tolua_S,"E_PLUGIN_COLLECT_ITEM",cPluginManager::E_PLUGIN_COLLECT_ITEM);
+ tolua_constant(tolua_S,"E_PLUGIN_BLOCK_DIG",cPluginManager::E_PLUGIN_BLOCK_DIG);
+ tolua_constant(tolua_S,"E_PLUGIN_BLOCK_PLACE",cPluginManager::E_PLUGIN_BLOCK_PLACE);
+ tolua_constant(tolua_S,"E_PLUGIN_DISCONNECT",cPluginManager::E_PLUGIN_DISCONNECT);
+ tolua_constant(tolua_S,"E_PLUGIN_HANDSHAKE",cPluginManager::E_PLUGIN_HANDSHAKE);
+ tolua_constant(tolua_S,"E_PLUGIN_LOGIN",cPluginManager::E_PLUGIN_LOGIN);
+ tolua_constant(tolua_S,"E_PLUGIN_PLAYER_SPAWN",cPluginManager::E_PLUGIN_PLAYER_SPAWN);
+ tolua_constant(tolua_S,"E_PLUGIN_PLAYER_JOIN",cPluginManager::E_PLUGIN_PLAYER_JOIN);
+ tolua_constant(tolua_S,"E_PLUGIN_PLAYER_MOVE",cPluginManager::E_PLUGIN_PLAYER_MOVE);
+ tolua_constant(tolua_S,"E_PLUGIN_TAKE_DAMAGE",cPluginManager::E_PLUGIN_TAKE_DAMAGE);
+ tolua_constant(tolua_S,"E_PLUGIN_KILLED",cPluginManager::E_PLUGIN_KILLED);
+ tolua_function(tolua_S,"GetPluginManager",tolua_AllToLua_cPluginManager_GetPluginManager00);
+ tolua_function(tolua_S,"GetPlugin",tolua_AllToLua_cPluginManager_GetPlugin00);
+ tolua_function(tolua_S,"ReloadPlugins",tolua_AllToLua_cPluginManager_ReloadPlugins00);
+ tolua_function(tolua_S,"AddPlugin",tolua_AllToLua_cPluginManager_AddPlugin00);
+ tolua_function(tolua_S,"AddHook",tolua_AllToLua_cPluginManager_AddHook00);
+ tolua_function(tolua_S,"GetNumPlugins",tolua_AllToLua_cPluginManager_GetNumPlugins00);
+ tolua_function(tolua_S,"RemovePlugin",tolua_AllToLua_cPluginManager_RemovePlugin00);
+ tolua_function(tolua_S,"RemoveLuaPlugin",tolua_AllToLua_cPluginManager_RemoveLuaPlugin00);
+ tolua_function(tolua_S,"GetLuaPlugin",tolua_AllToLua_cPluginManager_GetLuaPlugin00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cPlugin","cPlugin","",tolua_collect_cPlugin);
+ #else
+ tolua_cclass(tolua_S,"cPlugin","cPlugin","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cPlugin");
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cPlugin_delete00);
+ tolua_function(tolua_S,"OnDisable",tolua_AllToLua_cPlugin_OnDisable00);
+ tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlugin_Initialize00);
+ tolua_function(tolua_S,"Tick",tolua_AllToLua_cPlugin_Tick00);
+ tolua_function(tolua_S,"OnCollectItem",tolua_AllToLua_cPlugin_OnCollectItem00);
+ tolua_function(tolua_S,"OnDisconnect",tolua_AllToLua_cPlugin_OnDisconnect00);
+ tolua_function(tolua_S,"OnBlockPlace",tolua_AllToLua_cPlugin_OnBlockPlace00);
+ tolua_function(tolua_S,"OnBlockDig",tolua_AllToLua_cPlugin_OnBlockDig00);
+ tolua_function(tolua_S,"OnChat",tolua_AllToLua_cPlugin_OnChat00);
+ tolua_function(tolua_S,"OnLogin",tolua_AllToLua_cPlugin_OnLogin00);
+ tolua_function(tolua_S,"OnPlayerSpawn",tolua_AllToLua_cPlugin_OnPlayerSpawn00);
+ tolua_function(tolua_S,"OnPlayerJoin",tolua_AllToLua_cPlugin_OnPlayerJoin00);
+ tolua_function(tolua_S,"OnPlayerMove",tolua_AllToLua_cPlugin_OnPlayerMove00);
+ tolua_function(tolua_S,"OnTakeDamage",tolua_AllToLua_cPlugin_OnTakeDamage00);
+ tolua_function(tolua_S,"OnKilled",tolua_AllToLua_cPlugin_OnKilled00);
+ tolua_function(tolua_S,"GetName",tolua_AllToLua_cPlugin_GetName00);
+ tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlugin_SetName00);
+ tolua_function(tolua_S,"GetVersion",tolua_AllToLua_cPlugin_GetVersion00);
+ tolua_function(tolua_S,"SetVersion",tolua_AllToLua_cPlugin_SetVersion00);
+ tolua_cclass(tolua_S,"CommandStruct","cPlugin::CommandStruct","",NULL);
+ tolua_beginmodule(tolua_S,"CommandStruct");
+ tolua_variable(tolua_S,"Command",tolua_get_cPlugin__CommandStruct_Command,tolua_set_cPlugin__CommandStruct_Command);
+ tolua_variable(tolua_S,"Description",tolua_get_cPlugin__CommandStruct_Description,tolua_set_cPlugin__CommandStruct_Description);
+ tolua_variable(tolua_S,"Permission",tolua_get_cPlugin__CommandStruct_Permission,tolua_set_cPlugin__CommandStruct_Permission);
+ tolua_endmodule(tolua_S);
+ tolua_function(tolua_S,"AddCommand",tolua_AllToLua_cPlugin_AddCommand00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cPlugin","Lua__cPlugin","cPlugin",tolua_collect_Lua__cPlugin);
+ #else
+ tolua_cclass(tolua_S,"Lua__cPlugin","Lua__cPlugin","cPlugin",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cPlugin");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPlugin_tolua__set_instance00);
+ tolua_function(tolua_S,"cPlugin__OnDisable",tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisable00);
+ tolua_function(tolua_S,"cPlugin__Tick",tolua_AllToLua_Lua__cPlugin_cPlugin__Tick00);
+ tolua_function(tolua_S,"cPlugin__OnCollectItem",tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00);
+ tolua_function(tolua_S,"cPlugin__OnDisconnect",tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00);
+ tolua_function(tolua_S,"cPlugin__OnBlockPlace",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00);
+ tolua_function(tolua_S,"cPlugin__OnBlockDig",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00);
+ tolua_function(tolua_S,"cPlugin__OnChat",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChat00);
+ tolua_function(tolua_S,"cPlugin__OnLogin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00);
+ tolua_function(tolua_S,"cPlugin__OnPlayerSpawn",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00);
+ tolua_function(tolua_S,"cPlugin__OnPlayerJoin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00);
+ tolua_function(tolua_S,"cPlugin__OnPlayerMove",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00);
+ tolua_function(tolua_S,"cPlugin__OnTakeDamage",tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00);
+ tolua_function(tolua_S,"cPlugin__OnKilled",tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPlugin_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPlugin_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPlugin_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cPlugin_delete00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPlugin_Lua","cPlugin_Lua","",NULL);
+ tolua_beginmodule(tolua_S,"cPlugin_Lua");
+ tolua_function(tolua_S,"GetFileName",tolua_AllToLua_cPlugin_Lua_GetFileName00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cServer","cServer","",NULL);
+ tolua_beginmodule(tolua_S,"cServer");
+ tolua_function(tolua_S,"GetServer",tolua_AllToLua_cServer_GetServer00);
+ tolua_function(tolua_S,"ServerCommand",tolua_AllToLua_cServer_ServerCommand00);
+ tolua_function(tolua_S,"SendMessage",tolua_AllToLua_cServer_SendMessage00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cWorld","cWorld","",NULL);
+ tolua_beginmodule(tolua_S,"cWorld");
+ tolua_function(tolua_S,"GetWorld",tolua_AllToLua_cWorld_GetWorld00);
+ tolua_function(tolua_S,"GetTime",tolua_AllToLua_cWorld_GetTime00);
+ tolua_function(tolua_S,"SetWorldTime",tolua_AllToLua_cWorld_SetWorldTime00);
+ tolua_function(tolua_S,"GetHeight",tolua_AllToLua_cWorld_GetHeight00);
+ tolua_function(tolua_S,"GetNumPlayers",tolua_AllToLua_cWorld_GetNumPlayers00);
+ tolua_function(tolua_S,"GetPlayer",tolua_AllToLua_cWorld_GetPlayer00);
+ tolua_function(tolua_S,"GetEntity",tolua_AllToLua_cWorld_GetEntity00);
+ tolua_function(tolua_S,"SetBlock",tolua_AllToLua_cWorld_SetBlock00);
+ tolua_function(tolua_S,"FastSetBlock",tolua_AllToLua_cWorld_FastSetBlock00);
+ tolua_function(tolua_S,"GetBlock",tolua_AllToLua_cWorld_GetBlock00);
+ tolua_function(tolua_S,"GetBlockMeta",tolua_AllToLua_cWorld_GetBlockMeta00);
+ tolua_function(tolua_S,"SetBlockMeta",tolua_AllToLua_cWorld_SetBlockMeta00);
+ tolua_function(tolua_S,"DigBlock",tolua_AllToLua_cWorld_DigBlock00);
+ tolua_function(tolua_S,"SendBlockTo",tolua_AllToLua_cWorld_SendBlockTo00);
+ tolua_function(tolua_S,"GetSpawnX",tolua_AllToLua_cWorld_GetSpawnX00);
+ tolua_function(tolua_S,"GetSpawnY",tolua_AllToLua_cWorld_GetSpawnY00);
+ tolua_function(tolua_S,"GetSpawnZ",tolua_AllToLua_cWorld_GetSpawnZ00);
+ tolua_function(tolua_S,"GetBlockEntity",tolua_AllToLua_cWorld_GetBlockEntity00);
+ tolua_function(tolua_S,"GrowTree",tolua_AllToLua_cWorld_GrowTree00);
+ tolua_function(tolua_S,"GetWorldSeed",tolua_AllToLua_cWorld_GetWorldSeed00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cInventory","cInventory","",NULL);
+ tolua_beginmodule(tolua_S,"cInventory");
+ tolua_function(tolua_S,"Clear",tolua_AllToLua_cInventory_Clear00);
+ tolua_function(tolua_S,"AddItem",tolua_AllToLua_cInventory_AddItem00);
+ tolua_function(tolua_S,"RemoveItem",tolua_AllToLua_cInventory_RemoveItem00);
+ tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cInventory_GetSlot00);
+ tolua_function(tolua_S,"GetFromHotBar",tolua_AllToLua_cInventory_GetFromHotBar00);
+ tolua_function(tolua_S,"GetEquippedItem",tolua_AllToLua_cInventory_GetEquippedItem00);
+ tolua_function(tolua_S,"SetEquippedSlot",tolua_AllToLua_cInventory_SetEquippedSlot00);
+ tolua_function(tolua_S,"SendSlot",tolua_AllToLua_cInventory_SendSlot00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cItem","cItem","",tolua_collect_cItem);
+ #else
+ tolua_cclass(tolua_S,"cItem","cItem","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cItem");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cItem_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cItem_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cItem_new00_local);
+ tolua_function(tolua_S,"Empty",tolua_AllToLua_cItem_Empty00);
+ tolua_function(tolua_S,"IsEmpty",tolua_AllToLua_cItem_IsEmpty00);
+ tolua_function(tolua_S,"Equals",tolua_AllToLua_cItem_Equals00);
+ tolua_variable(tolua_S,"m_ItemID",tolua_get_cItem_m_ItemID,tolua_set_cItem_m_ItemID);
+ tolua_variable(tolua_S,"m_ItemCount",tolua_get_cItem_m_ItemCount,tolua_set_cItem_m_ItemCount);
+ tolua_variable(tolua_S,"m_ItemHealth",tolua_get_cItem_m_ItemHealth,tolua_set_cItem_m_ItemHealth);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"HTTPRequest","HTTPRequest","",NULL);
+ tolua_beginmodule(tolua_S,"HTTPRequest");
+ tolua_variable(tolua_S,"Method",tolua_get_HTTPRequest_Method,tolua_set_HTTPRequest_Method);
+ tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path);
+ tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params_ptr,tolua_set_HTTPRequest_Params_ptr);
+ tolua_variable(tolua_S,"Username",tolua_get_HTTPRequest_Username,tolua_set_HTTPRequest_Username);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",tolua_collect_cWebPlugin);
+ #else
+ tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cWebPlugin");
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cWebPlugin_delete00);
+ tolua_function(tolua_S,"SetName",tolua_AllToLua_cWebPlugin_SetName00);
+ tolua_function(tolua_S,"GetName",tolua_AllToLua_cWebPlugin_GetName00);
+ tolua_function(tolua_S,"HandleRequest",tolua_AllToLua_cWebPlugin_HandleRequest00);
+ tolua_function(tolua_S,"Initialize",tolua_AllToLua_cWebPlugin_Initialize00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cWebPlugin","Lua__cWebPlugin","cWebPlugin",tolua_collect_Lua__cWebPlugin);
+ #else
+ tolua_cclass(tolua_S,"Lua__cWebPlugin","Lua__cWebPlugin","cWebPlugin",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cWebPlugin");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cWebPlugin_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cWebPlugin_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cWebPlugin_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cWebPlugin_delete00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cPickup","cPickup","cEntity",tolua_collect_cPickup);
+ #else
+ tolua_cclass(tolua_S,"cPickup","cPickup","cEntity",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cPickup");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cPickup_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cPickup_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cPickup_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_cPickup_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cPickup_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cPickup_new01_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cPickup_delete00);
+ tolua_function(tolua_S,"GetItem",tolua_AllToLua_cPickup_GetItem00);
+ tolua_function(tolua_S,"CollectedBy",tolua_AllToLua_cPickup_CollectedBy00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cPickup","Lua__cPickup","cPickup",tolua_collect_Lua__cPickup);
+ #else
+ tolua_cclass(tolua_S,"Lua__cPickup","Lua__cPickup","cPickup",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cPickup");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPickup_tolua__set_instance00);
+ tolua_function(tolua_S,"cPickup__CollectedBy",tolua_AllToLua_Lua__cPickup_cPickup__CollectedBy00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPickup_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPickup_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPickup_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPickup_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPickup_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPickup_new01_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cPickup_delete00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cRoot","cRoot","",NULL);
+ tolua_beginmodule(tolua_S,"cRoot");
+ tolua_function(tolua_S,"Get",tolua_AllToLua_cRoot_Get00);
+ tolua_function(tolua_S,"GetServer",tolua_AllToLua_cRoot_GetServer00);
+ tolua_function(tolua_S,"GetWorld",tolua_AllToLua_cRoot_GetWorld00);
+ tolua_function(tolua_S,"GetGroupManager",tolua_AllToLua_cRoot_GetGroupManager00);
+ tolua_function(tolua_S,"GetRecipeChecker",tolua_AllToLua_cRoot_GetRecipeChecker00);
+ tolua_function(tolua_S,"GetFurnaceRecipe",tolua_AllToLua_cRoot_GetFurnaceRecipe00);
+ tolua_function(tolua_S,"GetWebAdmin",tolua_AllToLua_cRoot_GetWebAdmin00);
+ tolua_function(tolua_S,"GetPluginManager",tolua_AllToLua_cRoot_GetPluginManager00);
+ tolua_function(tolua_S,"ServerCommand",tolua_AllToLua_cRoot_ServerCommand00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cTCPLink","cTCPLink","",tolua_collect_cTCPLink);
+ #else
+ tolua_cclass(tolua_S,"cTCPLink","cTCPLink","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cTCPLink");
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cTCPLink_delete00);
+ tolua_function(tolua_S,"Connect",tolua_AllToLua_cTCPLink_Connect00);
+ tolua_function(tolua_S,"Send",tolua_AllToLua_cTCPLink_Send00);
+ tolua_function(tolua_S,"SendMessage",tolua_AllToLua_cTCPLink_SendMessage00);
+ tolua_function(tolua_S,"CloseSocket",tolua_AllToLua_cTCPLink_CloseSocket00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cTCPLink","Lua__cTCPLink","cTCPLink",tolua_collect_Lua__cTCPLink);
+ #else
+ tolua_cclass(tolua_S,"Lua__cTCPLink","Lua__cTCPLink","cTCPLink",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cTCPLink");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cTCPLink_tolua__set_instance00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cTCPLink_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cTCPLink_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cTCPLink_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cTCPLink_delete00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Vector3f","Vector3f","",tolua_collect_Vector3f);
+ #else
+ tolua_cclass(tolua_S,"Vector3f","Vector3f","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Vector3f");
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new01_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new02);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new02_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new02_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new03);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new03_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new03_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new04);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new04_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new04_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3f_new05);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3f_new05_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3f_new05_local);
+ tolua_function(tolua_S,"Set",tolua_AllToLua_Vector3f_Set00);
+ tolua_function(tolua_S,"Normalize",tolua_AllToLua_Vector3f_Normalize00);
+ tolua_function(tolua_S,"NormalizeCopy",tolua_AllToLua_Vector3f_NormalizeCopy00);
+ tolua_function(tolua_S,"NormalizeCopy",tolua_AllToLua_Vector3f_NormalizeCopy01);
+ tolua_function(tolua_S,"Length",tolua_AllToLua_Vector3f_Length00);
+ tolua_function(tolua_S,"SqrLength",tolua_AllToLua_Vector3f_SqrLength00);
+ tolua_function(tolua_S,"Dot",tolua_AllToLua_Vector3f_Dot00);
+ tolua_function(tolua_S,"Cross",tolua_AllToLua_Vector3f_Cross00);
+ tolua_function(tolua_S,"Equals",tolua_AllToLua_Vector3f_Equals00);
+ tolua_function(tolua_S,".add",tolua_AllToLua_Vector3f__add00);
+ tolua_function(tolua_S,".add",tolua_AllToLua_Vector3f__add01);
+ tolua_function(tolua_S,".sub",tolua_AllToLua_Vector3f__sub00);
+ tolua_function(tolua_S,".sub",tolua_AllToLua_Vector3f__sub01);
+ tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3f__mul00);
+ tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3f__mul01);
+ tolua_variable(tolua_S,"x",tolua_get_Vector3f_x,tolua_set_Vector3f_x);
+ tolua_variable(tolua_S,"y",tolua_get_Vector3f_y,tolua_set_Vector3f_y);
+ tolua_variable(tolua_S,"z",tolua_get_Vector3f_z,tolua_set_Vector3f_z);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Vector3d","Vector3d","",tolua_collect_Vector3d);
+ #else
+ tolua_cclass(tolua_S,"Vector3d","Vector3d","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Vector3d");
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3d_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3d_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3d_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3d_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3d_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3d_new01_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3d_new02);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3d_new02_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3d_new02_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3d_new03);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3d_new03_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3d_new03_local);
+ tolua_function(tolua_S,"Set",tolua_AllToLua_Vector3d_Set00);
+ tolua_function(tolua_S,"Normalize",tolua_AllToLua_Vector3d_Normalize00);
+ tolua_function(tolua_S,"NormalizeCopy",tolua_AllToLua_Vector3d_NormalizeCopy00);
+ tolua_function(tolua_S,"NormalizeCopy",tolua_AllToLua_Vector3d_NormalizeCopy01);
+ tolua_function(tolua_S,"Length",tolua_AllToLua_Vector3d_Length00);
+ tolua_function(tolua_S,"SqrLength",tolua_AllToLua_Vector3d_SqrLength00);
+ tolua_function(tolua_S,"Dot",tolua_AllToLua_Vector3d_Dot00);
+ tolua_function(tolua_S,"Cross",tolua_AllToLua_Vector3d_Cross00);
+ tolua_function(tolua_S,".add",tolua_AllToLua_Vector3d__add00);
+ tolua_function(tolua_S,".add",tolua_AllToLua_Vector3d__add01);
+ tolua_function(tolua_S,".sub",tolua_AllToLua_Vector3d__sub00);
+ tolua_function(tolua_S,".sub",tolua_AllToLua_Vector3d__sub01);
+ tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3d__mul00);
+ tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3d__mul01);
+ tolua_variable(tolua_S,"x",tolua_get_Vector3d_x,tolua_set_Vector3d_x);
+ tolua_variable(tolua_S,"y",tolua_get_Vector3d_y,tolua_set_Vector3d_y);
+ tolua_variable(tolua_S,"z",tolua_get_Vector3d_z,tolua_set_Vector3d_z);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Vector3i","Vector3i","",tolua_collect_Vector3i);
+ #else
+ tolua_cclass(tolua_S,"Vector3i","Vector3i","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Vector3i");
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3i_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3i_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3i_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3i_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3i_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3i_new01_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Vector3i_new02);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Vector3i_new02_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Vector3i_new02_local);
+ tolua_function(tolua_S,"Set",tolua_AllToLua_Vector3i_Set00);
+ tolua_function(tolua_S,"Length",tolua_AllToLua_Vector3i_Length00);
+ tolua_function(tolua_S,"SqrLength",tolua_AllToLua_Vector3i_SqrLength00);
+ tolua_function(tolua_S,"Equals",tolua_AllToLua_Vector3i_Equals00);
+ tolua_function(tolua_S,"Equals",tolua_AllToLua_Vector3i_Equals01);
+ tolua_variable(tolua_S,"x",tolua_get_Vector3i_x,tolua_set_Vector3i_x);
+ tolua_variable(tolua_S,"y",tolua_get_Vector3i_y,tolua_set_Vector3i_y);
+ tolua_variable(tolua_S,"z",tolua_get_Vector3i_z,tolua_set_Vector3i_z);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cCuboid","cCuboid","",tolua_collect_cCuboid);
+ #else
+ tolua_cclass(tolua_S,"cCuboid","cCuboid","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cCuboid");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cCuboid_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cCuboid_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cCuboid_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_cCuboid_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cCuboid_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cCuboid_new01_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_cCuboid_new02);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cCuboid_new02_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cCuboid_new02_local);
+ tolua_variable(tolua_S,"p1",tolua_get_cCuboid_p1,tolua_set_cCuboid_p1);
+ tolua_variable(tolua_S,"p2",tolua_get_cCuboid_p2,tolua_set_cCuboid_p2);
+ tolua_function(tolua_S,"Sort",tolua_AllToLua_cCuboid_Sort00);
+ tolua_function(tolua_S,"IsInside",tolua_AllToLua_cCuboid_IsInside00);
+ tolua_function(tolua_S,"IsInside",tolua_AllToLua_cCuboid_IsInside01);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cMCLogger","cMCLogger","",tolua_collect_cMCLogger);
+ #else
+ tolua_cclass(tolua_S,"cMCLogger","cMCLogger","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cMCLogger");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cMCLogger_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cMCLogger_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cMCLogger_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cMCLogger_delete00);
+ tolua_function(tolua_S,"LogSimple",tolua_AllToLua_cMCLogger_LogSimple00);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cTracer","cTracer","",tolua_collect_cTracer);
+ #else
+ tolua_cclass(tolua_S,"cTracer","cTracer","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cTracer");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cTracer_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cTracer_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cTracer_new00_local);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cTracer_delete00);
+ tolua_function(tolua_S,"Trace",tolua_AllToLua_cTracer_Trace00);
+ tolua_function(tolua_S,"SetValues",tolua_AllToLua_cTracer_SetValues00);
+ tolua_variable(tolua_S,"BlockHitPosition",tolua_get_cTracer_BlockHitPosition_ptr,tolua_set_cTracer_BlockHitPosition_ptr);
+ tolua_variable(tolua_S,"HitNormal",tolua_get_cTracer_HitNormal_ptr,tolua_set_cTracer_HitNormal_ptr);
+ tolua_variable(tolua_S,"RealHit",tolua_get_cTracer_RealHit_ptr,tolua_set_cTracer_RealHit_ptr);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cGroup","cGroup","",NULL);
+ tolua_beginmodule(tolua_S,"cGroup");
+ tolua_function(tolua_S,"SetName",tolua_AllToLua_cGroup_SetName00);
+ tolua_function(tolua_S,"GetName",tolua_AllToLua_cGroup_GetName00);
+ tolua_function(tolua_S,"SetColor",tolua_AllToLua_cGroup_SetColor00);
+ tolua_function(tolua_S,"AddCommand",tolua_AllToLua_cGroup_AddCommand00);
+ tolua_function(tolua_S,"AddPermission",tolua_AllToLua_cGroup_AddPermission00);
+ tolua_function(tolua_S,"InheritFrom",tolua_AllToLua_cGroup_InheritFrom00);
+ tolua_function(tolua_S,"HasCommand",tolua_AllToLua_cGroup_HasCommand00);
+ tolua_function(tolua_S,"GetColor",tolua_AllToLua_cGroup_GetColor00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPacket_Login","cPacket_Login","cPacket",NULL);
+ tolua_beginmodule(tolua_S,"cPacket_Login");
+ tolua_variable(tolua_S,"m_ProtocolVersion",tolua_get_cPacket_Login_m_ProtocolVersion,tolua_set_cPacket_Login_m_ProtocolVersion);
+ tolua_variable(tolua_S,"m_Username",tolua_get_cPacket_Login_m_Username,tolua_set_cPacket_Login_m_Username);
+ tolua_variable(tolua_S,"m_MapSeed",tolua_get_cPacket_Login_m_MapSeed,tolua_set_cPacket_Login_m_MapSeed);
+ tolua_variable(tolua_S,"m_Dimension",tolua_get_cPacket_Login_m_Dimension,tolua_set_cPacket_Login_m_Dimension);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cPacket_BlockDig","cPacket_BlockDig","cPacket",tolua_collect_cPacket_BlockDig);
+ #else
+ tolua_cclass(tolua_S,"cPacket_BlockDig","cPacket_BlockDig","cPacket",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cPacket_BlockDig");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cPacket_BlockDig_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cPacket_BlockDig_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cPacket_BlockDig_new00_local);
+ tolua_function(tolua_S,"Clone",tolua_AllToLua_cPacket_BlockDig_Clone00);
+ tolua_variable(tolua_S,"m_Status",tolua_get_cPacket_BlockDig_m_Status,tolua_set_cPacket_BlockDig_m_Status);
+ tolua_variable(tolua_S,"m_PosX",tolua_get_cPacket_BlockDig_m_PosX,tolua_set_cPacket_BlockDig_m_PosX);
+ tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockDig_m_PosY,tolua_set_cPacket_BlockDig_m_PosY);
+ tolua_variable(tolua_S,"m_PosZ",tolua_get_cPacket_BlockDig_m_PosZ,tolua_set_cPacket_BlockDig_m_PosZ);
+ tolua_variable(tolua_S,"m_Direction",tolua_get_cPacket_BlockDig_m_Direction,tolua_set_cPacket_BlockDig_m_Direction);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"Lua__cPacket_BlockDig","Lua__cPacket_BlockDig","cPacket_BlockDig",tolua_collect_Lua__cPacket_BlockDig);
+ #else
+ tolua_cclass(tolua_S,"Lua__cPacket_BlockDig","Lua__cPacket_BlockDig","cPacket_BlockDig",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"Lua__cPacket_BlockDig");
+ tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00);
+ tolua_function(tolua_S,"cPacket_BlockDig__Clone",tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00);
+ tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPacket_BlockDig_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPacket_BlockDig_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPacket_BlockDig_new00_local);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cPacket_BlockPlace","cPacket_BlockPlace","cPacket",NULL);
+ tolua_beginmodule(tolua_S,"cPacket_BlockPlace");
+ tolua_variable(tolua_S,"m_PosX",tolua_get_cPacket_BlockPlace_m_PosX,tolua_set_cPacket_BlockPlace_m_PosX);
+ tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockPlace_m_PosY,tolua_set_cPacket_BlockPlace_m_PosY);
+ tolua_variable(tolua_S,"m_PosZ",tolua_get_cPacket_BlockPlace_m_PosZ,tolua_set_cPacket_BlockPlace_m_PosZ);
+ tolua_variable(tolua_S,"m_Direction",tolua_get_cPacket_BlockPlace_m_Direction,tolua_set_cPacket_BlockPlace_m_Direction);
+ tolua_variable(tolua_S,"m_ItemType",tolua_get_cPacket_BlockPlace_m_ItemType,tolua_set_cPacket_BlockPlace_m_ItemType);
+ tolua_variable(tolua_S,"m_Count",tolua_get_cPacket_BlockPlace_m_Count,tolua_set_cPacket_BlockPlace_m_Count);
+ tolua_variable(tolua_S,"m_Uses",tolua_get_cPacket_BlockPlace_m_Uses,tolua_set_cPacket_BlockPlace_m_Uses);
+ tolua_endmodule(tolua_S);
+ tolua_endmodule(tolua_S);
+ return 1;
+}
+
+
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ TOLUA_API int luaopen_AllToLua (lua_State* tolua_S) {
+ return tolua_AllToLua_open(tolua_S);
+};
+#endif
+
diff --git a/source/Bindings.h b/source/Bindings.h
new file mode 100644
index 000000000..4fb3dfa9e
--- /dev/null
+++ b/source/Bindings.h
@@ -0,0 +1,8 @@
+/*
+** Lua binding: AllToLua
+** Generated automatically by tolua++-1.0.92 on 07/15/11 01:36:28.
+*/
+
+/* Exported function */
+TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
+
diff --git a/source/BlockID.h b/source/BlockID.h
new file mode 100644
index 000000000..3304e3b99
--- /dev/null
+++ b/source/BlockID.h
@@ -0,0 +1,151 @@
+#pragma once
+
+//tolua_begin
+enum ENUM_BLOCK_ID
+{
+ E_BLOCK_AIR = 0,
+ E_BLOCK_STONE = 1,
+ E_BLOCK_GRASS = 2,
+ E_BLOCK_DIRT = 3,
+ E_BLOCK_COBBLESTONE = 4,
+ E_BLOCK_WOOD = 5,
+ E_BLOCK_SAPLING = 6,
+ E_BLOCK_BEDROCK = 7,
+ E_BLOCK_WATER = 8,
+ E_BLOCK_STATIONARY_WATER = 9,
+ E_BLOCK_LAVA = 10,
+ E_BLOCK_STATIONARY_LAVA = 11,
+ E_BLOCK_SAND = 12,
+ E_BLOCK_GRAVEL = 13,
+ E_BLOCK_GOLD_ORE = 14,
+ E_BLOCK_IRON_ORE = 15,
+ E_BLOCK_COAL_ORE = 16,
+ E_BLOCK_LOG = 17,
+ E_BLOCK_LEAVES = 18,
+ E_BLOCK_SPONGE = 19,
+ E_BLOCK_GLASS = 20,
+ E_BLOCK_WHITE_CLOTH = 35,
+ E_BLOCK_YELLOW_FLOWER = 37,
+ E_BLOCK_RED_ROSE = 38,
+ E_BLOCK_BROWN_MUSHROOM = 39,
+ E_BLOCK_RED_MUSHROOM = 40,
+ E_BLOCK_GOLD_BLOCK = 41,
+ E_BLOCK_IRON_BLOCK = 42,
+ E_BLOCK_DOUBLE_STEP = 43,
+ E_BLOCK_STEP = 44,
+ E_BLOCK_BRICK = 45,
+ E_BLOCK_TNT = 46,
+ E_BLOCK_BOOKCASE = 47,
+ E_BLOCK_MOSSY_COBBLESTONE = 48,
+ E_BLOCK_OBSIDIAN = 49,
+ E_BLOCK_TORCH = 50,
+ E_BLOCK_FIRE = 51,
+ E_BLOCK_MOB_SPAWNER = 52,
+ E_BLOCK_WOODEN_STAIRS = 53,
+ E_BLOCK_CHEST = 54,
+ E_BLOCK_REDSTONE_WIRE = 55,
+ E_BLOCK_DIAMOND_ORE = 56,
+ E_BLOCK_DIAMOND_BLOCK = 57,
+ E_BLOCK_WORKBENCH = 58,
+ E_BLOCK_CROPS = 59,
+ E_BLOCK_SOIL = 60,
+ E_BLOCK_FURNACE = 61,
+ E_BLOCK_BURNING_FURNACE = 62,
+ E_BLOCK_SIGN_POST = 63,
+ E_BLOCK_WOODEN_DOOR = 64,
+ E_BLOCK_LADDER = 65,
+ E_BLOCK_MINECART_TRACKS = 66,
+ E_BLOCK_COBBLESTONE_STAIRS = 67,
+ E_BLOCK_WALLSIGN = 68,
+ E_BLOCK_LEVER = 69,
+ E_BLOCK_STONE_PRESSURE_PLATE = 70,
+ E_BLOCK_IRON_DOOR = 71,
+ E_BLOCK_WOODEN_PRESSURE_PLATE = 72,
+ E_BLOCK_REDSTONE_ORE = 73,
+ E_BLOCK_REDSTONE_ORE_GLOWING = 74,
+ E_BLOCK_REDSTONE_TORCH_ON = 75,
+ E_BLOCK_REDSTONE_TORCH_OFF = 76,
+
+ E_BLOCK_SNOW = 78,
+ E_BLOCK_ICE = 79,
+ E_BLOCK_SNOW_BLOCK = 80,
+ E_BLOCK_CACTUS = 81,
+ E_BLOCK_CLAY = 82,
+ E_BLOCK_REEDS = 83,
+
+ E_BLOCK_BLOODSTONE = 87,
+ E_BLOCK_SOULSAND = 88,
+ E_BLOCK_GLOWSTONE = 89,
+ E_BLOCK_PORT = 90,
+ E_BLOCK_JACK_O_LANTERN = 91,
+ E_BLOCK_CAKE = 92,
+ E_BLOCK_REDSTONE_REPEATER_OFF = 93,
+ E_BLOCK_REDSTONE_REPEATER_ON = 94,
+ E_BLOCK_LOCKED_CHEST = 95,
+ E_BLOCK_TRAPDOOR = 96,
+};
+//tolua_end
+
+//tolua_begin
+enum ENUM_ITEM_ID
+{
+ E_ITEM_EMPTY = -1,
+ E_ITEM_STONE = 1,
+ E_ITEM_GRASS = 2,
+ E_ITEM_DIRT = 3,
+ E_ITEM_COBBLESTONE = 4,
+ E_ITEM_WOOD = 5,
+ E_ITEM_SAPLING = 6,
+ E_ITEM_BEDROCK = 7,
+ E_ITEM_WATER = 8,
+ E_ITEM_STATIONARY_WATER = 9,
+ E_ITEM_LAVA = 10,
+ E_ITEM_STATIONARY_LAVA = 11,
+ E_ITEM_SAND = 12,
+ E_ITEM_GRAVEL = 13,
+ E_ITEM_GOLD_ORE = 14,
+ E_ITEM_IRON_ORE = 15,
+ E_ITEM_COAL_ORE = 16,
+ E_ITEM_LOG = 17,
+ E_ITEM_LEAVES = 18,
+ E_ITEM_GOLD_BLOCK = 41,
+ E_ITEM_IRON_BLOCK = 42,
+ E_ITEM_DIAMOND_BLOCK = 57,
+ E_ITEM_FLINT_AND_STEEL = 259,
+ E_ITEM_APPLE = 260,
+ E_ITEM_BOW = 261,
+ E_ITEM_ARROW = 262,
+ E_ITEM_COAL = 263,
+ E_ITEM_DIAMOND = 264,
+ E_ITEM_IRON = 265,
+ E_ITEM_GOLD = 266,
+
+ E_ITEM_MUSHROOM_SOUP = 282,
+ E_ITEM_GOLD_SWORD = 283,
+ E_ITEM_GOLD_SHOVEL = 284,
+ E_ITEM_GOLD_PICKAXE = 285,
+ E_ITEM_GOLD_AXE = 286,
+ E_ITEM_STRING = 287,
+ E_ITEM_FEATHER = 288,
+
+ E_ITEM_BREAD = 297,
+
+ E_ITEM_RAW_MEAT = 319,
+ E_ITEM_COOKED_MEAT = 320,
+
+ E_ITEM_GOLDEN_APPLE = 322,
+ E_ITEM_SIGN = 323,
+
+ E_ITEM_MILK = 335,
+
+ E_ITEM_EGG = 344,
+ E_ITEM_COMPASS = 345,
+ E_ITEM_FISHING_ROD = 346,
+ E_ITEM_CLOCK = 347,
+ E_ITEM_GLOWSTONE_DUST = 348,
+ E_ITEM_RAW_FISH = 349,
+ E_ITEM_COOKED_FISH = 350,
+
+ E_ITEM_CAKE = 354,
+};
+//tolua_end \ No newline at end of file
diff --git a/source/Defines.h b/source/Defines.h
new file mode 100644
index 000000000..1b176208c
--- /dev/null
+++ b/source/Defines.h
@@ -0,0 +1,129 @@
+#pragma once
+
+#include "MemoryLeak.h"
+
+//tolua_begin
+// emissive blocks
+extern char g_BlockLightValue[];
+// whether blocks allow spreading
+extern char g_BlockSpreadLightFalloff[];
+// whether blocks are transparent (light can shine though)
+extern bool g_BlockTransparent[];
+// one hit break blocks
+extern bool g_BlockOneHitDig[];
+//tolua_end
+
+//--DO NOT DELETE THIS COMMENT-- //tolua_export
+
+inline bool IsValidBlock( int a_BlockID ) //tolua_export
+{ //tolua_export
+ if( a_BlockID > -1 &&
+ a_BlockID <= 96 &&
+ a_BlockID != 29 &&
+ a_BlockID != 33 &&
+ a_BlockID != 34 &&
+ a_BlockID != 36 )
+ {
+ return true;
+ }
+ return false;
+} //tolua_export
+
+inline bool isValidItem( int a_ItemID ) //tolua_export
+{ //tolua_export
+ if( (a_ItemID >= 256 && a_ItemID <= 358)
+ || (a_ItemID == 2256 || a_ItemID == 2257) )
+ {
+ return true;
+ }
+
+ if( a_ItemID == 0 )
+ return false;
+
+ return IsValidBlock( a_ItemID );
+} //tolua_export
+
+inline void AddDirection( int & a_X, char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export
+{//tolua_export
+ if( !a_bInverse )
+ {
+ switch( a_Direction )
+ {
+ case 0:
+ a_Y--;
+ break;
+ case 1:
+ a_Y++;
+ break;
+ case 2:
+ a_Z--;
+ break;
+ case 3:
+ a_Z++;
+ break;
+ case 4:
+ a_X--;
+ break;
+ case 5:
+ a_X++;
+ break;
+ };
+ }
+ else
+ {
+ switch( a_Direction ) // other way around
+ {
+ case 0:
+ a_Y++;
+ break;
+ case 1:
+ a_Y--;
+ break;
+ case 2:
+ a_Z++;
+ break;
+ case 3:
+ a_Z--;
+ break;
+ case 4:
+ a_X++;
+ break;
+ case 5:
+ a_X--;
+ break;
+ };
+ }
+}//tolua_export
+
+#include <math.h>
+#define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f
+#define MIN(a,b) (((a)>(b))?(b):(a))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+inline void EulerToVector( float a_Pan, float a_Pitch, float & a_X, float & a_Y, float & a_Z )
+{
+// a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
+// a_Y = -sinf ( a_Pitch / 180 * PI );
+// a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
+a_X = cos(a_Pan / 180 * PI)*cos(a_Pitch / 180 * PI);
+a_Y = sin(a_Pan / 180 * PI)*cos(a_Pitch / 180 * PI);
+a_Z = sin(a_Pitch / 180 * PI);
+}
+
+inline void VectorToEuler( float a_X, float a_Y, float a_Z, float & a_Pan, float & a_Pitch )
+{
+ if( a_X != 0 )
+ a_Pan = atan2( a_Z, a_X ) * 180 / PI - 90;
+ else
+ a_Pan = 0;
+ a_Pitch = atan2(a_Y, sqrtf((a_X * a_X) + (a_Z * a_Z))) * 180 / PI;
+}
+
+inline float GetSignf( float a_Val )
+{
+ return (a_Val < 0.f)?-1.f:1.f;
+}
+
+inline float GetSpecialSignf( float a_Val )
+{
+ return (a_Val <= 0.f)?-1.f:1.f;
+}
diff --git a/source/Endianness.h b/source/Endianness.h
new file mode 100644
index 000000000..9e62c48c4
--- /dev/null
+++ b/source/Endianness.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <string>
+#ifdef _WIN32
+#include <WinSock.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#endif
+
+// Changes endianness
+inline unsigned long long HostToNetwork8( void* a_Value )
+{
+ unsigned long long __HostToNetwork8;
+ memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
+ __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32));
+ return __HostToNetwork8;
+}
+
+inline unsigned int HostToNetwork4( void* a_Value )
+{
+ unsigned int __HostToNetwork4;
+ memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
+ __HostToNetwork4 = ntohl( __HostToNetwork4 );
+ return __HostToNetwork4;
+}
+
+inline double NetworkToHostDouble8( void* a_Value )
+{
+#define ntohll(x) ((((unsigned long long)ntohl((u_long)x)) << 32) + ntohl(x >> 32))
+ unsigned long long buf = 0;//(*(unsigned long long*)a_Value);
+ memcpy( &buf, a_Value, 8 );
+ buf = ntohll(buf);
+ double x;
+ memcpy(&x, &buf, sizeof(double));
+ return x;
+}
+
+inline long long NetworkToHostLong8( void* a_Value )
+{
+ unsigned long long buf = *(unsigned long long*)a_Value;
+ buf = ntohll(buf);
+ return *reinterpret_cast<long long *>(&buf);
+}
+
+inline float NetworkToHostFloat4( void* a_Value )
+{
+ u_long buf = *(u_long*)a_Value;
+ buf = ntohl( buf );
+ return *(float*)reinterpret_cast<float *>(&buf);
+} \ No newline at end of file
diff --git a/source/FileDefine.h b/source/FileDefine.h
new file mode 100644
index 000000000..826d6dd75
--- /dev/null
+++ b/source/FileDefine.h
@@ -0,0 +1,21 @@
+#pragma once
+
+// So we don't have to include fstream :P
+#ifdef _WIN32
+#ifndef _FILE_DEFINED
+struct _iobuf {
+ char *_ptr;
+ int _cnt;
+ char *_base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char *_tmpfname;
+};
+typedef struct _iobuf FILE;
+#define _FILE_DEFINED
+#endif
+#else
+#include <stdio.h>
+#endif \ No newline at end of file
diff --git a/source/LuaFunctions.h b/source/LuaFunctions.h
new file mode 100644
index 000000000..04de7784f
--- /dev/null
+++ b/source/LuaFunctions.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "cMCLogger.h"
+#include <time.h>
+// tolua_begin
+
+unsigned int GetTime()
+{
+ return (unsigned int)time(0);
+}
+
+std::string GetChar( std::string & a_Str, unsigned int a_Idx )
+{
+ return std::string(1, a_Str[ a_Idx ]);
+}
+
+// tolua_end
diff --git a/source/MCSocket.h b/source/MCSocket.h
new file mode 100644
index 000000000..554a5f35b
--- /dev/null
+++ b/source/MCSocket.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#ifdef _WIN32
+
+#include <winsock2.h>
+#define socklen_t int
+#ifdef SendMessage
+#undef SendMessage
+#endif
+#else
+
+// Linux threads http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include <unistd.h>
+#define SOCKET int
+typedef void *HANDLE;
+#define CRITICAL_SECTION pthread_mutex_t
+#define SD_BOTH (2)
+#define closesocket(x) (shutdown(x, SD_BOTH), close(x))
+#define SOCKET_ERROR SO_ERROR
+#define EnterCriticalSection(x) pthread_mutex_lock(x)
+#define LeaveCriticalSection(x) pthread_mutex_unlock(x)
+#define InitializeCriticalSection(x) pthread_mutex_init(x, NULL)
+#define DeleteCriticalSection(x) (x)
+#define sprintf_s(x, y, ...) sprintf(x, __VA_ARGS__)
+
+#endif
+
+inline bool IsSocketError( int a_ReturnedValue )
+{
+ #ifdef _WIN32
+ return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+ #else
+ return (a_ReturnedValue <= 0);
+ #endif
+}
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
new file mode 100644
index 000000000..728320f11
--- /dev/null
+++ b/source/ManualBindings.cpp
@@ -0,0 +1,229 @@
+#include "ManualBindings.h"
+#include "tolua++.h"
+#include "cMCLogger.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPlugin.h"
+#include "cPluginManager.h"
+#include "cLuaCommandBinder.h"
+#include "cPlayer.h"
+#include "md5/md5.h"
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+/****************************
+ * Lua bound functions with special return types
+ **/
+
+static int tolua_StringSplit(lua_State* tolua_S)
+{
+ std::string str = ((std::string) tolua_tocppstring(tolua_S,1,0));
+ std::string delim = ((std::string) tolua_tocppstring(tolua_S,2,0));
+
+ std::vector<std::string> Split = StringSplit( str, delim );
+
+ lua_createtable(tolua_S, Split.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ std::vector<std::string>::const_iterator iter = Split.begin();
+ while(iter != Split.end()) {
+ tolua_pushstring( tolua_S, (*iter).c_str() );
+ lua_rawseti(tolua_S, newTable, index);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+static int tolua_LOG(lua_State* tolua_S)
+{
+ const char* str = tolua_tocppstring(tolua_S,1,0);
+ cMCLogger::GetInstance()->LogSimple( str, 0 );
+ return 0;
+}
+
+static int tolua_LOGINFO(lua_State* tolua_S)
+{
+ const char* str = tolua_tocppstring(tolua_S,1,0);
+ cMCLogger::GetInstance()->LogSimple( str, 1 );
+ return 0;
+}
+
+static int tolua_LOGWARN(lua_State* tolua_S)
+{
+ const char* str = tolua_tocppstring(tolua_S,1,0);
+ cMCLogger::GetInstance()->LogSimple( str, 2 );
+ return 0;
+}
+
+static int tolua_LOGERROR(lua_State* tolua_S)
+{
+ const char* str = tolua_tocppstring(tolua_S,1,0);
+ cMCLogger::GetInstance()->LogSimple( str, 3 );
+ return 0;
+}
+
+static int tolua_cWorld_GetAllPlayers(lua_State* tolua_S)
+{
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ lua_State* L = tolua_S;
+
+ self->GetAllPlayers(L);
+
+ return 1;
+}
+
+static int tolua_cPlugin_GetCommands(lua_State* tolua_S)
+{
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+
+ const std::vector< cPlugin::CommandStruct > & AllCommands = self->GetCommands();
+
+ lua_createtable(tolua_S, AllCommands.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ std::vector< cPlugin::CommandStruct >::const_iterator iter = AllCommands.begin();
+ while(iter != AllCommands.end())
+ {
+ const cPlugin::CommandStruct & CS = *iter;
+ tolua_pushusertype( tolua_S, (void*)&CS, "const cPlugin::CommandStruct" );
+ lua_rawseti(tolua_S, newTable, index);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+static int tolua_cPluginManager_GetAllPlugins(lua_State* tolua_S)
+{
+ cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+
+ const cPluginManager::PluginList & AllPlugins = self->GetAllPlugins();
+
+ lua_createtable(tolua_S, AllPlugins.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ cPluginManager::PluginList::const_iterator iter = AllPlugins.begin();
+ while(iter != AllPlugins.end())
+ {
+ const cPlugin* Plugin = *iter;
+ tolua_pushusertype( tolua_S, (void*)Plugin, "const cPlugin" );
+ lua_rawseti(tolua_S, newTable, index);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
+{
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+
+ const cPlayer::GroupList & AllGroups = self->GetGroups();
+
+ lua_createtable(tolua_S, AllGroups.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ cPlayer::GroupList::const_iterator iter = AllGroups.begin();
+ while(iter != AllGroups.end())
+ {
+ const cGroup* Group = *iter;
+ tolua_pushusertype( tolua_S, (void*)Group, "const cGroup" );
+ lua_rawseti(tolua_S, newTable, index);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+static int tolua_cPlugin_BindCommand(lua_State* tolua_S)
+{
+ cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
+ cPluginManager* PluginManager = cRoot::Get()->GetPluginManager();
+ cLuaCommandBinder* CommandBinder = PluginManager->GetLuaCommandBinder();
+
+ tolua_Error tolua_err;
+ tolua_err.array = 0;
+ tolua_err.index = 0;
+ tolua_err.type = 0;
+
+ std::string Permission = "";
+ std::string Command = "";
+ int Reference = LUA_REFNIL;
+
+ if( tolua_isstring( tolua_S, 2, 0, &tolua_err ) &&
+ lua_isfunction( tolua_S, 3 ) )
+ {
+ Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
+ Command = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ }
+ else if( tolua_isstring( tolua_S, 2, 0, &tolua_err ) &&
+ tolua_isstring( tolua_S, 3, 0, &tolua_err ) &&
+ lua_isfunction( tolua_S, 4 ) )
+ {
+ Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
+ Command = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ Permission = ((std::string) tolua_tocppstring(tolua_S,3,0));
+ }
+ else
+ {
+ if( tolua_err.type == 0 )
+ {
+ tolua_err.type = "function";
+ }
+ tolua_error(tolua_S,"#ferror in function 'BindCommand'.",&tolua_err);
+ return 0;
+ }
+
+ if( Reference != LUA_REFNIL )
+ {
+ if( !CommandBinder->BindCommand( Command, Permission, self, tolua_S, Reference ) )
+ {
+ luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference );
+ }
+ }
+ else
+ {
+ LOGERROR("ERROR: cPlugin:BindCommand invalid function reference in 2nd argument (Command: \"%s\")", Command.c_str() );
+ }
+
+ return 0;
+}
+
+static int tolua_md5(lua_State* tolua_S)
+{
+ std::string SourceString = tolua_tostring(tolua_S, 1, 0);
+ std::string CryptedString = md5( SourceString );
+ tolua_pushstring( tolua_S, CryptedString.c_str() );
+ return 1;
+}
+
+void ManualBindings::Bind( lua_State* tolua_S )
+{
+ tolua_beginmodule(tolua_S,NULL);
+ tolua_function(tolua_S,"StringSplit",tolua_StringSplit);
+ tolua_function(tolua_S,"LOG",tolua_LOG);
+ tolua_function(tolua_S,"LOGINFO",tolua_LOGINFO);
+ tolua_function(tolua_S,"LOGWARN",tolua_LOGWARN);
+ tolua_function(tolua_S,"LOGERROR",tolua_LOGERROR);
+ tolua_function(tolua_S,"Log",tolua_LOG); // Deprecated
+
+ tolua_beginmodule(tolua_S,"cWorld");
+ tolua_function(tolua_S,"GetAllPlayers",tolua_cWorld_GetAllPlayers);
+ tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S,"cPlugin");
+ tolua_function(tolua_S,"GetCommands",tolua_cPlugin_GetCommands);
+ tolua_function(tolua_S,"BindCommand",tolua_cPlugin_BindCommand);
+ tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S,"cPluginManager");
+ tolua_function(tolua_S,"GetAllPlugins",tolua_cPluginManager_GetAllPlugins);
+ tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S,"cPlayer");
+ tolua_function(tolua_S,"GetGroups",tolua_cPlayer_GetGroups);
+ tolua_endmodule(tolua_S);
+
+ tolua_function(tolua_S,"md5",tolua_md5);
+
+ tolua_endmodule(tolua_S);
+}
diff --git a/source/ManualBindings.h b/source/ManualBindings.h
new file mode 100644
index 000000000..147a1362d
--- /dev/null
+++ b/source/ManualBindings.h
@@ -0,0 +1,8 @@
+#pragma once
+
+struct lua_State;
+class ManualBindings
+{
+public:
+ static void Bind( lua_State* tolua_S );
+}; \ No newline at end of file
diff --git a/source/Matrix4f.cpp b/source/Matrix4f.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/source/Matrix4f.cpp
diff --git a/source/Matrix4f.h b/source/Matrix4f.h
new file mode 100644
index 000000000..8d92f6e44
--- /dev/null
+++ b/source/Matrix4f.h
@@ -0,0 +1,111 @@
+#pragma once
+
+#define _USE_MATH_DEFINES
+#include <math.h>
+#include "Vector3f.h"
+
+class Matrix4f
+{
+public:
+ enum
+ {
+ TX=3,
+ TY=7,
+ TZ=11,
+ D0=0, D1=5, D2=10, D3=15,
+ SX=D0, SY=D1, SZ=D2,
+ W=D3
+ };
+ Matrix4f() { Identity(); }
+ float& operator [] ( int a_N ) { return cell[a_N]; }
+ void Identity()
+ {
+ cell[1] = cell[2] = cell[TX] = cell[4] = cell[6] = cell[TY] =
+ cell[8] = cell[9] = cell[TZ] = cell[12] = cell[13] = cell[14] = 0;
+ cell[D0] = cell[D1] = cell[D2] = cell[W] = 1;
+ }
+ void Init( Vector3f a_Pos, float a_RX, float a_RY, float a_RZ )
+ {
+ Matrix4f t;
+ t.RotateX( a_RZ );
+ RotateY( a_RY );
+ Concatenate( t );
+ t.RotateZ( a_RX );
+ Concatenate( t );
+ Translate( a_Pos );
+ }
+ void RotateX( float a_RX )
+ {
+ float sx = (float)sin( a_RX * M_PI / 180 );
+ float cx = (float)cos( a_RX * M_PI / 180 );
+ Identity();
+ cell[5] = cx, cell[6] = sx, cell[9] = -sx, cell[10] = cx;
+ }
+ void RotateY( float a_RY )
+ {
+ float sy = (float)sin( a_RY * M_PI / 180 );
+ float cy = (float)cos( a_RY * M_PI / 180 );
+ Identity ();
+ cell[0] = cy, cell[2] = -sy, cell[8] = sy, cell[10] = cy;
+ }
+ void RotateZ( float a_RZ )
+ {
+ float sz = (float)sin( a_RZ * M_PI / 180 );
+ float cz = (float)cos( a_RZ * M_PI / 180 );
+ Identity ();
+ cell[0] = cz, cell[1] = sz, cell[4] = -sz, cell[5] = cz;
+ }
+ void Translate( Vector3f a_Pos ) { cell[TX] += a_Pos.x; cell[TY] += a_Pos.y; cell[TZ] += a_Pos.z; }
+ void SetTranslation( Vector3f a_Pos ) { cell[TX] = a_Pos.x; cell[TY] = a_Pos.y; cell[TZ] = a_Pos.z; }
+ void Concatenate( const Matrix4f& m2 )
+ {
+ Matrix4f res;
+ int c;
+ for ( c = 0; c < 4; c++ ) for ( int r = 0; r < 4; r++ )
+ res.cell[r * 4 + c] = cell[r * 4] * m2.cell[c] +
+ cell[r * 4 + 1] * m2.cell[c + 4] +
+ cell[r * 4 + 2] * m2.cell[c + 8] +
+ cell[r * 4 + 3] * m2.cell[c + 12];
+ for ( c = 0; c < 16; c++ ) cell[c] = res.cell[c];
+ }
+ Vector3f Transform( const Vector3f& v ) const
+ {
+ float x = cell[0] * v.x + cell[1] * v.y + cell[2] * v.z + cell[3];
+ float y = cell[4] * v.x + cell[5] * v.y + cell[6] * v.z + cell[7];
+ float z = cell[8] * v.x + cell[9] * v.y + cell[10] * v.z + cell[11];
+ return Vector3f( x, y, z );
+ }
+ void Invert()
+ {
+ Matrix4f t;
+ int h, i;
+ float tx = -cell[3], ty = -cell[7], tz = -cell[11];
+ for ( h = 0; h < 3; h++ ) for ( int v = 0; v < 3; v++ ) t.cell[h + v * 4] = cell[v + h * 4];
+ for ( i = 0; i < 11; i++ ) cell[i] = t.cell[i];
+ cell[3] = tx * cell[0] + ty * cell[1] + tz * cell[2];
+ cell[7] = tx * cell[4] + ty * cell[5] + tz * cell[6];
+ cell[11] = tx * cell[8] + ty * cell[9] + tz * cell[10];
+ }
+ Vector3f GetXColumn() { return Vector3f( cell[0], cell[1], cell[2] ); }
+ Vector3f GetYColumn() { return Vector3f( cell[4], cell[5], cell[6] ); }
+ Vector3f GetZColumn() { return Vector3f( cell[8], cell[9], cell[10] ); }
+ void SetXColumn( const Vector3f & a_X )
+ {
+ cell[0] = a_X.x;
+ cell[1] = a_X.y;
+ cell[2] = a_X.z;
+ }
+ void SetYColumn( const Vector3f & a_Y )
+ {
+ cell[4] = a_Y.x;
+ cell[5] = a_Y.y;
+ cell[6] = a_Y.z;
+ }
+ void SetZColumn( const Vector3f & a_Z )
+ {
+ cell[8] = a_Z.x;
+ cell[9] = a_Z.y;
+ cell[10] = a_Z.z;
+ }
+ float cell[16];
+};
diff --git a/source/MemoryLeak.h b/source/MemoryLeak.h
new file mode 100644
index 000000000..6ac06a302
--- /dev/null
+++ b/source/MemoryLeak.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#ifdef _WIN32
+
+#ifdef _DEBUG
+
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+
+#ifndef DEBUG_NEW
+#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
+#define new DEBUG_NEW
+#endif
+
+#endif
+
+#endif
diff --git a/source/PacketID.h b/source/PacketID.h
new file mode 100644
index 000000000..6a5611ae0
--- /dev/null
+++ b/source/PacketID.h
@@ -0,0 +1,52 @@
+#pragma once
+
+//tolua_begin
+enum ENUM_PACKET_ID
+{
+ E_KEEP_ALIVE = 0x00,
+ E_LOGIN = 0x01,
+ E_HANDSHAKE = 0x02,
+ E_CHAT = 0x03,
+ E_UPDATE_TIME = 0x04,
+ E_ENTITY_EQUIPMENT = 0x05,
+ E_USE_ENTITY = 0x07,
+ E_UPDATE_HEALTH = 0x08,
+ E_RESPAWN = 0x09,
+ E_FLYING = 0x0a,
+ E_PLAYERPOS = 0x0b,
+ E_PLAYERLOOK = 0x0c,
+ E_PLAYERMOVELOOK= 0x0d,
+ E_BLOCK_DIG = 0x0e,
+ E_BLOCK_PLACE = 0x0f,
+ E_ITEM_SWITCH = 0x10,
+ E_ADD_TO_INV = 0x11,
+ E_ANIMATION = 0x12,
+ E_PACKET_13 = 0x13,
+ E_NAMED_ENTITY_SPAWN = 0x14,
+ E_PICKUP_SPAWN = 0x15,
+ E_COLLECT_ITEM = 0x16,
+ E_ADD_VEHICLE = 0x17,
+ E_SPAWN_MOB = 0x18,
+ E_DESTROY_ENT = 0x1d,
+ E_ENTITY = 0x1e,
+ E_REL_ENT_MOVE = 0x1f,
+ E_ENT_LOOK = 0x20,
+ E_REL_ENT_MOVE_LOOK = 0x21,
+ E_ENT_TELEPORT = 0x22,
+ E_ENT_STATUS = 0x26,
+ E_METADATA = 0x28,
+ E_PRE_CHUNK = 0x32,
+ E_MAP_CHUNK = 0x33,
+ E_MULTI_BLOCK = 0x34,
+ E_BLOCK_CHANGE = 0x35,
+ E_WINDOW_OPEN = 0x64,
+ E_WINDOW_CLOSE = 0x65,
+ E_WINDOW_CLICK = 0x66,
+ E_INVENTORY_SLOT = 0x67,
+ E_INVENTORY_WHOLE = 0x68,
+ E_INVENTORY_PROGRESS= 0x69,
+ E_UPDATE_SIGN = 0x82,
+ E_PING = 0xfe,
+ E_DISCONNECT = 0xff,
+};
+//tolua_end \ No newline at end of file
diff --git a/source/Vector3d.cpp b/source/Vector3d.cpp
new file mode 100644
index 000000000..b2c47972a
--- /dev/null
+++ b/source/Vector3d.cpp
@@ -0,0 +1,16 @@
+#include "Vector3d.h"
+#include "Vector3f.h"
+
+Vector3d::Vector3d(const Vector3f & v )
+ : x( v.x )
+ , y( v.y )
+ , z( v.z )
+{
+}
+
+Vector3d::Vector3d(const Vector3f * v )
+ : x( v->x )
+ , y( v->y )
+ , z( v->z )
+{
+} \ No newline at end of file
diff --git a/source/Vector3d.h b/source/Vector3d.h
new file mode 100644
index 000000000..84b04fce7
--- /dev/null
+++ b/source/Vector3d.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <math.h>
+
+class Vector3f;
+class Vector3d //tolua_export
+{ //tolua_export
+public: //tolua_export
+ // convert from float
+ Vector3d(const Vector3f & v ); //tolua_export
+ Vector3d(const Vector3f * v ); //tolua_export
+
+ Vector3d() : x(0), y(0), z(0) {} //tolua_export
+ Vector3d(double a_x, double a_y, double a_z) : x(a_x), y(a_y), z(a_z) {} //tolua_export
+
+ inline void Set(double a_x, double a_y, double a_z) { x = a_x, y = a_y, z = a_z; } //tolua_export
+ inline void Normalize() { double l = 1.0f / Length(); x *= l; y *= l; z *= l; } //tolua_export
+ inline Vector3d NormalizeCopy() { double l = 1.0f / Length(); return Vector3d( x * l, y * l, z * l ); } //tolua_export
+ inline void NormalizeCopy(Vector3d & a_V) { double l = 1.0f / Length(); a_V.Set(x*l, y*l, z*l ); } //tolua_export
+ inline double Length() const { return (double)sqrt( x * x + y * y + z * z ); } //tolua_export
+ inline double SqrLength() const { return x * x + y * y + z * z; } //tolua_export
+ inline double Dot( const Vector3d & a_V ) const { return x * a_V.x + y * a_V.y + z * a_V.z; } //tolua_export
+ inline Vector3d Cross( const Vector3d & v ) const { return Vector3d( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); } //tolua_export
+
+ void operator += ( const Vector3d& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
+ void operator += ( Vector3d* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
+ void operator -= ( const Vector3d& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
+ void operator -= ( Vector3d* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
+ void operator *= ( double a_f ) { x *= a_f; y *= a_f; z *= a_f; }
+
+ Vector3d operator + ( const Vector3d& v2 ) const { return Vector3d( x + v2.x, y + v2.y, z + v2.z ); } //tolua_export
+ Vector3d operator + ( const Vector3d* v2 ) const { return Vector3d( x + v2->x, y + v2->y, z + v2->z ); } //tolua_export
+ Vector3d operator - ( const Vector3d& v2 ) const { return Vector3d( x - v2.x, y - v2.y, z - v2.z ); } //tolua_export
+ Vector3d operator - ( const Vector3d* v2 ) const { return Vector3d( x - v2->x, y - v2->y, z - v2->z ); } //tolua_export
+ Vector3d operator * ( const double f ) const { return Vector3d( x * f, y * f, z * f ); } //tolua_export
+ Vector3d operator * ( const Vector3d& v2 ) const { return Vector3d( x * v2.x, y * v2.y, z * v2.z ); } //tolua_export
+
+ double x, y, z; //tolua_export
+
+};//tolua_export \ No newline at end of file
diff --git a/source/Vector3f.cpp b/source/Vector3f.cpp
new file mode 100644
index 000000000..bc73a8070
--- /dev/null
+++ b/source/Vector3f.cpp
@@ -0,0 +1,31 @@
+#include "Vector3f.h"
+#include "Vector3d.h"
+#include "Vector3i.h"
+
+Vector3f::Vector3f( const Vector3d & v )
+ : x( (float)v.x )
+ , y( (float)v.y )
+ , z( (float)v.z )
+{
+}
+
+Vector3f::Vector3f( const Vector3d * v )
+ : x( (float)v->x )
+ , y( (float)v->y )
+ , z( (float)v->z )
+{
+}
+
+Vector3f::Vector3f( const Vector3i & v )
+ : x( (float)v.x )
+ , y( (float)v.y )
+ , z( (float)v.z )
+{
+}
+
+Vector3f::Vector3f( const Vector3i * v )
+ : x( (float)v->x )
+ , y( (float)v->y )
+ , z( (float)v->z )
+{
+} \ No newline at end of file
diff --git a/source/Vector3f.h b/source/Vector3f.h
new file mode 100644
index 000000000..ed1a6ef07
--- /dev/null
+++ b/source/Vector3f.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include <math.h>
+
+class Vector3i;
+class Vector3d;
+class Vector3f //tolua_export
+{ //tolua_export
+public: //tolua_export
+ Vector3f( const Vector3d & v ); //tolua_export
+ Vector3f( const Vector3d * v ); //tolua_export
+ Vector3f( const Vector3i & v ); //tolua_export
+ Vector3f( const Vector3i * v ); //tolua_export
+
+
+ Vector3f() : x(0), y(0), z(0) {} //tolua_export
+ Vector3f(float a_x, float a_y, float a_z) : x(a_x), y(a_y), z(a_z) {} //tolua_export
+
+ inline void Set(float a_x, float a_y, float a_z) { x = a_x, y = a_y, z = a_z; } //tolua_export
+ inline void Normalize() { float l = 1.0f / Length(); x *= l; y *= l; z *= l; } //tolua_export
+ inline Vector3f NormalizeCopy() const { float l = 1.0f / Length(); return Vector3f( x * l, y * l, z * l ); }//tolua_export
+ inline void NormalizeCopy(Vector3f & a_V) const { float l = 1.0f / Length(); a_V.Set(x*l, y*l, z*l ); } //tolua_export
+ inline float Length() const { return (float)sqrtf( x * x + y * y + z * z ); } //tolua_export
+ inline float SqrLength() const { return x * x + y * y + z * z; } //tolua_export
+ inline float Dot( const Vector3f & a_V ) const { return x * a_V.x + y * a_V.y + z * a_V.z; } //tolua_export
+ inline Vector3f Cross( const Vector3f & v ) const { return Vector3f( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); } //tolua_export
+
+ inline bool Equals( const Vector3f & v ) const { return (x == v.x && y == v.y && z == v.z ); } //tolua_export
+
+ void operator += ( const Vector3f& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
+ void operator += ( Vector3f* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
+ void operator -= ( const Vector3f& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
+ void operator -= ( Vector3f* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
+ void operator *= ( float a_f ) { x *= a_f; y *= a_f; z *= a_f; }
+ void operator *= ( Vector3f* a_V ) { x *= a_V->x; y *= a_V->y; z *= a_V->z; }
+ void operator *= ( const Vector3f& a_V ) { x *= a_V.x; y *= a_V.y; z *= a_V.z; }
+
+ Vector3f operator + ( const Vector3f& v2 ) const { return Vector3f( x + v2.x, y + v2.y, z + v2.z ); } //tolua_export
+ Vector3f operator + ( const Vector3f* v2 ) const { return Vector3f( x + v2->x, y + v2->y, z + v2->z ); } //tolua_export
+ Vector3f operator - ( const Vector3f& v2 ) const { return Vector3f( x - v2.x, y - v2.y, z - v2.z ); } //tolua_export
+ Vector3f operator - ( const Vector3f* v2 ) const { return Vector3f( x - v2->x, y - v2->y, z - v2->z ); } //tolua_export
+ Vector3f operator * ( const float f ) const { return Vector3f( x * f, y * f, z * f ); } //tolua_export
+ Vector3f operator * ( const Vector3f& v2 ) const { return Vector3f( x * v2.x, y * v2.y, z * v2.z ); } //tolua_export
+
+ float x, y, z; //tolua_export
+
+};//tolua_export \ No newline at end of file
diff --git a/source/Vector3i.cpp b/source/Vector3i.cpp
new file mode 100644
index 000000000..6a163a7e8
--- /dev/null
+++ b/source/Vector3i.cpp
@@ -0,0 +1,9 @@
+#include "Vector3i.h"
+#include "Vector3d.h"
+
+Vector3i::Vector3i( const Vector3d & v )
+ : x( (int)v.x )
+ , y( (int)v.y )
+ , z( (int)v.z )
+{
+} \ No newline at end of file
diff --git a/source/Vector3i.h b/source/Vector3i.h
new file mode 100644
index 000000000..676e7ba21
--- /dev/null
+++ b/source/Vector3i.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <math.h>
+
+class Vector3d;
+class Vector3i //tolua_export
+{ //tolua_export
+public: //tolua_export
+ Vector3i( const Vector3d & v ); //tolua_export
+
+ Vector3i() : x(0), y(0), z(0) {} //tolua_export
+ Vector3i(int a_x, int a_y, int a_z) : x(a_x), y(a_y), z(a_z) {} //tolua_export
+
+ inline void Set(int a_x, int a_y, int a_z) { x = a_x, y = a_y, z = a_z; } //tolua_export
+ inline float Length() const { return sqrtf( (float)( x * x + y * y + z * z) ); } //tolua_export
+ inline int SqrLength() const { return x * x + y * y + z * z; } //tolua_export
+
+ inline bool Equals( const Vector3i & v ) const { return (x == v.x && y == v.y && z == v.z ); } //tolua_export
+ inline bool Equals( const Vector3i * v ) const { return (x == v->x && y == v->y && z == v->z ); } //tolua_export
+
+ void operator += ( const Vector3i& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
+ void operator += ( Vector3i* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
+ void operator -= ( const Vector3i& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
+ void operator -= ( Vector3i* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
+ void operator *= ( int a_f ) { x *= a_f; y *= a_f; z *= a_f; }
+
+ friend Vector3i operator + ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ); }
+ friend Vector3i operator + ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x + v2->x, v1.y + v2->y, v1.z + v2->z ); }
+ friend Vector3i operator - ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ); }
+ friend Vector3i operator - ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x - v2->x, v1.y - v2->y, v1.z - v2->z ); }
+ friend Vector3i operator - ( const Vector3i* v1, Vector3i& v2 ) { return Vector3i( v1->x - v2.x, v1->y - v2.y, v1->z - v2.z ); }
+ friend Vector3i operator * ( const Vector3i& v, const int f ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
+ friend Vector3i operator * ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ); }
+ friend Vector3i operator * ( const int f, const Vector3i& v ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
+
+ int x, y, z; //tolua_export
+}; //tolua_export \ No newline at end of file
diff --git a/source/cAuthenticator.cpp b/source/cAuthenticator.cpp
new file mode 100644
index 000000000..bce7f942f
--- /dev/null
+++ b/source/cAuthenticator.cpp
@@ -0,0 +1,194 @@
+#include "cAuthenticator.h"
+#include "cBlockingTCPLink.h"
+#include "cMCLogger.h"
+
+#include "../iniFile/iniFile.h"
+#ifndef _WIN32
+#include <cstring>
+#endif
+
+#include <string>
+#include <sstream>
+
+extern void ReplaceString( std::string & a_HayStack, const std::string & a_Needle, const std::string & a_ReplaceWith );
+
+cAuthenticator::cAuthenticator()
+{
+}
+
+cAuthenticator::~cAuthenticator()
+{
+}
+
+bool cAuthenticator::Authenticate( const char* a_PlayerName, const char* a_ServerID )
+{
+ // Default values
+ std::string Server = "www.minecraft.net";
+ std::string Address = "/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%";
+ bool bAuthenticate = true;
+
+ // Read custom values from INI
+ cIniFile IniFile("settings.ini");
+ if( IniFile.ReadFile() )
+ {
+ std::string tServer = IniFile.GetValue("Authentication", "Server");
+ std::string tAddress = IniFile.GetValue("Authentication", "Address");
+ bAuthenticate = IniFile.GetValueB("Authentication", "Authenticate", true);
+ bool bSave = false;
+ if( tServer.length() == 0 )
+ {
+ IniFile.SetValue("Authentication", "Server", Server, true );
+ bSave = true;
+ }
+ else
+ Server = tServer;
+ if( tAddress.length() == 0 )
+ {
+ IniFile.SetValue("Authentication", "Address", Address, true );
+ bSave = true;
+ }
+ else
+ Address = tAddress;
+
+ if( bSave )
+ {
+ IniFile.SetValueB("Authentication", "Authenticate", bAuthenticate, true );
+ IniFile.WriteFile();
+ }
+ }
+
+ if( !bAuthenticate ) // If we don't want to authenticate.. just return true
+ {
+ return true;
+ }
+
+ ReplaceString( Address, "%USERNAME%", a_PlayerName );
+ ReplaceString( Address, "%SERVERID%", a_ServerID );
+
+
+ cBlockingTCPLink TCPLink;
+ if( TCPLink.Connect( Server.c_str(), 80 ) )
+ {
+ //TCPLink.SendMessage( std::string( "GET /game/checkserver.jsp?user=" + std::string(a_PlayerName) + "&serverId=" + std::string(a_ServerID) + " HTTP/1.0\r\n\r\n" ).c_str() );
+ TCPLink.SendMessage( std::string( "GET " + Address + " HTTP/1.0\r\n\r\n" ).c_str() );
+ //LOGINFO("Successfully connected to mc.net");
+ std::string Received = TCPLink.ReceiveData();
+ //LOGINFO("Received data: %s", Received.c_str() );
+ return ParseReceived( Received.c_str(), &TCPLink );
+ }
+ else
+ {
+ LOGERROR("Could not connect to %s to verify player name! (%s)", Server.c_str(), a_PlayerName );
+ return false;
+ }
+}
+
+bool cAuthenticator::ParseReceived( const char* a_Data, cBlockingTCPLink* a_TCPLink )
+{
+ std::stringstream ss(a_Data);
+
+ std::string temp;
+ ss >> temp;
+ //LOGINFO("tmp: %s", temp.c_str() );
+
+ bool bRedirect = false;
+ bool bOK = false;
+
+ if( temp.compare("HTTP/1.1") == 0 || temp.compare("HTTP/1.0") == 0 )
+ {
+ int code;
+ ss >> code;
+ if( code == 302 )
+ {
+ // redirect blabla
+ LOGINFO("Need to redirect!");
+ bRedirect = true;
+ }
+ else if( code == 200 )
+ {
+ LOGINFO("Got 200 OK :D");
+ bOK = true;
+ }
+ }
+ else
+ return false;
+
+ if( bRedirect )
+ {
+ std::string Location;
+ // Search for "Location:"
+ bool bFoundLocation = false;
+ while( !bFoundLocation && ss.good() )
+ {
+ char c = 0;
+ while( c != '\n' )
+ {
+ ss.get( c );
+ }
+ std::string Name;
+ ss >> Name;
+ if( Name.compare("Location:") == 0 )
+ {
+ bFoundLocation = true;
+ ss >> Location;
+ }
+ }
+ if( !bFoundLocation )
+ {
+ LOGERROR("Could not find location");
+ return false;
+ }
+
+ Location = Location.substr( strlen("http://"), std::string::npos ); // Strip http://
+ std::string Server = Location.substr( 0, Location.find( "/" ) ); // Only leave server address
+ Location = Location.substr( Server.length(), std::string::npos );
+ //LOGINFO("Got location: (%s)", Location.c_str() );
+ //LOGINFO("Got server addr: (%s)", Server.c_str() );
+ a_TCPLink->CloseSocket();
+ if( a_TCPLink->Connect( Server.c_str(), 80 ) )
+ {
+ LOGINFO("Successfully connected to %s", Server.c_str() );
+ a_TCPLink->SendMessage( ( std::string("GET ") + Location + " HTTP/1.0\r\n\r\n").c_str() );
+ std::string Received = a_TCPLink->ReceiveData();
+ //LOGINFO("Received data: %s", Received.c_str() );
+ return ParseReceived( Received.c_str(), a_TCPLink );
+ }
+ else
+ {
+ LOGERROR("Could not connect to %s to verify player name!", Server.c_str() );
+ }
+ }
+ else if( bOK )
+ {
+ // Header says OK, so receive the rest.
+
+ // Go past header, double \n means end of headers
+ char c = 0;
+ while( ss.good() )
+ {
+ while( c != '\n' )
+ {
+ ss.get( c );
+ }
+ ss.get( c );
+ if( c == '\n' || c == '\r' || ss.peek() == '\r' || ss.peek() == '\n' )
+ break;
+ }
+ if( !ss.good() ) return false;
+
+ std::string Result;
+ ss >> Result;
+ LOGINFO("Got result: %s", Result.c_str() );
+ if( Result.compare("YES") == 0 )
+ {
+ LOGINFO("Result was \"YES\", so player is authenticated!");
+ return true;
+ }
+ else
+ {
+ LOGINFO("Result was \"%s\", so player is NOT authenticated!", Result.c_str() );
+ return false;
+ }
+ }
+ return false;
+}
diff --git a/source/cAuthenticator.h b/source/cAuthenticator.h
new file mode 100644
index 000000000..dada1ce43
--- /dev/null
+++ b/source/cAuthenticator.h
@@ -0,0 +1,13 @@
+#pragma once
+
+class cBlockingTCPLink;
+class cAuthenticator
+{
+public:
+ cAuthenticator();
+ ~cAuthenticator();
+
+ bool Authenticate( const char* a_PlayerName, const char* a_ServerID );
+private:
+ bool ParseReceived( const char* a_Data, cBlockingTCPLink* a_TCPLink );
+}; \ No newline at end of file
diff --git a/source/cBlockEntity.h b/source/cBlockEntity.h
new file mode 100644
index 000000000..75c864cec
--- /dev/null
+++ b/source/cBlockEntity.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#ifndef _WIN32
+#include "BlockID.h"
+#else
+enum ENUM_BLOCK_ID;
+#endif
+
+class cClientHandle;
+class cPlayer;
+class cBlockEntity
+{
+protected:
+ cBlockEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z) : m_PosX( a_X ), m_PosY( a_Y ), m_PosZ( a_Z ), m_BlockType( a_BlockType ) {}
+public:
+ virtual ~cBlockEntity() {};
+ virtual void Destroy() {};
+
+ int GetPosX() { return m_PosX; }
+ int GetPosY() { return m_PosY; }
+ int GetPosZ() { return m_PosZ; }
+
+ ENUM_BLOCK_ID GetBlockType() { return m_BlockType; }
+
+ virtual void UsedBy( cPlayer & a_Player ) = 0;
+ virtual void SendTo( cClientHandle* a_Client ) { (void)a_Client; }
+
+protected:
+ int m_PosX; // Position in block coordinates
+ int m_PosY;
+ int m_PosZ;
+
+ ENUM_BLOCK_ID m_BlockType;
+};
diff --git a/source/cBlockToPickup.cpp b/source/cBlockToPickup.cpp
new file mode 100644
index 000000000..3638740a3
--- /dev/null
+++ b/source/cBlockToPickup.cpp
@@ -0,0 +1,37 @@
+#include "cBlockToPickup.h"
+#include "BlockID.h"
+
+ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_UsedItemID )
+{
+ (void)a_UsedItemID;
+
+ switch( a_BlockID )
+ {
+ case E_BLOCK_AIR:
+ return E_ITEM_EMPTY;
+ case E_BLOCK_STONE:
+ return E_ITEM_COBBLESTONE;
+ case E_BLOCK_GRASS:
+ return E_ITEM_DIRT;
+ case E_BLOCK_DIRT:
+ return E_ITEM_DIRT;
+ case E_BLOCK_LOG:
+ return E_ITEM_LOG;
+ case E_BLOCK_COAL_ORE:
+ return E_ITEM_COAL;
+ case E_BLOCK_DIAMOND_ORE:
+ return E_ITEM_DIAMOND;
+ case E_BLOCK_IRON_BLOCK:
+ return E_ITEM_IRON_BLOCK;
+ case E_BLOCK_DIAMOND_BLOCK:
+ return E_ITEM_DIAMOND_BLOCK;
+ case E_BLOCK_GOLD_BLOCK:
+ return E_ITEM_GOLD_BLOCK;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ return E_ITEM_SIGN;
+ default:
+ return (ENUM_ITEM_ID)a_BlockID;
+ }
+ return E_ITEM_EMPTY;
+}
diff --git a/source/cBlockToPickup.h b/source/cBlockToPickup.h
new file mode 100644
index 000000000..8eb74c5ae
--- /dev/null
+++ b/source/cBlockToPickup.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifndef _WIN32
+#include "BlockID.h"
+#else
+enum ENUM_ITEM_ID;
+#endif
+
+class cBlockToPickup
+{
+public:
+ static ENUM_ITEM_ID ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_UsedItemID );
+};
diff --git a/source/cBlockingTCPLink.cpp b/source/cBlockingTCPLink.cpp
new file mode 100644
index 000000000..a87809857
--- /dev/null
+++ b/source/cBlockingTCPLink.cpp
@@ -0,0 +1,137 @@
+#include "cBlockingTCPLink.h"
+#include "packets/cPacket.h"
+#include <string>
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <cstring>
+#include <errno.h>
+#endif
+
+#ifdef _WIN32
+#define MSG_NOSIGNAL (0)
+#endif
+#ifdef __MACH__
+#define MSG_NOSIGNAL (0)
+#endif
+
+cBlockingTCPLink::cBlockingTCPLink()
+ : m_Socket( 0 )
+{
+}
+
+cBlockingTCPLink::~cBlockingTCPLink()
+{
+ CloseSocket();
+}
+
+void cBlockingTCPLink::CloseSocket()
+{
+ if( m_Socket )
+ {
+ closesocket( m_Socket );
+ m_Socket = 0;
+ }
+}
+
+bool cBlockingTCPLink::Connect( const char* a_Address, unsigned int a_Port )
+{
+ if( m_Socket )
+ {
+ LOGWARN("WARNING: cTCPLink Connect() called while still connected. ALWAYS disconnect before re-connecting!");
+ }
+
+ struct hostent *hp;
+ unsigned int addr;
+ struct sockaddr_in server;
+
+#ifdef _WIN32
+ WSADATA wsaData;
+ int wsaret=WSAStartup(/*0x101*/ MAKEWORD(2, 2),&wsaData);
+
+ if(wsaret!=0)
+ {
+ LOGERROR("cTCPLink: WSAStartup returned error");
+ return false;
+ }
+#endif
+
+ m_Socket=socket(AF_INET,SOCK_STREAM,0);
+#ifdef _WIN32
+ if( m_Socket==INVALID_SOCKET )
+#else
+ if( m_Socket < 0 )
+#endif
+ {
+ LOGERROR("cTCPLink: Invalid socket");
+ m_Socket = 0;
+ return false;
+ }
+
+
+ addr=inet_addr( a_Address );
+ hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
+ if(hp==NULL)
+ {
+ //LOGWARN("cTCPLink: gethostbyaddr returned NULL");
+ hp = gethostbyname( a_Address );
+ if( hp == NULL )
+ {
+ LOGWARN("cTCPLink: Could not resolve %s", a_Address);
+ CloseSocket();
+ return false;
+ }
+ }
+
+ server.sin_addr.s_addr=*((unsigned long*)hp->h_addr);
+ server.sin_family=AF_INET;
+ server.sin_port=htons( (unsigned short)a_Port );
+ if( connect( m_Socket, (struct sockaddr*)&server, sizeof(server) ) )
+ {
+ LOGWARN("cTCPLink: No response from server (%i)", errno);
+ CloseSocket();
+ return false;
+ }
+
+ return true;
+}
+
+int cBlockingTCPLink::Send( char* a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
+{
+ if( !m_Socket )
+ {
+ LOGWARN("cBlockingTCPLink: Trying to send data without a valid connection!");
+ return -1;
+ }
+ return cPacket::SendData( m_Socket, a_Data, a_Size, a_Flags );
+}
+
+int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
+{
+ if( !m_Socket )
+ {
+ LOGWARN("cBlockingTCPLink: Trying to send message without a valid connection!");
+ return -1;
+ }
+ return cPacket::SendData( m_Socket, a_Message, strlen(a_Message), a_Flags );
+}
+
+std::string cBlockingTCPLink::ReceiveData()
+{
+ if( !m_Socket ) return "";
+
+ int Received = 0;
+ char Buffer[256];
+ std::string Data;
+ while( (Received = recv(m_Socket, Buffer, 256, 0) ) > 0 )
+ {
+ //LOGINFO("Recv: %i", Received);
+ //LOG("%s", Buffer );
+ Data.append( Buffer, Received );
+ memset( Buffer, 0, 256 );
+ }
+
+ //LOGINFO("Received returned: %i", Received );
+ return Data;
+}
diff --git a/source/cBlockingTCPLink.h b/source/cBlockingTCPLink.h
new file mode 100644
index 000000000..535137c3e
--- /dev/null
+++ b/source/cBlockingTCPLink.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cSocket.h"
+#include <string>
+
+class cEvent;
+class cBlockingTCPLink //tolua_export
+{ //tolua_export
+public: //tolua_export
+ cBlockingTCPLink(); //tolua_export
+ ~cBlockingTCPLink(); //tolua_export
+
+ bool Connect( const char* a_Address, unsigned int a_Port ); //tolua_export
+ int Send( char* a_Data, unsigned int a_Size, int a_Flags = 0 ); //tolua_export
+ int SendMessage( const char* a_Message, int a_Flags = 0 ); //tolua_export
+ void CloseSocket(); //tolua_export
+ std::string ReceiveData(); //tolua_export
+protected:
+
+ cSocket m_Socket;
+}; //tolua_export
diff --git a/source/cChatColor.cpp b/source/cChatColor.cpp
new file mode 100644
index 000000000..a0f7813c5
--- /dev/null
+++ b/source/cChatColor.cpp
@@ -0,0 +1,25 @@
+#include "cChatColor.h"
+
+const std::string cChatColor::Color = "§";
+const std::string cChatColor::Delimiter = "\xa7";
+const std::string cChatColor::Black = cChatColor::Color + "0";
+const std::string cChatColor::Navy = cChatColor::Color + "1";
+const std::string cChatColor::Green = cChatColor::Color + "2";
+const std::string cChatColor::Blue = cChatColor::Color + "3";
+const std::string cChatColor::Red = cChatColor::Color + "4";
+const std::string cChatColor::Purple = cChatColor::Color + "5";
+const std::string cChatColor::Gold = cChatColor::Color + "6";
+const std::string cChatColor::LightGray = cChatColor::Color + "7";
+const std::string cChatColor::Gray = cChatColor::Color + "8";
+const std::string cChatColor::DarkPurple = cChatColor::Color + "9";
+const std::string cChatColor::LightGreen = cChatColor::Color + "a";
+const std::string cChatColor::LightBlue = cChatColor::Color + "b";
+const std::string cChatColor::Rose = cChatColor::Color + "c";
+const std::string cChatColor::LightPurple = cChatColor::Color + "d";
+const std::string cChatColor::Yellow = cChatColor::Color + "e";
+const std::string cChatColor::White = cChatColor::Color + "f";
+
+const std::string cChatColor::MakeColor( char a_Color )
+{
+ return cChatColor::Color + a_Color;
+} \ No newline at end of file
diff --git a/source/cChatColor.h b/source/cChatColor.h
new file mode 100644
index 000000000..217a0afc3
--- /dev/null
+++ b/source/cChatColor.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <string>
+
+// tolua_begin
+class cChatColor
+{
+public:
+ static const std::string Color;
+ static const std::string Delimiter;
+
+ static const std::string Black;
+ static const std::string Navy;
+ static const std::string Green;
+ static const std::string Blue;
+ static const std::string Red;
+ static const std::string Purple;
+ static const std::string Gold;
+ static const std::string LightGray;
+ static const std::string Gray;
+ static const std::string DarkPurple;
+ static const std::string LightGreen;
+ static const std::string LightBlue;
+ static const std::string Rose;
+ static const std::string LightPurple;
+ static const std::string Yellow;
+ static const std::string White;
+
+ static const std::string MakeColor( char a_Color );
+};
+
+// tolua_end \ No newline at end of file
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
new file mode 100644
index 000000000..f76848879
--- /dev/null
+++ b/source/cChestEntity.cpp
@@ -0,0 +1,185 @@
+#include "cChestEntity.h"
+#include "cItem.h"
+#include <string>
+#include "cClientHandle.h"
+#include "cMCLogger.h"
+#include "cPlayer.h"
+#include "cWindow.h"
+#include "cPickup.h"
+#include "cMCLogger.h"
+
+#include <json/json.h>
+
+cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z)
+ : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z )
+{
+ m_Content = new cItem[ c_ChestHeight*c_ChestWidth ];
+}
+
+cChestEntity::~cChestEntity()
+{
+ if( GetWindow() )
+ {
+ GetWindow()->OwnerDestroyed();
+ }
+
+ if( m_Content )
+ {
+ delete [] m_Content;
+ }
+}
+
+void cChestEntity::Destroy()
+{
+ // Drop items
+ for( int i = 0; i < c_ChestHeight*c_ChestWidth; ++i )
+ {
+ if( !m_Content[i].IsEmpty() )
+ {
+ cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Content[i], 0, 1.f, 0 );
+ Pickup->Initialize();
+ m_Content[i].Empty();
+ }
+ }
+}
+
+cItem * cChestEntity::GetSlot( int a_Slot )
+{
+ if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
+ {
+ return &m_Content[ a_Slot ];
+ }
+ return 0;
+}
+
+void cChestEntity::SetSlot( int a_Slot, cItem & a_Item )
+{
+ if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
+ {
+ m_Content[a_Slot] = a_Item;
+ }
+}
+
+void cChestEntity::WriteToFile(FILE* a_File)
+{
+ fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File );
+ fwrite( &m_PosX, sizeof( int ), 1, a_File );
+ fwrite( &m_PosY, sizeof( int ), 1, a_File );
+ fwrite( &m_PosZ, sizeof( int ), 1, a_File );
+
+ unsigned int NumSlots = c_ChestHeight*c_ChestWidth;
+ fwrite( &NumSlots, sizeof(unsigned int), 1, a_File );
+ for(unsigned int i = 0; i < NumSlots; i++)
+ {
+ cItem* Item = GetSlot( i );
+ if( Item )
+ {
+ fwrite( &Item->m_ItemID, sizeof(Item->m_ItemID), 1, a_File );
+ fwrite( &Item->m_ItemCount, sizeof(Item->m_ItemCount), 1, a_File );
+ fwrite( &Item->m_ItemHealth, sizeof(Item->m_ItemHealth), 1, a_File );
+ }
+ }
+}
+
+bool cChestEntity::LoadFromFile(FILE* a_File)
+{
+ if( fread( &m_PosX, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ if( fread( &m_PosY, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ if( fread( &m_PosZ, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+
+ unsigned int NumSlots = 0;
+ if( fread( &NumSlots, sizeof(unsigned int), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ for(unsigned int i = 0; i < NumSlots; i++)
+ {
+ cItem Item;
+ if( fread( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ if( fread( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File) != 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ if( fread( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File)!= 1 ) { LOGERROR("ERROR READING CHEST FROM FILE"); return false; }
+ SetSlot( i, Item );
+ }
+ return true;
+}
+
+bool cChestEntity::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 )
+ {
+ Json::Value & Slot = *itr;
+ cItem Item;
+ Item.m_ItemID = (ENUM_ITEM_ID)Slot.get("ID", -1 ).asInt();
+ if( Item.m_ItemID > 0 )
+ {
+ Item.m_ItemCount = (char)Slot.get("Count", -1 ).asInt();
+ Item.m_ItemHealth = (short)Slot.get("Health", -1 ).asInt();
+ }
+ SetSlot( SlotIdx, Item );
+ SlotIdx++;
+ }
+ return true;
+}
+
+void cChestEntity::SaveToJson( Json::Value& a_Value )
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ unsigned int NumSlots = c_ChestHeight*c_ChestWidth;
+ Json::Value AllSlots;
+ for(unsigned int i = 0; i < NumSlots; i++)
+ {
+ Json::Value Slot;
+ cItem* Item = GetSlot( i );
+ if( Item )
+ {
+ Slot["ID"] = Item->m_ItemID;
+ if( Item->m_ItemID > 0 )
+ {
+ Slot["Count"] = Item->m_ItemCount;
+ Slot["Health"] = Item->m_ItemHealth;
+ }
+ }
+ AllSlots.append( Slot );
+ }
+ a_Value["Slots"] = AllSlots;
+}
+
+void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
+{
+ (void)a_Client;
+ (void)a_Server;
+ return;
+}
+
+void cChestEntity::UsedBy( cPlayer & a_Player )
+{
+ LOG("Used a chest");
+// m_Content[0].m_ItemCount = 1;
+// m_Content[0].m_ItemID = E_ITEM_STONE;
+// m_Content[0].m_ItemHealth = 0;
+
+ if( !GetWindow() )
+ {
+ cWindow* Window = new cWindow( this, true );
+ Window->SetSlots( m_Content, c_ChestHeight*c_ChestWidth );
+ Window->SetWindowID( 1 );
+ Window->SetWindowType( 0 );
+ Window->SetWindowTitle("UberChest");
+ OpenWindow( Window );
+ }
+ if( GetWindow() )
+ {
+ if( a_Player.GetWindow() != GetWindow() )
+ {
+ a_Player.OpenWindow( GetWindow() );
+
+ GetWindow()->SendWholeWindow( a_Player.GetClientHandle() );
+ }
+ }
+}
diff --git a/source/cChestEntity.h b/source/cChestEntity.h
new file mode 100644
index 000000000..5170b168d
--- /dev/null
+++ b/source/cChestEntity.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "cBlockEntity.h"
+#include "cWindowOwner.h"
+#include "FileDefine.h"
+
+namespace Json
+{
+ class Value;
+};
+
+class cClientHandle;
+class cServer;
+class cItem;
+class cNBTData;
+class cChestEntity : public cBlockEntity, public cWindowOwner
+{
+public:
+ cChestEntity(int a_X, int a_Y, int a_Z);
+ virtual ~cChestEntity();
+ virtual void Destroy();
+
+ void HandleData( cNBTData* a_NBTData );
+
+ cItem * GetSlot( int a_Slot );
+ void SetSlot( int a_Slot, cItem & a_Item );
+
+ void WriteToFile(FILE* a_File);
+ bool LoadFromFile(FILE* a_File);
+
+ bool LoadFromJson( const Json::Value& a_Value );
+ void SaveToJson( Json::Value& a_Value );
+
+ void SendTo( cClientHandle* a_Client, cServer* a_Server );
+
+ virtual void UsedBy( cPlayer & a_Player );
+
+ static const int c_ChestWidth = 9;
+ static const int c_ChestHeight = 3;
+private:
+ cItem* m_Content;
+}; \ No newline at end of file
diff --git a/source/cChicken.cpp b/source/cChicken.cpp
new file mode 100644
index 000000000..ed420f256
--- /dev/null
+++ b/source/cChicken.cpp
@@ -0,0 +1,90 @@
+#include "cChicken.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+#include <string>
+
+
+
+cChicken::cChicken()
+ : m_ChaseTime( 999999 )
+
+{
+ //LOG("SPAWNING A CHICKEN!!!!!!!!!!!!!!!!!!!!!");
+ m_EMPersonality = PASSIVE;
+ m_MobType = 93;
+ GetMonsterConfig("Chicken");
+}
+
+cChicken::~cChicken()
+{
+}
+
+bool cChicken::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cChicken ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cChicken::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cChicken::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cChicken::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cChicken::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cChicken::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
diff --git a/source/cChicken.h b/source/cChicken.h
new file mode 100644
index 000000000..9da836587
--- /dev/null
+++ b/source/cChicken.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cChicken : public cMonster
+{
+public:
+ cChicken();
+ ~cChicken();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
new file mode 100644
index 000000000..c6d0fb3b3
--- /dev/null
+++ b/source/cChunk.cpp
@@ -0,0 +1,1388 @@
+#ifndef _WIN32
+#include <cstring>
+#include <cstdlib>
+#include <stdio.h>
+#include <sys/stat.h> // for mkdir
+#include <sys/types.h>
+#endif
+#include "cChunk.h"
+#include "cWorld.h"
+#include "cClientHandle.h"
+#include "cServer.h"
+#include "zlib.h"
+#include "Defines.h"
+#include <string> // memset
+#include "cChestEntity.h"
+#include "cFurnaceEntity.h"
+#include "cSignEntity.h"
+#include "cMCLogger.h"
+#include "cTorch.h"
+#include "cLadder.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cNoise.h"
+#include "cRoot.h"
+
+#include "cGenSettings.h"
+
+#include "packets/cPacket_DestroyEntity.h"
+#include "packets/cPacket_PreChunk.h"
+#include "packets/cPacket_BlockChange.h"
+#include "packets/cPacket_MapChunk.h"
+#include "packets/cPacket_MultiBlock.h"
+
+#include <json/json.h>
+
+#include <list>
+#include <vector>
+#include <map>
+
+extern bool g_bWaterPhysics;
+
+
+typedef std::list< cFurnaceEntity* > FurnaceEntityList;
+typedef std::list< cClientHandle* > ClientHandleList;
+typedef std::list< cBlockEntity* > BlockEntityList;
+typedef std::list< cEntity* > EntityList;
+struct cChunk::sChunkState
+{
+ std::map< unsigned int, int > m_ToTickBlocks;
+ FurnaceEntityList m_TickBlockEntities;
+ std::vector< unsigned int > m_PendingSendBlocks;
+ ClientHandleList m_LoadedByClient;
+ ClientHandleList m_UnloadQuery;
+ BlockEntityList m_BlockEntities;
+ EntityList m_Entities;
+};
+
+cChunk::~cChunk()
+{
+ //LOG("~cChunk() %i %i %i", m_PosX, m_PosY, m_PosZ );
+ for( std::list<cBlockEntity*>::iterator itr = m_pState->m_BlockEntities.begin(); itr != m_pState->m_BlockEntities.end(); ++itr)
+ {
+ delete *itr;
+ }
+ m_pState->m_BlockEntities.clear();
+
+ LockEntities();
+ for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr)
+ {
+ if( (*itr)->GetEntityType() != cEntity::E_PLAYER )
+ {
+ cRoot::Get()->GetWorld()->AddToRemoveEntityQueue( **itr ); // World also destroys the entity
+ }
+ }
+ m_pState->m_Entities.clear();
+ UnlockEntities();
+
+ if( m_EntitiesCriticalSection )
+ {
+ DeleteCriticalSection( (CRITICAL_SECTION*)m_EntitiesCriticalSection );
+ delete (CRITICAL_SECTION*)m_EntitiesCriticalSection;
+ m_EntitiesCriticalSection = 0;
+ }
+ delete m_pState;
+}
+
+cChunk::cChunk(int a_X, int a_Y, int a_Z)
+ : m_pState( new sChunkState )
+ , m_bCalculateLighting( false )
+ , m_bCalculateHeightmap( false )
+ , m_PosX( a_X )
+ , m_PosY( a_Y )
+ , m_PosZ( a_Z )
+ , m_BlockType( m_BlockData ) // Offset the pointers
+ , m_BlockMeta( m_BlockType + c_NumBlocks )
+ , m_BlockLight( m_BlockMeta + c_NumBlocks/2 )
+ , m_BlockSkyLight( m_BlockLight + c_NumBlocks/2 )
+ , m_BlockTickNum( 0 )
+ , m_BlockTickX( 0 )
+ , m_BlockTickY( 0 )
+ , m_BlockTickZ( 0 )
+ , m_EntitiesCriticalSection( 0 )
+{
+ //LOG("cChunk::cChunk(%i, %i, %i)", a_X, a_Y, a_Z);
+ m_EntitiesCriticalSection = new CRITICAL_SECTION;
+ InitializeCriticalSection( (CRITICAL_SECTION*)m_EntitiesCriticalSection );
+}
+
+void cChunk::Initialize()
+{
+ if( !LoadFromDisk() )
+ {
+ // Clear memory
+ memset( m_BlockData, 0x00, c_BlockDataSize );
+
+// LARGE_INTEGER TicksPerSecond;
+// QueryPerformanceFrequency( &TicksPerSecond );
+
+ GenerateTerrain();
+
+// LARGE_INTEGER start;
+// QueryPerformanceCounter( &start );
+
+ CalculateHeightmap();
+ CalculateLighting();
+
+// LARGE_INTEGER end;
+// QueryPerformanceCounter( &end );
+// double Time = double( end.QuadPart - start.QuadPart ) / double( TicksPerSecond.QuadPart / 1000 );
+// LOG("Calculated light in %f ms", Time );
+
+ CreateBlockEntities();
+ }
+ else
+ {
+ //LOGINFO("Successfully loaded from disk");
+ CalculateHeightmap();
+ }
+}
+
+void cChunk::Tick(float a_Dt)
+{
+ if( m_bCalculateLighting )
+ CalculateLighting();
+ if( m_bCalculateHeightmap )
+ CalculateHeightmap();
+
+ unsigned int PendingSendBlocks = m_pState->m_PendingSendBlocks.size();
+ if( PendingSendBlocks > 1 )
+ {
+ cPacket_MultiBlock MultiBlock;
+ MultiBlock.m_ChunkX = m_PosX;
+ MultiBlock.m_ChunkZ = m_PosZ;
+ MultiBlock.m_NumBlocks = (short)PendingSendBlocks;
+ MultiBlock.m_BlockCoordinates = new unsigned short[PendingSendBlocks];
+ MultiBlock.m_BlockTypes = new char[PendingSendBlocks];
+ MultiBlock.m_BlockMetas = new char[PendingSendBlocks];
+ //LOG("Sending multiblock packet for %i blocks", PendingSendBlocks );
+ for( unsigned int i = 0; i < PendingSendBlocks; i++)
+ {
+ unsigned int index = m_pState->m_PendingSendBlocks[i];
+ unsigned int Y = index % 128;
+ unsigned int Z = (index / 128) % 16;
+ unsigned int X = (index / (128*16));
+
+ MultiBlock.m_BlockCoordinates[i] = (Z&0xf) | (X&0xf)<<4 | (Y&0xff)<<8;
+ //LOG("X: %i Y: %i Z: %i Combo: 0x%04x", X, Y, Z, MultiBlock.m_BlockCoordinates[i] );
+ MultiBlock.m_BlockTypes[i] = m_BlockType[index];
+ MultiBlock.m_BlockMetas[i] = GetLight( m_BlockMeta, index );
+ }
+ m_pState->m_PendingSendBlocks.clear();
+ PendingSendBlocks = m_pState->m_PendingSendBlocks.size();
+ Broadcast( MultiBlock );
+ }
+ if( PendingSendBlocks > 0 )
+ {
+ for( unsigned int i = 0; i < PendingSendBlocks; i++)
+ {
+ unsigned int index = m_pState->m_PendingSendBlocks[i];
+ int Y = index % 128;
+ int Z = (index / 128) % 16;
+ int X = (index / (128*16));
+
+ cPacket_BlockChange BlockChange;
+ BlockChange.m_PosX = X + m_PosX*16;
+ BlockChange.m_PosY = (char)(Y + m_PosY*128);
+ BlockChange.m_PosZ = Z + m_PosZ*16;
+ BlockChange.m_BlockType = m_BlockType[index];
+ BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
+ Broadcast( BlockChange );
+ }
+ m_pState->m_PendingSendBlocks.clear();
+ }
+
+ while( !m_pState->m_UnloadQuery.empty() )
+ {
+ cPacket_PreChunk UnloadPacket;
+ UnloadPacket.m_PosX = GetPosX();
+ UnloadPacket.m_PosZ = GetPosZ();
+ UnloadPacket.m_bLoad = false; // Unload
+ (*m_pState->m_UnloadQuery.begin())->Send( UnloadPacket );
+ m_pState->m_UnloadQuery.remove( *m_pState->m_UnloadQuery.begin() );
+ }
+
+ std::map< unsigned int, int > ToTickBlocks = m_pState->m_ToTickBlocks;
+ unsigned int NumTickBlocks = ToTickBlocks.size();
+ if( NumTickBlocks > 0 ) LOG("To tick: %i", NumTickBlocks );
+ m_pState->m_ToTickBlocks.clear();
+ for( std::map< unsigned int, int>::iterator itr = ToTickBlocks.begin(); itr != ToTickBlocks.end(); ++itr )
+ {
+ if( (*itr).second < 0 ) continue;
+ unsigned int index = (*itr).first;
+ int Y = index % 128;
+ int Z = (index / 128) % 16;
+ int X = (index / (128*16));
+
+ char BlockID = GetBlock( index );
+ switch( BlockID )
+ {
+ case E_BLOCK_REEDS:
+ case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_MINECART_TRACKS:
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_CROPS:
+ case E_BLOCK_SAPLING:
+ case E_BLOCK_YELLOW_FLOWER:
+ case E_BLOCK_RED_ROSE:
+ case E_BLOCK_RED_MUSHROOM:
+ case E_BLOCK_BROWN_MUSHROOM:
+ case E_BLOCK_REDSTONE_WIRE: // Stuff that drops when block below is destroyed
+ {
+ if( GetBlock( X, Y-1, Z ) == E_BLOCK_AIR )
+ {
+ SetBlock( X, Y, Z, 0, 0 );
+ cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
+ Pickup->Initialize();
+ }
+ }
+ break;
+ case E_BLOCK_REDSTONE_TORCH_OFF:
+ case E_BLOCK_REDSTONE_TORCH_ON:
+ case E_BLOCK_TORCH:
+ {
+ char Dir = cTorch::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
+ LOG("MetaData: %i", Dir );
+ int XX = X + m_PosX*16;
+ char YY = (char)Y;
+ int ZZ = Z + m_PosZ*16;
+ AddDirection( XX, YY, ZZ, Dir, true );
+ cWorld* World = cRoot::Get()->GetWorld();
+ if( World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
+ {
+ SetBlock( X, Y, Z, 0, 0 );
+ cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
+ Pickup->Initialize();
+ }
+ }
+ break;
+ case E_BLOCK_LADDER:
+ {
+ char Dir = cLadder::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
+ int XX = X + m_PosX*16;
+ char YY = (char)Y;
+ int ZZ = Z + m_PosZ*16;
+ AddDirection( XX, YY, ZZ, Dir, true );
+ cWorld* World = cRoot::Get()->GetWorld();
+ if( World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
+ {
+ SetBlock( X, Y, Z, 0, 0 );
+ cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
+ Pickup->Initialize();
+ }
+ }
+ break;
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_WATER:
+
+ break;
+ case E_BLOCK_GRAVEL:
+ case E_BLOCK_SAND:
+ {
+ char BottomBlock = GetBlock( X, Y-1, Z );
+ if( BottomBlock == E_BLOCK_AIR || BottomBlock == E_BLOCK_WATER || BottomBlock == E_BLOCK_STATIONARY_WATER || BottomBlock == E_BLOCK_LAVA || BottomBlock == E_BLOCK_STATIONARY_LAVA )
+ {
+ SetBlock( X, Y, Z, 0, 0 );
+ SetBlock( X, Y-1, Z, BlockID, 0 );
+ }
+ }
+ break;
+ default:
+ break;
+ };
+ }
+
+ // Tick dem blocks
+ int RandomX = rand();
+ int RandomY = rand();
+ int RandomZ = rand();
+
+ for(int i = 0; i < 50; i++)
+ {
+ m_BlockTickX = (m_BlockTickX + RandomX) % 16;
+ m_BlockTickY = (m_BlockTickY + RandomY) % 128;
+ m_BlockTickZ = (m_BlockTickZ + RandomZ) % 16;
+
+ //LOG("%03i %03i %03i", m_BlockTickX, m_BlockTickY, m_BlockTickZ);
+
+ if( m_BlockTickY > m_HeightMap[ m_BlockTickX + m_BlockTickZ*16 ] ) continue; // It's all air up here
+
+ //m_BlockTickNum = (m_BlockTickNum + 1 ) % c_NumBlocks;
+ unsigned int Index = MakeIndex( m_BlockTickX, m_BlockTickY, m_BlockTickZ );
+ char ID = m_BlockType[Index];
+ switch( ID )
+ {
+ case E_BLOCK_DIRT:
+ {
+ char AboveBlock = GetBlock( Index+1 );
+ if( AboveBlock == 0 && GetLight( m_BlockSkyLight, Index ) > 0xf/2 ) // Half lit
+ {
+ FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_GRASS, GetLight( m_BlockMeta, Index ) );
+ }
+ }
+ break;
+ case E_BLOCK_GRASS:
+ {
+ char AboveBlock = GetBlock( Index+1 );
+ if( AboveBlock != 0 )
+ {
+ FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_DIRT, GetLight( m_BlockMeta, Index ) );
+ }
+ }
+ break;
+ case E_BLOCK_SAPLING:
+ {
+ FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_AIR, GetLight( m_BlockMeta, Index ) );
+ cRoot::Get()->GetWorld()->GrowTree( m_BlockTickX + m_PosX*16, m_BlockTickY, m_BlockTickZ + m_PosZ*16 );
+ }
+ default:
+ break;
+ }
+ }
+
+ // Tick block entities (furnace)
+ std::list< cFurnaceEntity* > TickBlockEntites = m_pState->m_TickBlockEntities; // Dangerous stuff, better make a copy.
+ for( std::list< cFurnaceEntity* >::iterator itr = TickBlockEntites.begin(); itr != TickBlockEntites.end(); ++itr )
+ {
+ if( !(*itr)->Tick( a_Dt ) ) // Remove from list
+ {
+ m_pState->m_TickBlockEntities.remove( *itr );
+ }
+ }
+}
+
+char cChunk::GetHeight( int a_X, int a_Z )
+{
+ if( a_X >= 0 && a_X < 16 && a_Z >= 0 && a_Z < 16 )
+ return m_HeightMap[a_X + a_Z*16];
+ return 0;
+}
+
+void cChunk::CreateBlockEntities()
+{
+ for(int x = 0; x < 16; x++)
+ {
+ for(int z = 0; z < 16; z++)
+ {
+ for(int y = 0; y < 128; y++)
+ {
+ ENUM_BLOCK_ID BlockType = (ENUM_BLOCK_ID)m_BlockData[ MakeIndex( x, y, z ) ];
+ switch( BlockType )
+ {
+ case E_BLOCK_CHEST:
+ {
+ m_pState->m_BlockEntities.push_back( new cChestEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ m_pState->m_BlockEntities.push_back( new cFurnaceEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ m_pState->m_BlockEntities.push_back( new cSignEntity( BlockType, x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+unsigned int cChunk::MakeIndex(int x, int y, int z )
+{
+ if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
+ return y + (z * 128) + (x * 128 * 16);
+ return 0;
+}
+
+char cChunk::GetLight(char* a_Buffer, int a_BlockIdx)
+{
+ if( a_BlockIdx > -1 && a_BlockIdx < c_NumBlocks )
+ {
+ const int cindex = (a_BlockIdx/2);
+ if( (a_BlockIdx & 1) == 0 )
+ { // First half byte
+ return (a_Buffer[cindex] & 0x0f);
+ }
+ else
+ {
+ return ((a_Buffer[cindex] & 0xf0) >> 4);
+ }
+ }
+ return 0;
+}
+
+char cChunk::GetLight(char* a_Buffer, int x, int y, int z)
+{
+ if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
+ {
+ const int cindex = (y/2) + (z * 64) + (x * 64 * 16);
+ if( (y & 1) == 0 )
+ { // First half byte
+ return (a_Buffer[cindex] & 0x0f);
+ }
+ else
+ {
+ return ((a_Buffer[cindex] & 0xf0) >> 4);
+ }
+ }
+ return 0;
+}
+
+void cChunk::SetLight(char* a_Buffer, int a_BlockIdx, char a_Light)
+{
+ if( a_BlockIdx > -1 && a_BlockIdx < c_NumBlocks )
+ {
+ const int cindex = (a_BlockIdx/2);
+ if( (a_BlockIdx & 1) == 0 )
+ { // First half byte
+ a_Buffer[cindex] &= 0xf0; // Set first half to 0
+ a_Buffer[cindex] |= (a_Light) & 0x0f;
+ }
+ else
+ {
+ a_Buffer[cindex] &= 0x0f; // Set second half to 0
+ a_Buffer[cindex] |= (a_Light << 4) & 0xf0;
+ }
+ }
+}
+
+void cChunk::SetLight(char* a_Buffer, int x, int y, int z, char light)
+{
+ if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
+ {
+ int cindex = (y/2) + (z * 64) + (x * 64 * 16);
+ if( (y & 1) == 0 )
+ { // First half byte
+ a_Buffer[cindex] &= 0xf0; // Set first half to 0
+ a_Buffer[cindex] |= (light) & 0x0f;
+ }
+ else
+ {
+ a_Buffer[cindex] &= 0x0f; // Set second half to 0
+ a_Buffer[cindex] |= (light << 4) & 0xf0;
+ }
+ }
+}
+
+inline void cChunk::SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff)
+{
+ unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
+ SetLight( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X-1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
+ SetLight( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X+1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
+ SetLight( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y-1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
+ SetLight( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y+1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
+ SetLight( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z-1 ), MAX(0,CurrentLight-a_Falloff) ) );
+ SetLight( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z+1 ), MAX(0,CurrentLight-a_Falloff) ) );
+}
+
+inline void cChunk::SpreadLightOfBlockX(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
+{
+ unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
+ SetLight( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X-1, a_Y, a_Z ), CurrentLight-1) );
+ SetLight( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X+1, a_Y, a_Z ), CurrentLight-1) );
+}
+
+inline void cChunk::SpreadLightOfBlockY(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
+{
+ unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
+ SetLight( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y-1, a_Z ), CurrentLight-1) );
+ SetLight( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y+1, a_Z ), CurrentLight-1) );
+}
+
+inline void cChunk::SpreadLightOfBlockZ(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
+{
+ unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
+ SetLight( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z-1 ), CurrentLight-1) );
+ SetLight( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z+1 ), CurrentLight-1) );
+}
+
+void cChunk::CalculateHeightmap()
+{
+ m_bCalculateHeightmap = false;
+ for(int x = 0; x < 16; x++)
+ {
+ for(int z = 0; z < 16; z++)
+ {
+ for(int y = 127; y > -1; y--)
+ {
+ int index = MakeIndex( x, y, z );
+ if(m_BlockData[index] != E_BLOCK_AIR)
+ {
+ m_HeightMap[x + z*16] = (char)y;
+ break;
+ }
+ }
+ }
+ }
+}
+
+void cChunk::CalculateLighting()
+{
+ // Calculate sunlight
+ memset(m_BlockSkyLight, 0xff, c_NumBlocks/2 ); // Set all to fully lit, so everything above HeightMap is lit
+ for(int x = 0; x < 16; x++)
+ {
+ for(int z = 0; z < 16; z++)
+ {
+ char sunlight = 0xf;
+ for(int y = m_HeightMap[x + z*16]; y > -1; y--)
+ {
+ int index = y + (z * 128) + (x * 128 * 16);
+
+ if( g_BlockTransparent[ (int)m_BlockData[index] ] == false )
+ {
+ sunlight = 0x0;
+ }
+ SetLight( m_BlockSkyLight, x, y, z, sunlight );
+ }
+ }
+ }
+
+ // Calculate blocklights
+ for(int x = 0; x < 16; x++)
+ {
+ for(int z = 0; z < 16; z++)
+ {
+ int MaxHeight = m_HeightMap[x + z*16];
+ for(int y = 0; y < MaxHeight; y++)
+ {
+ char BlockID = GetBlock(x, y, z);
+ SetLight( m_BlockLight, x, y, z, g_BlockLightValue[(int)BlockID] );
+ }
+ }
+ }
+
+ SpreadLight(m_BlockSkyLight);
+ SpreadLight(m_BlockLight);
+
+ // Stop it from calculating again :P
+ m_bCalculateLighting = false;
+}
+
+void cChunk::SpreadLight(char* a_LightBuffer)
+{
+ // Spread the sunlight
+ for(int x = 0; x < 16; x++) for(int z = 0; z < 16; z++) for(int y = 0; y < 128; y++)
+ {
+ int index = y + (z * 128) + (x * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ SpreadLightOfBlock(a_LightBuffer, x, y, z, g_BlockSpreadLightFalloff[ m_BlockData[index] ]);
+ }
+ }
+
+ for(int x = 15; x > -1; x--) for(int z = 15; z > -1; z--) for(int y = 127; y > -1; y--)
+ {
+ int index = y + (z * 128) + (x * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ SpreadLightOfBlock(a_LightBuffer, x, y, z, g_BlockSpreadLightFalloff[ m_BlockData[index] ]);
+ }
+ }
+
+ bool bCalcLeft, bCalcRight, bCalcFront, bCalcBack;
+ bCalcLeft = bCalcRight = bCalcFront = bCalcBack = false;
+ // Spread to neighbour chunks X-axis
+ cChunk* LeftChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX-1, m_PosY, m_PosZ );
+ cChunk* RightChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX+1, m_PosY, m_PosZ );
+ char* LeftSky = 0, *RightSky = 0;
+ if(LeftChunk) LeftSky = (a_LightBuffer==m_BlockSkyLight)?LeftChunk->pGetSkyLight():LeftChunk->pGetLight();
+ if(RightChunk) RightSky = (a_LightBuffer==m_BlockSkyLight)?RightChunk->pGetSkyLight():RightChunk->pGetLight();
+ for(int z = 0; z < 16; z++) for(int y = 0; y < 128; y++)
+ {
+ if( LeftChunk )
+ {
+ int index = y + (z * 128) + (0 * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ char CurrentLight = GetLight( a_LightBuffer, 0, y, z );
+ char LeftLight = GetLight( LeftSky, 15, y, z );
+ if( LeftLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
+ {
+ SetLight( LeftSky, 15, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ bCalcLeft = true;
+ }
+ }
+ }
+ if( RightChunk )
+ {
+ int index = y + (z * 128) + (15 * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ char CurrentLight = GetLight( a_LightBuffer, 15, y, z );
+ char RightLight = GetLight( RightSky, 0, y, z );
+ if( RightLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
+ {
+ SetLight( RightSky, 0, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ bCalcRight = true;
+ }
+ }
+ }
+ }
+
+ // Spread to neighbour chunks Z-axis
+ cChunk* FrontChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ-1 );
+ cChunk* BackChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ+1 );
+ char* FrontSky = 0, *BackSky = 0;
+ if(FrontChunk) FrontSky = (a_LightBuffer==m_BlockSkyLight)?FrontChunk->pGetSkyLight():FrontChunk->pGetLight();
+ if(BackChunk) BackSky = (a_LightBuffer==m_BlockSkyLight)?BackChunk->pGetSkyLight():BackChunk->pGetLight();
+ for(int x = 0; x < 16; x++) for(int y = 0; y < 128; y++)
+ {
+ if( FrontChunk )
+ {
+ int index = y + (0 * 128) + (x * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ char CurrentLight = GetLight( a_LightBuffer, x, y, 0 );
+ char FrontLight = GetLight( FrontSky, x, y, 15 );
+ if( FrontLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
+ {
+ SetLight( FrontSky, x, y, 15, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ bCalcFront = true;
+ }
+ }
+ }
+ if( BackChunk )
+ {
+ int index = y + (15 * 128) + (x * 128 * 16);
+ if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
+ {
+ char CurrentLight = GetLight( a_LightBuffer, x, y, 15 );
+ char BackLight = GetLight( BackSky, x, y, 0 );
+ if( BackLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
+ {
+ SetLight( BackSky, x, y, 0, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ bCalcBack = true;
+ }
+ }
+ }
+ }
+
+ if( bCalcLeft ) cRoot::Get()->GetWorld()->ReSpreadLighting( LeftChunk );
+ if( bCalcRight ) cRoot::Get()->GetWorld()->ReSpreadLighting( RightChunk );
+ if( bCalcFront ) cRoot::Get()->GetWorld()->ReSpreadLighting( FrontChunk );
+ if( bCalcBack ) cRoot::Get()->GetWorld()->ReSpreadLighting( BackChunk );
+}
+
+float GetNoise( float x, float y, cNoise & a_Noise )
+{
+ float oct1 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq1, y*cGenSettings::HeightFreq1 )*cGenSettings::HeightAmp1;
+ float oct2 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq2, y*cGenSettings::HeightFreq2 )*cGenSettings::HeightAmp2;
+ float oct3 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq3, y*cGenSettings::HeightFreq3 )*cGenSettings::HeightAmp3;
+
+ float height = a_Noise.CubicNoise2D( x*0.1f, y*0.1f )*2;
+
+ float flatness = ((a_Noise.CubicNoise2D( x*0.5f, y*0.5f ) + 1.f ) * 0.5f) * 1.1f; // 0 ... 1.5
+ flatness *= flatness * flatness;
+
+ return (oct1 + oct2 + oct3) * flatness + height;
+}
+
+#define PI_2 (1.57079633)
+float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
+{
+ 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;
+}
+
+float GetOreNoise( float x, float y, float z, cNoise & a_Noise )
+{
+ float oct1 = a_Noise.CubicNoise3D( x*0.1f, y*0.1f, z*0.1f );
+ float oct2 = a_Noise.CubicNoise3D( x*0.05f, y*0.5f, z*0.05f );
+
+ oct2 *= oct2;
+ oct1 = (1 - (oct1 * oct1 *100)) * oct2;
+ //if( oct1 < 0.5f ) oct1 = 0;
+ //else oct1 = 1.f;
+
+ return oct1;
+}
+
+void cChunk::GenerateTerrain()
+{
+
+
+ const ENUM_BLOCK_ID GrassID = E_BLOCK_GRASS;
+ const ENUM_BLOCK_ID DirtID = E_BLOCK_DIRT;
+ const ENUM_BLOCK_ID StoneID = E_BLOCK_STONE;
+ const ENUM_BLOCK_ID SandID = E_BLOCK_SAND;
+ const ENUM_BLOCK_ID CaveID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID LavaID = E_BLOCK_STATIONARY_LAVA;
+ const ENUM_BLOCK_ID CoalID = E_BLOCK_COAL_ORE;
+ const ENUM_BLOCK_ID IronID = E_BLOCK_IRON_ORE;
+ const ENUM_BLOCK_ID GoldID = E_BLOCK_GOLD_ORE;
+ const ENUM_BLOCK_ID DiamondID = E_BLOCK_DIAMOND_ORE;
+ const ENUM_BLOCK_ID RedID = E_BLOCK_REDSTONE_ORE;
+
+ /*
+ const ENUM_BLOCK_ID GrassID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID DirtID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID StoneID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID SandID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID CaveID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID LavaID = E_BLOCK_AIR;
+ const ENUM_BLOCK_ID CoalID = E_BLOCK_COAL_ORE;
+ const ENUM_BLOCK_ID IronID = E_BLOCK_IRON_ORE;
+ const ENUM_BLOCK_ID GoldID = E_BLOCK_GOLD_ORE;
+ const ENUM_BLOCK_ID DiamondID = E_BLOCK_DIAMOND_ORE;
+ const ENUM_BLOCK_ID RedID = E_BLOCK_REDSTONE_ORE;
+ */
+
+ cNoise m_Noise( cRoot::Get()->GetWorld()->GetWorldSeed() );
+ for(int z = 0; z < 16; z++)
+ {
+ const float zz = (float)(m_PosZ*16 + z);
+ for(int x = 0; x < 16; x++)
+ {
+ // Place bedrock on bottom layer
+ m_BlockType[ MakeIndex(x, 0, z) ] = E_BLOCK_BEDROCK;
+
+ const float xx = (float)(m_PosX*16 + x);
+
+ int Height = (int)(GetNoise( xx*0.05f, zz*0.05f, m_Noise )*16);
+ const int Lower = 64;
+ if( Height+Lower > 127 ) Height = 127-Lower;
+ const int Top = Lower+Height;
+ const float WaveNoise = 1;//m_Noise.CubicNoise2D( xx*0.01f, zz*0.01f ) + 0.5f;
+ for( int y = 1; y < Top; ++y )
+ {
+ const float yy = (float)y;
+ // V prevent caves from getting too close to the surface
+ if( (Top - y > (WaveNoise*2) ) && cosf(GetMarbleNoise( xx, yy*0.5f, zz, m_Noise )) * fabs( cosf( yy*0.2f + WaveNoise*2 )*0.75f + WaveNoise ) > 0.5f )
+ {
+ if( y > 4 )
+ {
+ m_BlockType[ MakeIndex(x, y, z) ] = CaveID;
+ if( z > 0 ) m_BlockType[ MakeIndex(x, y, z-1) ] = CaveID;
+ if( z < 15 ) m_BlockType[ MakeIndex(x, y, z+1) ] = CaveID;
+ if( x > 0 ) m_BlockType[ MakeIndex(x-1, y, z) ] = CaveID;
+ if( x < 15 ) m_BlockType[ MakeIndex(x+1, y, z) ] = CaveID;
+ }
+ else
+ {
+ m_BlockType[ MakeIndex(x, y, z) ] = LavaID;
+ }
+ }
+ else if( y < 61 && Top - y < 3 )
+ m_BlockType[ MakeIndex(x, y, z) ] = SandID;
+ else if( Top - y > ((WaveNoise+1.5f)*1.5f) ) // rock and ores between 1.5 .. 4.5 deep
+ {
+ if( GetOreNoise( xx, yy, zz, m_Noise ) > 0.5f )
+ m_BlockType[ MakeIndex(x, y, z) ] = CoalID;
+ else if( GetOreNoise( xx, yy+100.f, zz, m_Noise ) > 0.6f )
+ m_BlockType[ MakeIndex(x, y, z) ] = IronID;
+ else if( yy < 20 && GetOreNoise( xx*1.5f, yy+300.f, zz*1.5f, m_Noise ) > 0.6f )
+ m_BlockType[ MakeIndex(x, y, z) ] = RedID;
+ else if( yy < 30 && GetOreNoise( xx*2, yy+200.f, zz*2, m_Noise ) > 0.75f )
+ m_BlockType[ MakeIndex(x, y, z) ] = DiamondID;
+ else if( yy < 40 && GetOreNoise( xx*2, yy+100.f, zz*2, m_Noise ) > 0.75f )
+ m_BlockType[ MakeIndex(x, y, z) ] = GoldID;
+ else
+ m_BlockType[ MakeIndex(x, y, z) ] = StoneID;
+ }
+ else
+ m_BlockType[ MakeIndex(x, y, z) ] = DirtID;
+ }
+ for( int y = Lower+Height; y < 60; ++y )
+ {
+ m_BlockType[ MakeIndex(x, y, z) ] = E_BLOCK_STATIONARY_WATER;
+ }
+ }
+ }
+
+ for(int z = 0; z < 16; z++) for(int x = 0; x < 16; x++)
+ {
+ // Find top most Y
+ int TopY = -1;
+ for(int y = 127; y > 0; y--)
+ {
+ int index = MakeIndex( x, y, z );
+ if( m_BlockType[index] != E_BLOCK_AIR )
+ {
+ TopY = y;
+ break;
+ }
+ }
+ if( TopY > 0 )
+ {
+ // Change top dirt into grass
+ int index = MakeIndex( x, TopY, z );
+ if( m_BlockType[index] == DirtID )
+ {
+ m_BlockType[ index ] = (char)GrassID;
+ }
+
+
+ // Plant sum trees
+ {
+ int xx = x + m_PosX*16;
+// int yy = TopY;
+ int zz = z + m_PosZ*16;
+
+ float val1 = m_Noise.CubicNoise2D( xx*0.1f, zz*0.1f );
+ float val2 = m_Noise.CubicNoise2D( xx*0.01f, zz*0.01f );
+ if( m_BlockType[index] == SandID )
+ {
+ if( (val1 + val2 > 0.f) && (rand()%128) > 124 && m_BlockType[index] == E_BLOCK_SAND )
+ {
+ m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_CACTUS;
+ if( (rand() & 3) == 3 )
+ {
+ m_BlockType[ MakeIndex(x, TopY+2, z) ] = E_BLOCK_CACTUS;
+ }
+ continue;
+ }
+ }
+ else if( m_BlockType[index] == GrassID )
+ {
+ float val3 = m_Noise.CubicNoise2D( xx*0.01f+10, zz*0.01f+10 );
+ float val4 = m_Noise.CubicNoise2D( xx*0.05f+20, zz*0.05f+20 );
+ if( val1 + val2 > 0.2f && (rand()%128) > 124 )
+ cRoot::Get()->GetWorld()->GrowTree( xx, TopY, zz );
+ else if( val3 > 0.2f && (rand()%128) > 124 )
+ m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_YELLOW_FLOWER;
+ else if( val4 > 0.2f && (rand()%128) > 124 )
+ m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_RED_ROSE;
+ else if( val1+val2+val3+val4 > 0.2f && (rand()%128) > 124 )
+ m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_RED_MUSHROOM;
+ else if( val1+val2+val3+val4 > 0.2f && (rand()%128) > 124 )
+ m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_BROWN_MUSHROOM;
+ }
+ }
+
+ }
+ }
+}
+
+
+void cChunk::AsyncUnload( cClientHandle* a_Client )
+{
+ m_pState->m_UnloadQuery.remove( a_Client ); // Make sure this client is only in the list once
+ m_pState->m_UnloadQuery.push_back( a_Client );
+}
+
+void cChunk::Send( cClientHandle* a_Client )
+{
+ cPacket_PreChunk PreChunk;
+ PreChunk.m_PosX = m_PosX;
+ PreChunk.m_PosZ = m_PosZ;
+ PreChunk.m_bLoad = true;
+ a_Client->Send( PreChunk );
+ a_Client->Send( cPacket_MapChunk( this ) );
+
+ for( BlockEntityList::iterator itr = m_pState->m_BlockEntities.begin(); itr != m_pState->m_BlockEntities.end(); ++itr )
+ {
+ (*itr)->SendTo( a_Client );
+ }
+}
+
+void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
+{
+ if(a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)
+ {
+ //printf(">>>>>>>>>>>>>>>> CLIPPED SETBLOCK %i %i %i\n", a_X, a_Y, a_Z );
+ return; // Clip
+ }
+
+ int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ char OldBlockMeta = GetLight( m_BlockMeta, index );
+ char OldBlockType = m_BlockType[index];
+ m_BlockType[index] = a_BlockType;
+
+ SetLight( m_BlockMeta, index, a_BlockMeta );
+
+ if( OldBlockType != a_BlockType || OldBlockMeta != a_BlockMeta )
+ {
+ //LOG("Old: %i %i New: %i %i", OldBlockType, OldBlockMeta, a_BlockType, a_BlockMeta );
+ m_pState->m_PendingSendBlocks.push_back( index );
+
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X+1, a_Y, a_Z ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X-1, a_Y, a_Z ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X, a_Y+1, a_Z ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X, a_Y-1, a_Z ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z+1 ) ]++;
+ m_pState->m_ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z-1 ) ]++;
+
+ cBlockEntity* BlockEntity = GetBlockEntity( a_X + m_PosX*16, a_Y+m_PosY*128, a_Z+m_PosZ*16 );
+ if( BlockEntity )
+ {
+ BlockEntity->Destroy();
+ RemoveBlockEntity( BlockEntity );
+ delete BlockEntity;
+ }
+ switch( a_BlockType )
+ {
+ case E_BLOCK_CHEST:
+ AddBlockEntity( new cChestEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ break;
+ case E_BLOCK_FURNACE:
+ AddBlockEntity( new cFurnaceEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ break;
+ default:
+ break;
+ };
+ }
+
+ CalculateHeightmap();
+ RecalculateLighting();
+}
+
+void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
+{
+ if(a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)
+ {
+ //printf(">>>>>>>>>>>>>>>> CLIPPED SETBLOCK %i %i %i\n", a_X, a_Y, a_Z );
+ return; // Clip
+ }
+
+ const int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ const char OldBlock = m_BlockType[index];
+ m_BlockType[index] = a_BlockType;
+ m_pState->m_PendingSendBlocks.push_back( index );
+ SetLight( m_BlockMeta, index, a_BlockMeta );
+
+ // ONLY recalculate lighting if it's nessesary!
+ if( g_BlockLightValue[ OldBlock ] != g_BlockLightValue[ a_BlockType ]
+ || g_BlockSpreadLightFalloff[ OldBlock ] != g_BlockSpreadLightFalloff[ a_BlockType ]
+ || g_BlockTransparent[ OldBlock ] != g_BlockTransparent[ a_BlockType ] )
+ {
+ RecalculateLighting();
+ }
+
+ // Recalculate next tick
+ RecalculateHeightmap();
+}
+
+void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
+{
+ if( a_Client == 0 )
+ {
+ m_pState->m_PendingSendBlocks.push_back( MakeIndex( a_X, a_Y, a_Z ) );
+ return;
+ }
+
+ for( std::list< cClientHandle* >::iterator itr = m_pState->m_LoadedByClient.begin(); itr != m_pState->m_LoadedByClient.end(); ++itr )
+ {
+ if( *itr == a_Client )
+ {
+ unsigned int index = MakeIndex( a_X, a_Y, a_Z );
+ cPacket_BlockChange BlockChange;
+ BlockChange.m_PosX = a_X + m_PosX*16;
+ BlockChange.m_PosY = (char)(a_Y + m_PosY*128);
+ BlockChange.m_PosZ = a_Z + m_PosZ*16;
+ BlockChange.m_BlockType = m_BlockType[ index ];
+ BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
+ a_Client->Send( BlockChange );
+ break;
+ }
+ }
+}
+
+void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity )
+{
+ m_pState->m_BlockEntities.push_back( a_BlockEntity );
+}
+
+void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
+{
+ m_pState->m_BlockEntities.remove( a_BlockEntity );
+}
+
+void cChunk::AddClient( cClientHandle* a_Client )
+{
+ m_pState->m_LoadedByClient.remove( a_Client );
+ m_pState->m_LoadedByClient.push_back( a_Client );
+
+ LockEntities();
+ for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr )
+ {
+ LOG("%i %i %i Spawning on %s", m_PosX, m_PosY, m_PosZ, a_Client->GetUsername() );
+ (*itr)->SpawnOn( a_Client );
+ }
+ UnlockEntities();
+}
+
+void cChunk::RemoveClient( cClientHandle* a_Client )
+{
+ m_pState->m_LoadedByClient.remove( a_Client );
+
+ LockEntities();
+ for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr )
+ {
+ LOG("%i %i %i Destroying on %s", m_PosX, m_PosY, m_PosZ, a_Client->GetUsername() );
+ cPacket_DestroyEntity DestroyEntity( *itr );
+ a_Client->Send( DestroyEntity );
+ }
+ UnlockEntities();
+}
+
+void cChunk::AddEntity( cEntity & a_Entity )
+{
+ LockEntities();
+ m_pState->m_Entities.push_back( &a_Entity );
+ UnlockEntities();
+}
+
+bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
+{
+ LockEntities();
+ unsigned int SizeBefore = m_pState->m_Entities.size();
+ m_pState->m_Entities.remove( &a_Entity );
+ if( SizeBefore == m_pState->m_Entities.size() )
+ {
+ LOG("WARNING: Entity was not in chunk %i %i %i", m_PosX, m_PosY, m_PosZ );
+ if( !a_CalledFrom )
+ {
+ UnlockEntities();
+ return cRoot::Get()->GetWorld()->RemoveEntityFromChunk( a_Entity, this );
+ }
+ UnlockEntities();
+ return false;
+ }
+ UnlockEntities();
+ return true;
+}
+
+void cChunk::LockEntities()
+{
+ EnterCriticalSection( (CRITICAL_SECTION*)m_EntitiesCriticalSection );
+}
+
+void cChunk::UnlockEntities()
+{
+ LeaveCriticalSection( (CRITICAL_SECTION*)m_EntitiesCriticalSection );
+}
+
+char cChunk::GetBlock( int a_X, int a_Y, int a_Z )
+{
+ if(a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16) return 0; // Clip
+
+ int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ return m_BlockType[index];
+}
+
+char cChunk::GetBlock( int a_BlockIdx )
+{
+ if( a_BlockIdx < 0 || a_BlockIdx >= c_NumBlocks ) return 0;
+ return m_BlockType[ a_BlockIdx ];
+}
+
+cBlockEntity* cChunk::GetBlockEntity( int a_X, int a_Y, int a_Z )
+{
+ for( std::list<cBlockEntity*>::iterator itr = m_pState->m_BlockEntities.begin(); itr != m_pState->m_BlockEntities.end(); ++itr)
+ {
+ if( (*itr)->GetPosX() == a_X &&
+ (*itr)->GetPosY() == a_Y &&
+ (*itr)->GetPosZ() == a_Z )
+ {
+ return *itr;
+ }
+ }
+ return 0;
+}
+
+bool cChunk::LoadFromDisk()
+{
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/X%i_Y%i_Z%i.bin", m_PosX, m_PosY, m_PosZ );
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "rb" )) != 0 ) // no error
+ #endif
+ {
+ if( fread( m_BlockData, sizeof(char)*c_BlockDataSize, 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+
+ // Now load Block Entities
+ ENUM_BLOCK_ID BlockType;
+ while( fread( &BlockType, sizeof(ENUM_BLOCK_ID), 1, f) == 1 )
+ {
+ switch( BlockType )
+ {
+ case E_BLOCK_CHEST:
+ {
+ cChestEntity* ChestEntity = new cChestEntity( 0, 0, 0 );
+ if( !ChestEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING CHEST FROM FILE %s", SourceFile );
+ delete ChestEntity;
+ fclose(f);
+ return false;
+ }
+ m_pState->m_BlockEntities.push_back( ChestEntity );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ cFurnaceEntity* FurnaceEntity = new cFurnaceEntity( 0, 0, 0 );
+ if( !FurnaceEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING FURNACE FROM FILE %s", SourceFile );
+ delete FurnaceEntity;
+ fclose(f);
+ return false;
+ }
+ m_pState->m_BlockEntities.push_back( FurnaceEntity );
+ m_pState->m_TickBlockEntities.push_back( FurnaceEntity ); // They need tickin'
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ cSignEntity* SignEntity = new cSignEntity(BlockType, 0, 0, 0 );
+ if( !SignEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING SIGN FROM FILE %s", SourceFile );
+ delete SignEntity;
+ fclose(f);
+ return false;
+ }
+ m_pState->m_BlockEntities.push_back( SignEntity );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ fclose(f);
+
+ // Delete old format file
+ if( std::remove( SourceFile ) != 0 )
+ LOGERROR("Could not delete file %s", SourceFile );
+ else
+ LOGINFO("Successfully deleted olf format file %s", SourceFile );
+
+ return true;
+ }
+ else
+ {
+ //LOGWARN("COULD NOT OPEN FILE %s\n", SourceFile);
+ return false;
+ }
+}
+
+bool cChunk::SaveToDisk()
+{
+ return true; //no more saving old format!
+
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/X%i_Y%i_Z%i.bin", m_PosX, m_PosY, m_PosZ );
+
+ #ifdef _WIN32
+ {
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("world", &Attrib);
+ }
+ #else
+ {
+ mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+ #endif
+
+ FILE* f = 0;
+#ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "wb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "wb" )) != 0 ) // no error
+ #endif
+ {
+ fwrite( m_BlockData, sizeof(char)*c_BlockDataSize, 1, f );
+
+ // Now write Block Entities
+ for( std::list<cBlockEntity*>::iterator itr = m_pState->m_BlockEntities.begin(); itr != m_pState->m_BlockEntities.end(); ++itr)
+ {
+ cBlockEntity* BlockEntity = *itr;
+ switch( BlockEntity->GetBlockType() )
+ {
+ case E_BLOCK_CHEST:
+ {
+ cChestEntity* ChestEntity = reinterpret_cast< cChestEntity* >( BlockEntity );
+ ChestEntity->WriteToFile( f );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ cFurnaceEntity* FurnaceEntity = reinterpret_cast< cFurnaceEntity* >( BlockEntity );
+ FurnaceEntity->WriteToFile( f );
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ cSignEntity* SignEntity = reinterpret_cast< cSignEntity* >( BlockEntity );
+ SignEntity->WriteToFile( f );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ fclose(f);
+ return true;
+ }
+ else
+ {
+ LOGERROR("ERROR WRITING TO FILE %s", SourceFile);
+ return false;
+ }
+}
+
+void cChunk::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ ) const
+{
+ for( std::list< cClientHandle* >::const_iterator itr = m_pState->m_LoadedByClient.begin(); itr != m_pState->m_LoadedByClient.end(); ++itr )
+ {
+ if( *itr == a_Exclude ) continue;
+ (*itr)->Send( a_Packet );
+ }
+}
+
+
+void cChunk::LoadFromJson( const Json::Value & a_Value )
+{
+ // Load chests
+ Json::Value AllChests = a_Value.get("Chests", Json::nullValue);
+ if( !AllChests.empty() )
+ {
+ for( Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
+ {
+ Json::Value & Chest = *itr;
+ cChestEntity* ChestEntity = new cChestEntity(0,0,0);
+ if( !ChestEntity->LoadFromJson( Chest ) )
+ {
+ LOGERROR("ERROR READING CHEST FROM JSON!" );
+ delete ChestEntity;
+ }
+ else m_pState->m_BlockEntities.push_back( ChestEntity );
+ }
+ }
+
+ // Load furnaces
+ Json::Value AllFurnaces = a_Value.get("Furnaces", Json::nullValue);
+ if( !AllFurnaces.empty() )
+ {
+ for( Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr )
+ {
+ Json::Value & Furnace = *itr;
+ cFurnaceEntity* FurnaceEntity = new cFurnaceEntity(0,0,0);
+ if( !FurnaceEntity->LoadFromJson( Furnace ) )
+ {
+ LOGERROR("ERROR READING FURNACE FROM JSON!" );
+ delete FurnaceEntity;
+ }
+ else m_pState->m_BlockEntities.push_back( FurnaceEntity );
+ }
+ }
+
+ // Load signs
+ Json::Value AllSigns = a_Value.get("Signs", Json::nullValue);
+ if( !AllSigns.empty() )
+ {
+ for( Json::Value::iterator itr = AllSigns.begin(); itr != AllSigns.end(); ++itr )
+ {
+ Json::Value & Sign = *itr;
+ cSignEntity* SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0,0,0);
+ if( !SignEntity->LoadFromJson( Sign ) )
+ {
+ LOGERROR("ERROR READING SIGN FROM JSON!" );
+ delete SignEntity;
+ }
+ else m_pState->m_BlockEntities.push_back( SignEntity );
+ }
+ }
+}
+
+void cChunk::SaveToJson( Json::Value & a_Value )
+{
+ Json::Value AllChests;
+ Json::Value AllFurnaces;
+ Json::Value AllSigns;
+ for( std::list<cBlockEntity*>::iterator itr = m_pState->m_BlockEntities.begin(); itr != m_pState->m_BlockEntities.end(); ++itr)
+ {
+ cBlockEntity* BlockEntity = *itr;
+ switch( BlockEntity->GetBlockType() )
+ {
+ case E_BLOCK_CHEST:
+ {
+ cChestEntity* ChestEntity = reinterpret_cast< cChestEntity* >( BlockEntity );
+ Json::Value NewChest;
+ ChestEntity->SaveToJson( NewChest );
+ AllChests.append( NewChest );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ cFurnaceEntity* FurnaceEntity = reinterpret_cast< cFurnaceEntity* >( BlockEntity );
+ Json::Value NewFurnace;
+ FurnaceEntity->SaveToJson( NewFurnace );
+ AllFurnaces.append( NewFurnace );
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ cSignEntity* SignEntity = reinterpret_cast< cSignEntity* >( BlockEntity );
+ Json::Value NewSign;
+ SignEntity->SaveToJson( NewSign );
+ AllSigns.append( NewSign );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if( !AllChests.empty() )
+ a_Value["Chests"] = AllChests;
+ if( !AllFurnaces.empty() )
+ a_Value["Furnaces"] = AllFurnaces;
+ if( !AllSigns.empty() )
+ a_Value["Signs"] = AllSigns;
+}
+
+EntityList & cChunk::GetEntities()
+{
+ return m_pState->m_Entities;
+}
+
+const ClientHandleList & cChunk::GetClients()
+{
+ return m_pState->m_LoadedByClient;
+}
+
+
+void cChunk::AddTickBlockEntity( cFurnaceEntity* a_Entity )
+{
+ m_pState->m_TickBlockEntities.remove( a_Entity );
+ m_pState->m_TickBlockEntities.push_back( a_Entity );
+}
+
+void cChunk::RemoveTickBlockEntity( cFurnaceEntity* a_Entity )
+{
+ m_pState->m_TickBlockEntities.remove( a_Entity );
+} \ No newline at end of file
diff --git a/source/cChunk.h b/source/cChunk.h
new file mode 100644
index 000000000..83c14dcfa
--- /dev/null
+++ b/source/cChunk.h
@@ -0,0 +1,127 @@
+#pragma once
+
+#include <list>
+
+namespace Json
+{
+ class Value;
+};
+
+class cFurnaceEntity;
+class cPacket;
+class cBlockEntity;
+class cEntity;
+class cClientHandle;
+class cServer;
+class cChunk
+{
+public:
+ cChunk(int a_X, int a_Y, int a_Z);
+ ~cChunk();
+
+ void Initialize();
+
+ void Tick(float a_Dt);
+
+ inline int GetPosX() { return m_PosX; }
+ inline int GetPosY() { return m_PosY; }
+ inline int GetPosZ() { return m_PosZ; }
+
+ void Send( cClientHandle* a_Client );
+ void AsyncUnload( cClientHandle* a_Client );
+
+ void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta );
+ void FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta );
+ char GetBlock( int a_X, int a_Y, int a_Z );
+ char GetBlock( int a_BlockIdx );
+ cBlockEntity* GetBlockEntity( int a_X, int a_Y, int a_Z );
+ void RemoveBlockEntity( cBlockEntity* a_BlockEntity );
+ void AddBlockEntity( cBlockEntity* a_BlockEntity );
+
+ char GetHeight( int a_X, int a_Z );
+
+ void SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client );
+
+ void AddClient( cClientHandle* a_Client );
+ void RemoveClient( cClientHandle* a_Client );
+
+ std::list< cEntity* > & GetEntities();// { return m_Entities; }
+ void AddEntity( cEntity & a_Entity );
+ bool RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom = 0 );
+ void LockEntities();
+ void UnlockEntities();
+
+ const std::list< cClientHandle* > & GetClients();// { return m_LoadedByClient; }
+
+ inline void RecalculateLighting() { m_bCalculateLighting = true; } // Recalculate lighting next tick
+ inline void RecalculateHeightmap() { m_bCalculateHeightmap = true; } // Recalculate heightmap next tick
+ void SpreadLight(char* a_LightBuffer);
+
+ bool SaveToDisk();
+ bool LoadFromDisk();
+
+ // Broadcasts to all clients that have loaded this chunk
+ void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 ) const;
+
+ char* pGetBlockData() { return m_BlockData; }
+ char* pGetType() { return m_BlockType; }
+ char* pGetMeta() { return m_BlockMeta; }
+ char* pGetLight() { return m_BlockLight; }
+ char* pGetSkyLight() { return m_BlockSkyLight; }
+
+ char GetLight(char* a_Buffer, int a_BlockIdx);
+ char GetLight(char* a_Buffer, int x, int y, int z);
+ void SetLight(char* a_Buffer, int a_BlockIdx, char a_Light);
+ void SetLight(char* a_Buffer, int x, int y, int z, char light);
+
+ void AddTickBlockEntity( cFurnaceEntity* a_Entity );
+ //{
+ // m_TickBlockEntities.remove( a_Entity );
+ // m_TickBlockEntities.push_back( a_Entity );
+ //}
+
+ void RemoveTickBlockEntity( cFurnaceEntity* a_Entity );
+ //{
+ // m_TickBlockEntities.remove( a_Entity );
+ //}
+
+ static const int c_NumBlocks = 16*128*16;
+ static const int c_BlockDataSize = c_NumBlocks * 2 + (c_NumBlocks/2); // 2.5 * numblocks
+private:
+ struct sChunkState;
+ sChunkState* m_pState;
+
+ friend class cChunkMap; // So it has access to buffers and shit
+ void LoadFromJson( const Json::Value & a_Value );
+ void SaveToJson( Json::Value & a_Value );
+
+ void GenerateTerrain();
+ void CalculateLighting(); // Recalculate right now
+ void CalculateHeightmap();
+ void SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
+ void SpreadLightOfBlockX(char* a_LightBuffer, int a_X, int a_Y, int a_Z);
+ void SpreadLightOfBlockY(char* a_LightBuffer, int a_X, int a_Y, int a_Z);
+ void SpreadLightOfBlockZ(char* a_LightBuffer, int a_X, int a_Y, int a_Z);
+
+ void CreateBlockEntities();
+
+ unsigned int MakeIndex(int x, int y, int z );
+
+ bool m_bCalculateLighting;
+ bool m_bCalculateHeightmap;
+
+ int m_PosX, m_PosY, m_PosZ;
+
+ char m_BlockData[c_BlockDataSize]; // Chunk data ready to be compressed and sent
+ char *m_BlockType; // Pointers to an element in m_BlockData
+ char *m_BlockMeta; // += NumBlocks
+ char *m_BlockLight; // += NumBlocks/2
+ char *m_BlockSkyLight; // += NumBlocks/2
+
+ unsigned char m_HeightMap[16*16];
+
+ unsigned int m_BlockTickNum;
+ unsigned int m_BlockTickX, m_BlockTickY, m_BlockTickZ;
+
+ void* m_EntitiesCriticalSection;
+}; \ No newline at end of file
diff --git a/source/cChunkLoader.cpp b/source/cChunkLoader.cpp
new file mode 100644
index 000000000..a5d07818d
--- /dev/null
+++ b/source/cChunkLoader.cpp
@@ -0,0 +1,364 @@
+#if 0 // ignore all contents of this file
+#include "cChunkLoader.h"
+#include "cChunk.h"
+#include "cMCLogger.h"
+#include "BlockID.h"
+#include "cCriticalSection.h"
+#include "cEvent.h"
+#include "cThread.h"
+#include "cSleep.h"
+
+#include "cChestEntity.h"
+#include "cFurnaceEntity.h"
+#include "cSignEntity.h"
+
+#include <iostream>
+#ifndef _WIN32
+#include <cstring>
+#include <cstdlib>
+#include <stdio.h>
+#include <sys/stat.h> // for mkdir
+#include <sys/types.h>
+#else
+#include <Windows.h>
+#endif
+
+#include <list>
+
+struct ChunkData
+{
+ ChunkData()
+ : x( 0 )
+ , z( 0 )
+ , Data( 0 )
+ , LiveChunk( 0 )
+ {}
+ int x, z;
+ unsigned int DataSize;
+ unsigned int ChunkStart;
+ char* Data;
+ cChunk* LiveChunk;
+};
+
+typedef std::list< ChunkData > ChunkDataList;
+struct cChunkLoader::ChunkPack
+{
+ ChunkDataList AllChunks;
+ int x, y, z;
+};
+
+typedef std::list< cChunkLoader::ChunkPack > ChunkPackList;
+struct cChunkLoader::ChunkPacks
+{
+ ChunkPackList AllPacks;
+};
+
+cChunkLoader::cChunkLoader()
+ : m_bStop( false )
+ , m_CriticalSection( new cCriticalSection() )
+ , m_Event( new cEvent() )
+ , m_ChunkPacks( new ChunkPacks )
+{
+ cThread( SaveThread, this );
+}
+
+cChunkLoader::~cChunkLoader()
+{
+ m_bStop = true;
+ m_Event->Wait();
+ delete m_CriticalSection;
+}
+
+void cChunkLoader::SaveThread( void* a_Param )
+{
+ cChunkLoader* self = (cChunkLoader*)a_Param;
+ while( !self->m_bStop )
+ {
+ cSleep::MilliSleep( 1000 ); // Only check for saving once a second
+ }
+ self->m_Event->Set();
+}
+
+cChunk* cChunkLoader::LoadChunk( int a_X, int a_Y, int a_Z )
+{
+ m_CriticalSection->Lock();
+ cChunk* Chunk = 0;
+
+ Chunk = LoadOldFormat( a_X, a_Y, a_Z );
+ if( Chunk ) { Chunk->CalculateHeightmap(); }
+ else
+ {
+ 1; // load new format()
+ }
+
+ m_CriticalSection->Unlock();
+ return Chunk;
+}
+
+bool cChunkLoader::SaveChunk( const cChunk & a_Chunk )
+{
+ m_CriticalSection->Lock();
+ bool Success = SaveOldFormat( a_Chunk );
+ m_CriticalSection->Unlock();
+
+ return Success;
+}
+
+/**************************************************
+ * Old format stuffs
+ **/
+
+cChunk* cChunkLoader::LoadOldFormat( int a_X, int a_Y, int a_Z )
+{
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/X%i_Y%i_Z%i.bin", a_X, a_Y, a_Z );
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "rb" )) != 0 ) // no error
+ #endif
+ {
+ cChunk* Chunk = new cChunk( a_X, a_Y, a_Z );
+ if( fread( Chunk->m_BlockData, sizeof(char)*cChunk::c_BlockDataSize, 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+
+ // Now load Block Entities
+ ENUM_BLOCK_ID BlockType;
+ while( fread( &BlockType, sizeof(ENUM_BLOCK_ID), 1, f) == 1 )
+ {
+ switch( BlockType )
+ {
+ case E_BLOCK_CHEST:
+ {
+ cChestEntity* ChestEntity = new cChestEntity( 0, 0, 0 );
+ if( !ChestEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING CHEST FROM FILE %s", SourceFile );
+ delete ChestEntity;
+ fclose(f);
+ return false;
+ }
+ Chunk->m_BlockEntities.push_back( ChestEntity );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ cFurnaceEntity* FurnaceEntity = new cFurnaceEntity( 0, 0, 0 );
+ if( !FurnaceEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING FURNACE FROM FILE %s", SourceFile );
+ delete FurnaceEntity;
+ fclose(f);
+ return false;
+ }
+ Chunk->m_BlockEntities.push_back( FurnaceEntity );
+ Chunk->m_TickBlockEntities.push_back( FurnaceEntity ); // They need tickin'
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ cSignEntity* SignEntity = new cSignEntity(BlockType, 0, 0, 0 );
+ if( !SignEntity->LoadFromFile( f ) )
+ {
+ LOGERROR("ERROR READING SIGN FROM FILE %s", SourceFile );
+ delete SignEntity;
+ fclose(f);
+ return false;
+ }
+ Chunk->m_BlockEntities.push_back( SignEntity );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ fclose(f);
+ return Chunk;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+bool cChunkLoader::SaveOldFormat( const cChunk & a_Chunk )
+{
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/X%i_Y%i_Z%i.bin", a_Chunk.m_PosX, a_Chunk.m_PosY, a_Chunk.m_PosZ );
+
+ #ifdef _WIN32
+ {
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("world", &Attrib);
+ }
+ #else
+ {
+ mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+ #endif
+
+ FILE* f = 0;
+#ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "wb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "wb" )) != 0 ) // no error
+ #endif
+ {
+ fwrite( a_Chunk.m_BlockData, sizeof(char)*cChunk::c_BlockDataSize, 1, f );
+
+ // Now write Block Entities
+ for( std::list<cBlockEntity*>::const_iterator itr = a_Chunk.m_BlockEntities.begin(); itr != a_Chunk.m_BlockEntities.end(); ++itr)
+ {
+ cBlockEntity* BlockEntity = *itr;
+ switch( BlockEntity->GetBlockType() )
+ {
+ case E_BLOCK_CHEST:
+ {
+ cChestEntity* ChestEntity = reinterpret_cast< cChestEntity* >( BlockEntity );
+ ChestEntity->WriteToFile( f );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ {
+ cFurnaceEntity* FurnaceEntity = reinterpret_cast< cFurnaceEntity* >( BlockEntity );
+ FurnaceEntity->WriteToFile( f );
+ }
+ break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN:
+ {
+ cSignEntity* SignEntity = reinterpret_cast< cSignEntity* >( BlockEntity );
+ SignEntity->WriteToFile( f );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ fclose(f);
+ return true;
+ }
+ else
+ {
+ LOGERROR("ERROR WRITING TO FILE %s", SourceFile);
+ return false;
+ }
+}
+
+
+/******************************************
+ * New format
+ **/
+
+cChunk* cChunkLoader::LoadFormat1( int a_X, int a_Y, int a_Z )
+{
+ int PakX = (int)(floorf((float)a_X / 16.f));
+ int PakY = (int)(floorf((float)a_Y / 16.f));
+ int PakZ = (int)(floorf((float)a_Z / 16.f));
+
+ ChunkPack * Pack = 0;
+ ChunkPackList & PackList = m_ChunkPacks->AllPacks;
+ for( ChunkPackList::iterator itr = PackList.begin(); itr != PackList.end(); ++itr )
+ {
+ if( itr->x == PakX && itr->y == PakY && itr->z == PakZ )
+ {
+ Pack = &(*itr);
+ break;
+ }
+ }
+
+
+ if( !Pack ) // The pack was not in memory, so try to load it from disk
+ {
+ Pack = LoadPak1( PakX, PakY, PakZ ); // Load .pak file from disk
+ if( Pack )
+ {
+ PackList.push_back( *Pack ); // Add it to the loaded list
+ }
+ }
+
+ if( Pack ) // Allright, the pack is in memory
+ {
+ ChunkData * Data = 0;
+ ChunkDataList & ChunkList = Pack->AllChunks;
+ for( ChunkDataList::iterator itr = ChunkList.begin(); itr != ChunkList.end(); ++itr )
+ {
+ if( itr->x == a_X && itr->z == a_Z )
+ {
+ Data = &(*itr);
+ break;
+ }
+ }
+
+ if( !Data ) // Sorry, chunk does not exist (yet)
+ return 0;
+
+ if( Data->LiveChunk ) // This chunk is already loaded and decoded (this should actually never happen)
+ return Data->LiveChunk;
+
+ // Decompress chunk, and return brand new chunk
+
+ // doing it...
+
+ return 0; // actually return the chunk
+ }
+
+ return 0; // .pak file didn't exist
+}
+
+cChunkLoader::ChunkPack* cChunkLoader::LoadPak1( int PakX, int PakY, int PakZ )
+{
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/X%i_Y%i_Z%i.pak", PakX, PakY, PakZ );
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "rb" )) != 0 ) // no error
+ #endif
+ {
+ cChunkLoader::ChunkPack * Pack = new cChunkLoader::ChunkPack;
+ Pack->x = PakX;
+ Pack->y = PakY;
+ Pack->z = PakZ;
+
+ short Version = 0;
+ if( fread( &Version, sizeof( short ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ if( Version != 1 ) { LOGERROR("Wrong pak version! %s", SourceFile ); return 0; }
+ short NumChunks = 0;
+ if( fread( &NumChunks, sizeof( short ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+
+ // Load all the headers
+ for( short i = 0; i < NumChunks; ++i )
+ {
+ ChunkData Data;
+ if( fread( &Data.x, sizeof( int ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ if( fread( &Data.z, sizeof( int ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ if( fread( &Data.DataSize, sizeof( unsigned int ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ if( fread( &Data.ChunkStart, sizeof( unsigned int ), 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ Pack->AllChunks.push_back( Data );
+ }
+
+ // Load all compressed chunk data in the order the headers were loaded
+ ChunkDataList::iterator itr = Pack->AllChunks.begin();
+ for( short i = 0; i < NumChunks; ++i )
+ {
+ itr->Data = new char[ itr->DataSize ];
+ if( fread( itr->Data, sizeof( char ) * itr->DataSize, 1, f ) != 1 ) { LOGERROR("Error reading file %s", SourceFile ); return 0; }
+ ++itr;
+ }
+
+ // And we're done :)
+ return Pack;
+ }
+ return 0;
+}
+#endif \ No newline at end of file
diff --git a/source/cChunkLoader.h b/source/cChunkLoader.h
new file mode 100644
index 000000000..5d9be39c5
--- /dev/null
+++ b/source/cChunkLoader.h
@@ -0,0 +1,32 @@
+#pragma once
+
+class cCriticalSection;
+class cEvent;
+class cChunk;
+class cChunkLoader
+{
+public:
+ cChunkLoader();
+ ~cChunkLoader();
+
+ cChunk* LoadChunk( int a_X, int a_Y, int a_Z );
+ bool SaveChunk( const cChunk & a_Chunk );
+
+ struct ChunkPack;
+private:
+ cChunk* LoadFormat1( int a_X, int a_Y, int a_Z );
+ ChunkPack* LoadPak1( int PakX, int PakY, int PakZ ); // This loads a .pak file from disk and returns it, nothing more
+
+ // Old stuffs
+ cChunk* LoadOldFormat( int a_X, int a_Y, int a_Z );
+ bool SaveOldFormat( const cChunk & a_Chunk );
+
+ static void SaveThread( void* a_Param );
+
+ bool m_bStop;
+ cCriticalSection* m_CriticalSection;
+ cEvent* m_Event;
+
+ struct ChunkPacks; // Defined in .cpp
+ ChunkPacks* m_ChunkPacks;
+}; \ No newline at end of file
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
new file mode 100644
index 000000000..5e0e39a9c
--- /dev/null
+++ b/source/cChunkMap.cpp
@@ -0,0 +1,714 @@
+#include "cChunkMap.h"
+#include "cChunk.h"
+#include "cMCLogger.h"
+#include "cWorld.h"
+#include "cRoot.h"
+#include "cMakeDir.h"
+#ifndef _WIN32
+#include <cstring> // memcpy
+#include <cstdlib> // abs
+#endif
+
+#include "zlib.h"
+#include <json/json.h>
+
+#define USE_MEMCPY
+
+#define LAYER_SIZE (32)
+
+cChunkMap::cChunkMap( int a_Width, int a_Height )
+ : m_Nodes( new cChunkNode[ a_Width * a_Height ] )
+ , m_Width( a_Width )
+ , m_Height( a_Height )
+ , m_Layers( 0 )
+ , m_NumLayers( 0 )
+{
+}
+
+cChunkMap::~cChunkMap()
+{
+ delete [] m_Nodes;
+}
+
+cChunkMap::cChunkNode::cChunkNode()
+{
+ m_Size = 0;
+ m_Allocated = 0;
+ m_Chunks = 0;
+}
+
+cChunkMap::cChunkNode::~cChunkNode()
+{
+ if( m_Allocated > 0 )
+ {
+ for( unsigned int i = 0; i < m_Size; ++i )
+ {
+ delete m_Chunks[i];
+ }
+ delete [] m_Chunks;
+ }
+// m_Chunks = 0;
+// m_Allocated = 0;
+// m_Size = 0;
+}
+
+void cChunkMap::cChunkNode::push_back( cChunk* a_Chunk )
+{
+ if( m_Allocated == 0 )
+ {
+ resize( 1 );
+ }
+ if( m_Size >= m_Allocated )
+ {
+ resize( m_Allocated*2 );
+ }
+
+ m_Chunks[ m_Size ] = a_Chunk;
+ m_Size++;
+}
+
+void cChunkMap::cChunkNode::resize( unsigned int a_NewSize )
+{
+ cChunk** TempChunks = new cChunk*[a_NewSize];
+ if( m_Allocated > 0 )
+ {
+#ifdef USE_MEMCPY
+ memcpy( TempChunks, m_Chunks, sizeof( cChunk* ) * m_Size );
+#else
+ for( unsigned int i = 0; i < a_NewSize; ++i )
+ TempChunks[i] = m_Chunks[i];
+#endif
+ delete [] m_Chunks;
+ }
+ m_Chunks = TempChunks;
+ m_Allocated = a_NewSize;
+}
+
+void cChunkMap::cChunkNode::erase( cChunk* a_Chunk )
+{
+ if( m_Size == 0 ) return;
+
+ cChunk** TempChunks = new cChunk*[m_Size];
+ unsigned int TempIdx = 0;
+ for( unsigned int i = 0; i < m_Size; ++i )
+ {
+ if( m_Chunks[i] != a_Chunk )
+ {
+ TempChunks[TempIdx] = m_Chunks[i];
+ TempIdx++;
+ }
+ }
+ delete [] m_Chunks;
+ m_Chunks = 0;
+ if( TempIdx > 0 )
+ {
+ m_Chunks = new cChunk*[ TempIdx ];
+#ifdef USE_MEMCPY
+ memcpy( m_Chunks, TempChunks, sizeof( cChunk* ) * TempIdx );
+#else
+ for( unsigned int i = 0; i < TempIdx; ++i )
+ m_Chunks[i] = TempChunks[i];
+#endif
+ }
+ delete [] TempChunks;
+ m_Allocated = TempIdx;
+ m_Size = TempIdx;
+}
+
+cChunkMap::cChunkData* cChunkMap::cChunkLayer::GetChunk( int a_X, int a_Z )
+{
+ const int LocalX = a_X - m_X * LAYER_SIZE;
+ const int LocalZ = a_Z - m_Z * LAYER_SIZE;
+ //LOG("LocalX:%i LocalZ:%i", LocalX, LocalZ );
+ if( LocalX < LAYER_SIZE && LocalZ < LAYER_SIZE && LocalX > -1 && LocalZ > -1 )
+ return &m_Chunks[ LocalX + LocalZ * LAYER_SIZE ];
+ return 0;
+}
+
+bool cChunkMap::RemoveLayer( cChunkLayer* a_Layer )
+{
+ cChunkLayer* NewLayers = 0;
+ if( m_NumLayers > 1 )
+ NewLayers = new cChunkLayer[m_NumLayers-1];
+
+ int idx = 0;
+ bool bExcludedLayer = false;
+ for( int i = 0; i < m_NumLayers; ++i )
+ {
+ if( &m_Layers[i] != a_Layer )
+ {
+ if( idx < m_NumLayers-1 )
+ {
+ NewLayers[ idx ] = m_Layers[i];
+ idx++;
+ }
+ }
+ else
+ bExcludedLayer = true;
+ }
+
+ if( !bExcludedLayer )
+ {
+ LOGWARN("Could not remove layer, because layer was not found %i %i", a_Layer->m_X, a_Layer->m_Z);
+ delete [] NewLayers;
+ return false;
+ }
+
+ if( m_Layers ) delete [] m_Layers;
+ m_Layers = NewLayers;
+ m_NumLayers--;
+ return true;
+}
+
+cChunkMap::cChunkLayer* cChunkMap::AddLayer( const cChunkLayer & a_Layer )
+{
+ cChunkLayer* TempLayers = new cChunkLayer[m_NumLayers+1];
+ if( m_NumLayers > 0 )
+ {
+ memcpy( TempLayers, m_Layers, sizeof( cChunkLayer ) * m_NumLayers );
+ delete [] m_Layers;
+ }
+ m_Layers = TempLayers;
+
+ m_Layers[m_NumLayers] = a_Layer;
+ cChunkLayer* NewLayer = &m_Layers[m_NumLayers];
+ m_NumLayers++;
+
+ return NewLayer;
+}
+
+void cChunkMap::AddChunk( cChunk* a_Chunk )
+{
+ /* // OLD
+ m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].push_back( a_Chunk );
+ */
+
+ // NEW
+ const int LayerX = (int)(floorf((float)a_Chunk->GetPosX() / (float)(LAYER_SIZE)));
+ const int LayerZ = (int)(floorf((float)a_Chunk->GetPosZ() / (float)(LAYER_SIZE)));
+ cChunkLayer* FoundLayer = GetLayer( LayerX, LayerZ );
+ if( !FoundLayer )
+ {
+ cChunkLayer NewLayer( LAYER_SIZE*LAYER_SIZE );
+ NewLayer.m_X = LayerX;
+ NewLayer.m_Z = LayerZ;
+ FoundLayer = AddLayer( NewLayer );
+ LOGWARN("Created new layer %i %i (total layers %i)", LayerX, LayerZ, m_NumLayers );
+ }
+
+ //Get local coordinates in layer
+ const int LocalX = a_Chunk->GetPosX() - LayerX * LAYER_SIZE;
+ const int LocalZ = a_Chunk->GetPosZ() - LayerZ * LAYER_SIZE;
+ if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk )
+ LOGWARN("WARNING: Added chunk to layer while it was already loaded!");
+ FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk = a_Chunk;
+ FoundLayer->m_NumChunksLoaded++;
+}
+
+void cChunkMap::RemoveChunk( cChunk* a_Chunk )
+{
+ /* // OLD
+ m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].erase( a_Chunk );
+ */
+
+ // NEW
+ cChunkLayer* Layer = GetLayerForChunk( a_Chunk->GetPosX(), a_Chunk->GetPosZ() );
+ if( Layer )
+ {
+ cChunkData* Data = Layer->GetChunk( a_Chunk->GetPosX(), a_Chunk->GetPosZ() );
+ if( Data->m_LiveChunk )
+ {
+ CompressChunk( Data );
+ Data->m_LiveChunk = 0; // Set live chunk to 0
+ }
+ Layer->m_NumChunksLoaded--;
+ }
+}
+
+void cChunkMap::CompressChunk( cChunkData* a_ChunkData )
+{
+ if( a_ChunkData->m_LiveChunk )
+ {
+ // Delete already present compressed data
+ if( a_ChunkData->m_Compressed ) delete [] a_ChunkData->m_Compressed;
+
+ // Get Json data
+ Json::Value root;
+ std::string JsonData = "";
+ a_ChunkData->m_LiveChunk->SaveToJson( root );
+ if( !root.empty() )
+ {
+ Json::StyledWriter writer; // TODO FIXME: change to FastWriter ? :D
+ JsonData = writer.write( root );
+ }
+
+ unsigned int TotalSize = cChunk::c_BlockDataSize + JsonData.size();
+ uLongf CompressedSize = compressBound( TotalSize );
+ a_ChunkData->m_Compressed = new char[CompressedSize];
+ char* DataSource = a_ChunkData->m_LiveChunk->pGetBlockData();
+ if( JsonData.size() > 0 )
+ {
+ // Move stuff around, so data is aligned in memory
+ DataSource = new char[TotalSize];
+ memcpy( DataSource, a_ChunkData->m_LiveChunk->pGetBlockData(), cChunk::c_BlockDataSize );
+ memcpy( DataSource + cChunk::c_BlockDataSize, JsonData.c_str(), JsonData.size() );
+ }
+
+ int errorcode = compress2( (Bytef*)a_ChunkData->m_Compressed, &CompressedSize, (const Bytef*)DataSource, TotalSize, Z_DEFAULT_COMPRESSION);
+ if( errorcode != Z_OK )
+ {
+ LOGERROR("Error compressing data (%i)", errorcode );
+ }
+
+ a_ChunkData->m_CompressedSize = CompressedSize;
+ a_ChunkData->m_UncompressedSize = TotalSize;
+
+ if( DataSource != a_ChunkData->m_LiveChunk->pGetBlockData() )
+ delete [] DataSource;
+ }
+}
+
+unsigned int cChunkMap::MakeHash( int a_X, int a_Z )
+{
+ const unsigned int HashX = abs( a_X ) % m_Width;
+ const unsigned int HashZ = abs( a_Z ) % m_Height;
+ return HashX + HashZ * m_Width;
+}
+
+cChunkMap::cChunkLayer* cChunkMap::GetLayerForChunk( int a_ChunkX, int a_ChunkZ )
+{
+ const int LayerX = (int)(floorf((float)a_ChunkX / (float)(LAYER_SIZE)));
+ const int LayerZ = (int)(floorf((float)a_ChunkZ / (float)(LAYER_SIZE)));
+ return GetLayer( LayerX, LayerZ );
+}
+
+cChunkMap::cChunkLayer* cChunkMap::GetLayer( int a_LayerX, int a_LayerZ )
+{
+ // Find layer in memory
+ for( int i = 0; i < m_NumLayers; ++i )
+ {
+ if( m_Layers[i].m_X == a_LayerX && m_Layers[i].m_Z == a_LayerZ )
+ {
+ return &m_Layers[i];
+ }
+ }
+
+ // Find layer on disk
+ cChunkLayer* Layer = LoadLayer( a_LayerX, a_LayerZ );
+ if( !Layer ) return 0;
+
+ cChunkLayer* NewLayer = AddLayer( *Layer );
+ delete Layer;
+ return NewLayer;
+}
+
+cChunk* cChunkMap::GetChunk( int a_X, int a_Y, int a_Z )
+{
+ /* // OLD
+ unsigned int Hash = MakeHash( a_X, a_Z );
+ cChunkNode & Node = m_Nodes[ Hash ];
+ cChunk** Chunks = Node.GetChunks();
+ for( unsigned int i = 0; i < Node.size(); ++i )
+ {
+ if( Chunks[i]->GetPosX() == a_X && // Check if we found the right chunk
+ Chunks[i]->GetPosY() == a_Y &&
+ Chunks[i]->GetPosZ() == a_Z )
+ {
+ return Chunks[i];
+ }
+ }
+ */
+
+ // NEW
+ cChunkLayer* Layer = GetLayerForChunk( a_X, a_Z );
+ if( Layer )
+ {
+ cChunkData* Data = Layer->GetChunk( a_X, a_Z );
+ if( Data->m_LiveChunk ) return Data->m_LiveChunk;
+
+ // Decompress cached chunk
+ if( Data->m_Compressed )
+ {
+ uLongf DestSize = Data->m_UncompressedSize;
+ char* BlockData = new char[ DestSize ];
+ int errorcode = uncompress( (Bytef*)BlockData, &DestSize, (Bytef*)Data->m_Compressed, Data->m_CompressedSize );
+ if( Data->m_UncompressedSize != DestSize )
+ {
+ LOGWARN("Lulwtf, expected uncompressed size differs!");
+ delete [] BlockData;
+ }
+ else if( errorcode != Z_OK )
+ {
+ LOGERROR("ERROR: Decompressing chunk data! %i", errorcode );
+ switch( errorcode )
+ {
+ case Z_MEM_ERROR:
+ LOGERROR("Not enough memory");
+ break;
+ case Z_BUF_ERROR:
+ LOGERROR("Not enough room in output buffer");
+ break;
+ case Z_DATA_ERROR:
+ LOGERROR("Input data corrupted or incomplete");
+ break;
+ default:
+ break;
+ };
+
+ delete [] BlockData;
+ }
+ else
+ {
+ cChunk* Chunk = new cChunk(a_X, a_Y, a_Z);
+ memcpy( Chunk->m_BlockData, BlockData, cChunk::c_BlockDataSize );
+ Chunk->CalculateHeightmap();
+ Data->m_LiveChunk = Chunk;
+ Layer->m_NumChunksLoaded++;
+
+ if( DestSize > cChunk::c_BlockDataSize ) // We gots some extra data :D
+ {
+ LOGINFO("Parsing trailing JSON");
+ Json::Value root; // will contains the root value after parsing.
+ Json::Reader reader;
+ if( !reader.parse( BlockData + cChunk::c_BlockDataSize, root, false ) )
+ {
+ LOGERROR("Failed to parse trailing JSON!");
+ }
+ else
+ {
+ //Json::StyledWriter writer;
+ //LOGINFO("Trailing Json:" );
+ //printf("%s", writer.write( root ).c_str() );
+ Chunk->LoadFromJson( root );
+ }
+ }
+
+ delete [] BlockData;
+ delete [] Data->m_Compressed; Data->m_Compressed = 0; Data->m_CompressedSize = 0;
+ return Chunk;
+ }
+
+
+ }
+ }
+
+ return 0;
+}
+
+void cChunkMap::Tick( float a_Dt )
+{
+ /* // OLD
+ for( int i = 0; i < m_Width*m_Height; ++i )
+ {
+ cChunkNode & Node = m_Nodes[ i ];
+ cChunk** Chunks = Node.GetChunks();
+ for( unsigned int i = 0; i < Node.size(); ++i )
+ {
+ Chunks[i]->Tick( a_Dt );
+ }
+ }
+ */
+
+ // NEW
+ for( int l = 0; l < m_NumLayers; ++l )
+ {
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
+ {
+ cChunk* Chunk = m_Layers[l].m_Chunks[i].m_LiveChunk;
+ if( Chunk )
+ Chunk->Tick( a_Dt );
+ }
+ }
+}
+
+void cChunkMap::UnloadUnusedChunks()
+{
+ cWorld* World = cRoot::Get()->GetWorld();
+ /* // OLD
+ for( int i = 0; i < m_Width*m_Height; ++i )
+ {
+ cChunkNode & Node = m_Nodes[ i ];
+ cChunk** Chunks = Node.GetChunks();
+ for( unsigned int i = 0; i < Node.size(); ++i )
+ {
+ if( Chunks[i]->GetClients().size() == 0 )
+ {
+ Chunks[i]->SaveToDisk();
+ LOG("Unloading %p", Chunks[i] );
+ World->RemoveSpread( Chunks[i] );
+ cChunk* TheChunk = Chunks[i];
+ RemoveChunk( TheChunk );
+ delete TheChunk;
+ //Node.erase( Chunks[i] );
+ Chunks = Node.GetChunks(); // Chunks pointer is no longer valid, get a new one
+ }
+ }
+ }
+ */
+
+ // NEW
+ for( int l = 0; l < m_NumLayers; ++l )
+ {
+ cChunkLayer & Layer = m_Layers[l];
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
+ {
+ cChunk* Chunk = Layer.m_Chunks[i].m_LiveChunk;
+ if( Chunk && Chunk->GetClients().size() == 0 )
+ {
+ Chunk->SaveToDisk();
+ World->RemoveSpread( Chunk );
+ RemoveChunk( Chunk );
+ delete Chunk;
+ }
+ }
+
+ // Unload layers
+ if( Layer.m_NumChunksLoaded == 0 )
+ {
+ SaveLayer( &Layer );
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i ) // Free all chunk data for layer
+ {
+ if( Layer.m_Chunks[i].m_Compressed )
+ delete [] Layer.m_Chunks[i].m_Compressed;
+ if( Layer.m_Chunks[i].m_LiveChunk )
+ delete Layer.m_Chunks[i].m_LiveChunk;
+ }
+ if( RemoveLayer( &Layer ) ) l--;
+ }
+ else if( Layer.m_NumChunksLoaded < 0 )
+ {
+ LOGERROR("WTF! Chunks loaded in layer is %i !!", Layer.m_NumChunksLoaded );
+ }
+ }
+}
+
+bool cChunkMap::RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
+{
+ /* // OLD
+ for( int i = 0; i < m_Width*m_Height; ++i )
+ {
+ cChunkNode & Node = m_Nodes[ i ];
+ cChunk** Chunks = Node.GetChunks();
+ for( unsigned int i = 0; i < Node.size(); ++i )
+ {
+ if( Chunks[i] != a_CalledFrom )
+ {
+ if( Chunks[i]->RemoveEntity( a_Entity, a_CalledFrom ) )
+ return true;
+ }
+ }
+ }
+ */
+
+ // NEW
+ for( int i = 0; i < m_NumLayers; ++i )
+ {
+ cChunkLayer & Layer = m_Layers[i];
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
+ {
+ cChunk* Chunk = Layer.m_Chunks[i].m_LiveChunk;
+ if( Chunk != a_CalledFrom )
+ {
+ if( Chunk && Chunk->RemoveEntity( a_Entity, a_CalledFrom ) )
+ return true;
+ }
+ }
+ }
+
+ LOG("WARNING: Entity was not found in any chunk!");
+ return false;
+}
+
+void cChunkMap::SaveAllChunks()
+{
+ for( int i = 0; i < m_Width*m_Height; ++i )
+ {
+ cChunkNode & Node = m_Nodes[ i ];
+ cChunk** Chunks = Node.GetChunks();
+ for( unsigned int i = 0; i < Node.size(); ++i )
+ {
+ Chunks[i]->SaveToDisk();
+ }
+ }
+
+ for( int i = 0; i < m_NumLayers; ++i )
+ {
+ SaveLayer( &m_Layers[i] );
+ }
+}
+
+
+
+/********************************
+ * Saving and loading
+ **/
+
+void cChunkMap::SaveLayer( cChunkLayer* a_Layer )
+{
+ cMakeDir::MakeDir("world");
+
+ char SourceFile[128];
+
+ #ifdef _WIN32
+ sprintf_s(SourceFile, 128, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
+ #else
+ sprintf(SourceFile, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
+ #endif
+
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "wb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "wb" )) != 0 ) // no error
+ #endif
+ {
+ //---------------
+ // Header
+ char PakVersion = 1;
+ char ChunkVersion = 1;
+ fwrite( &PakVersion, sizeof(PakVersion), 1, f ); // pak version
+ fwrite( &ChunkVersion, sizeof(ChunkVersion), 1, f ); // chunk version
+
+ // Count number of chunks in layer
+ short NumChunks = 0;
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
+ {
+ if( a_Layer->m_Chunks[i].m_Compressed || a_Layer->m_Chunks[i].m_LiveChunk )
+ NumChunks++;
+ }
+
+ fwrite( &NumChunks, sizeof( NumChunks ), 1, f );
+ LOG("Num Chunks in layer: %i", NumChunks );
+
+ //---------------
+ // Chunk headers
+ for( int z = 0; z < LAYER_SIZE; ++z )
+ {
+ for( int x = 0; x < LAYER_SIZE; ++x )
+ {
+ cChunkData & Data = a_Layer->m_Chunks[x + z*LAYER_SIZE];
+ CompressChunk( &Data );
+ if( Data.m_Compressed || Data.m_LiveChunk )
+ {
+ int ChunkX = a_Layer->m_X*LAYER_SIZE + x;
+ int ChunkZ = a_Layer->m_Z*LAYER_SIZE + z;
+ unsigned int Size = Data.m_CompressedSize; // Needs to be size of compressed data
+ unsigned int USize = Data.m_UncompressedSize; // Uncompressed size
+ fwrite( &ChunkX, sizeof( ChunkX ), 1, f );
+ fwrite( &ChunkZ, sizeof( ChunkZ ), 1, f );
+ fwrite( &Size, sizeof( Size ), 1, f );
+ fwrite( &USize, sizeof( USize ), 1, f );
+ }
+ }
+ }
+
+ //----------------
+ // Chunk data
+ for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
+ {
+ char* Compressed = a_Layer->m_Chunks[i].m_Compressed;
+ if( Compressed )
+ {
+ fwrite( Compressed, a_Layer->m_Chunks[i].m_CompressedSize, 1, f );
+ if(a_Layer->m_Chunks[i].m_LiveChunk) // If there's a live chunk we have no need for compressed data
+ {
+ delete [] a_Layer->m_Chunks[i].m_Compressed;
+ a_Layer->m_Chunks[i].m_Compressed = 0;
+ a_Layer->m_Chunks[i].m_CompressedSize = 0;
+ }
+ }
+ }
+
+
+ fclose(f);
+ }
+ else
+ {
+ LOGERROR("ERROR: Could not write to file %s", SourceFile );
+ }
+}
+
+cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
+{
+ char SourceFile[128];
+
+ #ifdef _WIN32
+ sprintf_s(SourceFile, 128, "world/X%i_Z%i.pak", a_LayerX, a_LayerZ );
+ #else
+ sprintf(SourceFile, "world/X%i_Z%i.pak", a_LayerX, a_LayerZ );
+ #endif
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "rb" )) != 0 ) // no error
+ #endif
+ {
+ char PakVersion = 0;
+ char ChunkVersion = 0;
+ if( fread( &PakVersion, sizeof(PakVersion), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( PakVersion != 1 ) { LOGERROR("WRONG PAK VERSION!"); fclose(f); return 0; }
+ if( fread( &ChunkVersion, sizeof(ChunkVersion), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( PakVersion != 1 ) { LOGERROR("WRONG CHUNK VERSION!"); fclose(f); return 0; }
+
+ short NumChunks = 0;
+ if( fread( &NumChunks, sizeof(NumChunks), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ LOG("Num chunks: %i", NumChunks );
+
+ cChunkLayer* Layer = new cChunkLayer( LAYER_SIZE*LAYER_SIZE );
+ Layer->m_X = a_LayerX;
+ Layer->m_Z = a_LayerZ;
+ cChunkData** OrderedData = new cChunkData*[ NumChunks ]; // So we can loop over the chunks in the order they were loaded
+ // Loop over all chunk headers
+ for( short i = 0; i < NumChunks; ++i )
+ {
+ int ChunkX = 0;
+ int ChunkZ = 0;
+ if( fread( &ChunkX, sizeof(ChunkX), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &ChunkZ, sizeof(ChunkZ), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ cChunkData* Data = Layer->GetChunk( ChunkX, ChunkZ );
+ if( Data )
+ {
+ if( fread( &Data->m_CompressedSize, sizeof(Data->m_CompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &Data->m_UncompressedSize, sizeof(Data->m_UncompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ }
+ else
+ {
+ LOGERROR("Chunk with wrong coordinates in pak file! %i %i", ChunkX, ChunkZ );
+ fclose(f);
+ return 0;
+ }
+
+ OrderedData[i] = Data;
+ }
+
+ // Loop over chunks again, in the order they were loaded, and load their compressed data
+ for( short i = 0; i < NumChunks; ++i )
+ {
+ cChunkData* Data = OrderedData[i];
+ Data->m_Compressed = new char[ Data->m_CompressedSize ];
+ if( fread( Data->m_Compressed, Data->m_CompressedSize, 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+
+ /* // Some testing...
+ uLongf DestSize = Data->m_UncompressedSize;
+ char* BlockData = new char[ DestSize ];
+ int errorcode = uncompress( (Bytef*)BlockData, &DestSize, (Bytef*)Data->m_Compressed, Data->m_CompressedSize );
+ if( errorcode != Z_OK )
+ {
+ LOGERROR("lulwut");
+ }
+ */
+ }
+ delete [] OrderedData;
+
+ fclose(f);
+ return Layer;
+ }
+ else
+ {
+ //LOGWARN("Could not open file %s", SourceFile );
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
new file mode 100644
index 000000000..57ad313dc
--- /dev/null
+++ b/source/cChunkMap.h
@@ -0,0 +1,91 @@
+#pragma once
+
+class cEntity;
+class cChunk;
+class cChunkMap
+{
+public:
+ cChunkMap( int a_Width, int a_Height );
+ ~cChunkMap();
+
+ void AddChunk( cChunk* a_Chunk );
+ unsigned int MakeHash( int a_X, int a_Z );
+
+ cChunk* GetChunk( int a_X, int a_Y, int a_Z );
+ void RemoveChunk( cChunk* a_Chunk );
+
+ void Tick( float a_Dt );
+
+ void UnloadUnusedChunks();
+ bool RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom = 0 );
+ void SaveAllChunks();
+private:
+ class cChunkData
+ {
+ public:
+ cChunkData()
+ : m_Compressed( 0 )
+ , m_LiveChunk( 0 )
+ , m_CompressedSize( 0 )
+ , m_UncompressedSize( 0 )
+ {}
+ char* m_Compressed;
+ unsigned int m_CompressedSize;
+ unsigned int m_UncompressedSize;
+ cChunk* m_LiveChunk;
+ };
+
+ class cChunkLayer
+ {
+ public:
+ cChunkLayer()
+ : m_Chunks( 0 )
+ , m_X( 0 )
+ , m_Z( 0 )
+ , m_NumChunksLoaded( 0 )
+ {}
+ cChunkLayer( int a_NumChunks )
+ : m_Chunks( new cChunkData[a_NumChunks] )
+ , m_X( 0 )
+ , m_Z( 0 )
+ , m_NumChunksLoaded( 0 )
+ {}
+ cChunkData* GetChunk( int a_X, int a_Z );
+ cChunkData* m_Chunks;
+ int m_X, m_Z;
+ int m_NumChunksLoaded;
+ };
+
+ void SaveLayer( cChunkLayer* a_Layer );
+ cChunkLayer* LoadLayer( int a_LayerX, int a_LayerZ );
+ cChunkLayer* GetLayerForChunk( int a_ChunkX, int a_ChunkZ );
+ cChunkLayer* GetLayer( int a_LayerX, int a_LayerZ );
+ cChunkLayer* AddLayer( const cChunkLayer & a_Layer );
+ bool RemoveLayer( cChunkLayer* a_Layer );
+ void CompressChunk( cChunkData* a_ChunkData );
+
+ int m_NumLayers;
+ cChunkLayer* m_Layers;
+
+ class cChunkNode
+ {
+ public:
+ cChunkNode();
+ ~cChunkNode();
+ void push_back( cChunk* a_Chunk );
+ unsigned int size() { return m_Size; }
+ unsigned int allocated() { return m_Allocated; }
+ void resize( unsigned int a_NewSize );
+
+ void erase( cChunk* a_Chunk );
+
+ cChunk** GetChunks() { return m_Chunks; }
+ private:
+ unsigned int m_Size;
+ unsigned int m_Allocated;
+ cChunk** m_Chunks;
+ };
+
+ cChunkNode* m_Nodes;
+ int m_Width, m_Height;
+}; \ No newline at end of file
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
new file mode 100644
index 000000000..f274795c1
--- /dev/null
+++ b/source/cClientHandle.cpp
@@ -0,0 +1,1082 @@
+#ifndef _WIN32
+#include <cstring>
+#include <semaphore.h>
+#include <errno.h>
+#endif
+
+#include "cClientHandle.h"
+#include "cServer.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cPickup.h"
+#include "cPluginManager.h"
+#include "cPlayer.h"
+#include "cInventory.h"
+#include "cChestEntity.h"
+#include "cSignEntity.h"
+#include "cMCLogger.h"
+#include "cWindow.h"
+#include "cCraftingWindow.h"
+#include "cItem.h"
+#include "cTorch.h"
+#include "cStairs.h"
+#include "cLadder.h"
+#include "cSign.h"
+#include "cBlockToPickup.h"
+#include "cMonster.h"
+#include "cChatColor.h"
+#include "cThread.h"
+#include "cSocket.h"
+
+#include "cTracer.h"
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "cCriticalSection.h"
+#include "cSemaphore.h"
+#include "cEvent.h"
+#include "cSleep.h"
+#include "cRoot.h"
+
+#include "cBlockingTCPLink.h"
+#include "cAuthenticator.h"
+
+#include "packets/cPacket_KeepAlive.h"
+#include "packets/cPacket_PlayerPosition.h"
+#include "packets/cPacket_Respawn.h"
+#include "packets/cPacket_UpdateHealth.h"
+#include "packets/cPacket_RelativeEntityMoveLook.h"
+#include "packets/cPacket_Chat.h"
+#include "packets/cPacket_Login.h"
+#include "packets/cPacket_WindowClick.h"
+#include "packets/cPacket_PlayerMoveLook.h"
+#include "packets/cPacket_TimeUpdate.h"
+#include "packets/cPacket_BlockDig.h"
+#include "packets/cPacket_Handshake.h"
+#include "packets/cPacket_PlayerLook.h"
+#include "packets/cPacket_ArmAnim.h"
+#include "packets/cPacket_BlockPlace.h"
+#include "packets/cPacket_Flying.h"
+#include "packets/cPacket_Disconnect.h"
+#include "packets/cPacket_PickupSpawn.h"
+#include "packets/cPacket_ItemSwitch.h"
+#include "packets/cPacket_EntityEquipment.h"
+#include "packets/cPacket_UseEntity.h"
+#include "packets/cPacket_WindowClose.h"
+#include "packets/cPacket_13.h"
+#include "packets/cPacket_UpdateSign.h"
+#include "packets/cPacket_Ping.h"
+
+
+#define MAX_SEMAPHORES (2000)
+
+typedef std::list<cPacket*> PacketList;
+
+struct cClientHandle::sClientHandleState
+{
+ sClientHandleState()
+ : ProtocolVersion( 0 )
+ , pReceiveThread( 0 )
+ , pSendThread( 0 )
+ , pAuthenticateThread( 0 )
+ , pSemaphore( 0 )
+ {
+ for( int i = 0; i < 256; ++i )
+ PacketMap[i] = 0;
+ }
+ int ProtocolVersion;
+ std::string Username;
+ std::string Password;
+
+ PacketList PendingParsePackets;
+ PacketList PendingNrmSendPackets;
+ PacketList PendingLowSendPackets;
+
+ cThread* pReceiveThread;
+ cThread* pSendThread;
+ cThread* pAuthenticateThread;
+
+ cSocket Socket;
+
+ cCriticalSection CriticalSection;
+ cCriticalSection SendCriticalSection;
+ cCriticalSection SocketCriticalSection;
+ cSemaphore* pSemaphore;
+
+ cPacket* PacketMap[256];
+};
+
+cClientHandle::cClientHandle(const cSocket & a_Socket)
+ : m_bDestroyed( false )
+ , m_Player( 0 )
+ , m_bKicking( false )
+ , m_TimeLastPacket( cWorld::GetTime() )
+ , m_bLoggedIn( false )
+ , m_bKeepThreadGoing( true )
+ , m_pState( new sClientHandleState )
+{
+ LOG("cClientHandle::cClientHandle");
+
+ m_pState->Socket = a_Socket;
+
+ m_pState->pSemaphore = new cSemaphore( MAX_SEMAPHORES, 0 );
+
+ // All the packets that can be received from the client
+ m_pState->PacketMap[E_KEEP_ALIVE] = new cPacket_KeepAlive;
+ m_pState->PacketMap[E_HANDSHAKE] = new cPacket_Handshake;
+ m_pState->PacketMap[E_LOGIN] = new cPacket_Login;
+ m_pState->PacketMap[E_PLAYERPOS] = new cPacket_PlayerPosition;
+ m_pState->PacketMap[E_PLAYERLOOK] = new cPacket_PlayerLook;
+ m_pState->PacketMap[E_PLAYERMOVELOOK] = new cPacket_PlayerMoveLook;
+ m_pState->PacketMap[E_CHAT] = new cPacket_Chat;
+ m_pState->PacketMap[E_ANIMATION] = new cPacket_ArmAnim;
+ m_pState->PacketMap[E_FLYING] = new cPacket_Flying;
+ m_pState->PacketMap[E_BLOCK_DIG] = new cPacket_BlockDig;
+ m_pState->PacketMap[E_BLOCK_PLACE] = new cPacket_BlockPlace;
+ m_pState->PacketMap[E_DISCONNECT] = new cPacket_Disconnect;
+ m_pState->PacketMap[E_ITEM_SWITCH] = new cPacket_ItemSwitch;
+ m_pState->PacketMap[E_ENTITY_EQUIPMENT] = new cPacket_EntityEquipment;
+ m_pState->PacketMap[E_PICKUP_SPAWN] = new cPacket_PickupSpawn;
+ m_pState->PacketMap[E_USE_ENTITY] = new cPacket_UseEntity;
+ m_pState->PacketMap[E_WINDOW_CLOSE] = new cPacket_WindowClose;
+ m_pState->PacketMap[E_WINDOW_CLICK] = new cPacket_WindowClick;
+ m_pState->PacketMap[E_PACKET_13] = new cPacket_13;
+ m_pState->PacketMap[E_UPDATE_SIGN] = new cPacket_UpdateSign;
+ m_pState->PacketMap[E_RESPAWN] = new cPacket_Respawn;
+ m_pState->PacketMap[E_PING] = new cPacket_Ping;
+
+ memset( m_LoadedChunks, 0x00, sizeof(cChunk*)*VIEWDISTANCE*VIEWDISTANCE );
+
+ //////////////////////////////////////////////////////////////////////////
+ m_pState->pReceiveThread = new cThread( ReceiveThread, this );
+ m_pState->pSendThread = new cThread( SendThread, this );
+ m_pState->pReceiveThread->Start( true );
+ m_pState->pSendThread->Start( true );
+ //////////////////////////////////////////////////////////////////////////
+
+ LOG("New ClientHandle" );
+}
+
+cClientHandle::~cClientHandle()
+{
+ LOG("Deleting client %s", GetUsername() );
+
+ for(unsigned int i = 0; i < VIEWDISTANCE*VIEWDISTANCE; i++)
+ {
+ if( m_LoadedChunks[i] ) m_LoadedChunks[i]->RemoveClient( this );
+ }
+
+ // First stop sending thread
+ m_bKeepThreadGoing = false;
+
+ m_pState->SocketCriticalSection.Lock();
+ if( m_pState->Socket )
+ {
+ cPacket_Disconnect Disconnect;
+ Disconnect.m_Reason = "Server shut down? Kthnxbai";
+ Disconnect.Send( m_pState->Socket );
+
+ closesocket( m_pState->Socket );
+ m_pState->Socket = 0;
+ }
+ m_pState->SocketCriticalSection.Unlock();
+
+ m_pState->pSemaphore->Signal();
+ delete m_pState->pAuthenticateThread;
+ delete m_pState->pReceiveThread;
+ delete m_pState->pSendThread;
+ delete m_pState->pSemaphore;
+
+ while( !m_pState->PendingParsePackets.empty() )
+ {
+ delete *m_pState->PendingParsePackets.begin();
+ m_pState->PendingParsePackets.erase( m_pState->PendingParsePackets.begin() );
+ }
+ while( !m_pState->PendingNrmSendPackets.empty() )
+ {
+ delete *m_pState->PendingNrmSendPackets.begin();
+ m_pState->PendingNrmSendPackets.erase( m_pState->PendingNrmSendPackets.begin() );
+ }
+ if(m_Player)
+ {
+ m_Player->SetClientHandle( 0 );
+ m_Player->Destroy();
+ m_Player = 0;
+ }
+ for(int i = 0; i < 256; i++)
+ {
+ if( m_pState->PacketMap[i] )
+ delete m_pState->PacketMap[i];
+ }
+
+ delete m_pState;
+}
+
+void cClientHandle::Destroy()
+{
+ m_bDestroyed = true;
+ m_pState->SocketCriticalSection.Lock();
+ if( m_pState->Socket )
+ {
+ closesocket( m_pState->Socket );
+ m_pState->Socket = 0;
+ }
+ m_pState->SocketCriticalSection.Unlock();
+}
+
+void cClientHandle::Kick( const char* a_Reason )
+{
+ Send( cPacket_Disconnect( a_Reason ) );
+ m_bKicking = true;
+}
+
+void cClientHandle::StreamChunks()
+{
+ if( !m_bLoggedIn )
+ return;
+ int ChunkPosX = (int)m_Player->GetPosX() / 16;
+ if( m_Player->GetPosX() < 0 ) ChunkPosX -= 1;
+ int ChunkPosZ = (int)m_Player->GetPosZ() / 16;
+ if( m_Player->GetPosZ() < 0 ) ChunkPosZ -= 1;
+
+ cChunk* NeededChunks[VIEWDISTANCE*VIEWDISTANCE];
+ for(int x = 0; x < VIEWDISTANCE; x++)
+ {
+ for(int z = 0; z < VIEWDISTANCE; z++)
+ {
+ NeededChunks[x + z*VIEWDISTANCE] = cRoot::Get()->GetWorld()->GetChunk( x + ChunkPosX-(VIEWDISTANCE-1)/2, 0, z + ChunkPosZ-(VIEWDISTANCE-1)/2 );
+ }
+ }
+
+ cChunk* MissingChunks[VIEWDISTANCE*VIEWDISTANCE];
+ memset( MissingChunks, 0, VIEWDISTANCE*VIEWDISTANCE*sizeof(cChunk*) );
+ unsigned int MissIndex = 0;
+ for(int i = 0; i < VIEWDISTANCE*VIEWDISTANCE; i++) // Handshake loop - touch each chunk once
+ {
+ bool bChunkMissing = true;
+ for(int j = 0; j < VIEWDISTANCE*VIEWDISTANCE; j++)
+ {
+ if( m_LoadedChunks[j] == NeededChunks[i] )
+ {
+ bChunkMissing = false;
+ break;
+ }
+ }
+ if(bChunkMissing)
+ {
+ MissingChunks[MissIndex] = NeededChunks[i];
+ MissIndex++;
+ }
+ }
+
+ if( MissIndex > 0 )
+ { // Chunks are gonna be streamed in, so chunks probably also need to be streamed out
+ for(int x = 0; x < VIEWDISTANCE; x++)
+ {
+ for(int z = 0; z < VIEWDISTANCE; z++)
+ {
+ cChunk* Chunk = m_LoadedChunks[x + z*VIEWDISTANCE];
+ if( Chunk )
+ {
+ if( Chunk->GetPosX() < ChunkPosX-(VIEWDISTANCE-1)/2
+ || Chunk->GetPosX() > ChunkPosX+(VIEWDISTANCE-1)/2
+ || Chunk->GetPosZ() < ChunkPosZ-(VIEWDISTANCE-1)/2
+ || Chunk->GetPosZ() > ChunkPosZ+(VIEWDISTANCE-1)/2 )
+ {
+ Chunk->RemoveClient( this );
+ Chunk->AsyncUnload( this );
+ }
+ }
+ }
+ }
+
+ StreamChunksSmart( MissingChunks, MissIndex );
+
+ memcpy( m_LoadedChunks, NeededChunks, VIEWDISTANCE*VIEWDISTANCE*sizeof(cChunk*) );
+ }
+}
+
+void cClientHandle::StreamChunksSmart( cChunk** a_Chunks, unsigned int a_NumChunks )
+{
+ int X = (int)m_Player->GetPosX() / 16;
+ int Y = (int)m_Player->GetPosY() / 128;
+ int Z = (int)m_Player->GetPosZ() / 16;
+
+ bool bAllDone = false;
+ while( !bAllDone )
+ {
+ bAllDone = true;
+ int ClosestIdx = -1;
+ unsigned int ClosestSqrDist = (unsigned int)-1; // wraps around, becomes biggest number possible
+ for(unsigned int i = 0; i < a_NumChunks; ++i)
+ {
+ if( a_Chunks[i] )
+ {
+ bAllDone = false;
+ int DistX = a_Chunks[i]->GetPosX()-X;
+ int DistY = a_Chunks[i]->GetPosY()-Y;
+ int DistZ = a_Chunks[i]->GetPosZ()-Z;
+ unsigned int SqrDist = (DistX*DistX)+(DistY*DistY)+(DistZ*DistZ);
+ if( SqrDist < ClosestSqrDist )
+ {
+ ClosestSqrDist = SqrDist;
+ ClosestIdx = i;
+ }
+ }
+ }
+ if(ClosestIdx > -1)
+ {
+ a_Chunks[ClosestIdx]->Send( this );
+ a_Chunks[ClosestIdx]->AddClient( this );
+ a_Chunks[ClosestIdx] = 0;
+ }
+ }
+}
+
+void cClientHandle::AddPacket(cPacket * a_Packet)
+{
+ m_pState->CriticalSection.Lock();
+ m_pState->PendingParsePackets.push_back( a_Packet->Clone() );
+ m_pState->CriticalSection.Unlock();
+}
+
+void cClientHandle::RemovePacket( cPacket * a_Packet )
+{
+ delete a_Packet;
+ m_pState->PendingParsePackets.remove( a_Packet );
+}
+
+void cClientHandle::HandlePendingPackets()
+{
+ m_pState->CriticalSection.Lock();
+ while( m_pState->PendingParsePackets.begin() != m_pState->PendingParsePackets.end() )
+ {
+ HandlePacket( *m_pState->PendingParsePackets.begin() );
+ RemovePacket( *m_pState->PendingParsePackets.begin() );
+ }
+ m_pState->CriticalSection.Unlock();
+}
+
+void cClientHandle::HandlePacket( cPacket* a_Packet )
+{
+ m_TimeLastPacket = cWorld::GetTime();
+
+// cPacket* CopiedPacket = a_Packet->Clone();
+// a_Packet = CopiedPacket;
+
+ //LOG("Packet: 0x%02x", a_Packet->m_PacketID );
+
+ if( m_bKicking ) return;
+
+ if(!m_bLoggedIn)
+ {
+ switch( a_Packet->m_PacketID )
+ {
+ case E_PING: // Somebody tries to retreive information about the server
+ {
+ LOGINFO("Got ping");
+ char NumPlayers[8];
+ sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers() );
+ std::string response = std::string("Should be able to connect now!" + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + "9001" );
+ Kick( response.c_str() );
+ }
+ break;
+ case E_HANDSHAKE:
+ {
+ cPacket_Handshake* PacketData = reinterpret_cast<cPacket_Handshake*>(a_Packet);
+ m_pState->Username = PacketData->m_Username;
+ LOG("HANDSHAKE %s", GetUsername() );
+ cPacket_Chat Connecting(m_pState->Username + " is connecting.");
+ cRoot::Get()->GetServer()->Broadcast( Connecting, this );
+
+ // Give a server handshake thingy back
+ cPacket_Handshake Handshake;
+ Handshake.m_Username = cRoot::Get()->GetServer()->GetServerID();//ServerID;//"2e66f1dc032ab5f0";
+ Send( Handshake );
+ }
+ break;
+ case E_LOGIN:
+ {
+ LOG("LOGIN %s", GetUsername() );
+ cPacket_Login* PacketData = reinterpret_cast<cPacket_Login*>(a_Packet);
+ if( m_pState->Username.compare( PacketData->m_Username ) != 0 )
+ {
+ Kick("Login Username does not match Handshake username!");
+ return;
+ }
+ //m_Password = PacketData->m_Password;
+
+ if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_LOGIN, 1, PacketData ) )
+ {
+ Destroy();
+ return;
+ }
+
+ if( m_pState->pAuthenticateThread ) delete m_pState->pAuthenticateThread;
+ m_pState->pAuthenticateThread = new cThread( AuthenticateThread, this );
+ m_pState->pAuthenticateThread->Start( true );
+ }
+ break;
+ case E_PLAYERMOVELOOK: // After this is received we're safe to send anything
+ {
+ if( !m_Player )
+ {
+ Kick("Received wrong packet! Check your login sequence!");
+ return;
+ }
+ if( !cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_JOIN, 1, m_Player ) )
+ {
+ // Broadcast that this player has joined the game! Yay~
+ cPacket_Chat Joined( m_pState->Username + " joined the game!");
+ cRoot::Get()->GetServer()->Broadcast( Joined, this );
+ }
+
+ // Now initialize player (adds to entity list etc.)
+ m_Player->Initialize();
+
+ // Broadcasts to all but this ( this is actually handled in cChunk.cpp, after entity is added to the chunk )
+ //m_Player->SpawnOn( 0 );
+
+ // Send all already connected players to new player
+ //cRoot::Get()->GetServer()->SendAllEntitiesTo( this );
+
+ // Then we can start doing more stuffs! :D
+ m_bLoggedIn = true;
+ LOG("%s completely logged in", GetUsername() );
+ StreamChunks();
+ }
+ break;
+ case E_KEEP_ALIVE:
+ break;
+ default:
+ {
+ LOG("INVALID RESPONSE FOR LOGIN: needed 0x%02x got 0x%02x", E_PLAYERMOVELOOK, a_Packet->m_PacketID );
+ Kick("INVALID RESPONSE FOR LOGIN: needed 0x0d!");
+ }
+ break;
+ }
+ }
+ else // m_bLoggedIn == true
+ {
+ switch( a_Packet->m_PacketID )
+ {
+ case E_PLAYERPOS:
+ {
+ cPacket_PlayerPosition* PacketData = reinterpret_cast<cPacket_PlayerPosition*>(a_Packet);
+ //LOG("recv player pos: %0.2f %0.2f %0.2f", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ m_Player->MoveTo( Vector3d( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ ) );
+ m_Player->SetStance( PacketData->m_Stance );
+ m_Player->SetTouchGround( PacketData->m_bFlying );
+ }
+ break;
+ case E_BLOCK_DIG:
+ {
+ cPacket_BlockDig* PacketData = reinterpret_cast<cPacket_BlockDig*>(a_Packet);
+ //LOG("OnBlockDig: %i %i %i Dir: %i Stat: %i", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction, PacketData->m_Status );
+ if( PacketData->m_Status == 0x04 ) // Drop block
+ {
+ m_Player->TossItem( false );
+ }
+ else
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
+ char MetaData = World->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
+ bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock];
+
+ cItem PickupItem;
+ if( bBroken ) // broken
+ {
+ ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
+ PickupItem.m_ItemID = PickupID;
+ PickupItem.m_ItemHealth = MetaData;
+ PickupItem.m_ItemCount = 1;
+ }
+ if(!cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_BLOCK_DIG, 2, PacketData, m_Player, &PickupItem ) )
+ {
+ if( bBroken ) // Block broken
+ {
+ if( cRoot::Get()->GetWorld()->DigBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PickupItem ) )
+ {
+ m_Player->GetInventory().GetEquippedItem().m_ItemHealth ++;
+ LOG("Health: %i", m_Player->GetInventory().GetEquippedItem().m_ItemHealth);
+ }
+ }
+ }
+ else
+ {
+ cRoot::Get()->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
+ }
+ }
+ }
+ break;
+ case E_BLOCK_PLACE:
+ {
+ cPacket_BlockPlace* PacketData = reinterpret_cast<cPacket_BlockPlace*>(a_Packet);
+ cItem & Equipped = m_Player->GetInventory().GetEquippedItem();
+ if( Equipped.m_ItemID != PacketData->m_ItemType ) // Not valid
+ {
+ LOGWARN("Player %s tried to place a block that was not selected! (could indicate bot)", GetUsername() );
+ break;
+ }
+
+ if(cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_BLOCK_PLACE, 2, PacketData, m_Player ) )
+ {
+ if( PacketData->m_Direction > -1 )
+ {
+ AddDirection( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction );
+ cRoot::Get()->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
+ }
+ break;
+ }
+
+ //LOG("%i %i %i %i %i %i", PacketData->m_Count, PacketData->m_Direction, PacketData->m_ItemType, PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+
+ //printf("Place Dir:%i %i %i %i : %i\n", PacketData->m_Direction, PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_ItemType);
+ // 'use' useable items instead of placing blocks
+ bool bPlaceBlock = true;
+ if( PacketData->m_Direction >= 0 )
+ {
+ ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)cRoot::Get()->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ switch( BlockID )
+ {
+ case E_BLOCK_WORKBENCH:
+ {
+ bPlaceBlock = false;
+ cWindow* Window = new cCraftingWindow( 0, true );
+ m_Player->OpenWindow( Window );
+ }
+ break;
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_CHEST:
+ {
+ bPlaceBlock = false;
+ cBlockEntity* BlockEntity = cRoot::Get()->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ if( BlockEntity )
+ {
+ BlockEntity->UsedBy( *m_Player );
+ }
+ }
+ break;
+ default:
+ break;
+ };
+ }
+
+ // Some checks to see if it's a placeable item :P
+ if( bPlaceBlock )
+ {
+ cItem Item;
+ Item.m_ItemID = Equipped.m_ItemID;
+ Item.m_ItemCount = 1;
+
+ // Hacked in edible items go!~
+ bool bEat = false;
+ switch( Item.m_ItemID )
+ {
+ case E_ITEM_APPLE:
+ m_Player->Heal( 4 ); // 2 hearts
+ bEat = true;
+ break;
+ case E_ITEM_GOLDEN_APPLE:
+ m_Player->Heal( 20 ); // 10 hearts
+ bEat = true;
+ break;
+ case E_ITEM_MUSHROOM_SOUP:
+ m_Player->Heal( 10 ); // 5 hearts
+ bEat = true;
+ break;
+ case E_ITEM_BREAD:
+ m_Player->Heal( 5 ); // 2.5 hearts
+ bEat = true;
+ break;
+ case E_ITEM_RAW_MEAT:
+ m_Player->Heal( 3 ); // 1.5 hearts
+ bEat = true;
+ break;
+ case E_ITEM_COOKED_MEAT:
+ m_Player->Heal( 8 ); // 4 hearts
+ bEat = true;
+ break;
+ case E_ITEM_RAW_FISH:
+ m_Player->Heal( 2 ); // 1 heart
+ bEat = true;
+ break;
+ case E_ITEM_COOKED_FISH:
+ m_Player->Heal( 5 ); // 2.5 hearts
+ bEat = true;
+ break;
+ default:
+ break;
+ };
+
+ if( bEat )
+ {
+ m_Player->GetInventory().RemoveItem( Item );
+ break;
+ }
+
+ if( PacketData->m_Direction < 0 ) // clicked in air
+ break;
+
+ char MetaData = (char)Equipped.m_ItemHealth;
+ switch( PacketData->m_ItemType ) // Special handling for special items
+ {
+ case E_BLOCK_TORCH:
+ MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction );
+ break;
+ case E_BLOCK_COBBLESTONE_STAIRS:
+ case E_BLOCK_WOODEN_STAIRS:
+ MetaData = cStairs::RotationToMetaData( m_Player->GetRotation() );
+ break;
+ case E_BLOCK_LADDER:
+ MetaData = cLadder::DirectionToMetaData( PacketData->m_Direction );
+ break;
+ case E_ITEM_SIGN:
+ LOG("Dir: %i", PacketData->m_Direction);
+ if( PacketData->m_Direction == 1 )
+ {
+ LOG("Player Rotation: %f", m_Player->GetRotation() );
+ MetaData = cSign::RotationToMetaData( m_Player->GetRotation() );
+ LOG("Sign rotation %i", MetaData);
+ PacketData->m_ItemType = E_BLOCK_SIGN_POST;
+ }
+ else
+ {
+ MetaData = cSign::DirectionToMetaData( PacketData->m_Direction );
+ PacketData->m_ItemType = E_BLOCK_WALLSIGN;
+ }
+ break;
+ default:
+ break;
+ };
+
+ if( IsValidBlock( PacketData->m_ItemType) )
+ {
+ if( m_Player->GetInventory().RemoveItem( Item ) )
+ {
+ int X = PacketData->m_PosX;
+ char Y = PacketData->m_PosY;
+ int Z = PacketData->m_PosZ;
+ AddDirection( X, Y, Z, PacketData->m_Direction );
+
+ cRoot::Get()->GetWorld()->SetBlock( X, Y, Z, (char)PacketData->m_ItemType, MetaData );
+ }
+ }
+ }
+ /*
+ // Remove stuff with stick! :D
+ if( m_Username.compare("FakeTruth") == 0 )
+ { // It's me! :D
+ if( PacketData->m_ItemType == 280 )
+ {
+ cRoot::Get()->GetWorld()->SetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, 0, 0 );
+ }
+ }
+ */
+ }
+ break;
+ case E_PICKUP_SPAWN:
+ {
+ LOG("Received packet E_PICKUP_SPAWN");
+ cPacket_PickupSpawn* PacketData = reinterpret_cast<cPacket_PickupSpawn*>(a_Packet);
+
+ cItem DroppedItem;
+ DroppedItem.m_ItemID = (ENUM_ITEM_ID)PacketData->m_Item;
+ DroppedItem.m_ItemCount = PacketData->m_Count;
+ DroppedItem.m_ItemHealth = 0x0; // TODO: Somehow figure out what item was dropped, and apply correct health
+ if( m_Player->GetInventory().RemoveItem( DroppedItem ) )
+ {
+ cPickup* Pickup = new cPickup( PacketData );
+ Pickup->Initialize();
+ }
+ }
+ break;
+ case E_CHAT:
+ {
+ cPacket_Chat* PacketData = reinterpret_cast<cPacket_Chat*>(a_Packet);
+ if( !cRoot::Get()->GetServer()->Command( *this, PacketData->m_Message.c_str() ) )
+ {
+ PacketData->m_Message.insert( 0, "<"+m_Player->GetColor() + m_pState->Username + cChatColor::White + "> " );
+ cRoot::Get()->GetServer()->Broadcast( *PacketData );
+ }
+ }
+ break;
+ case E_PLAYERLOOK:
+ {
+ cPacket_PlayerLook* PacketData = reinterpret_cast<cPacket_PlayerLook*>(a_Packet);
+ m_Player->SetRotation( PacketData->m_Rotation );
+ m_Player->SetPitch( PacketData->m_Pitch );
+ m_Player->SetTouchGround( PacketData->m_bFlying );
+ m_Player->WrapRotation();
+ }
+ break;
+ case E_PLAYERMOVELOOK:
+ {
+ cPacket_PlayerMoveLook* PacketData = reinterpret_cast<cPacket_PlayerMoveLook*>(a_Packet);
+ m_Player->MoveTo( Vector3d( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ ) );
+ m_Player->SetStance( PacketData->m_Stance );
+ m_Player->SetTouchGround( PacketData->m_bFlying );
+ m_Player->SetRotation( PacketData->m_Rotation );
+ m_Player->SetPitch( PacketData->m_Pitch );
+ m_Player->WrapRotation();
+ }
+ break;
+ case E_ANIMATION:
+ {
+ cPacket_ArmAnim* PacketData = reinterpret_cast<cPacket_ArmAnim*>(a_Packet);
+ PacketData->m_EntityID = m_Player->GetUniqueID();
+ cRoot::Get()->GetServer()->Broadcast( *PacketData, this );
+ }
+ break;
+ case E_ITEM_SWITCH:
+ {
+ cPacket_ItemSwitch* PacketData = reinterpret_cast<cPacket_ItemSwitch*>(a_Packet);
+
+ m_Player->GetInventory().SetEquippedSlot( PacketData->m_SlotNum );
+
+ cPacket_EntityEquipment Equipment;
+ Equipment.m_ItemID = (short)m_Player->GetInventory().GetEquippedItem().m_ItemID;
+ Equipment.m_Slot = 0;
+ Equipment.m_UniqueID = m_Player->GetUniqueID();
+ cRoot::Get()->GetServer()->Broadcast( Equipment, this );
+ }
+ break;
+ case E_WINDOW_CLOSE:
+ {
+ cPacket_WindowClose* PacketData = reinterpret_cast<cPacket_WindowClose*>(a_Packet);
+ if( PacketData->m_Close > 0 ) // Don't care about closing inventory
+ {
+ m_Player->CloseWindow();
+ }
+ }
+ break;
+ case E_WINDOW_CLICK:
+ {
+ cPacket_WindowClick* PacketData = reinterpret_cast<cPacket_WindowClick*>(a_Packet);
+ if( PacketData->m_WindowID == 0 )
+ {
+ m_Player->GetInventory().Clicked( PacketData );
+ }
+ else
+ {
+ cWindow* Window = m_Player->GetWindow();
+ if( Window ) Window->Clicked( PacketData, *m_Player );
+ else LOG("No 'other' window! WTF");
+ }
+ }
+ break;
+ case E_UPDATE_SIGN:
+ {
+ cPacket_UpdateSign* PacketData = reinterpret_cast<cPacket_UpdateSign*>(a_Packet);
+ cWorld* World = cRoot::Get()->GetWorld();
+ cChunk* Chunk = World->GetChunkOfBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ cBlockEntity* BlockEntity = Chunk->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ if( BlockEntity && (BlockEntity->GetBlockType() == E_BLOCK_SIGN_POST || BlockEntity->GetBlockType() == E_BLOCK_WALLSIGN ) )
+ {
+ cSignEntity* Sign = reinterpret_cast< cSignEntity* >(BlockEntity);
+ Sign->SetLines( PacketData->m_Line1, PacketData->m_Line2, PacketData->m_Line3, PacketData->m_Line4 );
+ Sign->SendTo( 0 ); // Broadcast to all players in chunk
+ }
+ }
+ break;
+ case E_USE_ENTITY:
+ {
+ cPacket_UseEntity* PacketData = reinterpret_cast<cPacket_UseEntity*>(a_Packet);
+ if( PacketData->m_bLeftClick )
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ cEntity* Entity = World->GetEntity( PacketData->m_TargetID );
+ if( Entity && Entity->IsA("cPawn") )
+ {
+ cPawn* Pawn = (cPawn*)Entity;
+ Pawn->TakeDamage( 1, m_Player );
+ }
+ }
+ }
+ break;
+ case E_RESPAWN:
+ {
+ m_Player->Respawn();
+ }
+ break;
+ case E_DISCONNECT:
+ {
+ LOG("Received d/c packet from %s", GetUsername() );
+ cPacket_Disconnect* PacketData = reinterpret_cast<cPacket_Disconnect*>(a_Packet);
+ if( !cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_DISCONNECT, 2, PacketData->m_Reason.c_str(), m_Player ) )
+ {
+ cPacket_Chat DisconnectMessage( m_pState->Username + " disconnected: " + PacketData->m_Reason );
+ cRoot::Get()->GetServer()->Broadcast( DisconnectMessage );
+ }
+ Destroy();
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void cClientHandle::AuthenticateThread( void* a_Param )
+{
+ cClientHandle* self = (cClientHandle*)a_Param;
+
+ cAuthenticator Authenticator;
+ if( !Authenticator.Authenticate( self->GetUsername(), cRoot::Get()->GetServer()->GetServerID() ) )
+ {
+ self->Kick("You could not be authenticated, sorry buddy!");
+ return;
+ }
+
+ self->SendLoginResponse();
+}
+
+void cClientHandle::SendLoginResponse()
+{
+ cWorld* World = cRoot::Get()->GetWorld();
+ World->LockEntities();
+ // Spawn player (only serversided, so data is loaded)
+ m_Player = new cPlayer( this, GetUsername() ); // !!DO NOT INITIALIZE!! <- is done after receiving MoveLook Packet
+
+ cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player );
+
+ // Return a server login packet
+ cPacket_Login LoginResponse;
+ LoginResponse.m_ProtocolVersion = m_Player->GetUniqueID();
+ //LoginResponse.m_Username = "";
+ LoginResponse.m_MapSeed = 0;
+ LoginResponse.m_Dimension = 0;
+ Send( LoginResponse );
+
+ // Send position
+ Send( cPacket_PlayerMoveLook( m_Player ) );
+
+ // Send time
+ Send( cPacket_TimeUpdate( (cRoot::Get()->GetWorld()->GetWorldTime() ) ) );
+
+ // Send inventory
+ m_Player->GetInventory().SendWholeInventory( this );
+
+ // Send health
+ Send( cPacket_UpdateHealth( (short)m_Player->GetHealth() ) );
+ World->UnlockEntities();
+}
+
+void cClientHandle::Tick(float a_Dt)
+{
+ (void)a_Dt;
+ if( cWorld::GetTime() - m_TimeLastPacket > 30.f ) // 30 seconds time-out
+ {
+ cPacket_Disconnect DC("Nooooo!! You timed out! D: Come back!");
+ DC.Send( m_pState->Socket );
+
+ cSleep::MilliSleep( 1000 ); // Give packet some time to be received
+
+ Destroy();
+ }
+}
+
+void cClientHandle::Send( const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* = E_PRIORITY_NORMAL */ )
+{
+ if( m_bKicking ) return; // Don't add more packets if player is getting kicked anyway
+
+ bool bSignalSemaphore = true;
+ m_pState->SendCriticalSection.Lock();
+ if( a_Priority == E_PRIORITY_NORMAL )
+ {
+ if( a_Packet.m_PacketID == E_REL_ENT_MOVE_LOOK )
+ {
+ PacketList & Packets = m_pState->PendingNrmSendPackets;
+ for( std::list<cPacket*>::iterator itr = Packets.begin(); itr != Packets.end(); ++itr )
+ {
+ bool bBreak = false;
+ switch( (*itr)->m_PacketID )
+ {
+ case E_REL_ENT_MOVE_LOOK:
+ {
+ const cPacket_RelativeEntityMoveLook* ThisPacketData = reinterpret_cast< const cPacket_RelativeEntityMoveLook* >(&a_Packet);
+ cPacket_RelativeEntityMoveLook* PacketData = reinterpret_cast< cPacket_RelativeEntityMoveLook* >(*itr);
+ if( ThisPacketData->m_UniqueID == PacketData->m_UniqueID )
+ {
+ //LOGINFO("Optimized by removing double packet");
+ Packets.erase( itr );
+ bBreak = true;
+ bSignalSemaphore = false; // Because 1 packet is removed, semaphore count is the same
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if( bBreak )
+ break;
+ }
+ }
+ m_pState->PendingNrmSendPackets.push_back( a_Packet.Clone() );
+ }
+ else if( a_Priority == E_PRIORITY_LOW ) m_pState->PendingLowSendPackets.push_back( a_Packet.Clone() );
+ m_pState->SendCriticalSection.Unlock();
+ if( bSignalSemaphore )
+ m_pState->pSemaphore->Signal();
+}
+
+void cClientHandle::SendThread( void *lpParam )
+{
+ cClientHandle* self = (cClientHandle*)lpParam;
+ sClientHandleState* m_pState = self->m_pState;
+ PacketList & NrmSendPackets = m_pState->PendingNrmSendPackets;
+ PacketList & LowSendPackets = m_pState->PendingLowSendPackets;
+
+
+ while( self->m_bKeepThreadGoing && m_pState->Socket )
+ {
+ m_pState->pSemaphore->Wait();
+ m_pState->SendCriticalSection.Lock();
+ //LOG("Pending packets: %i", m_PendingPackets.size() );
+ if( NrmSendPackets.size() + LowSendPackets.size() > MAX_SEMAPHORES )
+ {
+ LOGERROR("ERROR: Too many packets in queue for player %s !!", self->GetUsername() );
+ cPacket_Disconnect DC("Too many packets in queue.");
+ DC.Send( m_pState->Socket );
+
+ cSleep::MilliSleep( 1000 ); // Give packet some time to be received
+
+ self->Destroy();
+ m_pState->SendCriticalSection.Unlock();
+ break;
+ }
+ if( NrmSendPackets.size() == 0 && LowSendPackets.size() == 0 )
+ {
+ if( self->m_bKeepThreadGoing ) LOGERROR("ERROR: Semaphore was signaled while PendingSendPackets.size == 0");
+ m_pState->SendCriticalSection.Unlock();
+ continue;
+ }
+ if( NrmSendPackets.size() > MAX_SEMAPHORES/2 )
+ {
+ LOGINFO("Pending packets: %i Last: 0x%02x", NrmSendPackets.size(), (*NrmSendPackets.rbegin())->m_PacketID );
+ }
+
+ cPacket* Packet = 0;
+ if( NrmSendPackets.size() > 0 )
+ {
+ Packet = *NrmSendPackets.begin();
+ NrmSendPackets.erase( NrmSendPackets.begin() );
+ }
+ else if( LowSendPackets.size() > 0 )
+ {
+ Packet = *LowSendPackets.begin();
+ LowSendPackets.erase( LowSendPackets.begin() );
+ }
+ m_pState->SendCriticalSection.Unlock();
+
+ m_pState->SocketCriticalSection.Lock();
+ if( !m_pState->Socket )
+ {
+ m_pState->SocketCriticalSection.Unlock();
+ break;
+ }
+ bool bSuccess = Packet->Send( m_pState->Socket );
+ m_pState->SocketCriticalSection.Unlock();
+ if( !bSuccess )
+ {
+ LOGERROR("ERROR: While sending packet 0x%02x", Packet->m_PacketID );
+ delete Packet;
+ self->Destroy();
+ break;
+ }
+ delete Packet;
+
+ if( self->m_bKicking && (NrmSendPackets.size() + LowSendPackets.size() == 0) ) // Disconnect player after all packets have been sent
+ {
+ cSleep::MilliSleep( 1000 ); // Give all packets some time to be received
+ self->Destroy();
+ break;
+ }
+ }
+
+ return;
+}
+
+
+extern std::string GetWSAError();
+
+void cClientHandle::ReceiveThread( void *lpParam )
+{
+ LOG("ReceiveThread");
+
+ cClientHandle* self = (cClientHandle*)lpParam;
+
+
+ char temp = 0;
+ int iStat = 0;
+
+ cSocket socket = self->GetSocket();
+
+ while( self->m_bKeepThreadGoing )
+ {
+ iStat = recv(socket, &temp, 1, 0);
+ if( cSocket::IsSocketError(iStat) || iStat == 0 )
+ {
+ LOG("CLIENT DISCONNECTED (%i bytes):%s", iStat, GetWSAError().c_str() );
+ break;
+ }
+ else
+ {
+ cPacket* pPacket = self->m_pState->PacketMap[ (unsigned char)temp ];
+ if( pPacket )
+ {
+ if( pPacket->Parse( socket ) )
+ {
+ self->AddPacket( pPacket );
+ //self->HandlePendingPackets();
+ }
+ else
+ {
+#ifndef _WIN32
+ LOGERROR("Something went wrong during PacketID 0x%02x (%i)", temp, errno );
+#else
+ LOGERROR("Something went wrong during PacketID 0x%02x (%s)", temp, GetWSAError().c_str() );
+#endif
+ LOG("CLIENT %s DISCONNECTED", self->GetUsername() );
+ break;
+ }
+ }
+ else
+ {
+ LOG("Unknown packet: 0x%2x %c %i", (unsigned char)temp, (unsigned char)temp, (unsigned char)temp );
+
+
+ char c_Str[128];
+#ifdef _WIN32
+ sprintf_s( c_Str, "[C->S] Unknown PacketID: 0x%2x", (unsigned char)temp );
+#else
+ sprintf( c_Str, "[C->S] Unknown PacketID: 0x%2x", (unsigned char)temp );
+#endif
+ cPacket_Disconnect DC(c_Str);
+ DC.Send( socket );
+
+ cSleep::MilliSleep( 1000 ); // Give packet some time to be received
+ break;
+ }
+ }
+ }
+
+ self->Destroy();
+
+ LOG("ReceiveThread STOPPED");
+ return;
+}
+
+
+const char* cClientHandle::GetUsername()
+{
+ return m_pState->Username.c_str();
+}
+
+const cSocket & cClientHandle::GetSocket()
+{
+ return m_pState->Socket;
+} \ No newline at end of file
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
new file mode 100644
index 000000000..224ba46b3
--- /dev/null
+++ b/source/cClientHandle.h
@@ -0,0 +1,70 @@
+#pragma once
+
+class cSocket;
+class cSemaphore;
+class cEvent;
+class Game;
+class cPacket;
+class cChunk;
+class cPlayer;
+class cClientHandle // tolua_export
+{ // tolua_export
+public:
+ enum ENUM_PRIORITY
+ {
+ E_PRIORITY_LOW,
+ E_PRIORITY_NORMAL
+ };
+
+ cClientHandle(const cSocket & a_Socket);
+ ~cClientHandle();
+
+ static const int VIEWDISTANCE = 13;
+
+ const cSocket & GetSocket();
+ cPlayer* GetPlayer() { return m_Player; } // tolua_export
+
+ void Kick( const char* a_Reason ); //tolua_export
+
+ void AddPacket( cPacket * a_Packet );
+ void HandlePendingPackets();
+
+ void StreamChunks();
+ void StreamChunksSmart( cChunk** a_Chunks, unsigned int a_NumChunks );
+
+ inline void SetLoggedIn( bool a_bLoggedIn ) { m_bLoggedIn = a_bLoggedIn; }
+ inline bool IsLoggedIn() { return m_bLoggedIn; }
+
+ void Tick(float a_Dt);
+
+ bool IsDestroyed() { return m_bDestroyed; }
+ void Destroy();
+
+ cChunk* m_LoadedChunks[VIEWDISTANCE*VIEWDISTANCE];
+
+ void Send( const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL );
+
+ static void SendThread( void *lpParam );
+ static void ReceiveThread( void *lpParam );
+ static void AuthenticateThread( void* a_Param );
+
+ const char* GetUsername();
+private:
+ void HandlePacket( cPacket* a_Packet );
+ void RemovePacket( cPacket * a_Packet );
+
+ void SendLoginResponse();
+
+ struct sClientHandleState;
+ sClientHandleState* m_pState;
+
+ bool m_bDestroyed;
+ cPlayer* m_Player;
+ bool m_bKicking;
+
+ float m_TimeLastPacket;
+
+ bool m_bLoggedIn;
+
+ bool m_bKeepThreadGoing;
+}; // tolua_export
diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp
new file mode 100644
index 000000000..be3de600b
--- /dev/null
+++ b/source/cCraftingWindow.cpp
@@ -0,0 +1,103 @@
+#include "cCraftingWindow.h"
+#include "cItem.h"
+#include "cMCLogger.h"
+#include "cRecipeChecker.h"
+#include "cPlayer.h"
+#include "cClientHandle.h"
+#include "cInventory.h"
+#include "cPickup.h"
+#include "cRoot.h"
+
+#include "packets/cPacket_WindowClick.h"
+#include "packets/cPacket_InventorySlot.h"
+
+cCraftingWindow::cCraftingWindow( cWindowOwner* a_Owner, bool a_bInventoryVisible )
+ : cWindow( a_Owner, a_bInventoryVisible )
+{
+ SetWindowID( 1 );
+ SetWindowType( 1 ); // Workbench
+
+ cItem* Slots = new cItem[10];
+ SetSlots( Slots, 10 );
+}
+
+void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
+{
+ bool bDontCook = false;
+ // Override for craft result slot
+ if( a_ClickPacket->m_SlotNum == 0 )
+ {
+ LOG("In craft slot: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
+ cItem* DraggingItem = GetDraggingItem( &a_Player );
+ if( DraggingItem->m_ItemID <= 0 )
+ {
+ *DraggingItem = *GetSlot(0);
+ GetSlot(0)->Empty();
+ }
+ else if( DraggingItem->Equals( *GetSlot(0) ) )
+ {
+ if( DraggingItem->m_ItemCount + GetSlot(0)->m_ItemCount <= 64 )
+ {
+ DraggingItem->m_ItemCount += GetSlot(0)->m_ItemCount;
+ GetSlot(0)->Empty();
+ }
+ else
+ {
+ bDontCook = true;
+ }
+ }
+ else
+ {
+ bDontCook = true;
+ }
+ LOG("Dragging Dish %i", DraggingItem->m_ItemCount );
+ }
+ else
+ {
+ cWindow::Clicked( a_ClickPacket, a_Player );
+ }
+
+ if( a_ClickPacket->m_SlotNum >= 0 && a_ClickPacket->m_SlotNum < 10 )
+ {
+ cItem CookedItem;
+ if( a_ClickPacket->m_SlotNum == 0 && !bDontCook )
+ {
+ CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3, true );
+ }
+ else
+ {
+ CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3 );
+ }
+ *GetSlot(0) = CookedItem;
+ LOG("You cooked: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
+ }
+ SendWholeWindow( a_Player.GetClientHandle() );
+ a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() );
+ // Separate packet for result =/ Don't know why
+ cPacket_InventorySlot Packet;
+ Packet.m_WindowID = (char)GetWindowID();
+ Packet.m_SlotNum = 0;
+ Packet.m_ItemID = (short)GetSlot(0)->m_ItemID;
+ Packet.m_ItemCount = GetSlot(0)->m_ItemCount;
+ Packet.m_ItemUses = (char)GetSlot(0)->m_ItemHealth;
+ a_Player.GetClientHandle()->Send( Packet );
+}
+
+void cCraftingWindow::Close( cPlayer & a_Player )
+{
+ // Start from slot 1, don't drop what's in the result slot
+ for( int i = 1; i < GetNumSlots(); i++ )
+ {
+ cItem* Item = GetSlot( i );
+ if( Item->m_ItemID > 0 && Item->m_ItemCount > 0 )
+ {
+ float vX = 0, vY = 0, vZ = 0;
+ EulerToVector( -a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY );
+ vY = -vY*2 + 1.f;
+ cPickup* Pickup = new cPickup( (int)(a_Player.GetPosX()*32), (int)(a_Player.GetPosY()*32) + (int)(1.6f*32), (int)(a_Player.GetPosZ()*32), *Item, vX*2, vY*2, vZ*2 );
+ Pickup->Initialize();
+ }
+ Item->Empty();
+ }
+ cWindow::Close( a_Player );
+} \ No newline at end of file
diff --git a/source/cCraftingWindow.h b/source/cCraftingWindow.h
new file mode 100644
index 000000000..df32bf74a
--- /dev/null
+++ b/source/cCraftingWindow.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "cWindow.h"
+
+class cWindowOwner;
+class cCraftingWindow : public cWindow
+{
+public:
+ cCraftingWindow( cWindowOwner* a_Owner, bool a_bInventoryVisible );
+
+ virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player );
+ virtual void Close( cPlayer & a_Player );
+}; \ No newline at end of file
diff --git a/source/cCriticalSection.cpp b/source/cCriticalSection.cpp
new file mode 100644
index 000000000..85f89c195
--- /dev/null
+++ b/source/cCriticalSection.cpp
@@ -0,0 +1,60 @@
+#include "cCriticalSection.h"
+#include "cMCLogger.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <pthread.h>
+#endif
+
+cCriticalSection::cCriticalSection()
+{
+#ifdef _WIN32
+ m_CriticalSectionPtr = new CRITICAL_SECTION;
+ InitializeCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+#else
+ m_Attributes = new pthread_mutexattr_t;
+ pthread_mutexattr_init((pthread_mutexattr_t*)m_Attributes);
+ pthread_mutexattr_settype((pthread_mutexattr_t*)m_Attributes, PTHREAD_MUTEX_RECURSIVE);
+
+ m_CriticalSectionPtr = new pthread_mutex_t;
+ if( pthread_mutex_init( (pthread_mutex_t*)m_CriticalSectionPtr, (pthread_mutexattr_t*)m_Attributes ) != 0 )
+ {
+ LOG("ERROR: Could not initialize Critical Section!");
+ }
+#endif
+}
+
+cCriticalSection::~cCriticalSection()
+{
+#ifdef _WIN32
+ DeleteCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+ delete (CRITICAL_SECTION*)m_CriticalSectionPtr;
+#else
+ if( pthread_mutex_destroy( (pthread_mutex_t*)m_CriticalSectionPtr ) != 0 )
+ {
+ LOG("ERROR: Could not destroy Critical Section!");
+ }
+ delete (pthread_mutex_t*)m_CriticalSectionPtr;
+ pthread_mutexattr_destroy( (pthread_mutexattr_t*)m_Attributes );
+ delete (pthread_mutexattr_t*)m_Attributes;
+#endif
+}
+
+void cCriticalSection::Lock()
+{
+#ifdef _WIN32
+ EnterCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+#else
+ pthread_mutex_lock( (pthread_mutex_t*)m_CriticalSectionPtr );
+#endif
+}
+
+void cCriticalSection::Unlock()
+{
+#ifdef _WIN32
+ LeaveCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+#else
+ pthread_mutex_unlock( (pthread_mutex_t*)m_CriticalSectionPtr );
+#endif
+}
diff --git a/source/cCriticalSection.h b/source/cCriticalSection.h
new file mode 100644
index 000000000..fd1d34e46
--- /dev/null
+++ b/source/cCriticalSection.h
@@ -0,0 +1,16 @@
+#pragma once
+
+class cCriticalSection
+{
+public:
+ cCriticalSection();
+ ~cCriticalSection();
+
+ void Lock();
+ void Unlock();
+private:
+ void* m_CriticalSectionPtr; // Pointer to a CRITICAL_SECTION object
+#ifndef _WIN32
+ void* m_Attributes;
+#endif
+}; \ No newline at end of file
diff --git a/source/cCuboid.cpp b/source/cCuboid.cpp
new file mode 100644
index 000000000..9f102129c
--- /dev/null
+++ b/source/cCuboid.cpp
@@ -0,0 +1,10 @@
+#include "cCuboid.h"
+
+#include <algorithm> // swap
+
+void cCuboid::Sort()
+{
+ if( p1.x > p2.x ) std::swap( p1.x, p2.x );
+ if( p1.y > p2.y ) std::swap( p1.y, p2.y );
+ if( p1.z > p2.z ) std::swap( p1.z, p2.z );
+} \ No newline at end of file
diff --git a/source/cCuboid.h b/source/cCuboid.h
new file mode 100644
index 000000000..28e222e41
--- /dev/null
+++ b/source/cCuboid.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "Vector3i.h"
+#include "Vector3d.h"
+
+class cCuboid //tolua_export
+{ //tolua_export
+public: //tolua_export
+ cCuboid() {} //tolua_export
+ cCuboid( const cCuboid & a_Cuboid ) : p1( a_Cuboid.p1 ), p2( a_Cuboid.p2 ) {} //tolua_export
+ cCuboid( const Vector3i & a_p1, const Vector3i & a_p2 ) : p1( a_p1 ), p2( a_p2 ) {} //tolua_export
+
+
+ Vector3i p1, p2; //tolua_export
+
+ void Sort(); //tolua_export
+
+ bool IsInside( const Vector3i & v ) const //tolua_export
+ { //tolua_export
+ if( v.x >= p1.x && v.x <= p2.x
+ && v.y >= p1.y && v.y <= p2.y
+ && v.z >= p1.z && v.z <= p2.z )
+ {
+ return true;
+ }
+ return false;
+ } //tolua_export
+
+ bool IsInside( const Vector3d & v ) const //tolua_export
+ { //tolua_export
+ if( v.x >= p1.x && v.x <= p2.x
+ && v.y >= p1.y && v.y <= p2.y
+ && v.z >= p1.z && v.z <= p2.z )
+ {
+ return true;
+ }
+ return false;
+ } //tolua_export
+
+}; //tolua_export \ No newline at end of file
diff --git a/source/cEntity.cpp b/source/cEntity.cpp
new file mode 100644
index 000000000..3b62bec9c
--- /dev/null
+++ b/source/cEntity.cpp
@@ -0,0 +1,283 @@
+#include "cEntity.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cMCLogger.h"
+#include "cServer.h"
+#include "cRoot.h"
+#include "Vector3d.h"
+#include "Vector3f.h"
+#include "Matrix4f.h"
+#include "cReferenceManager.h"
+#include "cClientHandle.h"
+
+#include "packets/cPacket_DestroyEntity.h"
+
+int cEntity::m_EntityCount = 0;
+
+cEntity::cEntity(const double & a_X, const double & a_Y, const double & a_Z)
+ : m_UniqueID( 0 )
+ , m_Referencers( new cReferenceManager( cReferenceManager::RFMNGR_REFERENCERS ) )
+ , m_References( new cReferenceManager( cReferenceManager::RFMNGR_REFERENCES ) )
+ , m_ChunkX( 0 )
+ , m_ChunkY( 0 )
+ , m_ChunkZ( 0 )
+ , m_Pos( new Vector3d( a_X, a_Y, a_Z ) )
+ , m_bDirtyPosition( true )
+ , m_Rot( new Vector3f() )
+ , m_bDirtyOrientation( true )
+ , m_bDestroyed( false )
+ , m_EntityType( E_ENTITY )
+{
+ m_EntityCount++;
+ m_UniqueID = m_EntityCount;
+}
+
+cEntity::~cEntity()
+{
+ delete m_Referencers;
+ delete m_References;
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ cPacket_DestroyEntity DestroyEntity( this );
+ Chunk->Broadcast( DestroyEntity );
+ Chunk->RemoveEntity( *this );
+ }
+ delete m_Pos;
+ delete m_Rot;
+}
+
+void cEntity::Initialize()
+{
+ cRoot::Get()->GetWorld()->AddEntity( this );
+
+ cWorld::BlockToChunk( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z, m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ //LOG("Adding entity %i to chunk %i %i %i", m_UniqueID, Chunk->GetPosX(), Chunk->GetPosY(), Chunk->GetPosZ() );
+ Chunk->AddEntity( *this );
+ }
+}
+
+void cEntity::WrapRotation()
+{
+ while(m_Rot->x > 180.f) m_Rot->x-=360.f; // Wrap it
+ while(m_Rot->x < -180.f) m_Rot->x+=360.f;
+ while(m_Rot->y > 180.f) m_Rot->y-=360.f;
+ while(m_Rot->y < -180.f) m_Rot->y+=360.f;
+}
+
+void cEntity::MoveToCorrectChunk()
+{
+ int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
+ cWorld::BlockToChunk( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z, ChunkX, ChunkY, ChunkZ );
+ if( m_ChunkX != ChunkX || m_ChunkY != ChunkY || m_ChunkZ != ChunkZ )
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ LOG("From %i %i To %i %i", m_ChunkX, m_ChunkZ, ChunkX, ChunkZ );
+ cChunk* Chunk = World->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+
+ typedef std::list< cClientHandle* > ClientList;
+ ClientList BeforeClients;
+ if( Chunk )
+ {
+ Chunk->RemoveEntity( *this );
+ BeforeClients = Chunk->GetClients();
+ }
+ m_ChunkX = ChunkX; m_ChunkY = ChunkY; m_ChunkZ = ChunkZ;
+ cChunk* NewChunk = World->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ ClientList AfterClients;
+ if( NewChunk )
+ {
+ NewChunk->AddEntity( *this );
+ AfterClients = NewChunk->GetClients();
+ }
+
+
+ /********************
+ * I reaalllyyyy don't like this piece of code, but it's needed I guess (maybe there's a way to optimize this)
+ **/
+ // Now compare clients before with after
+ for( ClientList::iterator itr = BeforeClients.begin(); itr != BeforeClients.end(); ++itr )
+ {
+ bool bFound = false;
+ for( ClientList::iterator itr2 = AfterClients.begin(); itr2 != AfterClients.end(); ++itr2 )
+ {
+ if( *itr2 == *itr )
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if( !bFound ) // Client was in old chunk, but not new, so destroy on that client
+ {
+ cPacket_DestroyEntity DestroyEntity( this );
+ (*itr)->Send( DestroyEntity );
+ }
+ }
+
+ // Now compare clients after with before
+ for( ClientList::iterator itr = AfterClients.begin(); itr != AfterClients.end(); ++itr )
+ {
+ bool bFound = false;
+ for( ClientList::iterator itr2 = BeforeClients.begin(); itr2 != BeforeClients.end(); ++itr2 )
+ {
+ if( *itr2 == *itr )
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if( !bFound ) // Client is in the new chunk, but not in old, so spawn on the client
+ {
+ SpawnOn( *itr );
+ }
+ }
+ }
+}
+
+
+CLASS_DEF_GETCLASS( cEntity );
+bool cEntity::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cEntity ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cEntity" ) == 0 ) return true;
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Set orientations
+void cEntity::SetRot( const Vector3f & a_Rot )
+{
+ *m_Rot = a_Rot;
+ m_bDirtyOrientation = true;
+}
+
+void cEntity::SetRotation( float a_Rotation )
+{
+ m_Rot->x = a_Rotation;
+ m_bDirtyOrientation = true;
+}
+
+void cEntity::SetPitch( float a_Pitch )
+{
+ m_Rot->y = a_Pitch;
+ m_bDirtyOrientation = true;
+}
+
+void cEntity::SetRoll( float a_Roll )
+{
+ m_Rot->z = a_Roll;
+ m_bDirtyOrientation = true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Get orientations
+const Vector3f & cEntity::GetRot()
+{
+ return *m_Rot;
+}
+
+float cEntity::GetRotation()
+{
+ return m_Rot->x;
+}
+
+float cEntity::GetPitch()
+{
+ return m_Rot->y;
+}
+
+float cEntity::GetRoll()
+{
+ return m_Rot->z;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Get look vector (this is NOT a rotation!)
+Vector3f cEntity::GetLookVector()
+{
+ Matrix4f m;
+ m.Init( Vector3f(), 0, m_Rot->x, -m_Rot->y );
+ Vector3f Look = m.Transform( Vector3f(0, 0, 1) );
+ LOG("Look: %0.1f %0.1f %0.1f", Look.x, Look.y, Look.z );
+ return Look;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Set position
+void cEntity::SetPosition( const Vector3d & a_Pos )
+{
+ *m_Pos = a_Pos;
+ MoveToCorrectChunk();
+ m_bDirtyPosition = true;
+}
+
+void cEntity::SetPosition( const double & a_PosX, const double & a_PosY, const double & a_PosZ )
+{
+ m_Pos->Set( a_PosX, a_PosY, a_PosZ );
+ MoveToCorrectChunk();
+ m_bDirtyPosition = true;
+}
+
+void cEntity::SetPosX( const double & a_PosX )
+{
+ m_Pos->x = a_PosX;
+ MoveToCorrectChunk();
+ m_bDirtyPosition = true;
+}
+
+void cEntity::SetPosY( const double & a_PosY )
+{
+ m_Pos->y = a_PosY;
+ MoveToCorrectChunk();
+ m_bDirtyPosition = true;
+}
+
+void cEntity::SetPosZ( const double & a_PosZ )
+{
+ m_Pos->z = a_PosZ;
+ MoveToCorrectChunk();
+ m_bDirtyPosition = true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Get position
+const Vector3d & cEntity::GetPosition()
+{
+ return *m_Pos;
+}
+
+const double & cEntity::GetPosX()
+{
+ return m_Pos->x;
+}
+
+const double & cEntity::GetPosY()
+{
+ return m_Pos->y;
+}
+
+const double & cEntity::GetPosZ()
+{
+ return m_Pos->z;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Reference stuffs
+void cEntity::AddReference( cEntity*& a_EntityPtr )
+{
+ m_References->AddReference( a_EntityPtr );
+ a_EntityPtr->ReferencedBy( a_EntityPtr );
+}
+
+void cEntity::ReferencedBy( cEntity*& a_EntityPtr )
+{
+ m_Referencers->AddReference( a_EntityPtr );
+}
+
+void cEntity::Dereference( cEntity*& a_EntityPtr )
+{
+ m_Referencers->Dereference( a_EntityPtr );
+}
diff --git a/source/cEntity.h b/source/cEntity.h
new file mode 100644
index 000000000..602abeeaf
--- /dev/null
+++ b/source/cEntity.h
@@ -0,0 +1,108 @@
+#pragma once
+
+#include "MemoryLeak.h"
+
+#define CLASS_PROT_ISA() virtual bool IsA( const char* a_EntityType );
+#define CLASS_PROT_GETCLASS() virtual const char* GetClass();
+
+/* Can't use this (yet) because of tolua */
+#define CLASS_PROTOTYPE() \
+ CLASS_PROT_ISA(); \
+ CLASS_PROT_GETCLASS();
+
+#define CLASS_DEF_ISA( classname, superclass ) \
+ bool classname::IsA( const char* a_EntityType ) \
+ { \
+ if( strcmp( a_EntityType, #classname ) == 0 ) return true; \
+ return superclass::IsA( a_EntityType ); \
+ }
+
+#define CLASS_DEF_GETCLASS( classname ) \
+ const char* classname::GetClass() \
+ { \
+ return #classname; \
+ }
+
+#define CLASS_DEFINITION( classname, superclass ) \
+ CLASS_DEF_ISA( classname, superclass ) \
+ CLASS_DEF_GETCLASS( classname )
+
+class cReferenceManager;
+class Vector3d;
+class Vector3f;
+class cClientHandle;
+class cEntity //tolua_export
+{ //tolua_export
+public: //tolua_export
+ cEntity(const double & a_X, const double & a_Y, const double & a_Z); //tolua_export
+ virtual ~cEntity(); //tolua_export
+
+ virtual void Initialize(); //tolua_export
+
+ enum ENUM_ENTITY_TYPE //tolua_export
+ { //tolua_export
+ E_ENTITY, //tolua_export
+ E_PLAYER, //tolua_export
+ E_PICKUP //tolua_export
+ }; //tolua_export
+
+ virtual unsigned int GetEntityType() { return m_EntityType; } //tolua_export
+ virtual bool IsA( const char* a_EntityType ); //tolua_export
+ virtual const char* GetClass(); //tolua_export
+
+
+ const Vector3d & GetPosition(); //tolua_export
+ const double & GetPosX(); //tolua_export
+ const double & GetPosY(); //tolua_export
+ const double & GetPosZ(); //tolua_export
+ const Vector3f & GetRot(); //tolua_export
+ float GetRotation(); //tolua_export
+ float GetPitch(); //tolua_export
+ float GetRoll(); //tolua_export
+ Vector3f GetLookVector(); //tolua_export
+
+ void SetPosX( const double & a_PosX ); //tolua_export
+ void SetPosY( const double & a_PosY ); //tolua_export
+ void SetPosZ( const double & a_PosZ ); //tolua_export
+ void SetPosition( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
+ void SetPosition( const Vector3d & a_Pos ); //tolua_export
+ void SetRot( const Vector3f & a_Rot ); //tolua_export
+ void SetRotation( float a_Rotation ); //tolua_export
+ void SetPitch( float a_Pitch ); //tolua_export
+ void SetRoll( float a_Roll ); //tolua_export
+
+ inline int GetUniqueID() { return m_UniqueID; } //tolua_export
+ inline bool IsDestroyed() { return m_bDestroyed; } //tolua_export
+
+ void Destroy() { m_bDestroyed = true; } //tolua_export
+
+ virtual void Tick(float a_Dt) = 0; //tolua_export
+
+ virtual void SpawnOn( cClientHandle* a_Target ) = 0; //tolua_export
+ void WrapRotation();
+
+protected:
+ void MoveToCorrectChunk();
+
+ friend class cReferenceManager;
+ void AddReference( cEntity*& a_EntityPtr );
+ void ReferencedBy( cEntity*& a_EntityPtr );
+ void Dereference( cEntity*& a_EntityPtr );
+
+ static int m_EntityCount;
+ int m_UniqueID;
+
+ cReferenceManager* m_Referencers;
+ cReferenceManager* m_References;
+
+ int m_ChunkX, m_ChunkY, m_ChunkZ;
+ Vector3d* m_Pos;
+ bool m_bDirtyPosition;
+
+ Vector3f* m_Rot;
+ bool m_bDirtyOrientation;
+
+ bool m_bDestroyed;
+
+ ENUM_ENTITY_TYPE m_EntityType;
+}; //tolua_export
diff --git a/source/cEvent.cpp b/source/cEvent.cpp
new file mode 100644
index 000000000..f3a0a3570
--- /dev/null
+++ b/source/cEvent.cpp
@@ -0,0 +1,112 @@
+#include "cEvent.h"
+#include "cMCLogger.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <semaphore.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#endif
+
+cEvent::cEvent( unsigned int a_NumEvents /* = 1 */ )
+ : m_NumEvents( a_NumEvents )
+#ifndef _WIN32
+ , m_bNamed( false )
+#endif
+{
+ if( m_NumEvents < 1 ) m_NumEvents = 1;
+
+#ifdef _WIN32
+ m_Handle = new HANDLE[ m_NumEvents ];
+ for( unsigned int i = 0; i < m_NumEvents; i++)
+ {
+ ((HANDLE*)m_Handle)[i] = CreateEvent( 0, FALSE, FALSE, 0 );
+ }
+#else
+ m_Handle = new sem_t*[ m_NumEvents ];
+ for( unsigned int i = 0; i < m_NumEvents; i++)
+ {
+
+ sem_t* & HandlePtr = ((sem_t**)m_Handle)[i];
+ HandlePtr = new sem_t;
+
+ if( sem_init( HandlePtr, 0, 0 ) )
+ {
+ LOG("WARNING cEvent: Could not create unnamed semaphore, fallback to named.");
+ m_bNamed = true;
+ delete HandlePtr; // named semaphores return their own address
+
+ char c_Str[32];
+ sprintf( c_Str, "cEvent%p", &HandlePtr );
+ HandlePtr = sem_open( c_Str, O_CREAT, 777, 0 );
+ if( HandlePtr == SEM_FAILED )
+ LOG("ERROR: Could not create Event. (%i)", errno);
+ else
+ if( sem_unlink( c_Str ) != 0 )
+ LOG("ERROR: Could not unlink cEvent. (%i)", errno);
+ }
+ }
+#endif
+}
+
+cEvent::~cEvent()
+{
+#ifdef _WIN32
+ for( unsigned int i = 0; i < m_NumEvents; i++ )
+ {
+ CloseHandle( ((HANDLE*)m_Handle)[i] );
+ }
+ delete [] (HANDLE*)m_Handle;
+#else
+ for( unsigned int i = 0; i < m_NumEvents; i++ )
+ {
+ if( m_bNamed )
+ {
+ sem_t* & HandlePtr = ((sem_t**)m_Handle)[i];
+ char c_Str[32];
+ sprintf( c_Str, "cEvent%p", &HandlePtr );
+ // LOG("Closing event: %s", c_Str );
+ // LOG("Sem ptr: %p", HandlePtr );
+ if( sem_close( HandlePtr ) != 0 )
+ {
+ LOG("ERROR: Could not close cEvent. (%i)", errno);
+ }
+ }
+ else
+ {
+ sem_destroy( ((sem_t**)m_Handle)[i] );
+ delete ((sem_t**)m_Handle)[i];
+ }
+ }
+ delete [] (sem_t**)m_Handle; m_Handle = 0;
+#endif
+}
+
+void cEvent::Wait()
+{
+#ifdef _WIN32
+ WaitForMultipleObjects( m_NumEvents, (HANDLE*)m_Handle, true, INFINITE );
+#else
+ for(unsigned int i = 0; i < m_NumEvents; i++)
+ {
+ if( sem_wait( ((sem_t**)m_Handle)[i] ) != 0 )
+ {
+ LOG("ERROR: Could not wait for cEvent. (%i)", errno);
+ }
+ }
+#endif
+}
+
+void cEvent::Set(unsigned int a_EventNum /* = 0 */)
+{
+#ifdef _WIN32
+ SetEvent( ((HANDLE*)m_Handle)[a_EventNum] );
+#else
+ if( sem_post( ((sem_t**)m_Handle)[a_EventNum] ) != 0 )
+ {
+ LOG("ERROR: Could not set cEvent. (%i)", errno);
+ }
+#endif
+}
diff --git a/source/cEvent.h b/source/cEvent.h
new file mode 100644
index 000000000..b0b1d73be
--- /dev/null
+++ b/source/cEvent.h
@@ -0,0 +1,18 @@
+#pragma once
+
+class cEvent
+{
+public:
+ cEvent( unsigned int a_NumEvents = 1 );
+ ~cEvent();
+
+ 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/source/cFurnaceEntity.cpp b/source/cFurnaceEntity.cpp
new file mode 100644
index 000000000..1bca35aca
--- /dev/null
+++ b/source/cFurnaceEntity.cpp
@@ -0,0 +1,372 @@
+#include "cFurnaceEntity.h"
+#include "BlockID.h"
+#include "cItem.h"
+#include "cFurnaceWindow.h"
+#include "cPlayer.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cClientHandle.h"
+#include "cFurnaceRecipe.h"
+#include "cServer.h"
+#include "cPickup.h"
+#include "cRoot.h"
+
+#include "packets/cPacket_InventoryProgressBar.h"
+
+#include "cMCLogger.h"
+
+#include <json/json.h>
+
+cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z)
+ : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z )
+ , m_Items( new cItem[3] )
+ , m_CookingItem( 0 )
+ , m_CookTime( 0 )
+ , m_TimeCooked( 0 )
+ , m_BurnTime( 0 )
+ , m_TimeBurned( 0 )
+{
+}
+
+cFurnaceEntity::~cFurnaceEntity()
+{
+ // Tell window its owner is destroyed
+ if( GetWindow() )
+ {
+ GetWindow()->OwnerDestroyed();
+ }
+
+ // Clean up items
+ if( m_Items )
+ {
+ delete [] m_Items;
+ }
+}
+
+void cFurnaceEntity::Destroy()
+{
+ // Drop items
+ for( int i = 0; i < 3; i++)
+ {
+ if( !m_Items[i].IsEmpty() )
+ {
+ cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Items[i], 0, 1.f, 0 );
+ Pickup->Initialize();
+ m_Items[i].Empty();
+ }
+ }
+
+ // Remove from tick list
+ cWorld* World = cRoot::Get()->GetWorld();
+ cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
+ Chunk->RemoveTickBlockEntity( this );
+}
+
+void cFurnaceEntity::UsedBy( cPlayer & a_Player )
+{
+ LOG("Used a furnace");
+
+ if( !GetWindow() )
+ {
+ cWindow* Window = new cFurnaceWindow( this );
+ Window->SetSlots( m_Items, 3 );
+ Window->SetWindowTitle("UberFurnace");
+ OpenWindow( Window );
+ }
+ if( GetWindow() )
+ {
+ if( a_Player.GetWindow() != GetWindow() )
+ {
+ a_Player.OpenWindow( GetWindow() );
+
+ GetWindow()->SendWholeWindow( a_Player.GetClientHandle() );
+ }
+ }
+}
+
+bool cFurnaceEntity::Tick( float a_Dt )
+{
+ //LOG("Time left: %0.1f Time burned: %0.1f Burn time: %0.1f", m_CookTime - m_TimeCooked, m_TimeBurned, m_BurnTime );
+ if( m_CookingItem && ( (m_TimeBurned < m_BurnTime) || (m_TimeCooked + a_Dt >= m_CookTime) ) )
+ {
+ if( m_CookingItem->Equals( m_Items[2] ) || m_Items[2].IsEmpty() )
+ {
+ m_TimeCooked += a_Dt;
+ if( m_TimeCooked >= m_CookTime )
+ {
+ m_Items[0].m_ItemCount--;
+ if( m_Items[0].IsEmpty() ) m_Items[0].Empty();
+
+ m_Items[2].m_ItemHealth = m_CookingItem->m_ItemHealth;
+ m_Items[2].m_ItemID = m_CookingItem->m_ItemID;
+ m_Items[2].m_ItemCount += m_CookingItem->m_ItemCount;
+ delete m_CookingItem;
+ m_CookingItem = 0;
+
+ cWindow* Window = GetWindow();
+ if( Window )
+ {
+ const std::list< cPlayer* > & OpenedBy = Window->GetOpenedBy();
+ for( std::list< cPlayer* >::const_iterator itr = OpenedBy.begin(); itr != OpenedBy.end(); ++itr )
+ {
+ Window->SendWholeWindow( (*itr)->GetClientHandle() );
+ }
+ }
+
+ m_TimeCooked = 0.f;
+ StartCooking();
+ }
+ cWindow* Window = GetWindow();
+ if( Window )
+ {
+ const std::list< cPlayer* > & OpenedBy = Window->GetOpenedBy();
+ for( std::list< cPlayer* >::const_iterator itr = OpenedBy.begin(); itr != OpenedBy.end(); ++itr )
+ {
+ cClientHandle* Client = (*itr)->GetClientHandle();
+
+ cPacket_InventoryProgressBar Progress;
+ Progress.m_ProgressBar = 0;
+ Progress.m_WindowID = (char)Window->GetWindowID();
+ Progress.m_Value = (short)( m_TimeCooked * (180.f/m_CookTime) );
+ if( Progress.m_Value > 180 ) Progress.m_Value = 180;
+ if( Progress.m_Value < 0 ) Progress.m_Value = 0;
+ Client->Send( Progress );
+ }
+ }
+ }
+ }
+
+ m_TimeBurned += a_Dt;
+
+ cWindow* Window = GetWindow();
+ if( m_TimeBurned >= m_BurnTime )
+ {
+ m_TimeBurned -= m_BurnTime;
+ m_BurnTime = 0;
+ if( StartCooking() && Window )
+ {
+ const std::list< cPlayer* > & OpenedBy = Window->GetOpenedBy();
+ for( std::list< cPlayer* >::const_iterator itr = OpenedBy.begin(); itr != OpenedBy.end(); ++itr )
+ {
+ Window->SendWholeWindow( (*itr)->GetClientHandle() );
+ }
+ }
+ }
+ if( Window )
+ {
+ const std::list< cPlayer* > & OpenedBy = Window->GetOpenedBy();
+ for( std::list< cPlayer* >::const_iterator itr = OpenedBy.begin(); itr != OpenedBy.end(); ++itr )
+ {
+ cClientHandle* Client = (*itr)->GetClientHandle();
+
+ cPacket_InventoryProgressBar Progress;
+ Progress.m_WindowID = (char)Window->GetWindowID();
+ Progress.m_ProgressBar = 1;
+
+ if( m_BurnTime > 0.f ) Progress.m_Value = (short)( m_TimeBurned * (150.f/m_BurnTime) );
+ else Progress.m_Value = 0;
+ if( Progress.m_Value > 150 ) Progress.m_Value = 150;
+ if( Progress.m_Value < 0 ) Progress.m_Value = 0;
+ Client->Send( Progress );
+ }
+ }
+ return ((m_CookingItem != 0) || (m_TimeBurned < m_BurnTime)) && m_BurnTime > 0.f; // Keep on ticking, if there's more to cook, or if it's cooking
+}
+
+bool cFurnaceEntity::StartCooking()
+{
+ cFurnaceRecipe* FR = cRoot::Get()->GetFurnaceRecipe();
+ float BurnTime = FR->GetBurnTime( m_Items[1] );
+ if( (m_TimeBurned < m_BurnTime) || BurnTime > 0.f ) // burnable material
+ {
+ const cFurnaceRecipe::Recipe* R = FR->GetRecipeFrom( m_Items[0] );
+ if( R ) // cook able ingredient
+ {
+ if( m_Items[2].Equals( *R->Out ) || m_Items[2].IsEmpty() )
+ {
+ // good to go
+
+ if( m_TimeBurned >= m_BurnTime ) // burn new material
+ {
+ m_Items[1].m_ItemCount--;
+ if( m_Items[1].m_ItemCount <= 0 ) m_Items[1].Empty();
+ m_TimeBurned = 0;
+ m_BurnTime = BurnTime;
+ }
+
+ if( !m_CookingItem ) // Only cook new item if not already cooking
+ {
+ m_CookingItem = new cItem( *R->Out ); // Resulting item
+ m_TimeCooked = 0.f;
+ m_CookTime = R->CookTime;
+ }
+ cWorld* World = cRoot::Get()->GetWorld();
+ cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
+ Chunk->AddTickBlockEntity( this );
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void cFurnaceEntity::ResetCookTimer()
+{
+ if( m_CookingItem )
+ {
+ delete m_CookingItem;
+ m_CookingItem = 0;
+ }
+ m_TimeCooked = 0.f;
+ m_CookTime = 0.f;
+}
+
+void cFurnaceEntity::WriteToFile(FILE* a_File)
+{
+ fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File );
+ fwrite( &m_PosX, sizeof( int ), 1, a_File );
+ fwrite( &m_PosY, sizeof( int ), 1, a_File );
+ fwrite( &m_PosZ, sizeof( int ), 1, a_File );
+
+ unsigned int NumSlots = 3;
+ fwrite( &NumSlots, sizeof(unsigned int), 1, a_File );
+ for(unsigned int i = 0; i < NumSlots; i++)
+ {
+ cItem* Item = &m_Items[i];
+ if( Item )
+ {
+ fwrite( &Item->m_ItemID, sizeof(Item->m_ItemID), 1, a_File );
+ fwrite( &Item->m_ItemCount, sizeof(Item->m_ItemCount), 1, a_File );
+ fwrite( &Item->m_ItemHealth, sizeof(Item->m_ItemHealth), 1, a_File );
+ }
+ }
+ cItem Item;
+ if( m_CookingItem ) Item = *m_CookingItem;
+ fwrite( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File );
+ fwrite( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File );
+ fwrite( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File );
+
+ fwrite( &m_CookTime, sizeof(float), 1, a_File );
+ fwrite( &m_TimeCooked, sizeof(float), 1, a_File );
+ fwrite( &m_BurnTime, sizeof(float), 1, a_File );
+ fwrite( &m_TimeBurned, sizeof(float), 1, a_File );
+}
+
+bool cFurnaceEntity::LoadFromFile(FILE* a_File)
+{
+ if( fread( &m_PosX, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &m_PosY, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &m_PosZ, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+
+ unsigned int NumSlots = 0;
+ if( fread( &NumSlots, sizeof(unsigned int), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ m_Items = new cItem[ NumSlots ];
+ for(unsigned int i = 0; i < NumSlots; i++)
+ {
+ cItem & Item = m_Items[ i ];
+ if( fread( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File)!= 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ }
+ cItem Item;
+ if( fread( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File)!= 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( !Item.IsEmpty() ) m_CookingItem = new cItem( Item );
+
+ if( fread( &m_CookTime, sizeof(float), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &m_TimeCooked, sizeof(float), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &m_BurnTime, sizeof(float), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+ if( fread( &m_TimeBurned, sizeof(float), 1, a_File) != 1 ) { LOGERROR("ERROR READING FURNACE FROM FILE"); return false; }
+
+ return true;
+}
+
+bool cFurnaceEntity::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 )
+ {
+ Json::Value & Slot = *itr;
+ cItem & Item = m_Items[ SlotIdx ];
+ Item.m_ItemID = (ENUM_ITEM_ID)Slot.get("ID", -1 ).asInt();
+ if( Item.m_ItemID > 0 )
+ {
+ Item.m_ItemCount = (char)Slot.get("Count", -1 ).asInt();
+ Item.m_ItemHealth = (short)Slot.get("Health", -1 ).asInt();
+ }
+ SlotIdx++;
+ }
+
+ // Get currently cooking item
+ Json::Value JsonItem = a_Value.get("Cooking", Json::nullValue );
+ if( !JsonItem.empty() )
+ {
+ cItem Item;
+ Item.m_ItemID = (ENUM_ITEM_ID)JsonItem.get("ID", -1).asInt();
+ if( Item.m_ItemID > 0 )
+ {
+ Item.m_ItemCount = (char)JsonItem.get("Count", -1).asInt();
+ Item.m_ItemHealth = (short)JsonItem.get("Health", -1).asInt();
+ }
+ if( !Item.IsEmpty() )
+ {
+ m_CookingItem = new cItem( Item );
+
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
+ Chunk->AddTickBlockEntity( this );
+ }
+ }
+
+ m_CookTime = (float)a_Value.get("CookTime", 0).asDouble();
+ m_TimeCooked = (float)a_Value.get("TimeCooked", 0).asDouble();
+ m_BurnTime = (float)a_Value.get("BurnTime", 0).asDouble();
+ m_TimeBurned = (float)a_Value.get("TimeBurned", 0).asDouble();
+
+ return true;
+}
+
+void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ Json::Value AllSlots;
+ for(unsigned int i = 0; i < 3; i++)
+ {
+ Json::Value Slot;
+ cItem & Item = m_Items[ i ];
+ Slot["ID"] = Item.m_ItemID;
+ if( Item.m_ItemID > 0 )
+ {
+ Slot["Count"] = Item.m_ItemCount;
+ Slot["Health"] = Item.m_ItemHealth;
+ }
+ AllSlots.append( Slot );
+ }
+ a_Value["Slots"] = AllSlots;
+
+ // Currently cooking item
+ if( m_CookingItem )
+ {
+ Json::Value JsonItem;
+ JsonItem["ID"] = m_CookingItem->m_ItemID;
+ if( m_CookingItem->m_ItemID > 0 )
+ {
+ JsonItem["Count"] = m_CookingItem->m_ItemCount;
+ JsonItem["Health"] = m_CookingItem->m_ItemHealth;
+ }
+ a_Value["Cooking"] = JsonItem;
+ }
+
+ a_Value["CookTime"] = m_CookTime;
+ a_Value["TimeCooked"] = m_TimeCooked;
+ a_Value["BurnTime"] = m_BurnTime;
+ a_Value["TimeBurned"] = m_TimeBurned;
+} \ No newline at end of file
diff --git a/source/cFurnaceEntity.h b/source/cFurnaceEntity.h
new file mode 100644
index 000000000..a1ab051ba
--- /dev/null
+++ b/source/cFurnaceEntity.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "cBlockEntity.h"
+#include "cWindowOwner.h"
+#include "FileDefine.h"
+
+namespace Json
+{
+ class Value;
+}
+
+class cClientHandle;
+class cServer;
+class cItem;
+class cNBTData;
+class cFurnaceEntity : public cBlockEntity, public cWindowOwner
+{
+public:
+ cFurnaceEntity(int a_X, int a_Y, int a_Z);
+ virtual ~cFurnaceEntity();
+ virtual void Destroy();
+
+ void WriteToFile(FILE* a_File);
+ bool LoadFromFile(FILE* a_File);
+
+ bool LoadFromJson( const Json::Value& a_Value );
+ void SaveToJson( Json::Value& a_Value );
+
+ bool Tick( float a_Dt );
+ virtual void UsedBy( cPlayer & a_Player );
+
+ bool StartCooking();
+
+ void ResetCookTimer();
+private:
+ cItem* m_Items;
+ cItem* m_CookingItem;
+ float m_CookTime;
+ float m_TimeCooked;
+
+ float m_BurnTime;
+ float m_TimeBurned;
+}; \ No newline at end of file
diff --git a/source/cFurnaceRecipe.cpp b/source/cFurnaceRecipe.cpp
new file mode 100644
index 000000000..2885f769d
--- /dev/null
+++ b/source/cFurnaceRecipe.cpp
@@ -0,0 +1,214 @@
+#include "cFurnaceRecipe.h"
+#include "cItem.h"
+#include "cMCLogger.h"
+
+#include <fstream>
+#include <sstream>
+
+typedef std::list< cFurnaceRecipe::Recipe > RecipeList;
+typedef std::list< cFurnaceRecipe::Fuel > FuelList;
+struct cFurnaceRecipe::sFurnaceRecipeState
+{
+ RecipeList Recipes;
+ FuelList Fuel;
+};
+
+cFurnaceRecipe::cFurnaceRecipe()
+ : m_pState( new sFurnaceRecipeState )
+{
+ ReloadRecipes();
+}
+
+cFurnaceRecipe::~cFurnaceRecipe()
+{
+ ClearRecipes();
+ delete m_pState;
+}
+
+void cFurnaceRecipe::ReloadRecipes()
+{
+ ClearRecipes();
+ LOG("--Loading furnace recipes--");
+
+ std::ifstream f;
+ char a_File[] = "furnace.txt";
+ f.open(a_File, std::ios::in);
+ std::string input;
+
+ if( !f.good() )
+ {
+ f.close();
+ LOG("Could not open file for recipes: %s", a_File);
+ return;
+ }
+
+ bool bSyntaxError = false;
+ while( f.good() )
+ {
+ char c;
+
+ //////////////////////////////////////////////////////////////////////////
+ // comments
+ f >> c;
+ f.unget();
+ if( c == '#' )
+ {
+ while( f.good() && c != '\n' )
+ {
+ f.get( c );
+ }
+ continue;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // Line breaks
+ f.get( c );
+ while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); }
+ if( f.eof() ) break;
+ f.unget();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Check for fuel
+ f >> c;
+ if( c == '!' ) // It's fuel :)
+ {
+ // Read item
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0;
+ f >> IItemID;
+ f >> c; if( c != ':' ) { bSyntaxError = true; break; }
+ f >> IItemCount;
+
+ // Optional health
+ f >> c;
+ if( c != ':' )
+ f.unget();
+ else
+ {
+ f >> IItemHealth;
+ }
+
+ // Burn time
+ float BurnTime;
+ f >> c; if( c != '=' ) { bSyntaxError = true; break; }
+ f >> BurnTime;
+
+ // Add to fuel list
+ Fuel F;
+ F.In = new cItem( (ENUM_ITEM_ID) IItemID, (char)IItemCount, (short)IItemHealth );
+ F.BurnTime = BurnTime;
+ m_pState->Fuel.push_back( F );
+ continue;
+ }
+ f.unget();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Read items
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0;
+ f >> IItemID;
+ f >> c; if( c != ':' ) { bSyntaxError = true; break; }
+ f >> IItemCount;
+
+ // Optional health
+ f >> c;
+ if( c != ':' )
+ f.unget();
+ else
+ {
+ f >> IItemHealth;
+ }
+
+ float CookTime;
+ f >> c; if( c != '@' ) { bSyntaxError = true; break; }
+ f >> CookTime;
+
+ int OItemID = 0, OItemCount = 0, OItemHealth = 0;
+ f >> c; if( c != '=' ) { bSyntaxError = true; break; }
+ f >> OItemID;
+ f >> c; if( c != ':' ) { bSyntaxError = true; break; }
+ f >> OItemCount;
+
+ // Optional health
+ f >> c;
+ if( c != ':' )
+ f.unget();
+ else
+ {
+ f >> OItemHealth;
+ }
+
+ // Add to recipe list
+ Recipe R;
+ R.In = new cItem( (ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth );
+ R.Out = new cItem( (ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth );
+ R.CookTime = CookTime;
+ m_pState->Recipes.push_back( R );
+ }
+ if( bSyntaxError )
+ {
+ LOGERROR("ERROR: FurnaceRecipe, syntax error" );
+ }
+ LOG("Got %i furnace recipes, and %i fuels.", m_pState->Recipes.size(), m_pState->Fuel.size() );
+
+ LOG("--Done loading furnace recipes--");
+}
+
+void cFurnaceRecipe::ClearRecipes()
+{
+ for( RecipeList::iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
+ {
+ Recipe R = *itr;
+ delete R.In;
+ delete R.Out;
+ }
+ m_pState->Recipes.clear();
+
+ for( FuelList::iterator itr = m_pState->Fuel.begin(); itr != m_pState->Fuel.end(); ++itr )
+ {
+ Fuel F = *itr;
+ delete F.In;
+ }
+ m_pState->Fuel.clear();
+}
+
+const cFurnaceRecipe::Recipe* cFurnaceRecipe::GetRecipeFrom( const cItem & a_Ingredient ) const
+{
+ const Recipe* BestRecipe = 0;
+ for( RecipeList::const_iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
+ {
+ const Recipe & R = *itr;
+ if( (R.In->m_ItemID == a_Ingredient.m_ItemID) && (R.In->m_ItemCount <= a_Ingredient.m_ItemCount ) )
+ {
+ if( BestRecipe && (BestRecipe->In->m_ItemCount > R.In->m_ItemCount) )
+ {
+ continue;
+ }
+ else
+ {
+ BestRecipe = &R;
+ }
+ }
+ }
+ return BestRecipe;
+}
+
+float cFurnaceRecipe::GetBurnTime( const cItem & a_Fuel ) const
+{
+ float BestFuel = 0.f;
+ for( FuelList::const_iterator itr = m_pState->Fuel.begin(); itr != m_pState->Fuel.end(); ++itr )
+ {
+ const Fuel & F = *itr;
+ if( (F.In->m_ItemID == a_Fuel.m_ItemID) && (F.In->m_ItemCount <= a_Fuel.m_ItemCount ) )
+ {
+ if( BestFuel > 0.f && (BestFuel > F.BurnTime ) )
+ {
+ continue;
+ }
+ else
+ {
+ BestFuel = F.BurnTime;
+ }
+ }
+ }
+ return BestFuel;
+} \ No newline at end of file
diff --git a/source/cFurnaceRecipe.h b/source/cFurnaceRecipe.h
new file mode 100644
index 000000000..7489b09e6
--- /dev/null
+++ b/source/cFurnaceRecipe.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <list>
+
+class cItem;
+class cFurnaceRecipe
+{
+public:
+ cFurnaceRecipe();
+ ~cFurnaceRecipe();
+
+ void ReloadRecipes();
+
+ struct Fuel
+ {
+ cItem* In;
+ float BurnTime;
+ };
+
+ struct Recipe
+ {
+ cItem* In;
+ cItem* Out;
+ float CookTime;
+ };
+ const Recipe* GetRecipeFrom( const cItem & a_Ingredient ) const;
+ float GetBurnTime( const cItem & a_Fuel ) const;
+
+private:
+ void ClearRecipes();
+
+ struct sFurnaceRecipeState;
+ sFurnaceRecipeState* m_pState;
+}; \ No newline at end of file
diff --git a/source/cFurnaceWindow.cpp b/source/cFurnaceWindow.cpp
new file mode 100644
index 000000000..8b86f16d6
--- /dev/null
+++ b/source/cFurnaceWindow.cpp
@@ -0,0 +1,42 @@
+#include "cFurnaceWindow.h"
+#include "cItem.h"
+#include "cFurnaceEntity.h"
+#include "cPlayer.h"
+
+#include "packets/cPacket_WindowClick.h"
+
+#include "cMCLogger.h"
+
+cFurnaceWindow::cFurnaceWindow( cFurnaceEntity* a_Owner )
+ : cWindow( a_Owner, true )
+ , m_Furnace( a_Owner )
+{
+ SetWindowID( 1 );
+ SetWindowType( 2 ); // Furnace
+}
+
+void cFurnaceWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
+{
+ cItem Fuel = *GetSlot( 0 );
+
+ cWindow::Clicked( a_ClickPacket, a_Player );
+ if( m_Furnace )
+ {
+ if( a_ClickPacket->m_SlotNum >= 0 && a_ClickPacket->m_SlotNum <= 2 ) // them important slots
+ {
+ if( Fuel.m_ItemID != GetSlot( 0 )->m_ItemID )
+ m_Furnace->ResetCookTimer();
+
+ if( m_Furnace->StartCooking() )
+ {
+ SendWholeWindow( a_Player.GetClientHandle() );
+ }
+ }
+ }
+}
+
+void cFurnaceWindow::Close( cPlayer & a_Player )
+{
+ m_Furnace = 0;
+ cWindow::Close( a_Player );
+} \ No newline at end of file
diff --git a/source/cFurnaceWindow.h b/source/cFurnaceWindow.h
new file mode 100644
index 000000000..8dd7d3223
--- /dev/null
+++ b/source/cFurnaceWindow.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "cWindow.h"
+
+class cFurnaceEntity;
+class cWindowOwner;
+class cFurnaceWindow : public cWindow
+{
+public:
+ cFurnaceWindow( cFurnaceEntity* a_Owner );
+
+ virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player );
+ virtual void Close( cPlayer & a_Player );
+private:
+ cFurnaceEntity* m_Furnace;
+}; \ No newline at end of file
diff --git a/source/cGenSettings.cpp b/source/cGenSettings.cpp
new file mode 100644
index 000000000..7c7206d91
--- /dev/null
+++ b/source/cGenSettings.cpp
@@ -0,0 +1,10 @@
+#include "cGenSettings.h"
+
+
+float cGenSettings::HeightFreq1 = 0.1f;
+float cGenSettings::HeightFreq2 = 1.f;
+float cGenSettings::HeightFreq3 = 2.f;
+
+float cGenSettings::HeightAmp1 = 1.f;
+float cGenSettings::HeightAmp2 = 0.5f;
+float cGenSettings::HeightAmp3 = 0.5f; \ No newline at end of file
diff --git a/source/cGenSettings.h b/source/cGenSettings.h
new file mode 100644
index 000000000..ba76f55e9
--- /dev/null
+++ b/source/cGenSettings.h
@@ -0,0 +1,9 @@
+#pragma once
+
+class cGenSettings
+{
+public:
+ static float HeightFreq1, HeightAmp1;
+ static float HeightFreq2, HeightAmp2;
+ static float HeightFreq3, HeightAmp3;
+}; \ No newline at end of file
diff --git a/source/cGroup.cpp b/source/cGroup.cpp
new file mode 100644
index 000000000..2590c5303
--- /dev/null
+++ b/source/cGroup.cpp
@@ -0,0 +1,34 @@
+#include "cGroup.h"
+
+void cGroup::AddCommand( std::string a_Command )
+{
+ m_Commands[ a_Command ] = true;
+}
+
+void cGroup::AddPermission( std::string a_Permission )
+{
+ m_Permissions[ a_Permission ] = true;
+}
+
+bool cGroup::HasCommand( std::string a_Command )
+{
+ if( m_Commands.find("*") != m_Commands.end() ) return true;
+
+ CommandMap::iterator itr = m_Commands.find( a_Command );
+ if( itr != m_Commands.end() )
+ {
+ if( itr->second ) return true;
+ }
+
+ for( GroupList::iterator itr = m_Inherits.begin(); itr != m_Inherits.end(); ++itr )
+ {
+ if( (*itr)->HasCommand( a_Command ) ) return true;
+ }
+ return false;
+}
+
+void cGroup::InheritFrom( cGroup* a_Group )
+{
+ m_Inherits.remove( a_Group );
+ m_Inherits.push_back( a_Group );
+} \ No newline at end of file
diff --git a/source/cGroup.h b/source/cGroup.h
new file mode 100644
index 000000000..303df85fa
--- /dev/null
+++ b/source/cGroup.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <string>
+#include <map>
+#include <list>
+
+class cGroup //tolua_export
+{ //tolua_export
+public: //tolua_export
+ cGroup() {}
+ ~cGroup() {}
+
+ void SetName( std::string a_Name ) { m_Name = a_Name; } //tolua_export
+ const std::string & GetName() const { return m_Name; } //tolua_export
+ void SetColor( std::string a_Color ) { m_Color = a_Color; } //tolua_export
+ void AddCommand( std::string a_Command ); //tolua_export
+ void AddPermission( std::string a_Permission ); //tolua_export
+ void InheritFrom( cGroup* a_Group ); //tolua_export
+
+ bool HasCommand( std::string a_Command ); //tolua_export
+
+ typedef std::map< std::string, bool > PermissionMap;
+ const PermissionMap & GetPermissions() const { return m_Permissions; }
+
+ typedef std::map< std::string, bool > CommandMap;
+ const CommandMap & GetCommands() const { return m_Commands; }
+
+ std::string GetColor() const { return m_Color; } //tolua_export
+
+ typedef std::list< cGroup* > GroupList;
+ const GroupList & GetInherits() const { return m_Inherits; }
+private:
+ std::string m_Name;
+ std::string m_Color;
+
+ PermissionMap m_Permissions;
+ CommandMap m_Commands;
+ GroupList m_Inherits;
+};//tolua_export \ No newline at end of file
diff --git a/source/cGroupManager.cpp b/source/cGroupManager.cpp
new file mode 100644
index 000000000..4d7bf7a9a
--- /dev/null
+++ b/source/cGroupManager.cpp
@@ -0,0 +1,104 @@
+#include "cGroupManager.h"
+#include "cGroup.h"
+#include "../iniFile/iniFile.h"
+#include "cChatColor.h"
+#include "cMCLogger.h"
+#include "cRoot.h"
+
+extern std::vector< std::string > StringSplit( std::string str, std::string delim);
+
+typedef std::map< std::string, cGroup* > GroupMap;
+struct cGroupManager::sGroupManagerState
+{
+ GroupMap Groups;
+};
+
+cGroupManager* cGroupManager::GetGroupManager()
+{
+ LOGWARN("WARNING: Using deprecated function cGroupManager::GetGroupManager() use cRoot::Get()->GetGroupManager() instead!");
+ return cRoot::Get()->GetGroupManager();
+}
+
+cGroupManager::~cGroupManager()
+{
+ for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
+ {
+ delete itr->second;
+ }
+ m_pState->Groups.clear();
+
+ delete m_pState;
+}
+
+cGroupManager::cGroupManager()
+ : m_pState( new sGroupManagerState )
+{
+ LOG("-- Loading Groups --");
+ cIniFile IniFile("groups.ini");
+ if( IniFile.ReadFile() )
+ {
+ unsigned int NumKeys = IniFile.GetNumKeys();
+ for( unsigned int i = 0; i < NumKeys; i++ )
+ {
+ std::string KeyName = IniFile.GetKeyName( i );
+ cGroup* Group = GetGroup( KeyName.c_str() );
+
+ LOG("Loading group: %s", KeyName.c_str() );
+
+ Group->SetName( KeyName );
+ char Color = IniFile.GetValue( KeyName, "Color", "-" )[0];
+ if( Color != '-' )
+ Group->SetColor( cChatColor::MakeColor(Color) );
+ else
+ Group->SetColor( cChatColor::White );
+
+ std::string Commands = IniFile.GetValue( KeyName, "Commands", "" );
+ if( Commands.size() > 0 )
+ {
+ std::vector< std::string > Split = StringSplit( Commands, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
+ {
+ Group->AddCommand( Split[i] );
+ //LOG("%s", Split[i].c_str() );
+ }
+ }
+
+ std::string Permissions = IniFile.GetValue( KeyName, "Permissions", "" );
+ if( Permissions.size() > 0 )
+ {
+ std::vector< std::string > Split = StringSplit( Permissions, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
+ {
+ Group->AddPermission( Split[i] );
+ LOGINFO("Permission: %s", Split[i].c_str() );
+ }
+ }
+
+ std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
+ if( Groups.size() > 0 )
+ {
+ std::vector< std::string > Split = StringSplit( Groups, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
+ {
+ Group->InheritFrom( GetGroup( Split[i].c_str() ) );
+ }
+ }
+ }
+ }
+ LOG("-- Done Loading Groups --");
+}
+
+cGroup* cGroupManager::GetGroup( const char* a_Name )
+{
+ GroupMap::iterator itr = m_pState->Groups.find( a_Name );
+ if( itr != m_pState->Groups.end() )
+ {
+ return itr->second;
+ }
+
+ cGroup* Group = new cGroup();
+ m_pState->Groups[a_Name] = Group;
+
+ return Group;
+
+} \ No newline at end of file
diff --git a/source/cGroupManager.h b/source/cGroupManager.h
new file mode 100644
index 000000000..fbd16f117
--- /dev/null
+++ b/source/cGroupManager.h
@@ -0,0 +1,17 @@
+#pragma once
+
+class cGroup;
+class cGroupManager
+{
+public:
+ static cGroupManager * GetGroupManager(); //tolua_export
+
+ cGroup* GetGroup( const char* a_Name );
+private:
+ friend class cRoot;
+ cGroupManager();
+ ~cGroupManager();
+
+ struct sGroupManagerState;
+ sGroupManagerState* m_pState;
+}; \ No newline at end of file
diff --git a/source/cHeartBeat.cpp b/source/cHeartBeat.cpp
new file mode 100644
index 000000000..b518a753a
--- /dev/null
+++ b/source/cHeartBeat.cpp
@@ -0,0 +1,119 @@
+#include "cHeartBeat.h"
+#include "cMCLogger.h"
+#include "md5/md5.h"
+
+#include <stdio.h>
+
+#include "cRoot.h"
+#include "cServer.h"
+#include "cSleep.h"
+
+cHeartBeat::cHeartBeat()
+{
+ m_State = 0;
+ Authenticate();
+}
+
+cHeartBeat::~cHeartBeat()
+{
+}
+
+void cHeartBeat::ReceivedData( char a_Data[256], int a_Size )
+{
+ if( a_Size < 0 ) // Disconnected
+ return;
+
+ char MySalt[] = "1234567890";
+
+ if( a_Size == 0 )
+ {
+ Authenticate();
+ return;
+ }
+
+ bool bLoop = false;
+ do
+ {
+ switch (m_State)
+ {
+ case 1:
+ {
+ m_ServerID = std::string( a_Data, a_Size );
+ LOGINFO("Got server ID %s", m_ServerID.c_str() );
+ std::string Hash = md5( m_ServerID + std::string( MySalt ) );
+ CloseSocket();
+ if( Connect( "mc-server.org", 80 ) )
+ {
+ SendMessage( (std::string("GET http://master.mc-server.org/?hash=") + Hash + std::string("&server=") + m_ServerID + "\n").c_str() );
+ m_State = 2;
+ }
+ }
+ break;
+ case 2:
+ {
+ std::string ReturnedString = std::string( a_Data, a_Size );
+ if( ReturnedString.compare("VALIDATED") == 0 )
+ {
+ LOGINFO("Successfully validated server on master server list");
+ }
+ else
+ {
+ LOGINFO("Could not validate server! Will try again later.");
+ cSleep::MilliSleep( 10*1000 );
+ Authenticate();
+ return;
+ }
+ m_State = 3;
+ } // Don't break, but fall through and update server info
+ case 3:
+ {
+ cSleep::MilliSleep( 10*1000 );
+ SendUpdate();
+ m_State = 4;
+ }
+ break;
+ case 4:
+ {
+ if( a_Data[0] == '0' )
+ {
+ LOGINFO("Successfully updated server info!");
+ cSleep::MilliSleep( 10*1000 );
+ SendUpdate();
+ }
+ else
+ {
+ LOGINFO("Failed to update server info, reauthenticating");
+ Authenticate();
+ }
+ }
+ default:
+ break;
+ };
+ } while( bLoop );
+}
+
+void cHeartBeat::SendUpdate()
+{
+ CloseSocket();
+ if( Connect( "mc-server.org", 80 ) )
+ {
+ int Port = cRoot::Get()->GetServer()->GetPort();
+ char c_Port[16];
+ sprintf_s( c_Port, 16, "%i", Port );
+
+ std::string sPort = std::string( c_Port );
+ std::string sChecksum = md5( m_ServerID + sPort );
+ SendMessage( (std::string("GET http://master.mc-server.org/?update=") + m_ServerID + std::string("&checksum=") + sChecksum + std::string("&port=") + sPort + "\n").c_str() );
+ }
+}
+
+void cHeartBeat::Authenticate()
+{
+ CloseSocket();
+ if( Connect( "mc-server.org", 80 ) )
+ {
+ m_State = 1;
+ int RetVal = SendMessage( "GET http://master.mc-server.org/\r\n\r\n");
+ LOGINFO("Returned %i", RetVal );
+ }
+}
diff --git a/source/cHeartBeat.h b/source/cHeartBeat.h
new file mode 100644
index 000000000..8a5373af4
--- /dev/null
+++ b/source/cHeartBeat.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cTCPLink.h"
+
+#include <string>
+
+class cHeartBeat : public cTCPLink
+{
+public:
+ cHeartBeat();
+ ~cHeartBeat();
+private:
+ virtual void ReceivedData( char a_Data[256], int a_Size );
+
+ void Authenticate();
+ int m_State;
+
+ void SendUpdate();
+
+ std::string m_ServerID;
+}; \ No newline at end of file
diff --git a/source/cInventory.cpp b/source/cInventory.cpp
new file mode 100644
index 000000000..e78ac226e
--- /dev/null
+++ b/source/cInventory.cpp
@@ -0,0 +1,364 @@
+#include "cInventory.h"
+#include <string> //memset
+#include "cPlayer.h"
+#include "cClientHandle.h"
+#include "cMCLogger.h"
+#include "cWindow.h"
+#include "cItem.h"
+#include "cRecipeChecker.h"
+#include "cRoot.h"
+
+#include "packets/cPacket_WindowClick.h"
+#include "packets/cPacket_WholeInventory.h"
+#include "packets/cPacket_InventorySlot.h"
+
+cInventory::~cInventory()
+{
+ delete [] m_Slots;
+ delete m_EquippedItem;
+ if( GetWindow() ) GetWindow()->Close( *m_Owner );
+ CloseWindow();
+}
+
+cInventory::cInventory(cPlayer* a_Owner)
+{
+ m_Owner = a_Owner;
+
+ m_Slots = new cItem[c_NumSlots];
+ for(unsigned int i = 0; i < c_NumSlots; i++)
+ m_Slots[i].Empty();
+
+ m_CraftSlots = m_Slots + c_CraftOffset;
+ m_ArmorSlots = m_Slots + c_ArmorOffset;
+ m_MainSlots = m_Slots + c_MainOffset;
+ m_HotSlots = m_Slots + c_HotOffset;
+
+ m_EquippedItem = new cItem();
+ m_EquippedSlot = 0;
+
+ if( !GetWindow() )
+ {
+ cWindow* Window = new cWindow( this, false );
+ Window->SetSlots( m_Slots, c_NumSlots );
+ Window->SetWindowID( 0 );
+ OpenWindow( Window );
+ }
+}
+
+void cInventory::Clear()
+{
+ for(unsigned int i = 0; i < c_NumSlots; i++)
+ m_Slots[i].Empty();
+}
+
+cItem* cInventory::GetSlotsForType( int a_Type )
+{
+ switch( a_Type )
+ {
+ case -1:
+ return m_MainSlots;
+ case -2:
+ return m_CraftSlots;
+ case -3:
+ return m_ArmorSlots;
+ }
+ return 0;
+}
+
+int cInventory::GetSlotCountForType( int a_Type )
+{
+ switch( a_Type )
+ {
+ case -1:
+ return 36;
+ case -2:
+ case -3:
+ return 4;
+ }
+ return 0;
+}
+
+void cInventory::Clicked( cPacket_WindowClick* a_ClickPacket )
+{
+ bool bDontCook = false;
+ if( GetWindow() )
+ {
+ // Override for craft result slot
+ if( a_ClickPacket->m_SlotNum == (short)c_CraftOffset )
+ {
+ LOG("In craft slot: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
+ cItem* DraggingItem = GetWindow()->GetDraggingItem();
+ if( DraggingItem->IsEmpty() )
+ {
+ *DraggingItem = m_Slots[c_CraftOffset];
+ m_Slots[c_CraftOffset].Empty();
+ }
+ else if( DraggingItem->Equals( m_Slots[c_CraftOffset] ) )
+ {
+ if( DraggingItem->m_ItemCount + m_Slots[c_CraftOffset].m_ItemCount <= 64 )
+ {
+ DraggingItem->m_ItemCount += m_Slots[c_CraftOffset].m_ItemCount;
+ m_Slots[0].Empty();
+ }
+ else
+ {
+ bDontCook = true;
+ }
+ }
+ else
+ {
+ bDontCook = true;
+ }
+ LOG("Dragging Dish %i", DraggingItem->m_ItemCount );
+ }
+ else
+ {
+ GetWindow()->Clicked( a_ClickPacket, *m_Owner );
+ }
+ }
+ else
+ {
+ LOG("No Inventory window! WTF");
+ }
+
+ if( a_ClickPacket->m_SlotNum >= (short)c_CraftOffset && a_ClickPacket->m_SlotNum < (short)(c_CraftOffset+c_CraftSlots+1) )
+ {
+ cItem CookedItem;
+ if( a_ClickPacket->m_SlotNum == 0 && !bDontCook )
+ {
+ CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2, true );
+ }
+ else
+ {
+ CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2 );
+ }
+ m_Slots[c_CraftOffset] = CookedItem;
+ LOG("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
+ SendWholeInventory( m_Owner->GetClientHandle() );
+ }
+ SendSlot( 0 );
+}
+
+bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ )
+{
+ // Fill already present stacks
+ if( a_Mode < 2 )
+ {
+ for(int i = 0; i < a_Size; i++)
+ {
+ if( m_Slots[i + a_Offset].m_ItemID == a_Item.m_ItemID && m_Slots[i + a_Offset].m_ItemCount < 64 )
+ {
+ int NumFree = 64 - m_Slots[i + a_Offset].m_ItemCount;
+ if( NumFree >= a_Item.m_ItemCount )
+ {
+
+ //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
+ m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount;
+ a_Item.m_ItemCount = 0;
+ a_bChangedSlots[i + a_Offset] = true;
+ break;
+ }
+ else
+ {
+ //printf("2. Adding %i items\n", NumFree );
+ m_Slots[i + a_Offset].m_ItemCount += (char)NumFree;
+ a_Item.m_ItemCount -= (char)NumFree;
+ a_bChangedSlots[i + a_Offset] = true;
+ }
+ }
+ }
+ }
+
+ if( a_Mode > 0 )
+ {
+ // If we got more left, find first empty slot
+ for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
+ {
+ if( m_Slots[i + a_Offset].m_ItemID == -1 )
+ {
+ m_Slots[i + a_Offset] = a_Item;
+ a_Item.m_ItemCount = 0;
+ a_bChangedSlots[i + a_Offset] = true;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cInventory::AddItem( cItem & a_Item )
+{
+ cItem BackupSlots[c_NumSlots];
+ memcpy( BackupSlots, m_Slots, c_NumSlots * sizeof( cItem ) );
+
+ bool ChangedSlots[c_NumSlots];
+ memset( ChangedSlots, false, c_NumSlots * sizeof( bool ) );
+
+ if( a_Item.m_ItemCount > 0 ) AddToBar( a_Item, c_HotOffset, c_HotSlots, ChangedSlots, 0 );
+ if( a_Item.m_ItemCount > 0 ) AddToBar( a_Item, c_MainOffset, c_MainSlots, ChangedSlots, 0 );
+ if( a_Item.m_ItemCount > 0 ) AddToBar( a_Item, c_HotOffset, c_HotSlots, ChangedSlots, 2 );
+ if( a_Item.m_ItemCount > 0 ) AddToBar( a_Item, c_MainOffset, c_MainSlots, ChangedSlots, 2 );
+
+ if( a_Item.m_ItemCount > 0 ) // Could not add all items
+ {
+ // retore backup
+ memcpy( m_Slots, BackupSlots, c_NumSlots * sizeof( cItem ) );
+ return false;
+ }
+
+ for(unsigned int i = 0; i < c_NumSlots; i++)
+ {
+ if( ChangedSlots[i] )
+ {
+ LOG("Item was added to %i ID:%i Count:%i", i, m_Slots[i].m_ItemID, m_Slots[i].m_ItemCount );
+ SendSlot(i);
+ }
+ }
+
+ return (a_Item.m_ItemCount == 0);
+}
+
+// TODO: Right now if you dont have enough items, the items you did have are removed, and the function returns false anyway
+bool cInventory::RemoveItem( cItem & a_Item )
+{
+ // First check equipped slot
+ if( m_EquippedSlot >= 0 && m_EquippedSlot < 9 )
+ {
+ if( m_HotSlots[m_EquippedSlot].m_ItemID == a_Item.m_ItemID )
+ {
+ cItem & Item = m_HotSlots[m_EquippedSlot];
+ if(Item.m_ItemCount > a_Item.m_ItemCount)
+ {
+ Item.m_ItemCount -= a_Item.m_ItemCount;
+ SendSlot( m_EquippedSlot + c_HotOffset );
+ return true;
+ }
+ else if(Item.m_ItemCount > 0 )
+ {
+ a_Item.m_ItemCount -= Item.m_ItemCount;
+ Item.Empty();
+ SendSlot( m_EquippedSlot + c_HotOffset );
+ }
+ }
+ }
+
+ // Then check other slotz
+ if( a_Item.m_ItemCount > 0 )
+ {
+ for(int i = 0; i < 36; i++)
+ {
+ cItem & Item = m_MainSlots[i];
+ if( Item.m_ItemID == a_Item.m_ItemID )
+ {
+ if(Item.m_ItemCount > a_Item.m_ItemCount)
+ {
+ Item.m_ItemCount -= a_Item.m_ItemCount;
+ SendSlot( i + c_MainOffset );
+ return true;
+ }
+ else if(Item.m_ItemCount > 0 )
+ {
+ a_Item.m_ItemCount -= Item.m_ItemCount;
+ Item.Empty();
+ SendSlot( i + c_MainOffset );
+ }
+ }
+ }
+ }
+
+ if( a_Item.m_ItemCount == 0 )
+ return true;
+ else
+ return false;
+}
+
+cItem* cInventory::GetSlot( int a_SlotNum )
+{
+ if( a_SlotNum < 0 || a_SlotNum >= (short)c_NumSlots ) return 0;
+ return &m_Slots[a_SlotNum];
+}
+
+cItem* cInventory::GetFromHotBar( int a_SlotNum )
+{
+ if( a_SlotNum < 0 || a_SlotNum >= 9 ) return 0;
+ return &m_HotSlots[a_SlotNum];
+}
+
+void cInventory::SetEquippedSlot( int a_SlotNum )
+{
+ if( a_SlotNum < 0 || a_SlotNum >= 9 ) m_EquippedSlot = 0;
+ else m_EquippedSlot = (short)a_SlotNum;
+}
+
+cItem & cInventory::GetEquippedItem()
+{
+ cItem* Item = GetFromHotBar( m_EquippedSlot );
+ if( Item )
+ {
+ *m_EquippedItem = *Item;
+ return *Item;
+ }
+ else
+ {
+ m_EquippedItem->Empty();
+ }
+ return *m_EquippedItem;
+}
+
+void cInventory::SendWholeInventory( cClientHandle* a_Client )
+{
+ cPacket_WholeInventory Inventory( this );
+ a_Client->Send( Inventory );
+}
+
+void cInventory::SendSlot( int a_SlotNum )
+{
+ cItem* Item = GetSlot( a_SlotNum );
+ if( Item )
+ {
+ cPacket_InventorySlot InventorySlot;
+ InventorySlot.m_ItemCount = Item->m_ItemCount;
+ InventorySlot.m_ItemID = (short)Item->m_ItemID;
+ InventorySlot.m_ItemUses = (char)Item->m_ItemHealth;
+ InventorySlot.m_SlotNum = (short)a_SlotNum;
+ InventorySlot.m_WindowID = 0; // Inventory window ID
+ m_Owner->GetClientHandle()->Send( InventorySlot );
+ }
+}
+
+void cInventory::DrawInventory()
+{
+ printf("%i %i %i %i\n", m_ArmorSlots[0].m_ItemCount, m_ArmorSlots[1].m_ItemCount, m_CraftSlots[0].m_ItemCount, m_CraftSlots[1].m_ItemCount );
+ printf("%i %i %i %i\n", m_ArmorSlots[2].m_ItemCount, m_ArmorSlots[3].m_ItemCount, m_CraftSlots[2].m_ItemCount, m_CraftSlots[3].m_ItemCount );
+ for(int y = 0; y < 4; y++)
+ {
+ for(int x = 0; x < 9; x++)
+ {
+ printf("%i ", m_MainSlots[x + y*9].m_ItemCount );
+ }
+ printf("\n");
+ }
+}
+
+void cInventory::WriteToFile(FILE* a_File)
+{
+ for(unsigned int i = 0; i < c_NumSlots; i++)
+ {
+ cItem & Item = m_Slots[i];
+ fwrite( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File );
+ fwrite( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File );
+ fwrite( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File );
+ }
+}
+
+bool cInventory::LoadFromFile(FILE* a_File)
+{
+ for(unsigned int i = 0; i < c_NumSlots; i++)
+ {
+ cItem & Item = m_Slots[i];
+ if( fread( &Item.m_ItemID, sizeof(Item.m_ItemID), 1, a_File) != 1 ) { LOGERROR("ERROR READING INVENTORY FROM FILE"); return false; }
+ if( fread( &Item.m_ItemCount, sizeof(Item.m_ItemCount), 1, a_File) != 1 ) { LOGERROR("ERROR READING INVENTORY FROM FILE"); return false; }
+ if( fread( &Item.m_ItemHealth, sizeof(Item.m_ItemHealth), 1, a_File)!= 1 ) { LOGERROR("ERROR READING INVENTORY FROM FILE"); return false; }
+ }
+ return true;
+}
diff --git a/source/cInventory.h b/source/cInventory.h
new file mode 100644
index 000000000..19460142f
--- /dev/null
+++ b/source/cInventory.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "MemoryLeak.h"
+#include "cWindowOwner.h"
+#include "FileDefine.h"
+
+class cItem;
+class cClientHandle;
+class cPlayer;
+class cPacket_WindowClick;
+class cPacket_EntityEquipment;
+class cInventory //tolua_export
+ : public cWindowOwner
+{ //tolua_export
+public:
+ cInventory(cPlayer* a_Owner);
+ ~cInventory();
+
+ void Clear(); //tolua_export
+
+ cItem* GetSlotsForType( int a_Type );
+ int GetSlotCountForType( int a_Type );
+
+ bool AddItem( cItem & a_Item ); //tolua_export
+ bool RemoveItem( cItem & a_Item ); //tolua_export
+ void DrawInventory();
+
+ void WriteToFile(FILE* a_File);
+ bool LoadFromFile(FILE* a_File);
+
+ void SendWholeInventory( cClientHandle* a_Client );
+
+ cItem* GetSlot( int a_SlotNum ); //tolua_export
+ cItem* GetSlots() { return m_Slots; }
+ cItem* GetFromHotBar( int a_SlotNum ); //tolua_export
+
+ cItem & GetEquippedItem(); //tolua_export
+ void SetEquippedSlot( int a_SlotNum ); //tolua_export
+
+ void Clicked( cPacket_WindowClick* a_ClickPacket );
+
+ void SendSlot( int a_SlotNum ); //tolua_export
+
+ static const unsigned int c_NumSlots = 45;
+ static const unsigned int c_MainSlots = 27;
+ static const unsigned int c_HotSlots = 9;
+ static const unsigned int c_CraftSlots = 4;
+ static const unsigned int c_ArmorSlots = 4;
+
+ static const unsigned int c_CraftOffset = 0;
+ static const unsigned int c_ArmorOffset = 5;
+ static const unsigned int c_MainOffset = 9;
+ static const unsigned int c_HotOffset = 36;
+private:
+ bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 );
+
+ cItem* m_Slots;
+ cItem* m_MainSlots;
+ cItem* m_CraftSlots;
+ cItem* m_ArmorSlots;
+ cItem* m_HotSlots;
+
+ cItem* m_EquippedItem;
+ short m_EquippedSlot;
+
+ cPlayer* m_Owner;
+}; //tolua_export \ No newline at end of file
diff --git a/source/cItem.h b/source/cItem.h
new file mode 100644
index 000000000..edf3468ac
--- /dev/null
+++ b/source/cItem.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "Defines.h"
+#include "BlockID.h"
+
+class cItem //tolua_export
+{ //tolua_export
+public:
+ cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 ) //tolua_export
+ : m_ItemID ( a_ItemID )
+ , m_ItemCount ( a_ItemCount )
+ , m_ItemHealth ( a_ItemHealth )
+ { //tolua_export
+ if(!isValidItem( m_ItemID ) ) m_ItemID = E_ITEM_EMPTY;
+ } //tolua_export
+ void Empty() //tolua_export
+ { //tolua_export
+ m_ItemID = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemHealth = 0;
+ } //tolua_export
+ bool IsEmpty() //tolua_export
+ { //tolua_export
+ return (m_ItemID <= 0 || m_ItemCount <= 0);
+ } //tolua_export
+ bool Equals( cItem & a_Item ) //tolua_export
+ { //tolua_export
+ return ( (m_ItemID == a_Item.m_ItemID) && (m_ItemHealth == a_Item.m_ItemHealth) );
+ } //tolua_export
+ ENUM_ITEM_ID m_ItemID; //tolua_export
+ char m_ItemCount; //tolua_export
+ short m_ItemHealth; //tolua_export
+}; //tolua_export \ No newline at end of file
diff --git a/source/cLadder.h b/source/cLadder.h
new file mode 100644
index 000000000..be3964f10
--- /dev/null
+++ b/source/cLadder.h
@@ -0,0 +1,43 @@
+#pragma once
+
+class cLadder //tolua_export
+{ //tolua_export
+public:
+
+ static char 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:
+ break;
+ };
+ return 0x2;
+ } //tolua_export
+
+ static char MetaDataToDirection( char 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:
+ break;
+ };
+ return 0x2;
+ } //tolua_export
+
+}; //tolua_export \ No newline at end of file
diff --git a/source/cLog.cpp b/source/cLog.cpp
new file mode 100644
index 000000000..105916a2f
--- /dev/null
+++ b/source/cLog.cpp
@@ -0,0 +1,136 @@
+#include "cLog.h"
+#include <fstream>
+#include <ctime>
+#include <stdarg.h>
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <sys/stat.h> // for mkdir
+#include <sys/types.h>
+
+#define sprintf_s(buffer, buffer_size, stringbuffer, ...) (sprintf(buffer, stringbuffer, __VA_ARGS__))
+#define vsnprintf_s(buffer, buffer_size, maxcount, stringbuffer, ...) (vsnprintf(buffer, maxcount, stringbuffer, __VA_ARGS__))
+#endif
+
+#include <string>
+
+cLog* cLog::s_Log = NULL;
+
+cLog::cLog( const char* a_FileName )
+ : m_File(NULL)
+{
+ s_Log = this;
+
+ // create logs directory
+#ifdef _WIN32
+ {
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("logs", &Attrib);
+ }
+#else
+ {
+ mkdir("logs", S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+#endif
+
+ OpenLog( (std::string("logs/") + std::string(a_FileName)).c_str() );
+}
+
+cLog::~cLog()
+{
+ CloseLog();
+ s_Log = NULL;
+}
+
+cLog* cLog::GetInstance()
+{
+ if(s_Log)
+ return s_Log;
+
+ new cLog("log.txt");
+ return s_Log;
+}
+
+void cLog::CloseLog()
+{
+ if( m_File )
+ fclose (m_File);
+ m_File = 0;
+}
+
+void cLog::OpenLog( const char* a_FileName )
+{
+ if(m_File) fclose (m_File);
+ #ifdef _WIN32
+ fopen_s( &m_File, a_FileName, "a+" );
+ #else
+ m_File = fopen(a_FileName, "a+" );
+ #endif
+}
+
+void cLog::ClearLog()
+{
+ #ifdef _WIN32
+ if( fopen_s( &m_File, "log.txt", "w" ) == 0)
+ fclose (m_File);
+ #else
+ m_File = fopen("log.txt", "w" );
+ if( m_File )
+ fclose (m_File);
+ #endif
+ m_File = 0;
+}
+
+void cLog::Log(const char* a_Format, va_list argList )
+{
+ char c_Buffer[1024];
+
+ if( argList != 0 )
+ {
+ vsnprintf_s(c_Buffer, 1024, 1024, a_Format, argList );
+ }
+ else
+ {
+ sprintf_s( c_Buffer, 1024, "%s", a_Format );
+ }
+
+ time_t rawtime;
+ time ( &rawtime );
+#ifdef _WIN32
+ struct tm timeinfo;
+ localtime_s( &timeinfo, &rawtime );
+#else
+ struct tm* timeinfo;
+ timeinfo = localtime( &rawtime );
+#endif
+ char c_Buffer2[1024];
+#ifdef _WIN32
+ sprintf_s(c_Buffer2, 1024, "[%02d:%02d:%02d] %s\n", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, c_Buffer);
+#else
+ sprintf(c_Buffer2, "[%02d:%02d:%02d] %s\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, c_Buffer);
+#endif
+ if(m_File){
+ fputs(c_Buffer2, m_File);
+ fflush(m_File);
+ }
+
+
+ printf("%s", c_Buffer2 );
+}
+
+void cLog::Log(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ Log( a_Format, argList );
+ va_end(argList);
+}
+
+void cLog::SimpleLog(const char* a_String)
+{
+ Log("%s", a_String );
+}
diff --git a/source/cLog.h b/source/cLog.h
new file mode 100644
index 000000000..b2292ba7b
--- /dev/null
+++ b/source/cLog.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "MemoryLeak.h"
+#include "FileDefine.h"
+
+#ifndef _WIN32
+#include <stdarg.h>
+#endif
+
+class cLog { // tolua_export
+private:
+ FILE* m_File;
+ static cLog* s_Log;
+
+#ifdef _WIN32
+ typedef char* va_list;
+#endif
+public:
+ cLog( const char* a_FileName );
+ ~cLog();
+ void Log(const char* a_Format, va_list argList );
+ void Log(const char* a_Format, ...);
+ //tolua_begin
+ void SimpleLog(const char* a_String);
+ void OpenLog( const char* a_FileName );
+ void CloseLog();
+ void ClearLog();
+ static cLog* GetInstance();
+};
+//tolua_end
diff --git a/source/cLuaCommandBinder.cpp b/source/cLuaCommandBinder.cpp
new file mode 100644
index 000000000..a800513e1
--- /dev/null
+++ b/source/cLuaCommandBinder.cpp
@@ -0,0 +1,106 @@
+#include "cLuaCommandBinder.h"
+#include "cMCLogger.h"
+#include "cPlayer.h"
+#include "cPlugin_Lua.h"
+
+#include "tolua++.h"
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+extern bool report_errors(lua_State* lua, int status);
+
+cLuaCommandBinder::cLuaCommandBinder()
+{
+}
+
+cLuaCommandBinder::~cLuaCommandBinder()
+{
+}
+
+void cLuaCommandBinder::ClearBindings()
+{
+ m_BoundCommands.clear();
+}
+
+void cLuaCommandBinder::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( ) );
+ luaL_unref( itr->second.LuaState, LUA_REGISTRYINDEX, itr->second.Reference ); // unreference
+ CommandMap::iterator eraseme = itr;
+ ++itr;
+ m_BoundCommands.erase( eraseme );
+ continue;
+ }
+ ++itr;
+ }
+}
+
+bool cLuaCommandBinder::BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, lua_State * a_LuaState, int a_FunctionReference )
+{
+ 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() );
+ m_BoundCommands[ a_Command ] = BoundFunction( a_Plugin, a_LuaState, a_FunctionReference, a_Permission );
+ return true;
+}
+
+bool cLuaCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a_Player )
+{
+ std::vector<std::string> Split = StringSplit( a_Command, " ");
+ 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;
+ }
+ }
+
+ // For enabling 'self' in the function, it's kind of a hack I'm not sure this is the way to go
+ lua_pushvalue(func.LuaState, LUA_GLOBALSINDEX);
+ lua_pushstring(func.LuaState, "self");
+ tolua_pushusertype( func.LuaState, func.Plugin, "cPlugin" );
+ lua_rawset(func.LuaState, -3);
+ lua_pop(func.LuaState, 1);
+
+ LOGINFO("1. Stack size: %i", lua_gettop(func.LuaState) );
+ lua_rawgeti( func.LuaState, LUA_REGISTRYINDEX, func.Reference); // same as lua_getref()
+
+ // Push the split
+ LOGINFO("2. Stack size: %i", lua_gettop(func.LuaState) );
+ lua_createtable(func.LuaState, Split.size(), 0);
+ int newTable = lua_gettop(func.LuaState);
+ int index = 1;
+ std::vector<std::string>::const_iterator iter = Split.begin();
+ while(iter != Split.end()) {
+ tolua_pushstring( func.LuaState, (*iter).c_str() );
+ lua_rawseti(func.LuaState, newTable, index);
+ ++iter;
+ ++index;
+ }
+ LOGINFO("3. Stack size: %i", lua_gettop(func.LuaState) );
+ // Push player
+ tolua_pushusertype( func.LuaState, a_Player, "cPlayer" );
+ LOGINFO("Calling bound function! :D");
+ int s = lua_pcall(func.LuaState, 2, 1, 0);
+ if( report_errors( func.LuaState, s ) )
+ {
+ LOGINFO("error. Stack size: %i", lua_gettop(func.LuaState) );
+ return false;
+ }
+ bool RetVal = (tolua_toboolean(func.LuaState, -1, 0) > 0);
+ lua_pop(func.LuaState, 1); // Pop return value
+ LOGINFO("ok. Stack size: %i", lua_gettop(func.LuaState) );
+ return RetVal;
+ }
+ return false;
+}
diff --git a/source/cLuaCommandBinder.h b/source/cLuaCommandBinder.h
new file mode 100644
index 000000000..bafc16ee8
--- /dev/null
+++ b/source/cLuaCommandBinder.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <vector>
+#include <string>
+#include <map>
+
+struct lua_State;
+class cPlugin;
+class cPlayer;
+class cLuaCommandBinder
+{
+public:
+ cLuaCommandBinder();
+ ~cLuaCommandBinder();
+
+ 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, lua_State * a_LuaState, int a_FunctionReference );
+
+ void ClearBindings();
+ void RemoveBindingsForPlugin( cPlugin* a_Plugin );
+private:
+ struct BoundFunction
+ {
+ BoundFunction() : Plugin( 0 ), LuaState( 0 ), Reference( 0 ) {}
+ BoundFunction( cPlugin* a_Plugin, lua_State * a_LuaState, int a_Reference, const std::string & a_Permission ) : Plugin( a_Plugin ), LuaState( a_LuaState ), Reference( a_Reference ), Permission( a_Permission ) {}
+ cPlugin* Plugin;
+ lua_State* LuaState;
+ int Reference;
+ std::string Permission;
+ };
+
+ typedef std::map< std::string, BoundFunction > CommandMap;
+ CommandMap m_BoundCommands;
+
+};
diff --git a/source/cMCLogger.cpp b/source/cMCLogger.cpp
new file mode 100644
index 000000000..0c6d25df3
--- /dev/null
+++ b/source/cMCLogger.cpp
@@ -0,0 +1,155 @@
+#include "cMCLogger.h"
+#include "cLog.h"
+#include "cCriticalSection.h"
+
+#include <stdio.h>
+#include <cstdarg>
+#include <time.h>
+
+#ifndef _WIN32
+#define sprintf_s(buffer, buffer_size, stringbuffer, ...) (sprintf(buffer, stringbuffer, __VA_ARGS__))
+#else
+#include <Windows.h>
+#endif
+
+cMCLogger* cMCLogger::s_MCLogger = 0;
+
+cMCLogger* cMCLogger::GetInstance()
+{
+ return s_MCLogger;
+}
+
+cMCLogger::cMCLogger()
+{
+ m_CriticalSection = new cCriticalSection();
+ char c_Buffer[128];
+ sprintf_s(c_Buffer, 128, "LOG_%d.txt", (int)time(0) );
+ m_Log = new cLog(c_Buffer);
+ m_Log->Log("--- Started Log ---");
+
+ s_MCLogger = this;
+}
+
+cMCLogger::cMCLogger( char* a_File )
+{
+ m_CriticalSection = new cCriticalSection();
+ m_Log = new cLog( a_File );
+}
+
+cMCLogger::~cMCLogger()
+{
+ m_Log->Log("--- Stopped Log ---");
+ delete m_Log;
+ delete m_CriticalSection;
+ if( this == s_MCLogger )
+ s_MCLogger = 0;
+}
+
+void cMCLogger::LogSimple(const char* a_Text, int a_LogType /* = 0 */ )
+{
+ switch( a_LogType )
+ {
+ case 0:
+ Log(a_Text, 0);
+ break;
+ case 1:
+ Info(a_Text, 0);
+ break;
+ case 2:
+ Warn(a_Text, 0);
+ break;
+ case 3:
+ Error(a_Text, 0);
+ break;
+ default:
+ Log(a_Text, 0);
+ break;
+ }
+}
+
+void cMCLogger::Log(const char* a_Format, va_list a_ArgList)
+{
+ m_CriticalSection->Lock();
+ SetColor( 0x7 ); // 0x7 is default grey color
+ m_Log->Log( a_Format, a_ArgList );
+ m_CriticalSection->Unlock();
+}
+
+void cMCLogger::Info(const char* a_Format, va_list a_ArgList)
+{
+ m_CriticalSection->Lock();
+// for( int i = 0; i < 16; i++)
+// {
+// for( int j = 0; j < 16; j++ )
+// {
+// SetConsoleTextAttribute( hConsole, i | (j<<4) );
+// printf("0x%x", (i|j<<4));
+// }
+// printf("\n");
+// }
+
+ SetColor( 0xe ); // 0xe is yellow
+ m_Log->Log( a_Format, a_ArgList );
+ m_CriticalSection->Unlock();
+}
+
+void cMCLogger::Warn(const char* a_Format, va_list a_ArgList)
+{
+ m_CriticalSection->Lock();
+ SetColor( 0xc ); // 0xc is red
+ m_Log->Log( a_Format, a_ArgList );
+ m_CriticalSection->Unlock();
+}
+
+void cMCLogger::Error(const char* a_Format, va_list a_ArgList)
+{
+ m_CriticalSection->Lock();
+ SetColor( 0xc0 ); // 0xc0 is red bg and black text
+ m_Log->Log( a_Format, a_ArgList );
+ m_CriticalSection->Unlock();
+}
+
+void cMCLogger::SetColor( unsigned char a_Color )
+{
+#ifdef _WIN32
+ HANDLE hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
+ SetConsoleTextAttribute( hConsole, a_Color );
+#else
+ (void)a_Color;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// Global functions
+void LOG(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ cMCLogger::GetInstance()->Log( a_Format, argList );
+ va_end(argList);
+}
+
+void LOGINFO(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ cMCLogger::GetInstance()->Info( a_Format, argList );
+ va_end(argList);
+}
+
+void LOGWARN(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ cMCLogger::GetInstance()->Warn( a_Format, argList );
+ va_end(argList);
+}
+
+void LOGERROR(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ cMCLogger::GetInstance()->Error( a_Format, argList );
+ va_end(argList);
+}
diff --git a/source/cMCLogger.h b/source/cMCLogger.h
new file mode 100644
index 000000000..4bfae66f1
--- /dev/null
+++ b/source/cMCLogger.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#ifndef _WIN32
+#include <stdarg.h>
+#endif
+
+class cCriticalSection;
+class cLog;
+class cMCLogger //tolua_export
+{ //tolua_export
+private:
+#ifdef _WIN32
+ typedef char* va_list;
+#endif
+public: //tolua_export
+ cMCLogger();
+ cMCLogger( char* a_File ); //tolua_export
+ ~cMCLogger(); //tolua_export
+
+ void Log(const char* a_Format, va_list a_ArgList);
+ void Info(const char* a_Format, va_list a_ArgList);
+ void Warn(const char* a_Format, va_list a_ArgList);
+ void Error(const char* a_Format, va_list a_ArgList);
+
+ void LogSimple(const char* a_Text, int a_LogType = 0 ); //tolua_export
+
+ static cMCLogger* GetInstance();
+private:
+ void SetColor( unsigned char a_Color );
+
+ cCriticalSection* m_CriticalSection;
+ cLog* m_Log;
+ static cMCLogger* s_MCLogger;
+}; //tolua_export
+
+extern void LOG(const char* a_Format, ...);
+extern void LOGINFO(const char* a_Format, ...);
+extern void LOGWARN(const char* a_Format, ...);
+extern void LOGERROR(const char* a_Format, ...); \ No newline at end of file
diff --git a/source/cMakeDir.cpp b/source/cMakeDir.cpp
new file mode 100644
index 000000000..a4d62afdd
--- /dev/null
+++ b/source/cMakeDir.cpp
@@ -0,0 +1,24 @@
+#include "cMakeDir.h"
+
+#ifndef _WIN32
+//#include <cstring> // If something is missing, uncomment some of these!
+//#include <cstdlib>
+//#include <stdio.h>
+#include <sys/stat.h> // for mkdir
+//#include <sys/types.h>
+#else
+#include <Windows.h>
+#endif
+
+void cMakeDir::MakeDir( const char* a_Directory )
+{
+#ifdef _WIN32
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("world", &Attrib);
+#else
+ mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
+#endif
+} \ No newline at end of file
diff --git a/source/cMakeDir.h b/source/cMakeDir.h
new file mode 100644
index 000000000..378df2a36
--- /dev/null
+++ b/source/cMakeDir.h
@@ -0,0 +1,7 @@
+#pragma once
+
+class cMakeDir
+{
+public:
+ static void MakeDir( const char* a_Directory );
+}; \ No newline at end of file
diff --git a/source/cMonster.cpp b/source/cMonster.cpp
new file mode 100644
index 000000000..63ef1d862
--- /dev/null
+++ b/source/cMonster.cpp
@@ -0,0 +1,609 @@
+#include "cMonster.h"
+#include "cRoot.h"
+#include "cServer.h"
+#include "cClientHandle.h"
+#include "cWorld.h"
+#include "cMCLogger.h"
+#include "cChunk.h"
+#include "cPlayer.h"
+#include "BlockID.h"
+#include "Defines.h"
+
+#include "packets/cPacket_SpawnMob.h"
+#include "packets/cPacket_EntityLook.h"
+#include "packets/cPacket_TeleportEntity.h"
+#include "packets/cPacket_RelativeEntityMoveLook.h"
+#include "packets/cPacket_RelativeEntityMove.h"
+#include "packets/cPacket_Metadata.h"
+
+#include "Vector3f.h"
+#include "Vector3i.h"
+#include "Vector3d.h"
+
+#include "cTracer.h"
+#include "../iniFile/iniFile.h"
+
+#ifndef _WIN32
+#include <cstdlib> // rand
+#include <unistd.h>
+#include <string.h>
+#endif
+
+#include <string>
+
+
+cMonster::cMonster()
+ : m_Target(0)
+ , m_Destination( new Vector3f() )
+ , m_bMovingToDestination(false)
+ , m_Speed( new Vector3f() )
+ , m_DestinationTime( 0 )
+ , m_Gravity( -9.81 )
+ , m_bOnGround( false )
+ , m_DestroyTimer( 0 )
+ , m_Jump(0)
+ , m_MobType( 0 )
+ , m_EMState(IDLE)
+ , m_SightDistance(25)
+ ,m_SeePlayerInterval (0)
+ ,m_EMPersonality(AGGRESSIVE)
+ ,m_AttackDamage(1.0)
+ ,m_AttackRange(5.0)
+ ,m_AttackInterval(0)
+ ,m_AttackRate(3)
+ ,m_bPassiveAggressive(false)
+ ,idle_interval(0)
+ ,m_bBurnable(true)
+ ,m_EMMetaState(NORMAL)
+ ,m_FireDamageInterval(0)
+ ,m_BurnPeriod(0)
+{
+ LOG("cMonster::cMonster()");
+ LOG("In state: %s",GetState());
+ m_Health = 10;
+
+ int RandVal = rand() % 4;
+ if( RandVal == 0 )
+ m_MobType = 90; // Pig
+ else if( RandVal == 1 )
+ m_MobType = 91; // Sheep
+ else if( RandVal == 2 )
+ m_MobType = 92; // Cow
+ else
+ m_MobType = 93; // Hen
+}
+
+cMonster::~cMonster()
+{
+
+ LOG("cMonster::~cMonster()");
+ delete m_Destination;
+ delete m_Speed;
+}
+
+bool cMonster::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cMonster ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cMonster" ) == 0 ) return true;
+ return cPawn::IsA( a_EntityType );
+}
+
+void cMonster::SpawnOn( cClientHandle* a_Target )
+{
+ LOG("Spawn monster on client");
+ cPacket_SpawnMob Spawn;
+ Spawn.m_UniqueID = GetUniqueID();
+ Spawn.m_Type = m_MobType;
+ *Spawn.m_Pos = Vector3i((*m_Pos)*32);
+ Spawn.m_Yaw = 0;
+ Spawn.m_Pitch = 0;
+ Spawn.m_MetaDataSize = 1;
+ Spawn.m_MetaData = new char[Spawn.m_MetaDataSize];
+ Spawn.m_MetaData[0] = 0x7f; // not on fire/crouching/riding
+ //Spawn.m_MetaData[1] = 0x7f; // terminator
+ if( a_Target == 0 )
+ {
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ Chunk->Broadcast( Spawn );
+ }
+ else
+ {
+ a_Target->Send( Spawn );
+ }
+}
+
+void cMonster::MoveToPosition( const Vector3f & a_Position )
+{
+ m_bMovingToDestination = true;
+
+ *m_Destination = a_Position;
+}
+
+bool cMonster::ReachedDestination()
+{
+ Vector3f Distance = (*m_Destination) - Vector3f( m_Pos );
+ if( Distance.SqrLength() < 2.f )
+ return true;
+
+ return false;
+}
+
+void cMonster::Tick(float a_Dt)
+{
+ if( m_Health <= 0 )
+ {
+ m_DestroyTimer += a_Dt/1000;
+ if( m_DestroyTimer > 1 )
+ {
+ Destroy();
+ }
+ return;
+ }
+
+ //a_Dt/=1000;
+ a_Dt/=1000;
+
+ if( m_bMovingToDestination )
+ {
+ Vector3f Pos( m_Pos );
+ Vector3f Distance = *m_Destination - Pos;
+ if( !ReachedDestination() )
+ {
+ Distance.y = 0;
+ Distance.Normalize();
+ Distance*=3;
+ m_Speed->x = Distance.x;
+ m_Speed->z = Distance.z;
+ }
+ else
+ {
+ m_bMovingToDestination = false;
+ }
+
+ if( m_Speed->SqrLength() > 0.f )
+ {
+ if( m_bOnGround )
+ {
+ Vector3f NormSpeed = m_Speed->NormalizeCopy();
+ Vector3f NextBlock = Vector3f( *m_Pos ) + NormSpeed;
+ double NextHeight = (double)cRoot::Get()->GetWorld()->GetHeight( (int)NextBlock.x, (int)NextBlock.z );
+ if( NextHeight > m_Pos->y - 1.2 && NextHeight - m_Pos->y < 2.5 )
+ {
+ m_bOnGround = false;
+ m_Speed->y = 7.f; // Jump!!
+ }
+ }
+ }
+ }
+
+ HandlePhysics( a_Dt );
+
+ ReplicateMovement();
+
+ Vector3f Distance = *m_Destination - Vector3f( m_Pos );
+ if( Distance.SqrLength() > 0.1f )
+ {
+ float Rotation, Pitch;
+ Distance.Normalize();
+ VectorToEuler( Distance.x, Distance.y, Distance.z, Rotation, Pitch );
+ SetRotation( Rotation );
+ SetPitch( Pitch );
+ }
+
+ CheckMetaDataBurn(); //Check to see if Enemy should burn based on block they are on
+
+ if(m_EMMetaState == BURNING) {
+ InStateBurning(a_Dt);
+ }
+
+ if(m_EMState == IDLE) { //If enemy passive we ignore checks for player visibility
+ InStateIdle(a_Dt);
+ }
+
+ if(m_EMState == CHASING) { //If we do not see a player anymore skip chasing action
+ InStateChasing(a_Dt);
+ }
+
+ if(m_EMState == ESCAPING) {
+ InStateEscaping(a_Dt);
+ }
+
+ m_SeePlayerInterval += a_Dt;
+ if(m_SeePlayerInterval > 1) {
+ int rem = rand()%3 + 1; //check most of the time but miss occasionally
+ //LOG("See Player Interval: %3.3f",m_SeePlayerInterval);
+ m_SeePlayerInterval = 0.0;
+ if(rem >= 2) {
+ if(m_EMState == IDLE && m_EMPersonality != PASSIVE) {
+ CheckEventSeePlayer();
+ return;
+ }
+ if(m_EMState == CHASING || m_EMState == ESCAPING){
+ CheckEventLostPlayer();
+ return;
+ }
+ }
+ }
+
+
+}
+
+void cMonster::ReplicateMovement()
+{
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( !InChunk ) return;
+
+ if(m_bDirtyOrientation && !m_bDirtyPosition)
+ {
+ cPacket_EntityLook EntityLook( this );
+ InChunk->Broadcast( EntityLook );
+ m_bDirtyOrientation = false;
+ }
+ if( m_bDirtyPosition )
+ {
+
+ float DiffX = (float)(GetPosX() - m_LastPosX );
+ float DiffY = (float)(GetPosY() - m_LastPosY );
+ float DiffZ = (float)(GetPosZ() - m_LastPosZ );
+ float SqrDist = DiffX*DiffX + DiffY*DiffY + DiffZ*DiffZ;
+ if( SqrDist > 4*4 // 4 blocks is max Relative Move
+ || cWorld::GetTime() - m_TimeLastTeleportPacket > 2 ) // Send an absolute position every 2 seconds
+ {
+ //LOG("Teleported %f", sqrtf(SqrDist) );
+ cPacket_TeleportEntity TeleportEntity( this );
+ InChunk->Broadcast( TeleportEntity );
+ m_TimeLastTeleportPacket = cWorld::GetTime();
+ }
+ else
+ { // Relative move sucks balls! It's always wrong wtf!
+ if( m_bDirtyOrientation )
+ {
+ cPacket_RelativeEntityMoveLook RelativeEntityMoveLook;
+ RelativeEntityMoveLook.m_UniqueID = GetUniqueID();
+ RelativeEntityMoveLook.m_MoveX = (char)(DiffX*32);
+ RelativeEntityMoveLook.m_MoveY = (char)(DiffY*32);
+ RelativeEntityMoveLook.m_MoveZ = (char)(DiffZ*32);
+ RelativeEntityMoveLook.m_Yaw = (char)((GetRotation()/360.f)*256);
+ RelativeEntityMoveLook.m_Pitch = (char)((GetPitch()/360.f)*256);
+ InChunk->Broadcast( RelativeEntityMoveLook );
+ }
+ else
+ {
+ cPacket_RelativeEntityMove RelativeEntityMove;
+ RelativeEntityMove.m_UniqueID = GetUniqueID();
+ RelativeEntityMove.m_MoveX = (char)(DiffX*32);
+ RelativeEntityMove.m_MoveY = (char)(DiffY*32);
+ RelativeEntityMove.m_MoveZ = (char)(DiffZ*32);
+ InChunk->Broadcast( RelativeEntityMove );
+ }
+ }
+ m_LastPosX = GetPosX();
+ m_LastPosY = GetPosY();
+ m_LastPosZ = GetPosZ();
+ m_bDirtyPosition = false;
+ }
+}
+
+void cMonster::HandlePhysics(float a_Dt)
+{
+ if( m_bOnGround ) // check if it's still on the ground
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ if( World->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z ) == E_BLOCK_AIR )
+ {
+ m_bOnGround = false;
+ }
+ if( World->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z ) != E_BLOCK_AIR ) // If in ground itself, push it out
+ {
+ m_bOnGround = true;
+ m_Pos->y += 0.2;
+ m_bDirtyPosition = true;
+ }
+ m_Speed->x *= 0.7f/(1+a_Dt);
+ if( fabs(m_Speed->x) < 0.05 ) m_Speed->x = 0;
+ m_Speed->z *= 0.7f/(1+a_Dt);
+ if( fabs(m_Speed->z) < 0.05 ) m_Speed->z = 0;
+ }
+
+ if( !m_bOnGround )
+ {
+ float Gravity = -9.81f*a_Dt;
+ m_Speed->y += Gravity;
+ }
+
+ if( m_Speed->SqrLength() > 0.f )
+ {
+ cTracer Tracer( cRoot::Get()->GetWorld() );
+ int Ret = Tracer.Trace( *m_Pos, *m_Speed, 2 );
+ if( Ret ) // Oh noez! we hit something
+ {
+ // Set to hit position
+ if( (*Tracer.RealHit - Vector3f(*m_Pos)).SqrLength() <= ( *m_Speed * a_Dt ).SqrLength() )
+ {
+ if( Ret == 1 )
+ {
+
+ if( Tracer.HitNormal->x != 0.f ) m_Speed->x = 0.f;
+ if( Tracer.HitNormal->y != 0.f ) m_Speed->y = 0.f;
+ if( Tracer.HitNormal->z != 0.f ) m_Speed->z = 0.f;
+
+ if( Tracer.HitNormal->y > 0 ) // means on ground
+ {
+ m_bOnGround = true;
+ }
+ }
+ *m_Pos = Tracer.RealHit;
+ *m_Pos += *Tracer.HitNormal * 0.2;
+
+ }
+ else
+ *m_Pos += *m_Speed*a_Dt;
+ }
+ else
+ { // We didn't hit anything, so move =]
+ *m_Pos += *m_Speed*a_Dt;
+ }
+
+ m_bDirtyPosition = true;
+ }
+}
+
+void cMonster::TakeDamage( int a_Damage, cEntity* a_Instigator )
+{
+ cPawn::TakeDamage( a_Damage, a_Instigator );
+ m_Target = a_Instigator;
+ AddReference( m_Target );
+ if(m_EMPersonality == AGGRESSIVE) {
+ m_EMState = CHASING;
+ }
+ if(m_EMPersonality == COWARDLY || m_EMPersonality == PASSIVE) {
+ //m_bPassiveAggressive can be set so if the monster based on time of day for example
+ //so the monster will only attack if provoked
+ m_EMState = (m_bPassiveAggressive)? CHASING : ESCAPING;
+ }
+ //LOG("Take damage");
+}
+
+void cMonster::KilledBy( cEntity* a_Killer )
+{
+ cPawn::KilledBy( a_Killer );
+ m_DestroyTimer = 0;
+}
+
+//----State Logic
+
+const char *cMonster::GetState() {
+ switch(m_EMState) {
+ case IDLE:
+ return "Idle";
+ break;
+ case ATTACKING:
+ return "Attacking";
+ break;
+ case CHASING:
+ return "Chasing";
+ break;
+ default:
+ return "Unknown";
+ break;
+ }
+}
+
+//for debugging
+void cMonster::SetState(const char* a_str) {
+ std::string str = a_str;
+ if(str.compare("Idle") == 0 ) {
+ m_EMState = IDLE;
+ } else if(str.compare("Attacking") == 0 ) {
+ m_EMState = ATTACKING;
+ } else if(str.compare("Chasing") == 0 ) {
+ m_EMState = CHASING;
+ } else {
+ printf("Invalid State");
+ }
+}
+
+//Checks to see if EventSeePlayer should be fired
+//monster sez: Do I see the player
+void cMonster::CheckEventSeePlayer() {
+
+ //LOG("Checking if I see any players");
+ cMonster::ListClosePlayers(this);
+
+}
+
+void cMonster::CheckEventLostPlayer() {
+ Vector3f pos;
+ cTracer LineOfSight(cRoot::Get()->GetWorld() );
+
+ //LOG("Checking if I lost my enemy");
+ if(m_Target != 0) {
+ pos = m_Target->GetPosition();
+ if((pos - *m_Pos).Length() > m_SightDistance || LineOfSight.Trace(*m_Pos,(pos - *m_Pos), (int)(pos - *m_Pos).Length())){
+ //LOG("Losing Player: %5.5f",(pos - *m_Pos).Length());
+ EventLosePlayer();
+ }
+ } else {
+ LOG("Enemy went poof");
+ EventLosePlayer();
+ }
+}
+
+//What to do if player is seen
+//default to change state to chasing
+void cMonster::EventSeePlayer(cEntity *a_SeenPlayer) {
+ m_Target = a_SeenPlayer;
+ AddReference( m_Target );
+ if(m_EMPersonality == AGGRESSIVE) {
+ m_EMState = CHASING;
+ }
+ if(m_EMPersonality == COWARDLY) {
+ m_EMState = ESCAPING;
+ }
+ //LOG("Saw Player: %s",GetState());
+}
+
+void cMonster::EventLosePlayer(){
+ Dereference(m_Target);
+ m_Target = 0;
+ //LOG("Lost Player");
+ m_EMState = IDLE;
+}
+
+//What to do if in Idle State
+void cMonster::InStateIdle(float a_Dt) {
+ idle_interval += a_Dt;
+ if(idle_interval > 1) { //at this interval the results are predictable
+ int rem = rand()%6 + 1;
+ //LOG("Moving: int: %3.3f rem: %i",idle_interval,rem);
+ idle_interval = 0;
+ Vector3f Dist;
+ Dist.x = (float)((rand()%11)-5);
+ Dist.z = (float)((rand()%11)-5);
+ if( Dist.SqrLength() > 2 && rem >= 3)
+ {
+ m_Destination->x = (float)(m_Pos->x + Dist.x);
+ m_Destination->z = (float)(m_Pos->z + Dist.z);
+ m_Destination->y = (float)cRoot::Get()->GetWorld()->GetHeight( (int)m_Destination->x, (int)m_Destination->z ) + 1.2f;
+ MoveToPosition( *m_Destination );
+ }
+ }
+}
+
+//What to do if On fire
+void cMonster::InStateBurning(float a_Dt) {
+ m_FireDamageInterval += a_Dt;
+ char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ if(m_FireDamageInterval > 1) {
+
+ m_FireDamageInterval = 0;
+ int rem = rand()%3 + 1; //Burn most of the time
+ if(rem >= 2) {
+ //printf("OUCH burning!!!\n");
+ TakeDamage(1, this);
+ }
+ m_BurnPeriod++;
+ if(block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
+ || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)
+ m_BurnPeriod = 0;
+
+ if(m_BurnPeriod > 5) {
+
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ m_EMMetaState = NORMAL;
+ cPacket_Metadata md(NORMAL, GetUniqueID());
+ //md.m_UniqueID = GetUniqueID();
+ InChunk->Broadcast(md);
+ m_BurnPeriod = 0;
+
+ }
+ }
+
+}
+
+//What to do if in Chasing State
+//This state should always be defined in each child class
+void cMonster::InStateChasing(float a_Dt) {
+ (void)a_Dt;
+}
+
+//What to do if in Escaping State
+void cMonster::InStateEscaping(float a_Dt) {
+ (void)a_Dt;
+ if(m_Target) {
+ Vector3d newloc = *m_Pos;
+ newloc.x = (m_Target->GetPosition().x < newloc.x)? (newloc.x + m_SightDistance): (newloc.x - m_SightDistance);
+ newloc.z = (m_Target->GetPosition().z < newloc.z)? (newloc.z + m_SightDistance): (newloc.z - m_SightDistance);
+ MoveToPosition(newloc);
+ } else {
+ m_EMState = IDLE; //this shouldnt be required but just to be safe
+ }
+}
+
+
+//Do attack here
+//a_Dt is passed so we can set attack rate
+void cMonster::Attack(float a_Dt) {
+ m_AttackInterval += a_Dt*m_AttackRate;
+ if(m_Target != 0 && m_AttackInterval > 3.0) { //Setting this higher gives us more wiggle room for attackrate
+ //LOG("ATTACK!");
+ m_AttackInterval = 0.0;
+ ((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage,this);
+ }
+}
+//----Change Entity MetaData
+void cMonster::CheckMetaDataBurn() {
+ char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ if(m_bBurnable && m_EMMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
+ || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if(!InChunk)
+ return;
+ //printf("I should burn");
+ m_EMMetaState = BURNING;
+ cPacket_Metadata md(BURNING,GetUniqueID());
+ InChunk->Broadcast(md);
+ }
+}
+
+//----Debug
+
+void cMonster::ListMonsters() {
+
+ cWorld::EntityList Entities = cRoot::Get()->GetWorld()->GetEntities();
+ cRoot::Get()->GetWorld()->LockEntities();
+ for( cWorld::EntityList::iterator itr = Entities.begin(); itr != Entities.end(); ++itr) {
+ if((*itr)->GetEntityType() == cEntity::E_ENTITY){
+ LOG("In state: %s type: %i attack rate: %i",((cMonster *)(*itr))->GetState(), ((cMonster *)(*itr))->GetMobType(),((cMonster *)(*itr))->GetAttackRate());
+
+ }
+ }
+ cRoot::Get()->GetWorld()->UnlockEntities();
+}
+
+//Checks for Players close by and if they are visible
+void cMonster::ListClosePlayers(cMonster *m) {
+ int tries = 0;
+ cTracer LineOfSight(cRoot::Get()->GetWorld() );
+ cWorld::EntityList Entities = cRoot::Get()->GetWorld()->GetEntities();
+ for( cWorld::EntityList::iterator itr = Entities.begin(); itr != Entities.end(); ++itr) {
+ tries++;
+ if((*itr)->GetEntityType() == cEntity::E_PLAYER){
+ Vector3f pos = (*itr)->GetPosition();
+ if((pos - *(m->m_Pos)).Length() <= m->m_SightDistance){
+ if(!LineOfSight.Trace(*(m->m_Pos),(pos - *(m->m_Pos)),(int)(pos - *(m->m_Pos)).Length())){
+ //LOG("I SEE PLAYER !!!!!!!!!!!!!!!!!");
+ m->EventSeePlayer(*itr);
+ return; //get the first one in sight later we can reiterate and check
+ //for the closest out of all that match and make it more realistic
+
+ }
+ }
+
+ }
+ if(tries > 100) {
+ //LOG("I Give Up");
+ m->EventLosePlayer();
+ return;
+ }
+ }
+}
+
+void cMonster::GetMonsterConfig(const char* pm_name) {
+ (void)pm_name;
+}
+
+void cMonster::SetAttackRate(int ar) {
+ m_AttackRate = (float)ar;
+}
+void cMonster::SetAttackRange(float ar) {
+ m_AttackRange = ar;
+}
+void cMonster::SetAttackDamage(float ad) {
+ m_AttackDamage = ad;
+}
+void cMonster::SetSightDistance(float sd) {
+ m_SightDistance = sd;
+}
diff --git a/source/cMonster.h b/source/cMonster.h
new file mode 100644
index 000000000..b0cb19543
--- /dev/null
+++ b/source/cMonster.h
@@ -0,0 +1,85 @@
+#pragma once
+#include "cPawn.h"
+
+class Vector3f;
+class cClientHandle;
+class cMonster : public cPawn //tolua_export
+{ //tolua_export
+public:
+
+ cMonster();
+ virtual ~cMonster();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void SpawnOn( cClientHandle* a_Target );
+
+ virtual void Tick(float a_Dt);
+ virtual void HandlePhysics(float a_Dt);
+ virtual void ReplicateMovement();
+
+ virtual void TakeDamage( int a_Damage, cEntity* a_Instigator );
+ virtual void KilledBy( cEntity* a_Killer );
+
+ virtual void MoveToPosition( const Vector3f & a_Position );
+ virtual bool ReachedDestination();
+
+ const char *GetState();
+ void SetState(const char* str);
+ static void ListMonsters();
+
+ virtual void CheckEventSeePlayer();
+ virtual void EventSeePlayer(cEntity *);
+ float m_SightDistance;
+ static void ListClosePlayers(cMonster *);
+ virtual void GetMonsterConfig(const char* pm_name);
+ virtual void EventLosePlayer();
+ virtual void CheckEventLostPlayer();
+
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ virtual void InStateBurning(float a_Dt);
+
+ virtual void Attack(float a_Dt);
+ int GetMobType() {return m_MobType;}
+ int GetAttackRate(){return (int)m_AttackRate;}
+ void SetAttackRate(int ar);
+ void SetAttackRange(float ar);
+ void SetAttackDamage(float ad);
+ void SetSightDistance(float sd);
+ virtual void CheckMetaDataBurn();
+
+ enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
+ enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
+ enum MMetaState{NORMAL,BURNING,CROUCHED,RIDING} m_EMMetaState;
+
+protected:
+
+ cEntity* m_Target;
+ float m_AttackRate;
+ float idle_interval;
+
+ Vector3f* m_Destination;
+ bool m_bMovingToDestination;
+ bool m_bPassiveAggressive;
+ bool m_bBurnable;
+
+ Vector3f* m_Speed;
+ float m_DestinationTime;
+
+ float m_Gravity;
+ bool m_bOnGround;
+
+ float m_DestroyTimer;
+ float m_Jump;
+
+ char m_MobType;
+
+ float m_SeePlayerInterval;
+ float m_AttackDamage;
+ float m_AttackRange;
+ float m_AttackInterval;
+ float m_FireDamageInterval;
+ float m_BurnPeriod;
+}; //tolua_export
diff --git a/source/cMonsterConfig.cpp b/source/cMonsterConfig.cpp
new file mode 100644
index 000000000..4d309ec06
--- /dev/null
+++ b/source/cMonsterConfig.cpp
@@ -0,0 +1,93 @@
+#include "cMonsterConfig.h"
+#include "cMonster.h"
+#include "../iniFile/iniFile.h"
+#include <list>
+#include <vector>
+#include <cstdio>
+//#include "../source/cprintf.h"
+#include <string>
+using namespace std;
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+struct cMonsterConfig::sAttributesStruct
+{
+ string m_name;
+ float m_SightDistance;
+ float m_AttackDamage;
+ float m_AttackRange;
+ float m_AttackRate;
+};
+
+struct cMonsterConfig::sMonsterConfigState
+{
+ int TypeCount;
+ string MonsterTypes;
+ list< sAttributesStruct > AttributesList;
+};
+
+cMonsterConfig::cMonsterConfig(int TypeC)
+ : m_pState( new sMonsterConfigState )
+{
+ m_pState->TypeCount = TypeC;
+ Initialize();
+}
+
+cMonsterConfig::~cMonsterConfig() {
+ delete m_pState;
+}
+
+void cMonsterConfig::Initialize() {
+
+ sAttributesStruct Attributes;
+ cIniFile SettingsIniFile("settings.ini");
+ cIniFile MonstersIniFile("monsters.ini");
+
+ if(!SettingsIniFile.ReadFile() || !MonstersIniFile.ReadFile()) {
+ printf("Error: Must have both settings.ini and monsters.ini to configure attributes\n\tusing default attributes \n");
+ return;
+ }
+
+ m_pState->MonsterTypes = SettingsIniFile.GetValue("Monsters","Types","");
+
+ if( m_pState->MonsterTypes.empty() ) {
+ printf("Error: No Monster types listed in config file, using default attributes \n");
+ return;
+ }
+
+ vector<string> SplitList = StringSplit(m_pState->MonsterTypes,",");
+ for(unsigned int i = 0; i < SplitList.size(); ++i) {
+ if(!SplitList[i].empty()) {
+ printf("Getting Attributes for: %s \n",SplitList[i].c_str());
+ Attributes.m_name = SplitList[i].c_str();
+ Attributes.m_AttackDamage = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackDamage",0);
+ printf("Got AttackDamage: %3.3f \n",Attributes.m_AttackDamage);
+ Attributes.m_AttackRange = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRange",0);
+ printf("Got AttackRange: %3.3f \n",Attributes.m_AttackRange);
+ Attributes.m_SightDistance = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"SightDistance",0);
+ printf("Got SightDistance: %3.3f \n",Attributes.m_SightDistance);
+ Attributes.m_AttackRate = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRate",0);
+ printf("Got AttackRate: %3.3f \n",Attributes.m_AttackRate);
+ m_pState->AttributesList.push_front(Attributes);
+ }
+ }
+
+}
+
+void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
+{
+ list<sAttributesStruct>::iterator itr;
+ for(itr = m_pState->AttributesList.begin(); itr != m_pState->AttributesList.end(); ++itr) {
+ if(itr->m_name.compare(n) == 0) {
+ //printf("found my attribs: %s :\n",itr->m_name.c_str());
+ m->SetAttackDamage(itr->m_AttackDamage);
+ m->SetAttackRange(itr->m_AttackRange);
+ m->SetSightDistance(itr->m_SightDistance);
+ m->SetAttackRate((int)itr->m_AttackRate);
+ }
+ }
+}
+
+cMonsterConfig *cMonsterConfig::Get() {
+ return this;
+}
diff --git a/source/cMonsterConfig.h b/source/cMonsterConfig.h
new file mode 100644
index 000000000..12b03d8e1
--- /dev/null
+++ b/source/cMonsterConfig.h
@@ -0,0 +1,18 @@
+#pragma once
+
+class cMonster;
+class cMonsterConfig
+{
+public:
+ cMonsterConfig(int TypeC);
+ ~cMonsterConfig();
+ cMonsterConfig *Get();
+
+ void AssignAttributes(cMonster *m, const char* n);
+
+private:
+ struct sAttributesStruct;
+ struct sMonsterConfigState;
+ sMonsterConfigState* m_pState;
+ void Initialize();
+}; \ No newline at end of file
diff --git a/source/cNoise.cpp b/source/cNoise.cpp
new file mode 100644
index 000000000..1d321c089
--- /dev/null
+++ b/source/cNoise.cpp
@@ -0,0 +1,253 @@
+#include "cNoise.h"
+#include <math.h>
+
+#define FAST_FLOOR( x ) ( (x) < 0 ? ((int)x)-1 : ((int)x) )
+
+cNoise::cNoise( unsigned int a_Seed )
+ : m_Seed( a_Seed )
+{
+}
+
+
+cNoise::~cNoise()
+{
+}
+
+/****************
+ * Random value generator
+ **/
+float cNoise::IntNoise( int a_X ) const
+{
+ int x = ((a_X*m_Seed)<<13) ^ a_X;
+ return ( 1.0f - ( (x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f);
+}
+
+float cNoise::IntNoise2D( int a_X, int a_Y ) const
+{
+ int n = a_X + a_Y * 57 + m_Seed*57*57;
+ n = (n<<13) ^ n;
+ return ( 1.0f - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f);
+}
+
+float cNoise::IntNoise3D( int a_X, int a_Y, int a_Z ) const
+{
+ int n = a_X + a_Y * 57 + a_Z * 57*57 + m_Seed*57*57*57;
+ n = (n<<13) ^ n;
+ return ( 1.0f - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f);
+}
+
+/***************
+ * Interpolated (and 1 smoothed) noise in 1-dimension
+ **/
+float cNoise::LinearNoise1D( float a_X ) const
+{
+ int BaseX = FAST_FLOOR( a_X );
+ float FracX = (a_X) - BaseX;
+ return LinearInterpolate( IntNoise( BaseX ), IntNoise( BaseX+1 ), FracX);
+}
+
+float cNoise::CosineNoise1D( float a_X ) const
+{
+ int BaseX = FAST_FLOOR( a_X );
+ float FracX = (a_X) - BaseX;
+ return CosineInterpolate( IntNoise( BaseX ), IntNoise( BaseX+1 ), FracX);
+}
+
+float cNoise::CubicNoise1D( float a_X ) const
+{
+ int BaseX = FAST_FLOOR( a_X );
+ float FracX = (a_X) - BaseX;
+ return CubicInterpolate( IntNoise( BaseX-1 ), IntNoise( BaseX ), IntNoise( BaseX+1 ), IntNoise( BaseX+2 ), FracX);
+}
+
+float cNoise::SmoothNoise1D( int a_X ) const
+{
+ return IntNoise(a_X)/2 + IntNoise(a_X-1)/4 + IntNoise(a_X+1)/4;
+}
+
+/******************
+ * Interpolated (and 1 smoothed) noise in 2-dimensions
+ **/
+float cNoise::LinearNoise2D( float a_X, float a_Y ) const
+{
+ const int BaseX = FAST_FLOOR( a_X );
+ const int BaseY = FAST_FLOOR( a_Y );
+
+ const float tl = IntNoise2D( BaseX, BaseY );
+ const float tr = IntNoise2D( BaseX+1, BaseY );
+ const float bl = IntNoise2D( BaseX, BaseY+1 );
+ const float br = IntNoise2D( BaseX+1, BaseY+1 );
+
+ const float FracX = (a_X) - BaseX;
+ const float interp1 = LinearInterpolate( tl, tr, FracX );
+ const float interp2 = LinearInterpolate( bl, br, FracX );
+
+ const float FracY = (a_Y) - BaseY;
+ return LinearInterpolate( interp1, interp2, FracY );
+}
+
+float cNoise::CosineNoise2D( float a_X, float a_Y ) const
+{
+ const int BaseX = FAST_FLOOR( a_X );
+ const int BaseY = FAST_FLOOR( a_Y );
+
+ const float tl = IntNoise2D( BaseX, BaseY );
+ const float tr = IntNoise2D( BaseX+1, BaseY );
+ const float bl = IntNoise2D( BaseX, BaseY+1 );
+ const float br = IntNoise2D( BaseX+1, BaseY+1 );
+
+ const float FracX = (a_X) - BaseX;
+ const float interp1 = CosineInterpolate( tl, tr, FracX );
+ const float interp2 = CosineInterpolate( bl, br, FracX );
+
+ const float FracY = (a_Y) - BaseY;
+ return CosineInterpolate( interp1, interp2, FracY );
+}
+
+float cNoise::CubicNoise2D( float a_X, float a_Y ) const
+{
+ const int BaseX = FAST_FLOOR( a_X );
+ const int BaseY = FAST_FLOOR( a_Y );
+
+ const float points[4][4] = {
+
+ IntNoise2D( BaseX-1, BaseY-1 ), IntNoise2D( BaseX, BaseY-1 ), IntNoise2D( BaseX+1, BaseY-1 ), IntNoise2D( BaseX+2, BaseY-1 ),
+ IntNoise2D( BaseX-1, BaseY ), IntNoise2D( BaseX, BaseY ), IntNoise2D( BaseX+1, BaseY ), IntNoise2D( BaseX+2, BaseY ),
+ IntNoise2D( BaseX-1, BaseY+1 ), IntNoise2D( BaseX, BaseY+1 ), IntNoise2D( BaseX+1, BaseY+1 ), IntNoise2D( BaseX+2, BaseY+1 ),
+ IntNoise2D( BaseX-1, BaseY+2 ), IntNoise2D( BaseX, BaseY+2 ), IntNoise2D( BaseX+1, BaseY+2 ), IntNoise2D( BaseX+2, BaseY+2 ),
+
+ };
+
+ const float FracX = (a_X) - BaseX;
+ const float interp1 = CubicInterpolate( points[0][0], points[0][1], points[0][2], points[0][3], FracX );
+ const float interp2 = CubicInterpolate( points[1][0], points[1][1], points[1][2], points[1][3], FracX );
+ const float interp3 = CubicInterpolate( points[2][0], points[2][1], points[2][2], points[2][3], FracX );
+ const float interp4 = CubicInterpolate( points[3][0], points[3][1], points[3][2], points[3][3], FracX );
+
+
+ const float FracY = (a_Y) - BaseY;
+ return CubicInterpolate( interp1, interp2, interp3, interp4, FracY );
+}
+
+/******************
+ * Interpolated (and 1 smoothed) noise in 3-dimensions
+ **/
+float cNoise::CosineNoise3D( float a_X, float a_Y, float a_Z ) const
+{
+ const int BaseX = FAST_FLOOR( a_X );
+ const int BaseY = FAST_FLOOR( a_Y );
+ const int BaseZ = FAST_FLOOR( a_Z );
+
+ const float ftl = IntNoise3D( BaseX, BaseY, BaseZ );
+ const float ftr = IntNoise3D( BaseX+1, BaseY, BaseZ );
+ const float fbl = IntNoise3D( BaseX, BaseY+1, BaseZ );
+ const float fbr = IntNoise3D( BaseX+1, BaseY+1, BaseZ );
+
+ const float btl = IntNoise3D( BaseX, BaseY, BaseZ+1 );
+ const float btr = IntNoise3D( BaseX+1, BaseY, BaseZ+1 );
+ const float bbl = IntNoise3D( BaseX, BaseY+1, BaseZ+1 );
+ const float bbr = IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 );
+
+ const float FracX = (a_X) - BaseX;
+ const float finterp1 = CosineInterpolate( ftl, ftr, FracX );
+ const float finterp2 = CosineInterpolate( fbl, fbr, FracX );
+ const float binterp1 = CosineInterpolate( btl, btr, FracX );
+ const float binterp2 = CosineInterpolate( bbl, bbr, FracX );
+
+ const float FracY = (a_Y) - BaseY;
+ const float interp1 = CosineInterpolate( finterp1, finterp2, FracY );
+ const float interp2 = CosineInterpolate( binterp1, binterp2, FracY );
+
+ const float FracZ = (a_Z) - BaseZ;
+ return CosineInterpolate( interp1, interp2, FracZ );
+}
+
+float cNoise::CubicNoise3D( float a_X, float a_Y, float a_Z ) const
+{
+ const int BaseX = FAST_FLOOR( a_X );
+ const int BaseY = FAST_FLOOR( a_Y );
+ const int BaseZ = FAST_FLOOR( a_Z );
+
+ const float points1[4][4] = {
+ IntNoise3D( BaseX-1, BaseY-1, BaseZ-1 ), IntNoise3D( BaseX, BaseY-1, BaseZ-1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ-1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ-1 ),
+ IntNoise3D( BaseX-1, BaseY, BaseZ-1 ), IntNoise3D( BaseX, BaseY, BaseZ-1 ), IntNoise3D( BaseX+1, BaseY, BaseZ-1 ), IntNoise3D( BaseX+2, BaseY, BaseZ-1 ),
+ IntNoise3D( BaseX-1, BaseY+1, BaseZ-1 ), IntNoise3D( BaseX, BaseY+1, BaseZ-1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ-1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ-1 ),
+ IntNoise3D( BaseX-1, BaseY+2, BaseZ-1 ), IntNoise3D( BaseX, BaseY+2, BaseZ-1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ-1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ-1 ),
+ };
+
+ const float FracX = (a_X) - BaseX;
+ const float x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX );
+ const float x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX );
+ const float x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX );
+ const float x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX );
+
+ const float points2[4][4] = {
+ IntNoise3D( BaseX-1, BaseY-1, BaseZ ), IntNoise3D( BaseX, BaseY-1, BaseZ ), IntNoise3D( BaseX+1, BaseY-1, BaseZ ), IntNoise3D( BaseX+2, BaseY-1, BaseZ ),
+ IntNoise3D( BaseX-1, BaseY, BaseZ ), IntNoise3D( BaseX, BaseY, BaseZ ), IntNoise3D( BaseX+1, BaseY, BaseZ ), IntNoise3D( BaseX+2, BaseY, BaseZ ),
+ IntNoise3D( BaseX-1, BaseY+1, BaseZ ), IntNoise3D( BaseX, BaseY+1, BaseZ ), IntNoise3D( BaseX+1, BaseY+1, BaseZ ), IntNoise3D( BaseX+2, BaseY+1, BaseZ ),
+ IntNoise3D( BaseX-1, BaseY+2, BaseZ ), IntNoise3D( BaseX, BaseY+2, BaseZ ), IntNoise3D( BaseX+1, BaseY+2, BaseZ ), IntNoise3D( BaseX+2, BaseY+2, BaseZ ),
+ };
+
+ const float x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX );
+ const float x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX );
+ const float x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX );
+ const float x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX );
+
+ const float points3[4][4] = {
+ IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+1 ),
+ IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ+1 ),
+ IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+1 ),
+ IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+1 ),
+ };
+
+ const float x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX );
+ const float x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX );
+ const float x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX );
+ const float x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX );
+
+ const float points4[4][4] = {
+ IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ),
+ IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ),
+ IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ),
+ IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ),
+ };
+
+ const float x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX );
+ const float x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX );
+ const float x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX );
+ const float x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX );
+
+ const float FracY = (a_Y) - BaseY;
+ const float yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY );
+ const float yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY );
+ const float yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY );
+ const float yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY );
+
+ const float FracZ = (a_Z) - BaseZ;
+ return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ );
+}
+
+/******************
+ * Private
+ **/
+float cNoise::CubicInterpolate( float a_A, float a_B, float a_C, float a_D, float a_Pct ) const
+{
+ float P = (a_D - a_C) - (a_A - a_B);
+ float Q = (a_A - a_B) - P;
+ float R = a_C - a_A;
+ float S = a_B;
+
+ return P*(a_Pct*a_Pct*a_Pct) + Q*(a_Pct*a_Pct) + R*a_Pct + S;
+}
+
+float cNoise::CosineInterpolate( float a_A, float a_B, float a_Pct ) const
+{
+ const float ft = a_Pct * 3.1415927f;
+ const float f = (1.f - cosf(ft)) * 0.5f;
+ return a_A*(1-f) + a_B*f;
+}
+
+float cNoise::LinearInterpolate( float a_A, float a_B, float a_Pct ) const
+{
+ return a_A*(1.f-a_Pct) + a_B*a_Pct;
+} \ No newline at end of file
diff --git a/source/cNoise.h b/source/cNoise.h
new file mode 100644
index 000000000..538970da3
--- /dev/null
+++ b/source/cNoise.h
@@ -0,0 +1,33 @@
+#pragma once
+
+class cNoise
+{
+public:
+ cNoise( unsigned int a_Seed );
+ ~cNoise();
+
+ float IntNoise( int a_X ) const;
+ float IntNoise2D( int a_X, int a_Y ) const;
+ float IntNoise3D( int a_X, int a_Y, int a_Z ) const;
+
+ float LinearNoise1D( float a_X ) const;
+ float CosineNoise1D( float a_X ) const;
+ float CubicNoise1D( float a_X ) const;
+ float SmoothNoise1D( int a_X ) const;
+
+ float LinearNoise2D( float a_X, float a_Y ) const;
+ float CosineNoise2D( float a_X, float a_Y ) const;
+ float CubicNoise2D( float a_X, float a_Y ) const;
+
+ float CosineNoise3D( float a_X, float a_Y, float a_Z ) const;
+ float CubicNoise3D( float a_X, float a_Y, float a_Z ) const;
+
+ void SetSeed( unsigned int a_Seed ) { m_Seed = a_Seed; }
+private:
+ float CubicInterpolate( float a_A, float a_B, float a_C, float a_D, float a_Pct ) const;
+ float CosineInterpolate( float a_A, float a_B, float a_Pct ) const;
+ float LinearInterpolate( float a_A, float a_B, float a_Pct ) const;
+
+ unsigned int m_Seed;
+};
+
diff --git a/source/cPawn.cpp b/source/cPawn.cpp
new file mode 100644
index 000000000..d9f2ec8b5
--- /dev/null
+++ b/source/cPawn.cpp
@@ -0,0 +1,96 @@
+#include "cPawn.h"
+#include "cRoot.h"
+#include "cServer.h"
+#include "cWorld.h"
+#include "cPlayer.h"
+#include "cChunk.h"
+#include "cMCLogger.h"
+#include "cPluginManager.h"
+
+#include "packets/cPacket_TeleportEntity.h"
+#include "packets/cPacket_EntityStatus.h"
+
+CLASS_DEFINITION( cPawn, cEntity )
+
+cPawn::cPawn()
+ : cEntity( 0, 0, 0 )
+ , m_LastPosX( 0.0 )
+ , m_LastPosY( 0.0 )
+ , m_LastPosZ( 0.0 )
+ , m_TimeLastTeleportPacket( 0.f )
+{
+ m_Health = 20;
+}
+
+cPawn::~cPawn()
+{
+
+}
+
+void cPawn::Heal( int a_Health )
+{
+ (void)a_Health;
+}
+
+void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator )
+{
+ TakeDamageInfo TDI;
+ TDI.Damage = a_Damage;
+ TDI.Instigator = a_Instigator;
+ cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI );
+
+
+
+ if( TDI.Damage == 0 ) return;
+ if( m_Health <= 0 ) return; // Can't take damage if already dead
+
+ m_Health -= (short)TDI.Damage;
+ if( m_Health < 0 ) m_Health = 0;
+
+ cPacket_EntityStatus Status;
+ Status.m_UniqueID = GetUniqueID();
+ Status.m_Status = cPacket_EntityStatus::STATUS_TAKEDAMAGE;
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ Chunk->Broadcast( Status );
+
+ if( m_Health <= 0 )
+ KilledBy( TDI.Instigator );
+}
+
+void cPawn::KilledBy( cEntity* a_Killer )
+{
+ m_Health = 0;
+
+ if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_KILLED, 2, this, a_Killer ) )
+ {
+ return; // Give plugins a chance to 'unkill' the pawn.
+ }
+
+ cPacket_EntityStatus Status;
+ Status.m_UniqueID = GetUniqueID();
+ Status.m_Status = cPacket_EntityStatus::STATUS_DIE;
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ Chunk->Broadcast( Status ); // Die
+}
+
+void cPawn::TeleportTo( cEntity* a_Entity )
+{
+ TeleportTo( a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ() );
+}
+
+void cPawn::TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ )
+{
+ SetPosition( a_PosX, a_PosY, a_PosZ );
+ cPacket_TeleportEntity TeleportEntity( this );
+ if( IsA("cPlayer") )
+ {
+ cPlayer* Player = (cPlayer*)this;
+ cRoot::Get()->GetServer()->Broadcast( TeleportEntity, Player->GetClientHandle() );
+ }
+ else
+ {
+ cRoot::Get()->GetServer()->Broadcast( TeleportEntity );
+ }
+}
diff --git a/source/cPawn.h b/source/cPawn.h
new file mode 100644
index 000000000..2339bde03
--- /dev/null
+++ b/source/cPawn.h
@@ -0,0 +1,31 @@
+#pragma once
+#include "cEntity.h"
+
+struct TakeDamageInfo //tolua_export
+{ //tolua_export
+ int Damage; //tolua_export
+ cEntity* Instigator; //tolua_export
+}; //tolua_export
+
+class cPawn : public cEntity //tolua_export
+{ //tolua_export
+public:
+ CLASS_PROTOTYPE();
+
+ cPawn();
+ virtual ~cPawn();
+
+ virtual void TeleportTo( cEntity* a_Entity ); //tolua_export
+ virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
+
+ void Heal( int a_Health ); //tolua_export
+ virtual void TakeDamage( int a_Damage, cEntity* a_Instigator ); //tolua_export
+ virtual void KilledBy( cEntity* a_Killer ); //tolua_export
+ int GetHealth() { return m_Health; } //tolua_export
+
+protected:
+ short m_Health;
+
+ double m_LastPosX, m_LastPosY, m_LastPosZ;
+ float m_TimeLastTeleportPacket;
+}; //tolua_export
diff --git a/source/cPickup.cpp b/source/cPickup.cpp
new file mode 100644
index 000000000..585c1e32b
--- /dev/null
+++ b/source/cPickup.cpp
@@ -0,0 +1,229 @@
+#ifndef _WIN32
+#include <cstdlib>
+#endif
+
+#include "cPickup.h"
+#include "cClientHandle.h"
+#include "cInventory.h"
+#include "cWorld.h"
+#include "cServer.h"
+#include "cPlayer.h"
+#include "cPluginManager.h"
+#include "cItem.h"
+#include "cRoot.h"
+#include "cMCLogger.h"
+#include "cTracer.h"
+#include "cChunk.h"
+
+#include "packets/cPacket_TeleportEntity.h"
+#include "packets/cPacket_PickupSpawn.h"
+#include "packets/cPacket_CollectItem.h"
+
+#include "Vector3d.h"
+#include "Vector3f.h"
+
+CLASS_DEFINITION( cPickup, cEntity )
+
+cPickup::~cPickup()
+{
+ delete m_Item;
+}
+
+cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
+ : cEntity( ((double)(a_X))/32, ((double)(a_Y))/32, ((double)(a_Z))/32 )
+ , m_Speed( new Vector3f( a_SpeedX, a_SpeedY, a_SpeedZ ) )
+ , m_bOnGround( false )
+ , m_bReplicated( false )
+ , m_Timer( 0.f )
+ , m_Item( new cItem( a_Item ) )
+ , m_bCollected( false )
+{
+
+ //LOG("New pickup: ID(%i) Amount(%i) Health(%i)", m_Item.m_ItemID, m_Item.m_ItemCount, m_Item.m_ItemHealth );
+
+ // Spawn it on clients
+ cPacket_PickupSpawn PickupSpawn;
+ PickupSpawn.m_UniqueID = m_UniqueID;
+ PickupSpawn.m_Item = (short)m_Item->m_ItemID;
+ PickupSpawn.m_Count = m_Item->m_ItemCount;
+ PickupSpawn.m_Health = m_Item->m_ItemHealth;
+ PickupSpawn.m_PosX = a_X;
+ PickupSpawn.m_PosY = a_Y;
+ PickupSpawn.m_PosZ = a_Z;
+ PickupSpawn.m_Rotation = (char)(m_Speed->x * 8);
+ PickupSpawn.m_Pitch = (char)(m_Speed->y * 8);
+ PickupSpawn.m_Roll = (char)(m_Speed->z * 8);
+ cRoot::Get()->GetServer()->Broadcast( PickupSpawn );
+
+ m_EntityType = E_PICKUP;
+}
+
+cPickup::cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket)
+ : cEntity( ((double)a_PickupSpawnPacket->m_PosX)/32, ((double)a_PickupSpawnPacket->m_PosY)/32, ((double)a_PickupSpawnPacket->m_PosZ)/32 )
+ , m_bOnGround( false )
+ , m_bReplicated( false )
+ , m_Timer( 0.f )
+ , m_bCollected( false )
+{
+ a_PickupSpawnPacket->m_UniqueID = m_UniqueID;
+
+ m_Item = new cItem();
+ m_Item->m_ItemID = (ENUM_ITEM_ID)a_PickupSpawnPacket->m_Item;
+ m_Item->m_ItemCount = a_PickupSpawnPacket->m_Count;
+ m_Item->m_ItemHealth = 0x0;
+
+ m_Speed->x = (float)(a_PickupSpawnPacket->m_Rotation) / 8;
+ m_Speed->y = (float)(a_PickupSpawnPacket->m_Pitch) / 8;
+ m_Speed->z = (float)(a_PickupSpawnPacket->m_Roll) / 8;
+
+ // Spawn it on clients
+ cRoot::Get()->GetServer()->Broadcast( *a_PickupSpawnPacket );
+
+ m_EntityType = E_PICKUP;
+}
+
+void cPickup::SpawnOn( cClientHandle* a_Target )
+{
+ cPacket_PickupSpawn PickupSpawn;
+ PickupSpawn.m_UniqueID = m_UniqueID;
+ PickupSpawn.m_Item = (short)m_Item->m_ItemID;
+ PickupSpawn.m_Count = m_Item->m_ItemCount;
+ PickupSpawn.m_Health = m_Item->m_ItemHealth;
+ PickupSpawn.m_PosX = (int)(m_Pos->x * 32);
+ PickupSpawn.m_PosY = (int)(m_Pos->y * 32);
+ PickupSpawn.m_PosZ = (int)(m_Pos->z * 32);
+ PickupSpawn.m_Rotation = (char)(m_Speed->x * 8);
+ PickupSpawn.m_Pitch = (char)(m_Speed->y * 8);
+ PickupSpawn.m_Roll = (char)(m_Speed->z * 8);
+ a_Target->Send( PickupSpawn );
+}
+
+void cPickup::Tick(float a_Dt)
+{
+ m_Timer+=a_Dt;
+ a_Dt = a_Dt / 1000.f;
+ if(m_bCollected)
+ {
+ if(m_Timer > 500.f) // 0.5 second
+ {
+ Destroy();
+ return;
+ }
+ }
+
+ if( m_Timer > 1000*60*5 ) // 5 minutes
+ {
+ Destroy();
+ return;
+ }
+
+ if( m_Pos->y < 0 ) // Out of this world!
+ {
+ Destroy();
+ return;
+ }
+
+ HandlePhysics( a_Dt );
+
+ if( !m_bReplicated || m_bDirtyPosition )
+ {
+ MoveToCorrectChunk();
+ m_bReplicated = true;
+ m_bDirtyPosition = false;
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ cPacket_TeleportEntity TeleportEntity( this );
+ Chunk->Broadcast( TeleportEntity );
+ }
+ }
+
+ //printf("YSpeed: %f, OnGround: %i\n", m_SpeedY, m_bOnGround );
+}
+
+void cPickup::HandlePhysics(float a_Dt)
+{
+ if( m_bOnGround ) // check if it's still on the ground
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ int BlockX = (int)m_Pos->x;
+ if( m_Pos->x < 0 ) BlockX--;
+ int BlockZ = (int)m_Pos->z;
+ if( m_Pos->z < 0 ) BlockZ--;
+ if( World->GetBlock( BlockX, (int)m_Pos->y -1, BlockZ ) == E_BLOCK_AIR )
+ {
+ m_bOnGround = false;
+ }
+ if( World->GetBlock( BlockX, (int)m_Pos->y, BlockZ ) != E_BLOCK_AIR ) // If in ground itself, push it out
+ {
+ m_bOnGround = true;
+ m_Pos->y += 0.2;
+ m_bReplicated = false;
+ }
+ m_Speed->x *= 0.7f/(1+a_Dt);
+ if( fabs(m_Speed->x) < 0.05 ) m_Speed->x = 0;
+ m_Speed->z *= 0.7f/(1+a_Dt);
+ if( fabs(m_Speed->z) < 0.05 ) m_Speed->z = 0;
+ }
+
+ if( !m_bOnGround )
+ {
+
+ float Gravity = -9.81f*a_Dt;
+ m_Speed->y += Gravity;
+
+ cTracer Tracer( cRoot::Get()->GetWorld() );
+ int Ret = Tracer.Trace( *m_Pos, *m_Speed, 2 );
+ if( Ret ) // Oh noez! we hit something
+ {
+ // Set to hit position
+ if( (*Tracer.RealHit - Vector3f(*m_Pos)).SqrLength() <= ( *m_Speed * a_Dt ).SqrLength() )
+ {
+ m_bReplicated = false; // It's only interesting to replicate when we actually hit something...
+ if( Ret == 1 )
+ {
+
+ if( Tracer.HitNormal->x != 0.f ) m_Speed->x = 0.f;
+ if( Tracer.HitNormal->y != 0.f ) m_Speed->y = 0.f;
+ if( Tracer.HitNormal->z != 0.f ) m_Speed->z = 0.f;
+
+ if( Tracer.HitNormal->y > 0 ) // means on ground
+ {
+ m_bOnGround = true;
+ }
+ }
+ *m_Pos = Tracer.RealHit;
+ *m_Pos += *Tracer.HitNormal * 0.2;
+
+ }
+ else
+ *m_Pos += *m_Speed*a_Dt;
+ }
+ else
+ { // We didn't hit anything, so move =]
+ *m_Pos += *m_Speed*a_Dt;
+ }
+ }
+}
+
+bool cPickup::CollectedBy( cPlayer* a_Dest )
+{
+ if(m_bCollected) return false; // It's already collected!
+ if(m_Timer < 1000.f) return false; // Not old enough
+
+ if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_COLLECT_ITEM, 2, this, a_Dest ) ) return false;
+
+ if( a_Dest->GetInventory().AddItem( *m_Item ) )
+ {
+ cPacket_CollectItem CollectItem;
+ CollectItem.m_CollectedID = m_UniqueID;
+ CollectItem.m_CollectorID = a_Dest->GetUniqueID();
+ cRoot::Get()->GetServer()->Broadcast( CollectItem );
+
+ m_bCollected = true;
+ m_Timer = 0;
+ return true;
+ }
+
+ return false;
+}
diff --git a/source/cPickup.h b/source/cPickup.h
new file mode 100644
index 000000000..cad766e42
--- /dev/null
+++ b/source/cPickup.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "cEntity.h"
+
+class cPacket_PickupSpawn;
+class cPlayer;
+class cItem;
+class cPickup : public cEntity //tolua_export
+{ //tolua_export
+public:
+ CLASS_PROTOTYPE();
+
+ cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); //tolua_export
+ cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket); //tolua_export
+ ~cPickup(); //tolua_export
+
+ cItem* GetItem() { return m_Item; } //tolua_export
+
+ void SpawnOn( cClientHandle* a_Target );
+ virtual bool CollectedBy( cPlayer* a_Dest ); //tolua_export
+
+ void Tick(float a_Dt);
+ void HandlePhysics(float a_Dt);
+private:
+ Vector3f* m_Speed;
+ bool m_bOnGround;
+ bool m_bReplicated;
+
+ float m_Timer;
+
+ cItem* m_Item;
+
+ bool m_bCollected;
+};//tolua_export \ No newline at end of file
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
new file mode 100644
index 000000000..8552abd3e
--- /dev/null
+++ b/source/cPlayer.cpp
@@ -0,0 +1,713 @@
+#include "cPlayer.h"
+#include "cServer.h"
+#include "cInventory.h"
+#include "cClientHandle.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cPluginManager.h"
+#include "cChunk.h"
+#include "cMCLogger.h"
+#include "cWindow.h"
+#include "cBlockEntity.h"
+#include "cGroupManager.h"
+#include "cGroup.h"
+#include "cChatColor.h"
+#include "cItem.h"
+#include "cTracer.h"
+#include "cRoot.h"
+
+#include "packets/cPacket_NamedEntitySpawn.h"
+#include "packets/cPacket_EntityLook.h"
+#include "packets/cPacket_TeleportEntity.h"
+#include "packets/cPacket_RelativeEntityMove.h"
+#include "packets/cPacket_RelativeEntityMoveLook.h"
+#include "packets/cPacket_UpdateHealth.h"
+#include "packets/cPacket_Respawn.h"
+#include "packets/cPacket_PlayerPosition.h"
+#include "packets/cPacket_DestroyEntity.h"
+#include "packets/cPacket_Metadata.h"
+#include "packets/cPacket_Chat.h"
+
+#include "Vector3d.h"
+#include "Vector3f.h"
+
+#include "../iniFile/iniFile.h"
+
+#ifndef _WIN32 // for mkdir
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
+extern std::vector< std::string > StringSplit( std::string str, std::string delim);
+
+CLASS_DEFINITION( cPlayer, cPawn );
+
+typedef std::map< std::string, bool > PermissionMap;
+struct cPlayer::sPlayerState
+{
+ PermissionMap ResolvedPermissions;
+ PermissionMap Permissions;
+
+ cPlayer::GroupList ResolvedGroups;
+ cPlayer::GroupList Groups;
+
+ std::string PlayerName;
+};
+
+cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
+ : m_bBurnable(true)
+ , e_EPMetaState(NORMAL)
+ , m_bVisible( true )
+ , m_LastGroundHeight( 0 )
+ , m_bTouchGround( false )
+ , m_Stance( 0.0 )
+ , m_Inventory( 0 )
+ , m_CurrentWindow( 0 )
+ , m_TimeLastPickupCheck( 0.f )
+ , m_Color('-')
+ , m_FireDamageInterval(0)
+ , m_BurnPeriod(0)
+ , m_ClientHandle( a_Client )
+ , m_pState( new sPlayerState )
+{
+ m_EntityType = E_PLAYER;
+ m_Inventory = new cInventory( this );
+
+ m_TimeLastTeleportPacket = cWorld::GetTime();
+ m_TimeLastPickupCheck = cWorld::GetTime();
+
+ m_pState->PlayerName = a_PlayerName;
+ m_bDirtyPosition = true; // So chunks are streamed to player at spawn
+
+ if( !LoadFromDisk() )
+ {
+ m_Inventory->Clear();
+ SetPosX( cRoot::Get()->GetWorld()->GetSpawnX() );
+ SetPosY( cRoot::Get()->GetWorld()->GetSpawnY() );
+ SetPosZ( cRoot::Get()->GetWorld()->GetSpawnZ() );
+ }
+
+ MoveToCorrectChunk();
+ cRoot::Get()->GetWorld()->AddPlayer( this );
+}
+
+cPlayer::~cPlayer(void)
+{
+ SaveToDisk();
+ m_ClientHandle = 0;
+ CloseWindow();
+ if( m_Inventory )
+ {
+ delete m_Inventory;
+ m_Inventory = 0;
+ }
+ delete m_pState;
+ cRoot::Get()->GetWorld()->RemovePlayer( this );
+}
+
+void cPlayer::SpawnOn( cClientHandle* a_Target )
+{
+ if( a_Target == m_ClientHandle || !m_bVisible ) return;
+ LOG("cPlayer::SpawnOn -> Sending %s to %s", m_pState->PlayerName.c_str(), (a_Target)?a_Target->GetUsername():"Everybody" );
+ cPacket_NamedEntitySpawn SpawnPacket;
+ SpawnPacket.m_UniqueID = m_UniqueID;
+ SpawnPacket.m_PlayerName = m_pState->PlayerName;
+ SpawnPacket.m_PosX = (int)(m_Pos->x * 32);
+ SpawnPacket.m_PosY = (int)(m_Pos->y * 32);
+ SpawnPacket.m_PosZ = (int)(m_Pos->z * 32);
+ SpawnPacket.m_Rotation = (char)((m_Rot->x/360.f)*256);
+ SpawnPacket.m_Pitch = (char)((m_Rot->y/360.f)*256);
+ SpawnPacket.m_CurrentItem = (short)m_Inventory->GetEquippedItem().m_ItemID;
+ if( a_Target == 0 )
+ {
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ Chunk->Broadcast( SpawnPacket, m_ClientHandle );
+ }
+ else
+ {
+ a_Target->Send( SpawnPacket );
+ }
+}
+
+void cPlayer::Tick(float a_Dt)
+{
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if(m_bDirtyOrientation && !m_bDirtyPosition)
+ {
+ cPacket_EntityLook EntityLook( this );
+ InChunk->Broadcast( EntityLook, m_ClientHandle );
+ m_bDirtyOrientation = false;
+ }
+ if(m_bDirtyPosition )
+ {
+ cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_MOVE, 1, this );
+
+ float DiffX = (float)(GetPosX() - m_LastPosX );
+ float DiffY = (float)(GetPosY() - m_LastPosY );
+ float DiffZ = (float)(GetPosZ() - m_LastPosZ );
+ float SqrDist = DiffX*DiffX + DiffY*DiffY + DiffZ*DiffZ;
+ if( SqrDist > 4*4 // 4 blocks is max Relative Move
+ || cWorld::GetTime() - m_TimeLastTeleportPacket > 2 ) // Send an absolute position every 2 seconds
+ {
+ //LOG("Teleported %f", sqrtf(SqrDist) );
+ cPacket_TeleportEntity TeleportEntity( this );
+ InChunk->Broadcast( TeleportEntity, m_ClientHandle );
+ m_TimeLastTeleportPacket = cWorld::GetTime();
+ }
+ else
+ { // Relative move sucks balls! It's always wrong wtf!
+ if( m_bDirtyOrientation )
+ {
+ cPacket_RelativeEntityMoveLook RelativeEntityMoveLook;
+ RelativeEntityMoveLook.m_UniqueID = GetUniqueID();
+ RelativeEntityMoveLook.m_MoveX = (char)(DiffX*32);
+ RelativeEntityMoveLook.m_MoveY = (char)(DiffY*32);
+ RelativeEntityMoveLook.m_MoveZ = (char)(DiffZ*32);
+ RelativeEntityMoveLook.m_Yaw = (char)((GetRotation()/360.f)*256);
+ RelativeEntityMoveLook.m_Pitch = (char)((GetPitch()/360.f)*256);
+ InChunk->Broadcast( RelativeEntityMoveLook, m_ClientHandle );
+ }
+ else
+ {
+ cPacket_RelativeEntityMove RelativeEntityMove;
+ RelativeEntityMove.m_UniqueID = GetUniqueID();
+ RelativeEntityMove.m_MoveX = (char)(DiffX*32);
+ RelativeEntityMove.m_MoveY = (char)(DiffY*32);
+ RelativeEntityMove.m_MoveZ = (char)(DiffZ*32);
+ InChunk->Broadcast( RelativeEntityMove, m_ClientHandle );
+ }
+ }
+ m_LastPosX = GetPosX();
+ m_LastPosY = GetPosY();
+ m_LastPosZ = GetPosZ();
+ m_bDirtyPosition = false;
+ m_ClientHandle->StreamChunks();
+ }
+
+ if( m_Health > 0 ) // make sure player is alive
+ {
+ if( cWorld::GetTime() - m_TimeLastPickupCheck > 0.5f ) // Each 0.5 second, check for pickups
+ {
+ m_TimeLastPickupCheck = cWorld::GetTime();
+ // and also check if near a pickup
+ // TODO: Don't only check in current chunks, but also close chunks (chunks within range)
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ Chunk->LockEntities();
+ cWorld::EntityList Entities = Chunk->GetEntities();
+ for( cWorld::EntityList::iterator itr = Entities.begin(); itr != Entities.end();++itr)
+ {
+ if( (*itr)->GetEntityType() != cEntity::E_PICKUP ) continue; // Only pickups
+ float DiffX = (float)((*itr)->GetPosX() - GetPosX() );
+ float DiffY = (float)((*itr)->GetPosY() - GetPosY() );
+ float DiffZ = (float)((*itr)->GetPosZ() - GetPosZ() );
+ float SqrDist = DiffX*DiffX + DiffY*DiffY + DiffZ*DiffZ;
+ if(SqrDist < 1.5f*1.5f) // 1.5 block
+ {
+ cPickup* Pickup = reinterpret_cast<cPickup*>(*itr);
+ Pickup->CollectedBy( this );
+ }
+ }
+ Chunk->UnlockEntities();
+ }
+ }
+ CheckMetaDataBurn();
+ if(e_EPMetaState == BURNING){
+ InStateBurning(a_Dt);
+ }
+}
+
+void cPlayer::InStateBurning(float a_Dt) {
+ m_FireDamageInterval += a_Dt;
+ char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ if(m_FireDamageInterval > 1000) {
+
+ m_FireDamageInterval = 0;
+ int rem = rand()%3 + 1; //Burn most of the time
+ if(rem >= 2) {
+ //printf("OUCH burning!!!\n");
+ TakeDamage(1, this);
+ }
+ m_BurnPeriod++;
+ if(block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
+ || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)
+ m_BurnPeriod = 0;
+
+ if(m_BurnPeriod > 5) {
+
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ e_EPMetaState = NORMAL;
+ cPacket_Metadata md(NORMAL, GetUniqueID());
+ //md.m_UniqueID = GetUniqueID();
+ InChunk->Broadcast(md);
+ m_BurnPeriod = 0;
+
+ }
+
+ }
+
+}
+
+//----Change Entity MetaData
+void cPlayer::CheckMetaDataBurn() {
+ char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ if(m_bBurnable && e_EPMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
+ || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
+ cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if(!InChunk)
+ return;
+ printf("I should burn");
+ e_EPMetaState = BURNING;
+ cPacket_Metadata md(BURNING,GetUniqueID());
+ InChunk->Broadcast(md);
+ }
+}
+
+void cPlayer::SetTouchGround( bool a_bTouchGround )
+{
+ m_bTouchGround = a_bTouchGround;
+
+ if( !m_bTouchGround )
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ char BlockID = World->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ if( BlockID != E_BLOCK_AIR )
+ {
+ m_bTouchGround = true;
+ }
+ if( BlockID == E_BLOCK_WATER || BlockID == E_BLOCK_STATIONARY_WATER || BlockID == E_BLOCK_LADDER || BlockID == E_BLOCK_TORCH )
+ {
+ m_LastGroundHeight = (float)m_Pos->y;
+ }
+ }
+
+ if( m_bTouchGround )
+ {
+ float Dist = (float)(m_LastGroundHeight - m_Pos->y);
+ if( Dist > 4.f ) // Player dropped
+ {
+ int Damage = (int)(Dist - 4.f);
+ if( Damage > 0 )
+ {
+ TakeDamage( Damage, 0 );
+ }
+ }
+
+ m_LastGroundHeight = (float)m_Pos->y;
+ }
+}
+
+void cPlayer::Heal( int a_Health )
+{
+ if( m_Health < 20 )
+ {
+ m_Health += (short)a_Health;
+ if( m_Health > 20 )
+ {
+ m_Health = 20;
+ }
+
+ cPacket_UpdateHealth Health;
+ Health.m_Health = m_Health;
+ m_ClientHandle->Send( Health );
+ }
+}
+
+void cPlayer::TakeDamage( int a_Damage, cEntity* a_Instigator )
+{
+ cPawn::TakeDamage( a_Damage, a_Instigator );
+
+ cPacket_UpdateHealth Health;
+ Health.m_Health = m_Health;
+ m_ClientHandle->Send( Health );
+}
+
+void cPlayer::KilledBy( cEntity* a_Killer )
+{
+ cPawn::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
+ cItem* Items = m_Inventory->GetSlots();
+ for( unsigned int i = 1; i < m_Inventory->c_NumSlots; ++i )
+ {
+ if( !Items[i].IsEmpty() )
+ {
+ float SpeedX = ((rand()%1000)-500) /100.f;
+ float SpeedY = ((rand()%1000)) /100.f;
+ float SpeedZ = ((rand()%1000)-500) /100.f;
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), Items[i], SpeedX, SpeedY, SpeedZ );
+ Pickup->Initialize();
+ }
+ Items[i].Empty();
+ }
+ SaveToDisk(); // Save it, yeah the world is a tough place !
+}
+
+void cPlayer::Respawn()
+{
+ m_Health = 20;
+
+ cWorld* World = cRoot::Get()->GetWorld();
+ m_ClientHandle->Send( cPacket_Respawn() );
+ TeleportTo( World->GetSpawnX(), World->GetSpawnY(), World->GetSpawnZ() );
+ SetVisible( true );
+}
+
+double cPlayer::GetEyeHeight()
+{
+ return m_Stance;
+}
+
+Vector3d cPlayer::GetEyePosition()
+{
+ return Vector3d( m_Pos->x, m_Stance, m_Pos->z );
+}
+
+void cPlayer::OpenWindow( cWindow* a_Window )
+{
+ CloseWindow();
+ a_Window->Open( *this );
+ m_CurrentWindow = a_Window;
+}
+
+void cPlayer::CloseWindow()
+{
+ if( m_CurrentWindow ) m_CurrentWindow->Close( *this );
+ m_CurrentWindow = 0;
+}
+
+#ifdef SendMessage // Cause stupid windows.h defines SendMessage as SendMessageA
+#undef SendMessage
+#endif
+void cPlayer::SendMessage( const char* a_Message )
+{
+ m_ClientHandle->Send( cPacket_Chat( a_Message ) );
+}
+
+void cPlayer::TeleportTo( cEntity* a_Entity )
+{
+ cPawn::TeleportTo( a_Entity );
+ cPacket_PlayerPosition PlayerPosition( this );
+ m_ClientHandle->Send( PlayerPosition );
+}
+
+void cPlayer::TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ )
+{
+ cPawn::TeleportTo( a_PosX, a_PosY, a_PosZ );
+ cPacket_PlayerPosition PlayerPosition( this );
+ m_ClientHandle->Send( PlayerPosition );
+}
+
+void cPlayer::MoveTo( const Vector3d & a_NewPos )
+{
+ // TODO: should do some checks to see if player is not moving through terrain
+ SetPosition( a_NewPos );
+}
+
+void cPlayer::SetVisible( bool a_bVisible )
+{
+ if( a_bVisible == true && m_bVisible == false ) // Make visible
+ {
+ m_bVisible = true;
+ SpawnOn( 0 ); // Spawn on everybody
+ }
+ if( a_bVisible == false && m_bVisible == true )
+ {
+ m_bVisible = false;
+ cPacket_DestroyEntity DestroyEntity( this );
+ cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ Chunk->Broadcast( DestroyEntity ); // Destroy on all clients
+ }
+ }
+}
+
+void cPlayer::AddToGroup( const char* a_GroupName )
+{
+ cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
+ m_pState->Groups.push_back( Group );
+ LOG("Added %s to group %s", m_pState->PlayerName.c_str(), a_GroupName );
+ ResolveGroups();
+ ResolvePermissions();
+}
+
+bool cPlayer::CanUseCommand( const char* a_Command )
+{
+ for( GroupList::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
+ {
+ if( (*itr)->HasCommand( a_Command ) ) return true;
+ }
+ return false;
+}
+
+bool cPlayer::HasPermission( const char* a_Permission )
+{
+ std::vector< std::string > Split = StringSplit( a_Permission, "." );
+ PermissionMap Possibilities = m_pState->ResolvedPermissions;
+ // Now search the namespaces
+ while( Possibilities.begin() != Possibilities.end() )
+ {
+ PermissionMap::iterator itr = Possibilities.begin();
+ if( itr->second )
+ {
+ std::vector< std::string > 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 char* a_Group )
+{
+ for( GroupList::iterator itr = m_pState->ResolvedGroups.begin(); itr != m_pState->ResolvedGroups.end(); ++itr )
+ {
+ if( strcmp( a_Group, (*itr)->GetName().c_str() ) == 0 )
+ return true;
+ }
+ return false;
+}
+
+void cPlayer::ResolvePermissions()
+{
+ m_pState->ResolvedPermissions.clear(); // Start with an empty map yo~
+
+ // Copy all player specific permissions into the resolved permissions map
+ for( PermissionMap::iterator itr = m_pState->Permissions.begin(); itr != m_pState->Permissions.end(); ++itr )
+ {
+ m_pState->ResolvedPermissions[ itr->first ] = itr->second;
+ }
+
+ for( GroupList::iterator GroupItr = m_pState->ResolvedGroups.begin(); GroupItr != m_pState->ResolvedGroups.end(); ++GroupItr )
+ {
+ const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
+ for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
+ {
+ m_pState->ResolvedPermissions[ itr->first ] = itr->second;
+ }
+ }
+}
+
+void cPlayer::ResolveGroups()
+{
+ // Clear resolved groups first
+ m_pState->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_pState->Groups.begin(); GroupItr != m_pState->Groups.end(); ++GroupItr )
+ {
+ ToIterate.push_back( *GroupItr );
+ }
+ while( ToIterate.begin() != ToIterate.end() )
+ {
+ cGroup* CurrentGroup = *ToIterate.begin();
+ if( AllGroups.find( CurrentGroup ) != AllGroups.end() )
+ {
+ LOGERROR("ERROR: Player %s is in the same group multiple times (%s). FIX IT!", m_pState->PlayerName.c_str(), CurrentGroup->GetName().c_str() );
+ }
+ else
+ {
+ AllGroups[ CurrentGroup ] = true;
+ m_pState->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_pState->PlayerName.c_str(), (*itr)->GetName().c_str() );
+ continue;
+ }
+ ToIterate.push_back( *itr );
+ }
+ }
+ ToIterate.erase( ToIterate.begin() );
+ }
+}
+
+std::string cPlayer::GetColor()
+{
+ if( m_Color != '-' )
+ return cChatColor::MakeColor( m_Color );
+
+ if( m_pState->Groups.size() < 1 )
+ return cChatColor::White;
+
+ return (*m_pState->Groups.begin())->GetColor();
+}
+
+void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ )
+{
+ if( a_bDraggingItem )
+ {
+ cItem* Item = GetInventory().GetWindow()->GetDraggingItem();
+ if( Item->m_ItemID > 0 && Item->m_ItemCount >= a_Amount )
+ {
+ float vX = 0, vY = 0, vZ = 0;
+ EulerToVector( -GetRotation(), GetPitch(), vZ, vX, vY );
+ vY = -vY*2 + 1.f;
+ cPickup* Pickup = new cPickup( (int)(GetPosX()*32), (int)(GetPosY()*32) + (int)(1.6f*32), (int)(GetPosZ()*32), cItem( Item->m_ItemID, (char)a_Amount, Item->m_ItemHealth), vX*2, vY*2, vZ*2 );
+ Pickup->Initialize();
+ if( Item->m_ItemCount > a_Amount )
+ Item->m_ItemCount -= (char)a_Amount;
+ else
+ Item->Empty();
+ }
+ return;
+ }
+
+ // Else drop equipped item
+ cItem DroppedItem = GetInventory().GetEquippedItem();
+ if( DroppedItem.m_ItemID > 0 && DroppedItem.m_ItemCount > 0 )
+ {
+ DroppedItem.m_ItemCount = 1;
+ if( GetInventory().RemoveItem( DroppedItem ) )
+ {
+ DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again
+ float vX = 0, vY = 0, vZ = 0;
+ EulerToVector( -GetRotation(), GetPitch(), vZ, vX, vY );
+ vY = -vY*2 + 1.f;
+ cPickup* Pickup = new cPickup( (int)(GetPosX()*32), (int)(GetPosY()*32) + (int)(1.6f*32), (int)(GetPosZ()*32), DroppedItem, vX*2, vY*2, vZ*2 );
+ Pickup->Initialize();
+ }
+ }
+}
+
+bool cPlayer::LoadFromDisk()
+{
+ cIniFile IniFile("users.ini");
+ if( IniFile.ReadFile() )
+ {
+ std::string Groups = IniFile.GetValue(m_pState->PlayerName, "Groups", "");
+ if( Groups.size() > 0 )
+ {
+ std::vector< std::string > 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_pState->PlayerName, "Color", "-")[0];
+ }
+ else
+ {
+ AddToGroup("Default");
+ }
+ ResolvePermissions();
+
+ // Log player permissions, cause it's what the cool kids do
+ LOGINFO("Player %s has permissions:", m_pState->PlayerName.c_str() );
+ for( PermissionMap::iterator itr = m_pState->ResolvedPermissions.begin(); itr != m_pState->ResolvedPermissions.end(); ++itr )
+ {
+ if( itr->second ) LOGINFO("%s", itr->first.c_str() );
+ }
+
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/player/%s.bin", m_pState->PlayerName.c_str() );
+
+ FILE* f;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "rb" ) ) != 0 ) // no error
+ #endif
+ {
+ if( fread( &m_Pos->x, sizeof(double), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Pos->y, sizeof(double), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Pos->z, sizeof(double), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Rot->x, sizeof(float), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Rot->y, sizeof(float), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Rot->z, sizeof(float), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &m_Health, sizeof(m_Health), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( !m_Inventory->LoadFromFile( f ) ) { LOGERROR("ERROR READING INVENTORY FROM FILE %s", SourceFile); fclose(f); return false; }
+ fclose(f);
+ return true;
+ }
+ return false;
+}
+
+bool cPlayer::SaveToDisk()
+{
+ #ifdef _WIN32
+ { // Make sure some folders exist
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("world", &Attrib);
+ ::CreateDirectory("world/player", &Attrib);
+ }
+ #else
+ {
+ mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
+ mkdir("world/player", S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+ #endif
+
+ char SourceFile[128];
+ sprintf_s(SourceFile, 128, "world/player/%s.bin", m_pState->PlayerName.c_str() );
+
+ FILE* f;
+ #ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "wb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(SourceFile, "wb" ) ) != 0 ) // no error
+ #endif
+ {
+ fwrite( &m_Pos->x, sizeof(double), 1, f );
+ fwrite( &m_Pos->y, sizeof(double), 1, f );
+ fwrite( &m_Pos->z, sizeof(double), 1, f );
+ fwrite( &m_Rot->x, sizeof(float), 1, f );
+ fwrite( &m_Rot->y, sizeof(float), 1, f );
+ fwrite( &m_Rot->z, sizeof(float), 1, f );
+ fwrite( &m_Health, sizeof(m_Health), 1, f );
+ m_Inventory->WriteToFile( f );
+ fclose(f);
+ return true;
+ }
+
+ LOGERROR("ERROR WRITING PLAYER %s TO FILE %s", m_pState->PlayerName.c_str(), SourceFile);
+ return false;
+}
+
+
+const char* cPlayer::GetName()
+{
+ return m_pState->PlayerName.c_str();
+}
+
+void cPlayer::SetName( const char* a_Name )
+{
+ m_pState->PlayerName = a_Name;
+}
+
+const cPlayer::GroupList & cPlayer::GetGroups()
+{
+ return m_pState->Groups;
+} \ No newline at end of file
diff --git a/source/cPlayer.h b/source/cPlayer.h
new file mode 100644
index 000000000..6f05b824d
--- /dev/null
+++ b/source/cPlayer.h
@@ -0,0 +1,96 @@
+#pragma once
+
+#include "cPawn.h"
+#include <list>
+
+class cGroup;
+class cWindow;
+class cInventory;
+class cClientHandle;
+class cPlayer : public cPawn //tolua_export
+{ //tolua_export
+public:
+ CLASS_PROTOTYPE();
+
+ cPlayer(cClientHandle* a_Client, const char* a_PlayerName);
+ virtual ~cPlayer();
+
+ virtual void SpawnOn( cClientHandle* a_Target );
+ virtual void Tick(float a_Dt);
+
+ void SetTouchGround( bool a_bTouchGround );
+ inline void SetStance( const double & a_Stance ) { m_Stance = a_Stance; }
+ double GetEyeHeight(); //tolua_export
+ Vector3d GetEyePosition(); //tolua_export
+ inline bool GetFlying() { return m_bTouchGround; } //tolua_export
+ inline const double & GetStance() { return m_Stance; } //tolua_export
+ cInventory & GetInventory() { return *m_Inventory; } //tolua_export
+ virtual void TeleportTo( cEntity* a_Entity ); //tolua_export
+ virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
+
+ // Tries to move to a new position, with collision checks and stuff
+ virtual void MoveTo( const Vector3d & a_NewPos ); //tolua_export
+
+ cWindow* GetWindow() { return m_CurrentWindow; }
+ void OpenWindow( cWindow* a_Window );
+ void CloseWindow();
+
+ cClientHandle* GetClientHandle() { return m_ClientHandle; } //tolua_export
+ void SetClientHandle( cClientHandle* a_Client ) { m_ClientHandle = a_Client; }
+
+ void SendMessage( const char* a_Message ); //tolua_export
+
+ const char* GetName(); //tolua_export
+ void SetName( const char* a_Name ); //tolua_export
+
+ typedef std::list< cGroup* > GroupList;
+ void AddToGroup( const char* a_GroupName ); //tolua_export
+ bool CanUseCommand( const char* a_Command ); //tolua_export
+ bool HasPermission( const char* a_Permission ); //tolua_export
+ const GroupList & GetGroups(); // >> EXPORTED IN MANUALBINDINGS <<
+ bool IsInGroup( const char* a_Group ); //tolua_export
+
+ std::string GetColor(); //tolua_export
+
+ void TossItem( bool a_bDraggingItem, int a_Amount = 1 ); //tolua_export
+
+ void Heal( int a_Health ); //tolua_export
+ void TakeDamage( int a_Damage, cEntity* a_Instigator ); //tolua_export
+ void KilledBy( cEntity* a_Killer ); //tolua_export
+ void Respawn(); //tolua_export
+
+ void SetVisible( bool a_bVisible ); //tolua_export
+ bool IsVisible() { return m_bVisible; } //tolua_export
+
+ bool SaveToDisk();
+ bool LoadFromDisk();
+
+ //Burning logic
+ bool m_bBurnable;
+ enum PMetaState{NORMAL,BURNING,CROUCHED,RIDING} e_EPMetaState;
+ virtual void CheckMetaDataBurn();
+ virtual void InStateBurning(float a_Dt);
+
+protected:
+ struct sPlayerState;
+ sPlayerState* m_pState;
+
+ bool m_bVisible;
+
+ float m_LastGroundHeight;
+ bool m_bTouchGround;
+ double m_Stance;
+ cInventory* m_Inventory;
+ cWindow* m_CurrentWindow;
+
+ float m_TimeLastPickupCheck;
+
+ void ResolvePermissions();
+
+ void ResolveGroups();
+ char m_Color;
+ float m_FireDamageInterval;
+ float m_BurnPeriod;
+
+ cClientHandle* m_ClientHandle;
+}; //tolua_export
diff --git a/source/cPlugin.cpp b/source/cPlugin.cpp
new file mode 100644
index 000000000..10f5d74d3
--- /dev/null
+++ b/source/cPlugin.cpp
@@ -0,0 +1,78 @@
+#include "cPlugin.h"
+#include <stdio.h>
+
+#include "cMCLogger.h"
+
+cPlugin::cPlugin()
+ : m_Version( 0 )
+{
+}
+
+cPlugin::~cPlugin()
+{
+}
+
+// bool cPlugin::Initialize()
+// {
+// LOG("cPlugin::Initialize()");
+// return false;
+// }
+
+void cPlugin::Tick(float a_Dt)
+{
+ (void)a_Dt;
+}
+
+bool cPlugin::OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player )
+{
+ (void)a_PacketData;
+ (void)a_Player;
+ return false;
+}
+
+bool cPlugin::OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player )
+{
+ (void)a_Pickup;
+ (void)a_Player;
+ return false;
+}
+
+bool cPlugin::OnDisconnect( std::string a_Reason, cPlayer* a_Player )
+{
+ (void)a_Reason;
+ (void)a_Player;
+ return false;
+}
+
+bool cPlugin::OnChat( std::string a_Chat, cPlayer* a_Player )
+{
+ (void)a_Chat;
+ (void)a_Player;
+ return false;
+}
+
+bool cPlugin::OnLogin( cPacket_Login* a_PacketData )
+{
+ (void)a_PacketData;
+ return false;
+}
+
+void cPlugin::OnPlayerSpawn( cPlayer* a_Player )
+{
+ (void)a_Player;
+}
+
+bool cPlugin::OnPlayerJoin( cPlayer* a_Player )
+{
+ (void)a_Player;
+ return false;
+}
+
+void cPlugin::AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission )
+{
+ CommandStruct Command;
+ Command.Command = a_Command;
+ Command.Description = a_Description;
+ Command.Permission = a_Permission;
+ m_Commands.push_back( Command );
+}
diff --git a/source/cPlugin.h b/source/cPlugin.h
new file mode 100644
index 000000000..6c38871f3
--- /dev/null
+++ b/source/cPlugin.h
@@ -0,0 +1,76 @@
+#pragma once
+
+#include "MemoryLeak.h"
+
+#include <vector>
+#include <string>
+
+class cPacket_BlockPlace;
+class cPacket_PickupSpawn;
+class cPacket_EntityEquipment;
+class cPacket_Disconnect;
+class cPacket_Chat;
+class cPacket_BlockDig;
+class cPacket_Login;
+class cClientHandle;
+class cPlayer;
+class cPickup;
+class cItem;
+class cEntity;
+class cPawn;
+struct TakeDamageInfo;
+
+// tolua_begin
+class cPlugin
+{
+public:
+ cPlugin();
+ virtual ~cPlugin();
+
+ virtual void OnDisable() {}
+ virtual bool Initialize() = 0;
+
+ // Called each tick
+ virtual void Tick(float a_Dt);
+
+ /**
+ * On all these functions, return true if you want to override default behavior
+ * You can also return false, so default behavior is used, but with changed PacketData
+ **/
+ virtual bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player );
+ virtual bool OnDisconnect( std::string a_Reason, cPlayer* a_Player );
+ virtual bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player );
+ virtual bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) { (void)a_PacketData; (void)a_Player; (void)a_PickupItem; return false; }
+ virtual bool OnChat( std::string a_Chat, cPlayer* a_Player );
+ virtual bool OnLogin( cPacket_Login* a_PacketData );
+ virtual void OnPlayerSpawn( cPlayer* a_Player );
+ virtual bool OnPlayerJoin( cPlayer* a_Player );
+ virtual void OnPlayerMove( cPlayer* a_Player ) { (void)a_Player; }
+ virtual void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) { (void)a_Pawn; (void)a_TakeDamageInfo; }
+ virtual bool OnKilled( cPawn* a_Killed, cEntity* a_Killer ) { (void)a_Killed; (void)a_Killer; return false; }
+
+ // Accessors
+ std::string GetName() const { return m_Name; }
+ void SetName( std::string a_Name ) { m_Name = a_Name; }
+
+ int GetVersion() const { return m_Version; }
+ void SetVersion( int a_Version ) { m_Version = a_Version; }
+
+ struct CommandStruct
+ {
+ std::string Command;
+ std::string Description;
+ std::string Permission;
+ };
+
+ void AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission );
+ // tolua_end
+ typedef bool (FuncCommandHandler)( std::string & a_Command, std::vector< std::string > & a_Split );
+ void BindCommand( FuncCommandHandler* a_Function, std::string & a_Command ); // >> EXPORTED IN MANUALBINDINGS <<
+ const std::vector< CommandStruct > & GetCommands() const { return m_Commands; } // >> EXPORTED IN MANUALBINDINGS <<
+
+private:
+ std::vector< CommandStruct > m_Commands;
+ std::string m_Name;
+ int m_Version;
+}; //tolua_export
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp
new file mode 100644
index 000000000..db776f0a7
--- /dev/null
+++ b/source/cPluginManager.cpp
@@ -0,0 +1,423 @@
+#include "cPluginManager.h"
+#include "cPlugin.h"
+#include "cPlugin_Lua.h"
+#include "cMCLogger.h"
+#include "cWebAdmin.h"
+#include "cItem.h"
+#include "cRoot.h"
+#include "cLuaCommandBinder.h"
+
+#include <stdarg.h>
+
+#include "../iniFile/iniFile.h"
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+typedef std::list< cPlugin_Lua* > LuaPluginList;
+typedef std::map< cPluginManager::PluginHook, cPluginManager::PluginList > HookMap;
+
+struct cPluginManager::sPluginManagerState
+{
+ LuaPluginList LuaPlugins;
+ cPluginManager::PluginList Plugins;
+ HookMap Hooks;
+};
+
+cPluginManager* cPluginManager::GetPluginManager()
+{
+ LOGWARN("WARNING: Using deprecated function cPluginManager::GetPluginManager() use cRoot::Get()->GetPluginManager() instead!");
+ return cRoot::Get()->GetPluginManager();
+}
+
+cPluginManager::cPluginManager()
+ : m_pState( new sPluginManagerState )
+ , m_LuaCommandBinder( new cLuaCommandBinder() )
+ , m_bReloadPlugins(false)
+{
+}
+
+cPluginManager::~cPluginManager()
+{
+ UnloadPluginsNow();
+ delete m_LuaCommandBinder;
+ delete m_pState;
+}
+
+void cPluginManager::ReloadPlugins()
+{
+ m_bReloadPlugins = true;
+}
+
+void cPluginManager::ReloadPluginsNow()
+{
+ LOG("--Loading plugins--");
+ m_bReloadPlugins = false;
+ UnloadPluginsNow();
+
+ cIniFile IniFile("settings.ini");
+ if( IniFile.ReadFile() )
+ {
+ unsigned int KeyNum = IniFile.FindKey("Plugins");
+ unsigned int NumPlugins = IniFile.GetNumValues( KeyNum );
+ if( NumPlugins > 0 )
+ {
+ for(unsigned int i = 0; i < NumPlugins; i++)
+ {
+ std::string ValueName = IniFile.GetValueName(KeyNum, i );
+ if( ValueName.compare("Plugin") == 0 )
+ { // It's a plugin
+ std::string PluginFile = IniFile.GetValue(KeyNum, i );
+ if( PluginFile.compare("") != 0 )
+ {
+ // allow for comma separated plugin list
+ // degrades and works fine for the plugin
+ // per line
+ std::vector< std::string > split = StringSplit( PluginFile, "," );
+ for (unsigned int j = 0; j < split.size(); j++) {
+ cPlugin_Lua* Plugin = new cPlugin_Lua( (split[j] + std::string(".lua") ).c_str() );
+ if( !AddLuaPlugin( Plugin ) )
+ {
+ delete Plugin;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if( GetNumPlugins() == 0 )
+ {
+ LOG("No plugins loaded");
+ }
+ else
+ {
+ LOG("Loaded %i plugin(s)", GetNumPlugins() );
+ }
+ }
+ else
+ {
+ LOG("WARNING: Can't find settings.ini, so can't load any plugins.");
+ }
+ LOG("--Done loading plugins--");
+}
+
+void cPluginManager::Tick(float a_Dt)
+{
+ if( m_bReloadPlugins )
+ {
+ ReloadPluginsNow();
+ }
+
+
+ HookMap::iterator Plugins = m_pState->Hooks.find( E_PLUGIN_TICK );
+ if( Plugins != m_pState->Hooks.end() )
+ {
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ (*itr)->Tick( a_Dt );
+ }
+ }
+}
+
+bool cPluginManager::CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... )
+{
+ HookMap::iterator Plugins = m_pState->Hooks.find( a_Hook );
+
+ // Special case for chat hook, since you can also bind commands (bound commands don't use chat hook)
+ if( a_Hook == E_PLUGIN_CHAT )
+ {
+ if( a_NumArgs != 2 ) return false;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ const char* Message = va_arg(argptr, const char* );
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+
+ if( m_LuaCommandBinder->HandleCommand( std::string( Message ), Player ) )
+ return true;
+
+ if( Plugins != m_pState->Hooks.end() )
+ {
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnChat( Message, Player ) )
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ if( Plugins != m_pState->Hooks.end() )
+ {
+ switch( a_Hook )
+ {
+ case E_PLUGIN_COLLECT_ITEM:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPickup* Pickup = va_arg(argptr, cPickup* );
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnCollectItem( Pickup, Player ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_BLOCK_DIG:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPacket_BlockDig* Packet = va_arg(argptr, cPacket_BlockDig* );
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ cItem* Item = va_arg( argptr, cItem* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnBlockDig( Packet, Player, Item ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_BLOCK_PLACE:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPacket_BlockPlace* Packet = va_arg(argptr, cPacket_BlockPlace* );
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnBlockPlace( Packet, Player ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_DISCONNECT:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ const char* Reason = va_arg(argptr, const char* );
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnDisconnect( Reason, Player ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_LOGIN:
+ {
+ if( a_NumArgs != 1 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPacket_Login* Packet = va_arg(argptr, cPacket_Login* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnLogin( Packet ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_PLAYER_JOIN:
+ {
+ if( a_NumArgs != 1 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnPlayerJoin( Player ) )
+ return true;
+ }
+ }
+ break;
+ case E_PLUGIN_PLAYER_MOVE:
+ {
+ if( a_NumArgs != 1 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPlayer* Player = va_arg(argptr, cPlayer* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ (*itr)->OnPlayerMove( Player );
+ }
+ }
+ break;
+ case E_PLUGIN_TAKE_DAMAGE:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPawn* Pawn = va_arg(argptr, cPawn* );
+ TakeDamageInfo* TDI = va_arg(argptr, TakeDamageInfo* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ (*itr)->OnTakeDamage( Pawn, TDI );
+ }
+ }
+ break;
+ case E_PLUGIN_KILLED:
+ {
+ if( a_NumArgs != 2 ) break;
+ va_list argptr;
+ va_start( argptr, a_NumArgs);
+ cPawn* Killed = va_arg(argptr, cPawn* );
+ cEntity* Killer = va_arg(argptr, cEntity* );
+ va_end (argptr);
+ for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr )
+ {
+ if( (*itr)->OnKilled( Killed, Killer ) )
+ return true;
+ }
+ }
+ break;
+ default:
+ LOG("WARNING: Calling Unknown hook: %i", a_Hook );
+ break;
+ }
+ }
+ return false;
+}
+
+cPlugin* cPluginManager::GetPlugin( std::string a_Plugin )
+{
+ for( PluginList::iterator itr = m_pState->Plugins.begin(); itr != m_pState->Plugins.end(); ++itr )
+ {
+ if( (*itr)->GetName().compare( a_Plugin ) == 0 )
+ {
+ return *itr;
+ }
+ }
+ return 0;
+}
+
+const cPluginManager::PluginList & cPluginManager::GetAllPlugins()
+{
+ return m_pState->Plugins;
+}
+
+void cPluginManager::UnloadPluginsNow()
+{
+ m_pState->Hooks.clear();
+
+ while( m_pState->LuaPlugins.size() > 0 )
+ {
+ cPlugin_Lua* LuaPlugin = *m_pState->LuaPlugins.begin();
+ if( LuaPlugin )
+ {
+ cWebAdmin* WebAdmin = cRoot::Get()->GetWebAdmin();
+ if( WebAdmin ) WebAdmin->RemovePlugin( LuaPlugin->GetLuaState() );
+ delete LuaPlugin;
+ }
+ m_pState->LuaPlugins.remove( LuaPlugin );
+ }
+
+ while( m_pState->Plugins.size() > 0 )
+ {
+ RemovePlugin( *m_pState->Plugins.begin(), true );
+ }
+}
+
+void cPluginManager::RemovePlugin( cPlugin* a_Plugin, bool a_bDelete /* = false */ )
+{
+ if( a_bDelete )
+ {
+ m_LuaCommandBinder->RemoveBindingsForPlugin( a_Plugin );
+ m_pState->Plugins.remove( a_Plugin );
+ a_Plugin->OnDisable();
+ delete a_Plugin;
+ }
+ else
+ {
+ for( LuaPluginList::iterator itr = m_pState->LuaPlugins.begin(); itr != m_pState->LuaPlugins.end(); ++itr )
+ {
+ (*itr)->RemovePlugin( a_Plugin );
+ }
+ }
+}
+
+bool cPluginManager::AddPlugin( cPlugin* a_Plugin )
+{
+ if( a_Plugin->Initialize() )
+ {
+ m_pState->Plugins.remove( a_Plugin );
+ m_pState->Plugins.push_back( a_Plugin );
+ return true;
+ }
+ return false;
+}
+
+bool cPluginManager::AddPlugin( lua_State* a_LuaState, cPlugin* a_Plugin )
+{
+ cPlugin_Lua* LuaPlugin = GetLuaPlugin( a_LuaState );
+ if( LuaPlugin && a_Plugin->Initialize() )
+ {
+ m_pState->Plugins.remove( a_Plugin );
+ m_pState->Plugins.push_back( a_Plugin );
+ LuaPlugin->AddPlugin( a_Plugin );
+ return true;
+ }
+ return false;
+}
+
+bool cPluginManager::AddLuaPlugin( cPlugin_Lua* a_Plugin )
+{
+ m_pState->LuaPlugins.push_back( a_Plugin ); // It HAS to be in here before calling Initialize, so it can be found by AddPlugin()
+ if(a_Plugin->Initialize() )
+ {
+ return true;
+ }
+ LOG(">>>>>>> Could not initialize a plugin! ");
+ m_pState->LuaPlugins.remove( a_Plugin );
+ return false;
+}
+
+void cPluginManager::RemoveLuaPlugin( std::string a_FileName )
+{
+ for( LuaPluginList::iterator itr = m_pState->LuaPlugins.begin(); itr != m_pState->LuaPlugins.end(); ++itr )
+ {
+ if( (*itr)->GetFileName() == a_FileName )
+ {
+ cPlugin_Lua* Plugin = *itr;
+ delete Plugin;
+ m_pState->LuaPlugins.remove( Plugin );
+ return;
+ }
+ }
+}
+
+cPlugin_Lua* cPluginManager::GetLuaPlugin( lua_State* a_State )
+{
+ for( LuaPluginList::iterator itr = m_pState->LuaPlugins.begin(); itr != m_pState->LuaPlugins.end(); ++itr )
+ {
+ if( (*itr)->GetLuaState() == a_State )
+ {
+ return *itr;
+ }
+ }
+ return 0;
+}
+
+void cPluginManager::AddHook( cPlugin* a_Plugin, PluginHook a_Hook )
+{
+ PluginList & Plugins = m_pState->Hooks[ a_Hook ];
+ Plugins.remove( a_Plugin );
+ Plugins.push_back( a_Plugin );
+}
+
+unsigned int cPluginManager::GetNumPlugins()
+{
+ return m_pState->Plugins.size();
+} \ No newline at end of file
diff --git a/source/cPluginManager.h b/source/cPluginManager.h
new file mode 100644
index 000000000..32c7b9d3a
--- /dev/null
+++ b/source/cPluginManager.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <list>
+
+struct lua_State;
+class cLuaCommandBinder;
+class cPlugin;
+class cPlugin_Lua;
+class cPluginManager //tolua_export
+{ //tolua_export
+public: //tolua_export
+
+ // Called each tick
+ virtual void Tick(float a_Dt);
+
+ enum PluginHook //tolua_export
+ { //tolua_export
+ E_PLUGIN_TICK, //tolua_export
+ E_PLUGIN_CHAT, //tolua_export
+ E_PLUGIN_COLLECT_ITEM, //tolua_export
+ E_PLUGIN_BLOCK_DIG, //tolua_export
+ E_PLUGIN_BLOCK_PLACE, //tolua_export
+ E_PLUGIN_DISCONNECT, //tolua_export
+ E_PLUGIN_HANDSHAKE, //tolua_export
+ E_PLUGIN_LOGIN, //tolua_export
+ E_PLUGIN_PLAYER_SPAWN, //tolua_export
+ E_PLUGIN_PLAYER_JOIN, //tolua_export
+ E_PLUGIN_PLAYER_MOVE, //tolua_export
+ E_PLUGIN_TAKE_DAMAGE, //tolua_export
+ E_PLUGIN_KILLED, //tolua_export
+ }; //tolua_export
+
+ static cPluginManager * GetPluginManager(); //tolua_export
+
+ typedef std::list< cPlugin* > PluginList;
+ cPlugin* GetPlugin( std::string a_Plugin ); //tolua_export
+ const PluginList & GetAllPlugins(); // >> EXPORTED IN MANUALBINDINGS <<
+
+ void ReloadPlugins(); //tolua_export
+ bool AddPlugin( cPlugin* a_Plugin );
+ bool AddPlugin( lua_State* a_LuaState, cPlugin* a_Plugin ); //tolua_export
+ bool AddLuaPlugin( cPlugin_Lua* a_Plugin );
+ void AddHook( cPlugin* a_Plugin, PluginHook a_Hook ); //tolua_export
+
+ unsigned int GetNumPlugins(); //tolua_export
+
+ bool CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... );
+
+ void RemovePlugin( cPlugin* a_Plugin, bool a_bDelete = false ); //tolua_export
+ void RemoveLuaPlugin( std::string a_FileName ); //tolua_export
+ cPlugin_Lua* GetLuaPlugin( lua_State* a_State ); //tolua_export
+
+ cLuaCommandBinder* GetLuaCommandBinder() { return m_LuaCommandBinder; }
+private:
+ friend class cRoot;
+ cPluginManager();
+ ~cPluginManager();
+
+ struct sPluginManagerState;
+ sPluginManagerState* m_pState;
+
+ void ReloadPluginsNow();
+ void UnloadPluginsNow();
+
+ cLuaCommandBinder* m_LuaCommandBinder;
+
+ bool m_bReloadPlugins;
+}; //tolua_export
diff --git a/source/cPlugin_Lua.cpp b/source/cPlugin_Lua.cpp
new file mode 100644
index 000000000..3265f0615
--- /dev/null
+++ b/source/cPlugin_Lua.cpp
@@ -0,0 +1,97 @@
+#define LUA_USE_POSIX
+#include "cMCLogger.h"
+#include <string>
+#include "cPlugin_Lua.h"
+#include "cPluginManager.h"
+#include "cRoot.h"
+
+extern "C"
+{
+ #include "lualib.h"
+}
+
+#include "tolua++.h"
+#include "Bindings.h"
+#include "ManualBindings.h"
+
+bool report_errors(lua_State* lua, int status)
+{
+ if ( status!=0 )
+ {
+ std::string s = lua_tostring(lua, -1);
+ LOGERROR("-- %s", s.c_str() );
+ lua_pop(lua, 1);
+ return true;
+ }
+ return false;
+}
+
+cPlugin_Lua::~cPlugin_Lua()
+{
+ UnloadPlugins();
+ if( m_LuaState )
+ {
+ lua_close( m_LuaState );
+ m_LuaState = 0;
+ }
+}
+
+cPlugin_Lua::cPlugin_Lua(const char* a_Plugin)
+: m_LuaState( 0 )
+{
+ m_FileName.assign( a_Plugin );
+}
+
+bool cPlugin_Lua::Initialize()
+{
+ if( !m_LuaState )
+ {
+ m_LuaState = lua_open();
+ luaL_openlibs( m_LuaState );
+ tolua_AllToLua_open(m_LuaState);
+ ManualBindings::Bind( m_LuaState );
+ }
+
+ int s = luaL_loadfile(m_LuaState, (std::string("Plugins/") + m_FileName ).c_str() );
+ if( report_errors( m_LuaState, s ) )
+ {
+ LOGERROR("Can't load plugin %s", m_FileName.c_str() );
+ lua_close( m_LuaState );
+ m_LuaState = 0;
+ return false;
+ }
+
+ s = lua_pcall(m_LuaState, 0, LUA_MULTRET, 0);
+ if( report_errors( m_LuaState, s ) )
+ {
+ LOGERROR("Error in plugin %s", m_FileName.c_str() );
+ lua_close( m_LuaState );
+ m_LuaState = 0;
+ return false;
+ }
+ return true;
+}
+
+void cPlugin_Lua::AddPlugin( cPlugin* a_Plugin )
+{
+ m_Plugins.push_back( a_Plugin );
+}
+
+void cPlugin_Lua::RemovePlugin( cPlugin* a_Plugin )
+{
+ m_Plugins.remove( a_Plugin );
+ cRoot::Get()->GetPluginManager()->RemovePlugin( a_Plugin, true );
+}
+
+void cPlugin_Lua::UnloadPlugins()
+{
+ while( m_Plugins.begin() != m_Plugins.end() )
+ {
+ RemovePlugin( *m_Plugins.begin() );
+ }
+}
+
+lua_State* cPlugin_Lua::GetLuaState()
+{
+ return m_LuaState;
+} \ No newline at end of file
diff --git a/source/cPlugin_Lua.h b/source/cPlugin_Lua.h
new file mode 100644
index 000000000..e84ac8451
--- /dev/null
+++ b/source/cPlugin_Lua.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <string>
+#include <list>
+
+class cPickup;
+class cPlayer;
+class cPacket_BlockPlace;
+class cPacket_BlockDig;
+class cPacket_Login;
+class cPlugin;
+class cPlugin_Lua //tolua_export
+{ //tolua_export
+public:
+ cPlugin_Lua(const char* a_Plugin);
+ ~cPlugin_Lua();
+
+ virtual bool Initialize();
+
+ std::string GetFileName() { return m_FileName; } //tolua_export
+ typedef struct lua_State lua_State;
+ lua_State* GetLuaState();
+
+ void AddPlugin( cPlugin* a_Plugin );
+ void RemovePlugin( cPlugin* a_Plugin );
+private:
+ void UnloadPlugins();
+
+ std::string m_FileName;
+ lua_State* m_LuaState;
+
+ typedef std::list< cPlugin* > PluginList;
+ PluginList m_Plugins;
+}; //tolua_export \ No newline at end of file
diff --git a/source/cRecipeChecker.cpp b/source/cRecipeChecker.cpp
new file mode 100644
index 000000000..d85cb3c31
--- /dev/null
+++ b/source/cRecipeChecker.cpp
@@ -0,0 +1,458 @@
+#include "cRecipeChecker.h"
+
+#include <fstream>
+#include <sstream>
+#include <vector>
+#include <string>
+#include <list>
+
+#ifndef _WIN32
+#include <cstring>
+#include <cstdlib>
+#endif
+
+#include "Defines.h"
+#include "cMCLogger.h"
+#include "cRoot.h"
+
+typedef std::list< cRecipeChecker::Recipe* > RecipeList;
+struct cRecipeChecker::sRecipeCheckerState
+{
+ RecipeList Recipes;
+};
+
+cRecipeChecker* cRecipeChecker::GetRecipeChecker()
+{
+ LOGWARN("WARNING: Using deprecated function cRecipeChecker::GetRecipeChecker() use cRoot::Get()->GetRecipeChecker() instead!");
+ return cRoot::Get()->GetRecipeChecker();
+}
+
+cRecipeChecker::Recipe::~Recipe()
+{
+ delete [] Slots;
+ Slots = 0;
+}
+
+cRecipeChecker::~cRecipeChecker()
+{
+ ClearRecipes();
+ delete m_pState;
+}
+
+cRecipeChecker::cRecipeChecker()
+ : m_pState( new sRecipeCheckerState )
+{
+ ReloadRecipes();
+}
+
+void cRecipeChecker::ClearRecipes()
+{
+ while( m_pState->Recipes.size() > 0 )
+ {
+ delete *m_pState->Recipes.begin();
+ m_pState->Recipes.remove( *m_pState->Recipes.begin() );
+ }
+}
+
+void PrintRecipe( std::vector< cRecipeChecker::RecipeSlot > & RecipeSlots )
+{
+ LOG("Recipe:");
+ for(unsigned int i = 0; i < RecipeSlots.size(); i++)
+ {
+ cRecipeChecker::RecipeSlot Slot = RecipeSlots[i];
+ LOG("x:%i y:%i id:%i #%i", Slot.x, Slot.y, Slot.Item.m_ItemID, Slot.Item.m_ItemCount );
+ }
+}
+
+void PrintNear( std::ifstream & f, int a_History = 64 )
+{
+ f.clear();
+
+ // Calculate how far we can move pointer back
+ std::streamoff Position = f.tellg();
+ f.seekg( 0, std::ios_base::beg );
+ std::streamoff Difference = Position - f.tellg();
+ if( Difference > a_History ) Difference = a_History;
+ f.seekg( Position - Difference, std::ios_base::beg );
+
+ std::string Near;
+ if( f.good() )
+ {
+ while( f.good() && Near.size() < (unsigned int)Difference )
+ {
+ char c;
+ f.get(c);
+ Near.push_back( c );
+ }
+ }
+ LOGERROR("Error near: \"%s\"", Near.c_str() );
+}
+
+void cRecipeChecker::ReloadRecipes()
+{
+ LOG("--Loading recipes--");
+ ClearRecipes();
+
+ /*
+ char a_File[] = "recipes.txt";
+
+ FILE* f = 0;
+ #ifdef _WIN32
+ if( fopen_s(&f, a_File, "rb" ) == 0 ) // no error
+ #else
+ if( (f = fopen(a_File, "rb" )) != 0 ) // no error
+ #endif
+ {
+ char c;
+ while( fread( &c, sizeof(char), 1, f) == 1 )
+ {
+
+ }
+ }
+ else
+ {
+ LOG("Could not open file for recipes: %s", a_File);
+ return;
+ }
+ */
+
+
+ std::ifstream f;
+
+ char a_File[] = "recipes.txt";
+ f.open(a_File, std::ios::in);
+ std::string input;
+
+ if( !f.good() )
+ {
+ f.close();
+ LOG("Could not open file for recipes: %s", a_File);
+ return;
+ }
+
+ std::vector< RecipeSlot > RecipeSlots;
+
+ bool bError = false;
+ while( f.good() )
+ {
+ bool bLoadSlot = false;
+ bool bLoadResult = false;
+
+ char c;
+ f >> c;
+ f.unget();
+ if( c == '#' )
+ {
+ //LOG("Ignoring comment");
+ while( f.good() && c != '\n' )
+ {
+ f.get( c );
+ }
+ continue;
+ }
+
+ f.get( c );
+ while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); }
+ if( f.eof() ) break;
+ f.unget();
+
+ int width, height;
+ f >> width;
+ f >> c; if( c != 'x' ) { bError=true; break; }
+ f >> height;
+ f >> c;
+ if( c == ',' ) bLoadSlot = true;
+
+ while( f.good() && bLoadSlot )
+ {
+ bool bDontAddRecipe = false;
+ int x, y, ItemID, Amount;
+ if( f.peek() == '*' )
+ {
+ f >> c;
+ x = -1;
+ }
+ else
+ {
+ f >> x;
+ }
+ f >> c; if( c != ':' ) { bError=true; break; }
+ if( f.peek() == '*' )
+ {
+ f >> c;
+ y = -1;
+ }
+ else
+ {
+ f >> y;
+ }
+ f >> c; if( c != ':' ) { bError=true; break; }
+ f >> ItemID;
+ f >> c; if( c != ':' ) { bError=true; break; }
+ f >> Amount;
+
+ f >> c;
+ if( c == '@' ) bLoadResult = true;
+ if( c != ',' ) bLoadSlot = false;
+
+ if( !isValidItem( ItemID ) )
+ {
+ LOGERROR("Error in recipes file (%s): Invalid Item ID %i", a_File, ItemID );
+ bDontAddRecipe = true;
+ }
+ if( x < 0 && y < 0 )
+ {
+ if( Amount < 0 )
+ {
+ LOGERROR("Error in recipes file (%s): Invalid use of negative amount on wildcard coordinates", a_File );
+ bDontAddRecipe = true;
+ }
+ for(int x = 0; x < width; ++x) for(int y = 0; y < height; ++y )
+ {
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = x;
+ Slot.y = y;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ else if( x < 0 )
+ {
+ if( Amount < 0 )
+ {
+ for(int x = 0; x < width; ++x) for(int yy = 0; yy < height; ++yy )
+ {
+ if( yy == y-1 ) continue;
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = x;
+ Slot.y = yy;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ else
+ {
+ for(int x = 0; x < width; ++x)
+ {
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = x;
+ Slot.y = y-1;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ }
+ else if( y < 0 )
+ {
+ if( Amount < 0 )
+ {
+ for(int xx = 0; xx < width; ++xx) for(int y = 0; y < height; ++y )
+ {
+ if( xx == x-1 ) continue;
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = xx;
+ Slot.y = y;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ else
+ {
+ for(int y = 0; y < height; ++y)
+ {
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = x-1;
+ Slot.y = y;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ }
+ else
+ {
+ if( Amount < 0 )
+ {
+ for(int xx = 0; xx < width; ++xx) for(int yy = 0; yy < height; ++yy )
+ {
+ if( xx == x-1 && yy == y-1 ) continue;
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = xx;
+ Slot.y = yy;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ else
+ {
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
+ RecipeSlot Slot;
+ Slot.Item = Item;
+ Slot.x = x-1;
+ Slot.y = y-1;
+ RecipeSlots.push_back( Slot );
+ }
+ }
+ //LOG("%i %i %i %i", x, y, ItemID, Amount );
+
+ if( bLoadResult )
+ {
+ bLoadResult = false;
+ f >> ItemID;
+ f >> c; if( c != ':' ) { bError=true; break; }
+ f >> Amount;
+ //LOG("%i %i", ItemID, Amount );
+ if( !isValidItem( ItemID ) )
+ {
+ LOGERROR("Error in recipes file (%s): Invalid Item ID %i", a_File, ItemID );
+ bDontAddRecipe = true;
+ }
+
+ // Do a sanity check - Handshake algorithm :)
+ bool bDuplicateEntries = false;
+ for(unsigned int i = 0; i < RecipeSlots.size(); i++)
+ {
+ for(unsigned int j = i+1; j < RecipeSlots.size(); j++)
+ {
+ if( RecipeSlots[i].x == RecipeSlots[j].x && RecipeSlots[i].y == RecipeSlots[j].y )
+ {
+ LOGERROR("Error in recipes file (%s): Duplicate item on coordinates %i:%i", a_File, RecipeSlots[i].x+1, RecipeSlots[i].y+1 );
+ bDontAddRecipe = true;
+ bDuplicateEntries = true;
+ break;
+ }
+ }
+ }
+ if( bDuplicateEntries )
+ {
+ PrintNear( f, 64 );
+ PrintRecipe( RecipeSlots );
+ }
+
+ if( bDontAddRecipe == false )
+ {
+ cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
+ Recipe* recipe = new Recipe;
+ recipe->Result = Item;
+ recipe->NumItems = RecipeSlots.size();
+ recipe->Slots = new RecipeSlot[ recipe->NumItems ];
+ memcpy( recipe->Slots, &RecipeSlots[0], sizeof(RecipeSlot)*recipe->NumItems );
+ m_pState->Recipes.push_back( recipe );
+ //LOG("Loaded recipe for %i times %i", Amount, ItemID );
+ }
+
+ RecipeSlots.clear();
+ }
+ }
+ if( bError ) break;
+ }
+ if( bError || ( !f.eof() && !f.good() ) )
+ {
+ LOGERROR("Error: Wrong format");
+ PrintNear( f, 128 );
+ }
+ f.close();
+
+ LOG("Found %i recipes", m_pState->Recipes.size() );
+// for(RecipeList::iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
+// {
+// LOG("Recipe for %i times %i", (*itr)->Result.m_ItemCount, (*itr)->Result.m_ItemID );
+// for(unsigned int j = 0; j < (*itr)->NumItems; j++)
+// {
+// RecipeSlot Slot = (*itr)->Slots[j];
+// LOG("%i %i %i %i", Slot.x, Slot.y, Slot.Item.m_ItemID, Slot.Item.m_ItemCount );
+// }
+// }
+ LOG("--Done loading recipes--");
+}
+
+cItem cRecipeChecker::CookIngredients( cItem* a_Items, int a_Width, int a_Height, bool a_bConsumeIngredients /* = false */ )
+{
+ int iLeft = 999, iTop = 999;
+ int iRight = 0, iBottom = 0;
+ for(int y = 0; y < a_Height; y++ ) for(int x = 0; x < a_Width; x++)
+ {
+ cItem Item = a_Items[x + y*a_Width];
+ if( Item.m_ItemID != E_ITEM_EMPTY && Item.m_ItemCount > 0 )
+ {
+ iRight = MAX(x, iRight);
+ iBottom = MAX(y, iBottom);
+ iLeft = MIN(x, iLeft);
+ iTop = MIN(y, iTop);
+ }
+ }
+
+ for(RecipeList::iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
+ {
+ Recipe* recipe = (*itr);
+ int Left = 999, Top = 999;
+ int Right = 0, Bottom = 0;
+ for(unsigned int i = 0; i < recipe->NumItems; i++)
+ {
+ Right = MAX(recipe->Slots[i].x, Right);
+ Bottom = MAX(recipe->Slots[i].y, Bottom);
+ Left = MIN(recipe->Slots[i].x, Left);
+ Top = MIN(recipe->Slots[i].y, Top);
+ }
+ if( Right-Left != iRight-iLeft || Bottom-Top != iBottom-iTop ) continue;
+ // it has the right dimensions
+
+ // Check for empty spaces
+ unsigned int Hash = 0;
+ for(unsigned int i = 0; i < recipe->NumItems; i++)
+ {
+ int x = recipe->Slots[i].x - Left + iLeft +1;
+ int y = recipe->Slots[i].y - Top + iTop +1;
+ Hash += x + y * a_Width;
+ }
+ for(int y = 0; y < a_Height; y++ ) for(int x = 0; x < a_Width; x++)
+ {
+ cItem & Item = a_Items[x + y*a_Width];
+ if( Item.m_ItemID != E_ITEM_EMPTY && Item.m_ItemCount > 0 )
+ {
+ Hash -= (x+1) + (y+1)*a_Width;
+ }
+ }
+ if( Hash != 0 ) continue; // Empty spaces not in right place
+
+ bool bWrong = false;
+ for(unsigned int i = 0; i < recipe->NumItems; i++)
+ {
+ int x = recipe->Slots[i].x - Left + iLeft;
+ int y = recipe->Slots[i].y - Top + iTop;
+ cItem Item = a_Items[x + y*a_Width];
+ if( Item.m_ItemID != recipe->Slots[i].Item.m_ItemID
+ || Item.m_ItemCount < recipe->Slots[i].Item.m_ItemCount )
+ {
+ bWrong = true;
+ break;
+ }
+ }
+ if( bWrong ) continue;
+
+ cItem Dish = recipe->Result;
+
+ // else
+ if( a_bConsumeIngredients )
+ {
+ // Consume! nomnom~
+ for(unsigned int i = 0; i < recipe->NumItems; i++)
+ {
+ int x = recipe->Slots[i].x - Left + iLeft;
+ int y = recipe->Slots[i].y - Top + iTop;
+ a_Items[x + y*a_Width].m_ItemCount -= recipe->Slots[i].Item.m_ItemCount;
+ if( a_Items[x + y*a_Width].m_ItemCount <= 0 ) a_Items[x + y*a_Width].Empty();
+ }
+ Dish = CookIngredients( a_Items, a_Width, a_Height, false );
+ }
+
+ // Return the resulting dish!
+ return Dish;
+ }
+ return cItem();
+}
diff --git a/source/cRecipeChecker.h b/source/cRecipeChecker.h
new file mode 100644
index 000000000..91084b7de
--- /dev/null
+++ b/source/cRecipeChecker.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "cItem.h"
+
+class cRecipeChecker
+{
+public:
+ static cRecipeChecker * GetRecipeChecker();
+
+ // Grid of cItems of a_Width width and a_Height Height
+ cItem CookIngredients( cItem* a_Items, int a_Width, int a_Height, bool a_bConsumeIngredients = false );
+
+ struct RecipeSlot
+ {
+ cItem Item;
+ int x, y;
+ };
+
+ struct Recipe
+ {
+ Recipe() : Slots( 0 ), NumItems( 0 ) {}
+ ~Recipe();
+ RecipeSlot* Slots; // Array of RecipeSlots
+ unsigned int NumItems;
+ cItem Result;
+ };
+
+ void ReloadRecipes();
+ static void DeleteMe();
+private:
+ friend class cRoot;
+ cRecipeChecker();
+ ~cRecipeChecker();
+
+ struct sRecipeCheckerState;
+ sRecipeCheckerState* m_pState;
+
+ void ClearRecipes();
+}; \ No newline at end of file
diff --git a/source/cReferenceManager.cpp b/source/cReferenceManager.cpp
new file mode 100644
index 000000000..cad6ca0a2
--- /dev/null
+++ b/source/cReferenceManager.cpp
@@ -0,0 +1,36 @@
+#include "cReferenceManager.h"
+#include "cEntity.h"
+
+cReferenceManager::cReferenceManager( ENUM_REFERENCE_MANAGER_TYPE a_Type )
+ : m_Type( a_Type )
+{
+}
+
+cReferenceManager::~cReferenceManager()
+{
+ if( m_Type == RFMNGR_REFERENCERS )
+ {
+ for( std::list< cEntity** >::iterator itr = m_References.begin(); itr != m_References.end(); ++itr )
+ {
+ *(*itr) = 0; // Set referenced pointer to 0
+ }
+ }
+ else
+ {
+ for( std::list< cEntity** >::iterator itr = m_References.begin(); itr != m_References.end(); ++itr )
+ {
+ cEntity* Ptr = (*(*itr));
+ if( Ptr ) Ptr->Dereference( *(*itr) );
+ }
+ }
+}
+
+void cReferenceManager::AddReference( cEntity*& a_EntityPtr )
+{
+ m_References.push_back( &a_EntityPtr );
+}
+
+void cReferenceManager::Dereference( cEntity*& a_EntityPtr )
+{
+ m_References.remove( &a_EntityPtr );
+} \ No newline at end of file
diff --git a/source/cReferenceManager.h b/source/cReferenceManager.h
new file mode 100644
index 000000000..397527de1
--- /dev/null
+++ b/source/cReferenceManager.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <list>
+
+class cEntity;
+class cReferenceManager
+{
+public:
+ enum ENUM_REFERENCE_MANAGER_TYPE
+ {
+ RFMNGR_REFERENCERS,
+ RFMNGR_REFERENCES,
+ };
+ cReferenceManager( ENUM_REFERENCE_MANAGER_TYPE a_Type );
+ ~cReferenceManager();
+
+ void AddReference( cEntity*& a_EntityPtr );
+ void Dereference( cEntity*& a_EntityPtr );
+private:
+ ENUM_REFERENCE_MANAGER_TYPE m_Type;
+ std::list< cEntity** > m_References;
+}; \ No newline at end of file
diff --git a/source/cRoot.cpp b/source/cRoot.cpp
new file mode 100644
index 000000000..7f0012764
--- /dev/null
+++ b/source/cRoot.cpp
@@ -0,0 +1,162 @@
+#include "cRoot.h"
+#include "cMCLogger.h"
+#include "cServer.h"
+#include "cWorld.h"
+#include "cWebAdmin.h"
+#include "cFurnaceRecipe.h"
+#include "cGroupManager.h"
+#include "cRecipeChecker.h"
+#include "cPluginManager.h"
+#include "cMonsterConfig.h"
+#include "cSleep.h"
+
+#include "../iniFile/iniFile.h"
+
+#include <iostream>
+#include <time.h>
+#include <cstdio>
+
+#ifndef _WIN32
+#include <cstring>
+#endif
+
+cRoot* cRoot::s_Root = 0;
+
+cRoot::cRoot()
+ : m_Server( 0 )
+ , m_World( 0 )
+ , m_MonsterConfig( 0 )
+ , m_GroupManager( 0 )
+ , m_RecipeChecker( 0 )
+ , m_FurnaceRecipe( 0 )
+ , m_WebAdmin( 0 )
+ , m_PluginManager( 0 )
+ , m_Log( 0 )
+ , m_bStop( false )
+ , m_bRestart( false )
+ , m_hInputThread( 0 )
+{
+ s_Root = this;
+}
+
+cRoot::~cRoot()
+{
+ s_Root = 0;
+}
+
+#ifdef _WIN32
+DWORD WINAPI cRoot_InputThread(LPVOID lpParam)
+#else
+void *cRoot_InputThread( void *lpParam )
+#endif
+{
+ cRoot* Root = (cRoot*)lpParam;
+
+ while( 1 )
+ {
+ std::string Command;
+ std::getline(std::cin, Command);
+ Root->ServerCommand( Command.c_str() );
+ }
+ return 0;
+}
+
+void cRoot::Start()
+{
+ if( m_Log ) delete m_Log, m_Log = 0;
+ m_Log = new cMCLogger();
+
+#ifdef _WIN32
+ m_hInputThread = CreateThread(
+ NULL, // default security
+ 0, // default stack size
+ cRoot_InputThread, // name of the thread function
+ this, // thread parameters
+ 0, // default startup flags
+ NULL);
+#else
+ m_hInputThread = new pthread_t;
+ pthread_create( (pthread_t*)m_hInputThread, NULL, cRoot_InputThread, this );
+#endif
+
+ m_bStop = false;
+ while(!m_bStop)
+ {
+ m_bRestart = false;
+
+ m_Server = new cServer();
+
+ cIniFile IniFile("settings.ini"); IniFile.ReadFile();
+ int Port = IniFile.GetValueI("Server", "Port", 25565 );
+ if(!m_Server->InitServer( Port ))
+ {
+ LOG("Failed to start server, shutting down.");
+ return;
+ }
+
+
+ cIniFile WebIniFile("webadmin.ini");
+ if( WebIniFile.ReadFile() )
+ {
+ if( WebIniFile.GetValueB("WebAdmin", "Enabled", false ) == true )
+ {
+ m_WebAdmin = new cWebAdmin(8080);
+ }
+ }
+
+ m_GroupManager = new cGroupManager();
+ m_RecipeChecker = new cRecipeChecker();
+ m_FurnaceRecipe = new cFurnaceRecipe();
+ m_World = new cWorld();
+ m_World->InitializeSpawn();
+
+ m_PluginManager = new cPluginManager(); // This should be last
+ m_PluginManager->ReloadPluginsNow();
+ m_MonsterConfig = new cMonsterConfig(2);
+
+ // This sets stuff in motion
+ m_Server->StartListenThread();
+ //cHeartBeat* HeartBeat = new cHeartBeat();
+
+ while( !m_bStop && !m_bRestart ) // These are modified by external threads
+ {
+ cSleep::MilliSleep( 1000 );
+ }
+
+ // Deallocate stuffs
+ m_Server->Shutdown(); // This waits for threads to stop and d/c clients
+ delete m_PluginManager; m_PluginManager = 0; // This should be first
+ delete m_MonsterConfig; m_MonsterConfig = 0;
+ if( m_WebAdmin ) { delete m_WebAdmin; m_WebAdmin = 0; }
+ delete m_FurnaceRecipe; m_FurnaceRecipe = 0;
+ delete m_RecipeChecker; m_RecipeChecker = 0;
+ delete m_GroupManager; m_GroupManager = 0;
+ delete m_World; m_World = 0;
+ //delete HeartBeat; HeartBeat = 0;
+ delete m_Server; m_Server = 0;
+ }
+
+ // No other way to get it to exit
+#ifdef _WIN32
+ TerminateThread( m_hInputThread, 0 );
+#else
+ // TODO: pthread_kill
+ delete (pthread_t*)m_hInputThread;
+#endif
+
+ delete m_Log; m_Log = 0;
+}
+
+void cRoot::ServerCommand( const char* a_Cmd )
+{
+ //LOG("Command: %s", a_Cmd );
+ m_Server->ServerCommand( a_Cmd );
+ if( strcmp(a_Cmd, "stop") == 0 )
+ {
+ m_bStop = true;
+ }
+ else if( strcmp( a_Cmd, "restart") == 0 )
+ {
+ m_bRestart = true;
+ }
+}
diff --git a/source/cRoot.h b/source/cRoot.h
new file mode 100644
index 000000000..0ba59ae93
--- /dev/null
+++ b/source/cRoot.h
@@ -0,0 +1,52 @@
+#pragma once
+
+class cMonsterConfig;
+class cMCLogger;
+class cGroupManager;
+class cRecipeChecker;
+class cFurnaceRecipe;
+class cWebAdmin;
+class cPluginManager;
+class cServer;
+class cWorld;
+class cRoot //tolua_export
+{ //tolua_export
+public:
+ static cRoot* Get() { return s_Root; } //tolua_export
+
+ cRoot();
+ ~cRoot();
+
+ void Start();
+
+ cServer* GetServer() { return m_Server; } //tolua_export
+ cWorld* GetWorld() { return m_World; } //tolua_export
+ cMonsterConfig *GetMonsterConfig() { return m_MonsterConfig;}
+
+ cGroupManager* GetGroupManager() { return m_GroupManager; } //tolua_export
+ cRecipeChecker* GetRecipeChecker() { return m_RecipeChecker; } //tolua_export
+ cFurnaceRecipe* GetFurnaceRecipe() { return m_FurnaceRecipe; } //tolua_export
+ cWebAdmin* GetWebAdmin() { return m_WebAdmin; } //tolua_export
+ cPluginManager* GetPluginManager() { return m_PluginManager; } //tolua_export
+
+ void ServerCommand( const char* a_Cmd ); //tolua_export
+private:
+ cServer* m_Server;
+ cWorld* m_World;
+ cMonsterConfig *m_MonsterConfig;
+
+ cGroupManager* m_GroupManager;
+ cRecipeChecker* m_RecipeChecker;
+ cFurnaceRecipe* m_FurnaceRecipe;
+ cWebAdmin* m_WebAdmin;
+ cPluginManager* m_PluginManager;
+
+ cMCLogger* m_Log;
+
+ bool m_bStop;
+ bool m_bRestart;
+
+ void* m_hInputThread;
+
+ static cRoot* s_Root;
+}; //tolua_export \ No newline at end of file
diff --git a/source/cSemaphore.cpp b/source/cSemaphore.cpp
new file mode 100644
index 000000000..96c542df6
--- /dev/null
+++ b/source/cSemaphore.cpp
@@ -0,0 +1,96 @@
+#include "cSemaphore.h"
+#include "cMCLogger.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <semaphore.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#endif
+
+cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ )
+#ifndef _WIN32
+ : m_bNamed( false )
+#endif
+{
+#ifndef _WIN32
+ (void)a_MaxCount;
+ m_Handle = new sem_t;
+ if( sem_init( (sem_t*)m_Handle, 0, 0 ) )
+ {
+ LOG("WARNING cSemaphore: Could not create unnamed semaphore, fallback to named.");
+ delete (sem_t*)m_Handle; // named semaphores return their own address
+ m_bNamed = true;
+
+ char c_Str[32];
+ sprintf( c_Str, "cSemaphore%p", this );
+ m_Handle = sem_open( c_Str, O_CREAT, 777, a_InitialCount );
+ if( m_Handle == SEM_FAILED )
+ {
+ LOG("ERROR: Could not create Semaphore. (%i)", errno );
+ }
+ else
+ {
+ if( sem_unlink( c_Str ) != 0 )
+ {
+ LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
+ }
+ }
+ }
+#else
+ m_Handle = CreateSemaphore(
+ NULL, // security attribute
+ a_InitialCount, // initial count
+ a_MaxCount, // maximum count
+ 0 // name (optional)
+ );
+#endif
+}
+
+cSemaphore::~cSemaphore()
+{
+#ifdef _WIN32
+ CloseHandle( m_Handle );
+#else
+ if( m_bNamed )
+ {
+ if( sem_close( (sem_t*)m_Handle ) != 0 )
+ {
+ LOG("ERROR: Could not close cSemaphore. (%i)", errno);
+ }
+ }
+ else
+ {
+ sem_destroy( (sem_t*)m_Handle );
+ delete (sem_t*)m_Handle;
+ }
+ m_Handle = 0;
+
+#endif
+}
+
+void cSemaphore::Wait()
+{
+#ifndef _WIN32
+ if( sem_wait( (sem_t*)m_Handle ) != 0)
+ {
+ LOG("ERROR: Could not wait for cSemaphore. (%i)", errno);
+ }
+#else
+ WaitForSingleObject( m_Handle, INFINITE);
+#endif
+}
+
+void cSemaphore::Signal()
+{
+#ifndef _WIN32
+ if( sem_post( (sem_t*)m_Handle ) != 0 )
+ {
+ LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
+ }
+#else
+ ReleaseSemaphore( m_Handle, 1, NULL );
+#endif
+}
diff --git a/source/cSemaphore.h b/source/cSemaphore.h
new file mode 100644
index 000000000..86e473d11
--- /dev/null
+++ b/source/cSemaphore.h
@@ -0,0 +1,17 @@
+#pragma once
+
+class cSemaphore
+{
+public:
+ cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0 );
+ ~cSemaphore();
+
+ void Wait();
+ void Signal();
+private:
+ void* m_Handle; // HANDLE pointer
+
+#ifndef _WIN32
+ bool m_bNamed;
+#endif
+};
diff --git a/source/cServer.cpp b/source/cServer.cpp
new file mode 100644
index 000000000..966444a25
--- /dev/null
+++ b/source/cServer.cpp
@@ -0,0 +1,553 @@
+// ReDucTor is an awesome guy who helped me a lot
+
+#include "cServer.h"
+#include "cClientHandle.h"
+#include "cMCLogger.h"
+#include "cThread.h"
+#include "cEvent.h"
+#include "cSleep.h"
+#include "cTimer.h"
+#include "cMonster.h"
+#include "cSocket.h"
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cPluginManager.h"
+#include "cGroupManager.h"
+#include "cChatColor.h"
+#include "cPlayer.h"
+#include "cInventory.h"
+#include "cItem.h"
+#include "cRecipeChecker.h"
+#include "cFurnaceRecipe.h"
+#include "cTracer.h"
+#include "cWebAdmin.h"
+
+#include "../iniFile/iniFile.h"
+#include "Vector3f.h"
+
+#include "packets/cPacket_Chat.h"
+
+#ifndef _WIN32
+#include <cstring>
+#include <errno.h>
+#include <semaphore.h>
+#endif
+
+#include <string>
+#include <fstream>
+#include <sstream>
+#include <iostream>
+
+extern "C" {
+ #include "zlib.h"
+}
+
+#ifdef SendMessage
+#undef SendMessage
+#endif
+
+
+bool g_bWaterPhysics = false;
+
+struct cServer::sServerState
+{
+ sServerState()
+ : pListenThread( 0 )
+ , pTickThread( 0 )
+ , bStopListenThread( false )
+ , bStopTickThread( false )
+ {}
+ cSocket SListenClient; // socket listening for client calls
+
+ cThread* pListenThread; bool bStopListenThread;
+ cThread* pTickThread; bool bStopTickThread;
+
+ cEvent RestartEvent;
+ std::string ServerID;
+};
+
+cServer*cServer::GetServer()
+{
+ LOGWARN("WARNING: Using deprecated function cServer::GetServer() use cRoot::Get()->GetServer() instead!");
+ return cRoot::Get()->GetServer();
+}
+
+void cServer::ServerListenThread( void *a_Args )
+{
+ LOG("ServerListenThread");
+ cServer* self = (cServer*)a_Args;
+ sServerState* m_pState = self->m_pState;
+ while( !m_pState->bStopListenThread )
+ {
+ self->StartListenClient();
+ }
+}
+
+std::string GetWSAError()
+{
+#ifdef _WIN32
+ switch( WSAGetLastError() )
+ {
+ case WSANOTINITIALISED:
+ return "WSANOTINITIALISED";
+ case WSAENETDOWN:
+ return "WSAENETDOWN";
+ case WSAEFAULT:
+ return "WSAEFAULT";
+ case WSAENOTCONN:
+ return "WSAENOTCONN";
+ case WSAEINTR:
+ return "WSAEINTR";
+ case WSAEINPROGRESS:
+ return "WSAEINPROGRESS";
+ case WSAENETRESET:
+ return "WSAENETRESET";
+ case WSAENOTSOCK:
+ return "WSAENOTSOCK";
+ case WSAEOPNOTSUPP:
+ return "WSAEOPNOTSUPP";
+ case WSAESHUTDOWN:
+ return "WSAESHUTDOWN";
+ case WSAEWOULDBLOCK:
+ return "WSAEWOULDBLOCK";
+ case WSAEMSGSIZE:
+ return "WSAEMSGSIZE";
+ case WSAEINVAL:
+ return "WSAEINVAL";
+ case WSAECONNABORTED:
+ return "WSAECONNABORTED";
+ case WSAETIMEDOUT:
+ return "WSAETIMEDOUT";
+ case WSAECONNRESET:
+ return "WSAECONNRESET";
+ }
+#endif
+ return "No Error";
+}
+
+bool cServer::InitServer( int a_Port )
+{
+ if( m_bIsConnected )
+ {
+ LOGERROR("ERROR: Trying to initialize server while server is already running!");
+ return false;
+ }
+
+ printf("/============================\\\n");
+ printf("| Minecraft Alpha Server |\n");
+ printf("| Created by Kevin Bansberg |\n");
+ printf("| A.K.A. |\n");
+ printf("| FakeTruth |\n");
+ printf("| Monsters by Alex Sonek |\n");
+ printf("| A.K.A. Duralex |\n");
+ printf("\\============================/\n");
+ printf("More info: WWW.MC-SERVER.ORG\n");
+ printf(" WWW.AE-C.NET\n");
+ printf(" WWW.RBTHINKTANK.COM\n");
+ printf("email: faketruth@gmail.com\n\n");
+
+ LOG("Starting up server.");
+
+#ifdef _WIN32
+ WSADATA wsaData;
+ memset( &wsaData, 0, sizeof( wsaData ) );
+ int wsaret=WSAStartup(/*0x101*/ MAKEWORD(2, 2),&wsaData);
+
+ if(wsaret!=0)
+ {
+ LOG("wsaret != 0");
+ return false;
+ }
+#endif
+
+ sockaddr_in local;
+
+ local.sin_family=AF_INET;
+ local.sin_addr.s_addr=INADDR_ANY;
+ local.sin_port=htons((u_short)a_Port); // 25565
+
+ m_pState->SListenClient = socket(AF_INET,SOCK_STREAM,0);
+
+ if( !m_pState->SListenClient.IsValid() )
+ {
+#ifdef _WIN32
+ LOGERROR("m_SListenClient==INVALID_SOCKET (%s)", GetWSAError().c_str() );
+#else
+ LOGERROR("m_SListenClient==INVALID_SOCKET");
+#endif
+ }
+
+
+#ifdef _WIN32
+ char yes = 1;
+#else
+ int yes = 1;
+#endif
+ if (setsockopt( m_pState->SListenClient, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
+ LOGERROR("setsockopt == -1");
+ return false;
+ }
+
+ if( bind( m_pState->SListenClient, (sockaddr*)&local, sizeof(local)) != 0 )
+ {
+#ifdef _WIN32
+ LOGERROR("bind fail (%s)", GetWSAError().c_str() );
+#else
+ LOGERROR("bind fail (%i)", errno);
+#endif
+ return false;
+ }
+
+
+ if( listen( m_pState->SListenClient , 10 ) != 0)
+ {
+#ifdef _WIN32
+ LOGERROR("listen fail (%s)", GetWSAError().c_str() );
+#else
+ LOGERROR("listen fail (%i)", errno);
+#endif
+ return false;
+ }
+
+ m_iServerPort = a_Port;
+ LOG("Port %i has been bound, server is open for connections", m_iServerPort);
+ m_bIsConnected = true;
+
+ cIniFile IniFile("settings.ini");
+ if( IniFile.ReadFile() )
+ {
+ g_bWaterPhysics = IniFile.GetValueB("Physics", "Water", false );
+ std::string ServerID = IniFile.GetValue("Server", "ServerID");
+ if( ServerID.empty() )
+ {
+ ServerID = "MCServer";
+ IniFile.SetValue("Server", "ServerID", ServerID, true );
+ IniFile.WriteFile();
+ }
+ m_pState->ServerID = ServerID;
+ }
+ return true;
+}
+
+cServer::cServer()
+ : m_pState( new sServerState )
+ , m_Millisecondsf( 0 )
+ , m_Milliseconds( 0 )
+ , m_bIsConnected( false )
+ , m_iServerPort( 0 )
+ , m_bRestarting( false )
+{
+}
+
+cServer::~cServer()
+{
+ if( m_pState->SListenClient ) closesocket( m_pState->SListenClient );
+ m_pState->SListenClient = 0;
+
+ m_pState->bStopListenThread = true;
+ delete m_pState->pListenThread; m_pState->pListenThread = 0;
+ m_pState->bStopTickThread = true;
+ delete m_pState->pTickThread; m_pState->pTickThread = 0;
+
+ delete m_pState;
+}
+
+void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
+{
+ //m_World->LockClientHandle();
+ cWorld* World = cRoot::Get()->GetWorld();
+ for( cWorld::ClientList::iterator itr = World->GetClients().begin(); itr != World->GetClients().end(); ++itr)
+ {
+ if( *itr == a_Exclude || !(*itr)->IsLoggedIn() ) continue;
+ (*itr)->Send( a_Packet );
+ }
+ //m_World->UnlockClientHandle();
+}
+
+void cServer::SendAllEntitiesTo(cClientHandle* a_Target)
+{
+ cWorld* World = cRoot::Get()->GetWorld();
+ for( cWorld::EntityList::iterator itr = World->GetEntities().begin(); itr != World->GetEntities().end(); ++itr)
+ {
+ (*itr)->SpawnOn( a_Target );
+ }
+}
+
+void cServer::StartListenClient()
+{
+ sockaddr_in from;
+ socklen_t fromlen=sizeof(from);
+
+ cSocket SClient = accept(
+ m_pState->SListenClient,
+ (sockaddr*)&from,
+ &fromlen);
+
+ if( from.sin_addr.s_addr && SClient.IsValid() )
+ {
+ char * ClientIP = 0;
+ if((ClientIP = inet_ntoa(from.sin_addr)) == 0 )
+ return;
+
+ LOG("%s connected!", ClientIP);
+
+ cClientHandle *NewHandle = 0;
+ NewHandle = new cClientHandle( SClient );
+ cWorld* World = cRoot::Get()->GetWorld();
+ World->LockClientHandle();
+ World->AddClient( NewHandle );
+ World->UnlockClientHandle();
+ }
+}
+
+bool cServer::Tick(float a_Dt)
+{
+ //LOG("Tick");
+ if( a_Dt > 100.f ) a_Dt = 100.f; // Don't go over 1/10 second
+
+ cSleep::MilliSleep( 50 ); // Don't tick too much
+
+ m_Millisecondsf += a_Dt;
+ if( m_Millisecondsf > 1.f )
+ {
+ m_Milliseconds += (int)m_Millisecondsf;
+ m_Millisecondsf = m_Millisecondsf - (int)m_Millisecondsf;
+ }
+
+ cWorld* World = cRoot::Get()->GetWorld();
+ World->Tick(a_Dt);
+
+ World->LockClientHandle();
+ for( cWorld::ClientList::iterator itr = World->GetClients().begin(); itr != World->GetClients().end();)
+ {
+ (*itr)->HandlePendingPackets();
+
+ if( (*itr)->IsDestroyed() )
+ {
+
+ cClientHandle* RemoveMe = *itr;
+ ++itr;
+ cRoot::Get()->GetWorld()->RemoveClient( RemoveMe );
+ continue;
+ }
+ (*itr)->Tick(a_Dt);
+ ++itr;
+ }
+ World->UnlockClientHandle();
+
+ cRoot::Get()->GetPluginManager()->Tick( a_Dt );
+
+ if( !m_bRestarting )
+ return true;
+ else
+ {
+ m_bRestarting = false;
+ m_pState->RestartEvent.Set();
+ LOG("<<<<>>>>SIGNALLED SEMAPHORE");
+ return false;
+ }
+}
+
+void ServerTickThread( void * a_Param )
+{
+ LOG("ServerTickThread");
+ cServer *CServerObj = (cServer*)a_Param;
+
+ cTimer Timer;
+
+ long long LastTime = Timer.GetNowTime();
+
+ bool bKeepGoing = true;
+ while( bKeepGoing )
+ {
+ long long NowTime = Timer.GetNowTime();
+ float DeltaTime = (float)(NowTime-LastTime);
+ bKeepGoing = CServerObj->Tick( DeltaTime );
+ LastTime = NowTime;
+ }
+
+ LOG("TICK THREAD STOPPED");
+}
+
+void cServer::StartListenThread()
+{
+ m_pState->pListenThread = new cThread( ServerListenThread, this );
+ m_pState->pTickThread = new cThread( ServerTickThread, this );
+ m_pState->pListenThread->Start( true );
+ m_pState->pTickThread->Start( true );
+}
+
+std::vector< std::string > StringSplit(std::string str, std::string delim)
+{
+ std::vector< std::string > results;
+ size_t cutAt;
+ while( (cutAt = str.find_first_of(delim)) != str.npos )
+ {
+ if(cutAt > 0)
+ {
+ results.push_back(str.substr(0,cutAt));
+ }
+ str = str.substr(cutAt+1);
+ }
+ if(str.length() > 0)
+ {
+ results.push_back(str);
+ }
+ return results;
+}
+
+template <class T>
+bool from_string(T& t,
+ const std::string& s,
+ std::ios_base& (*f)(std::ios_base&))
+{
+ std::istringstream iss(s);
+ return !(iss >> f >> t).fail();
+}
+
+std::string & StrToUpper(std::string& s)
+{
+ std::string::iterator i = s.begin();
+ std::string::iterator end = s.end();
+
+ while (i != end) {
+ *i = (char)toupper(*i);
+ ++i;
+ }
+ return s;
+}
+
+int NoCaseCompare( std::string s1, std::string s2 )
+{
+ return StrToUpper( s1 ).compare( StrToUpper( s2 ) );
+}
+
+bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
+{
+ cPluginManager* PM = cRoot::Get()->GetPluginManager();
+ if( PM->CallHook( cPluginManager::E_PLUGIN_CHAT, 2, a_Cmd, a_Client.GetPlayer() ) )
+ return true;
+
+ std::string Command( a_Cmd );
+ if( Command.length() <= 0 ) return false;
+ if( Command[0] != '/' ) return false;
+
+ std::vector< std::string > split = StringSplit( Command, " " );
+ if( split.size() == 0 )
+ return false;
+
+ if( split[0].compare("/coords") == 0 )
+ {
+ char c_Str[128];
+ sprintf_s( c_Str, 128, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
+ a_Client.Send( cPacket_Chat( cChatColor::Green + c_Str ) );
+ return true;
+ }
+ return false;
+}
+
+void cServer::ServerCommand( const char* a_Cmd )
+{
+ std::string Command( a_Cmd );
+ std::vector< std::string > split = StringSplit( Command, " " );
+ if( split.size() > 0 )
+ {
+ if( split[0].compare( "help" ) == 0 )
+ {
+ printf("===================ALL COMMANDS====================\n");
+ printf("help - Shows this message\n");
+ printf("save-all - Saves all loaded chunks to disk\n");
+ printf("list - Lists all players currently in server\n");
+ printf("numchunks - Shows number of chunks currently loaded\n");
+ printf("say - Sends a chat message to all players\n");
+ printf("restart - Kicks all clients, and saves everything\n");
+ printf(" and clears memory\n");
+ printf("stop - Saves everything and closes server\n");
+ printf("===================================================\n");
+ return;
+ }
+ if( split[0].compare( "stop" ) == 0 || split[0].compare( "restart" ) == 0 )
+ {
+ return;
+ }
+ if( split[0].compare( "save-all" ) == 0 )
+ {
+ cRoot::Get()->GetWorld()->SaveAllChunks();
+ return;
+ }
+ if( split[0].compare( "list" ) == 0 )
+ {
+ cWorld::EntityList Entities = cRoot::Get()->GetWorld()->GetEntities();
+ std::string PlayerString;
+ int NumPlayers = 0;
+ cRoot::Get()->GetWorld()->LockEntities();
+ for( cWorld::EntityList::iterator itr = Entities.begin(); itr != Entities.end(); ++itr)
+ {
+ if( (*itr)->GetEntityType() != cEntity::E_PLAYER ) continue;
+ PlayerString.push_back(' ');
+ PlayerString += ((cPlayer*)*itr)->GetName();
+ NumPlayers++;
+ }
+ cRoot::Get()->GetWorld()->UnlockEntities();
+ printf( "Players (%i):%s\n", NumPlayers, PlayerString.c_str() );
+ return;
+ }
+ if( split[0].compare( "numchunks" ) == 0 )
+ {
+ //printf("Num loaded chunks: %i\n", cRoot::Get()->GetWorld()->GetChunks().size() );
+ return;
+ }
+ if(split[0].compare("monsters") == 0 ){
+ cMonster::ListMonsters();
+ return;
+ }
+ if(split.size() > 1)
+ {
+ if( split[0].compare( "say" ) == 0 )
+ {
+ std::string Message = cChatColor::Purple + "[SERVER] " + Command.substr( Command.find_first_of("say") + 4 );
+ LOG("%s", Message.c_str() );
+ Broadcast( cPacket_Chat(Message) );
+ return;
+ }
+ }
+ printf("Unknown command, type 'help' for all commands.\n");
+ }
+ //LOG("You didn't enter anything? (%s)", a_Cmd.c_str() );
+}
+
+void cServer::SendMessage( const char* a_Message, cPlayer* a_Player /* = 0 */, bool a_bExclude /* = false */ )
+{
+ cPacket_Chat Chat( a_Message );
+ if( a_Player && !a_bExclude )
+ {
+ cClientHandle* Client = a_Player->GetClientHandle();
+ if( Client ) Client->Send( Chat );
+ return;
+ }
+
+ Broadcast( Chat, (a_Player)?a_Player->GetClientHandle():0 );
+}
+
+void cServer::Shutdown()
+{
+ m_bRestarting = true;
+ m_pState->RestartEvent.Wait();
+
+ cRoot::Get()->GetWorld()->SaveAllChunks();
+
+ cWorld* World = cRoot::Get()->GetWorld();
+ World->LockClientHandle();
+ while( World->GetClients().begin() != World->GetClients().end() )
+ {
+ World->RemoveClient( *World->GetClients().begin() );
+ }
+ World->UnlockClientHandle();
+}
+
+
+const char* cServer::GetServerID()
+{
+ return m_pState->ServerID.c_str();
+} \ No newline at end of file
diff --git a/source/cServer.h b/source/cServer.h
new file mode 100644
index 000000000..c8a669949
--- /dev/null
+++ b/source/cServer.h
@@ -0,0 +1,53 @@
+#pragma once
+
+class cEvent;
+class cSemaphore;
+class cCriticalSection;
+class cPlayer;
+class cClientHandle;
+class cPacket;
+class cServer //tolua_export
+{ //tolua_export
+public: //tolua_export
+ static cServer * GetServer(); //tolua_export
+
+ bool InitServer( int a_Port = 25565 );
+
+ int GetPort() { return m_iServerPort; }
+ bool IsConnected(){return m_bIsConnected;} // returns connection status
+ void StartListenClient(); // Listen to client
+ int RecClient(cClientHandle *sRecSocket); // receive message for a particular socket
+
+ void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 );
+ void SendAllEntitiesTo( cClientHandle* a_Target );
+
+ bool Tick(float a_Dt);
+
+ void StartListenThread();
+
+ bool Command( cClientHandle & a_Client, const char* a_Cmd );
+ void ServerCommand( const char* a_Cmd ); //tolua_export
+ void Shutdown();
+
+ void SendMessage( const char* a_Message, cPlayer* a_Player = 0, bool a_bExclude = false ); //tolua_export
+
+ static void ServerListenThread( void* a_Args );
+
+ const char* GetServerID();
+private:
+ friend class cRoot; // so cRoot can create and destroy cServer
+ cServer();
+ ~cServer();
+
+ struct sServerState;
+ sServerState* m_pState;
+
+ // Time since server was started
+ float m_Millisecondsf;
+ unsigned int m_Milliseconds;
+
+ bool m_bIsConnected; // true - connected false - not connected
+ int m_iServerPort;
+
+ bool m_bRestarting;
+}; //tolua_export
diff --git a/source/cSign.h b/source/cSign.h
new file mode 100644
index 000000000..ebdeb3031
--- /dev/null
+++ b/source/cSign.h
@@ -0,0 +1,32 @@
+#pragma once
+
+class cSign //tolua_export
+{ //tolua_export
+public:
+ static char RotationToMetaData( float a_Rotation ) //tolua_export
+ { //tolua_export
+ a_Rotation += 180 + (180/16); // So its not aligned with axis
+ if( a_Rotation > 360.f ) a_Rotation -= 360.f;
+
+ a_Rotation = (a_Rotation/360) * 16;
+
+ return ((char)a_Rotation) % 16;
+ } //tolua_export
+ static char 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:
+ break;
+ };
+ return 0x2;
+ }
+}; //tolua_export \ No newline at end of file
diff --git a/source/cSignEntity.cpp b/source/cSignEntity.cpp
new file mode 100644
index 000000000..883da223e
--- /dev/null
+++ b/source/cSignEntity.cpp
@@ -0,0 +1,136 @@
+#include "cSignEntity.h"
+#include "cMCLogger.h"
+
+#include "cPlayer.h"
+#include "cClientHandle.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cRoot.h"
+
+#include "packets/cPacket_UpdateSign.h"
+
+#include <json/json.h>
+
+cSignEntity::cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z)
+ : cBlockEntity(a_BlockType, a_X, a_Y, a_Z)
+{
+}
+
+cSignEntity::~cSignEntity()
+{
+}
+
+// It don't do anything when 'used'
+void cSignEntity::UsedBy( cPlayer & a_Player )
+{
+ (void)a_Player;
+}
+
+void cSignEntity::SetLines( const std::string & a_Line1, const std::string & a_Line2, const std::string & a_Line3, const std::string & a_Line4 )
+{
+ m_Line[0] = a_Line1;
+ m_Line[1] = a_Line2;
+ m_Line[2] = a_Line3;
+ m_Line[3] = a_Line4;
+}
+
+void cSignEntity::SetLine( int a_Index, std::string a_Line )
+{
+ if( a_Index < 4 && a_Index > -1 )
+ {
+ m_Line[a_Index] = a_Line;
+ }
+}
+
+std::string cSignEntity::GetLine( int a_Index )
+{
+ if( a_Index < 4 && a_Index > -1 )
+ {
+ return m_Line[a_Index];
+ }
+ return "";
+}
+
+void cSignEntity::SendTo( cClientHandle* a_Client )
+{
+ cPacket_UpdateSign Sign;
+ Sign.m_PosX = m_PosX;
+ Sign.m_PosY = (short)m_PosY;
+ Sign.m_PosZ = m_PosZ;
+ Sign.m_Line1 = m_Line[0];
+ Sign.m_Line2 = m_Line[1];
+ Sign.m_Line3 = m_Line[2];
+ Sign.m_Line4 = m_Line[3];
+
+ if( a_Client ) a_Client->Send( Sign );
+ else // broadcast of a_Client == 0
+ {
+ cWorld* World = cRoot::Get()->GetWorld();
+ cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
+ Chunk->Broadcast( Sign );
+ }
+}
+
+void cSignEntity::WriteToFile(FILE* a_File)
+{
+ fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File );
+ fwrite( &m_PosX, sizeof( int ), 1, a_File );
+ fwrite( &m_PosY, sizeof( int ), 1, a_File );
+ fwrite( &m_PosZ, sizeof( int ), 1, a_File );
+
+ for( int i = 0; i < 4; i++ )
+ {
+ short Size = (short)m_Line[i].size();
+ fwrite( &Size, sizeof(short), 1, a_File );
+ fwrite( m_Line[i].c_str(), Size * sizeof(char), 1, a_File );
+ }
+}
+
+bool cSignEntity::LoadFromFile(FILE* a_File)
+{
+ if( fread( &m_PosX, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING SIGN FROM FILE"); return false; }
+ if( fread( &m_PosY, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING SIGN FROM FILE"); return false; }
+ if( fread( &m_PosZ, sizeof(int), 1, a_File) != 1 ) { LOGERROR("ERROR READING SIGN FROM FILE"); return false; }
+
+ for( int i = 0; i < 4; i++ )
+ {
+ short Size = 0;
+ if( fread( &Size, sizeof(short), 1, a_File) != 1 ) { LOGERROR("ERROR READING SIGN FROM FILE"); return false; }
+ if( Size > 0 )
+ {
+ char* c_Str = new char[Size];
+ if( fread( c_Str, Size * sizeof(char), 1, a_File) != 1 ) { LOGERROR("ERROR READING SIGN FROM FILE"); delete [] c_Str; return false; }
+ m_Line[i].assign( c_Str, Size );
+ delete [] c_Str;
+ }
+ LOG("Line %i: %s", i+1, m_Line[i].c_str() );
+ }
+
+ return true;
+}
+
+bool cSignEntity::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_Line[0] = a_Value.get("Line1", "").asString();
+ m_Line[1] = a_Value.get("Line2", "").asString();
+ m_Line[2] = a_Value.get("Line3", "").asString();
+ m_Line[3] = a_Value.get("Line4", "").asString();
+
+ return true;
+}
+
+void cSignEntity::SaveToJson( Json::Value & a_Value )
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ a_Value["Line1"] = m_Line[0];
+ a_Value["Line2"] = m_Line[1];
+ a_Value["Line3"] = m_Line[2];
+ a_Value["Line4"] = m_Line[3];
+} \ No newline at end of file
diff --git a/source/cSignEntity.h b/source/cSignEntity.h
new file mode 100644
index 000000000..b704fdd3c
--- /dev/null
+++ b/source/cSignEntity.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "cBlockEntity.h"
+#include "FileDefine.h"
+
+#include <string>
+
+namespace Json
+{
+ class Value;
+}
+
+class cSignEntity : public cBlockEntity
+{
+public:
+ cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z);
+ virtual ~cSignEntity();
+
+ void WriteToFile(FILE* a_File);
+ bool LoadFromFile(FILE* a_File);
+
+ bool LoadFromJson( const Json::Value& a_Value );
+ void SaveToJson( Json::Value& a_Value );
+
+ void SetLines( const std::string & a_Line1, const std::string & a_Line2, const std::string & a_Line3, const std::string & a_Line4 );
+ void SetLine( int a_Index, std::string a_Line );
+
+ std::string GetLine( int a_Index );
+
+ virtual void UsedBy( cPlayer & a_Player );
+ virtual void SendTo( cClientHandle* a_Client );
+private:
+ std::string m_Line[4];
+}; \ No newline at end of file
diff --git a/source/cSleep.cpp b/source/cSleep.cpp
new file mode 100644
index 000000000..920ffaf65
--- /dev/null
+++ b/source/cSleep.cpp
@@ -0,0 +1,16 @@
+#include "cSleep.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <unistd.h>
+#endif
+
+void cSleep::MilliSleep( unsigned int a_MilliSeconds )
+{
+#ifdef _WIN32
+ Sleep(a_MilliSeconds); // Don't tick too much
+#else
+ usleep(a_MilliSeconds*1000);
+#endif
+}
diff --git a/source/cSleep.h b/source/cSleep.h
new file mode 100644
index 000000000..20ca7fc7d
--- /dev/null
+++ b/source/cSleep.h
@@ -0,0 +1,7 @@
+#pragma once
+
+class cSleep
+{
+public:
+ static void MilliSleep( unsigned int a_MilliSeconds );
+}; \ No newline at end of file
diff --git a/source/cSocket.cpp b/source/cSocket.cpp
new file mode 100644
index 000000000..d2489d48e
--- /dev/null
+++ b/source/cSocket.cpp
@@ -0,0 +1,30 @@
+#include "cSocket.h"
+
+cSocket::cSocket( xSocket a_Socket )
+ : m_Socket( a_Socket )
+{
+}
+
+cSocket::~cSocket()
+{
+}
+
+cSocket::operator const cSocket::xSocket() const
+{
+ return m_Socket;
+}
+
+cSocket::xSocket cSocket::GetSocket() const
+{
+ return m_Socket;
+}
+
+bool cSocket::IsValid()
+{
+#ifdef _WIN32
+ return ( m_Socket != INVALID_SOCKET);
+#else
+ return ( m_Socket >= 0);
+#endif
+}
+
diff --git a/source/cSocket.h b/source/cSocket.h
new file mode 100644
index 000000000..4a58ff2c9
--- /dev/null
+++ b/source/cSocket.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#ifdef _WIN32
+#include <WinSock.h>
+#define socklen_t int
+#ifdef SendMessage
+#undef SendMessage
+#endif
+#endif
+
+class cSocket
+{
+#ifdef _WIN32
+ typedef SOCKET xSocket;
+#else
+ typedef int xSocket;
+#endif
+
+public:
+ cSocket() : m_Socket( 0 ) {}
+
+ cSocket( xSocket a_Socket );
+ ~cSocket();
+
+ bool IsValid();
+
+ operator const xSocket() const;
+ xSocket GetSocket() const;
+ void SetSocket( xSocket a_Socket );
+
+ inline static bool IsSocketError( int a_ReturnedValue )
+ {
+#ifdef _WIN32
+ return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+#else
+ return (a_ReturnedValue <= 0);
+#endif
+ }
+
+
+private:
+ xSocket m_Socket;
+}; \ No newline at end of file
diff --git a/source/cSpider.cpp b/source/cSpider.cpp
new file mode 100644
index 000000000..00d63c409
--- /dev/null
+++ b/source/cSpider.cpp
@@ -0,0 +1,92 @@
+#include "cSpider.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cSpider::cSpider() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 52;
+ GetMonsterConfig("Spider");
+}
+
+cSpider::~cSpider()
+{
+}
+
+bool cSpider::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSpider ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSpider::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ m_EMPersonality = (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
+}
+
+void cSpider::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSpider::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSpider::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSpider::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cSpider::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cSpider.h b/source/cSpider.h
new file mode 100644
index 000000000..23600d330
--- /dev/null
+++ b/source/cSpider.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSpider : public cMonster
+{
+public:
+ cSpider();
+ ~cSpider();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cStairs.h b/source/cStairs.h
new file mode 100644
index 000000000..6a63b84db
--- /dev/null
+++ b/source/cStairs.h
@@ -0,0 +1,19 @@
+#pragma once
+
+class cStairs //tolua_export
+{ //tolua_export
+public:
+ static char RotationToMetaData( float a_Rotation ) //tolua_export
+ { //tolua_export
+ 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 0x0;
+ else if( a_Rotation >= 180 && a_Rotation < 270 )
+ return 0x1;
+ else if( a_Rotation >= 90 && a_Rotation < 180 )
+ return 0x2;
+ else
+ return 0x3;
+ } //tolua_export
+}; //tolua_export \ No newline at end of file
diff --git a/source/cStringMap.cpp b/source/cStringMap.cpp
new file mode 100644
index 000000000..1ddc2197c
--- /dev/null
+++ b/source/cStringMap.cpp
@@ -0,0 +1,16 @@
+#include "cStringMap.h"
+
+unsigned int cStringMap::size() const
+{
+ return m_StringMap.size();
+}
+
+void cStringMap::clear()
+{
+ m_StringMap.clear();
+}
+
+std::string & cStringMap::get( const std::string & index )
+{
+ return m_StringMap[index];
+} \ No newline at end of file
diff --git a/source/cStringMap.h b/source/cStringMap.h
new file mode 100644
index 000000000..f83ca5797
--- /dev/null
+++ b/source/cStringMap.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "tolua++.h"
+#include <string>
+#include <map>
+// A std::map<string, string> interface for Lua
+
+class cStringMap // tolua_export
+{ // tolua_export
+public: // tolua_export
+ cStringMap(std::map< std::string, std::string > a_StringMap) : m_StringMap( a_StringMap ) {}
+ void clear(); // tolua_export
+
+ unsigned int size() const; // tolua_export
+
+ std::string & get( const std::string & index ); //tolua_export
+private:
+ std::map< std::string, std::string > m_StringMap;
+}; // tolua_export \ No newline at end of file
diff --git a/source/cTCPLink.cpp b/source/cTCPLink.cpp
new file mode 100644
index 000000000..13eb593ef
--- /dev/null
+++ b/source/cTCPLink.cpp
@@ -0,0 +1,146 @@
+#include "cTCPLink.h"
+#include "cSocket.h"
+#include "cEvent.h"
+#include "cThread.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <cstring>
+#include <errno.h>
+#endif
+
+#ifdef _WIN32
+#define MSG_NOSIGNAL (0)
+#endif
+#ifdef __MACH__
+#define MSG_NOSIGNAL (0)
+#endif
+
+cTCPLink::cTCPLink()
+ : m_Socket( 0 )
+ , m_StopEvent( new cEvent() )
+{
+}
+
+cTCPLink::~cTCPLink()
+{
+ if( m_Socket )
+ {
+ CloseSocket();
+ m_StopEvent->Wait();
+ }
+ delete m_StopEvent;
+}
+
+void cTCPLink::CloseSocket()
+{
+ if( m_Socket )
+ {
+ closesocket( m_Socket );
+ m_Socket = 0;
+ }
+}
+
+bool cTCPLink::Connect( const char* a_Address, unsigned int a_Port )
+{
+ if( m_Socket )
+ {
+ LOGWARN("WARNING: cTCPLink Connect() called while still connected. ALWAYS disconnect before re-connecting!");
+ }
+
+ struct hostent *hp;
+ unsigned int addr;
+ struct sockaddr_in server;
+
+#ifdef _WIN32
+ WSADATA wsaData;
+ int wsaret=WSAStartup(/*0x101*/ MAKEWORD(2, 2),&wsaData);
+
+ if(wsaret!=0)
+ {
+ LOGERROR("cTCPLink: WSAStartup returned error");
+ return false;
+ }
+#endif
+
+ m_Socket=socket(AF_INET,SOCK_STREAM,0);
+#ifdef _WIN32
+ if( m_Socket==INVALID_SOCKET )
+#else
+ if( m_Socket < 0 )
+#endif
+ {
+ LOGERROR("cTCPLink: Invalid socket");
+ m_Socket = 0;
+ return false;
+ }
+
+
+ addr=inet_addr( a_Address );
+ hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
+ if(hp==NULL)
+ {
+ //LOGWARN("cTCPLink: gethostbyaddr returned NULL");
+ hp = gethostbyname( a_Address );
+ if( hp == NULL )
+ {
+ LOGWARN("cTCPLink: Could not resolve %s", a_Address);
+ CloseSocket();
+ return false;
+ }
+ }
+
+ server.sin_addr.s_addr=*((unsigned long*)hp->h_addr);
+ server.sin_family=AF_INET;
+ server.sin_port=htons( (unsigned short)a_Port );
+ if( connect( m_Socket, (struct sockaddr*)&server, sizeof(server) ) )
+ {
+ LOGWARN("cTCPLink: No response from server (%i)", errno);
+ CloseSocket();
+ return false;
+ }
+
+ cThread( ReceiveThread, this );
+
+ return true;
+}
+
+int cTCPLink::Send( char* a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
+{
+ //LOG("TCPLink::Send()");
+ if( !m_Socket )
+ {
+ LOGWARN("cTCPLink: Trying to send data without a valid connection!");
+ return -1;
+ }
+ return send( m_Socket, a_Data, a_Size, a_Flags | MSG_NOSIGNAL );
+}
+
+int cTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
+{
+ //LOG("TCPLink::SendMessage()");
+ if( !m_Socket )
+ {
+ LOGWARN("cTCPLink: Trying to send message without a valid connection!");
+ return -1;
+ }
+ return send( m_Socket, a_Message, strlen(a_Message), a_Flags | MSG_NOSIGNAL );
+}
+
+void cTCPLink::ReceiveThread( void* a_Param)
+{
+ cTCPLink* self = (cTCPLink*)a_Param;
+ SOCKET Socket = self->m_Socket;
+ int Received = 0;
+ do
+ {
+ char Data[256];
+ Received = recv(Socket, Data, 256, 0);
+ self->ReceivedData( Data, (Received>0?Received:-1) );
+ } while ( Received > 0 );
+
+ LOGINFO("cTCPLink Disconnected (%i)", Received );
+
+ if( Socket == self->m_Socket ) self->m_StopEvent->Set();
+}
diff --git a/source/cTCPLink.h b/source/cTCPLink.h
new file mode 100644
index 000000000..634c3afd5
--- /dev/null
+++ b/source/cTCPLink.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "cSocket.h"
+
+class cEvent;
+class cTCPLink //tolua_export
+{ //tolua_export
+public: //tolua_export
+ cTCPLink(); //tolua_export
+ ~cTCPLink(); //tolua_export
+
+ bool Connect( const char* a_Address, unsigned int a_Port ); //tolua_export
+ int Send( char* a_Data, unsigned int a_Size, int a_Flags = 0 ); //tolua_export
+ int SendMessage( const char* a_Message, int a_Flags = 0 ); //tolua_export
+ void CloseSocket(); //tolua_export
+protected: //tolua_export
+ virtual void ReceivedData( char a_Data[256], int a_Size ) = 0; //tolua_export
+
+ static void ReceiveThread( void* a_Param );
+
+ cSocket m_Socket;
+ cEvent* m_StopEvent;
+}; //tolua_export
diff --git a/source/cThread.cpp b/source/cThread.cpp
new file mode 100644
index 000000000..d0ada2b4e
--- /dev/null
+++ b/source/cThread.cpp
@@ -0,0 +1,75 @@
+#ifndef _WIN32
+#include <cstring>
+#include <semaphore.h>
+#include <errno.h>
+#include <pthread.h>
+#else
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
+#endif
+#include "cThread.h"
+#include "cEvent.h"
+#include "cMCLogger.h"
+
+cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param )
+ : m_ThreadFunction( a_ThreadFunction )
+ , m_Param( a_Param )
+ , m_Event( new cEvent() )
+ , m_StopEvent( 0 )
+{
+}
+
+cThread::~cThread()
+{
+ delete m_Event;
+
+ if( m_StopEvent )
+ {
+ m_StopEvent->Wait();
+ delete m_StopEvent;
+ }
+}
+
+void cThread::Start( bool a_bWaitOnDelete /* = true */ )
+{
+ if( a_bWaitOnDelete )
+ m_StopEvent = new cEvent();
+
+#ifndef _WIN32
+ pthread_t SndThread;
+ if( pthread_create( &SndThread, NULL, MyThread, this) )
+ LOGERROR("ERROR: Could not create thread!");
+#else
+ HANDLE hThread = CreateThread( 0 // security
+ ,0 // stack size
+ , (LPTHREAD_START_ROUTINE) MyThread // function name
+ ,this // parameters
+ ,0 // flags
+ ,0 ); // thread id
+ CloseHandle( hThread );
+#endif
+
+ // Wait until thread has actually been created
+ m_Event->Wait();
+}
+
+#ifdef _WIN32
+unsigned long cThread::MyThread(void* a_Param )
+#else
+void *cThread::MyThread( void *a_Param )
+#endif
+{
+ cThread* self = (cThread*)a_Param;
+ cEvent* StopEvent = self->m_StopEvent;
+
+ ThreadFunc* ThreadFunction = self->m_ThreadFunction;
+ void* ThreadParam = self->m_Param;
+
+ // Set event to let other thread know this thread has been created and it's safe to delete the cThread object
+ self->m_Event->Set();
+
+ ThreadFunction( ThreadParam );
+
+ if( StopEvent ) StopEvent->Set();
+ return 0;
+}
diff --git a/source/cThread.h b/source/cThread.h
new file mode 100644
index 000000000..1e9d73c17
--- /dev/null
+++ b/source/cThread.h
@@ -0,0 +1,25 @@
+#pragma once
+
+class cEvent;
+class cThread
+{
+public:
+ typedef void (ThreadFunc)(void*);
+ cThread( ThreadFunc a_ThreadFunction, void* a_Param );
+ ~cThread();
+
+ void Start( bool a_bWaitOnDelete = true );
+ void WaitForThread();
+private:
+ ThreadFunc* m_ThreadFunction;
+
+#ifdef _WIN32
+ static unsigned long MyThread(void* a_Param );
+#else
+ static void *MyThread( void *lpParam );
+#endif
+
+ void* m_Param;
+ cEvent* m_Event;
+ cEvent* m_StopEvent;
+}; \ No newline at end of file
diff --git a/source/cTimer.cpp b/source/cTimer.cpp
new file mode 100644
index 000000000..1cdde38ce
--- /dev/null
+++ b/source/cTimer.cpp
@@ -0,0 +1,39 @@
+#include "cTimer.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <sys/time.h>
+#include <time.h>
+#endif
+
+cTimer::cTimer()
+#ifdef _WIN32
+ : m_TicksPerSecond( new LARGE_INTEGER )
+#endif
+{
+#ifdef _WIN32
+ QueryPerformanceFrequency( (LARGE_INTEGER*)m_TicksPerSecond );
+#endif
+}
+
+cTimer::~cTimer()
+{
+#ifdef _WIN32
+ delete (LARGE_INTEGER*)m_TicksPerSecond;
+#endif
+}
+
+long long cTimer::GetNowTime()
+{
+#ifdef _WIN32
+ LARGE_INTEGER now;
+ QueryPerformanceCounter( &now );
+ LARGE_INTEGER & tps = *((LARGE_INTEGER*)m_TicksPerSecond);
+ return ((now.QuadPart*1000) / tps.QuadPart );
+#else
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ return (long long)(now.tv_sec*1000 + now.tv_usec/1000);
+#endif
+} \ No newline at end of file
diff --git a/source/cTimer.h b/source/cTimer.h
new file mode 100644
index 000000000..52afda8bb
--- /dev/null
+++ b/source/cTimer.h
@@ -0,0 +1,15 @@
+#pragma once
+
+class cTimer
+{
+public:
+ cTimer();
+ ~cTimer();
+
+ long long GetNowTime();
+private:
+
+#ifdef _WIN32
+ void* m_TicksPerSecond; // LARGE_INTEGER*
+#endif
+}; \ No newline at end of file
diff --git a/source/cTorch.h b/source/cTorch.h
new file mode 100644
index 000000000..98f8b86e3
--- /dev/null
+++ b/source/cTorch.h
@@ -0,0 +1,51 @@
+#pragma once
+
+class cTorch //tolua_export
+{ //tolua_export
+public:
+
+ static char DirectionToMetaData( char a_Direction ) //tolua_export
+ { //tolua_export
+ switch( a_Direction )
+ {
+ case 0x0:
+ return 0x0;
+ case 0x1:
+ return 0x5; //standing on floor
+ case 0x2:
+ return 0x4; // south
+ case 0x3:
+ return 0x3; // north
+ case 0x4:
+ return 0x2; // west
+ case 0x5:
+ return 0x1; // east
+ default:
+ break;
+ };
+ return 0x0;
+ } //tolua_export
+
+ static char MetaDataToDirection( char a_MetaData ) //tolua_export
+ { //tolua_export
+ switch( a_MetaData )
+ {
+ case 0x0:
+ return 0x0;
+ case 0x1:
+ return 0x5;
+ case 0x2:
+ return 0x4;
+ case 0x3:
+ return 0x3;
+ case 0x4:
+ return 0x2;
+ case 0x5:
+ return 0x1;
+ default:
+ break;
+ };
+ return 0x0;
+ } //tolua_export
+
+}; //tolua_export \ No newline at end of file
diff --git a/source/cTracer.cpp b/source/cTracer.cpp
new file mode 100644
index 000000000..28e5c49b5
--- /dev/null
+++ b/source/cTracer.cpp
@@ -0,0 +1,377 @@
+#include "cTracer.h"
+#include "cWorld.h"
+
+#include "Vector3f.h"
+#include "Vector3i.h"
+#include "Vector3d.h"
+
+#include "BlockID.h"
+#include "cMCLogger.h"
+#include "cEntity.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // abs()
+#endif
+
+cTracer::cTracer(cWorld* a_World)
+ : m_World( a_World )
+{
+ m_NormalTable[0] = new Vector3f(-1, 0, 0);
+ m_NormalTable[1] = new Vector3f( 0, 0,-1);
+ m_NormalTable[2] = new Vector3f( 1, 0, 0);
+ m_NormalTable[3] = new Vector3f( 0, 0, 1);
+ m_NormalTable[4] = new Vector3f( 0, 1, 0);
+ m_NormalTable[5] = new Vector3f( 0,-1, 0);
+
+ DotPos = new Vector3f();
+ BoxOffset = new Vector3f();
+ BlockHitPosition = new Vector3f();
+ HitNormal = new Vector3f();
+ RealHit = new Vector3f();
+
+
+ dir = new Vector3f();
+ tDelta = new Vector3f();
+ pos = new Vector3i();
+ end1 = new Vector3i();
+ step = new Vector3i();
+ tMax = new Vector3f();
+}
+
+cTracer::~cTracer()
+{
+ for( int i = 0; i < 6; ++i )
+ {
+ delete m_NormalTable[i];
+ m_NormalTable[i] = 0;
+ }
+
+ delete DotPos; DotPos = 0;
+ delete BoxOffset; BoxOffset = 0;
+ delete BlockHitPosition; BlockHitPosition = 0;
+ delete HitNormal; HitNormal = 0;
+ delete RealHit; RealHit = 0;
+
+ delete dir; dir = 0;
+ delete tDelta; tDelta = 0;
+ delete pos; pos = 0;
+ delete end1; end1 = 0;
+ delete step; step = 0;
+ delete tMax; tMax = 0;
+}
+
+float cTracer::SigNum( float a_Num )
+{
+ if (a_Num < 0.f) return -1.f;
+ if (a_Num > 0.f) return 1.f;
+ return 0.f;
+}
+
+void cTracer::SetValues( const Vector3f & a_Start, const Vector3f & a_Direction )
+{
+ // calculate the direction of the ray (linear algebra)
+ *dir = a_Direction;
+
+ // decide which direction to start walking in
+ step->x = (int) SigNum(dir->x);
+ step->y = (int) SigNum(dir->y);
+ step->z = (int) SigNum(dir->z);
+
+ // normalize the direction vector
+ if( dir->SqrLength() > 0.f ) dir->Normalize();
+
+ // how far we must move in the ray direction before
+ // we encounter a new voxel in x-direction
+ // same but y-direction
+ if( dir->x != 0.f ) tDelta->x = 1/fabs(dir->x);
+ else tDelta->x = 0;
+ if( dir->y != 0.f ) tDelta->y = 1/fabs(dir->y);
+ else tDelta->y = 0;
+ if( dir->z != 0.f ) tDelta->z = 1/fabs(dir->z);
+ else tDelta->z = 0;
+
+ // start voxel coordinates
+ // use your
+ // transformer
+ // function here
+ pos->x = (int)floorf(a_Start.x);
+ pos->y = (int)floorf(a_Start.y);
+ pos->z = (int)floorf(a_Start.z);
+
+ // calculate distance to first intersection in the voxel we start from
+ if(dir->x < 0)
+ {
+ tMax->x = ((float)pos->x - a_Start.x) / dir->x;
+ }
+ else
+ {
+ tMax->x = (((float)pos->x + 1) - a_Start.x) / dir->x;
+ }
+
+ if(dir->y < 0)
+ {
+ tMax->y = ((float)pos->y - a_Start.y) / dir->y;
+ }
+ else
+ {
+ tMax->y = (((float)pos->y + 1) - a_Start.y) / dir->y;
+ }
+
+ if(dir->z < 0)
+ {
+ tMax->z = ((float)pos->z - a_Start.z) / dir->z;
+ }
+ else
+ {
+ tMax->z = (((float)pos->z + 1) - a_Start.z) / dir->z;
+ }
+}
+
+int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance)
+{
+ SetValues( a_Start, a_Direction );
+
+ const Vector3f End = a_Start + ((*dir) * (float)a_Distance);
+
+ // end voxel coordinates
+ end1->x = (int)floorf(End.x);
+ end1->y = (int)floorf(End.y);
+ end1->z = (int)floorf(End.z);
+
+ // check if first is occupied
+ if( pos->Equals( end1 ) )
+ {
+ LOG("WARNING: cTracer: Start and end in same block");
+ return 0;
+ }
+
+ bool reachedX = false, reachedY = false, reachedZ = false;
+
+ int Iterations = 0;
+ while ( Iterations < a_Distance )
+ {
+ Iterations++;
+ if(tMax->x < tMax->y && tMax->x < tMax->z)
+ {
+ tMax->x += tDelta->x;
+ pos->x += step->x;
+ }
+ else if(tMax->y < tMax->z)
+ {
+ tMax->y += tDelta->y;
+ pos->y += step->y;
+ }
+ else
+ {
+ tMax->z += tDelta->z;
+ pos->z += step->z;
+ }
+
+ if(step->x > 0.0f)
+ {
+ if(pos->x >= end1->x)
+ {
+ reachedX = true;
+ }
+ }
+ else if(pos->x <= end1->x)
+ {
+ reachedX = true;
+ }
+
+ if(step->y > 0.0f)
+ {
+ if(pos->y >= end1->y)
+ {
+ reachedY = true;
+ }
+ }
+ else if(pos->y <= end1->y)
+ {
+ reachedY = true;
+ }
+
+ if(step->z > 0.0f)
+ {
+ if(pos->z >= end1->z)
+ {
+ reachedZ = true;
+ }
+ }
+ else if(pos->z <= end1->z)
+ {
+ reachedZ = true;
+ }
+
+ if (reachedX && reachedY && reachedZ)
+ {
+ return false;
+ }
+
+ char BlockID = m_World->GetBlock( pos->x, pos->y, pos->z );
+ if ( BlockID != E_BLOCK_AIR )
+ {
+ *BlockHitPosition = pos;
+ int Normal = GetHitNormal(a_Start, End, *pos );
+ if(Normal > 0)
+ {
+ *HitNormal = *m_NormalTable[Normal-1];
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
+// return 1 = hit, other is not hit
+int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3)
+{
+ //float linx, liny;
+
+ float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2);
+ if (abs(d)<0.001) {return 0;}
+ float AB=((y0-y2)*(x3-x2)-(x0-x2)*(y3-y2))/d;
+ if (AB>=0.0 && AB<=1.0)
+ {
+ float CD=((y0-y2)*(x1-x0)-(x0-x2)*(y1-y0))/d;
+ if (CD>=0.0 && CD<=1.0)
+ {
+ //linx=x0+AB*(x1-x0);
+ //liny=y0+AB*(y1-y0);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+// intersect3D_SegmentPlane(): intersect a segment and a plane
+// Input: a_Ray = a segment, and a_Plane = a plane = {Point V0; Vector n;}
+// Output: *I0 = the intersect point (when it exists)
+// Return: 0 = disjoint (no intersection)
+// 1 = intersection in the unique point *I0
+// 2 = the segment lies in the plane
+int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal )
+{
+ Vector3f u = a_End - a_Origin;//a_Ray.P1 - S.P0;
+ Vector3f w = a_Origin - a_PlanePos;//S.P0 - Pn.V0;
+
+ float D = a_PlaneNormal.Dot( u );//dot(Pn.n, u);
+ float N = -(a_PlaneNormal.Dot( w ) );//-dot(a_Plane.n, w);
+
+ const float EPSILON = 0.0001f;
+ if (fabs(D) < EPSILON) { // segment is parallel to plane
+ if (N == 0) // segment lies in plane
+ return 2;
+ return 0; // no intersection
+ }
+ // they are not parallel
+ // compute intersect param
+ float sI = N / D;
+ if (sI < 0 || sI > 1)
+ return 0; // no intersection
+
+ //Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point
+ *RealHit = a_Origin + u * sI;
+ return 1;
+}
+
+int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos)
+{
+ Vector3i SmallBlockPos = a_BlockPos;
+ char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z );
+
+ if( BlockID == E_BLOCK_AIR )
+ return 0;
+
+ Vector3f BlockPos;
+ BlockPos = Vector3f(SmallBlockPos);
+
+ Vector3f Look = (end - start);
+ Look.Normalize();
+
+ float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) );
+ return 1;
+ }
+ }
+ }
+ dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) );
+ return 2;
+ }
+ }
+ }
+ dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) );
+ return 3;
+ }
+ }
+ }
+ dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) );
+ return 4;
+ }
+ }
+ }
+ dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) );
+ return 5;
+ }
+ }
+ }
+ dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1
+ if(dot < 0)
+ {
+ int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 );
+ if(Lines == 1)
+ {
+ Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 );
+ if(Lines == 1)
+ {
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) );
+ return 6;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/source/cTracer.h b/source/cTracer.h
new file mode 100644
index 000000000..3b7cd32c1
--- /dev/null
+++ b/source/cTracer.h
@@ -0,0 +1,32 @@
+#pragma once
+
+class cWorld;
+class Vector3i;
+class Vector3f;
+class cTracer //tolua_export
+{ //tolua_export
+public: //tolua_export
+ Vector3f* DotPos;
+ Vector3f* BoxOffset;
+ cTracer( cWorld* a_World); //tolua_export
+ ~cTracer(); //tolua_export
+ int Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance ); //tolua_export
+ void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction ); //tolua_export
+ Vector3f* BlockHitPosition; //tolua_export
+ Vector3f* HitNormal; //tolua_export
+ Vector3f* RealHit; //tolua_export
+private:
+ int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal );
+ int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos);
+ float SigNum( float a_Num );
+ cWorld* m_World;
+
+ Vector3f* m_NormalTable[6];
+
+ Vector3f* dir;
+ Vector3f* tDelta;
+ Vector3i* pos;
+ Vector3i* end1;
+ Vector3i* step;
+ Vector3f* tMax;
+}; //tolua_export \ No newline at end of file
diff --git a/source/cWaterSimulator.cpp b/source/cWaterSimulator.cpp
new file mode 100644
index 000000000..888ff69c4
--- /dev/null
+++ b/source/cWaterSimulator.cpp
@@ -0,0 +1,216 @@
+#include "cWaterSimulator.h"
+#include "cWorld.h"
+#include "Vector3i.h"
+#include "BlockID.h"
+#include <vector>
+
+class cWaterSimulator::WaterData
+{
+public:
+ WaterData( cWorld* a_World )
+ : m_ActiveWater( new std::vector< Vector3i >() )
+ , m_Buffer( new std::vector< Vector3i >() )
+ , m_World( a_World )
+ {}
+
+ std::vector< Vector3i > GetLowestPoints( int a_X, int a_Y, int a_Z )
+ {
+ std::vector< Vector3i > Points;
+ if( m_World->GetBlock(a_X, a_Y-1, a_Z) == E_BLOCK_AIR )
+ {
+ Points.push_back( Vector3i( a_X, a_Y-1, a_Z ) );
+ return Points;
+ }
+
+ Vector3i LowerPoints [] = {
+ Vector3i( a_X-1, a_Y-1, a_Z ),
+ Vector3i( a_X+1, a_Y-1, a_Z ),
+ Vector3i( a_X, a_Y-1, a_Z-1 ),
+ Vector3i( a_X, a_Y-1, a_Z+1 ),
+ };
+ bool bWaterFound = false;
+ for( int i = 0; i < 4; ++i )
+ {
+ char Block1 = m_World->GetBlock( LowerPoints[i].x, LowerPoints[i].y, LowerPoints[i].z );
+ char Block2 = m_World->GetBlock( LowerPoints[i].x, a_Y, LowerPoints[i].z );
+ if( Block1 == E_BLOCK_AIR && Block2 == E_BLOCK_AIR )
+ {
+ Points.push_back( LowerPoints[i] );
+ LowerPoints[i].y = a_Y;
+ Points.push_back( LowerPoints[i] );
+ }
+ else if( (Block2 == E_BLOCK_WATER || Block2 == E_BLOCK_STATIONARY_WATER ) && ( Block1 == E_BLOCK_AIR || Block1 == E_BLOCK_WATER || Block1 == E_BLOCK_STATIONARY_WATER ) )
+ {
+ bWaterFound = true;
+ }
+ }
+
+ if( Points.size() == 0 && !bWaterFound )
+ {
+ Vector3i LevelPoints [] = {
+ Vector3i( a_X-1, a_Y, a_Z ),
+ Vector3i( a_X+1, a_Y, a_Z ),
+ Vector3i( a_X, a_Y, a_Z-1 ),
+ Vector3i( a_X, a_Y, a_Z+1 ),
+ };
+ for( int i = 0; i < 4; ++i )
+ {
+ char Block = m_World->GetBlock( LevelPoints[i].x, a_Y, LevelPoints[i].z );
+ if( Block == E_BLOCK_AIR || Block == E_BLOCK_WATER || Block == E_BLOCK_STATIONARY_WATER )
+ Points.push_back( LevelPoints[i] );
+ }
+ }
+ return Points;
+ }
+
+ std::vector< Vector3i >* m_ActiveWater;
+ std::vector< Vector3i >* m_Buffer;
+ cWorld* m_World;
+};
+
+cWaterSimulator::cWaterSimulator( cWorld* a_World )
+ : m_World( a_World )
+ , m_Data( new WaterData( a_World ) )
+{
+}
+
+cWaterSimulator::~cWaterSimulator()
+{
+}
+
+void cWaterSimulator::WakeUp( int a_X, int a_Y, int a_Z )
+{
+ AddBlock( a_X, a_Y, a_Z );
+ AddBlock( a_X-1, a_Y, a_Z );
+ AddBlock( a_X+1, a_Y, a_Z );
+ AddBlock( a_X, a_Y-1, a_Z );
+ AddBlock( a_X, a_Y+1, a_Z );
+ AddBlock( a_X, a_Y, a_Z-1 );
+ AddBlock( a_X, a_Y, a_Z+1 );
+}
+
+void cWaterSimulator::AddBlock( int a_X, int a_Y, int a_Z )
+{
+ // Check for duplicates
+ std::vector< Vector3i > & ActiveWater = *m_Data->m_ActiveWater;
+ for( std::vector< Vector3i >::iterator itr = ActiveWater.begin(); itr != ActiveWater.end(); ++itr )
+ {
+ Vector3i & pos = *itr;
+ if( pos.x == a_X && pos.y == a_Y && pos.z == a_Z )
+ return;
+ }
+
+ ActiveWater.push_back( Vector3i( a_X, a_Y, a_Z ) );
+}
+
+char cWaterSimulator::GetHighestLevelAround( int a_X, int a_Y, int a_Z )
+{
+ char Max = 8;
+#define __HIGHLEVEL_CHECK__( x, y, z ) \
+ if( IsWaterBlock( m_World->GetBlock( x, y, z ) ) ) \
+ { \
+ char Meta; \
+ if( (Meta = m_World->GetBlockMeta( x, y, z ) ) < Max ) Max = Meta; \
+ else if( Meta == 8 ) Max = 0; \
+ if( Max == 0 ) return 0; \
+ }
+
+ __HIGHLEVEL_CHECK__( a_X-1, a_Y, a_Z );
+ __HIGHLEVEL_CHECK__( a_X+1, a_Y, a_Z );
+ __HIGHLEVEL_CHECK__( a_X, a_Y, a_Z-1 );
+ __HIGHLEVEL_CHECK__( a_X, a_Y, a_Z+1 );
+
+ return Max;
+}
+
+void cWaterSimulator::Simulate( float a_Dt )
+{
+ m_Timer += a_Dt;
+
+ std::swap( m_Data->m_ActiveWater, m_Data->m_Buffer ); // Swap so blocks can be added to empty ActiveWater array
+ m_Data->m_ActiveWater->clear();
+
+ std::vector< Vector3i > & WaterBlocks = *m_Data->m_Buffer;
+ for( std::vector< Vector3i >::iterator itr = WaterBlocks.begin(); itr != WaterBlocks.end(); ++itr )
+ {
+ Vector3i & pos = *itr;
+ char BlockID = m_World->GetBlock( pos.x, pos.y, pos.z );
+ if( IsWaterBlock( BlockID ) ) // only care about water
+ {
+ bool bIsFed = false;
+ char Meta = m_World->GetBlockMeta( pos.x, pos.y, pos.z );
+ char Feed = Meta;
+ if( Meta == 8 ) // Falling water
+ {
+ if( IsWaterBlock( m_World->GetBlock(pos.x, pos.y+1, pos.z) ) ) // Block above is water
+ {
+ bIsFed = true;
+ Meta = 0; // Make it a full block
+ }
+ }
+ else if( Meta == 0 ) // It's a full block, so it's always fed
+ {
+ bIsFed = true;
+ }
+ else
+ {
+ if( (Feed = GetHighestLevelAround( pos.x, pos.y, pos.z )) < Meta )
+ bIsFed = true;
+ }
+
+
+ if( bIsFed )
+ {
+ char DownID = m_World->GetBlock( pos.x, pos.y-1, pos.z );
+ if( DownID == E_BLOCK_AIR || IsWaterBlock( DownID ) ) // free for water
+ {
+ m_World->FastSetBlock( pos.x, pos.y-1, pos.z, E_BLOCK_WATER, 8 ); // falling
+ AddBlock( pos.x, pos.y-1, pos.z );
+ }
+ else // Not falling water
+ {
+ if( Feed+1 < Meta )
+ {
+ m_World->FastSetBlock( pos.x, pos.y, pos.z, E_BLOCK_WATER, Feed+1 );
+ AddBlock( pos.x, pos.y, pos.z );
+ }
+ else if( Meta < 7 ) // 7 is only 1 unit high, so it cannot spread, lower than 7 can though.
+ {
+ std::vector< Vector3i > Points = m_Data->GetLowestPoints( pos.x, pos.y, pos.z );
+ for( std::vector< Vector3i >::iterator itr = Points.begin(); itr != Points.end(); ++itr )
+ {
+ Vector3i & p = *itr;
+ char BlockID = m_World->GetBlock( p.x, p.y, p.z );
+ if( !IsWaterBlock( BlockID ) )
+ {
+ if( p.y == pos.y )
+ m_World->FastSetBlock(p.x, p.y, p.z, E_BLOCK_WATER, Meta+1);
+ else
+ m_World->FastSetBlock(p.x, p.y, p.z, E_BLOCK_WATER, 8);
+ AddBlock( p.x, p.y, p.z );
+ }
+ else // it's water
+ {
+ char PointMeta = m_World->GetBlockMeta( p.x, p.y, p.z );
+ if( PointMeta > Meta+1 )
+ {
+ AddBlock( p.x, p.y, p.z );
+ }
+ }
+ }
+ }
+ }
+ }
+ else // not fed
+ {
+ m_World->FastSetBlock( pos.x, pos.y, pos.z, E_BLOCK_AIR, 0 );
+ WakeUp( pos.x, pos.y, pos.z );
+ }
+ }
+ }
+}
+
+bool cWaterSimulator::IsWaterBlock( char a_BlockID )
+{
+ return a_BlockID == E_BLOCK_WATER || a_BlockID == E_BLOCK_STATIONARY_WATER;
+} \ No newline at end of file
diff --git a/source/cWaterSimulator.h b/source/cWaterSimulator.h
new file mode 100644
index 000000000..1e45256f8
--- /dev/null
+++ b/source/cWaterSimulator.h
@@ -0,0 +1,25 @@
+#pragma once
+
+class Vector3i;
+class cWorld;
+class cWaterSimulator
+{
+public:
+ cWaterSimulator( cWorld* a_World );
+ ~cWaterSimulator();
+
+ void Simulate( float a_Dt );
+ void WakeUp( int a_X, int a_Y, int a_Z );
+
+private:
+ void AddBlock( int a_X, int a_Y, int a_Z);
+ char GetHighestLevelAround( int a_X, int a_Y, int a_Z );
+
+ bool IsWaterBlock( char a_BlockID );
+
+ float m_Timer;
+ cWorld* m_World;
+
+ class WaterData;
+ WaterData* m_Data;
+}; \ No newline at end of file
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp
new file mode 100644
index 000000000..d6881c55f
--- /dev/null
+++ b/source/cWebAdmin.cpp
@@ -0,0 +1,309 @@
+#include "cWebAdmin.h"
+#include "cMCLogger.h"
+#include "cStringMap.h"
+
+#include "cWebPlugin.h"
+
+#include "cPluginManager.h"
+#include "cPlugin.h"
+
+#include "cEvent.h"
+#include "cWorld.h"
+#include "cPlayer.h"
+#include "cServer.h"
+#include "cRoot.h"
+
+#include <vector>
+
+#include "../iniFile/iniFile.h"
+
+#include "MemoryLeak.h"
+#ifdef _WIN32
+#include <psapi.h>
+#else
+#include <sys/resource.h>
+#endif
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+cWebAdmin* WebAdmin = 0;
+
+cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ )
+ : m_Port( a_Port )
+ , m_bConnected( false )
+{
+ WebAdmin = this;
+ m_Event = new cEvent();
+ Init( m_Port );
+}
+
+cWebAdmin::~cWebAdmin()
+{
+ WebAdmin = 0;
+ m_WebServer->Stop();
+
+ while( m_Plugins.begin() != m_Plugins.end() )
+ {
+ delete *m_Plugins.begin();
+ //m_Plugins.remove( *m_Plugins.begin() );
+ }
+ delete m_WebServer;
+ delete m_IniFile;
+
+ m_Event->Wait();
+ delete m_Event;
+}
+
+void ReplaceString( std::string & a_HayStack, const std::string & a_Needle, const std::string & a_ReplaceWith )
+{
+ size_t pos1 = a_HayStack.find( a_Needle );
+ a_HayStack.replace( pos1, a_Needle.size(), a_ReplaceWith );
+}
+
+void cWebAdmin::AddPlugin( cWebPlugin* a_Plugin )
+{
+ m_Plugins.remove( a_Plugin );
+ m_Plugins.push_back( a_Plugin );
+}
+
+void cWebAdmin::RemovePlugin( cWebPlugin* a_Plugin )
+{
+ m_Plugins.remove( a_Plugin );
+}
+
+void cWebAdmin::Request_Handler(webserver::http_request* r)
+{
+ if( WebAdmin == 0 ) return;
+ LOG("Path: %s", r->path_.c_str() );
+
+ std::vector< std::string > Split = StringSplit( r->path_, "/" );
+
+ if(r->path_ == "/")
+ {
+ r->answer_ += "<center>";
+ r->answer_ += "MCServer WebAdmin";
+ r->answer_ += "<br>";
+ r->answer_ += "<form method='get' action='webadmin/'>";
+ r->answer_ += "<input type='submit' value='Log in'>";
+ r->answer_ += "</form>";
+ r->answer_ += "</center>";
+ return;
+ }
+ else if( Split.size() > 0 && Split[0] == "webadmin" )
+ {
+ if( r->authentication_given_ )
+ {
+ std::string UserPassword = WebAdmin->m_IniFile->GetValue( "User:"+r->username_, "Password", "");
+ if (UserPassword != "" && r->password_ == UserPassword)
+ {
+ std::string Menu;
+ std::string Content;
+ std::string Template = WebAdmin->GetTemplate();
+
+ Content += "<h3>Current Game</h3>";
+ Content += "<h4>Server Name:</h4>";
+ Content += "<p>" + std::string( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
+
+ Content += "<h4>Plugins:</h4><p>";
+ cPluginManager* PM = cRoot::Get()->GetPluginManager();
+ const cPluginManager::PluginList & List = PM->GetAllPlugins();
+ for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr )
+ {
+ Content += (*itr)->GetName() + "<br>";
+ }
+ Content += "</p>";
+ Content += "<h4>Players:</h4><p>";
+
+ cWorld* World = cRoot::Get()->GetWorld();
+ cWorld::PlayerList PlayerList = World->GetAllPlayers();
+ for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
+ {
+ Content += std::string( (*itr)->GetName() ) + "<br>";
+ }
+ Content += "</p>";
+
+ for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr )
+ {
+ Menu += "<li><a href='" + (*itr)->GetName() + "'>" + (*itr)->GetName() + "</a></li>";
+ }
+
+ HTTPRequest Request;
+ Request.Username = r->username_;
+ Request.Method = r->method_;
+ Request.Params = new cStringMap(r->params_);
+ Request.Path = r->path_;
+
+ if( Split.size() > 1 )
+ {
+ std::string FoundPlugin = "";
+ for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr )
+ {
+ if( (*itr)->GetName() == Split[1] )
+ {
+ Content = (*itr)->HandleRequest( &Request );
+ FoundPlugin = (*itr)->GetName();
+ break;
+ }
+ }
+
+ if( FoundPlugin.compare("") != 0 ) // Add some header
+ {
+ Content = "<h3>" + FoundPlugin + "</h3>\n<p>" + Content + "</p>";
+ }
+ }
+
+ delete Request.Params;
+
+ if( Split.size() > 1 )
+ {
+ Content += "\n<p><a href='";
+ for( unsigned int i = 0; i < Split.size(); i++)
+ {
+ Content += "../";
+ }
+ Content += "webadmin/";
+ Content += "'>Go back</a></p>";
+ }
+
+ // mem usage
+#ifndef _WIN32
+ rusage resource_usage;
+ if (getrusage(RUSAGE_SELF, &resource_usage) != 0)
+ {
+ ReplaceString( Template, std::string("{MEM}"), "Error :(" );
+ }
+ else
+ {
+ char MemUsage[32];
+ sprintf( 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) ) )
+ {
+ char MemUsage[32];
+ sprintf( MemUsage, "%0.2f", (pmc.WorkingSetSize / 1024.f / 1024.f) );
+ ReplaceString( Template, std::string("{MEM}"), MemUsage );
+ }
+#endif
+ // end mem usage
+
+ ReplaceString( Template, std::string("{USERNAME}"), r->username_ );
+ ReplaceString( Template, std::string("{MENU}"), Menu );
+ ReplaceString( Template, std::string("{CONTENT}"), Content );
+ ReplaceString( Template, std::string("{TITLE}"), "MCServer" );
+
+ r->answer_ = Template;
+ }
+ else
+ {
+ r->answer_ += "Wrong username/password";
+ r->auth_realm_ = "MCServer WebAdmin";
+ }
+ }
+ else
+ {
+ r->answer_ += "no auth";
+ r->auth_realm_ = "MCServer WebAdmin";
+ }
+ }
+}
+
+bool cWebAdmin::Init( int a_Port )
+{
+ m_Port = a_Port;
+
+ m_IniFile = new cIniFile("webadmin.ini");
+ if( m_IniFile->ReadFile() )
+ {
+ m_Port = m_IniFile->GetValueI("WebAdmin", "Port", 8080 );
+ }
+
+ LOG("Starting WebAdmin on port %i", m_Port);
+
+#ifdef _WIN32
+ HANDLE hThread = CreateThread(
+ NULL, // default security
+ 0, // default stack size
+ ListenThread, // name of the thread function
+ this, // thread parameters
+ 0, // default startup flags
+ NULL);
+ CloseHandle( hThread ); // Just close the handle immediately
+#else
+ pthread_t LstnThread;
+ pthread_create( &LstnThread, 0, ListenThread, this);
+#endif
+
+ return true;
+}
+
+#ifdef _WIN32
+DWORD WINAPI cWebAdmin::ListenThread(LPVOID lpParam)
+#else
+void *cWebAdmin::ListenThread( void *lpParam )
+#endif
+{
+ cWebAdmin* self = (cWebAdmin*)lpParam;
+
+ self->m_WebServer = new webserver(self->m_Port, Request_Handler );
+ self->m_WebServer->Begin();
+
+ self->m_Event->Set();
+ return 0;
+}
+
+std::string cWebAdmin::GetTemplate()
+{
+ std::string retVal = "";
+
+ char SourceFile[] = "webadmin/template.html";
+
+ FILE* f;
+#ifdef _WIN32
+ if( fopen_s(&f, SourceFile, "rb" ) == 0 ) // no error
+#else
+ if( (f = fopen(SourceFile, "rb" ) ) != 0 ) // no error
+#endif
+ {
+ // obtain file size:
+ fseek (f , 0 , SEEK_END);
+ long lSize = ftell (f);
+ rewind (f);
+
+ // allocate memory to contain the whole file:
+ char* buffer = (char*) malloc (sizeof(char)*lSize);
+
+ // copy the file into the buffer:
+ size_t result = fread (buffer, 1, lSize, f);
+ if ((long)result != lSize)
+ {
+ LOG ("WEBADMIN: Could not read file %s", SourceFile);
+ free( buffer );
+ return "";
+ }
+
+ retVal.assign( buffer, lSize );
+
+ free( buffer );
+ fclose(f);
+ }
+ return retVal;
+}
+
+
+void cWebAdmin::RemovePlugin( lua_State* L )
+{
+ for( PluginList::iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); )
+ {
+ if( (*itr)->GetLuaState() == L )
+ {
+ PluginList::iterator prev = itr++;
+ delete *prev; // deleting a dereferenced iterator also takes it out of the list, so no need for erase()
+ }
+ else
+ ++itr;
+ }
+}
diff --git a/source/cWebAdmin.h b/source/cWebAdmin.h
new file mode 100644
index 000000000..e58eab24e
--- /dev/null
+++ b/source/cWebAdmin.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <list>
+#include "../WebServer/WebServer.h"
+#include "cSocket.h"
+
+class cStringMap;
+//tolua_begin
+struct HTTPRequest
+{
+ std::string Method;
+ std::string Path;
+ cStringMap* Params;
+ std::string Username;
+};
+//tolua_end
+
+struct lua_State;
+class cEvent;
+class cIniFile;
+class cWebPlugin;
+class cWebAdmin
+{
+public:
+ cWebAdmin( int a_Port = 8080 );
+ ~cWebAdmin();
+
+ bool Init( int a_Port );
+
+ 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);
+
+ void RemovePlugin( lua_State* L );
+private:
+
+#ifdef _WIN32
+ static DWORD WINAPI ListenThread(LPVOID lpParam);
+#else
+ static void *ListenThread( void *lpParam );
+#endif
+
+ std::string GetTemplate();
+
+ int m_Port;
+
+ bool m_bConnected;
+ cSocket m_ListenSocket;
+
+ cIniFile* m_IniFile;
+ PluginList m_Plugins;
+
+ cEvent* m_Event;
+
+ webserver* m_WebServer;
+}; \ No newline at end of file
diff --git a/source/cWebPlugin.cpp b/source/cWebPlugin.cpp
new file mode 100644
index 000000000..43e5e5e54
--- /dev/null
+++ b/source/cWebPlugin.cpp
@@ -0,0 +1,22 @@
+#include "cWebPlugin.h"
+#include "cWebAdmin.h"
+#include "cServer.h"
+#include "cMCLogger.h"
+#include "cRoot.h"
+
+#include "MemoryLeak.h"
+
+cWebPlugin::cWebPlugin( lua_State* L )
+{
+ LOG("cWebPlugin::cWebPlugin()");
+ m_LuaState = L;
+ cWebAdmin* WebAdmin = cRoot::Get()->GetWebAdmin();
+ if( WebAdmin ) WebAdmin->AddPlugin( this );
+}
+
+cWebPlugin::~cWebPlugin()
+{
+ LOG("~cWebPlugin::cWebPlugin()");
+ cWebAdmin* WebAdmin = cRoot::Get()->GetWebAdmin();
+ if( WebAdmin ) WebAdmin->RemovePlugin( this );
+} \ No newline at end of file
diff --git a/source/cWebPlugin.h b/source/cWebPlugin.h
new file mode 100644
index 000000000..397f3ea81
--- /dev/null
+++ b/source/cWebPlugin.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <string>
+
+struct lua_State;
+struct HTTPRequest;
+//tolua_begin
+class cWebPlugin
+{
+public:
+ cWebPlugin( lua_State* L );
+ virtual ~cWebPlugin();
+
+ void SetName( std::string a_Name ) { m_Name = a_Name; }
+ std::string GetName() { return m_Name; }
+
+ virtual std::string HandleRequest( HTTPRequest* a_Request ) = 0;
+ virtual void Initialize() = 0;
+ //tolua_end
+
+ lua_State* GetLuaState() { return m_LuaState; }
+private:
+ lua_State* m_LuaState;
+ std::string m_Name;
+}; //tolua_export \ No newline at end of file
diff --git a/source/cWindow.cpp b/source/cWindow.cpp
new file mode 100644
index 000000000..f3caa628c
--- /dev/null
+++ b/source/cWindow.cpp
@@ -0,0 +1,235 @@
+#include "cWindow.h"
+#include "cItem.h"
+#include "cMCLogger.h"
+#include "cClientHandle.h"
+#include "cPlayer.h"
+#include "cInventory.h"
+#include "cWindowOwner.h"
+
+#include "packets/cPacket_WindowClick.h"
+#include "packets/cPacket_WholeInventory.h"
+#include "packets/cPacket_WindowOpen.h"
+#include "packets/cPacket_WindowClose.h"
+
+#include <list>
+
+cWindow::cWindow( cWindowOwner* a_Owner, bool a_bInventoryVisible )
+ : m_WindowID( 0 )
+ , m_WindowType( 0 )
+ , m_Owner( a_Owner )
+ , m_bInventoryVisible( a_bInventoryVisible )
+ , m_NumSlots( 0 )
+ , m_Slots( 0 )
+ , m_DraggingItem( 0 )
+{
+ if( !m_bInventoryVisible ) m_DraggingItem = new cItem();
+}
+
+cWindow::~cWindow()
+{
+ if( !m_bInventoryVisible && m_DraggingItem )
+ {
+ delete m_DraggingItem;
+ m_DraggingItem = 0;
+ }
+}
+
+cItem* cWindow::GetSlot( int a_Slot )
+{
+ if(a_Slot > -1 && a_Slot < m_NumSlots)
+ {
+ return (m_Slots + a_Slot);
+ }
+ return 0;
+}
+
+cItem* cWindow::GetDraggingItem( cPlayer * a_Player /* = 0 */ )
+{
+ if( m_bInventoryVisible && a_Player )
+ {
+ cWindow* Window = a_Player->GetInventory().GetWindow();
+ if( Window )
+ {
+ return Window->GetDraggingItem();
+ }
+ }
+ return m_DraggingItem;
+}
+
+void cWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
+{
+ //LOG("cWindow click");
+ if( a_ClickPacket->m_WindowID != m_WindowID )
+ {
+ LOG("WRONG WINDOW ID!");
+ return;
+ }
+
+ if( m_bInventoryVisible )
+ {
+ cWindow* Window = a_Player.GetInventory().GetWindow();
+ if( Window )
+ {
+ m_DraggingItem = Window->GetDraggingItem();
+ }
+ }
+ bool bAsync = false;
+ if( a_ClickPacket->m_SlotNum == -999 ) // Outside window click
+ {
+ if( a_ClickPacket->m_RightMouse )
+ a_Player.TossItem( true );
+ else
+ a_Player.TossItem( true, m_DraggingItem->m_ItemCount );
+ }
+ else if( GetSlot( a_ClickPacket->m_SlotNum ) != 0 )
+ {
+ cItem* Item = GetSlot( a_ClickPacket->m_SlotNum );
+ if( a_ClickPacket->m_ItemID != Item->m_ItemID
+ || a_ClickPacket->m_ItemCount != Item->m_ItemCount
+ || a_ClickPacket->m_ItemUses != Item->m_ItemHealth )
+ {
+ if( !((a_ClickPacket->m_ItemID == -1 || a_ClickPacket->m_ItemID == 0) && (Item->m_ItemID == -1 || Item->m_ItemID == 0 )) )
+ {
+ LOG("My ID: %i Their ID: %i", Item->m_ItemID, a_ClickPacket->m_ItemID );
+ LOG("My Count: %i Their Count: %i", Item->m_ItemCount, a_ClickPacket->m_ItemCount );
+ LOG("My Uses: %i Their Uses: %i", Item->m_ItemHealth, a_ClickPacket->m_ItemUses );
+ bAsync = true;
+ }
+ }
+ }
+ if( m_DraggingItem && a_ClickPacket->m_SlotNum > -1 && a_ClickPacket->m_SlotNum < m_NumSlots )
+ {
+ if( a_ClickPacket->m_RightMouse == 0 )
+ {
+ if( !m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum] ) )
+ {
+ cItem tmp( *m_DraggingItem );
+ *m_DraggingItem = m_Slots[a_ClickPacket->m_SlotNum];
+ m_Slots[a_ClickPacket->m_SlotNum] = tmp; // Switch contents
+ }
+ else
+ {
+ int FreeSlots = 64 - m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount;
+ int Filling = (FreeSlots > m_DraggingItem->m_ItemCount) ? m_DraggingItem->m_ItemCount : FreeSlots;
+ m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount += (char)Filling;
+ m_DraggingItem->m_ItemCount -= (char)Filling;
+ if( m_DraggingItem->m_ItemCount <= 0 )
+ m_DraggingItem->Empty();
+ }
+ }
+ else // Right clicked
+ {
+ if( m_DraggingItem->m_ItemID <= 0 ) // Empty?
+ {
+ m_DraggingItem->m_ItemCount = (char)(((float)m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount)/2.f + 0.5f);
+ m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount -= m_DraggingItem->m_ItemCount;
+ m_DraggingItem->m_ItemID = m_Slots[a_ClickPacket->m_SlotNum].m_ItemID;
+ m_DraggingItem->m_ItemHealth = m_Slots[a_ClickPacket->m_SlotNum].m_ItemHealth;
+
+ if( m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount <= 0 )
+ {
+ m_Slots[a_ClickPacket->m_SlotNum].Empty();
+ }
+ }
+ else if( m_Slots[a_ClickPacket->m_SlotNum].m_ItemID <= 0 || m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum] ) )
+ { // Drop one item in slot
+ if( m_DraggingItem->m_ItemCount > 0 && m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount < 64 )
+ {
+ m_Slots[a_ClickPacket->m_SlotNum].m_ItemID = m_DraggingItem->m_ItemID;
+ m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount++;
+ m_Slots[a_ClickPacket->m_SlotNum].m_ItemHealth = m_DraggingItem->m_ItemHealth;
+ m_DraggingItem->m_ItemCount--;
+ }
+ if( m_DraggingItem->m_ItemCount <= 0 )
+ {
+ m_DraggingItem->Empty();
+ }
+ }
+ else if( !m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum]) ) // Swap contents
+ {
+ cItem tmp( *m_DraggingItem );
+ *m_DraggingItem = m_Slots[a_ClickPacket->m_SlotNum];
+ m_Slots[a_ClickPacket->m_SlotNum] = tmp; // Switch contents
+ }
+ }
+ if( bAsync )
+ {
+ LOG("Window is not synchonous with client. Sending whole window. ID: %i", m_WindowID);
+ for( std::list< cPlayer* >::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr )
+ {
+ SendWholeWindow( (*itr)->GetClientHandle() );
+ }
+ if( m_bInventoryVisible || m_OpenedBy.size() == 0 )
+ {
+ a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() );
+ }
+ }
+ }
+ else if( m_bInventoryVisible ) // Click in player inventory
+ {
+ a_ClickPacket->m_WindowID = 0;
+ a_ClickPacket->m_SlotNum -= (short)(m_NumSlots - 9);
+ cWindow* Window = a_Player.GetInventory().GetWindow();
+ if( Window )
+ {
+ Window->Clicked( a_ClickPacket, a_Player );
+ }
+ }
+ if( m_DraggingItem ) LOG("Dragging: %i", m_DraggingItem->m_ItemCount );
+}
+
+void cWindow::Open( cPlayer & a_Player )
+{
+ // If player is already in OpenedBy remove player first
+ m_OpenedBy.remove( &a_Player );
+ // Then add player
+ m_OpenedBy.push_back( &a_Player );
+
+ cPacket_WindowOpen WindowOpen;
+ WindowOpen.m_WindowID = (char)m_WindowID;
+ WindowOpen.m_InventoryType = (char)m_WindowType;
+ WindowOpen.m_WindowTitle = m_WindowTitle;
+ WindowOpen.m_NumSlots = (char)m_NumSlots;
+ a_Player.GetClientHandle()->Send( WindowOpen );
+}
+
+void cWindow::Close( cPlayer & a_Player )
+{
+ cPacket_WindowClose WindowClose;
+ WindowClose.m_Close = (char)m_WindowID;
+ cClientHandle* ClientHandle = a_Player.GetClientHandle();
+ if( ClientHandle ) ClientHandle->Send( WindowClose );
+
+ m_OpenedBy.remove( &a_Player );
+ if( m_OpenedBy.size() == 0 )
+ {
+ Destroy();
+ }
+}
+
+void cWindow::OwnerDestroyed()
+{
+ m_Owner = 0;
+ while( m_OpenedBy.size() > 1 )
+ {
+ (*m_OpenedBy.begin() )->CloseWindow();
+ }
+ (*m_OpenedBy.begin() )->CloseWindow();
+}
+
+void cWindow::Destroy()
+{
+ LOG("DESTROY WINDOW");
+ if( m_Owner )
+ {
+ m_Owner->CloseWindow();
+ m_Owner = 0;
+ }
+ delete this;
+}
+
+void cWindow::SendWholeWindow( cClientHandle* a_Client )
+{
+ cPacket_WholeInventory Inventory( this );
+ a_Client->Send( Inventory );
+}
diff --git a/source/cWindow.h b/source/cWindow.h
new file mode 100644
index 000000000..888a11b98
--- /dev/null
+++ b/source/cWindow.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "MemoryLeak.h"
+#include <list>
+#include <string>
+
+class cPacket_WindowClick;
+class cPlayer;
+class cItem;
+class cWindowOwner;
+class cClientHandle;
+class cWindow
+{
+public:
+ cWindow( cWindowOwner* a_Owner, bool a_bInventoryVisible );
+ ~cWindow();
+
+ int GetWindowID() { return m_WindowID; }
+ void SetWindowID( int a_WindowID ) { m_WindowID = a_WindowID; }
+
+ int GetWindowType() { return m_WindowType; }
+ void SetWindowType( int a_WindowType ) { m_WindowType = a_WindowType; }
+
+ cItem* GetSlots() { return m_Slots; }
+ int GetNumSlots() { return m_NumSlots; }
+
+ cItem* GetSlot( int a_Slot );
+
+ cItem* GetDraggingItem( cPlayer * a_Player = 0 );
+
+ // a_Slots is an array of slots of size a_NumSlots
+ void SetSlots(cItem* a_Slots, int a_NumSlots) { m_Slots = a_Slots; m_NumSlots = a_NumSlots; }
+
+ bool IsInventoryVisible() { return m_bInventoryVisible; }
+ void SetInventoryVisible( bool a_bVisible ) { m_bInventoryVisible = a_bVisible; }
+
+ virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player );
+
+ virtual void Open( cPlayer & a_Player );
+ virtual void Close( cPlayer & a_Player );
+
+ cWindowOwner* GetOwner() { return m_Owner; }
+ void SetOwner( cWindowOwner* a_Owner ) { m_Owner = a_Owner; }
+
+ void SendWholeWindow( cClientHandle* a_Client );
+
+ const std::string & GetWindowTitle() const { return m_WindowTitle; }
+ void SetWindowTitle( const std::string & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
+
+ const std::list<cPlayer*> & GetOpenedBy() const { return m_OpenedBy; }
+
+ void OwnerDestroyed();
+private:
+ void Destroy();
+
+ int m_WindowID;
+ int m_WindowType;
+ std::string m_WindowTitle;
+
+ cWindowOwner* m_Owner;
+
+ std::list<cPlayer*> m_OpenedBy;
+ bool m_bInventoryVisible;
+ int m_NumSlots;
+ cItem* m_Slots;
+ cItem* m_DraggingItem;
+}; \ No newline at end of file
diff --git a/source/cWindowOwner.h b/source/cWindowOwner.h
new file mode 100644
index 000000000..b60b97b6c
--- /dev/null
+++ b/source/cWindowOwner.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "MemoryLeak.h"
+
+class cWindow;
+class cWindowOwner
+{
+public:
+ cWindowOwner() : m_Window( 0 ) {}
+ void CloseWindow() { m_Window = 0; }
+ void OpenWindow( cWindow* a_Window ) { m_Window = a_Window; }
+
+ cWindow* GetWindow() { return m_Window; }
+private:
+ cWindow* m_Window;
+}; \ No newline at end of file
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
new file mode 100644
index 000000000..e634ea112
--- /dev/null
+++ b/source/cWorld.cpp
@@ -0,0 +1,764 @@
+#include "BlockID.h"
+#include "cWorld.h"
+#include "cChunk.h"
+#include "cClientHandle.h"
+#include "cPickup.h"
+#include "cBlockToPickup.h"
+#include "cMCLogger.h"
+#include "cPlayer.h"
+#include "cServer.h"
+#include "cCriticalSection.h"
+#include "cItem.h"
+#include "cRoot.h"
+#include "../iniFile/iniFile.h"
+#include "cChunkMap.h"
+#include "cWaterSimulator.h"
+#include "cChicken.h"
+#include "cSpider.h"
+#include "cGenSettings.h"
+
+
+#include "packets/cPacket_TimeUpdate.h"
+
+#include "Vector3d.h"
+
+#include <time.h>
+
+#include "tolua++.h"
+
+#ifndef _WIN32
+#include <stdlib.h>
+#include <sys/stat.h> // for mkdir
+#include <sys/types.h>
+#endif
+
+float cWorld::m_Time = 0.f;
+
+char g_BlockLightValue[128];
+char g_BlockSpreadLightFalloff[128];
+bool g_BlockTransparent[128];
+bool g_BlockOneHitDig[128];
+
+#define RECI_RAND_MAX (1.f/RAND_MAX)
+inline float fRadRand( float a_Radius )
+{
+ return ((float)rand() * RECI_RAND_MAX)*a_Radius - a_Radius*0.5f;
+}
+
+struct cWorld::sWorldState
+{
+ cWorld::EntityList m_RemoveEntityQueue;
+ cWorld::EntityList m_AllEntities;
+ cWorld::ClientList m_Clients;
+ cWorld::PlayerList m_Players;
+
+ static const unsigned int CHUNKBUFFER_SIZE = 5;
+ std::vector< unsigned int > m_ChunkBuffer;
+
+ cWorld::ChunkList m_SpreadQueue;
+};
+
+cWorld* cWorld::GetWorld()
+{
+ LOGWARN("WARNING: Using deprecated function cWorld::GetWorld() use cRoot::Get()->GetWorld() instead!");
+ return cRoot::Get()->GetWorld();
+}
+
+cWorld::~cWorld()
+{
+ LockEntities();
+ while( m_pState->m_AllEntities.begin() != m_pState->m_AllEntities.end() )
+ {
+ cEntity* Entity = *m_pState->m_AllEntities.begin();
+ m_pState->m_AllEntities.remove( Entity );
+ RemoveEntity( Entity );
+ }
+ UnlockEntities();
+
+ delete m_WaterSimulator;
+
+ UnloadUnusedChunks();
+ delete m_ChunkMap;
+
+ delete m_ClientHandleCriticalSection; m_ClientHandleCriticalSection = 0;
+ delete m_EntitiesCriticalSection; m_EntitiesCriticalSection = 0;
+ delete m_ChunksCriticalSection; m_ChunksCriticalSection = 0;
+ delete m_pState;
+}
+
+cWorld::cWorld()
+ : m_pState( new sWorldState )
+ , m_SpawnMonsterTime( 0.f )
+{
+ LOG("cWorld::cWorld()");
+
+#ifdef _WIN32
+ {
+ SECURITY_ATTRIBUTES Attrib;
+ Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
+ Attrib.lpSecurityDescriptor = NULL;
+ Attrib.bInheritHandle = false;
+ ::CreateDirectory("world", &Attrib);
+ }
+#else
+ {
+ mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+#endif
+
+ srand( (unsigned int) time(0) );
+ m_SpawnX = (double)((rand()%10000)-5000);
+ m_SpawnY = 128;
+ m_SpawnZ = (double)((rand()%10000)-5000);
+ m_WorldSeed = rand();
+
+ cIniFile IniFile("world/world.ini");
+ if( IniFile.ReadFile() )
+ {
+ m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX );
+ m_SpawnY = IniFile.GetValueF("SpawnPosition", "Y", m_SpawnY );
+ m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ );
+ m_WorldSeed = IniFile.GetValueI("Seed", "Seed", m_WorldSeed );
+ }
+ else
+ {
+ IniFile.SetValueF("SpawnPosition", "X", m_SpawnX );
+ IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY );
+ IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ );
+ IniFile.SetValueI("Seed", "Seed", m_WorldSeed );
+ if( !IniFile.WriteFile() )
+ {
+ LOG("WARNING: Could not write to world/world.ini");
+ }
+ }
+ LOGINFO("Seed: %i", m_WorldSeed );
+
+ cIniFile GenSettings("terrain.ini");
+ if( GenSettings.ReadFile() )
+ {
+#define READ_INI_TERRAIN_VAL( var, type ) cGenSettings::var = (type)GenSettings.GetValueF("Terrain", #var, cGenSettings::var )
+ READ_INI_TERRAIN_VAL( HeightFreq1, float );
+ READ_INI_TERRAIN_VAL( HeightFreq2, float );
+ READ_INI_TERRAIN_VAL( HeightFreq3, float );
+ READ_INI_TERRAIN_VAL( HeightAmp1, float );
+ READ_INI_TERRAIN_VAL( HeightAmp2, float );
+ READ_INI_TERRAIN_VAL( HeightAmp3, float );
+ }
+ else
+ {
+#define SET_INI_TERRAIN_VAL( var ) GenSettings.SetValueF("Terrain", #var, cGenSettings::var )
+ SET_INI_TERRAIN_VAL( HeightFreq1 );
+ SET_INI_TERRAIN_VAL( HeightFreq2 );
+ SET_INI_TERRAIN_VAL( HeightFreq3 );
+ SET_INI_TERRAIN_VAL( HeightAmp1 );
+ SET_INI_TERRAIN_VAL( HeightAmp2 );
+ SET_INI_TERRAIN_VAL( HeightAmp3 );
+ GenSettings.WriteFile();
+ }
+
+ m_bAnimals = true;
+ m_SpawnMonsterRate = 10;
+ cIniFile IniFile2("settings.ini");
+ if( IniFile2.ReadFile() )
+ {
+ m_bAnimals = IniFile2.GetValueB("Monsters", "AnimalsOn", true );
+ m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
+ }
+
+ m_ChunkMap = new cChunkMap( 32, 32 );
+
+ m_Time = 0;
+ m_WorldTimeFraction = 0.f;
+ m_WorldTime = 0;
+ m_LastSave = 0;
+ m_LastUnload = 0;
+ m_ClientHandleCriticalSection = new cCriticalSection();
+ m_EntitiesCriticalSection = new cCriticalSection();
+ m_ChunksCriticalSection = new cCriticalSection();
+
+ m_WaterSimulator = new cWaterSimulator( this );
+
+ memset( g_BlockLightValue, 0x0, 128 );
+ memset( g_BlockSpreadLightFalloff, 0xf, 128 ); // 0xf means total falloff
+ memset( g_BlockTransparent, 0x0, 128 );
+ memset( g_BlockOneHitDig, 0x0, 128 );
+
+ // Emissive blocks
+ g_BlockLightValue[ E_BLOCK_TORCH ] = 14;
+ g_BlockLightValue[ E_BLOCK_FIRE ] = 15;
+ g_BlockLightValue[ E_BLOCK_LAVA ] = 15;
+ g_BlockLightValue[ E_BLOCK_STATIONARY_LAVA ] = 15;
+ g_BlockLightValue[ E_BLOCK_GLOWSTONE ] = 15;
+
+ // Spread blocks
+ g_BlockSpreadLightFalloff[ E_BLOCK_AIR ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_TORCH ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_FIRE ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_LAVA ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_STATIONARY_LAVA ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_WATER ] = 4; // Light in water dissapears faster
+ g_BlockSpreadLightFalloff[ E_BLOCK_STATIONARY_WATER ] = 4;
+ g_BlockSpreadLightFalloff[ E_BLOCK_LEAVES ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_GLASS ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_GLOWSTONE ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_SIGN_POST ] = 1;
+ g_BlockSpreadLightFalloff[ E_BLOCK_WALLSIGN ] = 1;
+
+ // Transparent blocks
+ g_BlockTransparent[ E_BLOCK_AIR ] = true;
+ g_BlockTransparent[ E_BLOCK_GLASS ] = true;
+ g_BlockTransparent[ E_BLOCK_FIRE ] = true;
+ g_BlockTransparent[ E_BLOCK_ICE ] = true;
+ g_BlockTransparent[ E_BLOCK_TORCH ] = true;
+ g_BlockTransparent[ E_BLOCK_SIGN_POST ] = true;
+ g_BlockTransparent[ E_BLOCK_WALLSIGN ] = true;
+
+ // One hit break blocks
+ g_BlockOneHitDig[ E_BLOCK_SAPLING ] = true;
+ g_BlockOneHitDig[ E_BLOCK_YELLOW_FLOWER ] = true;
+ g_BlockOneHitDig[ E_BLOCK_RED_ROSE ] = true;
+ g_BlockOneHitDig[ E_BLOCK_BROWN_MUSHROOM ] = true;
+ g_BlockOneHitDig[ E_BLOCK_RED_MUSHROOM ] = true;
+ g_BlockOneHitDig[ E_BLOCK_TNT ] = true;
+ g_BlockOneHitDig[ E_BLOCK_TORCH ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_WIRE ] = true;
+ g_BlockOneHitDig[ E_BLOCK_CROPS ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_TORCH_OFF ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_TORCH_ON ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REEDS ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_WIRE ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_REPEATER_OFF ] = true;
+ g_BlockOneHitDig[ E_BLOCK_REDSTONE_REPEATER_ON ] = true;
+ g_BlockOneHitDig[ E_BLOCK_LOCKED_CHEST ] = true;
+
+}
+
+void cWorld::InitializeSpawn()
+{
+ int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
+ BlockToChunk( (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ );
+ int ViewDist = cClientHandle::VIEWDISTANCE;
+ LOG("Loading spawn area");
+ for(int x = 0; x < ViewDist; x++)
+ {
+ for(int z = 0; z < ViewDist; z++)
+ {
+ GetChunk( x + ChunkX-(ViewDist-1)/2, 0, z + ChunkZ-(ViewDist-1)/2 );
+ }
+ LOG("Loaded %0.2f", ((float)x / (float)ViewDist)*100 );
+ }
+}
+
+void cWorld::Tick(float a_Dt)
+{
+ m_Time+=a_Dt/1000.f;
+
+ bool bSendTime = false;
+ m_WorldTimeFraction+=a_Dt/1000.f;
+ while( m_WorldTimeFraction > 1.f )
+ {
+ m_WorldTimeFraction-=1.f;
+ m_WorldTime+=20;
+ m_WorldTime %= 24000; // 24000 units in a day
+ bSendTime = true;
+ }
+ if( bSendTime ) cRoot::Get()->GetServer()->Broadcast( cPacket_TimeUpdate( (m_WorldTime) ) );
+
+ LockEntities();
+ for( cWorld::EntityList::iterator itr = GetEntities().begin(); itr != GetEntities().end();)
+ {
+ if( (*itr)->IsDestroyed() )
+ {
+ LOG("Destroy that entity! %i", (*itr)->GetUniqueID() );
+ cEntity* RemoveMe = *itr;
+ itr++;
+ AddToRemoveEntityQueue( *RemoveMe );
+ continue;
+ }
+ (*itr)->Tick(a_Dt);
+ itr++;
+ }
+ UnlockEntities();
+
+ LockChunks();
+
+ while( !m_pState->m_SpreadQueue.empty() )
+ {
+ cChunk* Chunk = (*m_pState->m_SpreadQueue.begin());
+ //LOG("Spreading: %p", Chunk );
+ Chunk->SpreadLight( Chunk->pGetSkyLight() );
+ Chunk->SpreadLight( Chunk->pGetLight() );
+ m_pState->m_SpreadQueue.remove( &*Chunk );
+ }
+
+ m_ChunkMap->Tick(a_Dt);
+ m_WaterSimulator->Simulate(a_Dt);
+ UnlockChunks();
+
+ if( m_Time - m_LastSave > 60*5 ) // Save each 5 minutes
+ {
+ SaveAllChunks();
+ }
+
+ if( m_Time - m_LastUnload > 10 ) // Unload each minute
+ {
+ UnloadUnusedChunks();
+ }
+
+ while( !m_pState->m_RemoveEntityQueue.empty() )
+ {
+ RemoveEntity( *m_pState->m_RemoveEntityQueue.begin() );
+ }
+
+
+ if( m_bAnimals && ( m_Time - m_SpawnMonsterTime > m_SpawnMonsterRate ) ) // 10 seconds
+ {
+ m_SpawnMonsterTime = m_Time;
+ if( m_pState->m_Players.size() > 0 )
+ {
+ cChicken *Chicken;
+ cSpider *Spider;
+ int RandomPlayerIdx = rand() & m_pState->m_Players.size();
+ PlayerList::iterator itr = m_pState->m_Players.begin();
+ for( int i = 1; i < RandomPlayerIdx; i++ )
+ itr++;
+
+ cPlayer* Player = *itr;
+ Vector3d SpawnPos = Player->GetPosition();
+ SpawnPos += Vector3d( (double)(rand()%64)-32, (double)(rand()%64)-32, (double)(rand()%64)-32 );
+ char Height = GetHeight( (int)SpawnPos.x, (int)SpawnPos.z );
+
+ //cMonster* Monster = new cChicken();
+ if(m_WorldTime >= 12000 + 1000) {
+ Spider = new cSpider();
+ Spider->Initialize();
+ Spider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Spider->SpawnOn( 0 );
+ } else {
+ Chicken = new cChicken();
+ Chicken->Initialize();
+ Chicken->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Chicken->SpawnOn( 0 );
+ }
+ //Monster->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ //Monster->SpawnOn( 0 );
+ }
+ }
+}
+
+void cWorld::GrowTree( int a_X, int a_Y, int a_Z )
+{
+ // new tree code, looks much better
+ // with help from seanj
+ // converted from php to lua then lua to c++
+
+ // build trunk
+ int trunk = rand() % (7 - 5 + 1) + 5;
+ for (int i = 0; i < trunk; i++)
+ {
+
+ if( GetBlock( a_X, a_Y + i, a_Z ) == E_BLOCK_AIR )
+ FastSetBlock( a_X, a_Y + i, a_Z, E_BLOCK_LOG, 0 );
+ }
+
+ // build tree
+ for (int j = 0; j < trunk; j++) {
+ int radius = trunk - j;
+ if (radius < 4) {
+ if (radius > 2) {
+ radius = 2;
+ }
+ for (int i = a_X - radius; i <= a_X + radius; i++) {
+ for (int k = a_Z-radius; k <= a_Z + radius; k++) {
+ // small chance to be missing a block to add a little random
+ if (k != a_Z || i != a_X && (rand() % 100 + 1) > 20) {
+
+ if( GetBlock( i, a_Y + j, k ) == E_BLOCK_AIR )
+ FastSetBlock(i, a_Y+j, k, E_BLOCK_LEAVES, 0 );
+ }
+ else {
+ //if( m_BlockType[ MakeIndex(i, TopY+j, k) ] == E_BLOCK_AIR )
+ // m_BlockType[ MakeIndex(i, TopY+j, k) ] = E_BLOCK_LEAVES;
+ }
+ }
+ }
+ if( GetBlock( a_X, a_Y+j, a_Z ) == E_BLOCK_AIR )
+ FastSetBlock( a_X, a_Y+j, a_Z, E_BLOCK_LOG, 0 );
+
+ }
+ }
+
+ // do the top
+ if( GetBlock( a_X+1, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
+ FastSetBlock( a_X+1, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
+
+ if( GetBlock( a_X-1, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
+ FastSetBlock( a_X-1, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
+
+ if( GetBlock( a_X, a_Y+trunk, a_Z+1 ) == E_BLOCK_AIR )
+ FastSetBlock( a_X, a_Y+trunk, a_Z+1, E_BLOCK_LEAVES, 0 );
+
+ if( GetBlock( a_X, a_Y+trunk, a_Z-1 ) == E_BLOCK_AIR )
+ FastSetBlock( a_X, a_Y+trunk, a_Z-1, E_BLOCK_LEAVES, 0 );
+
+ if( GetBlock( a_X, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
+ FastSetBlock( a_X, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
+
+ // end new tree code
+}
+
+void cWorld::UnloadUnusedChunks()
+{
+ m_LastUnload = m_Time;
+
+ LockChunks();
+ m_ChunkMap->UnloadUnusedChunks();
+ UnlockChunks();
+}
+
+cChunk* cWorld::GetChunk( int a_X, int a_Y, int a_Z )
+{
+ cChunk* Chunk = GetChunkUnreliable( a_X, a_Y, a_Z );
+ if( Chunk )
+ {
+ return Chunk;
+ }
+
+ // Found nothing, create a chunk
+ Chunk = new cChunk( a_X, a_Y, a_Z );
+ if(Chunk)
+ {
+ LOGWARN("Created new chunk! %i %i", a_X, a_Z);
+ LockChunks();
+ m_ChunkMap->AddChunk( Chunk );
+ UnlockChunks();
+ Chunk->Initialize();
+ return Chunk;
+ }
+
+ // This should never happen, but yeah
+ return 0;
+}
+
+cChunk* cWorld::GetChunkUnreliable( int a_X, int a_Y, int a_Z )
+{
+ LockChunks();
+ cChunk* Chunk = m_ChunkMap->GetChunk( a_X, a_Y, a_Z );
+ UnlockChunks();
+ if( Chunk ) return Chunk;
+ return 0;
+}
+
+cChunk* cWorld::GetChunkOfBlock( int a_X, int a_Y, int a_Z )
+{
+ int ChunkX, ChunkY, ChunkZ;
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+ return GetChunk( ChunkX, ChunkY, ChunkZ );
+}
+
+void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
+{
+ m_WaterSimulator->WakeUp( a_X, a_Y, a_Z );
+
+ int ChunkX, ChunkY, ChunkZ;
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+
+ GetChunk( ChunkX, ChunkY, ChunkZ )->SetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta );
+}
+
+void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
+{
+ int ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+
+ GetChunk( ChunkX, ChunkY, ChunkZ )->FastSetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta );
+}
+
+char cWorld::GetBlock( int a_X, int a_Y, int a_Z )
+{
+ int ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+
+ return GetChunk( ChunkX, ChunkY, ChunkZ )->GetBlock(a_X, a_Y, a_Z);
+}
+
+char cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
+{
+ int ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+
+ cChunk* Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ return Chunk->GetLight( Chunk->pGetMeta(), a_X, a_Y, a_Z );
+}
+
+void cWorld::SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData )
+{
+ int ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+
+ cChunk* Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ Chunk->SetLight( Chunk->pGetMeta(), a_X, a_Y, a_Z, a_MetaData );
+ Chunk->SendBlockTo( a_X, a_Y, a_Z, 0 );
+}
+
+bool cWorld::DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem )
+{
+ int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
+
+ cChunk* DestChunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ if(DestChunk)
+ {
+ DestChunk->SetBlock(PosX, PosY, PosZ, 0, 0 );
+ m_WaterSimulator->WakeUp( a_X, a_Y, a_Z );
+
+ if( !a_PickupItem.IsEmpty() )
+ {
+ cPickup* Pickup = new cPickup( a_X*32 + 16 + (int)fRadRand(16.f), a_Y*32 + 16 + (int)fRadRand(16.f), a_Z*32 + 16 + (int)fRadRand(16.f), a_PickupItem );
+ Pickup->Initialize();
+ }
+ }
+
+ return true;
+}
+
+void cWorld::SendBlockTo( int a_X, int a_Y, int a_Z, cPlayer* a_Player )
+{
+ int ChunkX, ChunkY, ChunkZ;
+ AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
+ cChunk* Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ Chunk->SendBlockTo( a_X, a_Y, a_Z, a_Player->GetClientHandle() );
+}
+
+cBlockEntity* cWorld::GetBlockEntity( int a_X, int a_Y, int a_Z )
+{
+ int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
+
+ AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
+
+ cChunk* Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ if( !Chunk ) return 0;
+
+ return Chunk->GetBlockEntity( a_X, a_Y, a_Z );
+}
+
+char cWorld::GetHeight( int a_X, int a_Z )
+{
+ int PosX = a_X, PosY = 0, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
+ AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
+ cChunk* Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
+ return Chunk->GetHeight( PosX, PosZ );
+}
+
+const double & cWorld::GetSpawnY()
+{
+ m_SpawnY = (double)GetHeight( (int)m_SpawnX, (int)m_SpawnZ ) + 1.6f; // +1.6f eye height
+ return m_SpawnY;
+}
+
+void cWorld::AddPlayer( cPlayer* a_Player )
+{
+ m_pState->m_Players.remove( a_Player );
+ m_pState->m_Players.push_back( a_Player );
+}
+
+void cWorld::RemovePlayer( cPlayer* a_Player )
+{
+ m_pState->m_Players.remove( a_Player );
+}
+
+void cWorld::GetAllPlayers( lua_State* L )
+{
+ lua_createtable(L, m_pState->m_Players.size(), 0);
+ int newTable = lua_gettop(L);
+ int index = 1;
+ PlayerList::const_iterator iter = m_pState->m_Players.begin();
+ while(iter != m_pState->m_Players.end()) {
+ tolua_pushusertype( L, (*iter), "cPlayer" );
+ lua_rawseti(L, newTable, index);
+ ++iter;
+ ++index;
+ }
+}
+
+cPlayer* cWorld::GetPlayer( const char* a_PlayerName )
+{
+ cPlayer* BestMatch = 0;
+ unsigned int MatchedLetters = 0;
+ unsigned int NumMatches = 0;
+ bool bPerfectMatch = false;
+
+ unsigned int NameLength = strlen( a_PlayerName );
+ for( PlayerList::iterator itr = m_pState->m_Players.begin(); itr != m_pState->m_Players.end(); itr++ )
+ {
+ std::string Name = (*itr)->GetName();
+ if( NameLength > Name.length() ) continue; // Definitely not a match
+
+ for(unsigned int i = 0; i < NameLength; i++)
+ {
+ char c1 = (char)toupper( a_PlayerName[i] );
+ char c2 = (char)toupper( Name[i] );
+ if( c1 == c2 )
+ {
+ if( i+1 > MatchedLetters )
+ {
+ MatchedLetters = i+1;
+ BestMatch = *itr;
+ }
+ if( i+1 == NameLength )
+ {
+ NumMatches++;
+ if( NameLength == Name.length() )
+ {
+ bPerfectMatch = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if( BestMatch == *itr ) BestMatch = 0;
+ break;
+ }
+ if( bPerfectMatch )
+ break;
+ }
+ }
+ if( NumMatches == 1 )
+ return BestMatch;
+
+ // More than one matches, so it's undefined. Return 0 instead
+ return 0;
+}
+
+cEntity* cWorld::GetEntity( int a_UniqueID )
+{
+ for( EntityList::iterator itr = m_pState->m_AllEntities.begin(); itr != m_pState->m_AllEntities.end(); ++itr )
+ {
+ if( (*itr)->GetUniqueID() == a_UniqueID )
+ return *itr;
+ }
+ return 0;
+}
+
+void cWorld::RemoveClient( cClientHandle* a_Client )
+{
+ m_pState->m_Clients.remove( a_Client );
+ if( a_Client )
+ {
+ delete a_Client;
+ a_Client = 0;
+ }
+}
+
+void cWorld::RemoveEntity( cEntity* a_Entity )
+{
+ m_pState->m_RemoveEntityQueue.remove( a_Entity );
+ if( a_Entity )
+ {
+ delete a_Entity;
+ a_Entity = 0;
+ }
+}
+
+bool cWorld::RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
+{
+ LockChunks();
+ bool retVal = m_ChunkMap->RemoveEntityFromChunk( a_Entity, a_CalledFrom );
+ UnlockChunks();
+ return retVal;
+}
+
+void cWorld::SaveAllChunks()
+{
+ LOG("Saving all chunks...");
+ m_LastSave = m_Time;
+ LockChunks();
+ m_ChunkMap->SaveAllChunks();
+ UnlockChunks();
+ LOG("Done saving chunks");
+}
+
+void cWorld::LockClientHandle()
+{
+ m_ClientHandleCriticalSection->Lock();
+}
+
+void cWorld::UnlockClientHandle()
+{
+ m_ClientHandleCriticalSection->Unlock();
+}
+
+void cWorld::LockEntities()
+{
+ m_EntitiesCriticalSection->Lock();
+}
+
+void cWorld::UnlockEntities()
+{
+ m_EntitiesCriticalSection->Unlock();
+}
+
+void cWorld::LockChunks()
+{
+ m_ChunksCriticalSection->Lock();
+}
+
+void cWorld::UnlockChunks()
+{
+ m_ChunksCriticalSection->Unlock();
+}
+
+void cWorld::ReSpreadLighting( cChunk* a_Chunk )
+{
+ LockChunks();
+ m_pState->m_SpreadQueue.remove( a_Chunk );
+ m_pState->m_SpreadQueue.push_back( a_Chunk );
+ UnlockChunks();
+}
+
+void cWorld::RemoveSpread( cChunk* a_Chunk )
+{
+ LockChunks();
+ m_pState->m_SpreadQueue.remove( a_Chunk );
+ UnlockChunks();
+}
+
+
+/************************************************************************/
+/* Get and set */
+/************************************************************************/
+void cWorld::AddClient( cClientHandle* a_Client )
+{
+ m_pState->m_Clients.push_back( a_Client );
+}
+cWorld::ClientList & cWorld::GetClients()
+{
+ return m_pState->m_Clients;
+}
+cWorld::EntityList & cWorld::GetEntities()
+{
+ return m_pState->m_AllEntities;
+}
+void cWorld::AddEntity( cEntity* a_Entity )
+{
+ m_pState->m_AllEntities.push_back( a_Entity );
+}
+cWorld::PlayerList & cWorld::GetAllPlayers()
+{
+ return m_pState->m_Players;
+}
+unsigned int cWorld::GetNumPlayers()
+{
+ return m_pState->m_Players.size();
+}
+void cWorld::AddToRemoveEntityQueue( cEntity & a_Entity )
+{
+ m_pState->m_AllEntities.remove( &a_Entity);
+ m_pState->m_RemoveEntityQueue.push_back( &a_Entity );
+} \ No newline at end of file
diff --git a/source/cWorld.h b/source/cWorld.h
new file mode 100644
index 000000000..0b2f8ec85
--- /dev/null
+++ b/source/cWorld.h
@@ -0,0 +1,158 @@
+#pragma once
+
+#ifndef _WIN32
+#include "BlockID.h"
+#else
+enum ENUM_ITEM_ID;
+#endif
+
+#include <list>
+
+class cWaterSimulator;
+class cChunkMap;
+class cItem;
+class cCriticalSection;
+class cPlayer;
+class cClientHandle;
+class cChunk;
+class cEntity;
+class cBlockEntity;
+class cWorld //tolua_export
+{ //tolua_export
+public:
+ typedef std::list< cClientHandle* > ClientList;
+ typedef std::list< cEntity* > EntityList;
+ typedef std::list< cChunk* > ChunkList;
+ typedef std::list< cPlayer* > PlayerList;
+
+ static cWorld* GetWorld(); //tolua_export
+
+ // Return time in seconds
+ inline static float GetTime() //tolua_export
+ {
+ return m_Time;
+ }
+ long long GetWorldTime() { return m_WorldTime; } //tolua_export
+ void SetWorldTime(long long a_WorldTime) { m_WorldTime = a_WorldTime; } //tolua_export
+
+ cChunk* GetChunk( int a_X, int a_Y, int a_Z );
+ cChunk* GetChunkUnreliable( int a_X, int a_Y, int a_Z );
+ cChunk* GetChunkOfBlock( int a_X, int a_Y, int a_Z );
+ char GetHeight( int a_X, int a_Z ); //tolua_export
+
+ void AddClient( cClientHandle* a_Client );
+ void RemoveClient( cClientHandle* a_Client );
+ ClientList & GetClients();
+
+ void AddPlayer( cPlayer* a_Player );
+ void RemovePlayer( cPlayer* a_Player );
+ PlayerList & GetAllPlayers();
+ typedef struct lua_State lua_State;
+ void GetAllPlayers( lua_State* L ); // >> EXPORTED IN MANUALBINDINGS <<
+ unsigned int GetNumPlayers(); //tolua_export
+ cPlayer* GetPlayer( const char* a_PlayerName ); //tolua_export
+
+ void AddEntity( cEntity* a_Entity );
+ void AddToRemoveEntityQueue( cEntity & a_Entity );
+ bool RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom = 0 );
+ EntityList & GetEntities();
+
+ cEntity* GetEntity( int a_UniqueID ); //tolua_export
+
+ void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
+ void FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
+ char GetBlock( int a_X, int a_Y, int a_Z ); //tolua_export
+ char GetBlockMeta( int a_X, int a_Y, int a_Z ); //tolua_export
+ void SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData ); //tolua_export
+ bool DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem ); //tolua_export
+ void SendBlockTo( int a_X, int a_Y, int a_Z, cPlayer* a_Player ); //tolua_export
+
+ const double & GetSpawnX() { return m_SpawnX; } //tolua_export
+ const double & GetSpawnY(); //tolua_export
+ const double & GetSpawnZ() { return m_SpawnZ; } //tolua_export
+
+ cBlockEntity* GetBlockEntity( int a_X, int a_Y, int a_Z ); //tolua_export
+
+ void GrowTree( int a_X, int a_Y, int a_Z ); //tolua_export
+
+ unsigned int GetWorldSeed() { return m_WorldSeed; } //tolua_export
+
+ inline static void AbsoluteToRelative( int & a_X, int & a_Y, int & a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
+ {
+ (void)a_Y; // not unused anymore
+ a_ChunkX = a_X/16;
+ if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
+ a_ChunkY = 0;
+ a_ChunkZ = a_Z/16;
+ if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
+
+ a_X = a_X - a_ChunkX*16;
+ //a_Y = a_Y - a_ChunkY*16;
+ a_Z = a_Z - a_ChunkZ*16;
+ }
+ inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
+ {
+ (void)a_Y; // not unused anymore
+ a_ChunkX = a_X/16;
+ if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
+ a_ChunkY = 0;
+ a_ChunkZ = a_Z/16;
+ if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
+ }
+
+ void SaveAllChunks();
+
+ void Tick(float a_Dt);
+
+ void LockClientHandle();
+ void UnlockClientHandle();
+
+ void LockEntities();
+ void UnlockEntities();
+
+ void LockChunks();
+ void UnlockChunks();
+
+ void ReSpreadLighting( cChunk* a_Chunk );
+ void RemoveSpread( cChunk* a_Chunk );
+
+ void InitializeSpawn();
+private:
+ friend class cRoot;
+ cWorld();
+ ~cWorld();
+
+ struct sWorldState;
+ sWorldState* m_pState;
+
+ void RemoveEntity( cEntity* a_Entity );
+ void UnloadUnusedChunks();
+
+ double m_SpawnX;
+ double m_SpawnY;
+ double m_SpawnZ;
+
+ float m_LastUnload;
+ float m_LastSave;
+ static float m_Time; // Time in seconds
+ long long m_WorldTime; // Time in seconds*20, this is sent to clients (is wrapped)
+ float m_WorldTimeFraction; // When this > 1.f m_WorldTime is incremented by 20
+
+ cWaterSimulator* m_WaterSimulator;
+
+ cCriticalSection* m_ClientHandleCriticalSection;
+ cCriticalSection* m_EntitiesCriticalSection;
+ cCriticalSection* m_ChunksCriticalSection;
+
+
+
+ cChunkMap* m_ChunkMap;
+
+
+
+ bool m_bAnimals;
+ float m_SpawnMonsterTime;
+ float m_SpawnMonsterRate;
+
+ unsigned int m_WorldSeed;
+}; //tolua_export
diff --git a/source/main.cpp b/source/main.cpp
new file mode 100644
index 000000000..393db121e
--- /dev/null
+++ b/source/main.cpp
@@ -0,0 +1,36 @@
+// Mem leak detection
+#include "MemoryLeak.h"
+
+#include "cRoot.h"
+#include "cMCLogger.h"
+
+#ifdef _WIN32
+#include <exception>
+#endif
+
+int main( int argc, char **argv )
+{
+ (void)argc;
+ (void)argv;
+#ifdef _DEBUG
+ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
+
+ try
+ {
+ cRoot Root;
+ Root.Start();
+ }
+ catch( std::exception& e )
+ {
+ LOGERROR("Standard exception: %s", e.what() );
+ }
+ catch( ... )
+ {
+ LOGERROR("Unknown exception!");
+ }
+#ifdef _DEBUG
+ _CrtDumpMemoryLeaks();
+#endif
+ return 0;
+}
diff --git a/source/md5/md5.cpp b/source/md5/md5.cpp
new file mode 100644
index 000000000..21bec8f12
--- /dev/null
+++ b/source/md5/md5.cpp
@@ -0,0 +1,366 @@
+/* MD5
+ converted to C++ class by Frank Thilo (thilo@unix-ag.org)
+ for bzflag (http://www.bzflag.org)
+
+ based on:
+
+ md5.h and md5.c
+ reference implemantion of RFC 1321
+
+ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+
+*/
+
+/* interface header */
+#include "md5.h"
+
+/* system implementation headers */
+#include <stdio.h>
+
+#ifndef _WIN32
+#include <cstring>
+#endif
+
+
+// Constants for MD5Transform routine.
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+///////////////////////////////////////////////
+
+// F, G, H and I are basic MD5 functions.
+inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {
+ return x&y | ~x&z;
+}
+
+inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {
+ return x&z | y&~z;
+}
+
+inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {
+ return x^y^z;
+}
+
+inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {
+ return y ^ (x | ~z);
+}
+
+// rotate_left rotates x left n bits.
+inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {
+ return (x << n) | (x >> (32-n));
+}
+
+// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+// Rotation is separate from addition to prevent recomputation.
+inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;
+}
+
+inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a = rotate_left(a + G(b,c,d) + x + ac, s) + b;
+}
+
+inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a = rotate_left(a + H(b,c,d) + x + ac, s) + b;
+}
+
+inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a = rotate_left(a + I(b,c,d) + x + ac, s) + b;
+}
+
+//////////////////////////////////////////////
+
+// default ctor, just initailize
+MD5::MD5()
+{
+ init();
+}
+
+//////////////////////////////////////////////
+
+// nifty shortcut ctor, compute MD5 for string and finalize it right away
+MD5::MD5(const std::string &text)
+{
+ init();
+ update(text.c_str(), text.length());
+ finalize();
+}
+
+//////////////////////////////
+
+void MD5::init()
+{
+ finalized=false;
+
+ count[0] = 0;
+ count[1] = 0;
+
+ // load magic initialization constants.
+ state[0] = 0x67452301;
+ state[1] = 0xefcdab89;
+ state[2] = 0x98badcfe;
+ state[3] = 0x10325476;
+}
+
+//////////////////////////////
+
+// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
+void MD5::decode(uint4 output[], const uint1 input[], size_type len)
+{
+ for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
+ (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
+}
+
+//////////////////////////////
+
+// encodes input (uint4) into output (unsigned char). Assumes len is
+// a multiple of 4.
+void MD5::encode(uint1 output[], const uint4 input[], size_type len)
+{
+ for (size_type i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = input[i] & 0xff;
+ output[j+1] = (input[i] >> 8) & 0xff;
+ output[j+2] = (input[i] >> 16) & 0xff;
+ output[j+3] = (input[i] >> 24) & 0xff;
+ }
+}
+
+//////////////////////////////
+
+// apply MD5 algo on a block
+void MD5::transform(const uint1 block[blocksize])
+{
+ uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ decode (x, block, blocksize);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ // Zeroize sensitive information.
+ memset(x, 0, sizeof x);
+}
+
+//////////////////////////////
+
+// MD5 block update operation. Continues an MD5 message-digest
+// operation, processing another message block
+void MD5::update(const unsigned char input[], size_type length)
+{
+ // compute number of bytes mod 64
+ size_type index = count[0] / 8 % blocksize;
+
+ // Update number of bits
+ if ((count[0] += (length << 3)) < (length << 3))
+ count[1]++;
+ count[1] += (length >> 29);
+
+ // number of bytes we need to fill in buffer
+ size_type firstpart = 64 - index;
+
+ size_type i;
+
+ // transform as many times as possible.
+ if (length >= firstpart)
+ {
+ // fill buffer first, transform
+ memcpy(&buffer[index], input, firstpart);
+ transform(buffer);
+
+ // transform chunks of blocksize (64 bytes)
+ for (i = firstpart; i + blocksize <= length; i += blocksize)
+ transform(&input[i]);
+
+ index = 0;
+ }
+ else
+ i = 0;
+
+ // buffer remaining input
+ memcpy(&buffer[index], &input[i], length-i);
+}
+
+//////////////////////////////
+
+// for convenience provide a verson with signed char
+void MD5::update(const char input[], size_type length)
+{
+ update((const unsigned char*)input, length);
+}
+
+//////////////////////////////
+
+// MD5 finalization. Ends an MD5 message-digest operation, writing the
+// the message digest and zeroizing the context.
+MD5& MD5::finalize()
+{
+ static unsigned char padding[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+
+ if (!finalized) {
+ // Save number of bits
+ unsigned char bits[8];
+ encode(bits, count, 8);
+
+ // pad out to 56 mod 64.
+ size_type index = count[0] / 8 % 64;
+ size_type padLen = (index < 56) ? (56 - index) : (120 - index);
+ update(padding, padLen);
+
+ // Append length (before padding)
+ update(bits, 8);
+
+ // Store state in digest
+ encode(digest, state, 16);
+
+ // Zeroize sensitive information.
+ memset(buffer, 0, sizeof buffer);
+ memset(count, 0, sizeof count);
+
+ finalized=true;
+ }
+
+ return *this;
+}
+
+//////////////////////////////
+
+// return hex representation of digest as string
+std::string MD5::hexdigest() const
+{
+ if (!finalized)
+ return "";
+
+ char buf[33];
+ for (int i=0; i<16; i++)
+ sprintf(buf+i*2, "%02x", digest[i]);
+ buf[32]=0;
+
+ return std::string(buf);
+}
+
+//////////////////////////////
+
+std::ostream& operator<<(std::ostream& out, MD5 md5)
+{
+ return out << md5.hexdigest();
+}
+
+//////////////////////////////
+
+std::string md5(const std::string & str)
+{
+ MD5 md5 = MD5(str);
+
+ return md5.hexdigest();
+}
diff --git a/source/md5/md5.h b/source/md5/md5.h
new file mode 100644
index 000000000..140ad1f14
--- /dev/null
+++ b/source/md5/md5.h
@@ -0,0 +1,93 @@
+/* MD5
+ converted to C++ class by Frank Thilo (thilo@unix-ag.org)
+ for bzflag (http://www.bzflag.org)
+
+ based on:
+
+ md5.h and md5.c
+ reference implementation of RFC 1321
+
+ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+
+*/
+
+#ifndef BZF_MD5_H
+#define BZF_MD5_H
+
+#include <string>
+#include <iostream>
+
+
+// a small class for calculating MD5 hashes of strings or byte arrays
+// it is not meant to be fast or secure
+//
+// usage: 1) feed it blocks of uchars with update()
+// 2) finalize()
+// 3) get hexdigest() string
+// or
+// MD5(std::string).hexdigest()
+//
+// assumes that char is 8 bit and int is 32 bit
+class MD5
+{
+public:
+ typedef unsigned int size_type; // must be 32bit
+
+ MD5();
+ MD5(const std::string& text);
+ void update(const unsigned char *buf, size_type length);
+ void update(const char *buf, size_type length);
+ MD5& finalize();
+ std::string hexdigest() const;
+ friend std::ostream& operator<<(std::ostream&, MD5 md5);
+
+private:
+ void init();
+ typedef unsigned char uint1; // 8bit
+ typedef unsigned int uint4; // 32bit
+ enum {blocksize = 64}; // VC6 won't eat a const static int here
+
+ void transform(const uint1 block[blocksize]);
+ static void decode(uint4 output[], const uint1 input[], size_type len);
+ static void encode(uint1 output[], const uint4 input[], size_type len);
+
+ bool finalized;
+ uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
+ uint4 count[2]; // 64bit counter for number of bits (lo, hi)
+ uint4 state[4]; // digest so far
+ uint1 digest[16]; // the result
+
+ // low level logic operations
+ static inline uint4 F(uint4 x, uint4 y, uint4 z);
+ static inline uint4 G(uint4 x, uint4 y, uint4 z);
+ static inline uint4 H(uint4 x, uint4 y, uint4 z);
+ static inline uint4 I(uint4 x, uint4 y, uint4 z);
+ static inline uint4 rotate_left(uint4 x, int n);
+ static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+ static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+ static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+ static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+};
+
+std::string md5(const std::string & str);
+
+#endif \ No newline at end of file
diff --git a/source/packets/cPacket.cpp b/source/packets/cPacket.cpp
new file mode 100644
index 000000000..e49c3e016
--- /dev/null
+++ b/source/packets/cPacket.cpp
@@ -0,0 +1,223 @@
+#include "cPacket.h"
+#include "cMCLogger.h"
+#include "Endianness.h"
+
+#ifdef _WIN32
+#define MSG_NOSIGNAL (0)
+#endif
+
+#ifdef __MAC_NA
+#define MSG_NOSIGNAL (0)
+#endif
+
+//*****************************************************************************
+// Blocking receive all function
+//*****************************************************************************
+int cPacket::RecvAll( SOCKET a_Socket, char* a_Data, unsigned int a_Size, int a_Options )
+{
+ unsigned int RequestSize = a_Size;
+ while(a_Size != 0)
+ {
+ int Num = recv(a_Socket, a_Data, a_Size, a_Options);
+ if( cSocket::IsSocketError( Num ) )
+ return Num;
+ a_Size -= Num;
+ a_Data += Num;
+ }
+ return RequestSize - a_Size;
+}
+
+//*****************************************************************************
+// Own implementation of send()
+//*****************************************************************************
+int cPacket::SendData( SOCKET a_Socket, const char* a_Message, unsigned int a_Size, int a_Options )
+{
+ return send(a_Socket, a_Message, a_Size, a_Options | MSG_NOSIGNAL );
+}
+
+
+//*****************************************************************************
+// New packets
+//*****************************************************************************
+
+bool cPacket::ReadString( std::string & a_OutString )
+{
+ short StrLen;
+ if(!ReadShort( StrLen )) return false;
+
+ if( StrLen == 0 )
+ {
+ a_OutString.clear();
+ return true;
+ }
+
+ char* cString = new char[StrLen];
+ if( cSocket::IsSocketError( RecvAll( m_Socket, cString, StrLen, 0 ) ) ) return false;
+
+ a_OutString.assign( cString, StrLen );
+
+ //printf("Discoved string: %s size: %i\n", a_OutString.c_str(), a_OutString.size() );
+ delete [] cString;
+ return true;
+}
+
+bool cPacket::ReadString16( std::string & a_OutString )
+{
+ short StrLen;
+ if(!ReadShort( StrLen )) return false;
+
+ a_OutString.clear();
+ if( StrLen == 0 )
+ {
+ return true;
+ }
+
+ char* UTF16 = new char[StrLen*sizeof( short )];
+ if( cSocket::IsSocketError( RecvAll( m_Socket, UTF16, StrLen * sizeof( short ), 0 ) ) ) return false;
+
+ for( int i = 0; i < StrLen; ++i )
+ a_OutString.push_back( (char)UTF16[i*sizeof( short )+1] );
+
+ //printf("Discoved string: %s size: %i\n", a_OutString.c_str(), a_OutString.size() );
+ delete [] UTF16;
+ return true;
+}
+
+bool cPacket::ReadShort( short & a_OutShort )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutShort, sizeof(short), 0 ) ) ) return false;
+ a_OutShort = ntohs(a_OutShort);
+ return true;
+}
+
+bool cPacket::ReadInteger( int & a_OutInteger )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutInteger, sizeof(int), 0 ) ) ) return false;
+ a_OutInteger = ntohl(a_OutInteger);
+ return true;
+}
+
+bool cPacket::ReadInteger( unsigned int & a_OutInteger )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutInteger, sizeof(unsigned int), 0 ) ) ) return false;
+ a_OutInteger = ntohl(a_OutInteger);
+ return true;
+}
+
+bool cPacket::ReadFloat( float & a_OutFloat )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutFloat, sizeof(float), 0 ) ) ) return false;
+ a_OutFloat = NetworkToHostFloat4( &a_OutFloat );
+ return true;
+}
+
+bool cPacket::ReadDouble( double & a_OutDouble )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutDouble, sizeof(double), 0 ) ) ) return false;
+ a_OutDouble = NetworkToHostDouble8( &a_OutDouble );
+ return true;
+}
+
+bool cPacket::ReadByte( char & a_OutByte )
+{
+ return !cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutByte, sizeof(char), 0 ) );
+}
+
+bool cPacket::ReadByte( unsigned char & a_OutByte )
+{
+ return !cSocket::IsSocketError(RecvAll( m_Socket, (char*)&a_OutByte, sizeof(char), 0 ) );
+}
+
+bool cPacket::ReadLong( long long & a_OutLong )
+{
+ if( cSocket::IsSocketError( RecvAll( m_Socket, (char*)&a_OutLong, sizeof(long long), 0 ) ) ) return false;
+ a_OutLong = NetworkToHostLong8( &a_OutLong );
+ return true;
+}
+
+bool cPacket::ReadBool( bool & a_OutBool )
+{
+ if( cSocket::IsSocketError(RecvAll( m_Socket, (char*)&a_OutBool, sizeof(bool), 0 ) ) ) return false;
+ return true;
+}
+
+//*****************************************************************************
+// Append variables to a c-String
+//*****************************************************************************
+void cPacket::AppendString( std::string & a_String, char* a_Dst, unsigned int & a_Iterator )
+{
+ AppendShort( (unsigned short)a_String.size(), a_Dst, a_Iterator );
+ memcpy( a_Dst + a_Iterator, a_String.c_str(), a_String.size() ); a_Iterator += a_String.size();
+}
+
+void cPacket::AppendString16( std::string & a_String, char* a_Dst, unsigned int & a_Iterator )
+{
+ AppendShort( (unsigned short)a_String.size(), a_Dst, a_Iterator );
+ char* UTF16 = new char[ a_String.size() * sizeof( short ) ];
+ for( unsigned int i = 0; i < a_String.size(); ++i )
+ {
+ UTF16[i*sizeof( short )] = 0x00;//a_String[i];
+ UTF16[i*sizeof( short )+1] = a_String[i];
+ }
+ memcpy( a_Dst + a_Iterator, UTF16, a_String.size() * sizeof( short ) ); a_Iterator += a_String.size() * sizeof( short );
+ delete [] UTF16;
+}
+
+void cPacket::AppendShort( short a_Short, char *a_Dst, unsigned int &a_Iterator )
+{
+ short ConvertedShort = htons( a_Short );
+ memcpy( a_Dst + a_Iterator, &ConvertedShort, sizeof( short ) ); a_Iterator+=sizeof( short );
+}
+
+void cPacket::AppendShort( unsigned short a_Short, char *a_Dst, unsigned int &a_Iterator )
+{
+ short ConvertedShort = htons( a_Short );
+ memcpy( a_Dst + a_Iterator, &ConvertedShort, sizeof( unsigned short ) ); a_Iterator+=sizeof( unsigned short );
+}
+
+
+void cPacket::AppendInteger( int a_Integer, char* a_Dst, unsigned int & a_Iterator )
+{
+ int ConvertedInt = htonl( a_Integer );
+ memcpy( a_Dst + a_Iterator, &ConvertedInt, sizeof( int ) ); a_Iterator+=sizeof( int );
+}
+
+void cPacket::AppendInteger( unsigned int a_Integer, char* a_Dst, unsigned int & a_Iterator )
+{
+ unsigned int ConvertedInt = htonl( a_Integer );
+ memcpy( a_Dst + a_Iterator, &ConvertedInt, sizeof( unsigned int ) ); a_Iterator+=sizeof( unsigned int );
+}
+
+void cPacket::AppendFloat( float a_Float, char* a_Dst, unsigned int & a_Iterator )
+{
+ unsigned int ConvertedFloat = HostToNetwork4(&a_Float);
+ memcpy( a_Dst + a_Iterator, &ConvertedFloat, sizeof(float) ); a_Iterator += sizeof(float);
+}
+
+void cPacket::AppendDouble( double & a_Double, char* a_Dst, unsigned int & a_Iterator )
+{
+ unsigned long long ConvertedDouble = HostToNetwork8(&a_Double);
+ memcpy( a_Dst + a_Iterator, &ConvertedDouble, sizeof(double) ); a_Iterator += sizeof(double);
+}
+
+void cPacket::AppendByte( char a_Byte, char* a_Dst, unsigned int & a_Iterator )
+{
+ a_Dst[a_Iterator] = a_Byte; a_Iterator+=sizeof(char);
+}
+
+void cPacket::AppendLong( long long & a_Long, char* a_Dst, unsigned int & a_Iterator )
+{
+ unsigned long long ConvertedLong = HostToNetwork8(&a_Long);
+ memcpy( a_Dst + a_Iterator, &ConvertedLong, sizeof(long long) );
+ a_Iterator += sizeof( long long );
+}
+
+void cPacket::AppendBool( bool a_Bool, char* a_Dst, unsigned int & a_Iterator )
+{
+ a_Dst[a_Iterator] = (char)a_Bool; a_Iterator+=sizeof(bool);
+}
+
+void cPacket::AppendData( char* a_Data, unsigned int a_Size, char* a_Dst, unsigned int & a_Iterator )
+{
+ memcpy( a_Dst + a_Iterator, a_Data, a_Size ); a_Iterator += a_Size;
+}
diff --git a/source/packets/cPacket.h b/source/packets/cPacket.h
new file mode 100644
index 000000000..3cab5f222
--- /dev/null
+++ b/source/packets/cPacket.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "cSocket.h"
+#ifdef _WIN32
+#include <xstring>
+#else
+#include <cstring> // Silly Linux doesn't have xstring...
+#include <string>
+#include <cstdio>
+#endif
+
+class cSocket;
+class cPacket
+{
+public:
+ cPacket()
+ : m_PacketID( 0 )
+ {}
+ virtual ~cPacket() {}
+
+ virtual bool Parse( cSocket & a_Socket) { a_Socket=0; printf("ERROR: Undefined NEW Parse function %x\n", m_PacketID ); return false; }
+ virtual bool Send( cSocket & a_Socket) { a_Socket=0; printf("ERROR: Undefined NEW Send function %x\n", m_PacketID ); return false; }
+ virtual cPacket* Clone() const = 0;
+
+ unsigned char m_PacketID;
+ cSocket m_Socket; // Current socket being used
+protected:
+ bool ReadString ( std::string & a_OutString );
+ bool ReadString16( std::string & a_OutString );
+ bool ReadShort ( short & a_Short );
+ bool ReadInteger(int & a_OutInteger );
+ bool ReadInteger(unsigned int & a_OutInteger );
+ bool ReadFloat ( float & a_OutFloat );
+ bool ReadDouble ( double & a_OutDouble );
+ bool ReadByte ( char & a_OutByte );
+ bool ReadByte ( unsigned char & a_OutByte );
+ bool ReadLong ( long long & a_OutLong );
+ bool ReadBool ( bool & a_OutBool );
+
+ void AppendString ( std::string & a_String, char* a_Dst, unsigned int & a_Iterator );
+ void AppendString16 ( std::string & a_String, char* a_Dst, unsigned int & a_Iterator );
+ void AppendShort ( short a_Short, char* a_Dst, unsigned int & a_Iterator );
+ void AppendShort ( unsigned short a_Short, char* a_Dst, unsigned int & a_Iterator );
+ void AppendInteger ( int a_Integer, char* a_Dst, unsigned int & a_Iterator );
+ void AppendInteger ( unsigned int a_Integer, char* a_Dst, unsigned int & a_Iterator );
+ void AppendFloat ( float a_Float, char* a_Dst, unsigned int & a_Iterator );
+ void AppendDouble ( double & a_Double, char* a_Dst, unsigned int & a_Iterator );
+ void AppendByte ( char a_Byte, char* a_Dst, unsigned int & a_Iterator );
+ void AppendLong ( long long & a_Long, char* a_Dst, unsigned int & a_Iterator );
+ void AppendBool ( bool a_Bool, char* a_Dst, unsigned int & a_Iterator );
+ void AppendData ( char* a_Data, unsigned int a_Size, char* a_Dst, unsigned int & a_Iterator );
+
+public:
+ static int SendData( SOCKET a_Socket, const char* a_Message, unsigned int a_Size, int a_Options );
+ static int RecvAll( SOCKET a_Socket, char* a_Data, unsigned int a_Size, int a_Options );
+};
diff --git a/source/packets/cPacket_13.cpp b/source/packets/cPacket_13.cpp
new file mode 100644
index 000000000..5e649fbd9
--- /dev/null
+++ b/source/packets/cPacket_13.cpp
@@ -0,0 +1,10 @@
+#include "cPacket_13.h"
+
+bool cPacket_13::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+
+ if( !ReadInteger( m_EntityID ) ) return false;
+ if( !ReadByte ( m_ActionID ) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_13.h b/source/packets/cPacket_13.h
new file mode 100644
index 000000000..ec9aedc3c
--- /dev/null
+++ b/source/packets/cPacket_13.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_13 : public cPacket
+{
+public:
+ enum ENUM_ACTION
+ {
+ ACTION_CROUCH = 1,
+ ACTION_UNCROUCH = 2,
+ ACTION_LEAVEBED = 3,
+ ACTION_STARTSPRINTING = 4,
+ ACTION_STOPSPRINTING = 5,
+ };
+
+ cPacket_13()
+ : m_EntityID( 0 )
+ , m_ActionID( 0 )
+ { m_PacketID = E_PACKET_13; }
+ virtual cPacket* Clone() const { return new cPacket_13( *this ); }
+
+ bool Parse(cSocket & a_Socket);
+
+ int m_EntityID;
+ char m_ActionID;
+
+ static const unsigned int c_Size = 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_AddToInventory.cpp b/source/packets/cPacket_AddToInventory.cpp
new file mode 100644
index 000000000..5d3274229
--- /dev/null
+++ b/source/packets/cPacket_AddToInventory.cpp
@@ -0,0 +1,17 @@
+#include "cPacket_AddToInventory.h"
+
+bool cPacket_AddToInventory::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendShort ( m_ItemType, Message, i );
+ AppendByte ( m_Count, Message, i );
+ AppendShort ( m_Life, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_AddToInventory.h b/source/packets/cPacket_AddToInventory.h
new file mode 100644
index 000000000..8029a53d0
--- /dev/null
+++ b/source/packets/cPacket_AddToInventory.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_AddToInventory : public cPacket
+{
+public:
+ cPacket_AddToInventory()
+ : m_ItemType( 0 )
+ , m_Count( 0 )
+ , m_Life( 0 )
+ { m_PacketID = E_ADD_TO_INV; }
+ virtual cPacket* Clone() const { return new cPacket_AddToInventory(*this); }
+
+ bool Parse( cSocket & a_Socket );
+ bool Send( cSocket & a_Socket );
+
+ short m_ItemType;
+ char m_Count;
+ short m_Life;
+ static const unsigned int c_Size = 1 + 2 + 1 + 2;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_ArmAnim.cpp b/source/packets/cPacket_ArmAnim.cpp
new file mode 100644
index 000000000..f0a662f27
--- /dev/null
+++ b/source/packets/cPacket_ArmAnim.cpp
@@ -0,0 +1,24 @@
+#include "cPacket_ArmAnim.h"
+
+bool cPacket_ArmAnim::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+ if(!ReadInteger(m_EntityID) ) return false;
+ if(!ReadByte(m_Animation) ) return false;
+ return true;
+}
+
+bool cPacket_ArmAnim::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_EntityID, Message, i );
+ AppendByte ( m_Animation, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_ArmAnim.h b/source/packets/cPacket_ArmAnim.h
new file mode 100644
index 000000000..e22d88506
--- /dev/null
+++ b/source/packets/cPacket_ArmAnim.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_ArmAnim : public cPacket
+{
+public:
+ cPacket_ArmAnim()
+ : m_EntityID( 0 )
+ , m_Animation( 0 )
+ { m_PacketID = E_ANIMATION; }
+ virtual cPacket* Clone() const { return new cPacket_ArmAnim(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ int m_EntityID;
+ char m_Animation;
+ static const unsigned int c_Size = 1 + 4 + 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_BlockChange.cpp b/source/packets/cPacket_BlockChange.cpp
new file mode 100644
index 000000000..44b389a14
--- /dev/null
+++ b/source/packets/cPacket_BlockChange.cpp
@@ -0,0 +1,19 @@
+#include "cPacket_BlockChange.h"
+
+bool cPacket_BlockChange::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendByte ( m_PosY, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendByte ( m_BlockType, Message, i );
+ AppendByte ( m_BlockMeta, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_BlockChange.h b/source/packets/cPacket_BlockChange.h
new file mode 100644
index 000000000..0cd6cfb6f
--- /dev/null
+++ b/source/packets/cPacket_BlockChange.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_BlockChange : public cPacket
+{
+public:
+ cPacket_BlockChange()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_BlockType( 0 )
+ , m_BlockMeta( 0 )
+ { m_PacketID = E_BLOCK_CHANGE; }
+ virtual cPacket* Clone() const { return new cPacket_BlockChange(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_PosX;
+ char m_PosY;
+ int m_PosZ;
+ char m_BlockType;
+ char m_BlockMeta;
+ static const unsigned int c_Size = 1 + 4 + 1 + 4 + 1 + 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_BlockDig.cpp b/source/packets/cPacket_BlockDig.cpp
new file mode 100644
index 000000000..c6092f9cd
--- /dev/null
+++ b/source/packets/cPacket_BlockDig.cpp
@@ -0,0 +1,29 @@
+#include "cPacket_BlockDig.h"
+
+bool cPacket_BlockDig::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendByte ( m_PosY, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendByte ( m_Direction, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
+
+bool cPacket_BlockDig::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadByte ( m_Status ) ) return false;
+ if( !ReadInteger( m_PosX ) ) return false;
+ if( !ReadByte ( m_PosY ) ) return false;
+ if( !ReadInteger( m_PosZ ) ) return false;
+ if( !ReadByte ( m_Direction ) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_BlockDig.h b/source/packets/cPacket_BlockDig.h
new file mode 100644
index 000000000..7ea847aa1
--- /dev/null
+++ b/source/packets/cPacket_BlockDig.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_BlockDig : public cPacket //tolua_export
+{ //tolua_export
+public:
+ cPacket_BlockDig() //tolua_export
+ : m_Status( 0 )
+ , m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Direction( 0 )
+ { m_PacketID = E_BLOCK_DIG; } //tolua_export
+ virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } //tolua_export
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ char m_Status; //tolua_export
+ int m_PosX; //tolua_export
+ char m_PosY; //tolua_export
+ int m_PosZ; //tolua_export
+ char m_Direction; //tolua_export
+ static const unsigned int c_Size = 12;
+}; //tolua_export \ No newline at end of file
diff --git a/source/packets/cPacket_BlockPlace.cpp b/source/packets/cPacket_BlockPlace.cpp
new file mode 100644
index 000000000..08bc1c40c
--- /dev/null
+++ b/source/packets/cPacket_BlockPlace.cpp
@@ -0,0 +1,18 @@
+#include "cPacket_BlockPlace.h"
+
+bool cPacket_BlockPlace::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadInteger( m_PosX ) ) return false;
+ if( !ReadByte ( m_PosY ) ) return false;
+ if( !ReadInteger( m_PosZ ) ) return false;
+ if( !ReadByte ( m_Direction ) ) return false;
+
+ if( !ReadShort ( m_ItemType ) ) return false;
+ if( m_ItemType > -1 )
+ {
+ if( !ReadByte ( m_Count ) ) return false;
+ if( !ReadShort ( m_Uses ) ) return false;
+ }
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_BlockPlace.h b/source/packets/cPacket_BlockPlace.h
new file mode 100644
index 000000000..c7f72bacf
--- /dev/null
+++ b/source/packets/cPacket_BlockPlace.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_BlockPlace : public cPacket //tolua_export
+{ //tolua_export
+public:
+ cPacket_BlockPlace()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Direction( 0 )
+ , m_ItemType( 0 )
+ , m_Count( 0 )
+ , m_Uses( 0 )
+ { m_PacketID = E_BLOCK_PLACE; }
+ virtual cPacket* Clone() const { return new cPacket_BlockPlace(*this); }
+
+ bool Parse(cSocket & a_Socket);
+
+ int m_PosX; //tolua_export
+ char m_PosY; //tolua_export
+ int m_PosZ; //tolua_export
+ char m_Direction; //tolua_export
+
+ short m_ItemType; //tolua_export
+ char m_Count; //tolua_export
+ short m_Uses; //tolua_export
+
+ static const unsigned int c_Size = 1 + 4 + 1 + 4 + 1 + 2;// ( + 2 )
+}; //tolua_export \ No newline at end of file
diff --git a/source/packets/cPacket_Chat.cpp b/source/packets/cPacket_Chat.cpp
new file mode 100644
index 000000000..d948c5deb
--- /dev/null
+++ b/source/packets/cPacket_Chat.cpp
@@ -0,0 +1,23 @@
+#include "cPacket_Chat.h"
+
+
+bool cPacket_Chat::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+ if( !ReadString16( m_Message ) ) return false;
+ return true;
+}
+
+bool cPacket_Chat::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size + m_Message.size() * sizeof( short );
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendString16 ( m_Message, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_Chat.h b/source/packets/cPacket_Chat.h
new file mode 100644
index 000000000..0de5c9343
--- /dev/null
+++ b/source/packets/cPacket_Chat.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Chat : public cPacket
+{
+public:
+ cPacket_Chat() { m_PacketID = E_CHAT; }
+ cPacket_Chat( const std::string & a_Message ) : m_Message( a_Message) { m_PacketID = E_CHAT; }
+ virtual cPacket* Clone() const { return new cPacket_Chat(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ std::string m_Message;
+ static const unsigned int c_Size = 3; // Minimum size
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_CollectItem.cpp b/source/packets/cPacket_CollectItem.cpp
new file mode 100644
index 000000000..0ad92ddad
--- /dev/null
+++ b/source/packets/cPacket_CollectItem.cpp
@@ -0,0 +1,16 @@
+#include "cPacket_CollectItem.h"
+
+bool cPacket_CollectItem::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_CollectedID, Message, i );
+ AppendInteger( m_CollectorID, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_CollectItem.h b/source/packets/cPacket_CollectItem.h
new file mode 100644
index 000000000..5f11500b5
--- /dev/null
+++ b/source/packets/cPacket_CollectItem.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_CollectItem : public cPacket
+{
+public:
+ cPacket_CollectItem()
+ : m_CollectedID( 0 )
+ , m_CollectorID( 0 )
+ { m_PacketID = E_COLLECT_ITEM; }
+ virtual cPacket* Clone() const { return new cPacket_CollectItem(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_CollectedID;
+ int m_CollectorID;
+ static const unsigned int c_Size = 1 + 4 + 4;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_DestroyEntity.cpp b/source/packets/cPacket_DestroyEntity.cpp
new file mode 100644
index 000000000..e0ee22c76
--- /dev/null
+++ b/source/packets/cPacket_DestroyEntity.cpp
@@ -0,0 +1,23 @@
+#include "cPacket_DestroyEntity.h"
+#include "cEntity.h"
+
+cPacket_DestroyEntity::cPacket_DestroyEntity(cEntity* a_Entity)
+{
+ m_PacketID = E_DESTROY_ENT;
+
+ m_UniqueID = a_Entity->GetUniqueID();
+}
+
+bool cPacket_DestroyEntity::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_DestroyEntity.h b/source/packets/cPacket_DestroyEntity.h
new file mode 100644
index 000000000..0b852e727
--- /dev/null
+++ b/source/packets/cPacket_DestroyEntity.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cEntity;
+class cPacket_DestroyEntity : public cPacket
+{
+public:
+ cPacket_DestroyEntity()
+ : m_UniqueID( 0 )
+ { m_PacketID = E_DESTROY_ENT; }
+ cPacket_DestroyEntity(cEntity* a_Entity);
+ virtual cPacket* Clone() const { return new cPacket_DestroyEntity(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ static const unsigned int c_Size = 1 + 4;
+};
diff --git a/source/packets/cPacket_Disconnect.cpp b/source/packets/cPacket_Disconnect.cpp
new file mode 100644
index 000000000..c2a0e3be6
--- /dev/null
+++ b/source/packets/cPacket_Disconnect.cpp
@@ -0,0 +1,22 @@
+#include "cPacket_Disconnect.h"
+
+bool cPacket_Disconnect::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+ if( !ReadString16(m_Reason) ) return false;
+ return true;
+}
+
+bool cPacket_Disconnect::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size + m_Reason.size()*sizeof(short);
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendString16 ( m_Reason, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_Disconnect.h b/source/packets/cPacket_Disconnect.h
new file mode 100644
index 000000000..0711851f4
--- /dev/null
+++ b/source/packets/cPacket_Disconnect.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Disconnect : public cPacket
+{
+public:
+ cPacket_Disconnect() { m_PacketID = E_DISCONNECT; }
+ cPacket_Disconnect(const std::string & a_Reason) { m_PacketID = E_DISCONNECT; m_Reason = a_Reason; }
+ virtual cPacket* Clone() const { return new cPacket_Disconnect(*this); }
+
+ bool Parse( cSocket & a_Socket );
+ bool Send( cSocket & a_Socket );
+
+ std::string m_Reason;
+ static const unsigned int c_Size = 3; // Minimum size
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_EntityEquipment.cpp b/source/packets/cPacket_EntityEquipment.cpp
new file mode 100644
index 000000000..afd2e7678
--- /dev/null
+++ b/source/packets/cPacket_EntityEquipment.cpp
@@ -0,0 +1,42 @@
+#include "cPacket_EntityEquipment.h"
+
+cPacket_EntityEquipment::cPacket_EntityEquipment( const cPacket_EntityEquipment & a_Copy )
+{
+ m_PacketID = E_ENTITY_EQUIPMENT;
+ m_UniqueID = a_Copy.m_UniqueID;
+ m_Slot = a_Copy.m_Slot;
+ m_ItemID = a_Copy.m_ItemID;
+ m_Short = 0;
+}
+
+bool cPacket_EntityEquipment::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadInteger( m_UniqueID ) ) return false;
+ if( !ReadShort ( m_Slot ) ) return false;
+ if( !ReadShort ( m_ItemID ) ) return false;
+ if( !ReadShort ( m_Short ) ) return false;
+ return true;
+}
+
+bool cPacket_EntityEquipment::Send(cSocket & a_Socket)
+{
+ //LOG("InventoryChange:");
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ if( m_ItemID <= 0 ) m_ItemID = -1; // Fix, to make sure no invalid values are sent.
+ // WARNING: HERE ITS -1, BUT IN NAMED ENTITY SPAWN PACKET ITS 0 !!
+ //LOG("cPacket_EntityEquipment: Sending equipped item ID: %i", m_ItemID );
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendShort ( m_Slot, Message, i );
+ AppendShort ( m_ItemID, Message, i );
+ AppendShort ( m_Short, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_EntityEquipment.h b/source/packets/cPacket_EntityEquipment.h
new file mode 100644
index 000000000..253786140
--- /dev/null
+++ b/source/packets/cPacket_EntityEquipment.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_EntityEquipment : public cPacket
+{
+public:
+ cPacket_EntityEquipment()
+ : m_UniqueID( 0 )
+ , m_Slot( 0 )
+ , m_ItemID( 0 )
+ , m_Short( 0 )
+ { m_PacketID = E_ENTITY_EQUIPMENT; m_Short = 0; }
+ cPacket_EntityEquipment( const cPacket_EntityEquipment & a_Copy );
+ virtual cPacket* Clone() const { return new cPacket_EntityEquipment(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ int m_UniqueID;
+ short m_Slot; // 0 = hold 1-4 = armor
+ short m_ItemID;
+ short m_Short;
+
+ static const unsigned int c_Size = 1 + 4 + 2 + 2 + 2;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_EntityLook.cpp b/source/packets/cPacket_EntityLook.cpp
new file mode 100644
index 000000000..7dcbf61c2
--- /dev/null
+++ b/source/packets/cPacket_EntityLook.cpp
@@ -0,0 +1,28 @@
+#include "cPacket_EntityLook.h"
+
+#include "cEntity.h"
+
+cPacket_EntityLook::cPacket_EntityLook(cEntity* a_Entity)
+{
+ m_PacketID = E_ENT_LOOK;
+
+ m_UniqueID = a_Entity->GetUniqueID();
+ m_Rotation = (char)((a_Entity->GetRotation()/360.f)*256);
+ m_Pitch = (char)((a_Entity->GetPitch()/360.f)*256);
+}
+
+bool cPacket_EntityLook::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendByte ( m_Rotation, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_EntityLook.h b/source/packets/cPacket_EntityLook.h
new file mode 100644
index 000000000..215620f07
--- /dev/null
+++ b/source/packets/cPacket_EntityLook.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cEntity;
+class cPacket_EntityLook : public cPacket
+{
+public:
+ cPacket_EntityLook()
+ : m_UniqueID( 0 )
+ , m_Rotation( 0 )
+ , m_Pitch( 0 )
+ { m_PacketID = E_ENT_LOOK; }
+ cPacket_EntityLook(cEntity* a_Entity);
+ virtual cPacket* Clone() const { return new cPacket_EntityLook(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ char m_Rotation;
+ char m_Pitch;
+
+ static const unsigned int c_Size = 1 + 4 + 1 + 1;
+};
diff --git a/source/packets/cPacket_EntityStatus.cpp b/source/packets/cPacket_EntityStatus.cpp
new file mode 100644
index 000000000..41d94b6c2
--- /dev/null
+++ b/source/packets/cPacket_EntityStatus.cpp
@@ -0,0 +1,17 @@
+#include "cPacket_EntityStatus.h"
+
+bool cPacket_EntityStatus::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_UniqueID, Message, i );
+ AppendByte ( m_Status, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_EntityStatus.h b/source/packets/cPacket_EntityStatus.h
new file mode 100644
index 000000000..2511e2935
--- /dev/null
+++ b/source/packets/cPacket_EntityStatus.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_EntityStatus : public cPacket
+{
+public:
+ cPacket_EntityStatus()
+ : m_UniqueID( 0 )
+ , m_Status( 0 )
+ { m_PacketID = E_ENT_STATUS; }
+ virtual cPacket* Clone() const { return new cPacket_EntityStatus( *this ); }
+
+ bool Send(cSocket & a_Socket);
+
+ static const char STATUS_TAKEDAMAGE = 2;
+ static const char STATUS_DIE = 3;
+
+ int m_UniqueID;
+ char m_Status;
+
+ static const unsigned int c_Size = 1 + 4 + 1;
+};
diff --git a/source/packets/cPacket_Flying.cpp b/source/packets/cPacket_Flying.cpp
new file mode 100644
index 000000000..b8cab1de1
--- /dev/null
+++ b/source/packets/cPacket_Flying.cpp
@@ -0,0 +1,8 @@
+#include "cPacket_Flying.h"
+
+bool cPacket_Flying::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadBool( m_bFlying ) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_Flying.h b/source/packets/cPacket_Flying.h
new file mode 100644
index 000000000..7e30ebd73
--- /dev/null
+++ b/source/packets/cPacket_Flying.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Flying : public cPacket
+{
+public:
+ // The BS packet
+ cPacket_Flying()
+ : m_bFlying( false )
+ { m_PacketID = E_FLYING; }
+ virtual cPacket* Clone() const { return new cPacket_Flying(*this); }
+
+ bool Parse(cSocket & a_Socket);
+
+ bool m_bFlying;
+ static const unsigned int c_Size = 2;
+};
diff --git a/source/packets/cPacket_Handshake.cpp b/source/packets/cPacket_Handshake.cpp
new file mode 100644
index 000000000..2513ab33d
--- /dev/null
+++ b/source/packets/cPacket_Handshake.cpp
@@ -0,0 +1,24 @@
+#include "cPacket_Handshake.h"
+
+bool cPacket_Handshake::Parse(cSocket & a_Socket)
+{
+ //printf("Parse: NEW Handshake\n");
+ m_Socket = a_Socket;
+ if( !ReadString16( m_Username ) ) return false;
+ return true;
+}
+
+bool cPacket_Handshake::Send(cSocket & a_Socket)
+{
+ //LOG("Send: NEW Handshake %s", m_Username.c_str() );
+ unsigned int TotalSize = c_Size + m_Username.size() * sizeof(short);
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendString16( m_Username, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( cPacket::SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_Handshake.h b/source/packets/cPacket_Handshake.h
new file mode 100644
index 000000000..b14d829f4
--- /dev/null
+++ b/source/packets/cPacket_Handshake.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Handshake : public cPacket
+{
+public:
+ cPacket_Handshake() { m_PacketID = E_HANDSHAKE; }
+ virtual cPacket* Clone() const { return new cPacket_Handshake(*this); }
+
+ virtual bool Parse(cSocket & a_Socket);
+ virtual bool Send(cSocket & a_Socket);
+
+ std::string m_Username;
+ static const unsigned int c_Size = 3; // Minimal size
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_InventoryProgressBar.cpp b/source/packets/cPacket_InventoryProgressBar.cpp
new file mode 100644
index 000000000..c8d7b0383
--- /dev/null
+++ b/source/packets/cPacket_InventoryProgressBar.cpp
@@ -0,0 +1,18 @@
+#include "cPacket_InventoryProgressBar.h"
+
+bool cPacket_InventoryProgressBar::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_WindowID, Message, i );
+ AppendShort ( m_ProgressBar, Message, i );
+ AppendShort ( m_Value, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_InventoryProgressBar.h b/source/packets/cPacket_InventoryProgressBar.h
new file mode 100644
index 000000000..c9b5e196e
--- /dev/null
+++ b/source/packets/cPacket_InventoryProgressBar.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_InventoryProgressBar : public cPacket
+{
+public:
+ cPacket_InventoryProgressBar()
+ : m_WindowID( 0 )
+ , m_ProgressBar( 0 )
+ , m_Value( 0 )
+ { m_PacketID = E_INVENTORY_PROGRESS; }
+ virtual cPacket* Clone() const { return new cPacket_InventoryProgressBar(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ char m_WindowID;
+ short m_ProgressBar;
+ short m_Value;
+
+ static const unsigned int c_Size = 1 + 1 + 2 + 2;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_InventorySlot.cpp b/source/packets/cPacket_InventorySlot.cpp
new file mode 100644
index 000000000..13b41b7b1
--- /dev/null
+++ b/source/packets/cPacket_InventorySlot.cpp
@@ -0,0 +1,23 @@
+#include "cPacket_InventorySlot.h"
+
+bool cPacket_InventorySlot::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ if( m_ItemID > -1 ) TotalSize += 1 + 2;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_WindowID, Message, i );
+ AppendShort ( m_SlotNum, Message, i );
+ AppendShort ( m_ItemID, Message, i );
+ if( m_ItemID > -1 )
+ {
+ AppendByte ( m_ItemCount, Message, i );
+ AppendShort ( m_ItemUses, Message, i );
+ }
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_InventorySlot.h b/source/packets/cPacket_InventorySlot.h
new file mode 100644
index 000000000..95711c98d
--- /dev/null
+++ b/source/packets/cPacket_InventorySlot.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_InventorySlot : public cPacket // Set item [S -> C] ?
+{
+public:
+ cPacket_InventorySlot()
+ : m_WindowID( 0 )
+ , m_SlotNum( 0 )
+ , m_ItemID( 0 )
+ , m_ItemCount( 0 )
+ , m_ItemUses( 0 )
+ { m_PacketID = E_INVENTORY_SLOT; }
+ virtual cPacket* Clone() const { return new cPacket_InventorySlot(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ char m_WindowID;
+ short m_SlotNum; // Slot
+ // 0 = craft result
+ // 1-4 = crafting table
+ // 5-8 = armor
+ // 9-35 = inventory
+ // 36-44 = Hot bar
+
+ // Below = item
+ short m_ItemID; // if this is -1 the next stuff dont exist
+ char m_ItemCount;
+ short m_ItemUses;
+
+ static const unsigned int c_Size = 1 + 1 + 2 + 2; // Minimal size ( +1+1 = max)
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_ItemSwitch.cpp b/source/packets/cPacket_ItemSwitch.cpp
new file mode 100644
index 000000000..39c61833e
--- /dev/null
+++ b/source/packets/cPacket_ItemSwitch.cpp
@@ -0,0 +1,23 @@
+#include "cPacket_ItemSwitch.h"
+
+bool cPacket_ItemSwitch::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+
+ if( !ReadShort ( m_SlotNum ) ) return false;
+ return true;
+}
+
+bool cPacket_ItemSwitch::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendShort ( m_SlotNum, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_ItemSwitch.h b/source/packets/cPacket_ItemSwitch.h
new file mode 100644
index 000000000..8fee397c7
--- /dev/null
+++ b/source/packets/cPacket_ItemSwitch.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_ItemSwitch : public cPacket
+{
+public:
+ cPacket_ItemSwitch()
+ : m_SlotNum( 0 )
+ { m_PacketID = E_ITEM_SWITCH; }
+ virtual cPacket* Clone() const { return new cPacket_ItemSwitch(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ short m_SlotNum;
+ static const unsigned int c_Size = 1 + 2;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_KeepAlive.cpp b/source/packets/cPacket_KeepAlive.cpp
new file mode 100644
index 000000000..8dcd9092f
--- /dev/null
+++ b/source/packets/cPacket_KeepAlive.cpp
@@ -0,0 +1,22 @@
+#include "cPacket_KeepAlive.h"
+
+bool cPacket_KeepAlive::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_KeepAliveID, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
+
+bool cPacket_KeepAlive::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadInteger( m_KeepAliveID ) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_KeepAlive.h b/source/packets/cPacket_KeepAlive.h
new file mode 100644
index 000000000..833947bfb
--- /dev/null
+++ b/source/packets/cPacket_KeepAlive.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_KeepAlive : public cPacket
+{
+public:
+ cPacket_KeepAlive() { m_PacketID = E_KEEP_ALIVE; }
+ virtual cPacket* Clone() const { return new cPacket_KeepAlive(*this); }
+
+ virtual bool Parse(cSocket & a_Socket);
+ virtual bool Send(cSocket & a_Socket);
+
+ int m_KeepAliveID;
+
+ static const unsigned int c_Size = 1 + 4;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp
new file mode 100644
index 000000000..f0a9aaf30
--- /dev/null
+++ b/source/packets/cPacket_Login.cpp
@@ -0,0 +1,41 @@
+#include "cPacket_Login.h"
+
+bool cPacket_Login::Parse( cSocket & a_Socket )
+{
+ //printf("Parse: NEW Login\n");
+ m_Socket = a_Socket;
+
+ m_Username.clear();
+
+ if( !ReadInteger( m_ProtocolVersion ) ) return false;
+ if( !ReadString16( m_Username ) ) return false;
+ if( !ReadLong ( m_MapSeed ) ) return false;
+ if( !ReadInteger( m_ServerMode ) ) return false;
+ if( !ReadByte ( m_Dimension ) ) return false;
+ if( !ReadByte ( m_Difficulty ) ) return false;
+ if( !ReadByte ( m_WorldHeight ) ) return false;
+ if( !ReadByte ( m_MaxPlayers ) ) return false;
+ return true;
+}
+
+bool cPacket_Login::Send( cSocket & a_Socket )
+{
+ //printf("Send: NEW Login\n");
+ unsigned int TotalSize = c_Size + m_Username.size() * sizeof(short);
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_ProtocolVersion, Message, i );
+ AppendString16 ( m_Username, Message, i );
+ AppendLong ( m_MapSeed, Message, i );
+ AppendInteger( m_ServerMode, Message, i );
+ AppendByte ( m_Dimension, Message, i );
+ AppendByte ( m_Difficulty, Message, i );
+ AppendByte ( m_WorldHeight, Message, i );
+ AppendByte ( m_MaxPlayers, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( cPacket::SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h
new file mode 100644
index 000000000..91919a799
--- /dev/null
+++ b/source/packets/cPacket_Login.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "cPacket.h"
+#include <string>
+#include "PacketID.h"
+
+class cPacket_Login : public cPacket //tolua_export
+{ //tolua_export
+public:
+ cPacket_Login()
+ : m_ProtocolVersion( 0 )
+ , m_MapSeed( 0 )
+ , m_ServerMode( 0 )
+ , m_Dimension( 0 )
+ , m_Difficulty( 0 )
+ , m_WorldHeight( 0 )
+ , m_MaxPlayers( 0 )
+ { m_PacketID = E_LOGIN; }
+ virtual cPacket* Clone() const { return new cPacket_Login(*this); }
+
+ virtual bool Parse(cSocket & a_Socket);
+ virtual bool Send(cSocket & a_Socket);
+
+ int m_ProtocolVersion; //tolua_export
+ std::string m_Username; //tolua_export
+ long long m_MapSeed; //tolua_export
+ int m_ServerMode; //tolua_export
+ char m_Dimension; //tolua_export
+ char m_Difficulty; //tolua_export
+ unsigned char m_WorldHeight; //tolua_export
+ unsigned char m_MaxPlayers; //tolua_export
+ static const unsigned int c_Size = 1 + 4 + 2 + 8 + 4 + 1 + 1 + 1 + 1; // Minimal size
+}; //tolua_export
diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp
new file mode 100644
index 000000000..08681494c
--- /dev/null
+++ b/source/packets/cPacket_MapChunk.cpp
@@ -0,0 +1,69 @@
+#include "cPacket_MapChunk.h"
+#include "../cChunk.h"
+
+#include "zlib.h"
+
+cPacket_MapChunk::~cPacket_MapChunk()
+{
+ if( m_CompressedData )
+ {
+ delete [] m_CompressedData;
+ }
+}
+
+cPacket_MapChunk::cPacket_MapChunk(cChunk* a_Chunk)
+{
+ m_PacketID = E_MAP_CHUNK;
+
+ m_PosX = a_Chunk->GetPosX() * 16; // It has to be block coordinates
+ m_PosY = (short)(a_Chunk->GetPosY() * 128);
+ m_PosZ = a_Chunk->GetPosZ() * 16;
+
+ m_SizeX = 15;
+ m_SizeY = 127;
+ m_SizeZ = 15;
+
+ uLongf CompressedSize = compressBound( cChunk::c_BlockDataSize );
+ char* CompressedBlockData = new char[CompressedSize];
+
+ compress2( (Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)a_Chunk->pGetBlockData(), cChunk::c_BlockDataSize, Z_DEFAULT_COMPRESSION);
+
+ m_CompressedData = CompressedBlockData;
+ m_CompressedSize = CompressedSize;
+}
+
+cPacket_MapChunk::cPacket_MapChunk( const cPacket_MapChunk & a_Copy )
+{
+ m_PacketID = E_MAP_CHUNK;
+ m_PosX = a_Copy.m_PosX;
+ m_PosY = a_Copy.m_PosY;
+ m_PosZ = a_Copy.m_PosZ;
+ m_SizeX = a_Copy.m_SizeX;
+ m_SizeY = a_Copy.m_SizeY;
+ m_SizeZ = a_Copy.m_SizeZ;
+
+ m_CompressedSize = a_Copy.m_CompressedSize;
+ m_CompressedData = new char[m_CompressedSize];
+ memcpy( m_CompressedData, a_Copy.m_CompressedData, m_CompressedSize );
+}
+
+bool cPacket_MapChunk::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size + m_CompressedSize;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_PosX, Message, i );
+ AppendShort ( m_PosY, Message, i );
+ AppendInteger ( m_PosZ, Message, i );
+ AppendByte ( m_SizeX, Message, i );
+ AppendByte ( m_SizeY, Message, i );
+ AppendByte ( m_SizeZ, Message, i );
+ AppendInteger ( m_CompressedSize, Message, i );
+ AppendData ( m_CompressedData, m_CompressedSize, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_MapChunk.h b/source/packets/cPacket_MapChunk.h
new file mode 100644
index 000000000..48e2cbf1f
--- /dev/null
+++ b/source/packets/cPacket_MapChunk.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cChunk;
+class cPacket_MapChunk : public cPacket
+{
+public:
+ cPacket_MapChunk()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_SizeX( 0 )
+ , m_SizeY( 0 )
+ , m_SizeZ( 0 )
+ , m_CompressedSize( 0 )
+ , m_CompressedData( 0 )
+ { m_PacketID = E_MAP_CHUNK; m_CompressedData = 0; }
+ cPacket_MapChunk(cChunk* a_Chunk);
+ cPacket_MapChunk( const cPacket_MapChunk & a_Copy );
+ ~cPacket_MapChunk();
+ virtual cPacket* Clone() const { return new cPacket_MapChunk(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_PosX; // In block coordinates
+ short m_PosY;
+ int m_PosZ;
+ char m_SizeX; // Is actually size-1 (when size is 128, this is 127)
+ char m_SizeY;
+ char m_SizeZ;
+ int m_CompressedSize;
+ static const unsigned int c_Size = 1 + 4 + 2 + 4 + 1 + 1 + 1 + 4;
+
+ char* m_CompressedData;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_Metadata.cpp b/source/packets/cPacket_Metadata.cpp
new file mode 100644
index 000000000..3d3df3b9c
--- /dev/null
+++ b/source/packets/cPacket_Metadata.cpp
@@ -0,0 +1,65 @@
+#include "cPacket_Metadata.h"
+
+cPacket_Metadata::cPacket_Metadata(int s, int id)
+ : EMetaState( (MetaState)s )
+ , m_UniqueID( id )
+ , m_Type( 0 )
+ , m_MetaData( 0 )
+{
+ m_PacketID = E_METADATA;
+ FormPacket();
+}
+
+cPacket_Metadata::cPacket_Metadata()
+ : EMetaState(NORMAL)
+ , m_UniqueID( 0 )
+ , m_Type( 0 )
+ , m_MetaData( 0 )
+{
+ m_PacketID = E_METADATA;
+ FormPacket();
+}
+
+cPacket_Metadata::~cPacket_Metadata() {
+ //if( m_MetaData ) delete [] m_MetaData;
+}
+
+void cPacket_Metadata::FormPacket() {
+ if( m_MetaData ) delete [] m_MetaData;
+ m_MetaData = new char[3];
+ m_MetaDataSize = 3;
+ //m_UniqueID = GetUniqueID();
+ m_MetaData[0] = 0x00;
+ //m_MetaData[1] = 0x01; //Burning
+ m_MetaData[2] = 0x7f;
+ switch(EMetaState) {
+ case NORMAL:
+ m_MetaData[1] = 0x00;
+ break;
+ case BURNING:
+ m_MetaData[1] = 0x01;
+ break;
+ case CROUCHED:
+ m_MetaData[1] = 0x02;
+ break;
+ case RIDING:
+ m_MetaData[1] = 0x04;
+ break;
+ default:
+ m_MetaData[1] = 0x00;
+ break;
+ }
+}
+
+bool cPacket_Metadata::Send(cSocket & a_Socket) {
+ unsigned int TotalSize = c_Size + m_MetaDataSize;
+ char* Message = new char[TotalSize];
+ unsigned int i = 0;
+
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_UniqueID, Message, i );
+ AppendData ( m_MetaData, m_MetaDataSize, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ return RetVal;
+}
diff --git a/source/packets/cPacket_Metadata.h b/source/packets/cPacket_Metadata.h
new file mode 100644
index 000000000..f96178a2c
--- /dev/null
+++ b/source/packets/cPacket_Metadata.h
@@ -0,0 +1,23 @@
+#pragma once
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Metadata : public cPacket
+{
+public:
+ cPacket_Metadata(int s, int id);
+ cPacket_Metadata();
+ ~cPacket_Metadata();
+
+ bool Send(cSocket & a_Socket);
+ void FormPacket();
+ virtual cPacket* Clone() const { return new cPacket_Metadata( *this ); }
+
+ enum MetaState{NORMAL,BURNING,CROUCHED,RIDING} EMetaState;
+
+ static const unsigned int c_Size = 4 + 1;
+ int m_UniqueID;
+ char m_Type;
+ unsigned int m_MetaDataSize;
+ char* m_MetaData;
+};
diff --git a/source/packets/cPacket_MultiBlock.cpp b/source/packets/cPacket_MultiBlock.cpp
new file mode 100644
index 000000000..ef396874f
--- /dev/null
+++ b/source/packets/cPacket_MultiBlock.cpp
@@ -0,0 +1,42 @@
+#include "cPacket_MultiBlock.h"
+
+cPacket_MultiBlock::cPacket_MultiBlock( const cPacket_MultiBlock & a_Copy )
+{
+ m_PacketID = E_MULTI_BLOCK;
+ m_ChunkX = a_Copy.m_ChunkX;
+ m_ChunkZ = a_Copy.m_ChunkZ;
+ m_NumBlocks = a_Copy.m_NumBlocks;
+ m_BlockCoordinates = new unsigned short[m_NumBlocks];
+ memcpy( m_BlockCoordinates, a_Copy.m_BlockCoordinates, sizeof(short)*m_NumBlocks );
+ m_BlockTypes = new char[m_NumBlocks];
+ memcpy( m_BlockTypes, a_Copy.m_BlockTypes, m_NumBlocks );
+ m_BlockMetas = new char[m_NumBlocks];
+ memcpy( m_BlockMetas, a_Copy.m_BlockMetas, m_NumBlocks );
+}
+
+cPacket_MultiBlock::~cPacket_MultiBlock()
+{
+ if( m_BlockCoordinates ) delete [] m_BlockCoordinates;
+ if( m_BlockTypes ) delete [] m_BlockTypes;
+ if( m_BlockMetas ) delete [] m_BlockMetas;
+}
+
+bool cPacket_MultiBlock::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size + m_NumBlocks * ( sizeof(short) + 2*sizeof(char) );
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_ChunkX, Message, i );
+ AppendInteger ( m_ChunkZ, Message, i );
+ AppendShort ( m_NumBlocks, Message, i );
+
+ AppendData ( (char*)m_BlockCoordinates,sizeof(short)*m_NumBlocks, Message, i );
+ AppendData ( m_BlockTypes, sizeof(char)*m_NumBlocks, Message, i );
+ AppendData ( m_BlockMetas, sizeof(char)*m_NumBlocks, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_MultiBlock.h b/source/packets/cPacket_MultiBlock.h
new file mode 100644
index 000000000..fb5e50d93
--- /dev/null
+++ b/source/packets/cPacket_MultiBlock.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_MultiBlock : public cPacket
+{
+public:
+ cPacket_MultiBlock()
+ : m_ChunkX( 0 )
+ , m_ChunkZ( 0 )
+ , m_NumBlocks( 0 )
+ , m_BlockCoordinates( 0 )
+ , m_BlockTypes( 0 )
+ , m_BlockMetas( 0 )
+ { m_PacketID = E_MULTI_BLOCK; }
+ cPacket_MultiBlock( const cPacket_MultiBlock & a_Copy );
+ ~cPacket_MultiBlock();
+ virtual cPacket* Clone() const { return new cPacket_MultiBlock(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_ChunkX;
+ int m_ChunkZ;
+ short m_NumBlocks;
+
+ static const unsigned int c_Size = 1 + 4 + 4 + 2; // Minimum size (when NumBlocks == 0)
+
+ unsigned short* m_BlockCoordinates; // x<<12 | z<<8 | y
+ char* m_BlockTypes;
+ char* m_BlockMetas;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_NamedEntitySpawn.cpp b/source/packets/cPacket_NamedEntitySpawn.cpp
new file mode 100644
index 000000000..222711119
--- /dev/null
+++ b/source/packets/cPacket_NamedEntitySpawn.cpp
@@ -0,0 +1,26 @@
+#include "cPacket_NamedEntitySpawn.h"
+
+
+bool cPacket_NamedEntitySpawn::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size + m_PlayerName.size() * sizeof( short );
+ char* Message = new char[TotalSize];
+
+ if( m_CurrentItem <= 0 ) m_CurrentItem = 0; // Fix, to make sure no invalid values are sent.
+ // WARNING: HERE ITS 0, BUT IN EQUIP PACKET ITS -1 !!
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendString16( m_PlayerName, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendInteger( m_PosY, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendByte ( m_Rotation, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+ AppendShort ( m_CurrentItem, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_NamedEntitySpawn.h b/source/packets/cPacket_NamedEntitySpawn.h
new file mode 100644
index 000000000..1a404f693
--- /dev/null
+++ b/source/packets/cPacket_NamedEntitySpawn.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_NamedEntitySpawn : public cPacket
+{
+public:
+ cPacket_NamedEntitySpawn()
+ : m_UniqueID( 0 )
+ , m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Rotation( 0 )
+ , m_Pitch( 0 )
+ , m_CurrentItem( 0 )
+ { m_PacketID = E_NAMED_ENTITY_SPAWN; }
+ virtual cPacket* Clone() const { return new cPacket_NamedEntitySpawn(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ std::string m_PlayerName;
+ int m_PosX; // Pixel position, devide by 32 for block position
+ int m_PosY;
+ int m_PosZ;
+ char m_Rotation;
+ char m_Pitch;
+ short m_CurrentItem;
+
+ static const unsigned int c_Size = 1 + 4 + 2 + 4 + 4 + 4 + 1 + 1 + 2; // Minimum size
+};
diff --git a/source/packets/cPacket_PickupSpawn.cpp b/source/packets/cPacket_PickupSpawn.cpp
new file mode 100644
index 000000000..73f4e3846
--- /dev/null
+++ b/source/packets/cPacket_PickupSpawn.cpp
@@ -0,0 +1,40 @@
+#include "cPacket_PickupSpawn.h"
+
+bool cPacket_PickupSpawn::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+ if( !ReadInteger( m_UniqueID ) ) return false;
+ if( !ReadShort ( m_Item ) ) return false;
+ if( !ReadByte ( m_Count ) ) return false;
+ if( !ReadShort ( m_Health ) ) return false;
+ if( !ReadInteger( m_PosX ) ) return false;
+ if( !ReadInteger( m_PosY ) ) return false;
+ if( !ReadInteger( m_PosZ ) ) return false;
+ if( !ReadByte ( m_Rotation ) ) return false;
+ if( !ReadByte ( m_Pitch ) ) return false;
+ if( !ReadByte ( m_Roll ) ) return false;
+ return true;
+}
+
+bool cPacket_PickupSpawn::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendShort ( m_Item, Message, i );
+ AppendByte ( m_Count, Message, i );
+ AppendShort ( m_Health, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendInteger( m_PosY, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendByte ( m_Rotation, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+ AppendByte ( m_Roll, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_PickupSpawn.h b/source/packets/cPacket_PickupSpawn.h
new file mode 100644
index 000000000..c4152eedd
--- /dev/null
+++ b/source/packets/cPacket_PickupSpawn.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_PickupSpawn : public cPacket
+{
+public:
+ cPacket_PickupSpawn()
+ : m_UniqueID( 0 )
+ , m_Item( 0 )
+ , m_Count( 0 )
+ , m_Health( 0 )
+ , m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Rotation( 0 )
+ , m_Pitch( 0 )
+ , m_Roll( 0 )
+ { m_PacketID = E_PICKUP_SPAWN; }
+ virtual cPacket* Clone() const { return new cPacket_PickupSpawn(*this); }
+
+ bool Parse( cSocket & a_Socket );
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ short m_Item;
+ char m_Count;
+ short m_Health;
+ int m_PosX;
+ int m_PosY;
+ int m_PosZ;
+ char m_Rotation;
+ char m_Pitch;
+ char m_Roll;
+
+ static const unsigned int c_Size = 1 + 4 + 2 + 1 + 2 + 4 + 4 + 4 + 1 + 1 + 1;
+};
diff --git a/source/packets/cPacket_Ping.h b/source/packets/cPacket_Ping.h
new file mode 100644
index 000000000..abab822a4
--- /dev/null
+++ b/source/packets/cPacket_Ping.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Ping : public cPacket
+{
+public:
+ cPacket_Ping()
+ { m_PacketID = E_PING; }
+ virtual cPacket* Clone() const { return new cPacket_Ping(*this); }
+
+ bool Parse(cSocket & a_Socket) { (void)a_Socket; return true; }
+
+ static const unsigned int c_Size = 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerLook.cpp b/source/packets/cPacket_PlayerLook.cpp
new file mode 100644
index 000000000..2660ccf92
--- /dev/null
+++ b/source/packets/cPacket_PlayerLook.cpp
@@ -0,0 +1,36 @@
+#include "cPacket_PlayerLook.h"
+#include "../cPlayer.h"
+
+cPacket_PlayerLook::cPacket_PlayerLook( cPlayer* a_Player )
+{
+ m_PacketID = E_PLAYERLOOK;
+
+ m_Rotation = a_Player->GetRotation();
+ m_Pitch = a_Player->GetPitch();
+ m_bFlying = a_Player->GetFlying();
+}
+
+bool cPacket_PlayerLook::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+ if( !ReadFloat( m_Rotation ) ) return false;
+ if( !ReadFloat( m_Pitch ) ) return false;
+ if( !ReadBool ( m_bFlying ) ) return false;
+ return true;
+}
+
+bool cPacket_PlayerLook::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendFloat ( m_Rotation, Message, i );
+ AppendFloat ( m_Pitch, Message, i );
+ AppendBool ( m_bFlying, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( cPacket::SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerLook.h b/source/packets/cPacket_PlayerLook.h
new file mode 100644
index 000000000..1f315a78b
--- /dev/null
+++ b/source/packets/cPacket_PlayerLook.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPlayer;
+class cPacket_PlayerLook : public cPacket
+{
+public:
+ cPacket_PlayerLook()
+ : m_Rotation( 0 )
+ , m_Pitch( 0 )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERLOOK; }
+ cPacket_PlayerLook( cPlayer* a_Player );
+ virtual cPacket* Clone() const { return new cPacket_PlayerLook(*this); }
+
+ bool Parse( cSocket & a_Socket );
+ bool Send( cSocket & a_Socket );
+
+ float m_Rotation;
+ float m_Pitch;
+ bool m_bFlying; // Yeah.. wtf
+ static const unsigned int c_Size = 10;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerMoveLook.cpp b/source/packets/cPacket_PlayerMoveLook.cpp
new file mode 100644
index 000000000..f1d67478c
--- /dev/null
+++ b/source/packets/cPacket_PlayerMoveLook.cpp
@@ -0,0 +1,50 @@
+#include "cPacket_PlayerMoveLook.h"
+#include "../cPlayer.h"
+
+cPacket_PlayerMoveLook::cPacket_PlayerMoveLook( cPlayer* a_Player )
+{
+ m_PacketID = E_PLAYERMOVELOOK;
+
+
+ m_PosX = a_Player->GetPosX();
+ m_PosY = a_Player->GetPosY() + 1.65;
+ m_PosZ = a_Player->GetPosZ();
+ m_Stance = a_Player->GetStance();
+ m_Rotation = a_Player->GetRotation();
+ m_Pitch = a_Player->GetPitch();
+ m_bFlying = a_Player->GetFlying();
+}
+
+bool cPacket_PlayerMoveLook::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+
+ if( !ReadDouble( m_PosX ) ) return false;
+ if( !ReadDouble( m_PosY ) ) return false;
+ if( !ReadDouble( m_Stance ) ) return false;
+ if( !ReadDouble( m_PosZ ) ) return false;
+ if( !ReadFloat ( m_Rotation ) ) return false;
+ if( !ReadFloat ( m_Pitch ) ) return false;
+ if( !ReadBool ( m_bFlying ) ) return false;
+ return true;
+}
+
+bool cPacket_PlayerMoveLook::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendDouble( m_PosX, Message, i );
+ AppendDouble( m_PosY, Message, i );
+ AppendDouble( m_Stance, Message, i );
+ AppendDouble( m_PosZ, Message, i );
+ AppendFloat ( m_Rotation, Message, i );
+ AppendFloat ( m_Pitch, Message, i );
+ AppendBool ( m_bFlying, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerMoveLook.h b/source/packets/cPacket_PlayerMoveLook.h
new file mode 100644
index 000000000..3711e0e58
--- /dev/null
+++ b/source/packets/cPacket_PlayerMoveLook.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPlayer;
+class cPacket_PlayerMoveLook : public cPacket
+{
+public:
+ cPacket_PlayerMoveLook()
+ : m_PosX( 0.0 )
+ , m_PosY( 0.0 )
+ , m_Stance( 0.0 )
+ , m_PosZ( 0.0 )
+ , m_Rotation( 0.f )
+ , m_Pitch( 0.f )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERMOVELOOK; }
+ cPacket_PlayerMoveLook( cPlayer* a_Player );
+ virtual cPacket* Clone() const { return new cPacket_PlayerMoveLook(*this); }
+
+ virtual bool Parse(cSocket & a_Socket);
+ virtual bool Send(cSocket & a_Socket);
+
+ double m_PosX;
+ double m_PosY;
+ double m_Stance;
+ double m_PosZ;
+ float m_Rotation;
+ float m_Pitch;
+ bool m_bFlying; // Yeah.. wtf
+ static const unsigned int c_Size = 42;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerPosition.cpp b/source/packets/cPacket_PlayerPosition.cpp
new file mode 100644
index 000000000..eb17bc7e5
--- /dev/null
+++ b/source/packets/cPacket_PlayerPosition.cpp
@@ -0,0 +1,42 @@
+#include "cPacket_PlayerPosition.h"
+#include "cPlayer.h"
+
+cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player )
+{
+ m_PacketID = E_PLAYERPOS;
+
+ m_PosX = a_Player->GetPosX();
+ m_PosY = a_Player->GetPosY() + 1.65;
+ m_PosZ = a_Player->GetPosZ();
+ m_Stance = a_Player->GetStance();
+ m_bFlying = a_Player->GetFlying();
+}
+
+bool cPacket_PlayerPosition::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadDouble( m_PosX ) ) return false;
+ if( !ReadDouble( m_PosY ) ) return false;
+ if( !ReadDouble( m_Stance ) ) return false;
+ if( !ReadDouble( m_PosZ ) ) return false;
+ if( !ReadBool( m_bFlying ) ) return false;
+ return true;
+}
+
+bool cPacket_PlayerPosition::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendDouble ( m_PosX, Message, i );
+ AppendDouble ( m_PosY, Message, i );
+ AppendDouble ( m_Stance, Message, i );
+ AppendDouble ( m_PosZ, Message, i );
+ AppendBool ( m_bFlying, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_PlayerPosition.h b/source/packets/cPacket_PlayerPosition.h
new file mode 100644
index 000000000..d9c68a2e6
--- /dev/null
+++ b/source/packets/cPacket_PlayerPosition.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPlayer;
+class cPacket_PlayerPosition : public cPacket
+{
+public:
+ cPacket_PlayerPosition( cPlayer* a_Player );
+ cPacket_PlayerPosition()
+ : m_PosX( 0.0 )
+ , m_PosY( 0.0 )
+ , m_Stance( 0.0 )
+ , m_PosZ( 0.0 )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERPOS; }
+ virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); }
+
+ virtual bool Parse(cSocket & a_Socket);
+ virtual bool Send(cSocket & a_Socket);
+
+ double m_PosX;
+ double m_PosY;
+ double m_Stance;
+ double m_PosZ;
+ bool m_bFlying; // Yeah.. wtf
+ static const unsigned int c_Size = 34;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_PreChunk.cpp b/source/packets/cPacket_PreChunk.cpp
new file mode 100644
index 000000000..686984a1e
--- /dev/null
+++ b/source/packets/cPacket_PreChunk.cpp
@@ -0,0 +1,17 @@
+#include "cPacket_PreChunk.h"
+
+bool cPacket_PreChunk::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendBool ( m_bLoad, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_PreChunk.h b/source/packets/cPacket_PreChunk.h
new file mode 100644
index 000000000..a6bd4897e
--- /dev/null
+++ b/source/packets/cPacket_PreChunk.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_PreChunk: public cPacket
+{
+public:
+ cPacket_PreChunk()
+ : m_PosX( 0 )
+ , m_PosZ( 0 )
+ , m_bLoad( false )
+ { m_PacketID = E_PRE_CHUNK; }
+ virtual cPacket* Clone() const { return new cPacket_PreChunk(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_PosX;
+ int m_PosZ;
+ bool m_bLoad;
+ static const unsigned int c_Size = 10;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_RelativeEntityMove.cpp b/source/packets/cPacket_RelativeEntityMove.cpp
new file mode 100644
index 000000000..4a1dc56b2
--- /dev/null
+++ b/source/packets/cPacket_RelativeEntityMove.cpp
@@ -0,0 +1,18 @@
+#include "cPacket_RelativeEntityMove.h"
+
+bool cPacket_RelativeEntityMove::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendByte ( m_MoveX, Message, i );
+ AppendByte ( m_MoveY, Message, i );
+ AppendByte ( m_MoveZ, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_RelativeEntityMove.h b/source/packets/cPacket_RelativeEntityMove.h
new file mode 100644
index 000000000..03d895b38
--- /dev/null
+++ b/source/packets/cPacket_RelativeEntityMove.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_RelativeEntityMove : public cPacket
+{
+public:
+ cPacket_RelativeEntityMove()
+ : m_UniqueID( 0 )
+ , m_MoveX( 0 )
+ , m_MoveY( 0 )
+ , m_MoveZ( 0 )
+ { m_PacketID = E_REL_ENT_MOVE; }
+ virtual cPacket* Clone() const { return new cPacket_RelativeEntityMove(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ char m_MoveX; // Pixels, devide by 32 for block
+ char m_MoveY;
+ char m_MoveZ;
+
+ static const unsigned int c_Size = 1 + 4 + 1 + 1 + 1;
+};
diff --git a/source/packets/cPacket_RelativeEntityMoveLook.cpp b/source/packets/cPacket_RelativeEntityMoveLook.cpp
new file mode 100644
index 000000000..e879870cd
--- /dev/null
+++ b/source/packets/cPacket_RelativeEntityMoveLook.cpp
@@ -0,0 +1,20 @@
+#include "cPacket_RelativeEntityMoveLook.h"
+
+bool cPacket_RelativeEntityMoveLook::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendByte ( m_MoveX, Message, i );
+ AppendByte ( m_MoveY, Message, i );
+ AppendByte ( m_MoveZ, Message, i );
+ AppendByte ( m_Yaw, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_RelativeEntityMoveLook.h b/source/packets/cPacket_RelativeEntityMoveLook.h
new file mode 100644
index 000000000..cb54db159
--- /dev/null
+++ b/source/packets/cPacket_RelativeEntityMoveLook.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_RelativeEntityMoveLook : public cPacket
+{
+public:
+ cPacket_RelativeEntityMoveLook()
+ : m_UniqueID( 0 )
+ , m_MoveX( 0 )
+ , m_MoveY( 0 )
+ , m_MoveZ( 0 )
+ , m_Yaw( 0 )
+ , m_Pitch( 0 )
+ { m_PacketID = E_REL_ENT_MOVE_LOOK; }
+ virtual cPacket* Clone() const { return new cPacket_RelativeEntityMoveLook(*this); }
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ char m_MoveX; // Pixels, divide by 32 for block
+ char m_MoveY;
+ char m_MoveZ;
+ char m_Yaw;
+ char m_Pitch;
+
+ static const unsigned int c_Size = 1 + 4 + 1 + 1 + 1 + 1 + 1;
+};
diff --git a/source/packets/cPacket_Respawn.cpp b/source/packets/cPacket_Respawn.cpp
new file mode 100644
index 000000000..e12ea1ace
--- /dev/null
+++ b/source/packets/cPacket_Respawn.cpp
@@ -0,0 +1,31 @@
+#include "cPacket_Respawn.h"
+
+bool cPacket_Respawn::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_World, Message, i );
+ AppendByte ( m_Difficulty, Message, i );
+ AppendByte ( m_CreativeMode, Message, i );
+ AppendShort ( m_WorldHeight, Message, i );
+ AppendLong ( m_MapSeed, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
+
+bool cPacket_Respawn::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadByte( m_World ) ) return false;
+ if( !ReadByte( m_Difficulty ) ) return false;
+ if( !ReadByte( m_CreativeMode ) ) return false;
+ if( !ReadShort( m_WorldHeight ) ) return false;
+ if( !ReadLong( m_MapSeed ) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h
new file mode 100644
index 000000000..ab8fbe72a
--- /dev/null
+++ b/source/packets/cPacket_Respawn.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Respawn : public cPacket
+{
+public:
+ cPacket_Respawn()
+ : m_World( 0 )
+ , m_Difficulty( 0 )
+ , m_CreativeMode( 0 )
+ , m_WorldHeight( 0 )
+ , m_MapSeed( 0 )
+ { m_PacketID = E_RESPAWN; }
+ virtual cPacket* Clone() const { return new cPacket_Respawn( *this ); }
+
+ bool Send(cSocket & a_Socket);
+ bool Parse(cSocket & a_Socket);
+
+ char m_World;
+ char m_Difficulty;
+ char m_CreativeMode;
+ short m_WorldHeight;
+ long long m_MapSeed;
+
+ static const unsigned int c_Size = 1 + 1 + 1 + 1 + 2 + 8;
+};
diff --git a/source/packets/cPacket_SpawnMob.cpp b/source/packets/cPacket_SpawnMob.cpp
new file mode 100644
index 000000000..8de03f04b
--- /dev/null
+++ b/source/packets/cPacket_SpawnMob.cpp
@@ -0,0 +1,60 @@
+#include "cPacket_SpawnMob.h"
+#include "Vector3i.h"
+
+#include "cMCLogger.h"
+
+cPacket_SpawnMob::~cPacket_SpawnMob()
+{
+ if( m_MetaData ) delete [] m_MetaData;
+ delete m_Pos;
+}
+
+cPacket_SpawnMob::cPacket_SpawnMob()
+ : m_UniqueID( 0 )
+ , m_Type( 0 )
+ , m_Pos( new Vector3i() )
+ , m_Yaw( 0 )
+ , m_Pitch( 0 )
+ , m_MetaDataSize( 0 )
+ , m_MetaData( 0 )
+{
+ m_PacketID = E_SPAWN_MOB;
+}
+
+cPacket_SpawnMob::cPacket_SpawnMob( const cPacket_SpawnMob & a_Clone )
+{
+ m_Pos = new Vector3i();
+
+ m_PacketID = E_SPAWN_MOB;
+ m_UniqueID = a_Clone.m_UniqueID;
+ m_Type = a_Clone.m_Type;
+ *m_Pos = *a_Clone.m_Pos;
+ m_Yaw = a_Clone.m_Yaw;
+ m_Pitch = a_Clone.m_Pitch;
+
+ m_MetaDataSize = a_Clone.m_MetaDataSize;
+ m_MetaData = new char[m_MetaDataSize];
+ memcpy( m_MetaData, a_Clone.m_MetaData, sizeof( char ) * m_MetaDataSize );
+}
+
+bool cPacket_SpawnMob::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size + m_MetaDataSize;
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_UniqueID, Message, i );
+ AppendByte ( m_Type, Message, i );
+ AppendInteger ( m_Pos->x, Message, i );
+ AppendInteger ( m_Pos->y, Message, i );
+ AppendInteger ( m_Pos->z, Message, i );
+ AppendByte ( m_Yaw, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+ AppendData ( m_MetaData, m_MetaDataSize, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_SpawnMob.h b/source/packets/cPacket_SpawnMob.h
new file mode 100644
index 000000000..bd7c75464
--- /dev/null
+++ b/source/packets/cPacket_SpawnMob.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class Vector3i;
+class cPacket_SpawnMob : public cPacket
+{
+public:
+ cPacket_SpawnMob();
+ cPacket_SpawnMob( const cPacket_SpawnMob & a_Clone );
+ virtual cPacket* Clone() const { return new cPacket_SpawnMob( *this ); }
+ ~cPacket_SpawnMob();
+
+ bool Send(cSocket & a_Socket);
+
+ int m_UniqueID;
+ char m_Type;
+ Vector3i* m_Pos;
+ char m_Yaw;
+ char m_Pitch;
+
+ static const unsigned int c_Size = 1 + 4 + 1 + 4 + 4 + 4 + 1 + 1; // + metadata
+
+ unsigned int m_MetaDataSize;
+ char* m_MetaData;
+};
diff --git a/source/packets/cPacket_TeleportEntity.cpp b/source/packets/cPacket_TeleportEntity.cpp
new file mode 100644
index 000000000..73c7c0524
--- /dev/null
+++ b/source/packets/cPacket_TeleportEntity.cpp
@@ -0,0 +1,34 @@
+#include "cPacket_TeleportEntity.h"
+
+#include "cEntity.h"
+
+cPacket_TeleportEntity::cPacket_TeleportEntity(cEntity* a_Client)
+{
+ m_PacketID = E_ENT_TELEPORT;
+
+ m_UniqueID = a_Client->GetUniqueID();
+ m_PosX = (int)(a_Client->GetPosX() * 32);
+ m_PosY = (int)(a_Client->GetPosY() * 32);
+ m_PosZ = (int)(a_Client->GetPosZ() * 32);
+ m_Rotation = (char)((a_Client->GetRotation()/360.f)*256);
+ m_Pitch = (char)((a_Client->GetPitch()/360.f)*256);
+}
+
+bool cPacket_TeleportEntity::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger( m_UniqueID, Message, i );
+ AppendInteger( m_PosX, Message, i );
+ AppendInteger( m_PosY, Message, i );
+ AppendInteger( m_PosZ, Message, i );
+ AppendByte ( m_Rotation, Message, i );
+ AppendByte ( m_Pitch, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_TeleportEntity.h b/source/packets/cPacket_TeleportEntity.h
new file mode 100644
index 000000000..da1f61c60
--- /dev/null
+++ b/source/packets/cPacket_TeleportEntity.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cEntity;
+class cPacket_TeleportEntity : public cPacket
+{
+public:
+ cPacket_TeleportEntity()
+ : m_UniqueID( 0 )
+ , m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Rotation( 0 )
+ , m_Pitch( 0 )
+ { m_PacketID = E_ENT_TELEPORT; }
+ virtual cPacket* Clone() const { return new cPacket_TeleportEntity(*this); }
+ cPacket_TeleportEntity(cEntity* a_Client);
+
+ bool Send( cSocket & a_Socket );
+
+ int m_UniqueID;
+ int m_PosX; // Pixel position, divide by 32 for block position
+ int m_PosY;
+ int m_PosZ;
+ char m_Rotation;
+ char m_Pitch;
+
+ static const unsigned int c_Size = 1 + 4 + 4 + 4 + 4 + 1 + 1;
+};
diff --git a/source/packets/cPacket_TimeUpdate.cpp b/source/packets/cPacket_TimeUpdate.cpp
new file mode 100644
index 000000000..09a9ca66a
--- /dev/null
+++ b/source/packets/cPacket_TimeUpdate.cpp
@@ -0,0 +1,22 @@
+#include "cPacket_TimeUpdate.h"
+
+bool cPacket_TimeUpdate::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadLong(m_Time) ) return false;
+ return true;
+}
+
+bool cPacket_TimeUpdate::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendLong ( m_Time, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_TimeUpdate.h b/source/packets/cPacket_TimeUpdate.h
new file mode 100644
index 000000000..9913eba2c
--- /dev/null
+++ b/source/packets/cPacket_TimeUpdate.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_TimeUpdate : public cPacket
+{
+public:
+ cPacket_TimeUpdate()
+ : m_Time( 0 )
+ { m_PacketID = E_UPDATE_TIME; }
+ cPacket_TimeUpdate( long long a_Time ) { m_PacketID = E_UPDATE_TIME; m_Time = a_Time; }
+ virtual cPacket* Clone() const { return new cPacket_TimeUpdate(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ long long m_Time;
+ static const unsigned int c_Size = 1 + 8;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_UpdateHealth.cpp b/source/packets/cPacket_UpdateHealth.cpp
new file mode 100644
index 000000000..f46d159ad
--- /dev/null
+++ b/source/packets/cPacket_UpdateHealth.cpp
@@ -0,0 +1,20 @@
+#include "cPacket_UpdateHealth.h"
+
+#include "cMCLogger.h"
+
+bool cPacket_UpdateHealth::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendShort ( m_Health, Message, i );
+ AppendShort ( m_Food, Message, i );
+ AppendFloat ( m_Saturation, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_UpdateHealth.h b/source/packets/cPacket_UpdateHealth.h
new file mode 100644
index 000000000..97081e645
--- /dev/null
+++ b/source/packets/cPacket_UpdateHealth.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_UpdateHealth : public cPacket
+{
+public:
+ cPacket_UpdateHealth()
+ : m_Health( 0 )
+ , m_Food( 0 )
+ , m_Saturation( 0.f )
+ { m_PacketID = E_UPDATE_HEALTH; }
+ cPacket_UpdateHealth( short a_Health ) { m_Health = a_Health; m_PacketID = E_UPDATE_HEALTH; }
+ virtual cPacket* Clone() const { return new cPacket_UpdateHealth( *this ); }
+
+ bool Send(cSocket & a_Socket);
+
+ short m_Health;
+ short m_Food;
+ float m_Saturation;
+
+ static const unsigned int c_Size = 1 + 2 + 2 + 4;
+};
diff --git a/source/packets/cPacket_UpdateSign.cpp b/source/packets/cPacket_UpdateSign.cpp
new file mode 100644
index 000000000..f7d3f8618
--- /dev/null
+++ b/source/packets/cPacket_UpdateSign.cpp
@@ -0,0 +1,41 @@
+#include "cPacket_UpdateSign.h"
+
+bool cPacket_UpdateSign::Parse( cSocket & a_Socket )
+{
+ m_Socket = a_Socket;
+
+ if( !ReadInteger( m_PosX ) ) return false;
+ if( !ReadShort ( m_PosY ) ) return false;
+ if( !ReadInteger( m_PosZ ) ) return false;
+ if( !ReadString16 ( m_Line1 ) ) return false;
+ if( !ReadString16 ( m_Line2 ) ) return false;
+ if( !ReadString16 ( m_Line3 ) ) return false;
+ if( !ReadString16 ( m_Line4 ) ) return false;
+
+ return true;
+}
+
+bool cPacket_UpdateSign::Send( cSocket & a_Socket )
+{
+ unsigned int TotalSize = c_Size;
+ TotalSize += m_Line1.size() * sizeof( short );
+ TotalSize += m_Line2.size() * sizeof( short );
+ TotalSize += m_Line3.size() * sizeof( short );
+ TotalSize += m_Line4.size() * sizeof( short );
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_PosX, Message, i );
+ AppendShort ( m_PosY, Message, i );
+ AppendInteger ( m_PosZ, Message, i );
+ AppendString16 ( m_Line1, Message, i );
+ AppendString16 ( m_Line2, Message, i );
+ AppendString16 ( m_Line3, Message, i );
+ AppendString16 ( m_Line4, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_UpdateSign.h b/source/packets/cPacket_UpdateSign.h
new file mode 100644
index 000000000..f23da1540
--- /dev/null
+++ b/source/packets/cPacket_UpdateSign.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_UpdateSign : public cPacket
+{
+public:
+ cPacket_UpdateSign()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ { m_PacketID = E_UPDATE_SIGN; }
+ virtual cPacket* Clone() const { return new cPacket_UpdateSign( *this ); }
+
+ bool Parse( cSocket & a_Socket );
+ bool Send( cSocket & a_Socket );
+
+ int m_PosX;
+ short m_PosY;
+ int m_PosZ;
+ std::string m_Line1;
+ std::string m_Line2;
+ std::string m_Line3;
+ std::string m_Line4;
+
+ static const unsigned int c_Size = 1 + 4 + 2 + 4 + 2 + 2 + 2 + 2; // minimum size
+};
diff --git a/source/packets/cPacket_UseEntity.cpp b/source/packets/cPacket_UseEntity.cpp
new file mode 100644
index 000000000..bbe22d3ec
--- /dev/null
+++ b/source/packets/cPacket_UseEntity.cpp
@@ -0,0 +1,10 @@
+#include "cPacket_UseEntity.h"
+
+bool cPacket_UseEntity::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+ if( !ReadInteger(m_UniqueID) ) return false;
+ if( !ReadInteger(m_TargetID) ) return false;
+ if( !ReadBool (m_bLeftClick) ) return false;
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_UseEntity.h b/source/packets/cPacket_UseEntity.h
new file mode 100644
index 000000000..cd7b45e79
--- /dev/null
+++ b/source/packets/cPacket_UseEntity.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_UseEntity : public cPacket
+{
+public:
+ cPacket_UseEntity()
+ : m_UniqueID( 0 )
+ , m_TargetID( 0 )
+ , m_bLeftClick( false )
+ { m_PacketID = E_USE_ENTITY; }
+ virtual cPacket* Clone() const { return new cPacket_UseEntity(*this); }
+
+ bool Parse(cSocket & a_Socket);
+
+ int m_UniqueID;
+ int m_TargetID;
+ bool m_bLeftClick;
+
+ static const unsigned int c_Size = 1 + 4 + 4 + 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp
new file mode 100644
index 000000000..3ee047239
--- /dev/null
+++ b/source/packets/cPacket_WholeInventory.cpp
@@ -0,0 +1,68 @@
+#include "cPacket_WholeInventory.h"
+#include "../cItem.h"
+#include "../cInventory.h"
+#include "../cWindow.h"
+
+cPacket_WholeInventory::cPacket_WholeInventory( const cPacket_WholeInventory & a_Clone )
+{
+ m_PacketID = E_INVENTORY_WHOLE;
+ m_WindowID = a_Clone.m_WindowID;
+ m_Count = a_Clone.m_Count;
+ m_Items = new cItem[m_Count];
+ memcpy( m_Items, a_Clone.m_Items, sizeof(cItem)*m_Count );
+}
+
+cPacket_WholeInventory::cPacket_WholeInventory( cInventory* a_Inventory )
+{
+ m_PacketID = E_INVENTORY_WHOLE;
+ m_WindowID = 0;
+ m_Count = a_Inventory->c_NumSlots;
+ m_Items = new cItem[m_Count];
+ memcpy( m_Items, a_Inventory->GetSlots(), sizeof(cItem)*m_Count );
+}
+
+cPacket_WholeInventory::cPacket_WholeInventory( cWindow* a_Window )
+{
+ m_PacketID = E_INVENTORY_WHOLE;
+ m_WindowID = (char)a_Window->GetWindowID();
+ m_Count = (short)a_Window->GetNumSlots();
+ m_Items = new cItem[m_Count];
+ memcpy( m_Items, a_Window->GetSlots(), sizeof(cItem)*m_Count );
+}
+
+cPacket_WholeInventory::~cPacket_WholeInventory()
+{
+ delete [] m_Items;
+}
+
+bool cPacket_WholeInventory::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+
+ for(int i = 0; i < m_Count; i++)
+ {
+ if( m_Items[i].m_ItemID > -1 )
+ TotalSize+=3;
+ TotalSize+=2;
+ }
+
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_WindowID, Message, i );
+ AppendShort ( m_Count, Message, i );
+ for(int j = 0; j < m_Count; j++)
+ {
+ AppendShort ( (short)m_Items[j].m_ItemID, Message, i );
+ if( m_Items[j].m_ItemID > -1 )
+ {
+ AppendByte ( m_Items[j].m_ItemCount, Message, i );
+ AppendShort ( m_Items[j].m_ItemHealth, Message, i );
+ }
+ }
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_WholeInventory.h b/source/packets/cPacket_WholeInventory.h
new file mode 100644
index 000000000..a2e76658e
--- /dev/null
+++ b/source/packets/cPacket_WholeInventory.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cInventory;
+class cWindow;
+class cItem;
+class cPacket_WholeInventory : public cPacket // full inventory [S -> C] ?
+{
+public:
+ cPacket_WholeInventory( const cPacket_WholeInventory & a_Clone );
+ cPacket_WholeInventory( cInventory* a_Inventory );
+ cPacket_WholeInventory( cWindow* a_Window );
+ ~cPacket_WholeInventory();
+ cPacket_WholeInventory()
+ : m_WindowID( 0 )
+ , m_Count( 0 )
+ , m_Items( 0 )
+ { m_PacketID = E_INVENTORY_WHOLE; }
+ virtual cPacket* Clone() const { return new cPacket_WholeInventory(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ char m_WindowID; // WTF?
+ short m_Count; // Number of items
+
+ cItem* m_Items; // Array of m_Count items
+
+ static const unsigned int c_Size = 1 + 1 + 2; // Minimal size
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp
new file mode 100644
index 000000000..6b295b4d5
--- /dev/null
+++ b/source/packets/cPacket_WindowClick.cpp
@@ -0,0 +1,36 @@
+#include "cPacket_WindowClick.h"
+
+
+bool cPacket_WindowClick::Parse(cSocket & a_Socket)
+{
+// LOG("-----------INV66-----------");
+ m_Socket = a_Socket;
+
+ if( !ReadByte(m_WindowID) ) return false;
+ if( !ReadShort(m_SlotNum) ) return false;
+ if( !ReadByte(m_RightMouse) ) return false;
+ if( !ReadShort(m_NumClicks) ) return false;
+ if( !ReadBool(m_Bool) ) return false;
+
+// LOG("WindowID : %i", m_Type );
+// LOG("FromSlot: %i", m_SlotNum );
+// LOG("Right/Le: %i", m_RightMouse );
+// LOG("NumClick: %i", m_NumClicks );
+
+ if( !ReadShort(m_ItemID) ) return false;
+// LOG("ItemID: %i", m_ItemID );
+ if( m_ItemID > -1 )
+ {
+ if( !ReadByte(m_ItemCount) ) return false;
+ if( !ReadShort(m_ItemUses) ) return false;
+// LOG("Count : %i", m_ItemCount );
+// LOG("Uses : %i", m_ItemUses );
+ }
+ else
+ {
+ m_ItemCount = 0;
+ m_ItemUses = 0;
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_WindowClick.h b/source/packets/cPacket_WindowClick.h
new file mode 100644
index 000000000..d6f38e9ab
--- /dev/null
+++ b/source/packets/cPacket_WindowClick.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_WindowClick : public cPacket // [C -> S]
+{
+public:
+ cPacket_WindowClick()
+ : m_WindowID( 0 )
+ , m_SlotNum( 0 )
+ , m_RightMouse( 0 )
+ , m_NumClicks( 0 )
+ , m_Bool( false )
+ , m_ItemID( 0 )
+ , m_ItemCount( 0 )
+ , m_ItemUses( 0 )
+ { m_PacketID = E_WINDOW_CLICK; }
+ virtual cPacket* Clone() const { return new cPacket_WindowClick(*this); }
+
+ bool Parse(cSocket & a_Socket);
+
+ char m_WindowID;
+ short m_SlotNum; // Slot
+ // 0 = craft result
+ // 1-4 = crafting table
+ // 5-8 = armor
+ // 9-35 = inventory
+ // 36-44 = Hot bar
+
+ char m_RightMouse; // 0 = left 1 = Right mb
+ short m_NumClicks; // Num clicks
+ bool m_Bool; // unkown????????????
+
+ // Below = item
+ short m_ItemID; // if this is -1 the next stuff dont exist
+ char m_ItemCount;
+ short m_ItemUses;
+
+ static const unsigned int c_Size = 1 + 1 + 2 + 1 + 2 + 2; // Minimal size ( +1+1 = max)
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_WindowClose.cpp b/source/packets/cPacket_WindowClose.cpp
new file mode 100644
index 000000000..0881fb703
--- /dev/null
+++ b/source/packets/cPacket_WindowClose.cpp
@@ -0,0 +1,27 @@
+#include "cPacket_WindowClose.h"
+
+bool cPacket_WindowClose::Parse(cSocket & a_Socket)
+{
+ //LOG("CLOSE INVENTORY PACKET");
+ m_Socket = a_Socket;
+
+ if( !ReadByte(m_Close) ) return false;
+
+ //LOG("Closed inventory?: %i", m_Close );
+
+ return true;
+}
+
+bool cPacket_WindowClose::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_Close, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_WindowClose.h b/source/packets/cPacket_WindowClose.h
new file mode 100644
index 000000000..1940eec0a
--- /dev/null
+++ b/source/packets/cPacket_WindowClose.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_WindowClose : public cPacket
+{
+public:
+ cPacket_WindowClose()
+ : m_Close( 0 )
+ { m_PacketID = E_WINDOW_CLOSE; }
+ virtual cPacket* Clone() const { return new cPacket_WindowClose(*this); }
+
+ bool Parse(cSocket & a_Socket);
+ bool Send(cSocket & a_Socket);
+
+ char m_Close; // 1 = close
+
+ static const unsigned int c_Size = 1 + 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_WindowOpen.cpp b/source/packets/cPacket_WindowOpen.cpp
new file mode 100644
index 000000000..5d1299acd
--- /dev/null
+++ b/source/packets/cPacket_WindowOpen.cpp
@@ -0,0 +1,18 @@
+#include "cPacket_WindowOpen.h"
+
+bool cPacket_WindowOpen::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size + m_WindowTitle.size() * sizeof( short );
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendByte ( m_WindowID, Message, i );
+ AppendByte ( m_InventoryType, Message, i );
+ AppendString16( m_WindowTitle, Message, i );
+ AppendByte ( m_NumSlots, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+} \ No newline at end of file
diff --git a/source/packets/cPacket_WindowOpen.h b/source/packets/cPacket_WindowOpen.h
new file mode 100644
index 000000000..df05799d5
--- /dev/null
+++ b/source/packets/cPacket_WindowOpen.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_WindowOpen : public cPacket
+{
+public:
+ cPacket_WindowOpen()
+ : m_WindowID( 0 )
+ , m_InventoryType( 0 )
+ , m_NumSlots( 0 )
+ { m_PacketID = E_WINDOW_OPEN; }
+ virtual cPacket* Clone() const { return new cPacket_WindowOpen(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ char m_WindowID;
+ char m_InventoryType;
+ std::string m_WindowTitle;
+ char m_NumSlots;
+
+ static const unsigned int c_Size = 1 + 1 + 1 + 2 + 1; // + sizeof(string)
+}; \ No newline at end of file
diff --git a/source/tolua++.exe b/source/tolua++.exe
new file mode 100644
index 000000000..c39968dbf
--- /dev/null
+++ b/source/tolua++.exe
Binary files differ
diff --git a/source/tolua++.h b/source/tolua++.h
new file mode 100644
index 000000000..ed5344926
--- /dev/null
+++ b/source/tolua++.h
@@ -0,0 +1,186 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+
+#ifndef TOLUA_H
+#define TOLUA_H
+
+#ifndef TOLUA_API
+#define TOLUA_API extern
+#endif
+
+#define TOLUA_VERSION "tolua++-1.0.92"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str())
+#define tolua_iscppstring tolua_isstring
+
+#define tolua_iscppstringarray tolua_isstringarray
+#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
+
+#ifndef TEMPLATE_BIND
+ #define TEMPLATE_BIND(p)
+#endif
+
+#define TOLUA_TEMPLATE_BIND(p)
+
+#define TOLUA_PROTECTED_DESTRUCTOR
+#define TOLUA_PROPERTY_TYPE(p)
+
+typedef int lua_Object;
+
+#include "lua.h"
+#include "lauxlib.h"
+
+struct tolua_Error
+{
+ int index;
+ int array;
+ const char* type;
+};
+typedef struct tolua_Error tolua_Error;
+
+#define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */
+
+TOLUA_API const char* tolua_typename (lua_State* L, int lo);
+TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err);
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
+
+TOLUA_API void tolua_open (lua_State* L);
+
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
+TOLUA_API int tolua_register_gc (lua_State* L, int lo);
+TOLUA_API int tolua_default_collect (lua_State* tolua_S);
+
+TOLUA_API void tolua_usertype (lua_State* L, const char* type);
+TOLUA_API void tolua_beginmodule (lua_State* L, const char* name);
+TOLUA_API void tolua_endmodule (lua_State* L);
+TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar);
+TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base);
+TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col);
+TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func);
+TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value);
+TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set);
+
+/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
+/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
+TOLUA_API void tolua_pushboolean (lua_State* L, int value);
+TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value);
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v);
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
+
+TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def);
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
+TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def);
+TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name);
+
+TOLUA_API int class_gc_event (lua_State* L);
+
+#ifdef __cplusplus
+static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
+
+ const char* s = tolua_tostring(L, narg, def);
+ return s?s:"";
+};
+
+static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
+
+ const char* s = tolua_tofieldstring(L, lo, index, def);
+ return s?s:"";
+};
+
+#else
+#define tolua_tocppstring tolua_tostring
+#define tolua_tofieldcppstring tolua_tofieldstring
+#endif
+
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
+
+#ifndef Mtolua_new
+#define Mtolua_new(EXP) new EXP
+#endif
+
+#ifndef Mtolua_delete
+#define Mtolua_delete(EXP) delete EXP
+#endif
+
+#ifndef Mtolua_new_dim
+#define Mtolua_new_dim(EXP, len) new EXP[len]
+#endif
+
+#ifndef Mtolua_delete_dim
+#define Mtolua_delete_dim(EXP) delete [] EXP
+#endif
+
+#ifndef tolua_outside
+#define tolua_outside
+#endif
+
+#ifndef tolua_owned
+#define tolua_owned
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/source/tolua_base.h b/source/tolua_base.h
new file mode 100644
index 000000000..28ab9d41d
--- /dev/null
+++ b/source/tolua_base.h
@@ -0,0 +1,125 @@
+#ifndef TOLUA_BASE_H
+#define TOLUA_BASE_H
+
+#pragma warning(disable:4800) // This file is ONLY included by Bindings.cpp and it throws lots of C4800 warnings
+
+#include "tolua++.h"
+#include "cMCLogger.h"
+
+class ToluaBase {
+
+ int lua_instance;
+
+protected:
+
+ lua_State* lua_state;
+
+ void lua_stacktrace(lua_State* L) const
+ {
+ lua_Debug entry;
+ int depth = 0;
+
+ while (lua_getstack(L, depth, &entry))
+ {
+ lua_getinfo(L, "Sln", &entry);
+
+ LOGERROR("%s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "?");
+ depth++;
+ }
+ }
+
+
+ bool report_errors(int status) const
+ {
+ if ( status!=0 )
+ {
+ const char* s = lua_tostring(lua_state, -1);
+ LOGERROR("-- %s", s );
+ //lua_pop(lua_state, 1);
+ LOGERROR("Stack:");
+ lua_stacktrace( lua_state );
+ return true;
+ }
+ return false;
+ }
+
+ bool push_method(const char* name, lua_CFunction f) const {
+
+ if (!lua_state) return false;
+
+ lua_getref(lua_state, lua_instance);
+ lua_pushstring(lua_state, name);
+ //LOGINFO("1. push_method() Stack size: %i", lua_gettop( lua_state ) );
+ lua_gettable(lua_state, -2);
+ //LOGINFO("2. push_method() Stack size: %i", lua_gettop( lua_state ) );
+
+ if (lua_isnil(lua_state, -1)) {
+
+ // pop the table
+ lua_pop(lua_state, 2);
+ return false;
+
+ } else {
+
+ if (f) {
+ if (lua_iscfunction(lua_state, -1)) {
+ lua_pop(lua_state, 2);
+ return false;
+ };
+ /* // not for now
+ lua_pushcfunction(lua_state, f);
+ if (lua_rawequal(lua_state, -1, -2)) {
+
+ // avoid recursion, pop both functions and the table
+ lua_pop(lua_state, 3);
+ return false;
+ };
+
+ // pop f
+ lua_pop(lua_state, 1);
+ */
+ };
+
+ // swap table with function
+ lua_insert(lua_state, -2);
+ };
+
+ return true;
+ };
+
+ void dbcall(lua_State* L, int nargs, int nresults) const {
+
+ // using lua_call for now
+ int s = lua_pcall(L, nargs, nresults, 0);
+ report_errors( s );
+ };
+public:
+
+ int GetInstance() { return lua_instance; }
+ lua_State* GetLuaState() { return lua_state; }
+
+ void tolua__set_instance(lua_State* L, lua_Object lo) {
+
+ lua_state = L;
+
+ lua_pushvalue(L, lo);
+ lua_instance = lua_ref(lua_state, 1);
+ };
+
+ ToluaBase() {
+
+ lua_state = NULL;
+ };
+
+ ~ToluaBase() {
+
+ if (lua_state) {
+
+ lua_unref(lua_state, lua_instance);
+ };
+ };
+};
+
+#endif
+
+
diff --git a/source/virtual_method_hooks.lua b/source/virtual_method_hooks.lua
new file mode 100644
index 000000000..71b0e4cf8
--- /dev/null
+++ b/source/virtual_method_hooks.lua
@@ -0,0 +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 = (void*)new "..arg.type.."("..arg.name..");\n")
+ output('\t\t\ttolua_pushusertype_and_takeownership(lua_state, tolua_obj, "'..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
+
+
+
+
+