summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-16 18:20:28 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-16 18:20:28 +0100
commit008addf5d746b2d158f9116e4f6302861b42852f (patch)
treed569fe2253917ca3dc979c1b5b51d534aa4a538e
parentChunks are now marked as saved (diff)
downloadcuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.gz
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.bz2
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.lz
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.xz
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.zst
cuberite-008addf5d746b2d158f9116e4f6302861b42852f.zip
Diffstat (limited to '')
-rw-r--r--Plugins/Core/web_permissions.lua4
-rw-r--r--source/Bindings.cpp37
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cClientHandle.cpp26
-rw-r--r--source/cWorld.cpp9
-rw-r--r--source/cWorld.h8
6 files changed, 31 insertions, 55 deletions
diff --git a/Plugins/Core/web_permissions.lua b/Plugins/Core/web_permissions.lua
index 5c7527056..4fce502e1 100644
--- a/Plugins/Core/web_permissions.lua
+++ b/Plugins/Core/web_permissions.lua
@@ -11,7 +11,7 @@ local function ShowUsersTable()
Content = Content .. "<table>"
if( NumUsers > 0 ) then
- Content = Content .. "<tr><td></td><td>User</td><td>Groups</td></tr>"
+ Content = Content .. "<tr><th></th><th>User</th><th>Groups</th></tr>"
for i=0, NumUsers-1 do
local UserName = UsersIni:GetKeyName( i )
@@ -45,7 +45,7 @@ local function ShowGroupsTable()
Content = Content .. "<table>"
if( NumGroups > 0 ) then
- Content = Content .. "<tr><td></td><td>Name</td><td>Permissions</td><td>Color</td></tr>"
+ Content = Content .. "<tr><th></th><th>Name</th><th>Permissions</th><th>Color</th></tr>"
for i=0, NumGroups-1 do
local GroupName = GroupsIni:GetKeyName( i )
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index e9d23fa26..a8d99330f 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/15/12 23:43:42.
+** Generated automatically by tolua++-1.0.92 on 02/16/12 18:16:16.
*/
#ifndef __cplusplus
@@ -9587,40 +9587,6 @@ static int tolua_AllToLua_cWorld_GetPlayer00(lua_State* tolua_S)
}
#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)
@@ -17594,7 +17560,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
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);
diff --git a/source/Bindings.h b/source/Bindings.h
index 23e74ba4d..860db990f 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/15/12 23:43:42.
+** Generated automatically by tolua++-1.0.92 on 02/16/12 18:16:17.
*/
/* Exported function */
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index a28d8a56c..c8f8e82ed 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -1532,13 +1532,27 @@ void cClientHandle::HandleUseEntity(cPacket_UseEntity * a_Packet)
{
return;
}
- cWorld * World = m_Player->GetWorld();
- cEntity * Entity = World->GetEntity(a_Packet->m_TargetID);
- if ((Entity != NULL) && Entity->IsA("cPawn"))
+
+ class cDamageEntity : public cEntityCallback
{
- cPawn * Pawn = (cPawn *)Entity;
- Pawn->TakeDamage(1, m_Player);
- }
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if( a_Entity->IsA("cPawn") )
+ {
+ reinterpret_cast< cPawn* >( a_Entity )->TakeDamage(Damage, Instigator );
+ }
+ return true;
+ }
+ public:
+ int Damage;
+ cEntity * Instigator;
+ } Callback;
+
+ Callback.Damage = 1; // TODO: Find proper damage from current item equipped
+ Callback.Instigator = m_Player;
+
+ cWorld * World = m_Player->GetWorld();
+ World->DoWithEntity( a_Packet->m_TargetID, Callback );
}
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 8e95b5bd5..fc6941250 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -1168,18 +1168,17 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
-// TODO: This interface is dangerous!
-cEntity * cWorld::GetEntity( int a_UniqueID )
+bool cWorld::DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback )
{
cCSLock Lock(m_CSEntities);
for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end(); ++itr )
{
if( (*itr)->GetUniqueID() == a_UniqueID )
{
- return *itr;
+ return a_Callback.Item(*itr);
}
- }
- return NULL;
+ } // for itr - m_AllEntities[]
+ return false;
}
diff --git a/source/cWorld.h b/source/cWorld.h
index c47fa70e8..025d0782a 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -34,6 +34,7 @@ class cWorldGenerator; // The generator that actually generates the chunks for
class cChunkGenerator; // The thread responsible for generating chunks
typedef std::list< cPlayer * > cPlayerList;
typedef cItemCallback<cPlayer> cPlayerListCallback;
+typedef cItemCallback<cEntity> cEntityCallback;
@@ -102,12 +103,9 @@ public:
void AddEntity( cEntity* a_Entity );
void RemoveEntityFromChunk( cEntity * a_Entity);
-
- // TODO: This interface is dangerous!
- cEntityList & GetEntities(void) {return m_AllEntities; }
- // TODO: This interface is dangerous!
- cEntity * GetEntity( int a_UniqueID ); //tolua_export
+ // TODO: Export to Lua
+ bool DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback );
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