From 8b1262b19851da3739bbca854a85a43a667c930c Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 1 Feb 2014 14:55:51 -0800 Subject: [PATCH] Export clear_npctype_cache as both lua/perl general functions. --- zone/command.cpp | 2 +- zone/embparser_api.cpp | 17 +++++++++++++++++ zone/lua_general.cpp | 7 ++++++- zone/questmgr.cpp | 6 ++++++ zone/questmgr.h | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 8af940a32..329584140 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -11477,4 +11477,4 @@ void command_npctype_cache(Client *c, const Seperator *sep) c->Message(0, "#npctype_cache [npctype_id] ..."); c->Message(0, "#npctype_cache all"); } -} \ No newline at end of file +} diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 54f9bd73e..6a7114786 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3353,6 +3353,22 @@ XS(XS__disablerecipe) XSRETURN_YES; } +XS(XS__clear_npctype_cache); +XS(XS__clear_npctype_cache) +{ + dXSARGS; + + if (items != 1) { + Perl_croak(aTHX_ "Usage: clear_npctype_cache(npc_id)"); + } + else { + int32 npctype_id = (int32)SvIV(ST(0)); + quest_manager.ClearNPCTypeCache(npctype_id); + } + + XSRETURN_EMPTY; +} + /* This is the callback perl will look for to setup the quest package's XSUBs @@ -3573,6 +3589,7 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "crosszonemessageplayerbyname"), XS__crosszonemessageplayerbyname, file); newXS(strcpy(buf, "enablerecipe"), XS__enablerecipe, file); newXS(strcpy(buf, "disablerecipe"), XS__disablerecipe, file); + newXS(strcpy(buf, "clear_npctype_cache"), XS__clear_npctype_cache, file); XSRETURN_YES; } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 571432783..1c22865c9 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1060,6 +1060,10 @@ bool lua_disable_recipe(uint32 recipe_id) { return quest_manager.DisableRecipe(recipe_id); } +void lua_clear_npctype_cache(int npctype_id) { + quest_manager.ClearNPCTypeCache(npctype_id); +} + luabind::scope lua_register_general() { return luabind::namespace_("eq") [ @@ -1226,7 +1230,8 @@ luabind::scope lua_register_general() { luabind::def("map_opcodes", &lua_map_opcodes), luabind::def("clear_opcode", &lua_clear_opcode), luabind::def("enable_recipe", &lua_enable_recipe), - luabind::def("disable_recipe", &lua_disable_recipe) + luabind::def("disable_recipe", &lua_disable_recipe), + luabind::def("clear_npctype_cache", &lua_clear_npctype_cache) ]; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 34a2e6b01..e0183852f 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2908,6 +2908,12 @@ bool QuestManager::DisableRecipe(uint32 recipe_id) return (success); } +void QuestManager::ClearNPCTypeCache(int npctype_id) { + if (zone) { + zone->ClearNPCTypeCache(npctype_id); + } +} + Client *QuestManager::GetInitiator() const { if(!quests_running_.empty()) { running_quest e = quests_running_.top(); diff --git a/zone/questmgr.h b/zone/questmgr.h index 1ea026357..7c1960283 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -233,6 +233,7 @@ public: void CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message); bool EnableRecipe(uint32 recipe_id); bool DisableRecipe(uint32 recipe_id); + void ClearNPCTypeCache(int npctype_id); Client *GetInitiator() const; NPC *GetNPC() const;