summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp37
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ManualBindings.cpp22
-rw-r--r--source/cChunk.cpp2
-rw-r--r--source/cChunkMap.cpp2
-rw-r--r--source/cPlayer.cpp23
-rw-r--r--source/cPlayer.h3
-rw-r--r--source/cWebPlugin_Lua.cpp11
8 files changed, 91 insertions, 11 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 51342db62..8d484fa1f 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,10 +1,8 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 01/27/12 00:53:11.
+** Generated automatically by tolua++-1.0.92 on 01/30/12 17:26:14.
*/
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
#ifndef __cplusplus
#include "stdlib.h"
#endif
@@ -15,6 +13,7 @@
/* Exported function */
TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "tolua_base.h"
#include "cTorch.h"
#include "cStairs.h"
@@ -5899,6 +5898,37 @@ static int tolua_AllToLua_cPlayer_MoveToWorld00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: LoadPermissionsFromDisk of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_LoadPermissionsFromDisk00
+static int tolua_AllToLua_cPlayer_LoadPermissionsFromDisk00(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 'LoadPermissionsFromDisk'", NULL);
+#endif
+ {
+ self->LoadPermissionsFromDisk();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'LoadPermissionsFromDisk'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
class Lua__cPlayer : public cPlayer, public ToluaBase {
public:
void Initialize( cWorld* a_World) {
@@ -16785,6 +16815,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetVisible",tolua_AllToLua_cPlayer_SetVisible00);
tolua_function(tolua_S,"IsVisible",tolua_AllToLua_cPlayer_IsVisible00);
tolua_function(tolua_S,"MoveToWorld",tolua_AllToLua_cPlayer_MoveToWorld00);
+ tolua_function(tolua_S,"LoadPermissionsFromDisk",tolua_AllToLua_cPlayer_LoadPermissionsFromDisk00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"Lua__cPlayer","Lua__cPlayer","cPlayer",NULL);
tolua_beginmodule(tolua_S,"Lua__cPlayer");
diff --git a/source/Bindings.h b/source/Bindings.h
index fc3d0cb62..b2ff3c1c8 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 01/27/12 00:53:12.
+** Generated automatically by tolua++-1.0.92 on 01/30/12 17:26:15.
*/
/* Exported function */
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 45fae285d..06a148b91 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -140,6 +140,27 @@ static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
return 1;
}
+static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S)
+{
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+
+ cPlayer::StringList AllPermissions = self->GetResolvedPermissions();
+
+ lua_createtable(tolua_S, AllPermissions.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ cPlayer::StringList::iterator iter = AllPermissions.begin();
+ while(iter != AllPermissions.end())
+ {
+ std::string& Permission = *iter;
+ tolua_pushstring( tolua_S, Permission.c_str() );
+ 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);
@@ -267,6 +288,7 @@ void ManualBindings::Bind( lua_State* tolua_S )
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S,"cPlayer");
tolua_function(tolua_S,"GetGroups",tolua_cPlayer_GetGroups);
+ tolua_function(tolua_S,"GetResolvedPermissions",tolua_cPlayer_GetResolvedPermissions);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S,"cWebPlugin_Lua");
tolua_function(tolua_S,"AddTab",tolua_cWebPlugin_Lua_AddTab);
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 7d93b4ba9..5e9c44a18 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -249,7 +249,7 @@ void cChunk::Tick(float a_Dt)
}
m_pState->PendingSendBlocks.clear();
}
- Lock.Unlock();
+ cCSUnlock Unlock( Lock );
while( !m_pState->UnloadQuery.empty() )
{
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index d815e311a..d3dba0510 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -380,7 +380,7 @@ void cChunkMap::UnloadUnusedChunks()
cChunk* Chunk = Layer.m_Chunks[i].m_LiveChunk;
if( Chunk && Chunk->GetClients().size() == 0 && Chunk->GetReferenceCount() <= 0 )
{
- Chunk->SaveToDisk();
+ //Chunk->SaveToDisk();
World->RemoveSpread( ptr_cChunk( Chunk ) );
RemoveChunk( Chunk );
delete Chunk;
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index c7ef8e56d..c3ba32840 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -732,8 +732,11 @@ bool cPlayer::MoveToWorld( const char* a_WorldName )
return false;
}
-bool cPlayer::LoadFromDisk() // TODO - This should also get/set/whatever the correct world for this player
+void cPlayer::LoadPermissionsFromDisk()
{
+ m_pState->Groups.clear();
+ m_pState->Permissions.clear();
+
cIniFile IniFile("users.ini");
if( IniFile.ReadFile() )
{
@@ -759,6 +762,11 @@ bool cPlayer::LoadFromDisk() // TODO - This should also get/set/whatever the cor
AddToGroup("Default");
}
ResolvePermissions();
+}
+
+bool cPlayer::LoadFromDisk() // TODO - This should also get/set/whatever the correct world for this player
+{
+ LoadPermissionsFromDisk();
// Log player permissions, cause it's what the cool kids do
LOGINFO("Player %s has permissions:", m_pState->PlayerName.c_str() );
@@ -891,6 +899,19 @@ const cPlayer::GroupList & cPlayer::GetGroups()
return m_pState->Groups;
}
+cPlayer::StringList cPlayer::GetResolvedPermissions()
+{
+ StringList Permissions;
+
+ const PermissionMap& ResolvedPermissions = m_pState->ResolvedPermissions;
+ for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
+ {
+ if( itr->second ) Permissions.push_back( itr->first );
+ }
+
+ return Permissions;
+}
+
const char* cPlayer::GetLoadedWorldName()
{
return m_pState->LoadedWorldName.c_str();
diff --git a/source/cPlayer.h b/source/cPlayer.h
index 3793443dd..c05600f80 100644
--- a/source/cPlayer.h
+++ b/source/cPlayer.h
@@ -63,10 +63,12 @@ public:
void SetName( const char* a_Name ); //tolua_export
typedef std::list< cGroup* > GroupList;
+ typedef std::list< std::string > StringList;
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 <<
+ StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
bool IsInGroup( const char* a_Group ); //tolua_export
std::string GetColor(); //tolua_export
@@ -86,6 +88,7 @@ public:
bool SaveToDisk();
bool LoadFromDisk();
+ void LoadPermissionsFromDisk(); //tolua_export
const char* GetLoadedWorldName();
diff --git a/source/cWebPlugin_Lua.cpp b/source/cWebPlugin_Lua.cpp
index f92cb1690..40e8fcb76 100644
--- a/source/cWebPlugin_Lua.cpp
+++ b/source/cWebPlugin_Lua.cpp
@@ -84,18 +84,21 @@ std::string cWebPlugin_Lua::HandleRequest( HTTPRequest* a_Request )
tolua_pushusertype( LuaState, a_Request, "HTTPRequest" );
LOGINFO("Calling bound function! :D");
int s = lua_pcall( LuaState, 1, 1, 0);
- if( report_errors( LuaState, s ) )
+
+ if ( s != 0 )
{
+ std::string err = lua_tostring(LuaState, -1);
+ LOGERROR("-- %s", err.c_str() );
+ lua_pop(LuaState, 1);
LOGINFO("error. Stack size: %i", lua_gettop(LuaState) );
- return false;
+ return err; // Show the error message in the web page, looks cool
}
-
if( !lua_isstring( LuaState, -1 ) )
{
LOGWARN("WARNING: WebPlugin tab '%s' did not return a string!", Tab->Title.c_str() );
lua_pop(LuaState, 1); // Pop return value
- return "";
+ return std::string("WARNING: WebPlugin tab '") + Tab->Title + std::string("' did not return a string!");
}
RetVal += tolua_tostring(LuaState, -1, 0);