From 30b22e9f59e0873be84e80c83d274dbe5353b835 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 23 Feb 2014 13:25:02 +0200 Subject: [PATCH] Manually exported DoWithMap --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- src/Bindings/ManualBindings.cpp | 4 ++++ src/Map.h | 5 +++++ src/MapManager.cpp | 2 +- src/MapManager.h | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8265b4e19..c8811df66 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1541,7 +1541,7 @@ a_Player:OpenWindow(Window); ]], Functions = { - DoWithMap = { Params = "ID, Callback", Return = "bool", Notes = "Calls the callback for the map with the specified ID. Returns true if the map was found and the callback called, false if map not found." }, + DoWithMap = { Params = "ID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If a map with the specified ID exists, calls the CallbackFunction for that map. The CallbackFunction has the following signature:
function Callback({{cMap|Map}}, [CallbackData])
Returns true if the map was found and the callback called, false if map not found." }, GetNumMaps = { Params = "", Return = "number", Notes = "Returns the number of registered maps." }, }, diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index c220e5e0a..f2d21a682 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2511,6 +2511,10 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cMapManager"); + tolua_function(tolua_S, "DoWithMap", tolua_DoWithID); + tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cPlugin"); tolua_function(tolua_S, "Call", tolua_cPlugin_Call); tolua_endmodule(tolua_S); diff --git a/src/Map.h b/src/Map.h index fc754e6eb..a6df7e5f2 100644 --- a/src/Map.h +++ b/src/Map.h @@ -185,6 +185,11 @@ public: const cColorList & GetData(void) const { return m_Data; } + static const char * GetClassStatic(void) // Needed for ManualBindings's DoWith templates + { + return "cMap"; + } + protected: diff --git a/src/MapManager.cpp b/src/MapManager.cpp index 2fc44ccc8..9d02eafb4 100644 --- a/src/MapManager.cpp +++ b/src/MapManager.cpp @@ -22,7 +22,7 @@ cMapManager::cMapManager(cWorld * a_World) -bool cMapManager::DoWithMap(unsigned int a_ID, cMapCallback & a_Callback) +bool cMapManager::DoWithMap(int a_ID, cMapCallback & a_Callback) { cCSLock Lock(m_CS); cMap * Map = GetMapData(a_ID); diff --git a/src/MapManager.h b/src/MapManager.h index 5da8be035..80e6d16d1 100644 --- a/src/MapManager.h +++ b/src/MapManager.h @@ -45,7 +45,7 @@ public: * Returns true if the map was found and the callback called, false if map not found. * Callback return ignored. */ - bool DoWithMap(unsigned int a_ID, cMapCallback & a_Callback); // tolua_export + bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp /** Calls the callback for each map. *