diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-05-04 09:49:30 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:46 +0200 |
commit | 13cfbb7bb8b59ea31bebe0960e0dd3b054be3ba5 (patch) | |
tree | cb694c6890b2dd87daa4f2e49f8c33f94d29fc7d /src | |
parent | 68481094c0d02ba127bcab6c692801b01a27f21b (diff) | |
download | manaserv-13cfbb7bb8b59ea31bebe0960e0dd3b054be3ba5.tar.gz manaserv-13cfbb7bb8b59ea31bebe0960e0dd3b054be3ba5.tar.bz2 manaserv-13cfbb7bb8b59ea31bebe0960e0dd3b054be3ba5.tar.xz manaserv-13cfbb7bb8b59ea31bebe0960e0dd3b054be3ba5.zip |
Added get_monster_classes() bind
It returns all monster classes in a id->monsterclass table.
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/monstermanager.h | 11 | ||||
-rw-r--r-- | src/scripting/lua.cpp | 14 | ||||
-rw-r--r-- | src/scripting/luautil.h | 5 |
3 files changed, 28 insertions, 2 deletions
diff --git a/src/game-server/monstermanager.h b/src/game-server/monstermanager.h index 49a6e835..c00d24fd 100644 --- a/src/game-server/monstermanager.h +++ b/src/game-server/monstermanager.h @@ -29,6 +29,8 @@ class MonsterClass; +typedef std::map< int, MonsterClass * > MonsterClasses; + class MonsterManager { public: @@ -66,17 +68,22 @@ class MonsterManager */ MonsterClass *getMonsterByName(const std::string &name) const; + const MonsterClasses &getMonsterClasses() const; + void readMonsterNode(xmlNodePtr node, const std::string &filename); void checkStatus(); private: - - typedef std::map< int, MonsterClass * > MonsterClasses; MonsterClasses mMonsterClasses; /**< Monster reference */ utils::NameMap<MonsterClass*> mMonsterClassesByName; }; +inline const MonsterClasses &MonsterManager::getMonsterClasses() const +{ + return mMonsterClasses; +} + extern MonsterManager *monsterManager; #endif // MONSTERMANAGER_H diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 0c27788c..fb6990e5 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -2958,6 +2958,19 @@ static int get_monster_class(lua_State *s) return 1; } +/** LUA get_monster_classes (monsterclass) + * get_monster_classes() + ** + * **Return value:** A Table with all monster classes. The id of the monster + * is the key. The monster class itself the value. See below for the usage of + * this object. + */ +static int get_monster_classes(lua_State *s) +{ + pushSTLContainer(s, monsterManager->getMonsterClasses()); + return 1; +} + /** LUA monsterclass:on_update (monsterclass) * monsterclass:on_update(function callback) ** @@ -3265,6 +3278,7 @@ LuaScript::LuaScript(): { "on_mapupdate", on_mapupdate }, { "get_item_class", get_item_class }, { "get_monster_class", get_monster_class }, + { "get_monster_classes", get_monster_classes }, { "get_status_effect", get_status_effect }, { "npc_create", npc_create }, { "say", say }, diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h index e7cbc754..653bf24a 100644 --- a/src/scripting/luautil.h +++ b/src/scripting/luautil.h @@ -212,6 +212,11 @@ inline void push(lua_State *s, MapObject *val) LuaMapObject::push(s, val); } +inline void push(lua_State *s, MonsterClass *val) +{ + LuaMonsterClass::push(s, val); +} + /* Pushes an STL LIST */ template <typename T> |