From bcf9546b2dcfa7aa883eb6c49a94a38fc8dd9967 Mon Sep 17 00:00:00 2001 From: KimLS Date: Wed, 8 May 2013 20:18:39 -0700 Subject: [PATCH] Partial perl parser rewrite, want to make it cleaner and have it match the interface --- CMakeLists.txt | 5 - common/features.h | 3 - zone/QuestInterface.h | 9 +- zone/QuestParserCollection.cpp | 229 +- zone/QuestParserCollection.h | 10 + zone/command.cpp | 101 - zone/embparser.cpp | 2987 ++++++------- zone/embparser.h | 333 +- zone/embperl.cpp | 102 +- zone/lua_parser.h | 41 +- zone/net.cpp | 14 +- zone/perlparser.cpp | 7422 ++++++++++++++++---------------- zone/perlparser.h | 50 +- zone/questmgr.h | 4 - 14 files changed, 5712 insertions(+), 5598 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0314a9be7..0948dfb9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,11 +118,6 @@ OPTION(EQEMU_BUILD_LUA "Build Lua parser." OFF) #C++11 stuff IF(NOT MSVC) ADD_DEFINITIONS(-std=c++0x) - #Rvalue-Move - todo: auto set this based on gcc version - OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF) -ELSE(NOT MSVC) - #Rvalue-Move - todo: auto set this based on msvc version - OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF) ENDIF(NOT MSVC) IF(EQEMU_ENABLE_RVALUE_MOVE) diff --git a/common/features.h b/common/features.h index f418f1bb5..72f693a57 100644 --- a/common/features.h +++ b/common/features.h @@ -54,9 +54,6 @@ Core Zone features //enable perl-based in-game command, pretty useless without EMBPERL_XS_CLASSES #define EMBPERL_COMMANDS -//enable #plugin and #peval, which requires IO::Stringy -//#define EMBPERL_EVAL_COMMANDS - #endif /* diff --git a/zone/QuestInterface.h b/zone/QuestInterface.h index 481f563be..4a6e4bab8 100644 --- a/zone/QuestInterface.h +++ b/zone/QuestInterface.h @@ -25,15 +25,16 @@ public: virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname) { return false; } virtual void LoadNPCScript(std::string filename, int npc_id) { } - //virtual void LoadGlobalNPCScript(std::string filename) { } + virtual void LoadGlobalNPCScript(std::string filename) { } virtual void LoadPlayerScript(std::string filename) { } - //virtual void LoadGlobalPlayerScript(std::string filename) { } + virtual void LoadGlobalPlayerScript(std::string filename) { } virtual void LoadItemScript(std::string filename, std::string item_script) { } virtual void LoadSpellScript(std::string filename, uint32 spell_id) { } virtual void AddVar(std::string name, std::string val) { } - virtual void ReloadQuests(bool reset_timers = true) { } - virtual uint32 GetIdentifier() { return 0; } + virtual std::string GetVar(std::string name) { return std::string(); } + virtual void ReloadQuests() { } + virtual uint32 GetIdentifier() = 0; }; #endif diff --git a/zone/QuestParserCollection.cpp b/zone/QuestParserCollection.cpp index d800c961f..052ea99f7 100644 --- a/zone/QuestParserCollection.cpp +++ b/zone/QuestParserCollection.cpp @@ -1,10 +1,11 @@ #include "../common/debug.h" #include "../common/MiscFunctions.h" +#include "../common/features.h" #include "QuestParserCollection.h" #include "QuestInterface.h" #include "zone.h" #include "zonedb.h" -#include "../common/features.h" +#include "questmgr.h" #include #include @@ -14,8 +15,8 @@ extern Zone* zone; QuestParserCollection::QuestParserCollection() { _player_quest_status = QuestUnloaded; - //_global_player_quest_status = QuestUnloaded; - //_global_npc_quest_status = QuestUnloaded; + _global_player_quest_status = QuestUnloaded; + _global_npc_quest_status = QuestUnloaded; } QuestParserCollection::~QuestParserCollection() { @@ -36,20 +37,28 @@ void QuestParserCollection::AddVar(std::string name, std::string val) { } void QuestParserCollection::ReloadQuests(bool reset_timers) { + if(reset_timers) { + quest_manager.ClearAllTimers(); + } + _npc_quest_status.clear(); _player_quest_status = QuestUnloaded; - //_global_player_quest_status = QuestUnloaded; - //_global_npc_quest_status = QuestUnloaded; + _global_player_quest_status = QuestUnloaded; + _global_npc_quest_status = QuestUnloaded; _spell_quest_status.clear(); _item_quest_status.clear(); std::list::iterator iter = _load_precedence.begin(); while(iter != _load_precedence.end()) { - (*iter)->ReloadQuests(reset_timers); + (*iter)->ReloadQuests(); iter++; } } bool QuestParserCollection::HasQuestSub(uint32 npcid, const char *subname) { + return HasQuestSubLocal(npcid, subname) || HasQuestSubGlobal(subname); +} + +bool QuestParserCollection::HasQuestSubLocal(uint32 npcid, const char *subname) { std::map::iterator iter = _npc_quest_status.find(npcid); if(iter != _npc_quest_status.end()) { @@ -74,46 +83,63 @@ bool QuestParserCollection::HasQuestSub(uint32 npcid, const char *subname) { _npc_quest_status[npcid] = QuestFailedToLoad; } } + return false; +} - //if(_global_npc_quest_status == QuestUnloaded){ - // std::string filename; - // QuestInterface *qi = GetQIByGlobalNPCQuest(filename); - // if(qi) { - // qi->LoadGlobalNPCScript(filename); - // _global_npc_quest_status = qi->GetIdentifier(); - // if(qi->HasGlobalQuestSub(subname)) { - // return true; - // } - // } - //} else { - // if(_global_npc_quest_status != QuestFailedToLoad) { - // std::map::iterator qiter = _interfaces.find(_global_npc_quest_status); - // if(qiter->second->HasGlobalQuestSub(subname)) { - // return true; - // } - // } - //} +bool QuestParserCollection::HasQuestSubGlobal(const char *subname) { + if(_global_npc_quest_status == QuestUnloaded) { + std::string filename; + QuestInterface *qi = GetQIByGlobalNPCQuest(filename); + if(qi) { + qi->LoadGlobalNPCScript(filename); + _global_npc_quest_status = qi->GetIdentifier(); + if(qi->HasGlobalQuestSub(subname)) { + return true; + } + } + } else { + if(_global_npc_quest_status != QuestFailedToLoad) { + std::map::iterator qiter = _interfaces.find(_global_npc_quest_status); + if(qiter->second->HasGlobalQuestSub(subname)) { + return true; + } + } + } return false; } bool QuestParserCollection::PlayerHasQuestSub(const char *subname) { + return PlayerHasQuestSubLocal(subname) || PlayerHasQuestSubGlobal(subname); +} + +bool QuestParserCollection::PlayerHasQuestSubLocal(const char *subname) { if(_player_quest_status == QuestUnloaded) { - std::string filename; - //QuestInterface *qi = GetQIByGlobalPlayerQuest(filename); - //if(qi) { - // _global_player_quest_status = qi->GetIdentifier(); - // qi->LoadGlobalPlayerScript(filename); - //} - + std::string filename; QuestInterface *qi = GetQIByPlayerQuest(filename); if(qi) { _player_quest_status = qi->GetIdentifier(); qi->LoadPlayerScript(filename); - return qi->PlayerHasQuestSub(subname); // || qi->GlobalPlayerHasQuestSub(subname); + return qi->PlayerHasQuestSub(subname); } } else if(_player_quest_status != QuestFailedToLoad) { std::map::iterator iter = _interfaces.find(_player_quest_status); - return iter->second->PlayerHasQuestSub(subname); // || iter->second->GlobalPlayerHasQuestSub(subname); + return iter->second->PlayerHasQuestSub(subname); + } + return false; +} + +bool QuestParserCollection::PlayerHasQuestSubGlobal(const char *subname) { + if(_global_player_quest_status == QuestUnloaded) { + std::string filename; + QuestInterface *qi = GetQIByPlayerQuest(filename); + if(qi) { + _global_player_quest_status = qi->GetIdentifier(); + qi->LoadPlayerScript(filename); + return qi->GlobalPlayerHasQuestSub(subname); + } + } else if(_global_player_quest_status != QuestFailedToLoad) { + std::map::iterator iter = _interfaces.find(_global_player_quest_status); + return iter->second->GlobalPlayerHasQuestSub(subname); } return false; } @@ -172,9 +198,14 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname) return false; } -void QuestParserCollection::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { - std::map::iterator iter = _npc_quest_status.find(npc->GetNPCTypeID()); - if(iter != _npc_quest_status.end()) { +void QuestParserCollection::EventNPC(QuestEventID evt, NPC *npc, Mob *init, std::string data, uint32 extra_data) { + EventNPCLocal(evt, npc, init, data, extra_data); + EventNPCGlobal(evt, npc, init, data, extra_data); +} + +void QuestParserCollection::EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + std::map::iterator iter = _npc_quest_status.find(npc->GetNPCTypeID()); + if(iter != _npc_quest_status.end()) { //loaded or failed to load if(iter->second != QuestFailedToLoad) { std::map::iterator qiter = _interfaces.find(iter->second); @@ -191,48 +222,40 @@ void QuestParserCollection::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std: _npc_quest_status[npc->GetNPCTypeID()] = QuestFailedToLoad; } } +} - //// K, lets also parse templates/global_npc.pl - //if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) { - // std::map::iterator qiter = _interfaces.find(_global_npc_quest_status); - // qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data); - //} else { - // std::string filename; - // QuestInterface *qi = GetQIByGlobalNPCQuest(filename); - // if(qi) { - // _global_npc_quest_status = qi->GetIdentifier(); - // qi->LoadGlobalNPCScript(filename); - // qi->EventGlobalNPC(evt, npc, init, data, extra_data); - // } else { - // _global_npc_quest_status = QuestFailedToLoad; - // } - //} +void QuestParserCollection::EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) { + std::map::iterator qiter = _interfaces.find(_global_npc_quest_status); + qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data); + } else { + std::string filename; + QuestInterface *qi = GetQIByGlobalNPCQuest(filename); + if(qi) { + _global_npc_quest_status = qi->GetIdentifier(); + qi->LoadGlobalNPCScript(filename); + qi->EventGlobalNPC(evt, npc, init, data, extra_data); + } else { + _global_npc_quest_status = QuestFailedToLoad; + } + } } void QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { + EventPlayerLocal(evt, client, data, extra_data); + EventPlayerGlobal(evt, client, data, extra_data); +} + +void QuestParserCollection::EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { if(_player_quest_status == QuestUnloaded) { std::string filename; - //QuestInterface *qi = GetQIByGlobalPlayerQuest(filename); - //if(qi) { - // _global_player_quest_status = qi->GetIdentifier(); - // qi->LoadGlobalPlayerScript(filename); - // qi->EventGlobalPlayer(evt, client, data, extra_data); - //} - QuestInterface *qi = GetQIByPlayerQuest(filename); if(qi) { _player_quest_status = qi->GetIdentifier(); qi->LoadPlayerScript(filename); qi->EventPlayer(evt, client, data, extra_data); } - } else { - //if(_global_player_quest_status != QuestFailedToLoad) { - // std::map::iterator iter = _interfaces.find(_global_player_quest_status); - // if(iter != _interfaces.end()) - // iter->second->EventGlobalPlayer(evt, client, data, extra_data); - //} - if(_player_quest_status != QuestFailedToLoad) { std::map::iterator iter = _interfaces.find(_player_quest_status); iter->second->EventPlayer(evt, client, data, extra_data); @@ -240,6 +263,23 @@ void QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::s } } +void QuestParserCollection::EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { + if(_global_player_quest_status == QuestUnloaded) { + std::string filename; + QuestInterface *qi = GetQIByGlobalPlayerQuest(filename); + if(qi) { + _global_player_quest_status = qi->GetIdentifier(); + qi->LoadGlobalPlayerScript(filename); + qi->EventGlobalPlayer(evt, client, data, extra_data); + } + } else { + if(_global_player_quest_status != QuestFailedToLoad) { + std::map::iterator iter = _interfaces.find(_global_player_quest_status); + iter->second->EventGlobalPlayer(evt, client, data, extra_data); + } + } +} + void QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) { std::string item_script; if(evt == EVENT_SCALE_CALC || evt == EVENT_ITEM_ENTERZONE) { @@ -310,6 +350,7 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -343,33 +384,14 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } iter++; } - //third look for /quests/zone/default.ext (precedence) - filename = "quests/"; - filename += zone->GetShortName(); - filename += "/"; - filename += "default"; - iter = _load_precedence.begin(); - while(iter != _load_precedence.end()) { - tmp = filename; - std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); - tmp += "."; - tmp += ext->second; - f = fopen(tmp.c_str(), "r"); - if(f) { - fclose(f); - return (*iter); - } - - iter++; - } - - //fourth look for /quests/templates/npcid.ext (precedence) + //third look for /quests/templates/npcid.ext (precedence) filename = "quests/"; filename += QUEST_TEMPLATES_DIRECTORY; filename += "/"; @@ -383,13 +405,14 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } iter++; } - //fifth look for /quests/templates/npcname.ext (precedence) + //fourth look for /quests/templates/npcname.ext (precedence) filename = "quests/"; filename += QUEST_TEMPLATES_DIRECTORY; filename += "/"; @@ -403,13 +426,35 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } iter++; } - //fifth look for /quests/templates/default.ext (precedence) + //fifth look for /quests/zone/default.ext (precedence) + filename = "quests/"; + filename += zone->GetShortName(); + filename += "/"; + filename += "default"; + iter = _load_precedence.begin(); + while(iter != _load_precedence.end()) { + tmp = filename; + std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); + tmp += "."; + tmp += ext->second; + f = fopen(tmp.c_str(), "r"); + if(f) { + fclose(f); + filename = tmp; + return (*iter); + } + + iter++; + } + + //last look for /quests/templates/default.ext (precedence) filename = "quests/"; filename += QUEST_TEMPLATES_DIRECTORY; filename += "/"; @@ -423,6 +468,7 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -455,6 +501,7 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -476,6 +523,7 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -496,6 +544,7 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -523,6 +572,7 @@ QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filena f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -550,6 +600,7 @@ QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest(std::string &fil f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -575,6 +626,7 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } @@ -600,6 +652,7 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); + filename = tmp; return (*iter); } diff --git a/zone/QuestParserCollection.h b/zone/QuestParserCollection.h index 23d4760a8..d2d518821 100644 --- a/zone/QuestParserCollection.h +++ b/zone/QuestParserCollection.h @@ -35,6 +35,16 @@ public: void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); private: + bool HasQuestSubLocal(uint32 npcid, const char *subname); + bool HasQuestSubGlobal(const char *subname); + bool PlayerHasQuestSubLocal(const char *subname); + bool PlayerHasQuestSubGlobal(const char *subname); + + void EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); + void EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); + void EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data); + void EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data); + QuestInterface *GetQIByNPCQuest(uint32 npcid, std::string &filename); QuestInterface *GetQIByGlobalNPCQuest(std::string &filename); QuestInterface *GetQIByPlayerQuest(std::string &filename); diff --git a/zone/command.cpp b/zone/command.cpp index 276caf8da..7b112c0d8 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -325,12 +325,6 @@ int command_init(void) { command_add("qglobal","[on/off/view] - Toggles qglobal functionality on an NPC",100,command_qglobal) || command_add("loc","- Print out your or your target's current location and heading",0,command_loc) || command_add("goto","[x] [y] [z] - Teleport to the provided coordinates or to your target",10,command_goto) || -#ifdef EMBPERL_PLUGIN -#ifdef EMBPERL_EVAL_COMMANDS - command_add("plugin","(sub) [args] - execute a plugin",PERL_PRIVS,command_embperl_plugin) || - command_add("peval","(expression) - execute some perl",PERL_PRIVS,command_embperl_eval) || -#endif //EMBPERL_EVAL_COMMANDS -#endif //EMBPERL_PLUGIN command_add("iteminfo","- Get information about the item on your cursor",10,command_iteminfo) || command_add("uptime","[zone server id] - Get uptime of worldserver, or zone server if argument provided",10,command_uptime) || command_add("flag","[status] [acctname] - Refresh your admin status, or set an account's admin status if arguments provided",0,command_flag) || @@ -6400,101 +6394,6 @@ void command_stun(Client *c, const Seperator *sep) c->Message(0, "Usage: #stun [duration]"); } -#ifdef EMBPERL_PLUGIN -#ifdef EMBPERL_EVAL_COMMANDS - -void command_embperl_plugin(Client *c, const Seperator *sep) -{ - if(sep->arg[1][0] == 0) - { - c->Message(0, "Usage: #plugin (subname) [arguments]"); - return; - } - - Embperl * perl; - if(!parse || !(perl = ((PerlembParser *)parse)->getperl())) - { - c->Message(0, "Error: Perl module not loaded"); - return; - } - - std::string exports = "$plugin::printbuff='';$plugin::ip='"; - struct in_addr ip; ip.s_addr = c->GetIP(); - exports += inet_ntoa(ip); - exports += "';$plugin::name=qq("; - exports += c->GetName(); - exports += ");package plugin;"; - perl->eval(exports.c_str()); - - std::string fqsubname("plugin::"); - fqsubname.append(sep->arg[1]); - - //convert args into a vector of strings. - std::vector args; - for(int i = 2; i < sep->argnum; ++i) - { - args.push_back(sep->arg[i]); - } - - try - { - perl->dosub(fqsubname.c_str(), &args); - std::string output = perl->getstr("$plugin::printbuff"); - if(output.length()) - c->Message(0, "%s", output.c_str()); - } - catch(const char * err) - { - c->Message(0, "Error executing plugin: %s", perl->lasterr().c_str()); - } - - perl->eval("package main;"); - -} - -void command_embperl_eval(Client *c, const Seperator *sep) -{ - if(sep->arg[1][0] == 0) - { - c->Message(0, "Usage: #peval (expr)"); - return; - } - - Embperl * perl; - if(!parse || !(perl = ((PerlembParser *)parse)->getperl())) - { - c->Message(0, "Error: Perl module not loaded"); - return; - } - - std::string exports = "$plugin::printbuff='';$plugin::ip='"; - struct in_addr ip; ip.s_addr = c->GetIP(); - exports += inet_ntoa(ip); - exports += "';$plugin::name=qq("; - exports += c->GetName(); - exports += ");"; - perl->eval(exports.c_str()); - - try - { - std::string cmd = std::string("package plugin;") + std::string(sep->msg + sizeof("peval ")); - perl->eval(cmd.c_str()); - std::string output = perl->getstr("$plugin::printbuff"); - if(output.length()) - c->Message(0, "%s", output.c_str()); - } - catch(const char * err) - { - c->Message(0, "Error: %s", perl->lasterr().c_str()); - } - - perl->eval("package main;"); - -} - -#endif //EMBPERL_PLUGIN -#endif //EMBPERL_EVAL_COMMANDS - void command_ban(Client *c, const Seperator *sep) { char errbuf[MYSQL_ERRMSG_SIZE]; diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 64d28469a..b41607d6f 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1,5 +1,5 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) + Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,16 +16,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//extends the parser to include perl - -#ifndef EMBPARSER_CPP -#define EMBPARSER_CPP #ifdef EMBPERL #include "../common/debug.h" #include "masterentity.h" -#include "../common/features.h" #include "embparser.h" #include "questmgr.h" #include "command.h" @@ -33,10 +28,10 @@ #include "../common/MiscFunctions.h" #include "QGlobals.h" #include "zone.h" - #include -//these MUST be in the same order as the QuestEventID enum +extern Zone* zone; + const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_SAY", "EVENT_ITEM", @@ -72,7 +67,7 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_PROXIMITY_SAY", "EVENT_CAST", "EVENT_SCALE_CALC", - "EVENT_ITEM_ENTERZONE", + "EVENT_ITEM_ENTERZONE", "EVENT_TARGET_CHANGE", "EVENT_HATE_LIST", "EVENT_SPELL_EFFECT_CLIENT", @@ -96,41 +91,690 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_CONNECT" }; -extern Zone* zone; - -PerlembParser::PerlembParser(void) : Parser() -{ - perl = nullptr; - eventQueueProcessing = false; - globalPlayerQuestLoaded = pQuestReadyToLoad; - globalNPCQuestLoaded = nQuestReadyToLoad; +PerlembParser::PerlembParser() : perl(nullptr) { + global_npc_quest_status_ = questUnloaded; + player_quest_status_ = questUnloaded; + global_player_quest_status_ = questUnloaded; } -PerlembParser::~PerlembParser() -{ +PerlembParser::~PerlembParser() { safe_delete(perl); } -void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, const char * value) const +void PerlembParser::ReloadQuests() { + command_clear_perl(); + + try { + if(perl == nullptr) { + perl = new Embperl; + } else { + perl->Reinit(); + } + MapFunctions(); + } + catch(std::exception &e) { + if(perl != nullptr) { + delete perl; + perl = nullptr; + } + + LogFile->write(EQEMuLog::Status, "Error re-initializing perlembed: %s", e.what()); + throw e.what(); + } + + npc_quest_status_.clear(); + global_npc_quest_status_ = questUnloaded; + player_quest_status_ = questUnloaded; + global_player_quest_status_ = questUnloaded; + item_quest_status_.clear(); + spell_quest_status_.clear(); +} + +void PerlembParser::MapFunctions() { +} + +void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, + uint32 extradata, bool global) { if(!perl) return; - //this crap cant possibly throw anything in its current state... oh well - try - { - perl->setstr(std::string(pkgprefix).append("::").append(varname).c_str(), value); - //todo: consider replacing ' w/ ", so that values can be expanded on the perl side - } - catch(const char * err) - { //todo: consider rethrowing - LogFile->write(EQEMuLog::Status, "Error exporting var: %s", err); + + if(event >= _LargestEventID) + return; + + if(perl->InUse()) { + //PERL_TODO queue event + return; } } -// Exports key-value pairs to a hash named pkgprefix::hashname -void PerlembParser::ExportHash(const char *pkgprefix, const char *hashname, std::map &vals) +void PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data, false); +} + +void PerlembParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data, true); +} + +void PerlembParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { + EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data, false); +} + +void PerlembParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { + EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data, true); +} + +void PerlembParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) { + EventCommon(evt, objid, nullptr, nullptr, item, client, extra_data, false); +} + +void PerlembParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { + EventCommon(evt, 0, itoa(spell_id), npc, nullptr, client, extra_data, false); +} + +bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) { + return false; +} + +bool PerlembParser::HasGlobalQuestSub(const char *subname) { + return false; +} + +bool PerlembParser::PlayerHasQuestSub(const char *subname) { + return false; +} + +bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { + return false; +} + +bool PerlembParser::SpellHasQuestSub(uint32 spell_id, const char *subname) { + return false; +} + +bool PerlembParser::ItemHasQuestSub(ItemInst *itm, const char *subname) { + return false; +} + +////int PerlembParser::LoadScript(int npcid, const char * zone, Mob* activater) +////{ +//// if(!perl) +//// { +//// return(0); +//// } +//// +//// //we have already tried to load this quest... +//// if(hasQuests.count(npcid) == 1) +//// { +//// return(1); +//// } +//// +//// string filename = "quests/", packagename = GetPkgPrefix(npcid); +//// //each package name is of the form qstxxxx where xxxx = npcid (since numbers alone are not valid package names) +//// questMode curmode = questDefault; +//// FILE *tmpf; +//// //LogFile->write(EQEMuLog::Debug, "LoadScript(%d, %s):\n", npcid, zone); +//// if(!npcid || !zone) +//// { +//// //Load quests/default.pl +//// filename += DEFAULT_QUEST_PREFIX; +//// filename += ".pl"; +//// curmode = questDefault; +//// } +//// else +//// { +//// filename += zone; +//// filename += "/"; +////#ifdef QUEST_SCRIPTS_BYNAME +//// string bnfilename = filename; +////#endif +//// filename += itoa(npcid); +//// filename += ".pl"; +//// curmode = questByID; +//// +////#ifdef QUEST_SCRIPTS_BYNAME +//// //assuming name limit stays 64 chars. +//// char tmpname[64]; +//// int count0 = 0; +//// bool filefound = false; +//// tmpf = fopen(filename.c_str(), "r"); +//// if(tmpf != NULL) +//// { +//// fclose(tmpf); +//// filefound = true; +//// } +//// //LogFile->write(EQEMuLog::Debug, " tried '%s': %d", filename.c_str(), filefound); +//// +//// tmpname[0] = 0; +//// //if there is no file for the NPC's ID, try for the NPC's name +//// if(!filefound) +//// { +//// //revert to just path +//// filename = bnfilename; +//// const NPCType *npct = database.GetNPCType(npcid); +//// if(npct == NULL) +//// { +//// //LogFile->write(EQEMuLog::Debug, " no npc type"); +//// //revert and go on with life +//// filename += itoa(npcid); +//// filename += ".pl"; +//// curmode = questByID; +//// } +//// else +//// { +//// //trace out the ` characters, turn into - +//// int nlen = strlen(npct->name); +//// //just to make sure +//// if(nlen < 64) +//// { +//// int r; +//// //this should get our NULL as well.. +//// for(r = 0; r <= nlen; r++) +//// { +//// tmpname[r] = npct->name[r]; +//// +//// //watch for 00 delimiter +//// if(tmpname[r] == '0') +//// { +//// count0++; +//// //second '0' +//// if(count0 > 1) +//// { +//// //stop before previous 0 +//// tmpname[r-1] = '\0'; +//// break; +//// } +//// } +//// else +//// { +//// count0 = 0; +//// } +//// +//// //rewrite ` to be more file name friendly +//// if(tmpname[r] == '`') +//// { +//// tmpname[r] = '-'; +//// } +//// +//// } +//// filename += tmpname; +//// filename += ".pl"; +//// curmode = questByName; +//// } +//// else +//// { +//// //LogFile->write(EQEMuLog::Debug, " namelen too long"); +//// //revert and go on with life, again +//// filename += itoa(npcid); +//// filename += ".pl"; +//// curmode = questByID; +//// } +//// } +//// } +//// +////#ifdef QUEST_TEMPLATES_BYNAME +//// +//// tmpf = fopen(filename.c_str(), "r"); +//// if(tmpf != NULL) +//// { +//// fclose(tmpf); +//// filefound = true; +//// } +//// +//// +//// //LogFile->write(EQEMuLog::Debug, " tried '%s': %d", filename.c_str(), filefound2); +//// +//// //if there is no file for the NPC's ID or name, +//// //try for the NPC's name in the templates directory +//// //only works if we have gotten the NPC's name above +//// if(!filefound) +//// { +//// if(tmpname[0] != 0) +//// { +//// //revert to just path +//// filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/"; +//// filename += tmpname; +//// filename += ".pl"; +//// curmode = questTemplate; +//// //LogFile->write(EQEMuLog::Debug, " template '%s'", filename.c_str(), filefound2); +//// } +//// else +//// { +//// //LogFile->write(EQEMuLog::Debug, " no template name"); +//// filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/"; +//// filename += itoa(npcid); +//// filename += ".pl"; +//// curmode = questTemplateByID; +//// } +//// } +//// +////#endif //QUEST_TEMPLATES_BYNAME +//// +////#endif //QUEST_SCRIPTS_BYNAME +//// +//// tmpf = fopen(filename.c_str(), "r"); +//// if(tmpf != NULL) +//// { +//// fclose(tmpf); +//// filefound = true; +//// } +//// +//// // If by ID, Name or Template wasn't found, load /quests/zone/default.pl +//// if(!filefound) +//// { +//// //Load Default Quests Per Zone quests/zonename/default.pl +//// filename = bnfilename; +//// filename += "default.pl"; +//// curmode = questDefaultByZone; +//// //LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str()); +//// } +//// +//// tmpf = fopen(filename.c_str(), "r"); +//// if(tmpf != NULL) +//// { +//// fclose(tmpf); +//// filefound = true; +//// } +//// +//// // If zone template isn't found look for it globally /quests/template/default.pl +//// if(!filefound) +//// { +//// //Load Default Quests Globally +//// //filename = bnfilename; +//// filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/"; +//// filename += "default.pl"; +//// curmode = questDefaultByZone; +//// //LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str()); +//// } +//// } +//// +//// //check for existance of quest file before trying to make perl load it. +//// tmpf = fopen(filename.c_str(), "r"); +//// if(tmpf == NULL) +//// { +//// //the npc has no qst file, attach the defaults +//// std::string setdefcmd = "$"; +//// setdefcmd += packagename; +//// setdefcmd += "::isdefault = 1;"; +//// perl->eval(setdefcmd.c_str()); +//// setdefcmd = "$"; +//// setdefcmd += packagename; +//// setdefcmd += "::isloaded = 1;"; +//// perl->eval(setdefcmd.c_str()); +//// hasQuests[npcid] = questDefault; +//// return(1); +//// } +//// else +//// { +//// fclose(tmpf); +//// } +//// +//// //LogFile->write(EQEMuLog::Debug, " finally settling on '%s'", filename.c_str()); +//// // LogFile->write(EQEMuLog::Status, "Looking for quest file: '%s'", filename.c_str()); +//// +//// // todo: decide whether or not to delete the package to allow for script refreshes w/o restarting the server +//// // remember to guard against deleting the default package, on a similar note... consider deleting packages upon zone change +//// // try { perl->eval(std::string("delete_package(\"").append(packagename).append("\");").c_str()); } +//// // catch(...) {/*perl balked at us trynig to delete a non-existant package... no big deal.*/} +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// //try to reduce some of the console spam... +//// //todo: tweak this to be more accurate at deciding what to filter (we don't want to gag legit errors) +//// //if(!strstr(err,"No such file or directory")) +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s (reverting to default questfile)", filename.c_str(), err); +//// } +//// //todo: change this to just read eval_file's %cache - duh! +//// if(!isloaded(packagename.c_str())) +//// { +//// //the npc has no qst file, attach the defaults +//// std::string setdefcmd = "$"; +//// setdefcmd += packagename; +//// setdefcmd += "::isdefault = 1;"; +//// perl->eval(setdefcmd.c_str()); +//// setdefcmd = "$"; +//// setdefcmd += packagename; +//// setdefcmd += "::isloaded = 1;"; +//// perl->eval(setdefcmd.c_str()); +//// curmode = questDefault; +//// } +//// +//// hasQuests[npcid] = curmode; +//// return(1); +////} +//// +////int PerlembParser::LoadGlobalNPCScript() +////{ +//// if(!perl) +//// return 0; +//// +//// if(perl->InUse()) +//// { +//// return 0; +//// } +//// +//// if(globalNPCQuestLoaded != nQuestReadyToLoad) { +//// return 1; +//// } +//// +//// string filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/global_npc.pl"; +//// string packagename = "global_npc"; +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// +//// globalNPCQuestLoaded = nQuestLoaded; +//// +//// return 1; +////} +//// +////int PerlembParser::LoadPlayerScript(const char *zone_name) +////{ +//// if(!perl) +//// return 0; +//// +//// if(perl->InUse()) +//// { +//// return 0; +//// } +//// +//// if(playerQuestLoaded.count(zone_name) == 1) { +//// return 1; +//// } +//// +//// string filename= "quests/"; +//// filename += zone_name; +//// filename += "/player_v"; +//// filename += itoa(zone->GetInstanceVersion()); +//// filename += ".pl"; +//// string packagename = "player"; +//// packagename += "_"; +//// packagename += zone_name; +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// +//// if(!isloaded(packagename.c_str())) +//// { +//// filename= "quests/"; +//// filename += zone_name; +//// filename += "/player.pl"; +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// } +//// +//// //todo: change this to just read eval_file's %cache - duh! +//// if(!isloaded(packagename.c_str())) +//// { +//// filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/player.pl"; +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// if(!isloaded(packagename.c_str())) +//// { +//// playerQuestLoaded[zone_name] = pQuestUnloaded; +//// return 0; +//// } +//// } +//// +//// if(perl->SubExists(packagename.c_str(), "EVENT_CAST")) +//// playerQuestLoaded[zone_name] = pQuestEventCast; +//// else +//// playerQuestLoaded[zone_name] = pQuestLoaded; +//// return 1; +////} +//// +////int PerlembParser::LoadGlobalPlayerScript() +////{ +//// if(!perl) +//// return 0; +//// +//// if(perl->InUse()) +//// { +//// return 0; +//// } +//// +//// if(globalPlayerQuestLoaded != pQuestReadyToLoad) { +//// return 1; +//// } +//// +//// string filename = "quests/"; +//// filename += QUEST_TEMPLATES_DIRECTORY; +//// filename += "/global_player.pl"; +//// string packagename = "global_player"; +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char * err) +//// { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// +//// if(perl->SubExists(packagename.c_str(), "EVENT_CAST")) +//// globalPlayerQuestLoaded = pQuestEventCast; +//// else +//// globalPlayerQuestLoaded = pQuestLoaded; +//// return 1; +////} +//// +////int PerlembParser::LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype) { +//// if(!perl) +//// return 0; +//// +//// if(perl->InUse()) +//// { +//// return 0; +//// } +//// +//// // if we've already tried to load it, don't try again +//// if(itemQuestLoaded.count(packagename) == 1) +//// return 1; +//// +//// string filename = "quests/items/"; +//// if(Qtype == itemQuestScale) +//// filename += packagename; +//// else if(Qtype == itemQuestLore) { +//// filename += "lore_"; +//// filename += itoa(iteminst->GetItem()->LoreGroup); +//// } +//// else if(Qtype == itemScriptFileID) { +//// filename += "script_"; +//// filename += itoa(iteminst->GetItemScriptID()); +//// } +//// else +//// filename += itoa(iteminst->GetID()); +//// filename += ".pl"; +//// printf("Loading file %s\n",filename.c_str()); +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char* err) { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// +//// if(!isloaded(packagename.c_str())) { +//// itemQuestLoaded[packagename] = Qtype; +//// return 0; +//// } +//// +//// itemQuestLoaded[packagename] = itemQuestUnloaded; +//// return 1; +////} +//// +////int PerlembParser::LoadSpellScript(uint32 id) +////{ +//// if(!perl) +//// return 0; +//// +//// if(perl->InUse()) +//// { +//// return 0; +//// } +//// +//// // if we've already tried to load it, don't try again +//// if(spellQuestLoaded.count(id) == 1) +//// return 1; +//// +//// string filename = "quests/spells/"; +//// string packagename = "spell_effect_"; +//// filename += itoa(id); +//// packagename += itoa(id); +//// filename += ".pl"; +//// printf("Loading file %s\n", filename.c_str()); +//// +//// try { +//// perl->eval_file(packagename.c_str(), filename.c_str()); +//// } +//// catch(const char* err) { +//// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); +//// } +//// +//// if(!isloaded(packagename.c_str())) { +//// spellQuestLoaded[id] = spellQuestFailed; +//// return 0; +//// } +//// +//// spellQuestLoaded[id] = spellQuestFullyLoaded; +//// return 1; +////} + +void PerlembParser::LoadNPCScript(std::string filename, int npc_id) { + printf("Load NPC %d = %s\n", npc_id, filename.c_str()); +} + +void PerlembParser::LoadGlobalNPCScript(std::string filename) { + printf("%s %s\n", "qst_global_npc", filename.c_str()); + if(!perl) + return; + + if(perl->InUse()) + { + return; + } + + if(global_npc_quest_status_ != questUnloaded) { + return; + } + + try { + perl->eval_file("qst_global_npc", filename.c_str()); + } + catch(const char *err) + { + LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); + global_npc_quest_status_ = questFailedToLoad; + return; + } + + global_npc_quest_status_ = questLoaded; +} + +void PerlembParser::LoadPlayerScript(std::string filename) { + printf("%s %s\n", "qst_player", filename.c_str()); + if(!perl) + return; + + if(perl->InUse()) + { + return; + } + + if(player_quest_status_ != questUnloaded) { + return; + } + + try { + perl->eval_file("qst_player", filename.c_str()); + } + catch(const char *err) + { + LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); + player_quest_status_ = questFailedToLoad; + return; + } + + player_quest_status_ = questLoaded; +} + +void PerlembParser::LoadGlobalPlayerScript(std::string filename) { + printf("%s %s\n", "qst_global_player", filename.c_str()); + if(!perl) + return; + + if(perl->InUse()) + { + return; + } + + if(global_player_quest_status_ != questUnloaded) { + return; + } + + try { + perl->eval_file("qst_global_player", filename.c_str()); + } + catch(const char *err) + { + LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); + global_player_quest_status_ = questFailedToLoad; + return; + } + + global_player_quest_status_ = questLoaded; +} + +void PerlembParser::LoadItemScript(std::string filename, std::string item_script) { + printf("Load Spell %s = %s\n", item_script.c_str(), filename.c_str()); +} + +void PerlembParser::LoadSpellScript(std::string filename, uint32 spell_id) { + printf("Load Item %d = %s\n", spell_id, filename.c_str()); +} + +void PerlembParser::AddVar(std::string name, std::string val) { +} + +std::string PerlembParser::GetVar(std::string name) { + return std::string(); +} + +void PerlembParser::ExportHash(const char *pkgprefix, const char *hashname, std::map &vals) { - if (!perl) + if(!perl) return; try @@ -139,7 +783,7 @@ void PerlembParser::ExportHash(const char *pkgprefix, const char *hashname, std: std::string(pkgprefix).append("::").append(hashname).c_str(), vals ); - } catch(const char * err) { + } catch(const char *err) { LogFile->write(EQEMuLog::Status, "Error exporting hash: %s", err); } } @@ -149,7 +793,7 @@ void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, int if(!perl) return; - //this crap cant possibly throw anything in its current state... oh well + try { perl->seti(std::string(pkgprefix).append("::").append(varname).c_str(), value); @@ -163,7 +807,7 @@ void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, unsi if(!perl) return; - //this crap cant possibly throw anything in its current state... oh well + try { perl->seti(std::string(pkgprefix).append("::").append(varname).c_str(), value); @@ -177,7 +821,7 @@ void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, floa if(!perl) return; - //this crap cant possibly throw anything in its current state... oh well + try { perl->setd(std::string(pkgprefix).append("::").append(varname).c_str(), value); } catch(const char * err) { @@ -185,1493 +829,946 @@ void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, floa } } -void PerlembParser::ExportVarComplex(const char * pkgprefix, const char * varname, const char * value) const +void PerlembParser::ExportVarComplex(const char * pkgprefix, const char *varname, const char *value) const { if(!perl) return; try { - //todo: consider replacing ' w/ ", so that values can be expanded on the perl side perl->eval(std::string("$").append(pkgprefix).append("::").append(varname).append("=").append(value).append(";").c_str()); } catch(const char * err) - { //todo: consider rethrowing + { LogFile->write(EQEMuLog::Status, "Error exporting var: %s", err); } } -void PerlembParser::HandleQueue() { - if(eventQueueProcessing) - return; - eventQueueProcessing = true; - - while(!eventQueue.empty()) { - EventRecord e = eventQueue.front(); - eventQueue.pop(); - - EventCommon(e.event, e.objid, e.data.c_str(), e.npcmob, e.iteminst, e.mob, e.extradata, e.global); - } - - eventQueueProcessing = false; -} - -void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global) +void PerlembParser::ExportVar(const char *pkgprefix, const char *varname, const char *value) const { if(!perl) return; - if(event >= _LargestEventID) - return; - - if(perl->InUse()) { - //queue the event for later. - EventRecord e; - e.event = event; - e.objid = objid; - if(data != nullptr) - e.data = data; - e.npcmob = npcmob; - e.iteminst = iteminst; - e.mob = mob; - e.extradata = extradata; - e.global = global; - eventQueue.push(e); - return; - } - - bool isPlayerQuest = false; - bool isGlobalPlayerQuest = false; - bool isGlobalNPC = false; - bool isItemQuest = false; - bool isSpellQuest = false; - if(event == EVENT_SPELL_EFFECT_CLIENT || - event == EVENT_SPELL_EFFECT_NPC || - event == EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT || - event == EVENT_SPELL_EFFECT_BUFF_TIC_NPC || - event == EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE) + try { - isSpellQuest = true; + perl->setstr(std::string(pkgprefix).append("::").append(varname).c_str(), value); } - else + catch(const char * err) { - if(!npcmob && mob) { - if(!iteminst) { - if(global) { - isGlobalPlayerQuest = true; - } else { - isPlayerQuest = true; - } - } - else - isItemQuest = true; - } + LogFile->write(EQEMuLog::Status, "Error exporting var: %s", err); } +} - string packagename; - if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest){ +void PerlembParser::SendCommands(const char *pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst) { +} - if(global){ - isGlobalNPC = true; - packagename = "global_npc"; - } else { - - packagename = GetPkgPrefix(objid); - } - } - else if(isItemQuest) { - const Item_Struct* item = iteminst->GetItem(); - if (!item) return; - - if (event == EVENT_SCALE_CALC || event == EVENT_ITEM_ENTERZONE) { - packagename = item->CharmFile; - } - else if (event == EVENT_ITEM_CLICK || event == EVENT_ITEM_CLICK_CAST) { - packagename = "script_"; - packagename += itoa(item->ScriptFileID); - } - else { - packagename = "item_"; - packagename += itoa(objid); - } - } - else if(isPlayerQuest) { - if(!zone || !zone->GetShortName()) // possible segfault fix - return; - packagename = "player"; - packagename += "_"; - packagename += zone->GetShortName(); - } - else if(isGlobalPlayerQuest) { - packagename = "global_player"; - } - else - { - packagename = "spell_effect_"; - packagename += data; - } - - const char *sub_name = QuestEventSubroutines[event]; - - //make sure the sub we need even exists before we even do all this crap. - if(!perl->SubExists(packagename.c_str(), sub_name)) { - return; - } - - int charid = 0; - if (mob && mob->IsClient()) { // some events like waypoint and spawn don't have a player involved - charid = mob->CastToClient()->CharacterID(); - } else { - if(npcmob) - { - charid = -npcmob->GetNPCTypeID(); // make char id negative npc id as a fudge - } - else if(mob && mob->IsNPC()) - { - charid = -mob->CastToNPC()->GetNPCTypeID(); // make char id negative npc id as a fudge - } - } - ExportVar(packagename.c_str(), "charid", charid); - - //NPC quest - if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest) - { - //only export for npcs that are global enabled. - if(npcmob && npcmob->GetQglobal()) - { - map globhash; - QGlobalCache *npc_c = nullptr; - QGlobalCache *char_c = nullptr; - QGlobalCache *zone_c = nullptr; - - //retrieve our globals - npc_c = npcmob->GetQGlobals(); - if(mob && mob->IsClient()) - char_c = mob->CastToClient()->GetQGlobals(); - zone_c = zone->GetQGlobals(); - - if(!npc_c) - { - npc_c = npcmob->CreateQGlobals(); - npc_c->LoadByNPCID(npcmob->GetNPCTypeID()); - } - - if(!char_c) - { - if(mob && mob->IsClient()) - { - char_c = mob->CastToClient()->CreateQGlobals(); - char_c->LoadByCharID(mob->CastToClient()->CharacterID()); - } - } - - if(!zone_c) - { - zone_c = zone->CreateQGlobals(); - zone_c->LoadByZoneID(zone->GetZoneID()); - zone_c->LoadByGlobalContext(); - } - - std::list globalMap; - if(npc_c) - { - QGlobalCache::Combine(globalMap, npc_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); - } - - if(char_c) - { - QGlobalCache::Combine(globalMap, char_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); - } - - if(zone_c) - { - QGlobalCache::Combine(globalMap, zone_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); - } - - std::list::iterator iter = globalMap.begin(); - while(iter != globalMap.end()) - { - globhash[(*iter).name] = (*iter).value; - ExportVar(packagename.c_str(), (*iter).name.c_str(), (*iter).value.c_str()); - ++iter; - } - ExportHash(packagename.c_str(), "qglobals", globhash); - } - } - else - { - map globhash; - QGlobalCache *char_c = nullptr; - QGlobalCache *zone_c = nullptr; - - //retrieve our globals - if(mob && mob->IsClient()) - char_c = mob->CastToClient()->GetQGlobals(); - zone_c = zone->GetQGlobals(); - - if(!char_c) - { - if(mob && mob->IsClient()) - { - char_c = mob->CastToClient()->CreateQGlobals(); - char_c->LoadByCharID(mob->CastToClient()->CharacterID()); - } - } - - if(!zone_c) - { - zone_c = zone->CreateQGlobals(); - zone_c->LoadByZoneID(zone->GetZoneID()); - zone_c->LoadByGlobalContext(); - } - - std::list globalMap; - if(char_c) - { - QGlobalCache::Combine(globalMap, char_c->GetBucket(), 0, charid, zone->GetZoneID()); - } - - if(zone_c) - { - QGlobalCache::Combine(globalMap, zone_c->GetBucket(), 0, charid, zone->GetZoneID()); - } - - std::list::iterator iter = globalMap.begin(); - while(iter != globalMap.end()) - { - globhash[(*iter).name] = (*iter).value; - ExportVar(packagename.c_str(), (*iter).name.c_str(), (*iter).value.c_str()); - ++iter; - } - ExportHash(packagename.c_str(), "qglobals", globhash); - } - - uint8 fac = 0; - if (mob && mob->IsClient()) { - ExportVar(packagename.c_str(), "uguild_id", mob->CastToClient()->GuildID()); - ExportVar(packagename.c_str(), "uguildrank", mob->CastToClient()->GuildRank()); - ExportVar(packagename.c_str(), "status", mob->CastToClient()->Admin()); - } - - if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest){ - if (mob && npcmob && mob->IsClient() && npcmob->IsNPC()) { - Client* client = mob->CastToClient(); - NPC* npc = npcmob->CastToNPC(); - - // Need to figure out why one of these casts would fail.. - if (client && npc) { - fac = client->GetFactionLevel(client->CharacterID(), npcmob->GetID(), client->GetRace(), client->GetClass(), client->GetDeity(), npc->GetPrimaryFaction(), npcmob); - } - else if (!client) { - LogFile->write(EQEMuLog::Status, "WARNING: cast failure on mob->CastToClient()"); - } - else if (!npc) { - LogFile->write(EQEMuLog::Status, "WARNING: cast failure on npcmob->CastToNPC()"); - } - } - } - if (mob) { - ExportVar(packagename.c_str(), "name", mob->GetName()); - ExportVar(packagename.c_str(), "race", GetRaceName(mob->GetRace())); - ExportVar(packagename.c_str(), "class", GetEQClassName(mob->GetClass())); - ExportVar(packagename.c_str(), "ulevel", mob->GetLevel()); - ExportVar(packagename.c_str(), "userid", mob->GetID()); - } - - if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest) - { - if (npcmob) - { - ExportVar(packagename.c_str(), "mname", npcmob->GetName()); - ExportVar(packagename.c_str(), "mobid", npcmob->GetID()); - ExportVar(packagename.c_str(), "mlevel", npcmob->GetLevel()); - ExportVar(packagename.c_str(), "hpratio",npcmob->GetHPRatio()); - ExportVar(packagename.c_str(), "x", npcmob->GetX() ); - ExportVar(packagename.c_str(), "y", npcmob->GetY() ); - ExportVar(packagename.c_str(), "z", npcmob->GetZ() ); - ExportVar(packagename.c_str(), "h", npcmob->GetHeading() ); - if ( npcmob->GetTarget() ) { - ExportVar(packagename.c_str(), "targetid", npcmob->GetTarget()->GetID()); - ExportVar(packagename.c_str(), "targetname", npcmob->GetTarget()->GetName()); - } - } - - if (fac) { - ExportVar(packagename.c_str(), "faction", itoa(fac)); - } - } - - if (zone) { - ExportVar(packagename.c_str(), "zoneid", zone->GetZoneID()); - ExportVar(packagename.c_str(), "zoneln", zone->GetLongName()); - ExportVar(packagename.c_str(), "zonesn", zone->GetShortName()); - ExportVar(packagename.c_str(), "instanceid", zone->GetInstanceID()); - ExportVar(packagename.c_str(), "instanceversion", zone->GetInstanceVersion()); - TimeOfDay_Struct eqTime; - zone->zone_time.getEQTimeOfDay( time(0), &eqTime); - ExportVar(packagename.c_str(), "zonehour", eqTime.hour - 1); - ExportVar(packagename.c_str(), "zonemin", eqTime.minute); - ExportVar(packagename.c_str(), "zonetime", (eqTime.hour - 1) * 100 + eqTime.minute); - ExportVar(packagename.c_str(), "zoneweather", zone->zone_weather); - } - -// $hasitem -#define HASITEM_FIRST 0 -#define HASITEM_LAST 29 // this includes worn plus 8 base slots -#define HASITEM_ISNULLITEM(item) ((item==-1) || (item==0)) - - if(mob && mob->IsClient()) - { - string hashname = packagename + std::string("::hasitem"); -#if EQDEBUG >= 7 - LogFile->write(EQEMuLog::Debug, "starting hasitem, on : %s",hashname.c_str() ); #endif - //start with an empty hash - perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); - for(int slot=HASITEM_FIRST; slot<=HASITEM_LAST;slot++) - { - char *hi_decl=nullptr; - int itemid=mob->CastToClient()->GetItemIDAt(slot); - if(!HASITEM_ISNULLITEM(itemid)) - { - MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(),itemid,slot); -// this is annoying -#if EQDEBUG >= 7 - LogFile->write(EQEMuLog::Debug, "declare hasitem : %s",hi_decl); -#endif - perl->eval(hi_decl); - safe_delete_array(hi_decl); - } - } - } -// $oncursor - if(mob && mob->IsClient()) { - string hashname = packagename + std::string("::oncursor"); - perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); - char *hi_decl = nullptr; - int itemid = mob->CastToClient()->GetItemIDAt(30); - if(!HASITEM_ISNULLITEM(itemid)) { - MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(),itemid,30); - perl->eval(hi_decl); - safe_delete_array(hi_decl); - } - } - //do any event-specific stuff... - switch (event) { - case EVENT_SAY: { - if (npcmob && npcmob->GetAppearance() != eaDead) - npcmob->FaceTarget(mob); - ExportVar(packagename.c_str(), "data", objid); - ExportVar(packagename.c_str(), "text", data); - ExportVar(packagename.c_str(), "langid", extradata); - break; - } - case EVENT_ITEM: { - if (npcmob->GetAppearance() != eaDead) - npcmob->FaceTarget(mob); - //this is such a hack... why aren't these just set directly.. - ExportVar(packagename.c_str(), "item1", GetVar("item1", objid).c_str()); - ExportVar(packagename.c_str(), "item2", GetVar("item2", objid).c_str()); - ExportVar(packagename.c_str(), "item3", GetVar("item3", objid).c_str()); - ExportVar(packagename.c_str(), "item4", GetVar("item4", objid).c_str()); - ExportVar(packagename.c_str(), "item1_charges", GetVar("item1.charges", objid).c_str()); - ExportVar(packagename.c_str(), "item2_charges", GetVar("item2.charges", objid).c_str()); - ExportVar(packagename.c_str(), "item3_charges", GetVar("item3.charges", objid).c_str()); - ExportVar(packagename.c_str(), "item4_charges", GetVar("item4.charges", objid).c_str()); - ExportVar(packagename.c_str(), "item1_attuned", GetVar("item1.attuned", objid).c_str()); - ExportVar(packagename.c_str(), "item2_attuned", GetVar("item2.attuned", objid).c_str()); - ExportVar(packagename.c_str(), "item3_attuned", GetVar("item3.attuned", objid).c_str()); - ExportVar(packagename.c_str(), "item4_attuned", GetVar("item4.attuned", objid).c_str()); - ExportVar(packagename.c_str(), "copper", GetVar("copper", objid).c_str()); - ExportVar(packagename.c_str(), "silver", GetVar("silver", objid).c_str()); - ExportVar(packagename.c_str(), "gold", GetVar("gold", objid).c_str()); - ExportVar(packagename.c_str(), "platinum", GetVar("platinum", objid).c_str()); - string hashname = packagename + std::string("::itemcount"); - perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); - perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item1};").c_str()); - perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item2};").c_str()); - perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item3};").c_str()); - perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item4};").c_str()); - break; - } - case EVENT_WAYPOINT_ARRIVE: - case EVENT_WAYPOINT_DEPART: { - ExportVar(packagename.c_str(), "wp", data); - break; - } - case EVENT_HP: { - if (extradata == 1) { - ExportVar(packagename.c_str(), "hpevent", "-1"); - ExportVar(packagename.c_str(), "inchpevent", data); - } - else - { - ExportVar(packagename.c_str(), "hpevent", data); - ExportVar(packagename.c_str(), "inchpevent", "-1"); - } - break; -} - case EVENT_TIMER: { - ExportVar(packagename.c_str(), "timer", data); - break; - } - case EVENT_SIGNAL: { - ExportVar(packagename.c_str(), "signal", data); - break; - } - case EVENT_NPC_SLAY: { - ExportVar(packagename.c_str(), "killed", mob->GetNPCTypeID()); - break; - } - case EVENT_COMBAT: { - ExportVar(packagename.c_str(), "combat_state", data); - break; - } - - case EVENT_CLICKDOOR: { - Seperator *sep = new Seperator(data); - ExportVar(packagename.c_str(), "doorid", sep->arg[0]); - ExportVar(packagename.c_str(), "version", sep->arg[1]); - break; - } - - case EVENT_LOOT:{ - Seperator *sep = new Seperator(data); - ExportVar(packagename.c_str(), "looted_id", sep->arg[0]); - ExportVar(packagename.c_str(), "looted_charges", sep->arg[1]); - ExportVar(packagename.c_str(), "corpse", sep->arg[2]); - safe_delete(sep); - break; - } - - case EVENT_ZONE:{ - ExportVar(packagename.c_str(), "target_zone_id", data); - break; - } - - case EVENT_CAST_ON: - case EVENT_CAST:{ - ExportVar(packagename.c_str(), "spell_id", data); - break; - } - - case EVENT_TASKACCEPTED:{ - ExportVar(packagename.c_str(), "task_id", data); - break; - } - - case EVENT_TASK_STAGE_COMPLETE:{ - Seperator *sep = new Seperator(data); - ExportVar(packagename.c_str(), "task_id", sep->arg[0]); - ExportVar(packagename.c_str(), "activity_id", sep->arg[1]); - safe_delete(sep); - break; - } - case EVENT_TASK_FAIL:{ - Seperator *sep = new Seperator(data); - ExportVar(packagename.c_str(), "task_id", sep->arg[0]); - safe_delete(sep); - break; - } - case EVENT_TASK_COMPLETE: - case EVENT_TASK_UPDATE:{ - Seperator *sep = new Seperator(data); - ExportVar(packagename.c_str(), "donecount", sep->arg[0]); - ExportVar(packagename.c_str(), "activity_id", sep->arg[1]); - ExportVar(packagename.c_str(), "task_id", sep->arg[2]); - safe_delete(sep); - break; - } - case EVENT_PLAYER_PICKUP:{ - ExportVar(packagename.c_str(), "picked_up_id", data); - break; - } - - case EVENT_AGGRO_SAY: { - ExportVar(packagename.c_str(), "data", objid); - ExportVar(packagename.c_str(), "text", data); - ExportVar(packagename.c_str(), "langid", extradata); - break; - } - case EVENT_POPUPRESPONSE:{ - ExportVar(packagename.c_str(), "popupid", data); - break; - } - case EVENT_PROXIMITY_SAY: { - ExportVar(packagename.c_str(), "data", objid); - ExportVar(packagename.c_str(), "text", data); - ExportVar(packagename.c_str(), "langid", extradata); - break; - } - case EVENT_SCALE_CALC: - case EVENT_ITEM_ENTERZONE: { - ExportVar(packagename.c_str(), "itemid", objid); - ExportVar(packagename.c_str(), "itemname", iteminst->GetItem()->Name); - break; - } - case EVENT_ITEM_CLICK_CAST: - case EVENT_ITEM_CLICK: { - ExportVar(packagename.c_str(), "itemid", objid); - ExportVar(packagename.c_str(), "itemname", iteminst->GetItem()->Name); - ExportVar(packagename.c_str(), "slotid", extradata); - break; - } - case EVENT_GROUP_CHANGE: { - if(mob && mob->IsClient()) - { - ExportVar(packagename.c_str(), "grouped", mob->IsGrouped()); - ExportVar(packagename.c_str(), "raided", mob->IsRaidGrouped()); - } - break; - } - case EVENT_HATE_LIST: { - ExportVar(packagename.c_str(), "hate_state", data); - break; - } - - case EVENT_SPELL_EFFECT_CLIENT: - case EVENT_SPELL_EFFECT_NPC: - case EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT: - case EVENT_SPELL_EFFECT_BUFF_TIC_NPC: - { - ExportVar(packagename.c_str(), "caster_id", extradata); - break; - } - //tradeskill events - case EVENT_COMBINE_SUCCESS: - case EVENT_COMBINE_FAILURE: - { - ExportVar(packagename.c_str(), "recipe_id", extradata); - ExportVar(packagename.c_str(), "recipe_name", data); - break; - } - - case EVENT_FORAGE_SUCCESS: { - ExportVar(packagename.c_str(), "foraged_item", extradata); - break; - } - - case EVENT_FISH_SUCCESS: { - ExportVar(packagename.c_str(), "fished_item", extradata); - break; - } - - case EVENT_CLICK_OBJECT: { - ExportVar(packagename.c_str(), "objectid", data); - break; - } - - case EVENT_DISCOVER_ITEM: { - ExportVar(packagename.c_str(), "itemid", extradata); - break; - } - - //nothing special about these events - case EVENT_DEATH: - case EVENT_SPAWN: - case EVENT_ATTACK: - case EVENT_SLAY: - case EVENT_AGGRO: - case EVENT_ENTER: - case EVENT_EXIT: - case EVENT_ENTERZONE: - case EVENT_LEVEL_UP: - case EVENT_KILLED_MERIT: - case EVENT_TARGET_CHANGE: - break; - - default: { - // should we do anything here? - break; - } - } - - if(isPlayerQuest || isGlobalPlayerQuest){ - SendCommands(packagename.c_str(), sub_name, 0, mob, mob, nullptr); - } - else if(isItemQuest) { - SendCommands(packagename.c_str(), sub_name, 0, mob, mob, iteminst); - } - else if(isSpellQuest) - { - if(mob) { - SendCommands(packagename.c_str(), sub_name, 0, mob, mob, nullptr); - } else { - SendCommands(packagename.c_str(), sub_name, 0, npcmob, mob, nullptr); - } - } - else { - SendCommands(packagename.c_str(), sub_name, objid, npcmob, mob, nullptr); - } - - //now handle any events that cropped up... - HandleQueue(); -} - -void PerlembParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { - EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data, true); -} - -void PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { - EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data); -} - -void PerlembParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { - EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data); -} - -void PerlembParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { - EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data, true); -} - -void PerlembParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) { - EventCommon(evt, objid, nullptr, nullptr, item, client, extra_data); -} - -void PerlembParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { - EventCommon(evt, 0, itoa(spell_id), npc, nullptr, client, extra_data); -} - -void PerlembParser::ReloadQuests(bool with_timers) { - - if (with_timers) - { - // Clear all quest timers before reloading quests to prevent potential crashes - quest_manager.ClearAllTimers(); - } - - command_clear_perl(); - - try { - if(perl == nullptr) - perl = new Embperl; - else - perl->Reinit(); - map_funs(); - } - catch(std::exception &e) { - if(perl != nullptr) { - delete perl; - perl = nullptr; - } - LogFile->write(EQEMuLog::Status, "Error re-initializing perlembed: %s", e.what()); - throw e.what(); - } - - //try { - // LoadScript(0, nullptr); - //} - //catch(const char * err) { - // LogFile->write(EQEMuLog::Status, "Error loading default script: %s", err); - //} - - hasQuests.clear(); - playerQuestLoaded.clear(); - globalPlayerQuestLoaded = pQuestReadyToLoad; - globalNPCQuestLoaded = nQuestReadyToLoad; - itemQuestLoaded.clear(); - spellQuestLoaded.clear(); -} - -void PerlembParser::LoadNPCScript(std::string filename, int npc_id) { - if(!perl) - { - return; - } - - if(hasQuests.count(npc_id) == 1) - { - return; - } -} - -void PerlembParser::LoadGlobalNPCScript(std::string filename) { -} - -void PerlembParser::LoadPlayerScript(std::string filename) { -} - -void PerlembParser::LoadGlobalPlayerScript(std::string filename) { -} - -void PerlembParser::LoadItemScript(std::string filename, std::string item_script) { -} - -void PerlembParser::LoadSpellScript(std::string filename, uint32 spell_id) { -} - -//int PerlembParser::LoadScript(int npcid, const char * zone, Mob* activater) +// +//void PerlembParser::HandleQueue() { +// if(eventQueueProcessing) +// return; +// eventQueueProcessing = true; +// +// while(!eventQueue.empty()) { +// EventRecord e = eventQueue.front(); +// eventQueue.pop(); +// +// EventCommon(e.event, e.objid, e.data.c_str(), e.npcmob, e.iteminst, e.mob, e.extradata, e.global); +// } +// +// eventQueueProcessing = false; +//} +// +//void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global) //{ // if(!perl) -// { -// return(0); +// return; +// +// if(event >= _LargestEventID) +// return; +// +// if(perl->InUse()) { +// //queue the event for later. +// EventRecord e; +// e.event = event; +// e.objid = objid; +// if(data != nullptr) +// e.data = data; +// e.npcmob = npcmob; +// e.iteminst = iteminst; +// e.mob = mob; +// e.extradata = extradata; +// e.global = global; +// eventQueue.push(e); +// return; // } // -// //we have already tried to load this quest... -// if(hasQuests.count(npcid) == 1) +// bool isPlayerQuest = false; +// bool isGlobalPlayerQuest = false; +// bool isGlobalNPC = false; +// bool isItemQuest = false; +// bool isSpellQuest = false; +// if(event == EVENT_SPELL_EFFECT_CLIENT || +// event == EVENT_SPELL_EFFECT_NPC || +// event == EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT || +// event == EVENT_SPELL_EFFECT_BUFF_TIC_NPC || +// event == EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE) // { -// return(1); -// } -// -// string filename = "quests/", packagename = GetPkgPrefix(npcid); -// //each package name is of the form qstxxxx where xxxx = npcid (since numbers alone are not valid package names) -// questMode curmode = questDefault; -// FILE *tmpf; -// //LogFile->write(EQEMuLog::Debug, "LoadScript(%d, %s):\n", npcid, zone); -// if(!npcid || !zone) -// { -// //Load quests/default.pl -// filename += DEFAULT_QUEST_PREFIX; -// filename += ".pl"; -// curmode = questDefault; +// isSpellQuest = true; // } // else // { -// filename += zone; -// filename += "/"; -//#ifdef QUEST_SCRIPTS_BYNAME -// string bnfilename = filename; +// if(!npcmob && mob) { +// if(!iteminst) { +// if(global) { +// isGlobalPlayerQuest = true; +// } else { +// isPlayerQuest = true; +// } +// } +// else +// isItemQuest = true; +// } +// } +// +// string packagename; +// if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest){ +// +// if(global){ +// isGlobalNPC = true; +// packagename = "global_npc"; +// } else { +// +// packagename = GetPkgPrefix(objid); +// } +// } +// else if(isItemQuest) { +// const Item_Struct* item = iteminst->GetItem(); +// if (!item) return; +// +// if (event == EVENT_SCALE_CALC || event == EVENT_ITEM_ENTERZONE) { +// packagename = item->CharmFile; +// } +// else if (event == EVENT_ITEM_CLICK || event == EVENT_ITEM_CLICK_CAST) { +// packagename = "script_"; +// packagename += itoa(item->ScriptFileID); +// } +// else { +// packagename = "item_"; +// packagename += itoa(objid); +// } +// } +// else if(isPlayerQuest) { +// if(!zone || !zone->GetShortName()) // possible segfault fix +// return; +// packagename = "player"; +// packagename += "_"; +// packagename += zone->GetShortName(); +// } +// else if(isGlobalPlayerQuest) { +// packagename = "global_player"; +// } +// else +// { +// packagename = "spell_effect_"; +// packagename += data; +// } +// +// const char *sub_name = QuestEventSubroutines[event]; +// +// //make sure the sub we need even exists before we even do all this crap. +// if(!perl->SubExists(packagename.c_str(), sub_name)) { +// return; +// } +// +// int charid = 0; +// if (mob && mob->IsClient()) { // some events like waypoint and spawn don't have a player involved +// charid = mob->CastToClient()->CharacterID(); +// } else { +// if(npcmob) +// { +// charid = -npcmob->GetNPCTypeID(); // make char id negative npc id as a fudge +// } +// else if(mob && mob->IsNPC()) +// { +// charid = -mob->CastToNPC()->GetNPCTypeID(); // make char id negative npc id as a fudge +// } +// } +// ExportVar(packagename.c_str(), "charid", charid); +// +// //NPC quest +// if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest) +// { +// //only export for npcs that are global enabled. +// if(npcmob && npcmob->GetQglobal()) +// { +// map globhash; +// QGlobalCache *npc_c = nullptr; +// QGlobalCache *char_c = nullptr; +// QGlobalCache *zone_c = nullptr; +// +// //retrieve our globals +// npc_c = npcmob->GetQGlobals(); +// if(mob && mob->IsClient()) +// char_c = mob->CastToClient()->GetQGlobals(); +// zone_c = zone->GetQGlobals(); +// +// if(!npc_c) +// { +// npc_c = npcmob->CreateQGlobals(); +// npc_c->LoadByNPCID(npcmob->GetNPCTypeID()); +// } +// +// if(!char_c) +// { +// if(mob && mob->IsClient()) +// { +// char_c = mob->CastToClient()->CreateQGlobals(); +// char_c->LoadByCharID(mob->CastToClient()->CharacterID()); +// } +// } +// +// if(!zone_c) +// { +// zone_c = zone->CreateQGlobals(); +// zone_c->LoadByZoneID(zone->GetZoneID()); +// zone_c->LoadByGlobalContext(); +// } +// +// std::list globalMap; +// if(npc_c) +// { +// QGlobalCache::Combine(globalMap, npc_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); +// } +// +// if(char_c) +// { +// QGlobalCache::Combine(globalMap, char_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); +// } +// +// if(zone_c) +// { +// QGlobalCache::Combine(globalMap, zone_c->GetBucket(), npcmob->GetNPCTypeID(), charid, zone->GetZoneID()); +// } +// +// std::list::iterator iter = globalMap.begin(); +// while(iter != globalMap.end()) +// { +// globhash[(*iter).name] = (*iter).value; +// ExportVar(packagename.c_str(), (*iter).name.c_str(), (*iter).value.c_str()); +// ++iter; +// } +// ExportHash(packagename.c_str(), "qglobals", globhash); +// } +// } +// else +// { +// map globhash; +// QGlobalCache *char_c = nullptr; +// QGlobalCache *zone_c = nullptr; +// +// //retrieve our globals +// if(mob && mob->IsClient()) +// char_c = mob->CastToClient()->GetQGlobals(); +// zone_c = zone->GetQGlobals(); +// +// if(!char_c) +// { +// if(mob && mob->IsClient()) +// { +// char_c = mob->CastToClient()->CreateQGlobals(); +// char_c->LoadByCharID(mob->CastToClient()->CharacterID()); +// } +// } +// +// if(!zone_c) +// { +// zone_c = zone->CreateQGlobals(); +// zone_c->LoadByZoneID(zone->GetZoneID()); +// zone_c->LoadByGlobalContext(); +// } +// +// std::list globalMap; +// if(char_c) +// { +// QGlobalCache::Combine(globalMap, char_c->GetBucket(), 0, charid, zone->GetZoneID()); +// } +// +// if(zone_c) +// { +// QGlobalCache::Combine(globalMap, zone_c->GetBucket(), 0, charid, zone->GetZoneID()); +// } +// +// std::list::iterator iter = globalMap.begin(); +// while(iter != globalMap.end()) +// { +// globhash[(*iter).name] = (*iter).value; +// ExportVar(packagename.c_str(), (*iter).name.c_str(), (*iter).value.c_str()); +// ++iter; +// } +// ExportHash(packagename.c_str(), "qglobals", globhash); +// } +// +// uint8 fac = 0; +// if (mob && mob->IsClient()) { +// ExportVar(packagename.c_str(), "uguild_id", mob->CastToClient()->GuildID()); +// ExportVar(packagename.c_str(), "uguildrank", mob->CastToClient()->GuildRank()); +// ExportVar(packagename.c_str(), "status", mob->CastToClient()->Admin()); +// } +// +// if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest){ +// if (mob && npcmob && mob->IsClient() && npcmob->IsNPC()) { +// Client* client = mob->CastToClient(); +// NPC* npc = npcmob->CastToNPC(); +// +// // Need to figure out why one of these casts would fail.. +// if (client && npc) { +// fac = client->GetFactionLevel(client->CharacterID(), npcmob->GetID(), client->GetRace(), client->GetClass(), client->GetDeity(), npc->GetPrimaryFaction(), npcmob); +// } +// else if (!client) { +// LogFile->write(EQEMuLog::Status, "WARNING: cast failure on mob->CastToClient()"); +// } +// else if (!npc) { +// LogFile->write(EQEMuLog::Status, "WARNING: cast failure on npcmob->CastToNPC()"); +// } +// } +// } +// if (mob) { +// ExportVar(packagename.c_str(), "name", mob->GetName()); +// ExportVar(packagename.c_str(), "race", GetRaceName(mob->GetRace())); +// ExportVar(packagename.c_str(), "class", GetEQClassName(mob->GetClass())); +// ExportVar(packagename.c_str(), "ulevel", mob->GetLevel()); +// ExportVar(packagename.c_str(), "userid", mob->GetID()); +// } +// +// if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest) +// { +// if (npcmob) +// { +// ExportVar(packagename.c_str(), "mname", npcmob->GetName()); +// ExportVar(packagename.c_str(), "mobid", npcmob->GetID()); +// ExportVar(packagename.c_str(), "mlevel", npcmob->GetLevel()); +// ExportVar(packagename.c_str(), "hpratio",npcmob->GetHPRatio()); +// ExportVar(packagename.c_str(), "x", npcmob->GetX() ); +// ExportVar(packagename.c_str(), "y", npcmob->GetY() ); +// ExportVar(packagename.c_str(), "z", npcmob->GetZ() ); +// ExportVar(packagename.c_str(), "h", npcmob->GetHeading() ); +// if ( npcmob->GetTarget() ) { +// ExportVar(packagename.c_str(), "targetid", npcmob->GetTarget()->GetID()); +// ExportVar(packagename.c_str(), "targetname", npcmob->GetTarget()->GetName()); +// } +// } +// +// if (fac) { +// ExportVar(packagename.c_str(), "faction", itoa(fac)); +// } +// } +// +// if (zone) { +// ExportVar(packagename.c_str(), "zoneid", zone->GetZoneID()); +// ExportVar(packagename.c_str(), "zoneln", zone->GetLongName()); +// ExportVar(packagename.c_str(), "zonesn", zone->GetShortName()); +// ExportVar(packagename.c_str(), "instanceid", zone->GetInstanceID()); +// ExportVar(packagename.c_str(), "instanceversion", zone->GetInstanceVersion()); +// TimeOfDay_Struct eqTime; +// zone->zone_time.getEQTimeOfDay( time(0), &eqTime); +// ExportVar(packagename.c_str(), "zonehour", eqTime.hour - 1); +// ExportVar(packagename.c_str(), "zonemin", eqTime.minute); +// ExportVar(packagename.c_str(), "zonetime", (eqTime.hour - 1) * 100 + eqTime.minute); +// ExportVar(packagename.c_str(), "zoneweather", zone->zone_weather); +// } +// +//// $hasitem +//#define HASITEM_FIRST 0 +//#define HASITEM_LAST 29 // this includes worn plus 8 base slots +//#define HASITEM_ISNULLITEM(item) ((item==-1) || (item==0)) +// +// if(mob && mob->IsClient()) +// { +// string hashname = packagename + std::string("::hasitem"); +//#if EQDEBUG >= 7 +// LogFile->write(EQEMuLog::Debug, "starting hasitem, on : %s",hashname.c_str() ); //#endif -// filename += itoa(npcid); -// filename += ".pl"; -// curmode = questByID; // -//#ifdef QUEST_SCRIPTS_BYNAME -// //assuming name limit stays 64 chars. -// char tmpname[64]; -// int count0 = 0; -// bool filefound = false; -// tmpf = fopen(filename.c_str(), "r"); -// if(tmpf != NULL) -// { -// fclose(tmpf); -// filefound = true; -// } -// //LogFile->write(EQEMuLog::Debug, " tried '%s': %d", filename.c_str(), filefound); +// //start with an empty hash +// perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); // -// tmpname[0] = 0; -// //if there is no file for the NPC's ID, try for the NPC's name -// if(!filefound) +// for(int slot=HASITEM_FIRST; slot<=HASITEM_LAST;slot++) // { -// //revert to just path -// filename = bnfilename; -// const NPCType *npct = database.GetNPCType(npcid); -// if(npct == NULL) +// char *hi_decl=nullptr; +// int itemid=mob->CastToClient()->GetItemIDAt(slot); +// if(!HASITEM_ISNULLITEM(itemid)) // { -// //LogFile->write(EQEMuLog::Debug, " no npc type"); -// //revert and go on with life -// filename += itoa(npcid); -// filename += ".pl"; -// curmode = questByID; +// MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(),itemid,slot); +//// this is annoying +//#if EQDEBUG >= 7 +// LogFile->write(EQEMuLog::Debug, "declare hasitem : %s",hi_decl); +//#endif +// perl->eval(hi_decl); +// safe_delete_array(hi_decl); +// } +// } +// } +//// $oncursor +// if(mob && mob->IsClient()) { +// string hashname = packagename + std::string("::oncursor"); +// perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); +// char *hi_decl = nullptr; +// int itemid = mob->CastToClient()->GetItemIDAt(30); +// if(!HASITEM_ISNULLITEM(itemid)) { +// MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(),itemid,30); +// perl->eval(hi_decl); +// safe_delete_array(hi_decl); +// } +// } +// //do any event-specific stuff... +// switch (event) { +// case EVENT_SAY: { +// if (npcmob && npcmob->GetAppearance() != eaDead) +// npcmob->FaceTarget(mob); +// ExportVar(packagename.c_str(), "data", objid); +// ExportVar(packagename.c_str(), "text", data); +// ExportVar(packagename.c_str(), "langid", extradata); +// break; +// } +// case EVENT_ITEM: { +// if (npcmob->GetAppearance() != eaDead) +// npcmob->FaceTarget(mob); +// //this is such a hack... why aren't these just set directly.. +// ExportVar(packagename.c_str(), "item1", GetVar("item1", objid).c_str()); +// ExportVar(packagename.c_str(), "item2", GetVar("item2", objid).c_str()); +// ExportVar(packagename.c_str(), "item3", GetVar("item3", objid).c_str()); +// ExportVar(packagename.c_str(), "item4", GetVar("item4", objid).c_str()); +// ExportVar(packagename.c_str(), "item1_charges", GetVar("item1.charges", objid).c_str()); +// ExportVar(packagename.c_str(), "item2_charges", GetVar("item2.charges", objid).c_str()); +// ExportVar(packagename.c_str(), "item3_charges", GetVar("item3.charges", objid).c_str()); +// ExportVar(packagename.c_str(), "item4_charges", GetVar("item4.charges", objid).c_str()); +// ExportVar(packagename.c_str(), "item1_attuned", GetVar("item1.attuned", objid).c_str()); +// ExportVar(packagename.c_str(), "item2_attuned", GetVar("item2.attuned", objid).c_str()); +// ExportVar(packagename.c_str(), "item3_attuned", GetVar("item3.attuned", objid).c_str()); +// ExportVar(packagename.c_str(), "item4_attuned", GetVar("item4.attuned", objid).c_str()); +// ExportVar(packagename.c_str(), "copper", GetVar("copper", objid).c_str()); +// ExportVar(packagename.c_str(), "silver", GetVar("silver", objid).c_str()); +// ExportVar(packagename.c_str(), "gold", GetVar("gold", objid).c_str()); +// ExportVar(packagename.c_str(), "platinum", GetVar("platinum", objid).c_str()); +// string hashname = packagename + std::string("::itemcount"); +// perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); +// perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item1};").c_str()); +// perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item2};").c_str()); +// perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item3};").c_str()); +// perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item4};").c_str()); +// break; +// } +// case EVENT_WAYPOINT_ARRIVE: +// case EVENT_WAYPOINT_DEPART: { +// ExportVar(packagename.c_str(), "wp", data); +// break; +// } +// case EVENT_HP: { +// if (extradata == 1) { +// ExportVar(packagename.c_str(), "hpevent", "-1"); +// ExportVar(packagename.c_str(), "inchpevent", data); // } // else // { -// //trace out the ` characters, turn into - -// int nlen = strlen(npct->name); -// //just to make sure -// if(nlen < 64) -// { -// int r; -// //this should get our NULL as well.. -// for(r = 0; r <= nlen; r++) -// { -// tmpname[r] = npct->name[r]; -// -// //watch for 00 delimiter -// if(tmpname[r] == '0') -// { -// count0++; -// //second '0' -// if(count0 > 1) -// { -// //stop before previous 0 -// tmpname[r-1] = '\0'; -// break; -// } -// } -// else -// { -// count0 = 0; -// } -// -// //rewrite ` to be more file name friendly -// if(tmpname[r] == '`') -// { -// tmpname[r] = '-'; -// } -// -// } -// filename += tmpname; -// filename += ".pl"; -// curmode = questByName; -// } -// else -// { -// //LogFile->write(EQEMuLog::Debug, " namelen too long"); -// //revert and go on with life, again -// filename += itoa(npcid); -// filename += ".pl"; -// curmode = questByID; -// } +// ExportVar(packagename.c_str(), "hpevent", data); +// ExportVar(packagename.c_str(), "inchpevent", "-1"); // } +// break; +//} +// case EVENT_TIMER: { +// ExportVar(packagename.c_str(), "timer", data); +// break; +// } +// case EVENT_SIGNAL: { +// ExportVar(packagename.c_str(), "signal", data); +// break; +// } +// case EVENT_NPC_SLAY: { +// ExportVar(packagename.c_str(), "killed", mob->GetNPCTypeID()); +// break; +// } +// case EVENT_COMBAT: { +// ExportVar(packagename.c_str(), "combat_state", data); +// break; // } // -//#ifdef QUEST_TEMPLATES_BYNAME -// -// tmpf = fopen(filename.c_str(), "r"); -// if(tmpf != NULL) -// { -// fclose(tmpf); -// filefound = true; +// case EVENT_CLICKDOOR: { +// Seperator *sep = new Seperator(data); +// ExportVar(packagename.c_str(), "doorid", sep->arg[0]); +// ExportVar(packagename.c_str(), "version", sep->arg[1]); +// break; // } // +// case EVENT_LOOT:{ +// Seperator *sep = new Seperator(data); +// ExportVar(packagename.c_str(), "looted_id", sep->arg[0]); +// ExportVar(packagename.c_str(), "looted_charges", sep->arg[1]); +// ExportVar(packagename.c_str(), "corpse", sep->arg[2]); +// safe_delete(sep); +// break; +// } // -// //LogFile->write(EQEMuLog::Debug, " tried '%s': %d", filename.c_str(), filefound2); +// case EVENT_ZONE:{ +// ExportVar(packagename.c_str(), "target_zone_id", data); +// break; +// } +// +// case EVENT_CAST_ON: +// case EVENT_CAST:{ +// ExportVar(packagename.c_str(), "spell_id", data); +// break; +// } // -// //if there is no file for the NPC's ID or name, -// //try for the NPC's name in the templates directory -// //only works if we have gotten the NPC's name above -// if(!filefound) -// { -// if(tmpname[0] != 0) +// case EVENT_TASKACCEPTED:{ +// ExportVar(packagename.c_str(), "task_id", data); +// break; +// } +// +// case EVENT_TASK_STAGE_COMPLETE:{ +// Seperator *sep = new Seperator(data); +// ExportVar(packagename.c_str(), "task_id", sep->arg[0]); +// ExportVar(packagename.c_str(), "activity_id", sep->arg[1]); +// safe_delete(sep); +// break; +// } +// case EVENT_TASK_FAIL:{ +// Seperator *sep = new Seperator(data); +// ExportVar(packagename.c_str(), "task_id", sep->arg[0]); +// safe_delete(sep); +// break; +// } +// case EVENT_TASK_COMPLETE: +// case EVENT_TASK_UPDATE:{ +// Seperator *sep = new Seperator(data); +// ExportVar(packagename.c_str(), "donecount", sep->arg[0]); +// ExportVar(packagename.c_str(), "activity_id", sep->arg[1]); +// ExportVar(packagename.c_str(), "task_id", sep->arg[2]); +// safe_delete(sep); +// break; +// } +// case EVENT_PLAYER_PICKUP:{ +// ExportVar(packagename.c_str(), "picked_up_id", data); +// break; +// } +// +// case EVENT_AGGRO_SAY: { +// ExportVar(packagename.c_str(), "data", objid); +// ExportVar(packagename.c_str(), "text", data); +// ExportVar(packagename.c_str(), "langid", extradata); +// break; +// } +// case EVENT_POPUPRESPONSE:{ +// ExportVar(packagename.c_str(), "popupid", data); +// break; +// } +// case EVENT_PROXIMITY_SAY: { +// ExportVar(packagename.c_str(), "data", objid); +// ExportVar(packagename.c_str(), "text", data); +// ExportVar(packagename.c_str(), "langid", extradata); +// break; +// } +// case EVENT_SCALE_CALC: +// case EVENT_ITEM_ENTERZONE: { +// ExportVar(packagename.c_str(), "itemid", objid); +// ExportVar(packagename.c_str(), "itemname", iteminst->GetItem()->Name); +// break; +// } +// case EVENT_ITEM_CLICK_CAST: +// case EVENT_ITEM_CLICK: { +// ExportVar(packagename.c_str(), "itemid", objid); +// ExportVar(packagename.c_str(), "itemname", iteminst->GetItem()->Name); +// ExportVar(packagename.c_str(), "slotid", extradata); +// break; +// } +// case EVENT_GROUP_CHANGE: { +// if(mob && mob->IsClient()) // { -// //revert to just path -// filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/"; -// filename += tmpname; -// filename += ".pl"; -// curmode = questTemplate; -// //LogFile->write(EQEMuLog::Debug, " template '%s'", filename.c_str(), filefound2); -// } -// else -// { -// //LogFile->write(EQEMuLog::Debug, " no template name"); -// filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/"; -// filename += itoa(npcid); -// filename += ".pl"; -// curmode = questTemplateByID; +// ExportVar(packagename.c_str(), "grouped", mob->IsGrouped()); +// ExportVar(packagename.c_str(), "raided", mob->IsRaidGrouped()); // } +// break; // } -// -//#endif //QUEST_TEMPLATES_BYNAME -// -//#endif //QUEST_SCRIPTS_BYNAME -// -// tmpf = fopen(filename.c_str(), "r"); -// if(tmpf != NULL) -// { -// fclose(tmpf); -// filefound = true; -// } -// -// // If by ID, Name or Template wasn't found, load /quests/zone/default.pl -// if(!filefound) -// { -// //Load Default Quests Per Zone quests/zonename/default.pl -// filename = bnfilename; -// filename += "default.pl"; -// curmode = questDefaultByZone; -// //LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str()); +// case EVENT_HATE_LIST: { +// ExportVar(packagename.c_str(), "hate_state", data); +// break; // } // -// tmpf = fopen(filename.c_str(), "r"); -// if(tmpf != NULL) +// case EVENT_SPELL_EFFECT_CLIENT: +// case EVENT_SPELL_EFFECT_NPC: +// case EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT: +// case EVENT_SPELL_EFFECT_BUFF_TIC_NPC: // { -// fclose(tmpf); -// filefound = true; +// ExportVar(packagename.c_str(), "caster_id", extradata); +// break; // } -// -// // If zone template isn't found look for it globally /quests/template/default.pl -// if(!filefound) +// //tradeskill events +// case EVENT_COMBINE_SUCCESS: +// case EVENT_COMBINE_FAILURE: // { -// //Load Default Quests Globally -// //filename = bnfilename; -// filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/"; -// filename += "default.pl"; -// curmode = questDefaultByZone; -// //LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str()); +// ExportVar(packagename.c_str(), "recipe_id", extradata); +// ExportVar(packagename.c_str(), "recipe_name", data); +// break; +// } +// +// case EVENT_FORAGE_SUCCESS: { +// ExportVar(packagename.c_str(), "foraged_item", extradata); +// break; +// } +// +// case EVENT_FISH_SUCCESS: { +// ExportVar(packagename.c_str(), "fished_item", extradata); +// break; +// } +// +// case EVENT_CLICK_OBJECT: { +// ExportVar(packagename.c_str(), "objectid", data); +// break; +// } +// +// case EVENT_DISCOVER_ITEM: { +// ExportVar(packagename.c_str(), "itemid", extradata); +// break; +// } +// +// //nothing special about these events +// case EVENT_DEATH: +// case EVENT_SPAWN: +// case EVENT_ATTACK: +// case EVENT_SLAY: +// case EVENT_AGGRO: +// case EVENT_ENTER: +// case EVENT_EXIT: +// case EVENT_ENTERZONE: +// case EVENT_LEVEL_UP: +// case EVENT_KILLED_MERIT: +// case EVENT_TARGET_CHANGE: +// break; +// +// default: { +// // should we do anything here? +// break; // } // } // -// //check for existance of quest file before trying to make perl load it. -// tmpf = fopen(filename.c_str(), "r"); -// if(tmpf == NULL) +// if(isPlayerQuest || isGlobalPlayerQuest){ +// SendCommands(packagename.c_str(), sub_name, 0, mob, mob, nullptr); +// } +// else if(isItemQuest) { +// SendCommands(packagename.c_str(), sub_name, 0, mob, mob, iteminst); +// } +// else if(isSpellQuest) // { -// //the npc has no qst file, attach the defaults -// std::string setdefcmd = "$"; -// setdefcmd += packagename; -// setdefcmd += "::isdefault = 1;"; -// perl->eval(setdefcmd.c_str()); -// setdefcmd = "$"; -// setdefcmd += packagename; -// setdefcmd += "::isloaded = 1;"; -// perl->eval(setdefcmd.c_str()); -// hasQuests[npcid] = questDefault; -// return(1); +// if(mob) { +// SendCommands(packagename.c_str(), sub_name, 0, mob, mob, nullptr); +// } else { +// SendCommands(packagename.c_str(), sub_name, 0, npcmob, mob, nullptr); +// } +// } +// else { +// SendCommands(packagename.c_str(), sub_name, objid, npcmob, mob, nullptr); +// } +// +// //now handle any events that cropped up... +// HandleQueue(); +//} +// +//bool PerlembParser::isloaded(const char *packagename) const { +// char buffer[120]; +// snprintf(buffer, 120, "$%s::isloaded", packagename); +// if(!perl->VarExists(packagename, "isloaded")) +// return(false); +// return perl->geti(buffer); +//} +// +// +////this function does NOT consider the default to be a quest +//int PerlembParser::HasQuestFile(uint32 npcid) { +// int32 qstID = GetNPCqstID(npcid); +// int success=1; +// +// if(hasQuests.count(npcid) == 1) { +// questMode mode = hasQuests[npcid]; +// if(mode == questDefault) +// return(false); +// return(true); +// } +// +// if (qstID==-1) +// success = false; +// if (!success) +// return(false); +// +// if(hasQuests.count(npcid) != 1) +// return(false); +// +// questMode mode = hasQuests[npcid]; +// if(mode == questDefault) +// return(false); +// +// return(true); +//} +// +//bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) { +// int32 qstID = GetNPCqstID(npcid); +// +// string packagename = GetPkgPrefix(npcid); +// +// return(perl->SubExists(packagename.c_str(), subname)); +//} +// +//bool PerlembParser::HasGlobalQuestSub(const char *subname) { +// string packagename = "global_npc"; +// +// return(perl->SubExists(packagename.c_str(), subname)); +//} +// +//bool PerlembParser::PlayerHasQuestSub(const char *subname) { +// +// string packagename = "player_"; +// packagename += zone->GetShortName(); +// +// if(subname == "EVENT_CAST") +// return (playerQuestLoaded[zone->GetShortName()] == pQuestEventCast); +// +// return(perl->SubExists(packagename.c_str(), subname)); +//} +// +//bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { +// +// string packagename = "global_player"; +// +// if(subname == "EVENT_CAST") +// return (globalPlayerQuestLoaded == pQuestEventCast); +// +// return(perl->SubExists(packagename.c_str(), subname)); +//} +// +//bool PerlembParser::SpellHasQuestSub(uint32 id, const char *subname) +//{ +// string packagename = "spell_effect_"; +// packagename += itoa(id); +// +// return(perl->SubExists(packagename.c_str(), subname)); +//} +// +//bool PerlembParser::ItemHasQuestSub(ItemInst *itm, const char *subname) +//{ +// string packagename; +// const Item_Struct* item = itm->GetItem(); +// if(!item) +// return false; +// +// if(strcmp("EVENT_SCALE_CALC", subname) == 0 || strcmp("EVENT_ITEM_ENTERZONE", subname) == 0) +// { +// packagename = item->CharmFile; +// } +// else if(strcmp("EVENT_ITEM_CLICK", subname) == 0 || strcmp("EVENT_ITEM_CLICK_CAST", subname) == 0 ) +// { +// packagename = "script_"; +// packagename += itoa(item->ScriptFileID); // } // else // { -// fclose(tmpf); +// packagename = "item_"; +// packagename += itoa(item->ID); // } // -// //LogFile->write(EQEMuLog::Debug, " finally settling on '%s'", filename.c_str()); -// // LogFile->write(EQEMuLog::Status, "Looking for quest file: '%s'", filename.c_str()); +// return perl->SubExists(packagename.c_str(), subname); +//} // -// // todo: decide whether or not to delete the package to allow for script refreshes w/o restarting the server -// // remember to guard against deleting the default package, on a similar note... consider deleting packages upon zone change -// // try { perl->eval(std::string("delete_package(\"").append(packagename).append("\");").c_str()); } -// // catch(...) {/*perl balked at us trynig to delete a non-existant package... no big deal.*/} +////utility - return something of the form "qst1234"... +////will return "qst[DEFAULT_QUEST_PREFIX]" if the npc in question has no script of its own or failed to compile and defaultOK is set to true +//std::string PerlembParser::GetPkgPrefix(uint32 npcid, bool defaultOK) +//{ +// char buf[32]; +// snprintf(buf, 32, "qst%lu", (unsigned long) npcid); +//// std::string prefix = "qst"; +//// std::string temp = prefix + (std::string)(itoa(npcid)); +//// if(!npcid || (defaultOK && isdefault(temp.c_str()))) +// if(!npcid || (defaultOK && (hasQuests.count(npcid) == 1 && hasQuests[npcid] == questDefault))) +// { +// snprintf(buf, 32, "qst%s", DEFAULT_QUEST_PREFIX.c_str()); +// } // -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); +// return(std::string(buf)); +//} +// +//void PerlembParser::SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst) +//{ +// if(!perl) +// return; +// _ZP(PerlembParser_SendCommands); +// +// if(mob && mob->IsClient()) +// quest_manager.StartQuest(other, mob->CastToClient()); +// else +// quest_manager.StartQuest(other, nullptr); +// +// try +// { +// std::string cmd = "@quest::cmd_queue = (); package " + (std::string)(pkgprefix) + (std::string)(";"); +// perl->eval(cmd.c_str()); +// perl->dosub(std::string(pkgprefix).append("::").append(event).c_str()); // } // catch(const char * err) // { // //try to reduce some of the console spam... // //todo: tweak this to be more accurate at deciding what to filter (we don't want to gag legit errors) -// //if(!strstr(err,"No such file or directory")) -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s (reverting to default questfile)", filename.c_str(), err); -// } -// //todo: change this to just read eval_file's %cache - duh! -// if(!isloaded(packagename.c_str())) -// { -// //the npc has no qst file, attach the defaults -// std::string setdefcmd = "$"; -// setdefcmd += packagename; -// setdefcmd += "::isdefault = 1;"; -// perl->eval(setdefcmd.c_str()); -// setdefcmd = "$"; -// setdefcmd += packagename; -// setdefcmd += "::isloaded = 1;"; -// perl->eval(setdefcmd.c_str()); -// curmode = questDefault; +// if(!strstr(err,"Undefined subroutine")) +// LogFile->write(EQEMuLog::Status, "Script error: %s::%s - %s", pkgprefix, event, err); +// return; // } // -// hasQuests[npcid] = curmode; -// return(1); +// int numcoms = perl->geti("quest::qsize()"); +// for(int c = 0; c < numcoms; ++c) +// { +// char var[1024] = {0}; +// sprintf(var,"$quest::cmd_queue[%d]{func}",c); +// std::string cmd = perl->getstr(var); +// sprintf(var,"$quest::cmd_queue[%d]{args}",c); +// std::string args = perl->getstr(var); +// size_t num_args = std::count(args.begin(), args.end(), ',') + 1; +// +// ExCommands(cmd, args, num_args, npcid, other, mob); +// } +// +// quest_manager.EndQuest(); //} // -//int PerlembParser::LoadGlobalNPCScript() +//#ifdef EMBPERL_COMMANDS +//void PerlembParser::ExecCommand(Client *c, Seperator *sep) { +//#ifdef EMBPERL_XS_CLASSES +// SV *client = get_sv("commands::client", true); +// if(c != nullptr) { +// sv_setref_pv(client, "Client", c); +// } else { +// //clear out the value, mainly to get rid of blessedness +// //which prevents us from accessing an invalid pointer +// sv_setsv(client, newSV(0)); +// } +//#endif +// +// char namebuf[128]; +// snprintf(namebuf, 128, "commands::%s", sep->arg[0]+1); +// namebuf[127] = '\0'; +// std::vector args; +// int i; +// for(i = 1; i <= sep->argnum; i++) { +// args.push_back(sep->arg[i]); +// } +// +// try +// { +// perl->dosub(namebuf, &args); +// } catch(const char * err) +// { +// c->Message(13, "Error executing perl command, check the logs."); +// LogFile->write(EQEMuLog::Quest, "Script error: %s", err); +// } +// +// //now handle any events that cropped up... +// HandleQueue(); +//} +//#endif +// +//void PerlembParser::map_funs() //{ -// if(!perl) -// return 0; -// -// if(perl->InUse()) -// { -// return 0; -// } -// -// if(globalNPCQuestLoaded != nQuestReadyToLoad) { -// return 1; -// } -// -// string filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/global_npc.pl"; -// string packagename = "global_npc"; -// -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char * err) -// { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// -// globalNPCQuestLoaded = nQuestLoaded; -// -// return 1; +// //map each "exported" function to a variable list that we can access from c +// //todo: +// // break 1|settimer 2|stoptimer 1|dbspawnadd 2|flagcheck 1|write 2| +// // settarget 2|follow 1|sfollow 1|save 1|setallskill 1 +// //update/ensure that the api matches that of the native script engine +// perl->eval( +//"{" +//"package quest;" +//"&boot_qc;" +//"@cmd_queue = ();" +//"sub qsize{return scalar(@cmd_queue)};" +//"sub say{push(@cmd_queue,{func=>'say',args=>join(',',@_)});}" +//"sub emote{push(@cmd_queue,{func=>'emote',args=>join(',',@_)});}" +//"sub shout{push(@cmd_queue,{func=>'shout',args=>join(',',@_)});}" +//"sub spawn{push(@cmd_queue,{func=>'spawn',args=>join(',',@_)});}" +//"sub spawn2{push(@cmd_queue,{func=>'spawn2',args=>join(',',@_)});}" +//"sub unique_spawn{push(@cmd_queue,{func=>'unique_spawn',args=>join(',',@_)});}" +//"sub echo{push(@cmd_queue,{func=>'echo',args=>join(',',@_)});}" +//"sub summonitem{push(@cmd_queue,{func=>'summonitem',args=>join(',',@_)});}" +//"sub castspell{push(@cmd_queue,{func=>'castspell',args=>join(',',@_)});}" +//"sub selfcast{push(@cmd_queue,{func=>'selfcast',args=>join(',',@_)});}" +//"sub depop{push(@cmd_queue,{func=>'depop'});}" +//"sub exp{push(@cmd_queue,{func=>'exp',args=>join(',',@_)});}" +//"sub level{push(@cmd_queue,{func=>'level',args=>join(',',@_)});}" +//"sub safemove{push(@cmd_queue,{func=>'safemove'});}" +//"sub rain{push(@cmd_queue,{func=>'rain',args=>join(',',@_)});}" +//"sub snow{push(@cmd_queue,{func=>'snow',args=>join(',',@_)});}" +//"sub givecash{push(@cmd_queue,{func=>'givecash',args=>join(',',@_)});}" +//"sub pvp{push(@cmd_queue,{func=>'pvp',args=>join(',',@_)});}" +//"sub doanim{push(@cmd_queue,{func=>'doanim',args=>join(',',@_)});}" +//"sub addskill{push(@cmd_queue,{func=>'addskill',args=>join(',',@_)});}" +//"sub me{push(@cmd_queue,{func=>'me',args=>join(',',@_)});}" +//"sub permagender{push(@cmd_queue,{func=>'permagender',args=>join(',',@_)});}" +//"sub permarace{push(@cmd_queue,{func=>'permarace',args=>join(',',@_)});}" +//"sub scribespells{push(@cmd_queue,{func=>'scribespells',args=>join(',',@_)});}" +//"sub permaclass{push(@cmd_queue,{func=>'permaclass',args=>join(',',@_)});}" +//"sub surname{push(@cmd_queue,{func=>'surname',args=>join(',',@_)});}" +//"sub addldonpoint{push(@cmd_queue,{func=>'addldonpoint',args=>join(',',@_)});}" +//"sub ding{push(@cmd_queue,{func=>'ding',args=>join(',',@_)});}" +//"sub faction{push(@cmd_queue,{func=>'faction',args=>join(',',@_)});}" +//"sub setguild{push(@cmd_queue,{func=>'setguild',args=>join(',',@_)});}" +//"sub rebind{push(@cmd_queue,{func=>'rebind',args=>join(',',@_)});}" +//"sub flagcheck{push(@cmd_queue,{func=>'flagcheck',args=>join(',',@_)});}" +//"sub write{push(@cmd_queue,{func=>'write',args=>join(',',@_)});}" +//"sub settime{push(@cmd_queue,{func=>'settime',args=>join(',',@_)});}" +//"sub setsky{push(@cmd_queue,{func=>'setsky',args=>join(',',@_)});}" +//"sub settimer{push(@cmd_queue,{func=>'settimer',args=>join(',',@_)});}" +//"sub stoptimer{push(@cmd_queue,{func=>'stoptimer',args=>join(',',@_)});}" +//"sub settarget{push(@cmd_queue,{func=>'settarget',args=>join(',',@_)});}" +//"sub follow{push(@cmd_queue,{func=>'follow',args=>join(',',@_)});}" +//"sub sfollow{push(@cmd_queue,{func=>'sfollow',args=>join(',',@_)});}" +//"sub movepc{push(@cmd_queue,{func=>'movepc',args=>join(',',@_)});}" +//"sub gmmove{push(@cmd_queue,{func=>'gmmove',args=>join(',',@_)});}" +//"sub movegrp{push(@cmd_queue,{func=>'movegrp',args=>join(',',@_)});}" +//"sub setlanguage{push(@cmd_queue,{func=>'setlanguage',args=>join(',',@_)});}" +//"sub setskill{push(@cmd_queue,{func=>'setskill',args=>join(',',@_)});}" +//"sub setallskill{push(@cmd_queue,{func=>'setallskill',args=>join(',',@_)});}" +//"sub attack{push(@cmd_queue,{func=>'attack',args=>join(',',@_)});}" +//"sub save{push(@cmd_queue,{func=>'save',args=>join(',',@_)});}" +//"sub linkitem{push(@cmd_queue,{func=>'linkitem',args=>join(',',@_)});}" +//"sub sethp{push(@cmd_queue,{func=>'sethp',args=>join(',',@_)});}" +//"sub signal{push(@cmd_queue,{func=>'signal',args=>join(',',@_)});}" +//"sub setglobal{push(@cmd_queue,{func=>'setglobal',args=>join(',',@_)});}" +//"sub targlobal{push(@cmd_queue,{func=>'targlobal',args=>join(',',@_)});}" +//"sub delglobal{push(@cmd_queue,{func=>'delglobal',args=>join(',',@_)});}" +//"sub setnexthpevent{push(@cmd_queue,{func=>'setnexthpevent',args=>join(',',@_)});}" +//"sub setnextinchpevent{push(@cmd_queue,{func=>'setnextinchpevent',args=>join(',',@_)});}" +//"sub respawn{push(@cmd_queue,{func=>'respawn',args=>join(',',@_)});}" +//"sub stop{push(@cmd_queue,{func=>'stop',args=>join(',',@_)});}" +//"sub pause{push(@cmd_queue,{func=>'pause',args=>join(',',@_)});}" +//"sub resume{push(@cmd_queue,{func=>'resume',args=>join(',',@_)});}" +//"sub start{push(@cmd_queue,{func=>'start',args=>join(',',@_)});}" +//"sub moveto{push(@cmd_queue,{func=>'moveto',args=>join(',',@_)});}" +//"sub warp{push(@cmd_queue,{func=>'warp',args=>join(',',@_)});}" +//"sub changedeity{push(@cmd_queue,{func=>'changedeity',args=>join(',',@_)});}" +//"sub addldonpoints{push(@cmd_queue,{func=>'addldonpoints',args=>join(',',@_)});}" +//"sub addloot{push(@cmd_queue,{func=>'addloot',args=>join(',',@_)});}" +//"sub traindisc{push(@cmd_queue,{func=>'traindisc',args=>join(',',@_)});}" +//"sub set_proximity{push(@cmd_queue,{func=>'set_proximity',args=>join(',',@_)});}" +//"sub clear_proximity{push(@cmd_queue,{func=>'clear_proximity',args=>join(',',@_)});}" +//"sub setanim{push(@cmd_queue,{func=>'setanim',args=>join(',',@_)});}" +//"sub showgrid{push(@cmd_queue,{func=>'showgrid',args=>join(',',@_)});}" +//"sub showpath{push(@cmd_queue,{func=>'showpath',args=>join(',',@_)});}" +//"sub pathto{push(@cmd_queue,{func=>'pathto',args=>join(',',@_)});}" +//"sub spawn_condition{push(@cmd_queue,{func=>'spawn_condition',args=>join(',',@_)});}" +//"sub toggle_spawn_event{push(@cmd_queue,{func=>'toggle_spawn_event',args=>join(',',@_)});}" +//"sub set_zone_flag{push(@cmd_queue,{func=>'set_zone_flag',args=>join(',',@_)});}" +//"sub clear_zone_flag{push(@cmd_queue,{func=>'clear_zone_flag',args=>join(',',@_)});}" +//"package main;" +//"}" +//);//eval //} // -//int PerlembParser::LoadPlayerScript(const char *zone_name) -//{ -// if(!perl) -// return 0; +//#endif //EMBPERL // -// if(perl->InUse()) -// { -// return 0; -// } -// -// if(playerQuestLoaded.count(zone_name) == 1) { -// return 1; -// } -// -// string filename= "quests/"; -// filename += zone_name; -// filename += "/player_v"; -// filename += itoa(zone->GetInstanceVersion()); -// filename += ".pl"; -// string packagename = "player"; -// packagename += "_"; -// packagename += zone_name; -// -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char * err) -// { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// -// if(!isloaded(packagename.c_str())) -// { -// filename= "quests/"; -// filename += zone_name; -// filename += "/player.pl"; -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char * err) -// { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// } -// -// //todo: change this to just read eval_file's %cache - duh! -// if(!isloaded(packagename.c_str())) -// { -// filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/player.pl"; -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char * err) -// { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// if(!isloaded(packagename.c_str())) -// { -// playerQuestLoaded[zone_name] = pQuestUnloaded; -// return 0; -// } -// } -// -// if(perl->SubExists(packagename.c_str(), "EVENT_CAST")) -// playerQuestLoaded[zone_name] = pQuestEventCast; -// else -// playerQuestLoaded[zone_name] = pQuestLoaded; -// return 1; -//} -// -//int PerlembParser::LoadGlobalPlayerScript() -//{ -// if(!perl) -// return 0; -// -// if(perl->InUse()) -// { -// return 0; -// } -// -// if(globalPlayerQuestLoaded != pQuestReadyToLoad) { -// return 1; -// } -// -// string filename = "quests/"; -// filename += QUEST_TEMPLATES_DIRECTORY; -// filename += "/global_player.pl"; -// string packagename = "global_player"; -// -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char * err) -// { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// -// if(perl->SubExists(packagename.c_str(), "EVENT_CAST")) -// globalPlayerQuestLoaded = pQuestEventCast; -// else -// globalPlayerQuestLoaded = pQuestLoaded; -// return 1; -//} -// -//int PerlembParser::LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype) { -// if(!perl) -// return 0; -// -// if(perl->InUse()) -// { -// return 0; -// } -// -// // if we've already tried to load it, don't try again -// if(itemQuestLoaded.count(packagename) == 1) -// return 1; -// -// string filename = "quests/items/"; -// if(Qtype == itemQuestScale) -// filename += packagename; -// else if(Qtype == itemQuestLore) { -// filename += "lore_"; -// filename += itoa(iteminst->GetItem()->LoreGroup); -// } -// else if(Qtype == itemScriptFileID) { -// filename += "script_"; -// filename += itoa(iteminst->GetItemScriptID()); -// } -// else -// filename += itoa(iteminst->GetID()); -// filename += ".pl"; -// printf("Loading file %s\n",filename.c_str()); -// -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char* err) { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// -// if(!isloaded(packagename.c_str())) { -// itemQuestLoaded[packagename] = Qtype; -// return 0; -// } -// -// itemQuestLoaded[packagename] = itemQuestUnloaded; -// return 1; -//} -// -//int PerlembParser::LoadSpellScript(uint32 id) -//{ -// if(!perl) -// return 0; -// -// if(perl->InUse()) -// { -// return 0; -// } -// -// // if we've already tried to load it, don't try again -// if(spellQuestLoaded.count(id) == 1) -// return 1; -// -// string filename = "quests/spells/"; -// string packagename = "spell_effect_"; -// filename += itoa(id); -// packagename += itoa(id); -// filename += ".pl"; -// printf("Loading file %s\n", filename.c_str()); -// -// try { -// perl->eval_file(packagename.c_str(), filename.c_str()); -// } -// catch(const char* err) { -// LogFile->write(EQEMuLog::Quest, "WARNING: error compiling quest file %s: %s", filename.c_str(), err); -// } -// -// if(!isloaded(packagename.c_str())) { -// spellQuestLoaded[id] = spellQuestFailed; -// return 0; -// } -// -// spellQuestLoaded[id] = spellQuestFullyLoaded; -// return 1; -//} - -bool PerlembParser::isloaded(const char *packagename) const { - char buffer[120]; - snprintf(buffer, 120, "$%s::isloaded", packagename); - if(!perl->VarExists(packagename, "isloaded")) - return(false); - return perl->geti(buffer); -} - - -//this function does NOT consider the default to be a quest -int PerlembParser::HasQuestFile(uint32 npcid) { - int32 qstID = GetNPCqstID(npcid); - int success=1; - - if(hasQuests.count(npcid) == 1) { - questMode mode = hasQuests[npcid]; - if(mode == questDefault) - return(false); - return(true); - } - - if (qstID==-1) - success = false; - if (!success) - return(false); - - if(hasQuests.count(npcid) != 1) - return(false); - - questMode mode = hasQuests[npcid]; - if(mode == questDefault) - return(false); - - return(true); -} - -bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) { - int32 qstID = GetNPCqstID(npcid); - - string packagename = GetPkgPrefix(npcid); - - return(perl->SubExists(packagename.c_str(), subname)); -} - -bool PerlembParser::HasGlobalQuestSub(const char *subname) { - string packagename = "global_npc"; - - return(perl->SubExists(packagename.c_str(), subname)); -} - -bool PerlembParser::PlayerHasQuestSub(const char *subname) { - - string packagename = "player_"; - packagename += zone->GetShortName(); - - if(subname == "EVENT_CAST") - return (playerQuestLoaded[zone->GetShortName()] == pQuestEventCast); - - return(perl->SubExists(packagename.c_str(), subname)); -} - -bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { - - string packagename = "global_player"; - - if(subname == "EVENT_CAST") - return (globalPlayerQuestLoaded == pQuestEventCast); - - return(perl->SubExists(packagename.c_str(), subname)); -} - -bool PerlembParser::SpellHasQuestSub(uint32 id, const char *subname) -{ - string packagename = "spell_effect_"; - packagename += itoa(id); - - return(perl->SubExists(packagename.c_str(), subname)); -} - -bool PerlembParser::ItemHasQuestSub(ItemInst *itm, const char *subname) -{ - string packagename; - const Item_Struct* item = itm->GetItem(); - if(!item) - return false; - - if(strcmp("EVENT_SCALE_CALC", subname) == 0 || strcmp("EVENT_ITEM_ENTERZONE", subname) == 0) - { - packagename = item->CharmFile; - } - else if(strcmp("EVENT_ITEM_CLICK", subname) == 0 || strcmp("EVENT_ITEM_CLICK_CAST", subname) == 0 ) - { - packagename = "script_"; - packagename += itoa(item->ScriptFileID); - } - else - { - packagename = "item_"; - packagename += itoa(item->ID); - } - - return perl->SubExists(packagename.c_str(), subname); -} - -//utility - return something of the form "qst1234"... -//will return "qst[DEFAULT_QUEST_PREFIX]" if the npc in question has no script of its own or failed to compile and defaultOK is set to true -std::string PerlembParser::GetPkgPrefix(uint32 npcid, bool defaultOK) -{ - char buf[32]; - snprintf(buf, 32, "qst%lu", (unsigned long) npcid); -// std::string prefix = "qst"; -// std::string temp = prefix + (std::string)(itoa(npcid)); -// if(!npcid || (defaultOK && isdefault(temp.c_str()))) - if(!npcid || (defaultOK && (hasQuests.count(npcid) == 1 && hasQuests[npcid] == questDefault))) - { - snprintf(buf, 32, "qst%s", DEFAULT_QUEST_PREFIX.c_str()); - } - - return(std::string(buf)); -} - -void PerlembParser::SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst) -{ - if(!perl) - return; - _ZP(PerlembParser_SendCommands); - - if(mob && mob->IsClient()) - quest_manager.StartQuest(other, mob->CastToClient()); - else - quest_manager.StartQuest(other, nullptr); - - try - { - std::string cmd = "@quest::cmd_queue = (); package " + (std::string)(pkgprefix) + (std::string)(";"); - perl->eval(cmd.c_str()); - perl->dosub(std::string(pkgprefix).append("::").append(event).c_str()); - } - catch(const char * err) - { - //try to reduce some of the console spam... - //todo: tweak this to be more accurate at deciding what to filter (we don't want to gag legit errors) - if(!strstr(err,"Undefined subroutine")) - LogFile->write(EQEMuLog::Status, "Script error: %s::%s - %s", pkgprefix, event, err); - return; - } - - int numcoms = perl->geti("quest::qsize()"); - for(int c = 0; c < numcoms; ++c) - { - char var[1024] = {0}; - sprintf(var,"$quest::cmd_queue[%d]{func}",c); - std::string cmd = perl->getstr(var); - sprintf(var,"$quest::cmd_queue[%d]{args}",c); - std::string args = perl->getstr(var); - size_t num_args = std::count(args.begin(), args.end(), ',') + 1; - - ExCommands(cmd, args, num_args, npcid, other, mob); - } - - quest_manager.EndQuest(); -} - -#ifdef EMBPERL_COMMANDS -void PerlembParser::ExecCommand(Client *c, Seperator *sep) { -#ifdef EMBPERL_XS_CLASSES - SV *client = get_sv("commands::client", true); - if(c != nullptr) { - sv_setref_pv(client, "Client", c); - } else { - //clear out the value, mainly to get rid of blessedness - //which prevents us from accessing an invalid pointer - sv_setsv(client, newSV(0)); - } -#endif - - char namebuf[128]; - snprintf(namebuf, 128, "commands::%s", sep->arg[0]+1); - namebuf[127] = '\0'; - std::vector args; - int i; - for(i = 1; i <= sep->argnum; i++) { - args.push_back(sep->arg[i]); - } - - try - { - perl->dosub(namebuf, &args); - } catch(const char * err) - { - c->Message(13, "Error executing perl command, check the logs."); - LogFile->write(EQEMuLog::Quest, "Script error: %s", err); - } - - //now handle any events that cropped up... - HandleQueue(); -} -#endif - -void PerlembParser::map_funs() -{ - //map each "exported" function to a variable list that we can access from c - //todo: - // break 1|settimer 2|stoptimer 1|dbspawnadd 2|flagcheck 1|write 2| - // settarget 2|follow 1|sfollow 1|save 1|setallskill 1 - //update/ensure that the api matches that of the native script engine - perl->eval( -"{" -"package quest;" -"&boot_qc;" -"@cmd_queue = ();" -"sub qsize{return scalar(@cmd_queue)};" -"sub say{push(@cmd_queue,{func=>'say',args=>join(',',@_)});}" -"sub emote{push(@cmd_queue,{func=>'emote',args=>join(',',@_)});}" -"sub shout{push(@cmd_queue,{func=>'shout',args=>join(',',@_)});}" -"sub spawn{push(@cmd_queue,{func=>'spawn',args=>join(',',@_)});}" -"sub spawn2{push(@cmd_queue,{func=>'spawn2',args=>join(',',@_)});}" -"sub unique_spawn{push(@cmd_queue,{func=>'unique_spawn',args=>join(',',@_)});}" -"sub echo{push(@cmd_queue,{func=>'echo',args=>join(',',@_)});}" -"sub summonitem{push(@cmd_queue,{func=>'summonitem',args=>join(',',@_)});}" -"sub castspell{push(@cmd_queue,{func=>'castspell',args=>join(',',@_)});}" -"sub selfcast{push(@cmd_queue,{func=>'selfcast',args=>join(',',@_)});}" -"sub depop{push(@cmd_queue,{func=>'depop'});}" -"sub exp{push(@cmd_queue,{func=>'exp',args=>join(',',@_)});}" -"sub level{push(@cmd_queue,{func=>'level',args=>join(',',@_)});}" -"sub safemove{push(@cmd_queue,{func=>'safemove'});}" -"sub rain{push(@cmd_queue,{func=>'rain',args=>join(',',@_)});}" -"sub snow{push(@cmd_queue,{func=>'snow',args=>join(',',@_)});}" -"sub givecash{push(@cmd_queue,{func=>'givecash',args=>join(',',@_)});}" -"sub pvp{push(@cmd_queue,{func=>'pvp',args=>join(',',@_)});}" -"sub doanim{push(@cmd_queue,{func=>'doanim',args=>join(',',@_)});}" -"sub addskill{push(@cmd_queue,{func=>'addskill',args=>join(',',@_)});}" -"sub me{push(@cmd_queue,{func=>'me',args=>join(',',@_)});}" -"sub permagender{push(@cmd_queue,{func=>'permagender',args=>join(',',@_)});}" -"sub permarace{push(@cmd_queue,{func=>'permarace',args=>join(',',@_)});}" -"sub scribespells{push(@cmd_queue,{func=>'scribespells',args=>join(',',@_)});}" -"sub permaclass{push(@cmd_queue,{func=>'permaclass',args=>join(',',@_)});}" -"sub surname{push(@cmd_queue,{func=>'surname',args=>join(',',@_)});}" -"sub addldonpoint{push(@cmd_queue,{func=>'addldonpoint',args=>join(',',@_)});}" -"sub ding{push(@cmd_queue,{func=>'ding',args=>join(',',@_)});}" -"sub faction{push(@cmd_queue,{func=>'faction',args=>join(',',@_)});}" -"sub setguild{push(@cmd_queue,{func=>'setguild',args=>join(',',@_)});}" -"sub rebind{push(@cmd_queue,{func=>'rebind',args=>join(',',@_)});}" -"sub flagcheck{push(@cmd_queue,{func=>'flagcheck',args=>join(',',@_)});}" -"sub write{push(@cmd_queue,{func=>'write',args=>join(',',@_)});}" -"sub settime{push(@cmd_queue,{func=>'settime',args=>join(',',@_)});}" -"sub setsky{push(@cmd_queue,{func=>'setsky',args=>join(',',@_)});}" -"sub settimer{push(@cmd_queue,{func=>'settimer',args=>join(',',@_)});}" -"sub stoptimer{push(@cmd_queue,{func=>'stoptimer',args=>join(',',@_)});}" -"sub settarget{push(@cmd_queue,{func=>'settarget',args=>join(',',@_)});}" -"sub follow{push(@cmd_queue,{func=>'follow',args=>join(',',@_)});}" -"sub sfollow{push(@cmd_queue,{func=>'sfollow',args=>join(',',@_)});}" -"sub movepc{push(@cmd_queue,{func=>'movepc',args=>join(',',@_)});}" -"sub gmmove{push(@cmd_queue,{func=>'gmmove',args=>join(',',@_)});}" -"sub movegrp{push(@cmd_queue,{func=>'movegrp',args=>join(',',@_)});}" -"sub setlanguage{push(@cmd_queue,{func=>'setlanguage',args=>join(',',@_)});}" -"sub setskill{push(@cmd_queue,{func=>'setskill',args=>join(',',@_)});}" -"sub setallskill{push(@cmd_queue,{func=>'setallskill',args=>join(',',@_)});}" -"sub attack{push(@cmd_queue,{func=>'attack',args=>join(',',@_)});}" -"sub save{push(@cmd_queue,{func=>'save',args=>join(',',@_)});}" -"sub linkitem{push(@cmd_queue,{func=>'linkitem',args=>join(',',@_)});}" -"sub sethp{push(@cmd_queue,{func=>'sethp',args=>join(',',@_)});}" -"sub signal{push(@cmd_queue,{func=>'signal',args=>join(',',@_)});}" -"sub setglobal{push(@cmd_queue,{func=>'setglobal',args=>join(',',@_)});}" -"sub targlobal{push(@cmd_queue,{func=>'targlobal',args=>join(',',@_)});}" -"sub delglobal{push(@cmd_queue,{func=>'delglobal',args=>join(',',@_)});}" -"sub setnexthpevent{push(@cmd_queue,{func=>'setnexthpevent',args=>join(',',@_)});}" -"sub setnextinchpevent{push(@cmd_queue,{func=>'setnextinchpevent',args=>join(',',@_)});}" -"sub respawn{push(@cmd_queue,{func=>'respawn',args=>join(',',@_)});}" -"sub stop{push(@cmd_queue,{func=>'stop',args=>join(',',@_)});}" -"sub pause{push(@cmd_queue,{func=>'pause',args=>join(',',@_)});}" -"sub resume{push(@cmd_queue,{func=>'resume',args=>join(',',@_)});}" -"sub start{push(@cmd_queue,{func=>'start',args=>join(',',@_)});}" -"sub moveto{push(@cmd_queue,{func=>'moveto',args=>join(',',@_)});}" -"sub warp{push(@cmd_queue,{func=>'warp',args=>join(',',@_)});}" -"sub changedeity{push(@cmd_queue,{func=>'changedeity',args=>join(',',@_)});}" -"sub addldonpoints{push(@cmd_queue,{func=>'addldonpoints',args=>join(',',@_)});}" -"sub addloot{push(@cmd_queue,{func=>'addloot',args=>join(',',@_)});}" -"sub traindisc{push(@cmd_queue,{func=>'traindisc',args=>join(',',@_)});}" -"sub set_proximity{push(@cmd_queue,{func=>'set_proximity',args=>join(',',@_)});}" -"sub clear_proximity{push(@cmd_queue,{func=>'clear_proximity',args=>join(',',@_)});}" -"sub setanim{push(@cmd_queue,{func=>'setanim',args=>join(',',@_)});}" -"sub showgrid{push(@cmd_queue,{func=>'showgrid',args=>join(',',@_)});}" -"sub showpath{push(@cmd_queue,{func=>'showpath',args=>join(',',@_)});}" -"sub pathto{push(@cmd_queue,{func=>'pathto',args=>join(',',@_)});}" -"sub spawn_condition{push(@cmd_queue,{func=>'spawn_condition',args=>join(',',@_)});}" -"sub toggle_spawn_event{push(@cmd_queue,{func=>'toggle_spawn_event',args=>join(',',@_)});}" -"sub set_zone_flag{push(@cmd_queue,{func=>'set_zone_flag',args=>join(',',@_)});}" -"sub clear_zone_flag{push(@cmd_queue,{func=>'clear_zone_flag',args=>join(',',@_)});}" -"package main;" -"}" -);//eval -} - -#endif //EMBPERL - -#endif //EMBPARSER_CPP +//#endif //EMBPARSER_CPP diff --git a/zone/embparser.h b/zone/embparser.h index 1adc7cfde..5eda1dbd3 100644 --- a/zone/embparser.h +++ b/zone/embparser.h @@ -1,122 +1,42 @@ -//extends the parser to include perl -//Eglin - -#ifndef EMBPARSER_H -#define EMBPARSER_H - +#ifndef EQEMU_EMBPARSER_H +#define EQMEU_EMBPARSER_H #ifdef EMBPERL + #include "client.h" -#include "parser.h" -#include "embperl.h" #include "../common/features.h" #include "QuestParserCollection.h" #include "QuestInterface.h" - #include #include #include -using namespace std; +#include "embperl.h" -class Seperator; - -typedef enum { - questDefault = 1, - questDefaultByZone, - questByName, - questTemplate, - questTemplateByID, - questByID -} questMode; - -typedef enum { - itemQuestUnloaded = 1, - itemQuestScale, - itemQuestLore, - itemQuestID, - itemScriptFileID -} itemQuestMode; - -typedef enum { - pQuestLoaded = 1, - pQuestUnloaded, - pQuestEventCast, // player.pl loaded, has an EVENT_CAST sub - pQuestReadyToLoad -} playerQuestMode; - -typedef enum { - nQuestLoaded = 1, - nQuestUnloaded, - nQuestReadyToLoad -} GlobalNPCQuestMode; - -typedef enum { - spellQuestUnloaded = 1, - spellQuestFullyLoaded, - spellQuestFailed -} spellQuestMode; - - -struct EventRecord { - QuestEventID event; - uint32 objid; - string data; - NPC* npcmob; - ItemInst* iteminst; - Mob* mob; - uint32 extradata; - bool global; -}; - -class PerlembParser : public Parser +typedef enum { -protected: - - //could prolly get rid of this map now, since I check for the - //actual subroutine in the quest package as opposed to just seeing - //if they do not have a quest or the default. - map hasQuests; //npcid -> questMode - map playerQuestLoaded; //zone shortname -> playerQuestMode - playerQuestMode globalPlayerQuestLoaded; - GlobalNPCQuestMode globalNPCQuestLoaded; - map itemQuestLoaded; // package name - > itemQuestMode - map spellQuestLoaded; + questUnloaded, + questLoaded, + questFailedToLoad +} PerlQuestStatus; - queue eventQueue; //for events that happen when perl is in use. - bool eventQueueProcessing; - - void HandleQueue(); - - void EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global = false); - - Embperl * perl; - //export a symbol table of sorts - virtual void map_funs(); +class PerlembParser : public QuestInterface { public: - PerlembParser(void); + PerlembParser(); ~PerlembParser(); - Embperl * getperl(void) { return perl; }; - //todo, consider making the following two methods static (need to check for perl!=null, first, then) - bool isloaded(const char *packagename) const; - - //interface stuff - virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); + + virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data); virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); - virtual bool HasQuestSub(uint32 npcid, const char *subname); + virtual bool HasQuestSub(uint32 npcid, const char *subname); virtual bool HasGlobalQuestSub(const char *subname); virtual bool PlayerHasQuestSub(const char *subname); virtual bool GlobalPlayerHasQuestSub(const char *subname); virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); - virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); - - virtual void ReloadQuests(bool with_timers = false); - virtual void AddVar(std::string name, std::string val) { Parser::AddVar(name, val); }; - virtual uint32 GetIdentifier() { return 0xf8b05c11; } + virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); virtual void LoadNPCScript(std::string filename, int npc_id); virtual void LoadGlobalNPCScript(std::string filename); @@ -125,39 +45,200 @@ public: virtual void LoadItemScript(std::string filename, std::string item_script); virtual void LoadSpellScript(std::string filename, uint32 spell_id); - //int LoadScript(int npcid, const char * zone, Mob* activater=0); - //int LoadGlobalNPCScript(); - //int LoadPlayerScript(const char *zone); - //int LoadGlobalPlayerScript(); - //int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype); - //int LoadSpellScript(uint32 id); + virtual void AddVar(std::string name, std::string val); + virtual std::string GetVar(std::string name); + virtual void ReloadQuests(); + virtual uint32 GetIdentifier() { return 0xf8b05c11; } +private: + Embperl *perl; - //expose a var to the script (probably parallels addvar)) - //i.e. exportvar("qst1234", "name", "somemob"); - //would expose the variable $name='somemob' to the script that handles npc1234 - void ExportHash(const char *pkgprefix, const char *hashname, std::map &vals); - void ExportVar(const char * pkgprefix, const char * varname, const char * value) const; - void ExportVar(const char * pkgprefix, const char * varname, int value) const; - void ExportVar(const char * pkgprefix, const char * varname, unsigned int value) const; - void ExportVar(const char * pkgprefix, const char * varname, float value) const; - //I don't escape the strings, so use caution!! - //Same as export var, except value is not quoted, and is evaluated as perl - void ExportVarComplex(const char * pkgprefix, const char * varname, const char * value) const; - - //get an appropriate namespage/packagename from an npcid - std::string GetPkgPrefix(uint32 npcid, bool defaultOK = true); - //call the appropriate perl handler. afterwards, parse and dispatch the command queue - //SendCommands("qst1234", "EVENT_SAY") would trigger sub EVENT_SAY() from the qst1234.pl file - virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); - - int HasQuestFile(uint32 npcid); + void ExportHash(const char *pkgprefix, const char *hashname, std::map &vals); + void ExportVar(const char *pkgprefix, const char *varname, const char *value) const; + void ExportVar(const char *pkgprefix, const char *varname, int32 value) const; + void ExportVar(const char *pkgprefix, const char *varname, uint32 value) const; + void ExportVar(const char *pkgprefix, const char *varname, float value) const; + void ExportVarComplex(const char *pkgprefix, const char *varname, const char *value) const; -#ifdef EMBPERL_COMMANDS - void ExecCommand(Client *c, Seperator *sep); -#endif - + void EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, + uint32 extradata, bool global); + void SendCommands(const char *pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); + void MapFunctions(); + + std::map npc_quest_status_; + PerlQuestStatus global_npc_quest_status_; + PerlQuestStatus player_quest_status_; + PerlQuestStatus global_player_quest_status_; + std::map item_quest_status_; + std::map spell_quest_status_; }; -#endif //EMBPERL +#endif +#endif -#endif //EMBPARSER_H + + + + +////extends the parser to include perl +////Eglin +// +//#ifndef EMBPARSER_H +//#define EMBPARSER_H +// +//#ifdef EMBPERL +// +//#include "client.h" +//#include "parser.h" +//#include "embperl.h" +//#include "../common/features.h" +//#include "QuestParserCollection.h" +//#include "QuestInterface.h" +// +//#include +//#include +//#include +//using namespace std; +// +//class Seperator; +// +//typedef enum { +// questDefault = 1, +// questDefaultByZone, +// questByName, +// questTemplate, +// questTemplateByID, +// questByID +//} questMode; +// +//typedef enum { +// itemQuestUnloaded = 1, +// itemQuestScale, +// itemQuestLore, +// itemQuestID, +// itemScriptFileID +//} itemQuestMode; +// +//typedef enum { +// pQuestLoaded = 1, +// pQuestUnloaded, +// pQuestEventCast, // player.pl loaded, has an EVENT_CAST sub +// pQuestReadyToLoad +//} playerQuestMode; +// +//typedef enum { +// nQuestLoaded = 1, +// nQuestUnloaded, +// nQuestReadyToLoad +//} GlobalNPCQuestMode; +// +//typedef enum { +// spellQuestUnloaded = 1, +// spellQuestFullyLoaded, +// spellQuestFailed +//} spellQuestMode; +// +// +//struct EventRecord { +// QuestEventID event; +// uint32 objid; +// string data; +// NPC* npcmob; +// ItemInst* iteminst; +// Mob* mob; +// uint32 extradata; +// bool global; +//}; +// +//class PerlembParser : public Parser +//{ +//protected: +// +// //could prolly get rid of this map now, since I check for the +// //actual subroutine in the quest package as opposed to just seeing +// //if they do not have a quest or the default. +// map hasQuests; //npcid -> questMode +// map playerQuestLoaded; //zone shortname -> playerQuestMode +// playerQuestMode globalPlayerQuestLoaded; +// GlobalNPCQuestMode globalNPCQuestLoaded; +// map itemQuestLoaded; // package name - > itemQuestMode +// map spellQuestLoaded; +// +// queue eventQueue; //for events that happen when perl is in use. +// bool eventQueueProcessing; +// +// void HandleQueue(); +// +// void EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global = false); +// +// Embperl * perl; +// //export a symbol table of sorts +// virtual void map_funs(); +//public: +// PerlembParser(void); +// ~PerlembParser(); +// Embperl * getperl(void) { return perl; }; +// //todo, consider making the following two methods static (need to check for perl!=null, first, then) +// bool isloaded(const char *packagename) const; +// +// //interface stuff +// virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); +// virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); +// virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); +// virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); +// virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data); +// virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); +// +// virtual bool HasQuestSub(uint32 npcid, const char *subname); +// virtual bool HasGlobalQuestSub(const char *subname); +// virtual bool PlayerHasQuestSub(const char *subname); +// virtual bool GlobalPlayerHasQuestSub(const char *subname); +// virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); +// virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); +// +// virtual void ReloadQuests(bool with_timers = false); +// virtual void AddVar(std::string name, std::string val) { Parser::AddVar(name, val); }; +// virtual uint32 GetIdentifier() { return 0xf8b05c11; } +// +// virtual void LoadNPCScript(std::string filename, int npc_id); +// virtual void LoadGlobalNPCScript(std::string filename); +// virtual void LoadPlayerScript(std::string filename); +// virtual void LoadGlobalPlayerScript(std::string filename); +// virtual void LoadItemScript(std::string filename, std::string item_script); +// virtual void LoadSpellScript(std::string filename, uint32 spell_id); +// +// //int LoadScript(int npcid, const char * zone, Mob* activater=0); +// //int LoadGlobalNPCScript(); +// //int LoadPlayerScript(const char *zone); +// //int LoadGlobalPlayerScript(); +// //int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype); +// //int LoadSpellScript(uint32 id); +// +// //expose a var to the script (probably parallels addvar)) +// //i.e. exportvar("qst1234", "name", "somemob"); +// //would expose the variable $name='somemob' to the script that handles npc1234 +// void ExportHash(const char *pkgprefix, const char *hashname, std::map &vals); +// void ExportVar(const char * pkgprefix, const char * varname, const char * value) const; +// void ExportVar(const char * pkgprefix, const char * varname, int value) const; +// void ExportVar(const char * pkgprefix, const char * varname, unsigned int value) const; +// void ExportVar(const char * pkgprefix, const char * varname, float value) const; +// //I don't escape the strings, so use caution!! +// //Same as export var, except value is not quoted, and is evaluated as perl +// void ExportVarComplex(const char * pkgprefix, const char * varname, const char * value) const; +// +// //get an appropriate namespage/packagename from an npcid +// std::string GetPkgPrefix(uint32 npcid, bool defaultOK = true); +// //call the appropriate perl handler. afterwards, parse and dispatch the command queue +// //SendCommands("qst1234", "EVENT_SAY") would trigger sub EVENT_SAY() from the qst1234.pl file +// virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); +// +// int HasQuestFile(uint32 npcid); +// +//#ifdef EMBPERL_COMMANDS +// void ExecCommand(Client *c, Seperator *sep); +//#endif +// +//}; +// +//#endif //EMBPERL +// +//#endif //EMBPARSER_H diff --git a/zone/embperl.cpp b/zone/embperl.cpp index 8895b500c..1c0b70c9e 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -21,29 +21,24 @@ Eglin #define GvCV_set(gv,cv) (GvCV(gv) = (cv)) #endif -#ifdef EMBPERL_XS -EXTERN_C XS(boot_quest); -#ifdef EMBPERL_XS_CLASSES -EXTERN_C XS(boot_Mob); -EXTERN_C XS(boot_NPC); -EXTERN_C XS(boot_Client); -EXTERN_C XS(boot_Corpse); -EXTERN_C XS(boot_EntityList); -EXTERN_C XS(boot_Group); -EXTERN_C XS(boot_Raid); -EXTERN_C XS(boot_QuestItem); -EXTERN_C XS(boot_HateEntry); -EXTERN_C XS(boot_Object); -EXTERN_C XS(boot_Doors); -EXTERN_C XS(boot_PerlPacket); -/*XS(XS_Client_new); -//XS(XS_Mob_new); -XS(XS_NPC_new); -//XS(XS_Corpse_new); -XS(XS_EntityList_new); -//XS(XS_Group_new);*/ -#endif -#endif +//PERL_TODO: +//#ifdef EMBPERL_XS +//EXTERN_C XS(boot_quest); +//#ifdef EMBPERL_XS_CLASSES +//EXTERN_C XS(boot_Mob); +//EXTERN_C XS(boot_NPC); +//EXTERN_C XS(boot_Client); +//EXTERN_C XS(boot_Corpse); +//EXTERN_C XS(boot_EntityList); +//EXTERN_C XS(boot_Group); +//EXTERN_C XS(boot_Raid); +//EXTERN_C XS(boot_QuestItem); +//EXTERN_C XS(boot_HateEntry); +//EXTERN_C XS(boot_Object); +//EXTERN_C XS(boot_Doors); +//EXTERN_C XS(boot_PerlPacket); +//#endif +//#endif #ifdef EMBPERL_COMMANDS XS(XS_command_add); #endif @@ -66,30 +61,31 @@ EXTERN_C void xs_init(pTHX) newXS(strcpy(buf, "DynaLoader::boot_DynaLoader"), boot_DynaLoader, file); newXS(strcpy(buf, "quest::boot_qc"), boot_qc, file); -#ifdef EMBPERL_XS - newXS(strcpy(buf, "quest::boot_quest"), boot_quest, file); -#ifdef EMBPERL_XS_CLASSES - newXS(strcpy(buf, "Mob::boot_Mob"), boot_Mob, file); - newXS(strcpy(buf, "NPC::boot_Mob"), boot_Mob, file); - newXS(strcpy(buf, "NPC::boot_NPC"), boot_NPC, file); -/// newXS(strcpy(buf, "NPC::new"), XS_NPC_new, file); - newXS(strcpy(buf, "Corpse::boot_Mob"), boot_Mob, file); - newXS(strcpy(buf, "Corpse::boot_Corpse"), boot_Corpse, file); - newXS(strcpy(buf, "Client::boot_Mob"), boot_Mob, file); - newXS(strcpy(buf, "Client::boot_Client"), boot_Client, file); -// newXS(strcpy(buf, "Client::new"), XS_Client_new, file); - newXS(strcpy(buf, "EntityList::boot_EntityList"), boot_EntityList, file); -// newXS(strcpy(buf, "EntityList::new"), XS_EntityList_new, file); - newXS(strcpy(buf, "PerlPacket::boot_PerlPacket"), boot_PerlPacket, file); - newXS(strcpy(buf, "Group::boot_Group"), boot_Group, file); - newXS(strcpy(buf, "Raid::boot_Raid"), boot_Raid, file); - newXS(strcpy(buf, "QuestItem::boot_QuestItem"), boot_QuestItem, file); - newXS(strcpy(buf, "HateEntry::boot_HateEntry"), boot_HateEntry, file); - newXS(strcpy(buf, "Object::boot_Object"), boot_Object, file); - newXS(strcpy(buf, "Doors::boot_Doors"), boot_Doors, file); -; -#endif -#endif + //PERL_TODO: +//#ifdef EMBPERL_XS +// newXS(strcpy(buf, "quest::boot_quest"), boot_quest, file); +//#ifdef EMBPERL_XS_CLASSES +// newXS(strcpy(buf, "Mob::boot_Mob"), boot_Mob, file); +// newXS(strcpy(buf, "NPC::boot_Mob"), boot_Mob, file); +// newXS(strcpy(buf, "NPC::boot_NPC"), boot_NPC, file); +///// newXS(strcpy(buf, "NPC::new"), XS_NPC_new, file); +// newXS(strcpy(buf, "Corpse::boot_Mob"), boot_Mob, file); +// newXS(strcpy(buf, "Corpse::boot_Corpse"), boot_Corpse, file); +// newXS(strcpy(buf, "Client::boot_Mob"), boot_Mob, file); +// newXS(strcpy(buf, "Client::boot_Client"), boot_Client, file); +//// newXS(strcpy(buf, "Client::new"), XS_Client_new, file); +// newXS(strcpy(buf, "EntityList::boot_EntityList"), boot_EntityList, file); +//// newXS(strcpy(buf, "EntityList::new"), XS_EntityList_new, file); +// newXS(strcpy(buf, "PerlPacket::boot_PerlPacket"), boot_PerlPacket, file); +// newXS(strcpy(buf, "Group::boot_Group"), boot_Group, file); +// newXS(strcpy(buf, "Raid::boot_Raid"), boot_Raid, file); +// newXS(strcpy(buf, "QuestItem::boot_QuestItem"), boot_QuestItem, file); +// newXS(strcpy(buf, "HateEntry::boot_HateEntry"), boot_HateEntry, file); +// newXS(strcpy(buf, "Object::boot_Object"), boot_Object, file); +// newXS(strcpy(buf, "Doors::boot_Doors"), boot_Doors, file); +//; +//#endif +//#endif #ifdef EMBPERL_COMMANDS newXS(strcpy(buf, "commands::command_add"), XS_command_add, file); #endif @@ -186,18 +182,6 @@ void Embperl::DoInit() { "package plugin; " ,FALSE ); -#ifdef EMBPERL_EVAL_COMMANDS - try { - eval_pv( - "use IO::Scalar;" - "$plugin::printbuff='';" - "tie *PLUGIN,'IO::Scalar',\\$plugin::printbuff;" - ,FALSE); - } - catch(const char *err) { - throw "failed to install plugin printhook, do you lack IO::Scalar?"; - } -#endif LogFile->write(EQEMuLog::Quest, "Loading perlemb plugins."); try diff --git a/zone/lua_parser.h b/zone/lua_parser.h index 7e9c78bc7..374a2e739 100644 --- a/zone/lua_parser.h +++ b/zone/lua_parser.h @@ -11,24 +11,31 @@ class ItemInst; class Client; class NPC; -class LuaParser { +class LuaParser : public QuestInterface { public: - virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); - virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); - virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); - virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); - virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data); - virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); - - virtual bool HasQuestSub(uint32 npcid, const char *subname); - virtual bool HasGlobalQuestSub(const char *subname); - virtual bool PlayerHasQuestSub(const char *subname); - virtual bool GlobalPlayerHasQuestSub(const char *subname); - virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); - virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); - - virtual void AddVar(std::string name, std::string val); - virtual void ReloadQuests(bool reset_timers = true); + //virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); + //virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); + //virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); + //virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data); + //virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data); + //virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); + // + //virtual bool HasQuestSub(uint32 npcid, const char *subname); + //virtual bool HasGlobalQuestSub(const char *subname); + //virtual bool PlayerHasQuestSub(const char *subname); + //virtual bool GlobalPlayerHasQuestSub(const char *subname); + //virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); + //virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); + // + //virtual void LoadNPCScript(std::string filename, int npc_id) { } + ////virtual void LoadGlobalNPCScript(std::string filename) { } + //virtual void LoadPlayerScript(std::string filename) { } + ////virtual void LoadGlobalPlayerScript(std::string filename) { } + //virtual void LoadItemScript(std::string filename, std::string item_script) { } + //virtual void LoadSpellScript(std::string filename, uint32 spell_id) { } + // + //virtual void AddVar(std::string name, std::string val); + //virtual void ReloadQuests(bool reset_timers = true); virtual uint32 GetIdentifier() { return 0xb0712acc; } private: lua_State* L; diff --git a/zone/net.cpp b/zone/net.cpp index d6704531a..4e762a957 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -74,7 +74,6 @@ extern volatile bool ZoneLoaded; #include "../common/spdat.h" #include "zone.h" #include "command.h" -#include "parser.h" #include "embparser.h" #include "perlparser.h" #include "lua_parser.h" @@ -286,8 +285,9 @@ int main(int argc, char** argv) { parse = new QuestParserCollection(); #ifdef EMBPERL - PerlXSParser *pxs = new PerlXSParser(); - parse->RegisterQuestInterface(pxs, "pl"); + //PerlXSParser *pxs = new PerlXSParser(); + PerlembParser *perl_parser = new PerlembParser(); + parse->RegisterQuestInterface(perl_parser, "pl"); #endif #ifdef LUA_EQEMU @@ -295,10 +295,6 @@ int main(int argc, char** argv) { parse->RegisterQuestInterface(lua_parser, "lua"); #endif - Parser *ps = new Parser(); - //parse->RegisterQuestInterface(ps, "qst"); - - //now we have our parser, load the quests _log(ZONE__INIT, "Loading quests"); parse->ReloadQuests(); @@ -481,16 +477,14 @@ int main(int argc, char** argv) { entity_list.Clear(); - safe_delete(parse); #ifdef EMBPERL - safe_delete(pxs); + safe_delete(perl_parser); #endif #ifdef LUA_EQEMU safe_delete(lua_parser); #endif - safe_delete(ps); safe_delete(mmf); if (zone != 0) diff --git a/zone/perlparser.cpp b/zone/perlparser.cpp index c1fe55dbc..44348692c 100644 --- a/zone/perlparser.cpp +++ b/zone/perlparser.cpp @@ -16,3714 +16,3714 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../common/features.h" - -#ifdef EMBPERL -#ifdef EMBPERL_XS - -#include "../common/debug.h" -#include "perlparser.h" -#include "questmgr.h" -#include "embxs.h" -#include "entity.h" -#include "../common/MiscFunctions.h" -#include "zone.h" -extern Zone* zone; - -/* - -Some useful perl API info: - -SvUV == string to unsigned value (char->ulong) -SvIV == string to signed value (char->long) -SvNV == string to real value (float,double) -SvPV_nolen == string with no length restriction - - -*/ - -PerlXSParser::PerlXSParser() : PerlembParser() { - //we cannot rely on PerlembParser to call the right map_funs because - //our virtual table is not set up until after we call them, so we need to move - //the call to ReloadQuests out of the constructor. -} - -void PerlXSParser::map_funs() { - _empty_sv = newSV(0); - - perl->eval( - "{" - "package quest;" - "&boot_quest;" //load our quest XS -#ifdef EMBPERL_XS_CLASSES - "package Mob;" - "&boot_Mob;" //load our Mob XS - - "package Client;" - "our @ISA = qw(Mob);" //client inherits mob. - "&boot_Mob;" //load our Mob XS - "&boot_Client;" //load our Client XS - - "package NPC;" - "our @ISA = qw(Mob);" //NPC inherits mob. - "&boot_Mob;" //load our Mob XS - "&boot_NPC;" //load our NPC XS - - "package Corpse;" - "our @ISA = qw(Mob);" //Corpse inherits mob. - "&boot_Mob;" //load our Mob XS - "&boot_Corpse;" //load our Mob XS - - "package EntityList;" - "&boot_EntityList;" //load our EntityList XS - - "package PerlPacket;" - "&boot_PerlPacket;" //load our PerlPacket XS - - "package Group;" - "&boot_Group;" //load our Group XS - - "package Raid;" - "&boot_Raid;" //load our Raid XS - - "package QuestItem;" - "&boot_QuestItem;" // load quest Item XS - - "package HateEntry;" - "&boot_HateEntry;" // load quest Hate XS - - "package Object;" - "&boot_Object;" // load quest Object XS - - "package Doors;" - "&boot_Doors;" // load quest Doors XS - -#endif - "package main;" - "}" - );//eval -} - -void PerlXSParser::SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst) -{ - if(!perl) - return; - _ZP(PerlXSParser_SendCommands); - - if(mob && mob->IsClient()) - quest_manager.StartQuest(other, mob->CastToClient(), iteminst); - else - quest_manager.StartQuest(other, nullptr, nullptr); - - try { - - std::string cmd = "package " + (std::string)(pkgprefix) + (std::string)(";"); - perl->eval(cmd.c_str()); - -#ifdef EMBPERL_XS_CLASSES - char namebuf[64]; - - //init a couple special vars: client, npc, entity_list - Client *curc = quest_manager.GetInitiator(); - snprintf(namebuf, 64, "%s::client", pkgprefix); - SV *client = get_sv(namebuf, true); - if(curc != nullptr) { - sv_setref_pv(client, "Client", curc); - } else { - //clear out the value, mainly to get rid of blessedness - sv_setsv(client, _empty_sv); - } - - //only export NPC if it's a npc quest - if(!other->IsClient()){ - NPC *curn = quest_manager.GetNPC(); - snprintf(namebuf, 64, "%s::npc", pkgprefix); - SV *npc = get_sv(namebuf, true); - sv_setref_pv(npc, "NPC", curn); - } - - //only export QuestItem if it's an item quest - if(iteminst) { - ItemInst* curi = quest_manager.GetQuestItem(); - snprintf(namebuf, 64, "%s::questitem", pkgprefix); - SV *questitem = get_sv(namebuf, true); - sv_setref_pv(questitem, "QuestItem", curi); - } - - snprintf(namebuf, 64, "%s::entity_list", pkgprefix); - SV *el = get_sv(namebuf, true); - sv_setref_pv(el, "EntityList", &entity_list); -#endif - - //now call the requested sub - perl->dosub(std::string(pkgprefix).append("::").append(event).c_str()); - -#ifdef EMBPERL_XS_CLASSES - std::string eval_str = (std::string)"$" + (std::string)pkgprefix + (std::string)"::client = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::npc = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::questitem = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::entity_list = undef;"; - perl->eval(eval_str.c_str()); -#endif - - } catch(const char * err) { - - //try to reduce some of the console spam... - //todo: tweak this to be more accurate at deciding what to filter (we don't want to gag legit errors) - if(!strstr(err,"Undefined subroutine")) - LogFile->write(EQEMuLog::Status, "Script error: %s::%s - %s", pkgprefix, event, err); - } - - quest_manager.EndQuest(); -} - - -#ifdef EMBPERL_XS_CLASSES - -//Any creation of new Client objects gets the current quest Client -XS(XS_Client_new); -XS(XS_Client_new) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::new()"); - { - Client * RETVAL; - - RETVAL = quest_manager.GetInitiator(); - ST(0) = sv_newmortal(); - if(RETVAL) - sv_setref_pv(ST(0), "Client", (void*)RETVAL); - } - XSRETURN(1); -} - -//Any creation of new NPC objects gets the current quest NPC -XS(XS_NPC_new); -XS(XS_NPC_new) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::new()"); - { - NPC * RETVAL; - - RETVAL = quest_manager.GetNPC(); - ST(0) = sv_newmortal(); - if(RETVAL) - sv_setref_pv(ST(0), "NPC", (void*)RETVAL); - } - XSRETURN(1); -} - -//Any creation of new NPC objects gets the current quest NPC -XS(XS_EntityList_new); -XS(XS_EntityList_new) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::new()"); - { - EntityList * RETVAL; - - RETVAL = &entity_list; - ST(0) = sv_newmortal(); - if(RETVAL) - sv_setref_pv(ST(0), "EntityList", (void*)RETVAL); - } - XSRETURN(1); -} - -//Any creation of new quest items gets the current quest item -XS(XS_QuestItem_new); -XS(XS_QuestItem_new) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: QuestItem::new()"); - - ItemInst* RETVAL; - - RETVAL = quest_manager.GetQuestItem(); - ST(0) = sv_newmortal(); - if(RETVAL) - sv_setref_pv(ST(0), "QuestItem", (void*)RETVAL); - - XSRETURN(1); -} - -//Any creation of new quest items gets the current quest item -XS(XS_MobList_new); -XS(XS_MobList_new) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: MobList::new()"); - - ListElement* RETVAL; - - RETVAL = nullptr; - ST(0) = sv_newmortal(); - if(RETVAL) - sv_setref_pv(ST(0), "MobList", (void*)RETVAL); - - XSRETURN(1); -} - -#endif //EMBPERL_XS_CLASSES - - -XS(XS__echo); // prototype to pass -Wmissing-prototypes -XS(XS__echo) { - dXSARGS; - - if (items != 2) - Perl_croak(aTHX_ "Usage: echo(id#, str)"); - - quest_manager.echo(SvUV(ST(0)), SvPV_nolen(ST(1))); - - XSRETURN_EMPTY; -} - -XS(XS__say); // prototype to pass -Wmissing-prototypes -XS(XS__say) { - dXSARGS; - - if (items == 1) - quest_manager.say(SvPV_nolen(ST(0))); - else if (items == 2) - quest_manager.say(SvPV_nolen(ST(0)), (int)SvIV(ST(1))); - else - Perl_croak(aTHX_ "Usage: say(str [, language])"); - - XSRETURN_EMPTY; -} - -XS(XS__me); // prototype to pass -Wmissing-prototypes -XS(XS__me) { - dXSARGS; - - if (items != 1) - Perl_croak(aTHX_ "Usage: %s(str)", "me"); - - quest_manager.me(SvPV_nolen(ST(0))); - - XSRETURN_EMPTY; -} - -XS(XS__summonitem); // prototype to pass -Wmissing-prototypes -XS(XS__summonitem) -{ - dXSARGS; - if (items == 1) - quest_manager.summonitem(SvUV(ST(0))); - else if(items == 2) - quest_manager.summonitem(SvUV(ST(0)), SvUV(ST(1))); - else - Perl_croak(aTHX_ "Usage: summonitem(itemid, [charges])"); - XSRETURN_EMPTY; -} - -XS(XS__write); -XS(XS__write) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: write(file, str)"); - - char * file = (char *)SvPV_nolen(ST(0)); - char * str = (char *)SvPV_nolen(ST(1)); - - quest_manager.write(file, str); - - XSRETURN_EMPTY; -} - -XS(XS__spawn); -XS(XS__spawn) -{ - dXSARGS; - if (items != 6) - Perl_croak(aTHX_ "Usage: spawn(npc_type, grid, unused, x, y, z)"); - - uint16 RETVAL; - dXSTARG; - - int npc_type = (int)SvIV(ST(0)); - int grid = (int)SvIV(ST(1)); - int unused = (int)SvIV(ST(2)); - float x = (float)SvNV(ST(3)); - float y = (float)SvNV(ST(4)); - float z = (float)SvNV(ST(5)); - - RETVAL = quest_manager.spawn2(npc_type, grid, unused, x, y, z, 0); - XSprePUSH; PUSHu((UV)RETVAL); - - XSRETURN(1); -} - -XS(XS__spawn2); -XS(XS__spawn2) -{ - dXSARGS; - if (items != 7) - Perl_croak(aTHX_ "Usage: spawn2(npc_type, grid, unused, x, y, z, heading)"); - - uint16 RETVAL; - dXSTARG; - - int npc_type = (int)SvIV(ST(0)); - int grid = (int)SvIV(ST(1)); - int unused = (int)SvIV(ST(2)); - float x = (float)SvNV(ST(3)); - float y = (float)SvNV(ST(4)); - float z = (float)SvNV(ST(5)); - float heading = (float)SvNV(ST(6)); - - RETVAL = quest_manager.spawn2(npc_type, grid, unused, x, y, z, heading); - XSprePUSH; PUSHu((UV)RETVAL); - - XSRETURN(1); -} - -XS(XS__unique_spawn); -XS(XS__unique_spawn) -{ - dXSARGS; - if (items != 6 && items != 7) - Perl_croak(aTHX_ "Usage: unique_spawn(npc_type, grid, unused, x, y, z, [heading])"); - - uint16 RETVAL; - dXSTARG; - - int npc_type = (int)SvIV(ST(0)); - int grid = (int)SvIV(ST(1)); - int unused = (int)SvIV(ST(2)); - float x = (float)SvNV(ST(3)); - float y = (float)SvNV(ST(4)); - float z = (float)SvNV(ST(5)); - float heading = 0; - if(items == 7) - heading = (float)SvNV(ST(6)); - - RETVAL = quest_manager.unique_spawn(npc_type, grid, unused, x, y, z, heading); - XSprePUSH; PUSHu((UV)RETVAL); - - XSRETURN(1); -} - -XS(XS__spawn_from_spawn2); -XS(XS__spawn_from_spawn2) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: spawn_from_spawn2(spawn2_id)"); - - uint16 RETVAL; - dXSTARG; - - int spawn2_id = (int)SvIV(ST(0)); - - RETVAL = quest_manager.spawn_from_spawn2(spawn2_id); - XSprePUSH; PUSHu((UV)RETVAL); - - XSRETURN(1); -} - -XS(XS__enable_spawn2); -XS(XS__enable_spawn2) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: enable_spawn2(spawn2_id)"); - - int spawn2_id = (int)SvIV(ST(0)); - - quest_manager.enable_spawn2(spawn2_id); - XSRETURN_EMPTY; -} - -XS(XS__disable_spawn2); -XS(XS__disable_spawn2) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: disable_spawn2(spawn2_id)"); - - int spawn2_id = (int)SvIV(ST(0)); - - quest_manager.disable_spawn2(spawn2_id); - XSRETURN_EMPTY; -} - -XS(XS__setstat); -XS(XS__setstat) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: setstat(stat, value)"); - - int stat = (int)SvIV(ST(0)); - int value = (int)SvIV(ST(1)); - - quest_manager.setstat(stat, value); - - XSRETURN_EMPTY; -} - -XS(XS__incstat); //old setstat command aza -XS(XS__incstat) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: incstat(stat, value)"); - - int stat = (int)SvIV(ST(0)); - int value = (int)SvIV(ST(1)); - - quest_manager.incstat(stat, value); - - XSRETURN_EMPTY; -} - -XS(XS__castspell); -XS(XS__castspell) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: castspell(spell_id, target_id)"); - - int spell_id = (int)SvIV(ST(0)); - int target_id = (int)SvIV(ST(1)); - - quest_manager.castspell(spell_id, target_id); - - XSRETURN_EMPTY; -} - -XS(XS__selfcast); -XS(XS__selfcast) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: selfcast(spell_id)"); - - int spell_id = (int)SvIV(ST(0)); - - quest_manager.selfcast(spell_id); - - XSRETURN_EMPTY; -} - -XS(XS__addloot); -XS(XS__addloot) -{ - dXSARGS; - if(items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: addloot(item_id, charges = 0, equipitem = true)"); - - uint32 itemid = (uint32)SvUV(ST(0)); - uint16 charges = 0; - bool equipitem = true; - - if (items > 1) - charges = (uint16)SvUV(ST(1)); - if (items > 2) - equipitem = (bool)SvTRUE(ST(2)); - - quest_manager.addloot(itemid, charges, equipitem); - - XSRETURN_EMPTY; -} - -XS(XS__zone); -XS(XS__zone) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: zone(zone_name)"); - - char * zone_name = (char *)SvPV_nolen(ST(0)); - - quest_manager.Zone(zone_name); - - XSRETURN_EMPTY; -} - -XS(XS__settimer); -XS(XS__settimer) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: settimer(timer_name, seconds)"); - - char * timer_name = (char *)SvPV_nolen(ST(0)); - int seconds = (int)SvIV(ST(1)); - - quest_manager.settimer(timer_name, seconds); - - XSRETURN_EMPTY; -} - -XS(XS__settimerMS); -XS(XS__settimerMS) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: settimerMS(timer_name, milliseconds)"); - - char * timer_name = (char *)SvPV_nolen(ST(0)); - int milliseconds = (int)SvIV(ST(1)); - - quest_manager.settimerMS(timer_name, milliseconds); - - XSRETURN_EMPTY; -} - -XS(XS__stoptimer); -XS(XS__stoptimer) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: stoptimer(timer_name)"); - - char * timer_name = (char *)SvPV_nolen(ST(0)); - - quest_manager.stoptimer(timer_name); - - XSRETURN_EMPTY; -} - -XS(XS__stopalltimers); -XS(XS__stopalltimers) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: stopalltimers()"); - - quest_manager.stopalltimers(); - - XSRETURN_EMPTY; -} - -XS(XS__emote); -XS(XS__emote) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: emote(str)"); - - char * str = (char *)SvPV_nolen(ST(0)); - - quest_manager.emote(str); - - XSRETURN_EMPTY; -} - -XS(XS__shout); -XS(XS__shout) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: shout(str)"); - - char * str = (char *)SvPV_nolen(ST(0)); - - quest_manager.shout(str); - - XSRETURN_EMPTY; -} - -XS(XS__shout2); -XS(XS__shout2) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: shout2(str)"); - - char * str = (char *)SvPV_nolen(ST(0)); - - quest_manager.shout2(str); - - XSRETURN_EMPTY; -} - -XS(XS__gmsay); -XS(XS__gmsay) -{ - dXSARGS; - if ((items < 1) || (items > 5)) - Perl_croak(aTHX_ "Usage: gmsay(str, color, send_to_world?)"); - - char * str = (char *)SvPV_nolen(ST(0)); - int color = 7; - bool send_to_world = 0; - uint32 to_guilddbid = 0; - uint16 to_minstatus = 80; - - if (items > 1) { - color = (int)SvIV(ST(1)); - } - - if (items > 2) { - send_to_world = ((int)SvIV(ST(2))) == 0?false:true; - } - - if (items > 3) - to_guilddbid = (int)SvUV(ST(3)); - - if (items > 4) - to_minstatus = (int)SvUV(ST(4)); - - quest_manager.gmsay(str, color, send_to_world, to_guilddbid, to_minstatus); - - XSRETURN_EMPTY; -} - -XS(XS__depop); -XS(XS__depop) -{ - dXSARGS; - if (items < 0 || items > 1) - Perl_croak(aTHX_ "Usage: depop(npc_type= 0)"); - - int npc_type; - - if (items < 1) - npc_type = 0; - else - npc_type = (int)SvIV(ST(0)); - - - quest_manager.depop(npc_type); - - XSRETURN_EMPTY; -} - -XS(XS__depop_withtimer); -XS(XS__depop_withtimer) -{ - dXSARGS; - if (items < 0 || items > 1) - Perl_croak(aTHX_ "Usage: depop_withtimer(npc_type= 0)"); - - int npc_type; - - if (items < 1) - npc_type = 0; - else - npc_type = (int)SvIV(ST(0)); - - - quest_manager.depop_withtimer(npc_type); - - XSRETURN_EMPTY; -} - -XS(XS__depopall); -XS(XS__depopall) -{ - dXSARGS; - if (items < 0 || items > 1) - Perl_croak(aTHX_ "Usage: depopall(npc_type= 0)"); - - int npc_type; - - if (items < 1) - npc_type = 0; - else - npc_type = (int)SvIV(ST(0)); - - - quest_manager.depopall(npc_type); - - XSRETURN_EMPTY; -} - -XS(XS__settarget); -XS(XS__settarget) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: settarget(type, target_id)"); - - char * type = (char *)SvPV_nolen(ST(0)); - int target_id = (int)SvIV(ST(1)); - - quest_manager.settarget(type, target_id); - - XSRETURN_EMPTY; -} - -XS(XS__follow); -XS(XS__follow) -{ - dXSARGS; - if (items != 1 && items != 2) - Perl_croak(aTHX_ "Usage: follow(entity_id, [distance])"); - - int entity_id = (int)SvIV(ST(0)); - int distance; - - if (items == 2) - distance = (int)SvIV(ST(1)); - else - distance = 10; - - quest_manager.follow(entity_id, distance); - - XSRETURN_EMPTY; -} - -XS(XS__sfollow); -XS(XS__sfollow) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: sfollow()"); - - - quest_manager.sfollow(); - - XSRETURN_EMPTY; -} - -XS(XS__changedeity); -XS(XS__changedeity) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: changedeity(diety_id)"); - - int diety_id = (int)SvIV(ST(0)); - - quest_manager.changedeity(diety_id); - - XSRETURN_EMPTY; -} - -XS(XS__exp); -XS(XS__exp) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: exp(amt)"); - - int amt = (int)SvIV(ST(0)); - - quest_manager.exp(amt); - - XSRETURN_EMPTY; -} - -XS(XS__level); -XS(XS__level) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: level(newlevel)"); - - int newlevel = (int)SvIV(ST(0)); - - quest_manager.level(newlevel); - - XSRETURN_EMPTY; -} - -XS(XS__traindisc); -XS(XS__traindisc) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: traindisc(discipline_tome_item_id)"); - - int discipline_tome_item_id = (int)SvIV(ST(0)); - - quest_manager.traindisc(discipline_tome_item_id); - - XSRETURN_EMPTY; -} - -XS(XS__isdisctome); -XS(XS__isdisctome) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: isdisctome(item_id)"); - - bool RETVAL; - int item_id = (int)SvIV(ST(0)); - - RETVAL = quest_manager.isdisctome(item_id); - - ST(0) = boolSV(RETVAL); - sv_2mortal(ST(0)); - XSRETURN(1); -} - -XS(XS__safemove); -XS(XS__safemove) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: safemove()"); - - - quest_manager.safemove(); - - XSRETURN_EMPTY; -} - -XS(XS__rain); -XS(XS__rain) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: rain(weather)"); - - int weather = (int)SvIV(ST(0)); - - quest_manager.rain(weather); - - XSRETURN_EMPTY; -} - -XS(XS__snow); -XS(XS__snow) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: snow(weather)"); - - int weather = (int)SvIV(ST(0)); - - quest_manager.snow(weather); - - XSRETURN_EMPTY; -} - -XS(XS__surname); -XS(XS__surname) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: surname(name)"); - - char * name = (char *)SvPV_nolen(ST(0)); - - quest_manager.surname(name); - - XSRETURN_EMPTY; -} - -XS(XS__permaclass); -XS(XS__permaclass) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: permaclass(class_id)"); - - int class_id = (int)SvIV(ST(0)); - - quest_manager.permaclass(class_id); - - XSRETURN_EMPTY; -} - -XS(XS__permarace); -XS(XS__permarace) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: permarace(race_id)"); - - int race_id = (int)SvIV(ST(0)); - - quest_manager.permarace(race_id); - - XSRETURN_EMPTY; -} - -XS(XS__permagender); -XS(XS__permagender) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: permagender(gender_id)"); - - int gender_id = (int)SvIV(ST(0)); - - quest_manager.permagender(gender_id); - - XSRETURN_EMPTY; -} - -XS(XS__scribespells); -XS(XS__scribespells) -{ - dXSARGS; - if (items < 1) - Perl_croak(aTHX_ "Usage: scribespells(max_level, min_level = 1)"); - - uint16 RETVAL; - dXSTARG; - - uint8 max_level = (uint8)SvIV(ST(0)); - uint8 min_level = (uint8)SvIV(ST(1)); - - if (min_level) - RETVAL = quest_manager.scribespells(max_level, min_level); - else - RETVAL = quest_manager.scribespells(max_level); - - XSprePUSH; PUSHu((IV)RETVAL); - XSRETURN(1); -} - -XS(XS__traindiscs); -XS(XS__traindiscs) -{ - dXSARGS; - if (items < 1) - Perl_croak(aTHX_ "Usage: traindiscs(max_level, min_level = 1)"); - - uint16 RETVAL; - dXSTARG; - - uint8 max_level = (uint8)SvIV(ST(0)); - uint8 min_level = (uint8)SvIV(ST(1)); - - if (min_level) - RETVAL = quest_manager.traindiscs(max_level, min_level); - else - RETVAL = quest_manager.traindiscs(max_level); - - XSprePUSH; PUSHu((IV)RETVAL); - XSRETURN(1); -} - -XS(XS__unscribespells); -XS(XS__unscribespells) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: unscribespells()"); - - - quest_manager.unscribespells(); - - XSRETURN_EMPTY; -} - -XS(XS__untraindiscs); -XS(XS__untraindiscs) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: untraindiscs()"); - - - quest_manager.untraindiscs(); - - XSRETURN_EMPTY; -} - -XS(XS__givecash); -XS(XS__givecash) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: givecash(copper, silver, gold, platinum)"); - - int copper = (int)SvIV(ST(0)); - int silver = (int)SvIV(ST(1)); - int gold = (int)SvIV(ST(2)); - int platinum = (int)SvIV(ST(3)); - - quest_manager.givecash(copper, silver, gold, platinum); - - XSRETURN_EMPTY; -} - -XS(XS__pvp); -XS(XS__pvp) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: pvp(mode)"); - - char * mode = (char *)SvPV_nolen(ST(0)); - - quest_manager.pvp(mode); - - XSRETURN_EMPTY; -} - -XS(XS__movepc); -XS(XS__movepc) -{ - dXSARGS; - if (items != 4 && items != 5) - Perl_croak(aTHX_ "Usage: movepc(zone_id, x, y, z [,heading])"); - - int zoneid = (int)SvIV(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - - if (items == 4) - - quest_manager.movepc(zoneid, x, y, z, 0.0f); - - else { - float heading = (float)SvNV(ST(4)); - quest_manager.movepc(zoneid, x, y, z, heading); - } - - XSRETURN_EMPTY; -} - -XS(XS__gmmove); -XS(XS__gmmove) -{ - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: gmmove(x, y, z)"); - - float x = (float)SvNV(ST(0)); - float y = (float)SvNV(ST(1)); - float z = (float)SvNV(ST(2)); - - quest_manager.gmmove(x, y, z); - - XSRETURN_EMPTY; -} - -XS(XS__movegrp); -XS(XS__movegrp) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: movegrp(zoneid, x, y, z)"); - - int zoneid = (int)SvIV(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - - quest_manager.movegrp(zoneid, x, y, z); - - XSRETURN_EMPTY; -} - -XS(XS__doanim); -XS(XS__doanim) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: doanim(anim_id)"); - - int anim_id = (int)SvIV(ST(0)); - - quest_manager.doanim(anim_id); - - XSRETURN_EMPTY; -} - -XS(XS__addskill); -XS(XS__addskill) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: addskill(skill_id, value)"); - - int skill_id = (int)SvIV(ST(0)); - int value = (int)SvIV(ST(1)); - - quest_manager.addskill(skill_id, value); - - XSRETURN_EMPTY; -} - -XS(XS__setlanguage); -XS(XS__setlanguage) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: setlanguage(skill_id, value)"); - - int skill_id = (int)SvIV(ST(0)); - int value = (int)SvIV(ST(1)); - - quest_manager.setlanguage(skill_id, value); - - XSRETURN_EMPTY; -} - -XS(XS__setskill); -XS(XS__setskill) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: setskill(skill_id, value)"); - - int skill_id = (int)SvIV(ST(0)); - int value = (int)SvIV(ST(1)); - - quest_manager.setskill(skill_id, value); - - XSRETURN_EMPTY; -} - -XS(XS__setallskill); -XS(XS__setallskill) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: setallskill(value)"); - - int value = (int)SvIV(ST(0)); - - quest_manager.setallskill(value); - - XSRETURN_EMPTY; -} - -XS(XS__attack); -XS(XS__attack) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: attack(client_name)"); - - char * client_name = (char *)SvPV_nolen(ST(0)); - - quest_manager.attack(client_name); - - XSRETURN_EMPTY; -} - -XS(XS__attacknpc); -XS(XS__attacknpc) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: attacknpc(npc_entity_id)"); - - int npc_entity_id = (int)SvIV(ST(0)); - - quest_manager.attacknpc(npc_entity_id); - - XSRETURN_EMPTY; -} - -XS(XS__attacknpctype); -XS(XS__attacknpctype) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: attacknpctype(npc_type_id)"); - - int npc_type_id = (int)SvIV(ST(0)); - - quest_manager.attacknpctype(npc_type_id); - - XSRETURN_EMPTY; -} - -XS(XS__save); -XS(XS__save) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: save()"); - - - quest_manager.save(); - - XSRETURN_EMPTY; -} - -XS(XS__faction); -XS(XS__faction) -{ - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: faction(faction_id, faction_value, temp)"); - - int faction_id = (int)SvIV(ST(0)); - int faction_value = (int)SvIV(ST(1)); - int temp; - - if(items == 2) - temp = 0; - else - temp = (int)SvIV(ST(2)); - - quest_manager.faction(faction_id, faction_value, temp); - - XSRETURN_EMPTY; -} - -XS(XS__setsky); -XS(XS__setsky) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: setsky(new_sky)"); - - unsigned char new_sky = (unsigned char)SvUV(ST(0)); - - quest_manager.setsky(new_sky); - - XSRETURN_EMPTY; -} - -XS(XS__setguild); -XS(XS__setguild) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: setguild(new_guild_id, new_rank)"); - - unsigned long new_guild_id = (unsigned long)SvUV(ST(0)); - int new_rank = (int)SvIV(ST(1)); - - quest_manager.setguild(new_guild_id, new_rank); - - XSRETURN_EMPTY; -} - -XS(XS__createguild); -XS(XS__createguild) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: createguild(guild_name, leader)"); - - char * guild_name = (char *)SvPV_nolen(ST(0)); - char * leader = (char *)SvPV_nolen(ST(1)); - - quest_manager.CreateGuild(guild_name, leader); - - XSRETURN_EMPTY; -} - -XS(XS__settime); -XS(XS__settime) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: settime(new_hour, new_min)"); - - int new_hour = (int)SvIV(ST(0)); - int new_min = (int)SvIV(ST(1)); - - quest_manager.settime(new_hour, new_min); - - XSRETURN_EMPTY; -} - -XS(XS__itemlink); -XS(XS__itemlink) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: itemlink(item_id)"); - - int item_id = (int)SvIV(ST(0)); - - quest_manager.itemlink(item_id); - - XSRETURN_EMPTY; -} - -XS(XS__signalwith); -XS(XS__signalwith) -{ - dXSARGS; - - if (items == 2) { - int npc_id = (int)SvIV(ST(0)); - int signal_id = (int)SvIV(ST(1)); - quest_manager.signalwith(npc_id, signal_id); - } else if(items == 3) { - int npc_id = (int)SvIV(ST(0)); - int signal_id = (int)SvIV(ST(1)); - int wait = (int)SvIV(ST(2)); - quest_manager.signalwith(npc_id, signal_id, wait); - } else { - Perl_croak(aTHX_ "Usage: signalwith(npc_id,signal_id[,wait_ms])"); - } - - XSRETURN_EMPTY; -} - -XS(XS__signal); -XS(XS__signal) -{ - dXSARGS; - - if (items == 1) { - int npc_id = (int)SvIV(ST(0)); - quest_manager.signal(npc_id); - } else if(items == 2) { - int npc_id = (int)SvIV(ST(0)); - int wait = (int)SvIV(ST(1)); - quest_manager.signal(npc_id, wait); - } else { - Perl_croak(aTHX_ "Usage: signal(npc_id[,wait_ms])"); - } - - XSRETURN_EMPTY; -} - -XS(XS__setglobal); -XS(XS__setglobal) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: setglobal(varname, newvalue, options, duration)"); - - char * varname = (char *)SvPV_nolen(ST(0)); - char * newvalue = (char *)SvPV_nolen(ST(1)); - int options = (int)SvIV(ST(2)); - char * duration = (char *)SvPV_nolen(ST(3)); - - quest_manager.setglobal(varname, newvalue, options, duration); - - XSRETURN_EMPTY; -} - -XS(XS__targlobal); -XS(XS__targlobal) -{ - dXSARGS; - if (items != 6) - Perl_croak(aTHX_ "Usage: targlobal(varname, value, duration, npcid, charid, zoneid)"); - - char * varname = (char *)SvPV_nolen(ST(0)); - char * value = (char *)SvPV_nolen(ST(1)); - char * duration = (char *)SvPV_nolen(ST(2)); - int npcid = (int)SvIV(ST(3)); - int charid = (int)SvIV(ST(4)); - int zoneid = (int)SvIV(ST(5)); - - quest_manager.targlobal(varname, value, duration, npcid, charid, zoneid); - - XSRETURN_EMPTY; -} - -XS(XS__delglobal); -XS(XS__delglobal) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: delglobal(varname)"); - - char * varname = (char *)SvPV_nolen(ST(0)); - - quest_manager.delglobal(varname); - - XSRETURN_EMPTY; -} - -XS(XS__ding); -XS(XS__ding) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: ding()"); - - - quest_manager.ding(); - - XSRETURN_EMPTY; -} - -XS(XS__rebind); -XS(XS__rebind) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: rebind(zoneid, x, y, z)"); - - int zoneid = (int)SvIV(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - - quest_manager.rebind(zoneid, x, y, z); - - XSRETURN_EMPTY; -} - -XS(XS__start); -XS(XS__start) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: start(wp)"); - - int wp = (int)SvIV(ST(0)); - - quest_manager.start(wp); - - XSRETURN_EMPTY; -} - -XS(XS__stop); -XS(XS__stop) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: stop()"); - - - quest_manager.stop(); - - XSRETURN_EMPTY; -} - -XS(XS__pause); -XS(XS__pause) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: pause(duration)"); - - int duration = (int)SvIV(ST(0)); - - quest_manager.pause(duration); - - XSRETURN_EMPTY; -} - -XS(XS__moveto); -XS(XS__moveto) -{ - dXSARGS; - if (items != 3 && items != 4 && items != 5) - Perl_croak(aTHX_ "Usage: moveto(x, y, z, [mth, saveguard?])"); - - float x = (float)SvNV(ST(0)); - float y = (float)SvNV(ST(1)); - float z = (float)SvNV(ST(2)); - float h; - bool saveguard; - - if(items > 3) - h = (float)SvNV(ST(3)); - else - h = 0; - - if(items > 4) - saveguard = (bool)SvTRUE(ST(4)); - else - saveguard = false; - - quest_manager.moveto(x, y, z, h, saveguard); - - XSRETURN_EMPTY; -} - -XS(XS__resume); -XS(XS__resume) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: resume()"); - - - quest_manager.resume(); - - XSRETURN_EMPTY; -} - -XS(XS__addldonpoints); -XS(XS__addldonpoints) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: addldonpoints(points, theme)"); - - long points = (long)SvIV(ST(0)); - unsigned long theme = (unsigned long)SvUV(ST(1)); - - quest_manager.addldonpoints(points, theme); - - XSRETURN_EMPTY; -} - -XS(XS__addldonwin); -XS(XS__addldonwin) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: addldonwin(wins, theme)"); - - long wins = (long)SvIV(ST(0)); - unsigned long theme = (unsigned long)SvUV(ST(1)); - - quest_manager.addldonwin(wins, theme); - - XSRETURN_EMPTY; -} - -XS(XS__addldonloss); -XS(XS__addldonloss) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: addldonloss(losses, theme)"); - - long losses = (long)SvIV(ST(0)); - unsigned long theme = (unsigned long)SvUV(ST(1)); - - quest_manager.addldonloss(losses, theme); - - XSRETURN_EMPTY; -} - -XS(XS__setnexthpevent); -XS(XS__setnexthpevent) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: setnexthpevent(at)"); - - int at = (int)SvIV(ST(0)); - - quest_manager.setnexthpevent(at); - - XSRETURN_EMPTY; -} - -XS(XS__setnextinchpevent); -XS(XS__setnextinchpevent) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: setnextinchpevent(at)"); - - int at = (int)SvIV(ST(0)); - - quest_manager.setnextinchpevent(at); - - XSRETURN_EMPTY; -} - -XS(XS__sethp); -XS(XS__sethp) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: sethp(percentage)"); - - int hpperc = (int)SvIV(ST(0)); - - quest_manager.sethp(hpperc); - - XSRETURN_EMPTY; -} - -XS(XS__respawn); -XS(XS__respawn) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: respawn(npc_type, grid)"); - - int npc_type = (int)SvIV(ST(0)); - int grid = (int)SvIV(ST(1)); - - quest_manager.respawn(npc_type, grid); - - XSRETURN_EMPTY; -} - -XS(XS__ChooseRandom); -XS(XS__ChooseRandom) -{ - dXSARGS; - if (items < 1) - Perl_croak(aTHX_ "Usage: ChooseRandom(... list ...)"); - - int index = MakeRandomInt(0, items-1); - - SV *tmp = ST(0); - ST(0) = ST(index); - ST(index) = tmp; - - XSRETURN(1); //return 1 element from the stack (ST(0)) -} - -XS(XS__set_proximity); -XS(XS__set_proximity) -{ - dXSARGS; - if (items != 4 && items != 6) - Perl_croak(aTHX_ "Usage: set_proximity(minx, maxx, miny, maxy [, minz, maxz])"); - - float minx = (float)SvNV(ST(0)); - float maxx = (float)SvNV(ST(1)); - float miny = (float)SvNV(ST(2)); - float maxy = (float)SvNV(ST(3)); - - if(items == 4) - quest_manager.set_proximity(minx, maxx, miny, maxy); - else { - float minz = (float)SvNV(ST(4)); - float maxz = (float)SvNV(ST(5)); - quest_manager.set_proximity(minx, maxx, miny, maxy, minz, maxz); - } - - XSRETURN_EMPTY; -} - -XS(XS__clear_proximity); -XS(XS__clear_proximity) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: clear_proximity()"); - - quest_manager.clear_proximity(); - - XSRETURN_EMPTY; -} - -XS(XS__setanim); -XS(XS__setanim) //Cisyouc: mob->setappearance() addition -{ - dXSARGS; - if(items != 2) - Perl_croak(aTHX_ "Usage: quest::setanim(npc_type, animnum);"); - - quest_manager.setanim(SvUV(ST(0)), SvUV(ST(1))); - - XSRETURN_EMPTY; -} - -XS(XS__showgrid); -XS(XS__showgrid) -{ - dXSARGS; - if(items != 1) - Perl_croak(aTHX_ "Usage: quest::showgrid(grid_id);"); - - quest_manager.showgrid(SvUV(ST(0))); - - XSRETURN_EMPTY; -} - -XS(XS__showpath); -XS(XS__showpath) -{ - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: showpath(x, y, z)"); - - float x = (float)SvNV(ST(0)); - float y = (float)SvNV(ST(1)); - float z = (float)SvNV(ST(2)); - - quest_manager.showpath(x, y, z); - - XSRETURN_EMPTY; -} - -XS(XS__pathto); -XS(XS__pathto) -{ - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: pathto(x, y, z)"); - - float x = (float)SvNV(ST(0)); - float y = (float)SvNV(ST(1)); - float z = (float)SvNV(ST(2)); - - quest_manager.pathto(x, y, z); - - XSRETURN_EMPTY; -} - -XS(XS__spawn_condition); -XS(XS__spawn_condition) -{ - dXSARGS; - if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: spawn_condition(zone_short, [instance_id], condition_id, value)"); - - if(items == 3) - { - char * zone_short = (char *)SvPV_nolen(ST(0)); - uint16 cond_id = (int)SvUV(ST(1)); - int16 value = (int)SvIV(ST(2)); - - quest_manager.spawn_condition(zone_short, zone->GetInstanceID(), cond_id, value); - } - else - { - char * zone_short = (char *)SvPV_nolen(ST(0)); - uint32 instance_id = (int)SvUV(ST(1)); - uint16 cond_id = (int)SvUV(ST(2)); - int16 value = (int)SvIV(ST(3)); - - quest_manager.spawn_condition(zone_short, instance_id, cond_id, value); - } - XSRETURN_EMPTY; -} - -XS(XS__get_spawn_condition); -XS(XS__get_spawn_condition) -{ - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: get_spawn_condition(zone_short, [instance_id], condition_id)"); - - if(items == 2) - { - int16 RETVAL; - dXSTARG; - - char * zone_short = (char *)SvPV_nolen(ST(0)); - uint16 cond_id = (int)SvIV(ST(1)); - - RETVAL = quest_manager.get_spawn_condition(zone_short, zone->GetInstanceID(), cond_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); - } - else - { - int16 RETVAL; - dXSTARG; - - char * zone_short = (char *)SvPV_nolen(ST(0)); - uint16 instance_id = (int)SvIV(ST(1)); - uint16 cond_id = (int)SvIV(ST(2)); - - RETVAL = quest_manager.get_spawn_condition(zone_short, instance_id, cond_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); - } -} - -XS(XS__toggle_spawn_event); -XS(XS__toggle_spawn_event) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: toggle_spawn_event(event_id, enabled?, reset_base)"); - - uint32 event_id = (int)SvIV(ST(0)); - bool enabled = ((int)SvIV(ST(1))) == 0?false:true; - bool reset_base = ((int)SvIV(ST(1))) == 0?false:true; - - quest_manager.toggle_spawn_event(event_id, enabled, reset_base); - - XSRETURN_EMPTY; -} - -XS(XS__has_zone_flag); -XS(XS__has_zone_flag) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: has_zone_flag(zone_id)"); - - int16 RETVAL; - dXSTARG; - - uint32 zone_id = (int)SvIV(ST(0)); - - RETVAL = quest_manager.has_zone_flag(zone_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); - -} - -XS(XS__set_zone_flag); -XS(XS__set_zone_flag) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: set_zone_flag(zone_id)"); - - uint32 zone_id = (int)SvIV(ST(0)); - - quest_manager.set_zone_flag(zone_id); - - XSRETURN_EMPTY; -} - -XS(XS__clear_zone_flag); -XS(XS__clear_zone_flag) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: clear_zone_flag(zone_id)"); - - uint32 zone_id = (int)SvIV(ST(0)); - - quest_manager.clear_zone_flag(zone_id); - - XSRETURN_EMPTY; -} - -XS(XS__summonburriedplayercorpse); -XS(XS__summonburriedplayercorpse) -{ - dXSARGS; - if (items != 5) - Perl_croak(aTHX_ "Usage: summonburriedplayercorpse(char_id,dest_x,dest_y,dest_z,dest_heading)"); - - bool RETVAL; - uint32 char_id = (int)SvIV(ST(0)); - float dest_x = (float)SvIV(ST(1)); - float dest_y = (float)SvIV(ST(2)); - float dest_z = (float)SvIV(ST(3)); - float dest_heading = (float)SvIV(ST(4)); - - RETVAL = quest_manager.summonburriedplayercorpse(char_id, dest_x, dest_y, dest_z, dest_heading); - - ST(0) = boolSV(RETVAL); - sv_2mortal(ST(0)); - XSRETURN(1); -} - -XS(XS__summonallplayercorpses); -XS(XS__summonallplayercorpses) -{ - dXSARGS; - if (items != 5) - Perl_croak(aTHX_ "Usage: summonallplayercorpses(char_id,dest_x,dest_y,dest_z,dest_heading)"); - - bool RETVAL; - uint32 char_id = (int)SvIV(ST(0)); - float dest_x = (float)SvIV(ST(1)); - float dest_y = (float)SvIV(ST(2)); - float dest_z = (float)SvIV(ST(3)); - float dest_heading = (float)SvIV(ST(4)); - - RETVAL = quest_manager.summonallplayercorpses(char_id, dest_x, dest_y, dest_z, dest_heading); - - ST(0) = boolSV(RETVAL); - sv_2mortal(ST(0)); - XSRETURN(1); -} - -XS(XS__getplayerburriedcorpsecount); -XS(XS__getplayerburriedcorpsecount) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: getplayerburriedcorpsecount(char_id)"); - - uint32 RETVAL; - dXSTARG; - - uint32 char_id = (int)SvIV(ST(0)); - - RETVAL = quest_manager.getplayerburriedcorpsecount(char_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__buryplayercorpse); -XS(XS__buryplayercorpse) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: buryplayercorpse(char_id)"); - - uint32 RETVAL; - dXSTARG; - - uint32 char_id = (int)SvIV(ST(0)); - - RETVAL = quest_manager.buryplayercorpse(char_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__forcedooropen); -XS(XS__forcedooropen) -{ - dXSARGS; - if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: forcedooropen(doorid [, altmode=0])"); - - if (items == 1) - { - uint32 did = (int)SvIV(ST(0)); - - quest_manager.forcedooropen(did, false); - - XSRETURN_EMPTY; - } - else - { - uint32 did = (int)SvIV(ST(0)); - bool am = (int)SvIV(ST(1)) == 0?false:true; - - quest_manager.forcedooropen(did, am); - - XSRETURN_EMPTY; - } -} - -XS(XS__forcedoorclose); -XS(XS__forcedoorclose) -{ - dXSARGS; - if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: forcedoorclose(doorid [, altmode=0])"); - - if (items == 1) - { - uint32 did = (int)SvIV(ST(0)); - - quest_manager.forcedoorclose(did, false); - - XSRETURN_EMPTY; - } - else - { - uint32 did = (int)SvIV(ST(0)); - bool am = (int)SvIV(ST(1)) == 0?false:true; - - quest_manager.forcedoorclose(did, am); - - XSRETURN_EMPTY; - } -} - -XS(XS__toggledoorstate); -XS(XS__toggledoorstate) -{ - dXSARGS; - if (items !=1) - Perl_croak(aTHX_ "Usage: toggledoorstate(doorid)"); - - uint32 did = (int)SvIV(ST(0)); - - quest_manager.toggledoorstate(did); - - XSRETURN_EMPTY; -} - -XS(XS__isdooropen); -XS(XS__isdooropen) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: isdooropen(doorid)"); - - bool RETVAL; - dXSTARG; - - uint32 doorid = (int)SvIV(ST(0)); - - RETVAL = quest_manager.isdooropen(doorid); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__depopzone); -XS(XS__depopzone) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: depopzone(StartSpawnStatus)"); - - bool StartSpawnStatus = ((int)SvIV(ST(0))) == 0?false:true; - - quest_manager.depopzone(StartSpawnStatus); - - XSRETURN_EMPTY; -} - -XS(XS__repopzone); -XS(XS__repopzone) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: repopzone()"); - - quest_manager.repopzone(); - - XSRETURN_EMPTY; -} - -XS(XS__npcrace); -XS(XS__npcrace) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: npcrace(race_id)"); - - int race_id = (int)SvIV(ST(0)); - - quest_manager.npcrace(race_id); - - XSRETURN_EMPTY; -} - -XS(XS__npcgender); -XS(XS__npcgender) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: npcgender(gender_id)"); - - int gender_id= (int)SvIV(ST(0)); - - quest_manager.npcgender(gender_id); - - XSRETURN_EMPTY; -} - -XS(XS__npcsize); -XS(XS__npcsize) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: npcsize(newsize)"); - - int newsize = (int)SvIV(ST(0)); - - quest_manager.npcsize(newsize); - - XSRETURN_EMPTY; -} - -XS(XS__npctexture); -XS(XS__npctexture) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: npctexture(newtexture)"); - - int newtexture = (int)SvIV(ST(0)); - - quest_manager.npctexture(newtexture); - - XSRETURN_EMPTY; -} - -XS(XS__playerrace); -XS(XS__playerrace) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: playerrace(race_id)"); - - int race_id = (int)SvIV(ST(0)); - - quest_manager.playerrace(race_id); - - XSRETURN_EMPTY; -} - -XS(XS__playergender); -XS(XS__playergender) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: playergender(gender_id)"); - - int gender_id= (int)SvIV(ST(0)); - - quest_manager.playergender(gender_id); - - XSRETURN_EMPTY; -} - -XS(XS__playersize); -XS(XS__playersize) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: playersize(newsize)"); - - int newsize = (int)SvIV(ST(0)); - - quest_manager.playersize(newsize); - - XSRETURN_EMPTY; -} - -XS(XS__playertexture); -XS(XS__playertexture) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: playertexture(newtexture)"); - - int newtexture = (int)SvIV(ST(0)); - - quest_manager.playertexture(newtexture); - - XSRETURN_EMPTY; -} - -XS(XS__playerfeature); -XS(XS__playerfeature) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: playerfeature(feature, setting)"); - - char * feature = (char *)SvPV_nolen(ST(0)); - int setting = (int)SvIV(ST(1)); - - quest_manager.playerfeature(feature, setting); - - XSRETURN_EMPTY; -} - -XS(XS__npcfeature); -XS(XS__npcfeature) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: npcfeature(feature, setting)"); - - char * feature = (char *)SvPV_nolen(ST(0)); - int setting = (int)SvIV(ST(1)); - - quest_manager.npcfeature(feature, setting); - - XSRETURN_EMPTY; -} - -#ifdef BOTS - -XS(XS__createbotcount); -XS(XS__createbotcount) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - RETVAL = quest_manager.createbotcount(); - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__spawnbotcount); -XS(XS__spawnbotcount) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - RETVAL = quest_manager.spawnbotcount(); - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__botquest); -XS(XS__botquest) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - RETVAL = quest_manager.botquest(); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__createBot); -XS(XS__createBot) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - if(items != 6) - { - Perl_croak(aTHX_ "Usage: createBot(firstname, lastname, level, race, class, gender)"); - } - - char *firstname = (char *)SvPV_nolen(ST(0)); - char *lastname = (char *)SvPV_nolen(ST(1)); - int level = (int) SvIV(ST(2)); - int race = (int) SvIV(ST(3)); - int botclass = (int) SvIV(ST(4)); - int gender = (int) SvIV(ST(5)); - - RETVAL = quest_manager.createBot(firstname, lastname, level, race, botclass, gender); - XSprePUSH; PUSHu((IV)RETVAL); - XSRETURN(1); -} - -#endif //BOTS - -XS(XS__taskselector); -XS(XS__taskselector) -{ - dXSARGS; - if((items >= 1) && (items <=MAXCHOOSERENTRIES)) { - int tasks[MAXCHOOSERENTRIES]; - for(int i=0; i< items; i++) { - tasks[i] = (int)SvIV(ST(i)); - } - quest_manager.taskselector(items, tasks); - } else { - Perl_croak(aTHX_ "Usage: taskselector(taskid1, taskid2, ..., taskid%i)", MAXCHOOSERENTRIES); - } - - XSRETURN_EMPTY; -} -XS(XS__tasksetselector); -XS(XS__tasksetselector) -{ - dXSARGS; - if(items == 1) { - int tasksetid = (int)SvIV(ST(0)); - quest_manager.tasksetselector(tasksetid); - } else { - Perl_croak(aTHX_ "Usage: tasksetselector(tasksetid)"); - } - - XSRETURN_EMPTY; -} -XS(XS__enabletask); -XS(XS__enabletask) -{ - dXSARGS; - if((items >= 1) && (items <=10)) { - int tasks[10]; - for(int i=0; i< items; i++) { - tasks[i] = (int)SvIV(ST(i)); - } - quest_manager.enabletask(items, tasks); - } else { - Perl_croak(aTHX_ "Usage: enabletask(taskid1, taskid2, ..., taskid10"); - } - - XSRETURN_EMPTY; -} -XS(XS__disabletask); -XS(XS__disabletask) -{ - dXSARGS; - if((items >= 1) && (items <=10)) { - int tasks[10]; - for(int i=0; i< items; i++) { - tasks[i] = (int)SvIV(ST(i)); - } - quest_manager.disabletask(items, tasks); - } else { - Perl_croak(aTHX_ "Usage: disabletask(taskid1, taskid2, ..., taskid10"); - } - - XSRETURN_EMPTY; -} - -XS(XS__istaskenabled); -XS(XS__istaskenabled) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskid = (int)SvIV(ST(0)); - RETVAL = quest_manager.istaskenabled(taskid); - } else { - Perl_croak(aTHX_ "Usage: istaskenabled(taskid)"); - } - - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} -XS(XS__istaskactive); -XS(XS__istaskactive) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int task = (int)SvIV(ST(0)); - RETVAL = quest_manager.istaskactive(task); - } else { - Perl_croak(aTHX_ "Usage: istaskactive(task)"); - } - - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} -XS(XS__istaskactivityactive); -XS(XS__istaskactivityactive) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - if(items == 2) { - unsigned int task = (int)SvIV(ST(0)); - unsigned int activity = (int)SvIV(ST(1)); - RETVAL = quest_manager.istaskactivityactive(task, activity); - } else { - Perl_croak(aTHX_ "Usage: istaskactivityactive(task,activity)"); - } - - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} -XS(XS__gettaskactivitydonecount); -XS(XS__gettaskactivitydonecount) -{ - dXSARGS; - uint32 RETVAL; - dXSTARG; - - if(items == 2) { - unsigned int task = (int)SvIV(ST(0)); - unsigned int activity = (int)SvIV(ST(1)); - RETVAL = quest_manager.gettaskactivitydonecount(task, activity); - XSprePUSH; PUSHu((UV)RETVAL); - } else { - Perl_croak(aTHX_ "Usage: gettaskactivitydonecount(task,activity)"); - } - - XSRETURN(1); -} -XS(XS__updatetaskactivity); -XS(XS__updatetaskactivity) -{ - dXSARGS; - unsigned int task, activity; - int count = 1; - if(items == 2) { - task = (int)SvIV(ST(0)); - activity = (int)SvIV(ST(1)); - quest_manager.updatetaskactivity(task, activity, count); - } - else if(items == 3) { - task = (int)SvIV(ST(0)); - activity = (int)SvIV(ST(1)); - count = (int)SvIV(ST(2)); - quest_manager.updatetaskactivity(task, activity, count); - } else { - Perl_croak(aTHX_ "Usage: updatetaskactivity(task, activity [,count])"); - } - - XSRETURN_EMPTY; -} - -XS(XS__resettaskactivity); -XS(XS__resettaskactivity) -{ - dXSARGS; - unsigned int task, activity; - if(items == 2) { - task = (int)SvIV(ST(0)); - activity = (int)SvIV(ST(1)); - quest_manager.resettaskactivity(task, activity); - } else { - Perl_croak(aTHX_ "Usage: resettaskactivity(task, activity)"); - } - - XSRETURN_EMPTY; -} - -XS(XS__taskexploredarea); -XS(XS__taskexploredarea) -{ - dXSARGS; - unsigned int exploreid; - if(items == 1) { - exploreid = (int)SvIV(ST(0)); - quest_manager.taskexploredarea(exploreid); - } else { - Perl_croak(aTHX_ "Usage: taskexplorearea(exploreid)"); - } - - XSRETURN_EMPTY; -} - -XS(XS__assigntask); -XS(XS__assigntask) -{ - dXSARGS; - unsigned int taskid; - if(items == 1) { - taskid = (int)SvIV(ST(0)); - quest_manager.assigntask(taskid); - } else { - Perl_croak(aTHX_ "Usage: assigntask(taskid)"); - } - - XSRETURN_EMPTY; -} - -XS(XS__failtask); -XS(XS__failtask) -{ - dXSARGS; - unsigned int taskid; - if(items == 1) { - taskid = (int)SvIV(ST(0)); - quest_manager.failtask(taskid); - } else { - Perl_croak(aTHX_ "Usage: failtask(taskid)"); - } - - XSRETURN_EMPTY; -} - -XS(XS__tasktimeleft); -XS(XS__tasktimeleft) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskid = (int)SvIV(ST(0)); - RETVAL = quest_manager.tasktimeleft(taskid); - } else { - Perl_croak(aTHX_ "Usage: tasktimeleft(taskid)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__istaskcompleted); -XS(XS__istaskcompleted) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskid = (int)SvIV(ST(0)); - RETVAL = quest_manager.istaskcompleted(taskid); - } else { - Perl_croak(aTHX_ "Usage: istaskcompleted(taskid)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__enabledtaskcount); -XS(XS__enabledtaskcount) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskset = (int)SvIV(ST(0)); - RETVAL = quest_manager.enabledtaskcount(taskset); - } else { - Perl_croak(aTHX_ "Usage: enabledtaskcount(taskset)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__firsttaskinset); -XS(XS__firsttaskinset) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskset = (int)SvIV(ST(0)); - RETVAL = quest_manager.firsttaskinset(taskset); - } else { - Perl_croak(aTHX_ "Usage: firsttaskinset(taskset)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__lasttaskinset); -XS(XS__lasttaskinset) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskset = (int)SvIV(ST(0)); - RETVAL = quest_manager.lasttaskinset(taskset); - } else { - Perl_croak(aTHX_ "Usage: lasttaskinset(taskset)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__nexttaskinset); -XS(XS__nexttaskinset) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 2) { - unsigned int taskset = (int)SvIV(ST(0)); - unsigned int taskid = (int)SvIV(ST(1)); - RETVAL = quest_manager.nexttaskinset(taskset, taskid); - } else { - Perl_croak(aTHX_ "Usage: nexttaskinset(taskset, taskid)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} -XS(XS__activespeaktask); -XS(XS__activespeaktask) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 0) { - RETVAL = quest_manager.activespeaktask(); - } else { - Perl_croak(aTHX_ "Usage: activespeaktask()"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__activespeakactivity); -XS(XS__activespeakactivity) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskid = (int)SvIV(ST(0)); - RETVAL = quest_manager.activespeakactivity(taskid); - } else { - Perl_croak(aTHX_ "Usage: activespeakactivity(taskid)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__activetasksinset); -XS(XS__activetasksinset) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskset = (int)SvIV(ST(0)); - RETVAL = quest_manager.activetasksinset(taskset); - } else { - Perl_croak(aTHX_ "Usage: activetasksinset(taskset)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__completedtasksinset); -XS(XS__completedtasksinset) -{ - dXSARGS; - int RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int taskset = (int)SvIV(ST(0)); - RETVAL = quest_manager.completedtasksinset(taskset); - } else { - Perl_croak(aTHX_ "Usage: completedtasksinset(taskset)"); - } - - XSprePUSH; PUSHi((IV)RETVAL); - - XSRETURN(1); -} - - -XS(XS__istaskappropriate); -XS(XS__istaskappropriate) -{ - dXSARGS; - bool RETVAL; - dXSTARG; - - if(items == 1) { - unsigned int task = (int)SvIV(ST(0)); - RETVAL = quest_manager.istaskappropriate(task); - } else { - Perl_croak(aTHX_ "Usage: istaskaappropriate(task)"); - } - - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - - XS(XS__popup); // prototype to pass -Wmissing-prototypes - XS(XS__popup) { - dXSARGS; - int popupid = 0; - int buttons = 0; - int duration = 0; - - if((items < 2) || (items > 5)) - Perl_croak(aTHX_ "Usage: popup(windowtitle, text, popupid, buttons, duration)"); - - if(items >= 3) - popupid = (int)SvIV(ST(2)); - - if(items >= 4) - buttons = (int)SvIV(ST(3)); - - if(items == 5) - duration = (int)SvIV(ST(4)); - - quest_manager.popup(SvPV_nolen(ST(0)), SvPV_nolen(ST(1)), popupid, buttons, duration); - - XSRETURN_EMPTY; - } -XS(XS__clearspawntimers); -XS(XS__clearspawntimers) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: clearspawntimers()"); - - quest_manager.clearspawntimers(); - - XSRETURN_EMPTY; -} -XS(XS__ze); -XS(XS__ze) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: ze(type, str)"); - - int type = (int)SvIV(ST(0)); - char * str = (char *)SvPV_nolen(ST(1)); - - quest_manager.ze(type, str); - - XSRETURN_EMPTY; -} - -XS(XS__we); -XS(XS__we) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: we(type, str)"); - - int type = (int)SvIV(ST(0)); - char * str = (char *)SvPV_nolen(ST(1)); - - quest_manager.we(type, str); - - XSRETURN_EMPTY; -} -XS(XS__getlevel); -XS(XS__getlevel) -{ - dXSARGS; - if (items > 1) - Perl_croak(aTHX_ "Usage: getlevel(type)"); - - int RETVAL; - dXSTARG; - - int type; - if (items == 1) - type = (int)SvIV(ST(0)); - else - type = 0; - - RETVAL = quest_manager.getlevel(type); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__CreateGroundObject); -XS(XS__CreateGroundObject) -{ - dXSARGS; - if (items != 5 && items != 6) - Perl_croak(aTHX_ "Usage: creategroundobject(itemid, x, y, z, heading, [decay_time])"); - - int itemid = (int)SvIV(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - float heading = (float)SvNV(ST(4)); - uint16 id = 0; - - if(items == 5) - id = quest_manager.CreateGroundObject(itemid, x, y, z, heading); - else{ - uint32 decay_time = (uint32)SvIV(ST(5)); - id = quest_manager.CreateGroundObject(itemid, x, y, z, heading, decay_time); - } - - XSRETURN_IV(id); -} - -XS(XS__CreateGroundObjectFromModel); -XS(XS__CreateGroundObjectFromModel) -{ - dXSARGS; - if (items < 5 || items > 7) - Perl_croak(aTHX_ "Usage: creategroundobjectfrommodel(modelname, x, y, z, heading, [type], [decay_time])"); - - char * modelname = (char *)SvPV_nolen(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - float heading = (float)SvNV(ST(4)); - uint32 type = 0; - uint32 decay_time = 0; - uint16 id = 0; - - if (items > 5) - type = (uint32)SvIV(ST(5)); - - if (items > 6) - decay_time = (uint32)SvIV(ST(6)); - - id = quest_manager.CreateGroundObjectFromModel(modelname, x, y, z, heading, type, decay_time); - XSRETURN_IV(id); -} - -XS(XS__CreateDoor); -XS(XS__CreateDoor) -{ - dXSARGS; - if (items < 5 || items > 7) - Perl_croak(aTHX_ "Usage: createdoor(modelname, x, y, z, heading, [type], [size])"); - - char * modelname = (char *)SvPV_nolen(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); - float heading = (float)SvNV(ST(4)); - uint32 type = 58; - uint32 size = 100; - uint16 id = 0; - - if (items > 5) - type = (uint32)SvIV(ST(5)); - - if (items > 6) - size = (uint32)SvIV(ST(6)); - - id = quest_manager.CreateDoor(modelname, x, y, z, heading, type, size); - XSRETURN_IV(id); -} - -XS(XS__ModifyNPCStat); -XS(XS__ModifyNPCStat) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: ModifyNPCStat(identifier, newValue)"); - - quest_manager.ModifyNPCStat(SvPV_nolen(ST(0)), SvPV_nolen(ST(1))); - - XSRETURN_EMPTY; -} - -XS(XS__collectitems); -XS(XS__collectitems) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: collectitems(item_id, remove?)"); - - uint32 item_id = (int)SvIV(ST(0)); - bool remove = ((int)SvIV(ST(1))) == 0?false:true; - - int quantity = - quest_manager.collectitems(item_id, remove); - - XSRETURN_IV(quantity); -} - -XS(XS__UpdateSpawnTimer); -XS(XS__UpdateSpawnTimer) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: UpdateSpawnTimer(Spawn2_ID, Updated_Time_Till_Repop)"); - - uint32 id = (int)SvIV(ST(0)); - uint32 duration = (int)SvIV(ST(1)); - - quest_manager.UpdateSpawnTimer(id, duration); - - XSRETURN_EMPTY; -} - -XS(XS__MerchantSetItem); -XS(XS__MerchantSetItem) { - dXSARGS; - if (items != 2 && items != 3) - Perl_croak(aTHX_ "Usage: MerchantSetItem(NPCid, itemid [, quantity])"); - - uint32 NPCid = (int)SvUV(ST(0)); - uint32 itemid = (int)SvUV(ST(1)); - uint32 quantity = 0; - if (items == 3) - quantity = (int)SvUV(ST(2)); - - quest_manager.MerchantSetItem(NPCid, itemid, quantity); - - XSRETURN_EMPTY; -} - -XS(XS__MerchantCountItem); -XS(XS__MerchantCountItem) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: MerchantCountItem(NPCid, itemid)"); - - uint32 NPCid = (int)SvUV(ST(0)); - uint32 itemid = (int)SvUV(ST(1)); - uint32 quantity = quest_manager.MerchantCountItem(NPCid, itemid); - - XSRETURN_UV(quantity); -} - -XS(XS__varlink); -XS(XS__varlink) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: varlink(itemID)"); - dXSTARG; - - Const_char * RETVAL; - char text[250]; - uint32 itemID; - itemID = (int)SvUV(ST(0)); - - RETVAL = quest_manager.varlink(text, itemID); - - sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; - XSRETURN(1); -} - -XS(XS__CreateInstance); -XS(XS__CreateInstance) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: CreateInstance(zone_name, version, duration)"); - - char * zone = (char *)SvPV_nolen(ST(0)); - uint16 version = (int)SvUV(ST(1)); - uint32 duration = (int)SvUV(ST(2)); - uint32 id = quest_manager.CreateInstance(zone, version, duration); - - XSRETURN_UV(id); -} - -XS(XS__DestroyInstance); -XS(XS__DestroyInstance) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: DestroyInstance(id)"); - - uint16 id = (int)SvUV(ST(0)); - quest_manager.DestroyInstance(id); - - XSRETURN_EMPTY; -} - -XS(XS__GetInstanceID); -XS(XS__GetInstanceID) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: GetInstanceID(zone_name, version)"); - - char * zone = (char *)SvPV_nolen(ST(0)); - uint16 version = (int)SvUV(ST(1)); - uint16 id = quest_manager.GetInstanceID(zone, version); - - XSRETURN_UV(id); -} - -XS(XS__AssignToInstance); -XS(XS__AssignToInstance) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: AssignToInstance(id)"); - - uint16 id = (int)SvUV(ST(0)); - quest_manager.AssignToInstance(id); - - XSRETURN_EMPTY; -} - -XS(XS__AssignGroupToInstance); -XS(XS__AssignGroupToInstance) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: AssignGroupToInstance(id)"); - - uint16 id = (int)SvUV(ST(0)); - quest_manager.AssignGroupToInstance(id); - - XSRETURN_EMPTY; -} - -XS(XS__AssignRaidToInstance); -XS(XS__AssignRaidToInstance) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: AssignRaidToInstance(id)"); - - uint16 id = (int)SvUV(ST(0)); - quest_manager.AssignRaidToInstance(id); - - XSRETURN_EMPTY; -} - -XS(XS__MovePCInstance); -XS(XS__MovePCInstance) -{ - dXSARGS; - if (items != 5 && items != 6) - Perl_croak(aTHX_ "Usage: MovePCInstance(zone_id, instance_id, x, y, z [,heading])"); - - int zoneid = (int)SvIV(ST(0)); - int instanceid = (int)SvIV(ST(1)); - float x = (float)SvNV(ST(2)); - float y = (float)SvNV(ST(3)); - float z = (float)SvNV(ST(4)); - - if (items == 4) - { - quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, 0.0f); - } - else - { - float heading = (float)SvNV(ST(5)); - quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, heading); - } - - XSRETURN_EMPTY; -} - -XS(XS__FlagInstanceByGroupLeader); -XS(XS__FlagInstanceByGroupLeader) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: FlagInstanceByGroupLeader(zone, version)"); - - uint32 zone = (int)SvUV(ST(0)); - uint16 version = (int)SvUV(ST(1)); - quest_manager.FlagInstanceByGroupLeader(zone, version); - - XSRETURN_EMPTY; -} - -XS(XS__FlagInstanceByRaidLeader); -XS(XS__FlagInstanceByRaidLeader) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: FlagInstanceByRaidLeader(zone, version)"); - - uint32 zone = (int)SvUV(ST(0)); - uint16 version = (int)SvUV(ST(1)); - quest_manager.FlagInstanceByRaidLeader(zone, version); - - XSRETURN_EMPTY; -} - -XS(XS__saylink); -XS(XS__saylink) { - dXSARGS; - if (items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: saylink(phrase,[silent?],[linkname])"); - dXSTARG; - - Const_char * RETVAL; - char text[250]; - char text2[250]; - bool silent = false; - strcpy(text,(char *)SvPV_nolen(ST(0))); - if(items >= 2) { - silent = ((int)SvIV(ST(1))) == 0 ? false : true; - } - if (items == 3) - strcpy(text2,(char *)SvPV_nolen(ST(2))); - else - strcpy(text2,text); - - RETVAL = quest_manager.saylink(text, silent, text2); - sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; - XSRETURN(1); -} - -XS(XS__getguildnamebyid); -XS(XS__getguildnamebyid) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: getguildnamebyid(guild_id)"); - dXSTARG; - - Const_char * RETVAL; - uint32 guild_id = (int)SvUV(ST(0)); - - RETVAL = quest_manager.getguildnamebyid(guild_id); - - sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; - XSRETURN(1); -} - -XS(XS__SetRunning); -XS(XS__SetRunning) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: SetRunning(val)"); - - bool val = ((int)SvIV(ST(0))) == 0?false:true; - - quest_manager.SetRunning(val); - - XSRETURN_EMPTY; -} - -XS(XS__IsRunning); -XS(XS__IsRunning) -{ - dXSARGS; - if (items >= 1) - Perl_croak(aTHX_ "Usage: IsRunning()"); - - bool RETVAL; - dXSTARG; - - - RETVAL = quest_manager.IsRunning(); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__IsEffectInSpell); -XS(XS__IsEffectInSpell) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: IsEffectInSpell(spell_id, effect_id)"); - - uint32 spell_id = (uint32)SvUV(ST(0)); - uint32 effect_id = (uint32)SvUV(ST(1)); - bool RETVAL; - dXSTARG; - - - RETVAL = IsEffectInSpell(spell_id, effect_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__IsBeneficialSpell); -XS(XS__IsBeneficialSpell) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: IsBeneficialSpell(spell_id)"); - - uint32 spell_id = (uint32)SvUV(ST(0)); - bool RETVAL; - dXSTARG; - - - RETVAL = BeneficialSpell(spell_id); - XSprePUSH; PUSHu((IV)RETVAL); - - XSRETURN(1); -} - -XS(XS__GetSpellResistType); -XS(XS__GetSpellResistType) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: GetSpellResistType(spell_id)"); - - uint32 spell_id = (uint32)SvUV(ST(0)); - int32 spell_val = 0; - dXSTARG; - - spell_val = GetSpellResistType(spell_id); - XSRETURN_UV(spell_val); -} - -XS(XS__GetSpellTargetType); -XS(XS__GetSpellTargetType) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: GetSpellTargetType(spell_id)"); - - uint32 spell_id = (uint32)SvUV(ST(0)); - int32 spell_val = 0; - dXSTARG; - - spell_val = GetSpellTargetType(spell_id); - XSRETURN_UV(spell_val); -} - -XS(XS__FlyMode); -XS(XS__FlyMode) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: FlyMode([0/1/2])"); - - uint8 flymode = (int)SvUV(ST(0)); - quest_manager.FlyMode(flymode); - - XSRETURN_EMPTY; -} - -XS(XS_FactionValue); -XS(XS_FactionValue) { - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: factionvalue()"); - - uint8 fac = quest_manager.FactionValue(); - XSRETURN_UV(fac); -} - -XS(XS__enabletitle); -XS(XS__enabletitle) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: enabletitle(titleset)"); - - int titleset = (int)SvIV(ST(0)); - - quest_manager.enabletitle(titleset); - - XSRETURN_EMPTY; -} - -XS(XS__checktitle); -XS(XS__checktitle) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: checktitle(titleset)"); - - bool RETVAL; - int titleset = (int)SvIV(ST(0)); - - RETVAL = quest_manager.checktitle(titleset); - - ST(0) = boolSV(RETVAL); - sv_2mortal(ST(0)); - XSRETURN(1); -} - -XS(XS__removetitle); -XS(XS__removetitle) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: removetitle(titleset)"); - - int titleset = (int)SvIV(ST(0)); - - quest_manager.removetitle(titleset); - - XSRETURN_EMPTY; -} - -XS(XS__wearchange); -XS(XS__wearchange) -{ - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: wearchange(slot, texture)"); - - uint8 slot = (int)SvUV(ST(0)); - uint16 texture = (int)SvUV(ST(1)); - - quest_manager.wearchange(slot, texture); - - XSRETURN_EMPTY; -} - -XS(XS__voicetell); -XS(XS__voicetell) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: voicetell(clientname, type, race, gender)"); - - char * str = (char *)SvPV_nolen(ST(0)); - int macronum = (int)SvIV(ST(1)); - int racenum = (int)SvIV(ST(2)); - int gendernum = (int)SvIV(ST(3)); - - quest_manager.voicetell(str, macronum, racenum, gendernum); - - XSRETURN_EMPTY; -} - -XS(XS__LearnRecipe); -XS(XS__LearnRecipe) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: LearnRecipe(recipe_id)"); - - uint32 recipe_id = (uint32)SvIV(ST(0)); - - quest_manager.LearnRecipe(recipe_id); - - XSRETURN_EMPTY; -} - -XS(XS__SendMail); -XS(XS__SendMail) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: SendMail(to, from, subject, message)"); - - char *to = (char *)SvPV_nolen(ST(0)); - char *from = (char *)SvPV_nolen(ST(1)); - char *subject = (char *)SvPV_nolen(ST(2)); - char *message = (char *)SvPV_nolen(ST(3)); - - quest_manager.SendMail(to, from, subject, message); - - XSRETURN_EMPTY; -} - -XS(XS__GetZoneID); -XS(XS__GetZoneID) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: GetZoneID(zone)"); - - char *zone = (char *)SvPV_nolen(ST(0)); - int32 id = quest_manager.GetZoneID(zone); - - XSRETURN_IV(id); -} - -XS(XS__GetZoneLongName); -XS(XS__GetZoneLongName) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: GetZoneLongName(zone)"); - dXSTARG; - char *zone = (char *)SvPV_nolen(ST(0)); - Const_char* RETVAL = quest_manager.GetZoneLongName(zone); - - sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; - XSRETURN(1); -} - -XS(XS__GetTimeSeconds); -XS(XS__GetTimeSeconds) -{ - dXSARGS; - if (items != 0) - Perl_croak(aTHX_ "Usage: GetTimeSeconds()"); - - uint32 seconds = 0; - dXSTARG; - - seconds = Timer::GetTimeSeconds(); - XSRETURN_UV(seconds); -} - -XS(XS__handleturnin); // prototype to pass -Wmissing-prototypes -XS(XS__handleturnin) { - dXSARGS; - - if (items != 2) - Perl_croak(aTHX_ "Usage: handleturnin(itemid, itemcharges)"); - int itemid = (int)SvIV(ST(0)); - int charges = (int)SvIV(ST(1)); - - bool returnVal = quest_manager.TurnInItem(itemid,charges); - - ST(0) = boolSV(returnVal); - sv_2mortal(ST(0)); - XSRETURN(1); -} - -XS(XS__completehandin); // prototype to pass -Wmissing-prototypes -XS(XS__completehandin) { - dXSARGS; - - if (items != 0) - Perl_croak(aTHX_ "Usage: completehandin()"); - - quest_manager.CompleteHandIn(); - - XSRETURN_EMPTY; -} - -XS(XS__resethandin); // prototype to pass -Wmissing-prototypes -XS(XS__resethandin) { - dXSARGS; - - if (items != 0) - Perl_croak(aTHX_ "Usage: resethandin()"); - - quest_manager.ResetHandIn(); - - XSRETURN_EMPTY; -} - -XS(XS__clearhandin); // prototype to pass -Wmissing-prototypes -XS(XS__clearhandin) { - dXSARGS; - - if (items != 0) - Perl_croak(aTHX_ "Usage: clearhandin()"); - - quest_manager.ClearHandIn(); - - XSRETURN_EMPTY; -} - -XS(XS__crosszonesignalclientbycharid); -XS(XS__crosszonesignalclientbycharid) -{ - dXSARGS; - - if (items != 2) - Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(char_id, data)"); - - if (items == 2) { - int char_id = (int)SvIV(ST(0)); - uint32 data = (uint32)SvIV(ST(1)); - quest_manager.CrossZoneSignalPlayerByCharID(char_id, data); - } else { - Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(char_id, data)"); - } - - XSRETURN_EMPTY; -} - -XS(XS__crosszonesignalclientbyname); -XS(XS__crosszonesignalclientbyname) -{ - dXSARGS; - - if (items != 2) - Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(Name, data)"); - - if (items == 2) { - char *Name = (char *)SvPV_nolen(ST(0)); - uint32 data = (uint32)SvIV(ST(1)); - quest_manager.CrossZoneSignalPlayerByName(Name, data); - } else { - Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(Name, data)"); - } - - XSRETURN_EMPTY; -} - - -XS(XS__crosszonemessageplayerbyname); -XS(XS__crosszonemessageplayerbyname) -{ - dXSARGS; - - if (items != 3) - Perl_croak(aTHX_ "Usage: crosszonemessageplayerbyname(Type, Name, Message)"); - - if (items == 3) { - uint32 Type = (uint32)SvIV(ST(0)); - char *Name = (char *)SvPV_nolen(ST(1)); - char *Message = (char *)SvPV_nolen(ST(2)); - quest_manager.CrossZoneMessagePlayerByName(Type, Name, Message); - } else { - Perl_croak(aTHX_ "Usage: crosszonemessageplayerbyname(Type, Name, Message)"); - } - - XSRETURN_EMPTY; -} - -/* -This is the callback perl will look for to setup the -quest package's XSUBs -*/ -EXTERN_C XS(boot_quest); // prototype to pass -Wmissing-prototypes -EXTERN_C XS(boot_quest) -{ - dXSARGS; - char file[256]; - strncpy(file, __FILE__, 256); - file[255] = '\0'; - - if(items != 1) - LogFile->write(EQEMuLog::Error, "boot_quest does not take any arguments."); - - char buf[128]; //shouldent have any function names longer than this. - - //add the strcpy stuff to get rid of const warnings.... - - XS_VERSION_BOOTCHECK ; - newXS(strcpy(buf, "echo"), XS__echo, file); - newXS(strcpy(buf, "say"), XS__say, file); - newXS(strcpy(buf, "me"), XS__me, file); - newXS(strcpy(buf, "summonitem"), XS__summonitem, file); - newXS(strcpy(buf, "write"), XS__write, file); - newXS(strcpy(buf, "spawn"), XS__spawn, file); - newXS(strcpy(buf, "spawn2"), XS__spawn2, file); - newXS(strcpy(buf, "unique_spawn"), XS__unique_spawn, file); - newXS(strcpy(buf, "spawn_from_spawn2"), XS__spawn_from_spawn2, file); - newXS(strcpy(buf, "enable_spawn2"), XS__enable_spawn2, file); - newXS(strcpy(buf, "disable_spawn2"), XS__disable_spawn2, file); - newXS(strcpy(buf, "setstat"), XS__setstat, file); - newXS(strcpy(buf, "incstat"), XS__incstat, file); - newXS(strcpy(buf, "castspell"), XS__castspell, file); - newXS(strcpy(buf, "selfcast"), XS__selfcast, file); - newXS(strcpy(buf, "addloot"), XS__addloot, file); - newXS(strcpy(buf, "zone"), XS__zone, file); - newXS(strcpy(buf, "settimer"), XS__settimer, file); - newXS(strcpy(buf, "settimerMS"), XS__settimerMS, file); - newXS(strcpy(buf, "stoptimer"), XS__stoptimer, file); - newXS(strcpy(buf, "stopalltimers"), XS__stopalltimers, file); - newXS(strcpy(buf, "emote"), XS__emote, file); - newXS(strcpy(buf, "shout"), XS__shout, file); - newXS(strcpy(buf, "shout2"), XS__shout2, file); - newXS(strcpy(buf, "gmsay"), XS__gmsay, file); - newXS(strcpy(buf, "depop"), XS__depop, file); - newXS(strcpy(buf, "depop_withtimer"), XS__depop_withtimer, file); - newXS(strcpy(buf, "settarget"), XS__settarget, file); - newXS(strcpy(buf, "follow"), XS__follow, file); - newXS(strcpy(buf, "sfollow"), XS__sfollow, file); - newXS(strcpy(buf, "changedeity"), XS__changedeity, file); - newXS(strcpy(buf, "exp"), XS__exp, file); - newXS(strcpy(buf, "level"), XS__level, file); - newXS(strcpy(buf, "traindisc"), XS__traindisc, file); - newXS(strcpy(buf, "isdisctome"), XS__isdisctome, file); - newXS(strcpy(buf, "safemove"), XS__safemove, file); - newXS(strcpy(buf, "rain"), XS__rain, file); - newXS(strcpy(buf, "snow"), XS__snow, file); - newXS(strcpy(buf, "surname"), XS__surname, file); - newXS(strcpy(buf, "permaclass"), XS__permaclass, file); - newXS(strcpy(buf, "permarace"), XS__permarace, file); - newXS(strcpy(buf, "permagender"), XS__permagender, file); - newXS(strcpy(buf, "scribespells"), XS__scribespells, file); - newXS(strcpy(buf, "traindiscs"), XS__traindiscs, file); - newXS(strcpy(buf, "unscribespells"), XS__unscribespells, file); - newXS(strcpy(buf, "untraindiscs"), XS__untraindiscs, file); - newXS(strcpy(buf, "givecash"), XS__givecash, file); - newXS(strcpy(buf, "pvp"), XS__pvp, file); - newXS(strcpy(buf, "movepc"), XS__movepc, file); - newXS(strcpy(buf, "gmmove"), XS__gmmove, file); - newXS(strcpy(buf, "movegrp"), XS__movegrp, file); - newXS(strcpy(buf, "doanim"), XS__doanim, file); - newXS(strcpy(buf, "addskill"), XS__addskill, file); - newXS(strcpy(buf, "setlanguage"), XS__setlanguage, file); - newXS(strcpy(buf, "setskill"), XS__setskill, file); - newXS(strcpy(buf, "setallskill"), XS__setallskill, file); - newXS(strcpy(buf, "attack"), XS__attack, file); - newXS(strcpy(buf, "attacknpc"), XS__attacknpc, file); - newXS(strcpy(buf, "attacknpctype"), XS__attacknpctype, file); - newXS(strcpy(buf, "save"), XS__save, file); - newXS(strcpy(buf, "faction"), XS__faction, file); - newXS(strcpy(buf, "setsky"), XS__setsky, file); - newXS(strcpy(buf, "setguild"), XS__setguild, file); - newXS(strcpy(buf, "createguild"), XS__createguild, file); - newXS(strcpy(buf, "settime"), XS__settime, file); - newXS(strcpy(buf, "itemlink"), XS__itemlink, file); - newXS(strcpy(buf, "signal"), XS__signal, file); - newXS(strcpy(buf, "signalwith"), XS__signalwith, file); - newXS(strcpy(buf, "setglobal"), XS__setglobal, file); - newXS(strcpy(buf, "targlobal"), XS__targlobal, file); - newXS(strcpy(buf, "delglobal"), XS__delglobal, file); - newXS(strcpy(buf, "ding"), XS__ding, file); - newXS(strcpy(buf, "rebind"), XS__rebind, file); - newXS(strcpy(buf, "start"), XS__start, file); - newXS(strcpy(buf, "stop"), XS__stop, file); - newXS(strcpy(buf, "pause"), XS__pause, file); - newXS(strcpy(buf, "moveto"), XS__moveto, file); - newXS(strcpy(buf, "resume"), XS__resume, file); - newXS(strcpy(buf, "addldonpoints"), XS__addldonpoints, file); - newXS(strcpy(buf, "addldonwin"), XS__addldonpoints, file); - newXS(strcpy(buf, "addldonloss"), XS__addldonpoints, file); - newXS(strcpy(buf, "setnexthpevent"), XS__setnexthpevent, file); - newXS(strcpy(buf, "setnextinchpevent"), XS__setnextinchpevent, file); - newXS(strcpy(buf, "sethp"), XS__sethp, file); - newXS(strcpy(buf, "respawn"), XS__respawn, file); - newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file); - newXS(strcpy(buf, "ChooseRandom"), XS__ChooseRandom, file); - newXS(strcpy(buf, "set_proximity"), XS__set_proximity, file); - newXS(strcpy(buf, "clear_proximity"), XS__clear_proximity, file); - newXS(strcpy(buf, "setanim"), XS__setanim, file); - newXS(strcpy(buf, "showgrid"), XS__showgrid, file); - newXS(strcpy(buf, "showpath"), XS__showpath, file); - newXS(strcpy(buf, "pathto"), XS__pathto, file); - newXS(strcpy(buf, "spawn_condition"), XS__spawn_condition, file); - newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file); - newXS(strcpy(buf, "toggle_spawn_event"), XS__toggle_spawn_event, file); - newXS(strcpy(buf, "has_zone_flag"), XS__has_zone_flag, file); - newXS(strcpy(buf, "set_zone_flag"), XS__set_zone_flag, file); - newXS(strcpy(buf, "clear_zone_flag"), XS__clear_zone_flag, file); - newXS(strcpy(buf, "summonburriedplayercorpse"), XS__summonburriedplayercorpse, file); - newXS(strcpy(buf, "summonallplayercorpses"), XS__summonallplayercorpses, file); - newXS(strcpy(buf, "getplayerburriedcorpsecount"), XS__getplayerburriedcorpsecount, file); - newXS(strcpy(buf, "buryplayercorpse"), XS__buryplayercorpse, file); - newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file); - newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file); - newXS(strcpy(buf, "toggledoorstate"), XS__toggledoorstate, file); - newXS(strcpy(buf, "isdooropen"), XS__isdooropen, file); - newXS(strcpy(buf, "depopall"), XS__depopall, file); - newXS(strcpy(buf, "depopzone"), XS__depopzone, file); - newXS(strcpy(buf, "repopzone"), XS__repopzone, file); - newXS(strcpy(buf, "npcrace"), XS__npcrace, file); - newXS(strcpy(buf, "npcgender"), XS__npcgender, file); - newXS(strcpy(buf, "npcsize"), XS__npcsize, file); - newXS(strcpy(buf, "npctexture"), XS__npctexture, file); - newXS(strcpy(buf, "playerrace"), XS__playerrace, file); - newXS(strcpy(buf, "playergender"), XS__playergender, file); - newXS(strcpy(buf, "playersize"), XS__playersize, file); - newXS(strcpy(buf, "playertexture"), XS__playertexture, file); - newXS(strcpy(buf, "playerfeature"), XS__playerfeature, file); - newXS(strcpy(buf, "npcfeature"), XS__npcfeature, file); - -#ifdef BOTS - newXS(strcpy(buf, "botquest"), XS__botquest, file); - newXS(strcpy(buf, "spawnbotcount"), XS__spawnbotcount, file); - newXS(strcpy(buf, "createbotcount"), XS__createbotcount, file); - newXS(strcpy(buf, "createBot"), XS__createBot, file); -#endif //BOTS - - newXS(strcpy(buf, "taskselector"), XS__taskselector, file); - newXS(strcpy(buf, "tasksetselector"), XS__tasksetselector, file); - newXS(strcpy(buf, "enabletask"), XS__enabletask, file); - newXS(strcpy(buf, "disabletask"), XS__disabletask, file); - newXS(strcpy(buf, "istaskenabled"), XS__istaskenabled, file); - newXS(strcpy(buf, "istaskactive"), XS__istaskactive, file); - newXS(strcpy(buf, "istaskactivityactive"), XS__istaskactivityactive, file); - newXS(strcpy(buf, "gettaskactivitydonecount"), XS__gettaskactivitydonecount, file); - newXS(strcpy(buf, "updatetaskactivity"), XS__updatetaskactivity, file); - newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file); - newXS(strcpy(buf, "taskexploredarea"), XS__taskexploredarea, file); - newXS(strcpy(buf, "assigntask"), XS__assigntask, file); - newXS(strcpy(buf, "failtask"), XS__failtask, file); - newXS(strcpy(buf, "tasktimeleft"), XS__tasktimeleft, file); - newXS(strcpy(buf, "istaskcompleted"), XS__istaskcompleted, file); - newXS(strcpy(buf, "enabledtaskcount"), XS__enabledtaskcount, file); - newXS(strcpy(buf, "firsttaskinset"), XS__firsttaskinset, file); - newXS(strcpy(buf, "lasttaskinset"), XS__lasttaskinset, file); - newXS(strcpy(buf, "nexttaskinset"), XS__nexttaskinset, file); - newXS(strcpy(buf, "activespeaktask"), XS__activespeaktask, file); - newXS(strcpy(buf, "activespeakactivity"), XS__activespeakactivity, file); - newXS(strcpy(buf, "activetasksinset"), XS__activetasksinset, file); - newXS(strcpy(buf, "completedtasksinset"), XS__completedtasksinset, file); - newXS(strcpy(buf, "istaskappropriate"), XS__istaskappropriate, file); - newXS(strcpy(buf, "popup"), XS__popup, file); - newXS(strcpy(buf, "clearspawntimers"), XS__clearspawntimers, file); - newXS(strcpy(buf, "ze"), XS__ze, file); - newXS(strcpy(buf, "we"), XS__we, file); - newXS(strcpy(buf, "getlevel"), XS__getlevel, file); - newXS(strcpy(buf, "creategroundobject"), XS__CreateGroundObject, file); - newXS(strcpy(buf, "creategroundobjectfrommodel"), XS__CreateGroundObjectFromModel, file); - newXS(strcpy(buf, "createdoor"), XS__CreateDoor, file); - newXS(strcpy(buf, "modifynpcstat"), XS__ModifyNPCStat, file); - newXS(strcpy(buf, "collectitems"), XS__collectitems, file); - newXS(strcpy(buf, "updatespawntimer"), XS__UpdateSpawnTimer, file); - newXS(strcpy(buf, "MerchantSetItem"), XS__MerchantSetItem, file); - newXS(strcpy(buf, "MerchantCountItem"), XS__MerchantCountItem, file); - newXS(strcpy(buf, "varlink"), XS__varlink, file); - newXS(strcpy(buf, "saylink"), XS__saylink, file); - newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file); - newXS(strcpy(buf, "CreateInstance"), XS__CreateInstance, file); - newXS(strcpy(buf, "DestroyInstance"), XS__DestroyInstance, file); - newXS(strcpy(buf, "GetInstanceID"), XS__GetInstanceID, file); - newXS(strcpy(buf, "AssignToInstance"), XS__AssignToInstance, file); - newXS(strcpy(buf, "AssignGroupToInstance"), XS__AssignGroupToInstance, file); - newXS(strcpy(buf, "AssignRaidToInstance"), XS__AssignRaidToInstance, file); - newXS(strcpy(buf, "MovePCInstance"), XS__MovePCInstance, file); - newXS(strcpy(buf, "FlagInstanceByGroupLeader"), XS__FlagInstanceByGroupLeader, file); - newXS(strcpy(buf, "FlagInstanceByRaidLeader"), XS__FlagInstanceByRaidLeader, file); - newXS(strcpy(buf, "SetRunning"), XS__SetRunning, file); - newXS(strcpy(buf, "IsRunning"), XS__IsRunning, file); - newXS(strcpy(buf, "IsEffectInSpell"), XS__IsEffectInSpell, file); - newXS(strcpy(buf, "IsBeneficialSpell"), XS__IsBeneficialSpell, file); - newXS(strcpy(buf, "GetSpellResistType"), XS__GetSpellResistType, file); - newXS(strcpy(buf, "GetSpellTargetType"), XS__GetSpellTargetType, file); - newXS(strcpy(buf, "FlyMode"), XS__FlyMode, file); - newXS(strcpy(buf, "factionvalue"), XS_FactionValue, file); - newXS(strcpy(buf, "checktitle"), XS__checktitle, file); - newXS(strcpy(buf, "enabletitle"), XS__enabletitle, file); - newXS(strcpy(buf, "removetitle"), XS__removetitle, file); - newXS(strcpy(buf, "wearchange"), XS__wearchange, file); - newXS(strcpy(buf, "voicetell"), XS__voicetell, file); - newXS(strcpy(buf, "LearnRecipe"), XS__LearnRecipe, file); - newXS(strcpy(buf, "SendMail"), XS__SendMail, file); - newXS(strcpy(buf, "GetZoneID"), XS__GetZoneID, file); - newXS(strcpy(buf, "GetZoneLongName"), XS__GetZoneLongName, file); - newXS(strcpy(buf, "GetTimeSeconds"), XS__GetTimeSeconds, file); - newXS(strcpy(buf, "handleturnin"), XS__handleturnin, file); - newXS(strcpy(buf, "completehandin"), XS__completehandin, file); - newXS(strcpy(buf, "resethandin"), XS__resethandin, file); - newXS(strcpy(buf, "clearhandin"), XS__clearhandin, file); - newXS(strcpy(buf, "crosszonesignalclientbycharid"), XS__crosszonesignalclientbycharid, file); - newXS(strcpy(buf, "crosszonesignalclientbyname"), XS__crosszonesignalclientbyname, file); - newXS(strcpy(buf, "crosszonemessageplayerbyname"), XS__crosszonemessageplayerbyname, file); - XSRETURN_YES; -} - -#endif -#endif +//#include "../common/features.h" +// +//#ifdef EMBPERL +//#ifdef EMBPERL_XS +// +//#include "../common/debug.h" +//#include "perlparser.h" +//#include "questmgr.h" +//#include "embxs.h" +//#include "entity.h" +//#include "../common/MiscFunctions.h" +//#include "zone.h" +//extern Zone* zone; +// +///* +// +//Some useful perl API info: +// +//SvUV == string to unsigned value (char->ulong) +//SvIV == string to signed value (char->long) +//SvNV == string to real value (float,double) +//SvPV_nolen == string with no length restriction +// +// +//*/ +// +//PerlXSParser::PerlXSParser() : PerlembParser() { +// //we cannot rely on PerlembParser to call the right map_funs because +// //our virtual table is not set up until after we call them, so we need to move +// //the call to ReloadQuests out of the constructor. +//} +// +//void PerlXSParser::map_funs() { +// _empty_sv = newSV(0); +// +// perl->eval( +// "{" +// "package quest;" +// "&boot_quest;" //load our quest XS +//#ifdef EMBPERL_XS_CLASSES +// "package Mob;" +// "&boot_Mob;" //load our Mob XS +// +// "package Client;" +// "our @ISA = qw(Mob);" //client inherits mob. +// "&boot_Mob;" //load our Mob XS +// "&boot_Client;" //load our Client XS +// +// "package NPC;" +// "our @ISA = qw(Mob);" //NPC inherits mob. +// "&boot_Mob;" //load our Mob XS +// "&boot_NPC;" //load our NPC XS +// +// "package Corpse;" +// "our @ISA = qw(Mob);" //Corpse inherits mob. +// "&boot_Mob;" //load our Mob XS +// "&boot_Corpse;" //load our Mob XS +// +// "package EntityList;" +// "&boot_EntityList;" //load our EntityList XS +// +// "package PerlPacket;" +// "&boot_PerlPacket;" //load our PerlPacket XS +// +// "package Group;" +// "&boot_Group;" //load our Group XS +// +// "package Raid;" +// "&boot_Raid;" //load our Raid XS +// +// "package QuestItem;" +// "&boot_QuestItem;" // load quest Item XS +// +// "package HateEntry;" +// "&boot_HateEntry;" // load quest Hate XS +// +// "package Object;" +// "&boot_Object;" // load quest Object XS +// +// "package Doors;" +// "&boot_Doors;" // load quest Doors XS +// +//#endif +// "package main;" +// "}" +// );//eval +//} +// +//void PerlXSParser::SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst) +//{ +// if(!perl) +// return; +// _ZP(PerlXSParser_SendCommands); +// +// if(mob && mob->IsClient()) +// quest_manager.StartQuest(other, mob->CastToClient(), iteminst); +// else +// quest_manager.StartQuest(other, nullptr, nullptr); +// +// try { +// +// std::string cmd = "package " + (std::string)(pkgprefix) + (std::string)(";"); +// perl->eval(cmd.c_str()); +// +//#ifdef EMBPERL_XS_CLASSES +// char namebuf[64]; +// +// //init a couple special vars: client, npc, entity_list +// Client *curc = quest_manager.GetInitiator(); +// snprintf(namebuf, 64, "%s::client", pkgprefix); +// SV *client = get_sv(namebuf, true); +// if(curc != nullptr) { +// sv_setref_pv(client, "Client", curc); +// } else { +// //clear out the value, mainly to get rid of blessedness +// sv_setsv(client, _empty_sv); +// } +// +// //only export NPC if it's a npc quest +// if(!other->IsClient()){ +// NPC *curn = quest_manager.GetNPC(); +// snprintf(namebuf, 64, "%s::npc", pkgprefix); +// SV *npc = get_sv(namebuf, true); +// sv_setref_pv(npc, "NPC", curn); +// } +// +// //only export QuestItem if it's an item quest +// if(iteminst) { +// ItemInst* curi = quest_manager.GetQuestItem(); +// snprintf(namebuf, 64, "%s::questitem", pkgprefix); +// SV *questitem = get_sv(namebuf, true); +// sv_setref_pv(questitem, "QuestItem", curi); +// } +// +// snprintf(namebuf, 64, "%s::entity_list", pkgprefix); +// SV *el = get_sv(namebuf, true); +// sv_setref_pv(el, "EntityList", &entity_list); +//#endif +// +// //now call the requested sub +// perl->dosub(std::string(pkgprefix).append("::").append(event).c_str()); +// +//#ifdef EMBPERL_XS_CLASSES +// std::string eval_str = (std::string)"$" + (std::string)pkgprefix + (std::string)"::client = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::npc = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::questitem = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::entity_list = undef;"; +// perl->eval(eval_str.c_str()); +//#endif +// +// } catch(const char * err) { +// +// //try to reduce some of the console spam... +// //todo: tweak this to be more accurate at deciding what to filter (we don't want to gag legit errors) +// if(!strstr(err,"Undefined subroutine")) +// LogFile->write(EQEMuLog::Status, "Script error: %s::%s - %s", pkgprefix, event, err); +// } +// +// quest_manager.EndQuest(); +//} +// +// +//#ifdef EMBPERL_XS_CLASSES +// +////Any creation of new Client objects gets the current quest Client +//XS(XS_Client_new); +//XS(XS_Client_new) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: Client::new()"); +// { +// Client * RETVAL; +// +// RETVAL = quest_manager.GetInitiator(); +// ST(0) = sv_newmortal(); +// if(RETVAL) +// sv_setref_pv(ST(0), "Client", (void*)RETVAL); +// } +// XSRETURN(1); +//} +// +////Any creation of new NPC objects gets the current quest NPC +//XS(XS_NPC_new); +//XS(XS_NPC_new) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: NPC::new()"); +// { +// NPC * RETVAL; +// +// RETVAL = quest_manager.GetNPC(); +// ST(0) = sv_newmortal(); +// if(RETVAL) +// sv_setref_pv(ST(0), "NPC", (void*)RETVAL); +// } +// XSRETURN(1); +//} +// +////Any creation of new NPC objects gets the current quest NPC +//XS(XS_EntityList_new); +//XS(XS_EntityList_new) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: EntityList::new()"); +// { +// EntityList * RETVAL; +// +// RETVAL = &entity_list; +// ST(0) = sv_newmortal(); +// if(RETVAL) +// sv_setref_pv(ST(0), "EntityList", (void*)RETVAL); +// } +// XSRETURN(1); +//} +// +////Any creation of new quest items gets the current quest item +//XS(XS_QuestItem_new); +//XS(XS_QuestItem_new) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: QuestItem::new()"); +// +// ItemInst* RETVAL; +// +// RETVAL = quest_manager.GetQuestItem(); +// ST(0) = sv_newmortal(); +// if(RETVAL) +// sv_setref_pv(ST(0), "QuestItem", (void*)RETVAL); +// +// XSRETURN(1); +//} +// +////Any creation of new quest items gets the current quest item +//XS(XS_MobList_new); +//XS(XS_MobList_new) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: MobList::new()"); +// +// ListElement* RETVAL; +// +// RETVAL = nullptr; +// ST(0) = sv_newmortal(); +// if(RETVAL) +// sv_setref_pv(ST(0), "MobList", (void*)RETVAL); +// +// XSRETURN(1); +//} +// +//#endif //EMBPERL_XS_CLASSES +// +// +//XS(XS__echo); // prototype to pass -Wmissing-prototypes +//XS(XS__echo) { +// dXSARGS; +// +// if (items != 2) +// Perl_croak(aTHX_ "Usage: echo(id#, str)"); +// +// quest_manager.echo(SvUV(ST(0)), SvPV_nolen(ST(1))); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__say); // prototype to pass -Wmissing-prototypes +//XS(XS__say) { +// dXSARGS; +// +// if (items == 1) +// quest_manager.say(SvPV_nolen(ST(0))); +// else if (items == 2) +// quest_manager.say(SvPV_nolen(ST(0)), (int)SvIV(ST(1))); +// else +// Perl_croak(aTHX_ "Usage: say(str [, language])"); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__me); // prototype to pass -Wmissing-prototypes +//XS(XS__me) { +// dXSARGS; +// +// if (items != 1) +// Perl_croak(aTHX_ "Usage: %s(str)", "me"); +// +// quest_manager.me(SvPV_nolen(ST(0))); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__summonitem); // prototype to pass -Wmissing-prototypes +//XS(XS__summonitem) +//{ +// dXSARGS; +// if (items == 1) +// quest_manager.summonitem(SvUV(ST(0))); +// else if(items == 2) +// quest_manager.summonitem(SvUV(ST(0)), SvUV(ST(1))); +// else +// Perl_croak(aTHX_ "Usage: summonitem(itemid, [charges])"); +// XSRETURN_EMPTY; +//} +// +//XS(XS__write); +//XS(XS__write) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: write(file, str)"); +// +// char * file = (char *)SvPV_nolen(ST(0)); +// char * str = (char *)SvPV_nolen(ST(1)); +// +// quest_manager.write(file, str); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__spawn); +//XS(XS__spawn) +//{ +// dXSARGS; +// if (items != 6) +// Perl_croak(aTHX_ "Usage: spawn(npc_type, grid, unused, x, y, z)"); +// +// uint16 RETVAL; +// dXSTARG; +// +// int npc_type = (int)SvIV(ST(0)); +// int grid = (int)SvIV(ST(1)); +// int unused = (int)SvIV(ST(2)); +// float x = (float)SvNV(ST(3)); +// float y = (float)SvNV(ST(4)); +// float z = (float)SvNV(ST(5)); +// +// RETVAL = quest_manager.spawn2(npc_type, grid, unused, x, y, z, 0); +// XSprePUSH; PUSHu((UV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__spawn2); +//XS(XS__spawn2) +//{ +// dXSARGS; +// if (items != 7) +// Perl_croak(aTHX_ "Usage: spawn2(npc_type, grid, unused, x, y, z, heading)"); +// +// uint16 RETVAL; +// dXSTARG; +// +// int npc_type = (int)SvIV(ST(0)); +// int grid = (int)SvIV(ST(1)); +// int unused = (int)SvIV(ST(2)); +// float x = (float)SvNV(ST(3)); +// float y = (float)SvNV(ST(4)); +// float z = (float)SvNV(ST(5)); +// float heading = (float)SvNV(ST(6)); +// +// RETVAL = quest_manager.spawn2(npc_type, grid, unused, x, y, z, heading); +// XSprePUSH; PUSHu((UV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__unique_spawn); +//XS(XS__unique_spawn) +//{ +// dXSARGS; +// if (items != 6 && items != 7) +// Perl_croak(aTHX_ "Usage: unique_spawn(npc_type, grid, unused, x, y, z, [heading])"); +// +// uint16 RETVAL; +// dXSTARG; +// +// int npc_type = (int)SvIV(ST(0)); +// int grid = (int)SvIV(ST(1)); +// int unused = (int)SvIV(ST(2)); +// float x = (float)SvNV(ST(3)); +// float y = (float)SvNV(ST(4)); +// float z = (float)SvNV(ST(5)); +// float heading = 0; +// if(items == 7) +// heading = (float)SvNV(ST(6)); +// +// RETVAL = quest_manager.unique_spawn(npc_type, grid, unused, x, y, z, heading); +// XSprePUSH; PUSHu((UV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__spawn_from_spawn2); +//XS(XS__spawn_from_spawn2) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: spawn_from_spawn2(spawn2_id)"); +// +// uint16 RETVAL; +// dXSTARG; +// +// int spawn2_id = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.spawn_from_spawn2(spawn2_id); +// XSprePUSH; PUSHu((UV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__enable_spawn2); +//XS(XS__enable_spawn2) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: enable_spawn2(spawn2_id)"); +// +// int spawn2_id = (int)SvIV(ST(0)); +// +// quest_manager.enable_spawn2(spawn2_id); +// XSRETURN_EMPTY; +//} +// +//XS(XS__disable_spawn2); +//XS(XS__disable_spawn2) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: disable_spawn2(spawn2_id)"); +// +// int spawn2_id = (int)SvIV(ST(0)); +// +// quest_manager.disable_spawn2(spawn2_id); +// XSRETURN_EMPTY; +//} +// +//XS(XS__setstat); +//XS(XS__setstat) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: setstat(stat, value)"); +// +// int stat = (int)SvIV(ST(0)); +// int value = (int)SvIV(ST(1)); +// +// quest_manager.setstat(stat, value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__incstat); //old setstat command aza +//XS(XS__incstat) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: incstat(stat, value)"); +// +// int stat = (int)SvIV(ST(0)); +// int value = (int)SvIV(ST(1)); +// +// quest_manager.incstat(stat, value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__castspell); +//XS(XS__castspell) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: castspell(spell_id, target_id)"); +// +// int spell_id = (int)SvIV(ST(0)); +// int target_id = (int)SvIV(ST(1)); +// +// quest_manager.castspell(spell_id, target_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__selfcast); +//XS(XS__selfcast) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: selfcast(spell_id)"); +// +// int spell_id = (int)SvIV(ST(0)); +// +// quest_manager.selfcast(spell_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__addloot); +//XS(XS__addloot) +//{ +// dXSARGS; +// if(items < 1 || items > 3) +// Perl_croak(aTHX_ "Usage: addloot(item_id, charges = 0, equipitem = true)"); +// +// uint32 itemid = (uint32)SvUV(ST(0)); +// uint16 charges = 0; +// bool equipitem = true; +// +// if (items > 1) +// charges = (uint16)SvUV(ST(1)); +// if (items > 2) +// equipitem = (bool)SvTRUE(ST(2)); +// +// quest_manager.addloot(itemid, charges, equipitem); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__zone); +//XS(XS__zone) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: zone(zone_name)"); +// +// char * zone_name = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.Zone(zone_name); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__settimer); +//XS(XS__settimer) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: settimer(timer_name, seconds)"); +// +// char * timer_name = (char *)SvPV_nolen(ST(0)); +// int seconds = (int)SvIV(ST(1)); +// +// quest_manager.settimer(timer_name, seconds); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__settimerMS); +//XS(XS__settimerMS) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: settimerMS(timer_name, milliseconds)"); +// +// char * timer_name = (char *)SvPV_nolen(ST(0)); +// int milliseconds = (int)SvIV(ST(1)); +// +// quest_manager.settimerMS(timer_name, milliseconds); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__stoptimer); +//XS(XS__stoptimer) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: stoptimer(timer_name)"); +// +// char * timer_name = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.stoptimer(timer_name); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__stopalltimers); +//XS(XS__stopalltimers) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: stopalltimers()"); +// +// quest_manager.stopalltimers(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__emote); +//XS(XS__emote) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: emote(str)"); +// +// char * str = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.emote(str); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__shout); +//XS(XS__shout) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: shout(str)"); +// +// char * str = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.shout(str); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__shout2); +//XS(XS__shout2) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: shout2(str)"); +// +// char * str = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.shout2(str); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__gmsay); +//XS(XS__gmsay) +//{ +// dXSARGS; +// if ((items < 1) || (items > 5)) +// Perl_croak(aTHX_ "Usage: gmsay(str, color, send_to_world?)"); +// +// char * str = (char *)SvPV_nolen(ST(0)); +// int color = 7; +// bool send_to_world = 0; +// uint32 to_guilddbid = 0; +// uint16 to_minstatus = 80; +// +// if (items > 1) { +// color = (int)SvIV(ST(1)); +// } +// +// if (items > 2) { +// send_to_world = ((int)SvIV(ST(2))) == 0?false:true; +// } +// +// if (items > 3) +// to_guilddbid = (int)SvUV(ST(3)); +// +// if (items > 4) +// to_minstatus = (int)SvUV(ST(4)); +// +// quest_manager.gmsay(str, color, send_to_world, to_guilddbid, to_minstatus); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__depop); +//XS(XS__depop) +//{ +// dXSARGS; +// if (items < 0 || items > 1) +// Perl_croak(aTHX_ "Usage: depop(npc_type= 0)"); +// +// int npc_type; +// +// if (items < 1) +// npc_type = 0; +// else +// npc_type = (int)SvIV(ST(0)); +// +// +// quest_manager.depop(npc_type); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__depop_withtimer); +//XS(XS__depop_withtimer) +//{ +// dXSARGS; +// if (items < 0 || items > 1) +// Perl_croak(aTHX_ "Usage: depop_withtimer(npc_type= 0)"); +// +// int npc_type; +// +// if (items < 1) +// npc_type = 0; +// else +// npc_type = (int)SvIV(ST(0)); +// +// +// quest_manager.depop_withtimer(npc_type); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__depopall); +//XS(XS__depopall) +//{ +// dXSARGS; +// if (items < 0 || items > 1) +// Perl_croak(aTHX_ "Usage: depopall(npc_type= 0)"); +// +// int npc_type; +// +// if (items < 1) +// npc_type = 0; +// else +// npc_type = (int)SvIV(ST(0)); +// +// +// quest_manager.depopall(npc_type); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__settarget); +//XS(XS__settarget) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: settarget(type, target_id)"); +// +// char * type = (char *)SvPV_nolen(ST(0)); +// int target_id = (int)SvIV(ST(1)); +// +// quest_manager.settarget(type, target_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__follow); +//XS(XS__follow) +//{ +// dXSARGS; +// if (items != 1 && items != 2) +// Perl_croak(aTHX_ "Usage: follow(entity_id, [distance])"); +// +// int entity_id = (int)SvIV(ST(0)); +// int distance; +// +// if (items == 2) +// distance = (int)SvIV(ST(1)); +// else +// distance = 10; +// +// quest_manager.follow(entity_id, distance); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__sfollow); +//XS(XS__sfollow) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: sfollow()"); +// +// +// quest_manager.sfollow(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__changedeity); +//XS(XS__changedeity) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: changedeity(diety_id)"); +// +// int diety_id = (int)SvIV(ST(0)); +// +// quest_manager.changedeity(diety_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__exp); +//XS(XS__exp) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: exp(amt)"); +// +// int amt = (int)SvIV(ST(0)); +// +// quest_manager.exp(amt); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__level); +//XS(XS__level) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: level(newlevel)"); +// +// int newlevel = (int)SvIV(ST(0)); +// +// quest_manager.level(newlevel); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__traindisc); +//XS(XS__traindisc) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: traindisc(discipline_tome_item_id)"); +// +// int discipline_tome_item_id = (int)SvIV(ST(0)); +// +// quest_manager.traindisc(discipline_tome_item_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__isdisctome); +//XS(XS__isdisctome) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: isdisctome(item_id)"); +// +// bool RETVAL; +// int item_id = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.isdisctome(item_id); +// +// ST(0) = boolSV(RETVAL); +// sv_2mortal(ST(0)); +// XSRETURN(1); +//} +// +//XS(XS__safemove); +//XS(XS__safemove) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: safemove()"); +// +// +// quest_manager.safemove(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__rain); +//XS(XS__rain) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: rain(weather)"); +// +// int weather = (int)SvIV(ST(0)); +// +// quest_manager.rain(weather); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__snow); +//XS(XS__snow) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: snow(weather)"); +// +// int weather = (int)SvIV(ST(0)); +// +// quest_manager.snow(weather); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__surname); +//XS(XS__surname) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: surname(name)"); +// +// char * name = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.surname(name); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__permaclass); +//XS(XS__permaclass) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: permaclass(class_id)"); +// +// int class_id = (int)SvIV(ST(0)); +// +// quest_manager.permaclass(class_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__permarace); +//XS(XS__permarace) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: permarace(race_id)"); +// +// int race_id = (int)SvIV(ST(0)); +// +// quest_manager.permarace(race_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__permagender); +//XS(XS__permagender) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: permagender(gender_id)"); +// +// int gender_id = (int)SvIV(ST(0)); +// +// quest_manager.permagender(gender_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__scribespells); +//XS(XS__scribespells) +//{ +// dXSARGS; +// if (items < 1) +// Perl_croak(aTHX_ "Usage: scribespells(max_level, min_level = 1)"); +// +// uint16 RETVAL; +// dXSTARG; +// +// uint8 max_level = (uint8)SvIV(ST(0)); +// uint8 min_level = (uint8)SvIV(ST(1)); +// +// if (min_level) +// RETVAL = quest_manager.scribespells(max_level, min_level); +// else +// RETVAL = quest_manager.scribespells(max_level); +// +// XSprePUSH; PUSHu((IV)RETVAL); +// XSRETURN(1); +//} +// +//XS(XS__traindiscs); +//XS(XS__traindiscs) +//{ +// dXSARGS; +// if (items < 1) +// Perl_croak(aTHX_ "Usage: traindiscs(max_level, min_level = 1)"); +// +// uint16 RETVAL; +// dXSTARG; +// +// uint8 max_level = (uint8)SvIV(ST(0)); +// uint8 min_level = (uint8)SvIV(ST(1)); +// +// if (min_level) +// RETVAL = quest_manager.traindiscs(max_level, min_level); +// else +// RETVAL = quest_manager.traindiscs(max_level); +// +// XSprePUSH; PUSHu((IV)RETVAL); +// XSRETURN(1); +//} +// +//XS(XS__unscribespells); +//XS(XS__unscribespells) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: unscribespells()"); +// +// +// quest_manager.unscribespells(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__untraindiscs); +//XS(XS__untraindiscs) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: untraindiscs()"); +// +// +// quest_manager.untraindiscs(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__givecash); +//XS(XS__givecash) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: givecash(copper, silver, gold, platinum)"); +// +// int copper = (int)SvIV(ST(0)); +// int silver = (int)SvIV(ST(1)); +// int gold = (int)SvIV(ST(2)); +// int platinum = (int)SvIV(ST(3)); +// +// quest_manager.givecash(copper, silver, gold, platinum); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__pvp); +//XS(XS__pvp) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: pvp(mode)"); +// +// char * mode = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.pvp(mode); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__movepc); +//XS(XS__movepc) +//{ +// dXSARGS; +// if (items != 4 && items != 5) +// Perl_croak(aTHX_ "Usage: movepc(zone_id, x, y, z [,heading])"); +// +// int zoneid = (int)SvIV(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// +// if (items == 4) +// +// quest_manager.movepc(zoneid, x, y, z, 0.0f); +// +// else { +// float heading = (float)SvNV(ST(4)); +// quest_manager.movepc(zoneid, x, y, z, heading); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__gmmove); +//XS(XS__gmmove) +//{ +// dXSARGS; +// if (items != 3) +// Perl_croak(aTHX_ "Usage: gmmove(x, y, z)"); +// +// float x = (float)SvNV(ST(0)); +// float y = (float)SvNV(ST(1)); +// float z = (float)SvNV(ST(2)); +// +// quest_manager.gmmove(x, y, z); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__movegrp); +//XS(XS__movegrp) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: movegrp(zoneid, x, y, z)"); +// +// int zoneid = (int)SvIV(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// +// quest_manager.movegrp(zoneid, x, y, z); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__doanim); +//XS(XS__doanim) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: doanim(anim_id)"); +// +// int anim_id = (int)SvIV(ST(0)); +// +// quest_manager.doanim(anim_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__addskill); +//XS(XS__addskill) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: addskill(skill_id, value)"); +// +// int skill_id = (int)SvIV(ST(0)); +// int value = (int)SvIV(ST(1)); +// +// quest_manager.addskill(skill_id, value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setlanguage); +//XS(XS__setlanguage) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: setlanguage(skill_id, value)"); +// +// int skill_id = (int)SvIV(ST(0)); +// int value = (int)SvIV(ST(1)); +// +// quest_manager.setlanguage(skill_id, value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setskill); +//XS(XS__setskill) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: setskill(skill_id, value)"); +// +// int skill_id = (int)SvIV(ST(0)); +// int value = (int)SvIV(ST(1)); +// +// quest_manager.setskill(skill_id, value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setallskill); +//XS(XS__setallskill) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: setallskill(value)"); +// +// int value = (int)SvIV(ST(0)); +// +// quest_manager.setallskill(value); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__attack); +//XS(XS__attack) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: attack(client_name)"); +// +// char * client_name = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.attack(client_name); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__attacknpc); +//XS(XS__attacknpc) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: attacknpc(npc_entity_id)"); +// +// int npc_entity_id = (int)SvIV(ST(0)); +// +// quest_manager.attacknpc(npc_entity_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__attacknpctype); +//XS(XS__attacknpctype) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: attacknpctype(npc_type_id)"); +// +// int npc_type_id = (int)SvIV(ST(0)); +// +// quest_manager.attacknpctype(npc_type_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__save); +//XS(XS__save) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: save()"); +// +// +// quest_manager.save(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__faction); +//XS(XS__faction) +//{ +// dXSARGS; +// if (items < 2 || items > 3) +// Perl_croak(aTHX_ "Usage: faction(faction_id, faction_value, temp)"); +// +// int faction_id = (int)SvIV(ST(0)); +// int faction_value = (int)SvIV(ST(1)); +// int temp; +// +// if(items == 2) +// temp = 0; +// else +// temp = (int)SvIV(ST(2)); +// +// quest_manager.faction(faction_id, faction_value, temp); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setsky); +//XS(XS__setsky) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: setsky(new_sky)"); +// +// unsigned char new_sky = (unsigned char)SvUV(ST(0)); +// +// quest_manager.setsky(new_sky); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setguild); +//XS(XS__setguild) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: setguild(new_guild_id, new_rank)"); +// +// unsigned long new_guild_id = (unsigned long)SvUV(ST(0)); +// int new_rank = (int)SvIV(ST(1)); +// +// quest_manager.setguild(new_guild_id, new_rank); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__createguild); +//XS(XS__createguild) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: createguild(guild_name, leader)"); +// +// char * guild_name = (char *)SvPV_nolen(ST(0)); +// char * leader = (char *)SvPV_nolen(ST(1)); +// +// quest_manager.CreateGuild(guild_name, leader); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__settime); +//XS(XS__settime) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: settime(new_hour, new_min)"); +// +// int new_hour = (int)SvIV(ST(0)); +// int new_min = (int)SvIV(ST(1)); +// +// quest_manager.settime(new_hour, new_min); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__itemlink); +//XS(XS__itemlink) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: itemlink(item_id)"); +// +// int item_id = (int)SvIV(ST(0)); +// +// quest_manager.itemlink(item_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__signalwith); +//XS(XS__signalwith) +//{ +// dXSARGS; +// +// if (items == 2) { +// int npc_id = (int)SvIV(ST(0)); +// int signal_id = (int)SvIV(ST(1)); +// quest_manager.signalwith(npc_id, signal_id); +// } else if(items == 3) { +// int npc_id = (int)SvIV(ST(0)); +// int signal_id = (int)SvIV(ST(1)); +// int wait = (int)SvIV(ST(2)); +// quest_manager.signalwith(npc_id, signal_id, wait); +// } else { +// Perl_croak(aTHX_ "Usage: signalwith(npc_id,signal_id[,wait_ms])"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__signal); +//XS(XS__signal) +//{ +// dXSARGS; +// +// if (items == 1) { +// int npc_id = (int)SvIV(ST(0)); +// quest_manager.signal(npc_id); +// } else if(items == 2) { +// int npc_id = (int)SvIV(ST(0)); +// int wait = (int)SvIV(ST(1)); +// quest_manager.signal(npc_id, wait); +// } else { +// Perl_croak(aTHX_ "Usage: signal(npc_id[,wait_ms])"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setglobal); +//XS(XS__setglobal) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: setglobal(varname, newvalue, options, duration)"); +// +// char * varname = (char *)SvPV_nolen(ST(0)); +// char * newvalue = (char *)SvPV_nolen(ST(1)); +// int options = (int)SvIV(ST(2)); +// char * duration = (char *)SvPV_nolen(ST(3)); +// +// quest_manager.setglobal(varname, newvalue, options, duration); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__targlobal); +//XS(XS__targlobal) +//{ +// dXSARGS; +// if (items != 6) +// Perl_croak(aTHX_ "Usage: targlobal(varname, value, duration, npcid, charid, zoneid)"); +// +// char * varname = (char *)SvPV_nolen(ST(0)); +// char * value = (char *)SvPV_nolen(ST(1)); +// char * duration = (char *)SvPV_nolen(ST(2)); +// int npcid = (int)SvIV(ST(3)); +// int charid = (int)SvIV(ST(4)); +// int zoneid = (int)SvIV(ST(5)); +// +// quest_manager.targlobal(varname, value, duration, npcid, charid, zoneid); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__delglobal); +//XS(XS__delglobal) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: delglobal(varname)"); +// +// char * varname = (char *)SvPV_nolen(ST(0)); +// +// quest_manager.delglobal(varname); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__ding); +//XS(XS__ding) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: ding()"); +// +// +// quest_manager.ding(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__rebind); +//XS(XS__rebind) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: rebind(zoneid, x, y, z)"); +// +// int zoneid = (int)SvIV(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// +// quest_manager.rebind(zoneid, x, y, z); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__start); +//XS(XS__start) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: start(wp)"); +// +// int wp = (int)SvIV(ST(0)); +// +// quest_manager.start(wp); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__stop); +//XS(XS__stop) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: stop()"); +// +// +// quest_manager.stop(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__pause); +//XS(XS__pause) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: pause(duration)"); +// +// int duration = (int)SvIV(ST(0)); +// +// quest_manager.pause(duration); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__moveto); +//XS(XS__moveto) +//{ +// dXSARGS; +// if (items != 3 && items != 4 && items != 5) +// Perl_croak(aTHX_ "Usage: moveto(x, y, z, [mth, saveguard?])"); +// +// float x = (float)SvNV(ST(0)); +// float y = (float)SvNV(ST(1)); +// float z = (float)SvNV(ST(2)); +// float h; +// bool saveguard; +// +// if(items > 3) +// h = (float)SvNV(ST(3)); +// else +// h = 0; +// +// if(items > 4) +// saveguard = (bool)SvTRUE(ST(4)); +// else +// saveguard = false; +// +// quest_manager.moveto(x, y, z, h, saveguard); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__resume); +//XS(XS__resume) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: resume()"); +// +// +// quest_manager.resume(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__addldonpoints); +//XS(XS__addldonpoints) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: addldonpoints(points, theme)"); +// +// long points = (long)SvIV(ST(0)); +// unsigned long theme = (unsigned long)SvUV(ST(1)); +// +// quest_manager.addldonpoints(points, theme); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__addldonwin); +//XS(XS__addldonwin) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: addldonwin(wins, theme)"); +// +// long wins = (long)SvIV(ST(0)); +// unsigned long theme = (unsigned long)SvUV(ST(1)); +// +// quest_manager.addldonwin(wins, theme); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__addldonloss); +//XS(XS__addldonloss) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: addldonloss(losses, theme)"); +// +// long losses = (long)SvIV(ST(0)); +// unsigned long theme = (unsigned long)SvUV(ST(1)); +// +// quest_manager.addldonloss(losses, theme); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setnexthpevent); +//XS(XS__setnexthpevent) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: setnexthpevent(at)"); +// +// int at = (int)SvIV(ST(0)); +// +// quest_manager.setnexthpevent(at); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setnextinchpevent); +//XS(XS__setnextinchpevent) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: setnextinchpevent(at)"); +// +// int at = (int)SvIV(ST(0)); +// +// quest_manager.setnextinchpevent(at); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__sethp); +//XS(XS__sethp) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: sethp(percentage)"); +// +// int hpperc = (int)SvIV(ST(0)); +// +// quest_manager.sethp(hpperc); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__respawn); +//XS(XS__respawn) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: respawn(npc_type, grid)"); +// +// int npc_type = (int)SvIV(ST(0)); +// int grid = (int)SvIV(ST(1)); +// +// quest_manager.respawn(npc_type, grid); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__ChooseRandom); +//XS(XS__ChooseRandom) +//{ +// dXSARGS; +// if (items < 1) +// Perl_croak(aTHX_ "Usage: ChooseRandom(... list ...)"); +// +// int index = MakeRandomInt(0, items-1); +// +// SV *tmp = ST(0); +// ST(0) = ST(index); +// ST(index) = tmp; +// +// XSRETURN(1); //return 1 element from the stack (ST(0)) +//} +// +//XS(XS__set_proximity); +//XS(XS__set_proximity) +//{ +// dXSARGS; +// if (items != 4 && items != 6) +// Perl_croak(aTHX_ "Usage: set_proximity(minx, maxx, miny, maxy [, minz, maxz])"); +// +// float minx = (float)SvNV(ST(0)); +// float maxx = (float)SvNV(ST(1)); +// float miny = (float)SvNV(ST(2)); +// float maxy = (float)SvNV(ST(3)); +// +// if(items == 4) +// quest_manager.set_proximity(minx, maxx, miny, maxy); +// else { +// float minz = (float)SvNV(ST(4)); +// float maxz = (float)SvNV(ST(5)); +// quest_manager.set_proximity(minx, maxx, miny, maxy, minz, maxz); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__clear_proximity); +//XS(XS__clear_proximity) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: clear_proximity()"); +// +// quest_manager.clear_proximity(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__setanim); +//XS(XS__setanim) //Cisyouc: mob->setappearance() addition +//{ +// dXSARGS; +// if(items != 2) +// Perl_croak(aTHX_ "Usage: quest::setanim(npc_type, animnum);"); +// +// quest_manager.setanim(SvUV(ST(0)), SvUV(ST(1))); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__showgrid); +//XS(XS__showgrid) +//{ +// dXSARGS; +// if(items != 1) +// Perl_croak(aTHX_ "Usage: quest::showgrid(grid_id);"); +// +// quest_manager.showgrid(SvUV(ST(0))); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__showpath); +//XS(XS__showpath) +//{ +// dXSARGS; +// if (items != 3) +// Perl_croak(aTHX_ "Usage: showpath(x, y, z)"); +// +// float x = (float)SvNV(ST(0)); +// float y = (float)SvNV(ST(1)); +// float z = (float)SvNV(ST(2)); +// +// quest_manager.showpath(x, y, z); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__pathto); +//XS(XS__pathto) +//{ +// dXSARGS; +// if (items != 3) +// Perl_croak(aTHX_ "Usage: pathto(x, y, z)"); +// +// float x = (float)SvNV(ST(0)); +// float y = (float)SvNV(ST(1)); +// float z = (float)SvNV(ST(2)); +// +// quest_manager.pathto(x, y, z); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__spawn_condition); +//XS(XS__spawn_condition) +//{ +// dXSARGS; +// if (items < 3 || items > 4) +// Perl_croak(aTHX_ "Usage: spawn_condition(zone_short, [instance_id], condition_id, value)"); +// +// if(items == 3) +// { +// char * zone_short = (char *)SvPV_nolen(ST(0)); +// uint16 cond_id = (int)SvUV(ST(1)); +// int16 value = (int)SvIV(ST(2)); +// +// quest_manager.spawn_condition(zone_short, zone->GetInstanceID(), cond_id, value); +// } +// else +// { +// char * zone_short = (char *)SvPV_nolen(ST(0)); +// uint32 instance_id = (int)SvUV(ST(1)); +// uint16 cond_id = (int)SvUV(ST(2)); +// int16 value = (int)SvIV(ST(3)); +// +// quest_manager.spawn_condition(zone_short, instance_id, cond_id, value); +// } +// XSRETURN_EMPTY; +//} +// +//XS(XS__get_spawn_condition); +//XS(XS__get_spawn_condition) +//{ +// dXSARGS; +// if (items < 2 || items > 3) +// Perl_croak(aTHX_ "Usage: get_spawn_condition(zone_short, [instance_id], condition_id)"); +// +// if(items == 2) +// { +// int16 RETVAL; +// dXSTARG; +// +// char * zone_short = (char *)SvPV_nolen(ST(0)); +// uint16 cond_id = (int)SvIV(ST(1)); +// +// RETVAL = quest_manager.get_spawn_condition(zone_short, zone->GetInstanceID(), cond_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +// } +// else +// { +// int16 RETVAL; +// dXSTARG; +// +// char * zone_short = (char *)SvPV_nolen(ST(0)); +// uint16 instance_id = (int)SvIV(ST(1)); +// uint16 cond_id = (int)SvIV(ST(2)); +// +// RETVAL = quest_manager.get_spawn_condition(zone_short, instance_id, cond_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +// } +//} +// +//XS(XS__toggle_spawn_event); +//XS(XS__toggle_spawn_event) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: toggle_spawn_event(event_id, enabled?, reset_base)"); +// +// uint32 event_id = (int)SvIV(ST(0)); +// bool enabled = ((int)SvIV(ST(1))) == 0?false:true; +// bool reset_base = ((int)SvIV(ST(1))) == 0?false:true; +// +// quest_manager.toggle_spawn_event(event_id, enabled, reset_base); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__has_zone_flag); +//XS(XS__has_zone_flag) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: has_zone_flag(zone_id)"); +// +// int16 RETVAL; +// dXSTARG; +// +// uint32 zone_id = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.has_zone_flag(zone_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +// +//} +// +//XS(XS__set_zone_flag); +//XS(XS__set_zone_flag) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: set_zone_flag(zone_id)"); +// +// uint32 zone_id = (int)SvIV(ST(0)); +// +// quest_manager.set_zone_flag(zone_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__clear_zone_flag); +//XS(XS__clear_zone_flag) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: clear_zone_flag(zone_id)"); +// +// uint32 zone_id = (int)SvIV(ST(0)); +// +// quest_manager.clear_zone_flag(zone_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__summonburriedplayercorpse); +//XS(XS__summonburriedplayercorpse) +//{ +// dXSARGS; +// if (items != 5) +// Perl_croak(aTHX_ "Usage: summonburriedplayercorpse(char_id,dest_x,dest_y,dest_z,dest_heading)"); +// +// bool RETVAL; +// uint32 char_id = (int)SvIV(ST(0)); +// float dest_x = (float)SvIV(ST(1)); +// float dest_y = (float)SvIV(ST(2)); +// float dest_z = (float)SvIV(ST(3)); +// float dest_heading = (float)SvIV(ST(4)); +// +// RETVAL = quest_manager.summonburriedplayercorpse(char_id, dest_x, dest_y, dest_z, dest_heading); +// +// ST(0) = boolSV(RETVAL); +// sv_2mortal(ST(0)); +// XSRETURN(1); +//} +// +//XS(XS__summonallplayercorpses); +//XS(XS__summonallplayercorpses) +//{ +// dXSARGS; +// if (items != 5) +// Perl_croak(aTHX_ "Usage: summonallplayercorpses(char_id,dest_x,dest_y,dest_z,dest_heading)"); +// +// bool RETVAL; +// uint32 char_id = (int)SvIV(ST(0)); +// float dest_x = (float)SvIV(ST(1)); +// float dest_y = (float)SvIV(ST(2)); +// float dest_z = (float)SvIV(ST(3)); +// float dest_heading = (float)SvIV(ST(4)); +// +// RETVAL = quest_manager.summonallplayercorpses(char_id, dest_x, dest_y, dest_z, dest_heading); +// +// ST(0) = boolSV(RETVAL); +// sv_2mortal(ST(0)); +// XSRETURN(1); +//} +// +//XS(XS__getplayerburriedcorpsecount); +//XS(XS__getplayerburriedcorpsecount) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: getplayerburriedcorpsecount(char_id)"); +// +// uint32 RETVAL; +// dXSTARG; +// +// uint32 char_id = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.getplayerburriedcorpsecount(char_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__buryplayercorpse); +//XS(XS__buryplayercorpse) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: buryplayercorpse(char_id)"); +// +// uint32 RETVAL; +// dXSTARG; +// +// uint32 char_id = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.buryplayercorpse(char_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__forcedooropen); +//XS(XS__forcedooropen) +//{ +// dXSARGS; +// if (items < 1 || items > 2) +// Perl_croak(aTHX_ "Usage: forcedooropen(doorid [, altmode=0])"); +// +// if (items == 1) +// { +// uint32 did = (int)SvIV(ST(0)); +// +// quest_manager.forcedooropen(did, false); +// +// XSRETURN_EMPTY; +// } +// else +// { +// uint32 did = (int)SvIV(ST(0)); +// bool am = (int)SvIV(ST(1)) == 0?false:true; +// +// quest_manager.forcedooropen(did, am); +// +// XSRETURN_EMPTY; +// } +//} +// +//XS(XS__forcedoorclose); +//XS(XS__forcedoorclose) +//{ +// dXSARGS; +// if (items < 1 || items > 2) +// Perl_croak(aTHX_ "Usage: forcedoorclose(doorid [, altmode=0])"); +// +// if (items == 1) +// { +// uint32 did = (int)SvIV(ST(0)); +// +// quest_manager.forcedoorclose(did, false); +// +// XSRETURN_EMPTY; +// } +// else +// { +// uint32 did = (int)SvIV(ST(0)); +// bool am = (int)SvIV(ST(1)) == 0?false:true; +// +// quest_manager.forcedoorclose(did, am); +// +// XSRETURN_EMPTY; +// } +//} +// +//XS(XS__toggledoorstate); +//XS(XS__toggledoorstate) +//{ +// dXSARGS; +// if (items !=1) +// Perl_croak(aTHX_ "Usage: toggledoorstate(doorid)"); +// +// uint32 did = (int)SvIV(ST(0)); +// +// quest_manager.toggledoorstate(did); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__isdooropen); +//XS(XS__isdooropen) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: isdooropen(doorid)"); +// +// bool RETVAL; +// dXSTARG; +// +// uint32 doorid = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.isdooropen(doorid); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__depopzone); +//XS(XS__depopzone) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: depopzone(StartSpawnStatus)"); +// +// bool StartSpawnStatus = ((int)SvIV(ST(0))) == 0?false:true; +// +// quest_manager.depopzone(StartSpawnStatus); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__repopzone); +//XS(XS__repopzone) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: repopzone()"); +// +// quest_manager.repopzone(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__npcrace); +//XS(XS__npcrace) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: npcrace(race_id)"); +// +// int race_id = (int)SvIV(ST(0)); +// +// quest_manager.npcrace(race_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__npcgender); +//XS(XS__npcgender) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: npcgender(gender_id)"); +// +// int gender_id= (int)SvIV(ST(0)); +// +// quest_manager.npcgender(gender_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__npcsize); +//XS(XS__npcsize) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: npcsize(newsize)"); +// +// int newsize = (int)SvIV(ST(0)); +// +// quest_manager.npcsize(newsize); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__npctexture); +//XS(XS__npctexture) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: npctexture(newtexture)"); +// +// int newtexture = (int)SvIV(ST(0)); +// +// quest_manager.npctexture(newtexture); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__playerrace); +//XS(XS__playerrace) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: playerrace(race_id)"); +// +// int race_id = (int)SvIV(ST(0)); +// +// quest_manager.playerrace(race_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__playergender); +//XS(XS__playergender) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: playergender(gender_id)"); +// +// int gender_id= (int)SvIV(ST(0)); +// +// quest_manager.playergender(gender_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__playersize); +//XS(XS__playersize) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: playersize(newsize)"); +// +// int newsize = (int)SvIV(ST(0)); +// +// quest_manager.playersize(newsize); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__playertexture); +//XS(XS__playertexture) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: playertexture(newtexture)"); +// +// int newtexture = (int)SvIV(ST(0)); +// +// quest_manager.playertexture(newtexture); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__playerfeature); +//XS(XS__playerfeature) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: playerfeature(feature, setting)"); +// +// char * feature = (char *)SvPV_nolen(ST(0)); +// int setting = (int)SvIV(ST(1)); +// +// quest_manager.playerfeature(feature, setting); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__npcfeature); +//XS(XS__npcfeature) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: npcfeature(feature, setting)"); +// +// char * feature = (char *)SvPV_nolen(ST(0)); +// int setting = (int)SvIV(ST(1)); +// +// quest_manager.npcfeature(feature, setting); +// +// XSRETURN_EMPTY; +//} +// +//#ifdef BOTS +// +//XS(XS__createbotcount); +//XS(XS__createbotcount) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// RETVAL = quest_manager.createbotcount(); +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__spawnbotcount); +//XS(XS__spawnbotcount) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// RETVAL = quest_manager.spawnbotcount(); +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__botquest); +//XS(XS__botquest) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// RETVAL = quest_manager.botquest(); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__createBot); +//XS(XS__createBot) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// if(items != 6) +// { +// Perl_croak(aTHX_ "Usage: createBot(firstname, lastname, level, race, class, gender)"); +// } +// +// char *firstname = (char *)SvPV_nolen(ST(0)); +// char *lastname = (char *)SvPV_nolen(ST(1)); +// int level = (int) SvIV(ST(2)); +// int race = (int) SvIV(ST(3)); +// int botclass = (int) SvIV(ST(4)); +// int gender = (int) SvIV(ST(5)); +// +// RETVAL = quest_manager.createBot(firstname, lastname, level, race, botclass, gender); +// XSprePUSH; PUSHu((IV)RETVAL); +// XSRETURN(1); +//} +// +//#endif //BOTS +// +//XS(XS__taskselector); +//XS(XS__taskselector) +//{ +// dXSARGS; +// if((items >= 1) && (items <=MAXCHOOSERENTRIES)) { +// int tasks[MAXCHOOSERENTRIES]; +// for(int i=0; i< items; i++) { +// tasks[i] = (int)SvIV(ST(i)); +// } +// quest_manager.taskselector(items, tasks); +// } else { +// Perl_croak(aTHX_ "Usage: taskselector(taskid1, taskid2, ..., taskid%i)", MAXCHOOSERENTRIES); +// } +// +// XSRETURN_EMPTY; +//} +//XS(XS__tasksetselector); +//XS(XS__tasksetselector) +//{ +// dXSARGS; +// if(items == 1) { +// int tasksetid = (int)SvIV(ST(0)); +// quest_manager.tasksetselector(tasksetid); +// } else { +// Perl_croak(aTHX_ "Usage: tasksetselector(tasksetid)"); +// } +// +// XSRETURN_EMPTY; +//} +//XS(XS__enabletask); +//XS(XS__enabletask) +//{ +// dXSARGS; +// if((items >= 1) && (items <=10)) { +// int tasks[10]; +// for(int i=0; i< items; i++) { +// tasks[i] = (int)SvIV(ST(i)); +// } +// quest_manager.enabletask(items, tasks); +// } else { +// Perl_croak(aTHX_ "Usage: enabletask(taskid1, taskid2, ..., taskid10"); +// } +// +// XSRETURN_EMPTY; +//} +//XS(XS__disabletask); +//XS(XS__disabletask) +//{ +// dXSARGS; +// if((items >= 1) && (items <=10)) { +// int tasks[10]; +// for(int i=0; i< items; i++) { +// tasks[i] = (int)SvIV(ST(i)); +// } +// quest_manager.disabletask(items, tasks); +// } else { +// Perl_croak(aTHX_ "Usage: disabletask(taskid1, taskid2, ..., taskid10"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__istaskenabled); +//XS(XS__istaskenabled) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskid = (int)SvIV(ST(0)); +// RETVAL = quest_manager.istaskenabled(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: istaskenabled(taskid)"); +// } +// +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +//XS(XS__istaskactive); +//XS(XS__istaskactive) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int task = (int)SvIV(ST(0)); +// RETVAL = quest_manager.istaskactive(task); +// } else { +// Perl_croak(aTHX_ "Usage: istaskactive(task)"); +// } +// +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +//XS(XS__istaskactivityactive); +//XS(XS__istaskactivityactive) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// if(items == 2) { +// unsigned int task = (int)SvIV(ST(0)); +// unsigned int activity = (int)SvIV(ST(1)); +// RETVAL = quest_manager.istaskactivityactive(task, activity); +// } else { +// Perl_croak(aTHX_ "Usage: istaskactivityactive(task,activity)"); +// } +// +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +//XS(XS__gettaskactivitydonecount); +//XS(XS__gettaskactivitydonecount) +//{ +// dXSARGS; +// uint32 RETVAL; +// dXSTARG; +// +// if(items == 2) { +// unsigned int task = (int)SvIV(ST(0)); +// unsigned int activity = (int)SvIV(ST(1)); +// RETVAL = quest_manager.gettaskactivitydonecount(task, activity); +// XSprePUSH; PUSHu((UV)RETVAL); +// } else { +// Perl_croak(aTHX_ "Usage: gettaskactivitydonecount(task,activity)"); +// } +// +// XSRETURN(1); +//} +//XS(XS__updatetaskactivity); +//XS(XS__updatetaskactivity) +//{ +// dXSARGS; +// unsigned int task, activity; +// int count = 1; +// if(items == 2) { +// task = (int)SvIV(ST(0)); +// activity = (int)SvIV(ST(1)); +// quest_manager.updatetaskactivity(task, activity, count); +// } +// else if(items == 3) { +// task = (int)SvIV(ST(0)); +// activity = (int)SvIV(ST(1)); +// count = (int)SvIV(ST(2)); +// quest_manager.updatetaskactivity(task, activity, count); +// } else { +// Perl_croak(aTHX_ "Usage: updatetaskactivity(task, activity [,count])"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__resettaskactivity); +//XS(XS__resettaskactivity) +//{ +// dXSARGS; +// unsigned int task, activity; +// if(items == 2) { +// task = (int)SvIV(ST(0)); +// activity = (int)SvIV(ST(1)); +// quest_manager.resettaskactivity(task, activity); +// } else { +// Perl_croak(aTHX_ "Usage: resettaskactivity(task, activity)"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__taskexploredarea); +//XS(XS__taskexploredarea) +//{ +// dXSARGS; +// unsigned int exploreid; +// if(items == 1) { +// exploreid = (int)SvIV(ST(0)); +// quest_manager.taskexploredarea(exploreid); +// } else { +// Perl_croak(aTHX_ "Usage: taskexplorearea(exploreid)"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__assigntask); +//XS(XS__assigntask) +//{ +// dXSARGS; +// unsigned int taskid; +// if(items == 1) { +// taskid = (int)SvIV(ST(0)); +// quest_manager.assigntask(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: assigntask(taskid)"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__failtask); +//XS(XS__failtask) +//{ +// dXSARGS; +// unsigned int taskid; +// if(items == 1) { +// taskid = (int)SvIV(ST(0)); +// quest_manager.failtask(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: failtask(taskid)"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__tasktimeleft); +//XS(XS__tasktimeleft) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskid = (int)SvIV(ST(0)); +// RETVAL = quest_manager.tasktimeleft(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: tasktimeleft(taskid)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__istaskcompleted); +//XS(XS__istaskcompleted) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskid = (int)SvIV(ST(0)); +// RETVAL = quest_manager.istaskcompleted(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: istaskcompleted(taskid)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__enabledtaskcount); +//XS(XS__enabledtaskcount) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskset = (int)SvIV(ST(0)); +// RETVAL = quest_manager.enabledtaskcount(taskset); +// } else { +// Perl_croak(aTHX_ "Usage: enabledtaskcount(taskset)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__firsttaskinset); +//XS(XS__firsttaskinset) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskset = (int)SvIV(ST(0)); +// RETVAL = quest_manager.firsttaskinset(taskset); +// } else { +// Perl_croak(aTHX_ "Usage: firsttaskinset(taskset)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__lasttaskinset); +//XS(XS__lasttaskinset) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskset = (int)SvIV(ST(0)); +// RETVAL = quest_manager.lasttaskinset(taskset); +// } else { +// Perl_croak(aTHX_ "Usage: lasttaskinset(taskset)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__nexttaskinset); +//XS(XS__nexttaskinset) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 2) { +// unsigned int taskset = (int)SvIV(ST(0)); +// unsigned int taskid = (int)SvIV(ST(1)); +// RETVAL = quest_manager.nexttaskinset(taskset, taskid); +// } else { +// Perl_croak(aTHX_ "Usage: nexttaskinset(taskset, taskid)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +//XS(XS__activespeaktask); +//XS(XS__activespeaktask) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 0) { +// RETVAL = quest_manager.activespeaktask(); +// } else { +// Perl_croak(aTHX_ "Usage: activespeaktask()"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__activespeakactivity); +//XS(XS__activespeakactivity) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskid = (int)SvIV(ST(0)); +// RETVAL = quest_manager.activespeakactivity(taskid); +// } else { +// Perl_croak(aTHX_ "Usage: activespeakactivity(taskid)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__activetasksinset); +//XS(XS__activetasksinset) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskset = (int)SvIV(ST(0)); +// RETVAL = quest_manager.activetasksinset(taskset); +// } else { +// Perl_croak(aTHX_ "Usage: activetasksinset(taskset)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__completedtasksinset); +//XS(XS__completedtasksinset) +//{ +// dXSARGS; +// int RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int taskset = (int)SvIV(ST(0)); +// RETVAL = quest_manager.completedtasksinset(taskset); +// } else { +// Perl_croak(aTHX_ "Usage: completedtasksinset(taskset)"); +// } +// +// XSprePUSH; PUSHi((IV)RETVAL); +// +// XSRETURN(1); +//} +// +// +//XS(XS__istaskappropriate); +//XS(XS__istaskappropriate) +//{ +// dXSARGS; +// bool RETVAL; +// dXSTARG; +// +// if(items == 1) { +// unsigned int task = (int)SvIV(ST(0)); +// RETVAL = quest_manager.istaskappropriate(task); +// } else { +// Perl_croak(aTHX_ "Usage: istaskaappropriate(task)"); +// } +// +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +// XS(XS__popup); // prototype to pass -Wmissing-prototypes +// XS(XS__popup) { +// dXSARGS; +// int popupid = 0; +// int buttons = 0; +// int duration = 0; +// +// if((items < 2) || (items > 5)) +// Perl_croak(aTHX_ "Usage: popup(windowtitle, text, popupid, buttons, duration)"); +// +// if(items >= 3) +// popupid = (int)SvIV(ST(2)); +// +// if(items >= 4) +// buttons = (int)SvIV(ST(3)); +// +// if(items == 5) +// duration = (int)SvIV(ST(4)); +// +// quest_manager.popup(SvPV_nolen(ST(0)), SvPV_nolen(ST(1)), popupid, buttons, duration); +// +// XSRETURN_EMPTY; +// } +//XS(XS__clearspawntimers); +//XS(XS__clearspawntimers) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: clearspawntimers()"); +// +// quest_manager.clearspawntimers(); +// +// XSRETURN_EMPTY; +//} +//XS(XS__ze); +//XS(XS__ze) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: ze(type, str)"); +// +// int type = (int)SvIV(ST(0)); +// char * str = (char *)SvPV_nolen(ST(1)); +// +// quest_manager.ze(type, str); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__we); +//XS(XS__we) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: we(type, str)"); +// +// int type = (int)SvIV(ST(0)); +// char * str = (char *)SvPV_nolen(ST(1)); +// +// quest_manager.we(type, str); +// +// XSRETURN_EMPTY; +//} +//XS(XS__getlevel); +//XS(XS__getlevel) +//{ +// dXSARGS; +// if (items > 1) +// Perl_croak(aTHX_ "Usage: getlevel(type)"); +// +// int RETVAL; +// dXSTARG; +// +// int type; +// if (items == 1) +// type = (int)SvIV(ST(0)); +// else +// type = 0; +// +// RETVAL = quest_manager.getlevel(type); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__CreateGroundObject); +//XS(XS__CreateGroundObject) +//{ +// dXSARGS; +// if (items != 5 && items != 6) +// Perl_croak(aTHX_ "Usage: creategroundobject(itemid, x, y, z, heading, [decay_time])"); +// +// int itemid = (int)SvIV(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// float heading = (float)SvNV(ST(4)); +// uint16 id = 0; +// +// if(items == 5) +// id = quest_manager.CreateGroundObject(itemid, x, y, z, heading); +// else{ +// uint32 decay_time = (uint32)SvIV(ST(5)); +// id = quest_manager.CreateGroundObject(itemid, x, y, z, heading, decay_time); +// } +// +// XSRETURN_IV(id); +//} +// +//XS(XS__CreateGroundObjectFromModel); +//XS(XS__CreateGroundObjectFromModel) +//{ +// dXSARGS; +// if (items < 5 || items > 7) +// Perl_croak(aTHX_ "Usage: creategroundobjectfrommodel(modelname, x, y, z, heading, [type], [decay_time])"); +// +// char * modelname = (char *)SvPV_nolen(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// float heading = (float)SvNV(ST(4)); +// uint32 type = 0; +// uint32 decay_time = 0; +// uint16 id = 0; +// +// if (items > 5) +// type = (uint32)SvIV(ST(5)); +// +// if (items > 6) +// decay_time = (uint32)SvIV(ST(6)); +// +// id = quest_manager.CreateGroundObjectFromModel(modelname, x, y, z, heading, type, decay_time); +// XSRETURN_IV(id); +//} +// +//XS(XS__CreateDoor); +//XS(XS__CreateDoor) +//{ +// dXSARGS; +// if (items < 5 || items > 7) +// Perl_croak(aTHX_ "Usage: createdoor(modelname, x, y, z, heading, [type], [size])"); +// +// char * modelname = (char *)SvPV_nolen(ST(0)); +// float x = (float)SvNV(ST(1)); +// float y = (float)SvNV(ST(2)); +// float z = (float)SvNV(ST(3)); +// float heading = (float)SvNV(ST(4)); +// uint32 type = 58; +// uint32 size = 100; +// uint16 id = 0; +// +// if (items > 5) +// type = (uint32)SvIV(ST(5)); +// +// if (items > 6) +// size = (uint32)SvIV(ST(6)); +// +// id = quest_manager.CreateDoor(modelname, x, y, z, heading, type, size); +// XSRETURN_IV(id); +//} +// +//XS(XS__ModifyNPCStat); +//XS(XS__ModifyNPCStat) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: ModifyNPCStat(identifier, newValue)"); +// +// quest_manager.ModifyNPCStat(SvPV_nolen(ST(0)), SvPV_nolen(ST(1))); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__collectitems); +//XS(XS__collectitems) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: collectitems(item_id, remove?)"); +// +// uint32 item_id = (int)SvIV(ST(0)); +// bool remove = ((int)SvIV(ST(1))) == 0?false:true; +// +// int quantity = +// quest_manager.collectitems(item_id, remove); +// +// XSRETURN_IV(quantity); +//} +// +//XS(XS__UpdateSpawnTimer); +//XS(XS__UpdateSpawnTimer) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: UpdateSpawnTimer(Spawn2_ID, Updated_Time_Till_Repop)"); +// +// uint32 id = (int)SvIV(ST(0)); +// uint32 duration = (int)SvIV(ST(1)); +// +// quest_manager.UpdateSpawnTimer(id, duration); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__MerchantSetItem); +//XS(XS__MerchantSetItem) { +// dXSARGS; +// if (items != 2 && items != 3) +// Perl_croak(aTHX_ "Usage: MerchantSetItem(NPCid, itemid [, quantity])"); +// +// uint32 NPCid = (int)SvUV(ST(0)); +// uint32 itemid = (int)SvUV(ST(1)); +// uint32 quantity = 0; +// if (items == 3) +// quantity = (int)SvUV(ST(2)); +// +// quest_manager.MerchantSetItem(NPCid, itemid, quantity); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__MerchantCountItem); +//XS(XS__MerchantCountItem) { +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: MerchantCountItem(NPCid, itemid)"); +// +// uint32 NPCid = (int)SvUV(ST(0)); +// uint32 itemid = (int)SvUV(ST(1)); +// uint32 quantity = quest_manager.MerchantCountItem(NPCid, itemid); +// +// XSRETURN_UV(quantity); +//} +// +//XS(XS__varlink); +//XS(XS__varlink) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: varlink(itemID)"); +// dXSTARG; +// +// Const_char * RETVAL; +// char text[250]; +// uint32 itemID; +// itemID = (int)SvUV(ST(0)); +// +// RETVAL = quest_manager.varlink(text, itemID); +// +// sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; +// XSRETURN(1); +//} +// +//XS(XS__CreateInstance); +//XS(XS__CreateInstance) { +// dXSARGS; +// if (items != 3) +// Perl_croak(aTHX_ "Usage: CreateInstance(zone_name, version, duration)"); +// +// char * zone = (char *)SvPV_nolen(ST(0)); +// uint16 version = (int)SvUV(ST(1)); +// uint32 duration = (int)SvUV(ST(2)); +// uint32 id = quest_manager.CreateInstance(zone, version, duration); +// +// XSRETURN_UV(id); +//} +// +//XS(XS__DestroyInstance); +//XS(XS__DestroyInstance) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: DestroyInstance(id)"); +// +// uint16 id = (int)SvUV(ST(0)); +// quest_manager.DestroyInstance(id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__GetInstanceID); +//XS(XS__GetInstanceID) { +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: GetInstanceID(zone_name, version)"); +// +// char * zone = (char *)SvPV_nolen(ST(0)); +// uint16 version = (int)SvUV(ST(1)); +// uint16 id = quest_manager.GetInstanceID(zone, version); +// +// XSRETURN_UV(id); +//} +// +//XS(XS__AssignToInstance); +//XS(XS__AssignToInstance) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: AssignToInstance(id)"); +// +// uint16 id = (int)SvUV(ST(0)); +// quest_manager.AssignToInstance(id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__AssignGroupToInstance); +//XS(XS__AssignGroupToInstance) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: AssignGroupToInstance(id)"); +// +// uint16 id = (int)SvUV(ST(0)); +// quest_manager.AssignGroupToInstance(id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__AssignRaidToInstance); +//XS(XS__AssignRaidToInstance) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: AssignRaidToInstance(id)"); +// +// uint16 id = (int)SvUV(ST(0)); +// quest_manager.AssignRaidToInstance(id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__MovePCInstance); +//XS(XS__MovePCInstance) +//{ +// dXSARGS; +// if (items != 5 && items != 6) +// Perl_croak(aTHX_ "Usage: MovePCInstance(zone_id, instance_id, x, y, z [,heading])"); +// +// int zoneid = (int)SvIV(ST(0)); +// int instanceid = (int)SvIV(ST(1)); +// float x = (float)SvNV(ST(2)); +// float y = (float)SvNV(ST(3)); +// float z = (float)SvNV(ST(4)); +// +// if (items == 4) +// { +// quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, 0.0f); +// } +// else +// { +// float heading = (float)SvNV(ST(5)); +// quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, heading); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__FlagInstanceByGroupLeader); +//XS(XS__FlagInstanceByGroupLeader) { +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: FlagInstanceByGroupLeader(zone, version)"); +// +// uint32 zone = (int)SvUV(ST(0)); +// uint16 version = (int)SvUV(ST(1)); +// quest_manager.FlagInstanceByGroupLeader(zone, version); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__FlagInstanceByRaidLeader); +//XS(XS__FlagInstanceByRaidLeader) { +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: FlagInstanceByRaidLeader(zone, version)"); +// +// uint32 zone = (int)SvUV(ST(0)); +// uint16 version = (int)SvUV(ST(1)); +// quest_manager.FlagInstanceByRaidLeader(zone, version); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__saylink); +//XS(XS__saylink) { +// dXSARGS; +// if (items < 1 || items > 3) +// Perl_croak(aTHX_ "Usage: saylink(phrase,[silent?],[linkname])"); +// dXSTARG; +// +// Const_char * RETVAL; +// char text[250]; +// char text2[250]; +// bool silent = false; +// strcpy(text,(char *)SvPV_nolen(ST(0))); +// if(items >= 2) { +// silent = ((int)SvIV(ST(1))) == 0 ? false : true; +// } +// if (items == 3) +// strcpy(text2,(char *)SvPV_nolen(ST(2))); +// else +// strcpy(text2,text); +// +// RETVAL = quest_manager.saylink(text, silent, text2); +// sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; +// XSRETURN(1); +//} +// +//XS(XS__getguildnamebyid); +//XS(XS__getguildnamebyid) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: getguildnamebyid(guild_id)"); +// dXSTARG; +// +// Const_char * RETVAL; +// uint32 guild_id = (int)SvUV(ST(0)); +// +// RETVAL = quest_manager.getguildnamebyid(guild_id); +// +// sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; +// XSRETURN(1); +//} +// +//XS(XS__SetRunning); +//XS(XS__SetRunning) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: SetRunning(val)"); +// +// bool val = ((int)SvIV(ST(0))) == 0?false:true; +// +// quest_manager.SetRunning(val); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__IsRunning); +//XS(XS__IsRunning) +//{ +// dXSARGS; +// if (items >= 1) +// Perl_croak(aTHX_ "Usage: IsRunning()"); +// +// bool RETVAL; +// dXSTARG; +// +// +// RETVAL = quest_manager.IsRunning(); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__IsEffectInSpell); +//XS(XS__IsEffectInSpell) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: IsEffectInSpell(spell_id, effect_id)"); +// +// uint32 spell_id = (uint32)SvUV(ST(0)); +// uint32 effect_id = (uint32)SvUV(ST(1)); +// bool RETVAL; +// dXSTARG; +// +// +// RETVAL = IsEffectInSpell(spell_id, effect_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__IsBeneficialSpell); +//XS(XS__IsBeneficialSpell) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: IsBeneficialSpell(spell_id)"); +// +// uint32 spell_id = (uint32)SvUV(ST(0)); +// bool RETVAL; +// dXSTARG; +// +// +// RETVAL = BeneficialSpell(spell_id); +// XSprePUSH; PUSHu((IV)RETVAL); +// +// XSRETURN(1); +//} +// +//XS(XS__GetSpellResistType); +//XS(XS__GetSpellResistType) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: GetSpellResistType(spell_id)"); +// +// uint32 spell_id = (uint32)SvUV(ST(0)); +// int32 spell_val = 0; +// dXSTARG; +// +// spell_val = GetSpellResistType(spell_id); +// XSRETURN_UV(spell_val); +//} +// +//XS(XS__GetSpellTargetType); +//XS(XS__GetSpellTargetType) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: GetSpellTargetType(spell_id)"); +// +// uint32 spell_id = (uint32)SvUV(ST(0)); +// int32 spell_val = 0; +// dXSTARG; +// +// spell_val = GetSpellTargetType(spell_id); +// XSRETURN_UV(spell_val); +//} +// +//XS(XS__FlyMode); +//XS(XS__FlyMode) { +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: FlyMode([0/1/2])"); +// +// uint8 flymode = (int)SvUV(ST(0)); +// quest_manager.FlyMode(flymode); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS_FactionValue); +//XS(XS_FactionValue) { +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: factionvalue()"); +// +// uint8 fac = quest_manager.FactionValue(); +// XSRETURN_UV(fac); +//} +// +//XS(XS__enabletitle); +//XS(XS__enabletitle) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: enabletitle(titleset)"); +// +// int titleset = (int)SvIV(ST(0)); +// +// quest_manager.enabletitle(titleset); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__checktitle); +//XS(XS__checktitle) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: checktitle(titleset)"); +// +// bool RETVAL; +// int titleset = (int)SvIV(ST(0)); +// +// RETVAL = quest_manager.checktitle(titleset); +// +// ST(0) = boolSV(RETVAL); +// sv_2mortal(ST(0)); +// XSRETURN(1); +//} +// +//XS(XS__removetitle); +//XS(XS__removetitle) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: removetitle(titleset)"); +// +// int titleset = (int)SvIV(ST(0)); +// +// quest_manager.removetitle(titleset); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__wearchange); +//XS(XS__wearchange) +//{ +// dXSARGS; +// if (items != 2) +// Perl_croak(aTHX_ "Usage: wearchange(slot, texture)"); +// +// uint8 slot = (int)SvUV(ST(0)); +// uint16 texture = (int)SvUV(ST(1)); +// +// quest_manager.wearchange(slot, texture); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__voicetell); +//XS(XS__voicetell) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: voicetell(clientname, type, race, gender)"); +// +// char * str = (char *)SvPV_nolen(ST(0)); +// int macronum = (int)SvIV(ST(1)); +// int racenum = (int)SvIV(ST(2)); +// int gendernum = (int)SvIV(ST(3)); +// +// quest_manager.voicetell(str, macronum, racenum, gendernum); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__LearnRecipe); +//XS(XS__LearnRecipe) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: LearnRecipe(recipe_id)"); +// +// uint32 recipe_id = (uint32)SvIV(ST(0)); +// +// quest_manager.LearnRecipe(recipe_id); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__SendMail); +//XS(XS__SendMail) +//{ +// dXSARGS; +// if (items != 4) +// Perl_croak(aTHX_ "Usage: SendMail(to, from, subject, message)"); +// +// char *to = (char *)SvPV_nolen(ST(0)); +// char *from = (char *)SvPV_nolen(ST(1)); +// char *subject = (char *)SvPV_nolen(ST(2)); +// char *message = (char *)SvPV_nolen(ST(3)); +// +// quest_manager.SendMail(to, from, subject, message); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__GetZoneID); +//XS(XS__GetZoneID) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: GetZoneID(zone)"); +// +// char *zone = (char *)SvPV_nolen(ST(0)); +// int32 id = quest_manager.GetZoneID(zone); +// +// XSRETURN_IV(id); +//} +// +//XS(XS__GetZoneLongName); +//XS(XS__GetZoneLongName) +//{ +// dXSARGS; +// if (items != 1) +// Perl_croak(aTHX_ "Usage: GetZoneLongName(zone)"); +// dXSTARG; +// char *zone = (char *)SvPV_nolen(ST(0)); +// Const_char* RETVAL = quest_manager.GetZoneLongName(zone); +// +// sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; +// XSRETURN(1); +//} +// +//XS(XS__GetTimeSeconds); +//XS(XS__GetTimeSeconds) +//{ +// dXSARGS; +// if (items != 0) +// Perl_croak(aTHX_ "Usage: GetTimeSeconds()"); +// +// uint32 seconds = 0; +// dXSTARG; +// +// seconds = Timer::GetTimeSeconds(); +// XSRETURN_UV(seconds); +//} +// +//XS(XS__handleturnin); // prototype to pass -Wmissing-prototypes +//XS(XS__handleturnin) { +// dXSARGS; +// +// if (items != 2) +// Perl_croak(aTHX_ "Usage: handleturnin(itemid, itemcharges)"); +// int itemid = (int)SvIV(ST(0)); +// int charges = (int)SvIV(ST(1)); +// +// bool returnVal = quest_manager.TurnInItem(itemid,charges); +// +// ST(0) = boolSV(returnVal); +// sv_2mortal(ST(0)); +// XSRETURN(1); +//} +// +//XS(XS__completehandin); // prototype to pass -Wmissing-prototypes +//XS(XS__completehandin) { +// dXSARGS; +// +// if (items != 0) +// Perl_croak(aTHX_ "Usage: completehandin()"); +// +// quest_manager.CompleteHandIn(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__resethandin); // prototype to pass -Wmissing-prototypes +//XS(XS__resethandin) { +// dXSARGS; +// +// if (items != 0) +// Perl_croak(aTHX_ "Usage: resethandin()"); +// +// quest_manager.ResetHandIn(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__clearhandin); // prototype to pass -Wmissing-prototypes +//XS(XS__clearhandin) { +// dXSARGS; +// +// if (items != 0) +// Perl_croak(aTHX_ "Usage: clearhandin()"); +// +// quest_manager.ClearHandIn(); +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__crosszonesignalclientbycharid); +//XS(XS__crosszonesignalclientbycharid) +//{ +// dXSARGS; +// +// if (items != 2) +// Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(char_id, data)"); +// +// if (items == 2) { +// int char_id = (int)SvIV(ST(0)); +// uint32 data = (uint32)SvIV(ST(1)); +// quest_manager.CrossZoneSignalPlayerByCharID(char_id, data); +// } else { +// Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(char_id, data)"); +// } +// +// XSRETURN_EMPTY; +//} +// +//XS(XS__crosszonesignalclientbyname); +//XS(XS__crosszonesignalclientbyname) +//{ +// dXSARGS; +// +// if (items != 2) +// Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(Name, data)"); +// +// if (items == 2) { +// char *Name = (char *)SvPV_nolen(ST(0)); +// uint32 data = (uint32)SvIV(ST(1)); +// quest_manager.CrossZoneSignalPlayerByName(Name, data); +// } else { +// Perl_croak(aTHX_ "Usage: crosszonesignalclientbycharid(Name, data)"); +// } +// +// XSRETURN_EMPTY; +//} +// +// +//XS(XS__crosszonemessageplayerbyname); +//XS(XS__crosszonemessageplayerbyname) +//{ +// dXSARGS; +// +// if (items != 3) +// Perl_croak(aTHX_ "Usage: crosszonemessageplayerbyname(Type, Name, Message)"); +// +// if (items == 3) { +// uint32 Type = (uint32)SvIV(ST(0)); +// char *Name = (char *)SvPV_nolen(ST(1)); +// char *Message = (char *)SvPV_nolen(ST(2)); +// quest_manager.CrossZoneMessagePlayerByName(Type, Name, Message); +// } else { +// Perl_croak(aTHX_ "Usage: crosszonemessageplayerbyname(Type, Name, Message)"); +// } +// +// XSRETURN_EMPTY; +//} +// +///* +//This is the callback perl will look for to setup the +//quest package's XSUBs +//*/ +//EXTERN_C XS(boot_quest); // prototype to pass -Wmissing-prototypes +//EXTERN_C XS(boot_quest) +//{ +// dXSARGS; +// char file[256]; +// strncpy(file, __FILE__, 256); +// file[255] = '\0'; +// +// if(items != 1) +// LogFile->write(EQEMuLog::Error, "boot_quest does not take any arguments."); +// +// char buf[128]; //shouldent have any function names longer than this. +// +// //add the strcpy stuff to get rid of const warnings.... +// +// XS_VERSION_BOOTCHECK ; +// newXS(strcpy(buf, "echo"), XS__echo, file); +// newXS(strcpy(buf, "say"), XS__say, file); +// newXS(strcpy(buf, "me"), XS__me, file); +// newXS(strcpy(buf, "summonitem"), XS__summonitem, file); +// newXS(strcpy(buf, "write"), XS__write, file); +// newXS(strcpy(buf, "spawn"), XS__spawn, file); +// newXS(strcpy(buf, "spawn2"), XS__spawn2, file); +// newXS(strcpy(buf, "unique_spawn"), XS__unique_spawn, file); +// newXS(strcpy(buf, "spawn_from_spawn2"), XS__spawn_from_spawn2, file); +// newXS(strcpy(buf, "enable_spawn2"), XS__enable_spawn2, file); +// newXS(strcpy(buf, "disable_spawn2"), XS__disable_spawn2, file); +// newXS(strcpy(buf, "setstat"), XS__setstat, file); +// newXS(strcpy(buf, "incstat"), XS__incstat, file); +// newXS(strcpy(buf, "castspell"), XS__castspell, file); +// newXS(strcpy(buf, "selfcast"), XS__selfcast, file); +// newXS(strcpy(buf, "addloot"), XS__addloot, file); +// newXS(strcpy(buf, "zone"), XS__zone, file); +// newXS(strcpy(buf, "settimer"), XS__settimer, file); +// newXS(strcpy(buf, "settimerMS"), XS__settimerMS, file); +// newXS(strcpy(buf, "stoptimer"), XS__stoptimer, file); +// newXS(strcpy(buf, "stopalltimers"), XS__stopalltimers, file); +// newXS(strcpy(buf, "emote"), XS__emote, file); +// newXS(strcpy(buf, "shout"), XS__shout, file); +// newXS(strcpy(buf, "shout2"), XS__shout2, file); +// newXS(strcpy(buf, "gmsay"), XS__gmsay, file); +// newXS(strcpy(buf, "depop"), XS__depop, file); +// newXS(strcpy(buf, "depop_withtimer"), XS__depop_withtimer, file); +// newXS(strcpy(buf, "settarget"), XS__settarget, file); +// newXS(strcpy(buf, "follow"), XS__follow, file); +// newXS(strcpy(buf, "sfollow"), XS__sfollow, file); +// newXS(strcpy(buf, "changedeity"), XS__changedeity, file); +// newXS(strcpy(buf, "exp"), XS__exp, file); +// newXS(strcpy(buf, "level"), XS__level, file); +// newXS(strcpy(buf, "traindisc"), XS__traindisc, file); +// newXS(strcpy(buf, "isdisctome"), XS__isdisctome, file); +// newXS(strcpy(buf, "safemove"), XS__safemove, file); +// newXS(strcpy(buf, "rain"), XS__rain, file); +// newXS(strcpy(buf, "snow"), XS__snow, file); +// newXS(strcpy(buf, "surname"), XS__surname, file); +// newXS(strcpy(buf, "permaclass"), XS__permaclass, file); +// newXS(strcpy(buf, "permarace"), XS__permarace, file); +// newXS(strcpy(buf, "permagender"), XS__permagender, file); +// newXS(strcpy(buf, "scribespells"), XS__scribespells, file); +// newXS(strcpy(buf, "traindiscs"), XS__traindiscs, file); +// newXS(strcpy(buf, "unscribespells"), XS__unscribespells, file); +// newXS(strcpy(buf, "untraindiscs"), XS__untraindiscs, file); +// newXS(strcpy(buf, "givecash"), XS__givecash, file); +// newXS(strcpy(buf, "pvp"), XS__pvp, file); +// newXS(strcpy(buf, "movepc"), XS__movepc, file); +// newXS(strcpy(buf, "gmmove"), XS__gmmove, file); +// newXS(strcpy(buf, "movegrp"), XS__movegrp, file); +// newXS(strcpy(buf, "doanim"), XS__doanim, file); +// newXS(strcpy(buf, "addskill"), XS__addskill, file); +// newXS(strcpy(buf, "setlanguage"), XS__setlanguage, file); +// newXS(strcpy(buf, "setskill"), XS__setskill, file); +// newXS(strcpy(buf, "setallskill"), XS__setallskill, file); +// newXS(strcpy(buf, "attack"), XS__attack, file); +// newXS(strcpy(buf, "attacknpc"), XS__attacknpc, file); +// newXS(strcpy(buf, "attacknpctype"), XS__attacknpctype, file); +// newXS(strcpy(buf, "save"), XS__save, file); +// newXS(strcpy(buf, "faction"), XS__faction, file); +// newXS(strcpy(buf, "setsky"), XS__setsky, file); +// newXS(strcpy(buf, "setguild"), XS__setguild, file); +// newXS(strcpy(buf, "createguild"), XS__createguild, file); +// newXS(strcpy(buf, "settime"), XS__settime, file); +// newXS(strcpy(buf, "itemlink"), XS__itemlink, file); +// newXS(strcpy(buf, "signal"), XS__signal, file); +// newXS(strcpy(buf, "signalwith"), XS__signalwith, file); +// newXS(strcpy(buf, "setglobal"), XS__setglobal, file); +// newXS(strcpy(buf, "targlobal"), XS__targlobal, file); +// newXS(strcpy(buf, "delglobal"), XS__delglobal, file); +// newXS(strcpy(buf, "ding"), XS__ding, file); +// newXS(strcpy(buf, "rebind"), XS__rebind, file); +// newXS(strcpy(buf, "start"), XS__start, file); +// newXS(strcpy(buf, "stop"), XS__stop, file); +// newXS(strcpy(buf, "pause"), XS__pause, file); +// newXS(strcpy(buf, "moveto"), XS__moveto, file); +// newXS(strcpy(buf, "resume"), XS__resume, file); +// newXS(strcpy(buf, "addldonpoints"), XS__addldonpoints, file); +// newXS(strcpy(buf, "addldonwin"), XS__addldonpoints, file); +// newXS(strcpy(buf, "addldonloss"), XS__addldonpoints, file); +// newXS(strcpy(buf, "setnexthpevent"), XS__setnexthpevent, file); +// newXS(strcpy(buf, "setnextinchpevent"), XS__setnextinchpevent, file); +// newXS(strcpy(buf, "sethp"), XS__sethp, file); +// newXS(strcpy(buf, "respawn"), XS__respawn, file); +// newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file); +// newXS(strcpy(buf, "ChooseRandom"), XS__ChooseRandom, file); +// newXS(strcpy(buf, "set_proximity"), XS__set_proximity, file); +// newXS(strcpy(buf, "clear_proximity"), XS__clear_proximity, file); +// newXS(strcpy(buf, "setanim"), XS__setanim, file); +// newXS(strcpy(buf, "showgrid"), XS__showgrid, file); +// newXS(strcpy(buf, "showpath"), XS__showpath, file); +// newXS(strcpy(buf, "pathto"), XS__pathto, file); +// newXS(strcpy(buf, "spawn_condition"), XS__spawn_condition, file); +// newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file); +// newXS(strcpy(buf, "toggle_spawn_event"), XS__toggle_spawn_event, file); +// newXS(strcpy(buf, "has_zone_flag"), XS__has_zone_flag, file); +// newXS(strcpy(buf, "set_zone_flag"), XS__set_zone_flag, file); +// newXS(strcpy(buf, "clear_zone_flag"), XS__clear_zone_flag, file); +// newXS(strcpy(buf, "summonburriedplayercorpse"), XS__summonburriedplayercorpse, file); +// newXS(strcpy(buf, "summonallplayercorpses"), XS__summonallplayercorpses, file); +// newXS(strcpy(buf, "getplayerburriedcorpsecount"), XS__getplayerburriedcorpsecount, file); +// newXS(strcpy(buf, "buryplayercorpse"), XS__buryplayercorpse, file); +// newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file); +// newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file); +// newXS(strcpy(buf, "toggledoorstate"), XS__toggledoorstate, file); +// newXS(strcpy(buf, "isdooropen"), XS__isdooropen, file); +// newXS(strcpy(buf, "depopall"), XS__depopall, file); +// newXS(strcpy(buf, "depopzone"), XS__depopzone, file); +// newXS(strcpy(buf, "repopzone"), XS__repopzone, file); +// newXS(strcpy(buf, "npcrace"), XS__npcrace, file); +// newXS(strcpy(buf, "npcgender"), XS__npcgender, file); +// newXS(strcpy(buf, "npcsize"), XS__npcsize, file); +// newXS(strcpy(buf, "npctexture"), XS__npctexture, file); +// newXS(strcpy(buf, "playerrace"), XS__playerrace, file); +// newXS(strcpy(buf, "playergender"), XS__playergender, file); +// newXS(strcpy(buf, "playersize"), XS__playersize, file); +// newXS(strcpy(buf, "playertexture"), XS__playertexture, file); +// newXS(strcpy(buf, "playerfeature"), XS__playerfeature, file); +// newXS(strcpy(buf, "npcfeature"), XS__npcfeature, file); +// +//#ifdef BOTS +// newXS(strcpy(buf, "botquest"), XS__botquest, file); +// newXS(strcpy(buf, "spawnbotcount"), XS__spawnbotcount, file); +// newXS(strcpy(buf, "createbotcount"), XS__createbotcount, file); +// newXS(strcpy(buf, "createBot"), XS__createBot, file); +//#endif //BOTS +// +// newXS(strcpy(buf, "taskselector"), XS__taskselector, file); +// newXS(strcpy(buf, "tasksetselector"), XS__tasksetselector, file); +// newXS(strcpy(buf, "enabletask"), XS__enabletask, file); +// newXS(strcpy(buf, "disabletask"), XS__disabletask, file); +// newXS(strcpy(buf, "istaskenabled"), XS__istaskenabled, file); +// newXS(strcpy(buf, "istaskactive"), XS__istaskactive, file); +// newXS(strcpy(buf, "istaskactivityactive"), XS__istaskactivityactive, file); +// newXS(strcpy(buf, "gettaskactivitydonecount"), XS__gettaskactivitydonecount, file); +// newXS(strcpy(buf, "updatetaskactivity"), XS__updatetaskactivity, file); +// newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file); +// newXS(strcpy(buf, "taskexploredarea"), XS__taskexploredarea, file); +// newXS(strcpy(buf, "assigntask"), XS__assigntask, file); +// newXS(strcpy(buf, "failtask"), XS__failtask, file); +// newXS(strcpy(buf, "tasktimeleft"), XS__tasktimeleft, file); +// newXS(strcpy(buf, "istaskcompleted"), XS__istaskcompleted, file); +// newXS(strcpy(buf, "enabledtaskcount"), XS__enabledtaskcount, file); +// newXS(strcpy(buf, "firsttaskinset"), XS__firsttaskinset, file); +// newXS(strcpy(buf, "lasttaskinset"), XS__lasttaskinset, file); +// newXS(strcpy(buf, "nexttaskinset"), XS__nexttaskinset, file); +// newXS(strcpy(buf, "activespeaktask"), XS__activespeaktask, file); +// newXS(strcpy(buf, "activespeakactivity"), XS__activespeakactivity, file); +// newXS(strcpy(buf, "activetasksinset"), XS__activetasksinset, file); +// newXS(strcpy(buf, "completedtasksinset"), XS__completedtasksinset, file); +// newXS(strcpy(buf, "istaskappropriate"), XS__istaskappropriate, file); +// newXS(strcpy(buf, "popup"), XS__popup, file); +// newXS(strcpy(buf, "clearspawntimers"), XS__clearspawntimers, file); +// newXS(strcpy(buf, "ze"), XS__ze, file); +// newXS(strcpy(buf, "we"), XS__we, file); +// newXS(strcpy(buf, "getlevel"), XS__getlevel, file); +// newXS(strcpy(buf, "creategroundobject"), XS__CreateGroundObject, file); +// newXS(strcpy(buf, "creategroundobjectfrommodel"), XS__CreateGroundObjectFromModel, file); +// newXS(strcpy(buf, "createdoor"), XS__CreateDoor, file); +// newXS(strcpy(buf, "modifynpcstat"), XS__ModifyNPCStat, file); +// newXS(strcpy(buf, "collectitems"), XS__collectitems, file); +// newXS(strcpy(buf, "updatespawntimer"), XS__UpdateSpawnTimer, file); +// newXS(strcpy(buf, "MerchantSetItem"), XS__MerchantSetItem, file); +// newXS(strcpy(buf, "MerchantCountItem"), XS__MerchantCountItem, file); +// newXS(strcpy(buf, "varlink"), XS__varlink, file); +// newXS(strcpy(buf, "saylink"), XS__saylink, file); +// newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file); +// newXS(strcpy(buf, "CreateInstance"), XS__CreateInstance, file); +// newXS(strcpy(buf, "DestroyInstance"), XS__DestroyInstance, file); +// newXS(strcpy(buf, "GetInstanceID"), XS__GetInstanceID, file); +// newXS(strcpy(buf, "AssignToInstance"), XS__AssignToInstance, file); +// newXS(strcpy(buf, "AssignGroupToInstance"), XS__AssignGroupToInstance, file); +// newXS(strcpy(buf, "AssignRaidToInstance"), XS__AssignRaidToInstance, file); +// newXS(strcpy(buf, "MovePCInstance"), XS__MovePCInstance, file); +// newXS(strcpy(buf, "FlagInstanceByGroupLeader"), XS__FlagInstanceByGroupLeader, file); +// newXS(strcpy(buf, "FlagInstanceByRaidLeader"), XS__FlagInstanceByRaidLeader, file); +// newXS(strcpy(buf, "SetRunning"), XS__SetRunning, file); +// newXS(strcpy(buf, "IsRunning"), XS__IsRunning, file); +// newXS(strcpy(buf, "IsEffectInSpell"), XS__IsEffectInSpell, file); +// newXS(strcpy(buf, "IsBeneficialSpell"), XS__IsBeneficialSpell, file); +// newXS(strcpy(buf, "GetSpellResistType"), XS__GetSpellResistType, file); +// newXS(strcpy(buf, "GetSpellTargetType"), XS__GetSpellTargetType, file); +// newXS(strcpy(buf, "FlyMode"), XS__FlyMode, file); +// newXS(strcpy(buf, "factionvalue"), XS_FactionValue, file); +// newXS(strcpy(buf, "checktitle"), XS__checktitle, file); +// newXS(strcpy(buf, "enabletitle"), XS__enabletitle, file); +// newXS(strcpy(buf, "removetitle"), XS__removetitle, file); +// newXS(strcpy(buf, "wearchange"), XS__wearchange, file); +// newXS(strcpy(buf, "voicetell"), XS__voicetell, file); +// newXS(strcpy(buf, "LearnRecipe"), XS__LearnRecipe, file); +// newXS(strcpy(buf, "SendMail"), XS__SendMail, file); +// newXS(strcpy(buf, "GetZoneID"), XS__GetZoneID, file); +// newXS(strcpy(buf, "GetZoneLongName"), XS__GetZoneLongName, file); +// newXS(strcpy(buf, "GetTimeSeconds"), XS__GetTimeSeconds, file); +// newXS(strcpy(buf, "handleturnin"), XS__handleturnin, file); +// newXS(strcpy(buf, "completehandin"), XS__completehandin, file); +// newXS(strcpy(buf, "resethandin"), XS__resethandin, file); +// newXS(strcpy(buf, "clearhandin"), XS__clearhandin, file); +// newXS(strcpy(buf, "crosszonesignalclientbycharid"), XS__crosszonesignalclientbycharid, file); +// newXS(strcpy(buf, "crosszonesignalclientbyname"), XS__crosszonesignalclientbyname, file); +// newXS(strcpy(buf, "crosszonemessageplayerbyname"), XS__crosszonemessageplayerbyname, file); +// XSRETURN_YES; +//} +// +//#endif +//#endif diff --git a/zone/perlparser.h b/zone/perlparser.h index c0260b82a..2109b9365 100644 --- a/zone/perlparser.h +++ b/zone/perlparser.h @@ -19,28 +19,28 @@ //extends the perl parser to use C methods //instead of the command queue. -#ifndef PERLPARSER_H -#define PERLPARSER_H - -#ifdef EMBPERL -#ifdef EMBPERL_XS - -#include "embparser.h" - -class PerlXSParser : public PerlembParser { -public: - PerlXSParser(); -// ~PerlXSParser(); - - virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); -protected: - void map_funs(); - - SV *_empty_sv; -}; - - -#endif //EMBPERL_XS -#endif //EMBPERL - -#endif //PERLPARSER_H +//#ifndef PERLPARSER_H +//#define PERLPARSER_H +// +//#ifdef EMBPERL +//#ifdef EMBPERL_XS +// +//#include "embparser.h" +// +//class PerlXSParser : public PerlembParser { +//public: +// PerlXSParser(); +//// ~PerlXSParser(); +// +// virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); +//protected: +// void map_funs(); +// +// SV *_empty_sv; +//}; +// +// +//#endif //EMBPERL_XS +//#endif //EMBPERL +// +//#endif //PERLPARSER_H diff --git a/zone/questmgr.h b/zone/questmgr.h index eeec0d759..f97b8abb6 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -77,10 +77,6 @@ public: void settarget(const char *type, int target_id); void follow(int entity_id, int distance); void sfollow(); -// void cumflag(); -// void flagnpc(uint32 flag_num, uint8 flag_value); -// void flagcheck(uint32 flag_to_check, uint32 flag_to_set); -// bool isflagset(int flag_num); void changedeity(int diety_id); void exp(int amt); void level(int newlevel);