mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Quests] Cleanup Quest Parser Logic (#4025)
* [Quests] Cleanup Quest Parser Logic # Notes - Consolidate duplicated code into loops to make it easier to read and easier to add on to. # Images * Update quest_parser_collection.cpp * Push * Push * Update embperl.cpp * Push * Additional cleanup, use File::Exists utility * Range based loops * Update embparser.cpp * Cleanup * Update embparser.cpp --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
parent
9e2afd5571
commit
331e04fbf8
1386
zone/embparser.cpp
1386
zone/embparser.cpp
File diff suppressed because it is too large
Load Diff
268
zone/embparser.h
268
zone/embparser.h
@ -31,13 +31,11 @@ class Mob;
|
||||
class Client;
|
||||
class NPC;
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace EQ {
|
||||
class ItemInstance;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
questUnloaded,
|
||||
questLoaded,
|
||||
questFailedToLoad
|
||||
@ -49,84 +47,91 @@ public:
|
||||
~PerlembParser();
|
||||
|
||||
virtual int EventNPC(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventGlobalNPC(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventPlayer(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventGlobalPlayer(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventItem(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
EQ::ItemInstance *item,
|
||||
Mob *mob,
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
EQ::ItemInstance* item,
|
||||
Mob* mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventSpell(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
Mob* mob,
|
||||
Client *client,
|
||||
Client* client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventGlobalBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual bool HasQuestSub(uint32 npcid, QuestEventID evt);
|
||||
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
||||
virtual bool PlayerHasQuestSub(QuestEventID evt);
|
||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
|
||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
||||
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
||||
virtual bool BotHasQuestSub(QuestEventID evt);
|
||||
virtual bool GlobalBotHasQuestSub(QuestEventID evt);
|
||||
virtual int EventBot(
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual int EventGlobalBot(
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
virtual bool HasQuestSub(uint32 npc_id, QuestEventID event_id);
|
||||
virtual bool HasGlobalQuestSub(QuestEventID event_id);
|
||||
virtual bool PlayerHasQuestSub(QuestEventID event_id);
|
||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID event_id);
|
||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID event_id);
|
||||
virtual bool ItemHasQuestSub(EQ::ItemInstance* inst, QuestEventID event_id);
|
||||
virtual bool BotHasQuestSub(QuestEventID event_id);
|
||||
virtual bool GlobalBotHasQuestSub(QuestEventID event_id);
|
||||
|
||||
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, EQ::ItemInstance *item);
|
||||
virtual void LoadItemScript(std::string filename, EQ::ItemInstance* inst);
|
||||
virtual void LoadSpellScript(std::string filename, uint32 spell_id);
|
||||
virtual void LoadBotScript(std::string filename);
|
||||
virtual void LoadGlobalBotScript(std::string filename);
|
||||
@ -137,120 +142,131 @@ public:
|
||||
virtual uint32 GetIdentifier() { return 0xf8b05c11; }
|
||||
|
||||
private:
|
||||
Embperl *perl;
|
||||
Embperl* perl;
|
||||
|
||||
void ExportHash(const char *pkgprefix, const char *hashname, std::map<std::string, std::string> &vals);
|
||||
void ExportVar(const char *pkgprefix, const char *varname, const char *value);
|
||||
void ExportVar(const char *pkgprefix, const char *varname, int32 value);
|
||||
void ExportVar(const char *pkgprefix, const char *varname, uint32 value);
|
||||
void ExportVar(const char *pkgprefix, const char *varname, float value);
|
||||
void ExportVar(const char* pkgprefix, const char* varname, const char* classname, void* value);
|
||||
void ExportHash(const char* prefix, const char* hash_name, std::map<std::string, std::string>& vals);
|
||||
void ExportVar(const char* prefix, const char* variable_name, const char* value);
|
||||
void ExportVar(const char* prefix, const char* variable_name, int32 value);
|
||||
void ExportVar(const char* prefix, const char* variable_name, uint32 value);
|
||||
void ExportVar(const char* prefix, const char* variable_name, float value);
|
||||
void ExportVar(const char* prefix, const char* variable_name, const char* class_name, void* value);
|
||||
|
||||
int EventCommon(
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
uint32 object_id,
|
||||
const char* data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
Mob* npc_mob,
|
||||
EQ::ItemInstance* inst,
|
||||
const SPDat_Spell_Struct* spell,
|
||||
Mob* mob,
|
||||
uint32 extradata,
|
||||
bool global,
|
||||
std::vector<std::any> *extra_pointers
|
||||
uint32 extra_data,
|
||||
bool is_global,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int SendCommands(
|
||||
const char *pkgprefix,
|
||||
const char *event,
|
||||
const char* prefix,
|
||||
const char* event,
|
||||
uint32 spell_id,
|
||||
Mob* other,
|
||||
Mob* mob,
|
||||
EQ::ItemInstance *item_inst,
|
||||
const SPDat_Spell_Struct *spell
|
||||
EQ::ItemInstance* inst,
|
||||
const SPDat_Spell_Struct* spell
|
||||
);
|
||||
|
||||
void MapFunctions();
|
||||
|
||||
void GetQuestTypes(
|
||||
bool &isPlayerQuest,
|
||||
bool &isGlobalPlayerQuest,
|
||||
bool &isBotQuest,
|
||||
bool &isGlobalBotQuest,
|
||||
bool &isGlobalNPC,
|
||||
bool &isItemQuest,
|
||||
bool &isSpellQuest,
|
||||
bool& is_player_quest,
|
||||
bool& is_global_player_quest,
|
||||
bool& is_bot_quest,
|
||||
bool& is_global_bot_quest,
|
||||
bool& is_global_npc_quest,
|
||||
bool& is_item_quest,
|
||||
bool& is_spell_quest,
|
||||
QuestEventID event,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
Mob* npc_mob,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
bool global
|
||||
bool is_global
|
||||
);
|
||||
|
||||
void GetQuestPackageName(
|
||||
bool &isPlayerQuest,
|
||||
bool &isGlobalPlayerQuest,
|
||||
bool &isBotQuest,
|
||||
bool &isGlobalBotQuest,
|
||||
bool &isGlobalNPC,
|
||||
bool &isItemQuest,
|
||||
bool &isSpellQuest,
|
||||
std::string &package_name,
|
||||
bool& is_player_quest,
|
||||
bool& is_global_player_quest,
|
||||
bool& is_bot_quest,
|
||||
bool& is_global_bot_quest,
|
||||
bool& is_global_npc_quest,
|
||||
bool& is_item_quest,
|
||||
bool& is_spell_quest,
|
||||
std::string& package_name,
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
const char * data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
bool global
|
||||
uint32 object_id,
|
||||
const char* data,
|
||||
Mob* npc_mob,
|
||||
EQ::ItemInstance* inst,
|
||||
bool is_global
|
||||
);
|
||||
void ExportCharID(const std::string &package_name, int &char_id, Mob *npcmob, Mob *mob);
|
||||
|
||||
void ExportCharID(const std::string& package_name, int& char_id, Mob* npc_mob, Mob* mob);
|
||||
|
||||
void ExportQGlobals(
|
||||
bool isPlayerQuest,
|
||||
bool isGlobalPlayerQuest,
|
||||
bool isBotQuest,
|
||||
bool isGlobalBotQuest,
|
||||
bool isGlobalNPC,
|
||||
bool isItemQuest,
|
||||
bool isSpellQuest,
|
||||
std::string &package_name,
|
||||
Mob *npcmob,
|
||||
Mob *mob,
|
||||
bool is_player_quest,
|
||||
bool is_global_player_quest,
|
||||
bool is_bot_quest,
|
||||
bool is_global_bot_quest,
|
||||
bool is_global_npc_quest,
|
||||
bool is_item_quest,
|
||||
bool is_spell_quest,
|
||||
std::string& package_name,
|
||||
Mob* npc_mob,
|
||||
Mob* mob,
|
||||
int char_id
|
||||
);
|
||||
|
||||
void ExportMobVariables(
|
||||
bool isPlayerQuest,
|
||||
bool isGlobalPlayerQuest,
|
||||
bool isBotQuest,
|
||||
bool isGlobalBotQuest,
|
||||
bool isGlobalNPC,
|
||||
bool isItemQuest,
|
||||
bool isSpellQuest,
|
||||
std::string &package_name,
|
||||
Mob *mob,
|
||||
Mob *npcmob
|
||||
);
|
||||
void ExportZoneVariables(std::string &package_name);
|
||||
void ExportItemVariables(std::string &package_name, Mob *mob);
|
||||
void ExportEventVariables(
|
||||
std::string &package_name,
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
const char* data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
bool is_player_quest,
|
||||
bool is_global_player_quest,
|
||||
bool is_bot_quest,
|
||||
bool is_global_bot_quest,
|
||||
bool is_global_npc_quest,
|
||||
bool is_item_quest,
|
||||
bool is_spell_quest,
|
||||
std::string& package_name,
|
||||
Mob* mob,
|
||||
uint32 extradata,
|
||||
std::vector<std::any> *extra_pointers
|
||||
Mob* npc_mob
|
||||
);
|
||||
|
||||
void ExportZoneVariables(std::string& package_name);
|
||||
|
||||
void ExportItemVariables(std::string& package_name, Mob* mob);
|
||||
|
||||
void ExportEventVariables(
|
||||
std::string& package_name,
|
||||
QuestEventID event,
|
||||
uint32 object_id,
|
||||
const char* data,
|
||||
Mob* npc_mob,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
std::map<uint32, PerlQuestStatus> npc_quest_status_;
|
||||
std::map<uint32, PerlQuestStatus> item_quest_status_;
|
||||
std::map<uint32, PerlQuestStatus> spell_quest_status_;
|
||||
|
||||
PerlQuestStatus global_npc_quest_status_;
|
||||
PerlQuestStatus player_quest_status_;
|
||||
PerlQuestStatus global_player_quest_status_;
|
||||
std::map<uint32, PerlQuestStatus> item_quest_status_;
|
||||
std::map<uint32, PerlQuestStatus> spell_quest_status_;
|
||||
PerlQuestStatus bot_quest_status_;
|
||||
PerlQuestStatus global_bot_quest_status_;
|
||||
|
||||
SV* _empty_sv;
|
||||
|
||||
std::map<std::string, std::string> vars_;
|
||||
SV *_empty_sv;
|
||||
std::map<std::string, int> clear_vars_;
|
||||
std::map<std::string, int> clear_vars_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
185
zone/embperl.cpp
185
zone/embperl.cpp
@ -27,16 +27,18 @@ Eglin
|
||||
XS(XS_EQEmuIO_PRINT);
|
||||
#endif //EMBPERL_IO_CAPTURE
|
||||
|
||||
const char *argv_eqemu[] = { "",
|
||||
const char* argv_eqemu[] = {
|
||||
"",
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
"-w", "-W",
|
||||
"-w", "-W",
|
||||
#endif
|
||||
"-e", "0;", nullptr };
|
||||
"-e", "0;", nullptr
|
||||
};
|
||||
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
int argc = 5;
|
||||
int argc = 5;
|
||||
#else
|
||||
int argc = 3;
|
||||
int argc = 3;
|
||||
#endif
|
||||
//so embedded scripts can use xs extensions (ala 'use socket;')
|
||||
EXTERN_C void boot_DynaLoader(pTHX_ CV* cv);
|
||||
@ -46,7 +48,7 @@ EXTERN_C void xs_init(pTHX)
|
||||
strncpy(file, __FILE__, 256);
|
||||
file[255] = '\0';
|
||||
|
||||
char buf[128]; //shouldent have any function names longer than this.
|
||||
char buf[128]; //shouldent have any function names longer than this.
|
||||
|
||||
//add the strcpy stuff to get rid of const warnings....
|
||||
|
||||
@ -58,20 +60,20 @@ EXTERN_C void xs_init(pTHX)
|
||||
|
||||
Embperl::Embperl()
|
||||
{
|
||||
char **argv = (char **)argv_eqemu;
|
||||
char **env = { nullptr };
|
||||
in_use = true; //in case one of these files generates an event
|
||||
char** argv = (char**) argv_eqemu;
|
||||
char** env = { nullptr };
|
||||
PERL_SYS_INIT3(&argc, &argv, &env);
|
||||
DoInit();
|
||||
}
|
||||
|
||||
void Embperl::DoInit() {
|
||||
char **argv = (char **)argv_eqemu;
|
||||
char **env = { nullptr };
|
||||
void Embperl::DoInit()
|
||||
{
|
||||
char** argv = (char**) argv_eqemu;
|
||||
my_perl = perl_alloc();
|
||||
//setup perl...
|
||||
if(!my_perl)
|
||||
if (!my_perl) {
|
||||
throw "Failed to init Perl (perl_alloc)";
|
||||
}
|
||||
PERL_SET_CONTEXT(my_perl);
|
||||
PERL_SET_INTERP(my_perl);
|
||||
PL_perl_destruct_level = 1;
|
||||
@ -80,17 +82,17 @@ void Embperl::DoInit() {
|
||||
perl_run(my_perl);
|
||||
|
||||
//a little routine we use a lot.
|
||||
eval_pv("sub my_eval { eval $_[0];}", TRUE); //dies on error
|
||||
eval_pv("sub my_eval { eval $_[0];}", TRUE); //dies on error
|
||||
|
||||
//ruin the perl exit and command:
|
||||
eval_pv("sub my_exit {}",TRUE);
|
||||
eval_pv("sub my_sleep {}",TRUE);
|
||||
if(gv_stashpv("CORE::GLOBAL", FALSE)) {
|
||||
GV *exitgp = gv_fetchpv("CORE::GLOBAL::exit", TRUE, SVt_PVCV);
|
||||
GvCV_set(exitgp, perl_get_cv("my_exit", TRUE)); //dies on error
|
||||
eval_pv("sub my_exit {}", TRUE);
|
||||
eval_pv("sub my_sleep {}", TRUE);
|
||||
if (gv_stashpv("CORE::GLOBAL", FALSE)) {
|
||||
GV* exitgp = gv_fetchpv("CORE::GLOBAL::exit", TRUE, SVt_PVCV);
|
||||
GvCV_set(exitgp, perl_get_cv("my_exit", TRUE)); //dies on error
|
||||
GvIMPORTED_CV_on(exitgp);
|
||||
GV *sleepgp = gv_fetchpv("CORE::GLOBAL::sleep", TRUE, SVt_PVCV);
|
||||
GvCV_set(sleepgp, perl_get_cv("my_sleep", TRUE)); //dies on error
|
||||
GV* sleepgp = gv_fetchpv("CORE::GLOBAL::sleep", TRUE, SVt_PVCV);
|
||||
GvCV_set(sleepgp, perl_get_cv("my_sleep", TRUE)); //dies on error
|
||||
GvIMPORTED_CV_on(sleepgp);
|
||||
}
|
||||
|
||||
@ -98,8 +100,7 @@ void Embperl::DoInit() {
|
||||
try {
|
||||
init_eval_file();
|
||||
}
|
||||
catch(std::string& e)
|
||||
{
|
||||
catch (std::string& e) {
|
||||
//remember... lasterr() is no good if we crap out here, in construction
|
||||
LogQuests("Perl Error [{}]", e);
|
||||
throw "failed to install eval_file hook";
|
||||
@ -110,69 +111,62 @@ void Embperl::DoInit() {
|
||||
//make a tieable class to capture IO and pass it into EQEMuLog
|
||||
eval_pv(
|
||||
"package EQEmuIO; "
|
||||
"sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '. $me); return($me); } "
|
||||
"sub WRITE { } "
|
||||
//dunno why I need to shift off fmt here, but it dosent like without it
|
||||
"sub PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } "
|
||||
"sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } "
|
||||
"sub DESTROY { my $me = shift; $me->PRINT('Destroying '.$me); } "
|
||||
//this ties us for all packages, just do it in quest since thats kinda 'our' package
|
||||
"package quest;"
|
||||
" if(tied *STDOUT) { untie(*STDOUT); }"
|
||||
" if(tied *STDERR) { untie(*STDERR); }"
|
||||
" tie *STDOUT, 'EQEmuIO';"
|
||||
" tie *STDERR, 'EQEmuIO';"
|
||||
,FALSE);
|
||||
"sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '. $me); return($me); } "
|
||||
"sub WRITE { } "
|
||||
"sub PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } "
|
||||
"sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } "
|
||||
"sub DESTROY { my $me = shift; $me->PRINT('Destroying '.$me); } "
|
||||
"package quest;"
|
||||
" if(tied *STDOUT) { untie(*STDOUT); }"
|
||||
" if(tied *STDERR) { untie(*STDERR); }"
|
||||
" tie *STDOUT, 'EQEmuIO';"
|
||||
" tie *STDERR, 'EQEmuIO';", FALSE);
|
||||
#endif //EMBPERL_IO_CAPTURE
|
||||
|
||||
#ifdef EMBPERL_PLUGIN
|
||||
eval_pv(
|
||||
"package plugin; "
|
||||
,FALSE
|
||||
"package plugin; ", FALSE
|
||||
);
|
||||
|
||||
LogQuests("Loading perlemb plugins");
|
||||
try
|
||||
{
|
||||
try {
|
||||
std::string perl_command;
|
||||
perl_command = "main::eval_file('plugin', '" + Config->PluginPlFile + "');";
|
||||
eval_pv(perl_command.c_str(), FALSE);
|
||||
}
|
||||
catch(std::string& e)
|
||||
{
|
||||
catch (std::string& e) {
|
||||
LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e);
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
//should probably read the directory in c, instead, so that
|
||||
//I can echo filenames as I do it, but c'mon... I'm lazy and this 1 line reads in all the plugins
|
||||
std::string perl_command =
|
||||
"if(opendir(D,'" + path.GetPluginsPath() +"')) { "
|
||||
const std::string& perl_command = (
|
||||
"if(opendir(D,'" +
|
||||
path.GetPluginsPath() +
|
||||
"')) { "
|
||||
" my @d = readdir(D);"
|
||||
" closedir(D);"
|
||||
" foreach(@d){ "
|
||||
" main::eval_file('plugin','" + path.GetPluginsPath() + "/'.$_)if/\\.pl$/;"
|
||||
" main::eval_file('plugin','" +
|
||||
path.GetPluginsPath() +
|
||||
"/'.$_)if/\\.pl$/;"
|
||||
" }"
|
||||
"}";
|
||||
eval_pv(perl_command.c_str(),FALSE);
|
||||
"}");
|
||||
eval_pv(perl_command.c_str(), FALSE);
|
||||
}
|
||||
catch(std::string& e)
|
||||
{
|
||||
catch (std::string& e) {
|
||||
LogQuests("Warning [{}]", e);
|
||||
}
|
||||
#endif //EMBPERL_PLUGIN
|
||||
in_use = false;
|
||||
}
|
||||
|
||||
Embperl::~Embperl()
|
||||
{
|
||||
in_use = true;
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
eval_pv(
|
||||
"package quest;"
|
||||
" if(tied *STDOUT) { untie(*STDOUT); }"
|
||||
" if(tied *STDERR) { untie(*STDERR); }"
|
||||
,FALSE);
|
||||
" if(tied *STDERR) { untie(*STDERR); }", FALSE);
|
||||
#endif
|
||||
PL_perl_destruct_level = 1;
|
||||
perl_destruct(my_perl);
|
||||
@ -181,17 +175,15 @@ Embperl::~Embperl()
|
||||
my_perl = NULL;
|
||||
}
|
||||
|
||||
void Embperl::Reinit() {
|
||||
in_use = true;
|
||||
void Embperl::Reinit()
|
||||
{
|
||||
PERL_SET_CONTEXT(my_perl);
|
||||
PERL_SET_INTERP(my_perl);
|
||||
PL_perl_destruct_level = 1;
|
||||
perl_destruct(my_perl);
|
||||
perl_free(my_perl);
|
||||
my_perl = NULL;
|
||||
//Now reinit...
|
||||
DoInit();
|
||||
in_use = false;
|
||||
}
|
||||
|
||||
void Embperl::init_eval_file(void)
|
||||
@ -201,38 +193,30 @@ void Embperl::init_eval_file(void)
|
||||
"no warnings 'all';"
|
||||
"use Symbol qw(delete_package);"
|
||||
"sub eval_file {"
|
||||
"my($package, $filename) = @_;"
|
||||
"$filename=~s/\'//g;"
|
||||
"if(! -r $filename) { print \"Unable to read perl file '$filename'\\n\"; return; }"
|
||||
"my $mtime = -M $filename;"
|
||||
"if(defined $Cache{$package}{mtime}&&$Cache{$package}{mtime} <= $mtime && !($package eq 'plugin')){"
|
||||
" return;"
|
||||
"} else {"
|
||||
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
||||
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
||||
" print $@ if $@;"
|
||||
/* "local *FH;open FH, $filename or die \"open '$filename' $!\";"
|
||||
"local($/) = undef;my $sub = <FH>;close FH;"
|
||||
"my $eval = qq{package $package; sub handler { $sub; }};"
|
||||
"{ my($filename,$mtime,$package,$sub); eval $eval; }"
|
||||
"die $@ if $@;"
|
||||
"$Cache{$package}{mtime} = $mtime; ${$package.'::isloaded'} = 1;}"
|
||||
*/
|
||||
"}"
|
||||
"my($package, $filename) = @_;"
|
||||
"$filename=~s/\'//g;"
|
||||
"if(! -r $filename) { print \"Unable to read perl file '$filename'\\n\"; return; }"
|
||||
"my $mtime = -M $filename;"
|
||||
"if(defined $Cache{$package}{mtime}&&$Cache{$package}{mtime} <= $mtime && !($package eq 'plugin')){"
|
||||
" return;"
|
||||
"} else {"
|
||||
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
||||
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
||||
" print $@ if $@;"
|
||||
"}"
|
||||
,FALSE);
|
||||
}
|
||||
"}", FALSE);
|
||||
}
|
||||
|
||||
int Embperl::eval_file(const char * packagename, const char * filename)
|
||||
int Embperl::eval_file(const char* package_name, const char* filename)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
args.push_back(packagename);
|
||||
args.push_back(package_name);
|
||||
args.push_back(filename);
|
||||
|
||||
return dosub("main::eval_file", &args);
|
||||
}
|
||||
|
||||
int Embperl::dosub(const char * subname, const std::vector<std::string> * args, int mode)
|
||||
int Embperl::dosub(const char* sub_name, const std::vector<std::string>* args, int mode)
|
||||
{
|
||||
dSP;
|
||||
int ret_value = 0;
|
||||
@ -242,27 +226,29 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
|
||||
if (args && !args->empty()) {
|
||||
for (auto i = args->begin(); i != args->end(); ++i) {
|
||||
XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
|
||||
}
|
||||
}
|
||||
|
||||
PUTBACK;
|
||||
|
||||
count = call_pv(subname, mode);
|
||||
count = call_pv(sub_name, mode);
|
||||
SPAGAIN;
|
||||
|
||||
if (SvTRUE(ERRSV)) {
|
||||
error = SvPV_nolen(ERRSV);
|
||||
POPs;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (count == 1) {
|
||||
SV *ret = POPs;
|
||||
SV* ret = POPs;
|
||||
if (SvTYPE(ret) == SVt_IV) {
|
||||
IV v = SvIV(ret);
|
||||
ret_value = v;
|
||||
}
|
||||
|
||||
PUTBACK;
|
||||
}
|
||||
}
|
||||
@ -273,8 +259,8 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
// not sure why we pass this as blind args, strange
|
||||
// check for syntax errors
|
||||
if (args && !args->empty()) {
|
||||
const std::string &filename = args->back();
|
||||
std::string sub = subname;
|
||||
const std::string& filename = args->back();
|
||||
std::string sub = sub_name;
|
||||
if (sub == "main::eval_file" && !filename.empty() && File::Exists(filename)) {
|
||||
BenchTimer benchmark;
|
||||
|
||||
@ -286,8 +272,10 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
std::string syntax_error = Process::execute(
|
||||
fmt::format("{} -c {} 2>&1", perl, filename)
|
||||
);
|
||||
|
||||
LogQuests("Perl eval [{}] took [{}]", filename, benchmark.elapsed());
|
||||
syntax_error = Strings::Trim(syntax_error);
|
||||
|
||||
if (!Strings::Contains(syntax_error, "syntax OK")) {
|
||||
syntax_error += SvPVX(ERRSV);
|
||||
throw syntax_error;
|
||||
@ -305,19 +293,22 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
}
|
||||
|
||||
//evaluate an expression. throw error on fail
|
||||
int Embperl::eval(const char * code)
|
||||
int Embperl::eval(const char* code)
|
||||
{
|
||||
std::vector<std::string> arg;
|
||||
arg.push_back(code);
|
||||
return dosub("main::my_eval", &arg, G_SCALAR|G_EVAL|G_KEEPERR);
|
||||
return dosub("main::my_eval", &arg, G_SCALAR | G_EVAL | G_KEEPERR);
|
||||
}
|
||||
|
||||
bool Embperl::SubExists(const char *package, const char *sub) {
|
||||
HV *stash = gv_stashpv(package, false);
|
||||
if(!stash)
|
||||
return(false);
|
||||
bool Embperl::SubExists(const char* package, const char* sub)
|
||||
{
|
||||
HV* stash = gv_stashpv(package, false);
|
||||
if (!stash) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
int len = strlen(sub);
|
||||
return(hv_exists(stash, sub, len));
|
||||
return (hv_exists(stash, sub, len));
|
||||
}
|
||||
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
@ -331,8 +322,8 @@ XS(XS_EQEmuIO_PRINT)
|
||||
}
|
||||
|
||||
for (int r = 1; r < items; r++) {
|
||||
char *str = SvPV_nolen(ST(r));
|
||||
char *cur = str;
|
||||
char* str = SvPV_nolen(ST(r));
|
||||
char* cur = str;
|
||||
|
||||
/* Strip newlines from log message 'str' */
|
||||
*std::remove(str, str + strlen(str), '\n') = '\0';
|
||||
|
||||
@ -73,7 +73,6 @@ private:
|
||||
//install a perl func
|
||||
void init_eval_file(void);
|
||||
|
||||
bool in_use; //true if perl is executing
|
||||
protected:
|
||||
//the embedded interpreter
|
||||
PerlInterpreter * my_perl;
|
||||
@ -87,59 +86,66 @@ public:
|
||||
void Reinit();
|
||||
|
||||
//evaluate an expression. throws string errors on fail
|
||||
int eval(const char * code);
|
||||
int eval(const char* code);
|
||||
//execute a subroutine. throws lasterr on failure
|
||||
int dosub(const char * subname, const std::vector<std::string> * args = nullptr, int mode = G_SCALAR|G_EVAL);
|
||||
int dosub(const char* sub_name, const std::vector<std::string>* args = nullptr, int mode = G_SCALAR | G_EVAL);
|
||||
|
||||
//put an integer into a perl varable
|
||||
void seti(const char *varname, int val) const {
|
||||
SV *t = get_sv(varname, true);
|
||||
void seti(const char* variable_name, int val) const
|
||||
{
|
||||
SV* t = get_sv(variable_name, true);
|
||||
sv_setiv(t, val);
|
||||
}
|
||||
|
||||
//put a real into a perl varable
|
||||
void setd(const char *varname, float val) const {
|
||||
SV *t = get_sv(varname, true);
|
||||
void setd(const char* variable_name, float val) const
|
||||
{
|
||||
SV* t = get_sv(variable_name, true);
|
||||
sv_setnv(t, val);
|
||||
}
|
||||
|
||||
//put a string into a perl varable
|
||||
void setstr(const char *varname, const char *val) const {
|
||||
SV *t = get_sv(varname, true);
|
||||
void setstr(const char* variable_name, const char* val) const
|
||||
{
|
||||
SV* t = get_sv(variable_name, true);
|
||||
sv_setpv(t, val);
|
||||
}
|
||||
|
||||
// put a pointer into a blessed perl variable
|
||||
void setptr(const char* varname, const char* classname, void* val) const {
|
||||
SV* t = get_sv(varname, GV_ADD);
|
||||
sv_setref_pv(t, classname, val);
|
||||
void setptr(const char* variable_name, const char* class_name, void* val) const
|
||||
{
|
||||
SV* t = get_sv(variable_name, GV_ADD);
|
||||
sv_setref_pv(t, class_name, val);
|
||||
}
|
||||
|
||||
// put key-value pairs in hash
|
||||
void sethash(const char *varname, std::map<std::string,std::string> &vals)
|
||||
void sethash(const char* variable_name, std::map<std::string, std::string>& vals)
|
||||
{
|
||||
std::map<std::string,std::string>::iterator it;
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
|
||||
// Get hash and clear it.
|
||||
HV *hv = get_hv(varname, TRUE);
|
||||
HV* hv = get_hv(variable_name, TRUE);
|
||||
hv_clear(hv);
|
||||
|
||||
// Iterate through key-value pairs, storing them in hash
|
||||
for (it = vals.begin(); it != vals.end(); ++it)
|
||||
{
|
||||
int keylen = static_cast<int>(it->first.length());
|
||||
for (it = vals.begin(); it != vals.end(); ++it) {
|
||||
int key_length = static_cast<int>(it->first.length());
|
||||
|
||||
SV *val = newSVpv(it->second.c_str(), it->second.length());
|
||||
SV* val = newSVpv(it->second.c_str(), it->second.length());
|
||||
|
||||
// If val was not added to hash, reset reference count
|
||||
if (hv_store(hv, it->first.c_str(), keylen, val, 0) == nullptr)
|
||||
if (!hv_store(hv, it->first.c_str(), key_length, val, 0)) {
|
||||
val->sv_refcnt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//loads a file and compiles it into our interpreter (assuming it hasn't already been read in)
|
||||
//idea borrowed from perlembed
|
||||
int eval_file(const char * packagename, const char * filename);
|
||||
int eval_file(const char* package_name, const char* filename);
|
||||
|
||||
//check to see if a sub exists in package
|
||||
bool SubExists(const char *package, const char *sub);
|
||||
bool SubExists(const char* package, const char* sub);
|
||||
};
|
||||
#endif //EMBPERL
|
||||
|
||||
|
||||
@ -26,105 +26,262 @@
|
||||
class Client;
|
||||
class NPC;
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace EQ {
|
||||
class ItemInstance;
|
||||
}
|
||||
|
||||
class QuestInterface {
|
||||
public:
|
||||
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventEncounter(QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int EventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
virtual int EventNPC(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointer
|
||||
) {
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventGlobalNPC(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventPlayer(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventGlobalPlayer(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventItem(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventSpell(
|
||||
QuestEventID event_id,
|
||||
Mob* mob,
|
||||
Client* client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventEncounter(
|
||||
QuestEventID event_id,
|
||||
std::string encounter_name,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventBot(
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int EventGlobalBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool HasQuestSub(uint32 npcid, QuestEventID evt) { return false; }
|
||||
virtual bool HasGlobalQuestSub(QuestEventID evt) { return false; }
|
||||
virtual bool PlayerHasQuestSub(QuestEventID evt) { return false; }
|
||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt) { return false; }
|
||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt) { return false; }
|
||||
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt) { return false; }
|
||||
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt) { return false; }
|
||||
virtual bool HasEncounterSub(const std::string& package_name, QuestEventID evt) { return false; }
|
||||
virtual bool BotHasQuestSub(QuestEventID evt) { return false; }
|
||||
virtual bool GlobalBotHasQuestSub(QuestEventID evt) { return false; }
|
||||
virtual bool HasQuestSub(uint32 npc_id, QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool HasGlobalQuestSub(QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool PlayerHasQuestSub(QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool ItemHasQuestSub(EQ::ItemInstance* itm, QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool HasEncounterSub(const std::string& package_name, QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool BotHasQuestSub(QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool GlobalBotHasQuestSub(QuestEventID event_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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, EQ::ItemInstance *item) { }
|
||||
virtual void LoadItemScript(std::string filename, EQ::ItemInstance* inst) { }
|
||||
virtual void LoadSpellScript(std::string filename, uint32 spell_id) { }
|
||||
virtual void LoadEncounterScript(std::string filename, std::string encounter_name) { }
|
||||
virtual void LoadBotScript(std::string filename) { }
|
||||
virtual void LoadGlobalBotScript(std::string filename) { }
|
||||
|
||||
virtual int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int DispatchEventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers) { return 0; }
|
||||
virtual int DispatchEventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
virtual int DispatchEventNPC(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int DispatchEventPlayer(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int DispatchEventItem(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int DispatchEventSpell(
|
||||
QuestEventID event_id,
|
||||
Mob* mob,
|
||||
Client* client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int DispatchEventBot(
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void AddVar(std::string name, std::string val) { }
|
||||
virtual std::string GetVar(std::string name) { return std::string(); }
|
||||
virtual std::string GetVar(std::string name)
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
virtual void Init() { }
|
||||
virtual void ReloadQuests() { }
|
||||
virtual uint32 GetIdentifier() = 0;
|
||||
virtual void RemoveEncounter(const std::string &name) { }
|
||||
virtual void RemoveEncounter(const std::string& name) { }
|
||||
|
||||
virtual void GetErrors(std::list<std::string> &quest_errors) {
|
||||
virtual void GetErrors(std::list<std::string>& quest_errors)
|
||||
{
|
||||
quest_errors.insert(quest_errors.end(), errors_.begin(), errors_.end());
|
||||
}
|
||||
|
||||
virtual void AddError(std::string error) {
|
||||
virtual void AddError(std::string error)
|
||||
{
|
||||
LogQuests("{}", error);
|
||||
LogQuestErrors("{}", Strings::Trim(error));
|
||||
|
||||
errors_.push_back(error);
|
||||
|
||||
if (errors_.size() > RuleI(World, MaximumQuestErrors)) {
|
||||
errors_.pop_front();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -59,33 +59,66 @@ public:
|
||||
QuestParserCollection();
|
||||
~QuestParserCollection();
|
||||
|
||||
void RegisterQuestInterface(QuestInterface *qi, std::string ext);
|
||||
void UnRegisterQuestInterface(QuestInterface *qi, std::string ext);
|
||||
void RegisterQuestInterface(QuestInterface* qi, std::string ext);
|
||||
void ClearInterfaces();
|
||||
void AddVar(std::string name, std::string val);
|
||||
void Init();
|
||||
void ReloadQuests(bool reset_timers = true);
|
||||
void RemoveEncounter(const std::string name);
|
||||
void RemoveEncounter(const std::string& name);
|
||||
|
||||
bool HasQuestSub(uint32 npcid, QuestEventID evt);
|
||||
bool PlayerHasQuestSub(QuestEventID evt);
|
||||
bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
||||
bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
||||
bool BotHasQuestSub(QuestEventID evt);
|
||||
bool HasQuestSub(uint32 npc_id, QuestEventID event_id);
|
||||
bool PlayerHasQuestSub(QuestEventID event_id);
|
||||
bool SpellHasQuestSub(uint32 spell_id, QuestEventID event_id);
|
||||
bool ItemHasQuestSub(EQ::ItemInstance* inst, QuestEventID event_id);
|
||||
bool BotHasQuestSub(QuestEventID event_id);
|
||||
|
||||
int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers = nullptr);
|
||||
int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers = nullptr);
|
||||
int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers = nullptr);
|
||||
int EventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers = nullptr);
|
||||
int EventEncounter(QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers = nullptr);
|
||||
int EventNPC(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers = nullptr
|
||||
);
|
||||
|
||||
int EventPlayer(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers = nullptr
|
||||
);
|
||||
|
||||
int EventItem(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers = nullptr
|
||||
);
|
||||
|
||||
int EventSpell(
|
||||
QuestEventID event_id,
|
||||
Mob* mob,
|
||||
Client* client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers = nullptr
|
||||
);
|
||||
|
||||
int EventEncounter(
|
||||
QuestEventID event_id,
|
||||
std::string encounter_name,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers = nullptr
|
||||
);
|
||||
|
||||
int EventBot(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
@ -117,32 +150,63 @@ public:
|
||||
void LoadPerlEventExportSettings(PerlEventExportSettings* s);
|
||||
|
||||
private:
|
||||
bool HasQuestSubLocal(uint32 npcid, QuestEventID evt);
|
||||
bool HasQuestSubGlobal(QuestEventID evt);
|
||||
bool NPCHasEncounterSub(uint32 npc_id, QuestEventID evt);
|
||||
bool PlayerHasQuestSubLocal(QuestEventID evt);
|
||||
bool PlayerHasQuestSubGlobal(QuestEventID evt);
|
||||
bool PlayerHasEncounterSub(QuestEventID evt);
|
||||
bool SpellHasEncounterSub(uint32 spell_id, QuestEventID evt);
|
||||
bool ItemHasEncounterSub(EQ::ItemInstance* item, QuestEventID evt);
|
||||
bool HasEncounterSub(QuestEventID evt, const std::string& package_name);
|
||||
bool BotHasQuestSubLocal(QuestEventID evt);
|
||||
bool BotHasQuestSubGlobal(QuestEventID evt);
|
||||
bool HasQuestSubLocal(uint32 npc_id, QuestEventID event_id);
|
||||
bool HasQuestSubGlobal(QuestEventID event_id);
|
||||
bool NPCHasEncounterSub(uint32 npc_id, QuestEventID event_id);
|
||||
bool PlayerHasQuestSubLocal(QuestEventID event_id);
|
||||
bool PlayerHasQuestSubGlobal(QuestEventID event_id);
|
||||
bool PlayerHasEncounterSub(QuestEventID event_id);
|
||||
bool SpellHasEncounterSub(uint32 spell_id, QuestEventID event_id);
|
||||
bool ItemHasEncounterSub(EQ::ItemInstance* inst, QuestEventID event_id);
|
||||
bool HasEncounterSub(QuestEventID event_id, const std::string& package_name);
|
||||
bool BotHasQuestSubLocal(QuestEventID event_id);
|
||||
bool BotHasQuestSubGlobal(QuestEventID event_id);
|
||||
|
||||
int EventNPCLocal(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int EventNPCGlobal(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int EventPlayerLocal(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int EventPlayerGlobal(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<std::any> *extra_pointers);
|
||||
int EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<std::any> *extra_pointers);
|
||||
int EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data, std::vector<std::any> *extra_pointers);
|
||||
int EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data, std::vector<std::any> *extra_pointers);
|
||||
int EventBotLocal(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
int EventBotGlobal(
|
||||
QuestEventID evt,
|
||||
QuestEventID event_id,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
@ -150,47 +214,74 @@ private:
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
QuestInterface *GetQIByNPCQuest(uint32 npcid, std::string &filename);
|
||||
QuestInterface *GetQIByGlobalNPCQuest(std::string &filename);
|
||||
QuestInterface *GetQIByPlayerQuest(std::string &filename);
|
||||
QuestInterface *GetQIByGlobalPlayerQuest(std::string &filename);
|
||||
QuestInterface *GetQIBySpellQuest(uint32 spell_id, std::string &filename);
|
||||
QuestInterface *GetQIByItemQuest(std::string item_script, std::string &filename);
|
||||
QuestInterface *GetQIByEncounterQuest(std::string encounter_name, std::string &filename);
|
||||
QuestInterface *GetQIByBotQuest(std::string &filename);
|
||||
QuestInterface *GetQIByGlobalBotQuest(std::string &filename);
|
||||
QuestInterface* GetQIByNPCQuest(uint32 npc_id, std::string& filename);
|
||||
QuestInterface* GetQIByGlobalNPCQuest(std::string& filename);
|
||||
QuestInterface* GetQIByPlayerQuest(std::string& filename);
|
||||
QuestInterface* GetQIByGlobalPlayerQuest(std::string& filename);
|
||||
QuestInterface* GetQIBySpellQuest(uint32 spell_id, std::string& filename);
|
||||
QuestInterface* GetQIByItemQuest(std::string item_script, std::string& filename);
|
||||
QuestInterface* GetQIByEncounterQuest(std::string encounter_name, std::string& filename);
|
||||
QuestInterface* GetQIByBotQuest(std::string& filename);
|
||||
QuestInterface* GetQIByGlobalBotQuest(std::string& filename);
|
||||
|
||||
int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
int DispatchEventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
int DispatchEventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
int DispatchEventNPC(
|
||||
QuestEventID event_id,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int DispatchEventPlayer(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int DispatchEventItem(
|
||||
QuestEventID event_id,
|
||||
Client* client,
|
||||
EQ::ItemInstance* inst,
|
||||
Mob* mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int DispatchEventSpell(
|
||||
QuestEventID event_id,
|
||||
Mob* mob,
|
||||
Client* client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
int DispatchEventBot(
|
||||
QuestEventID event_id,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers
|
||||
);
|
||||
|
||||
std::map<uint32, QuestInterface*> _interfaces;
|
||||
std::map<uint32, std::string> _extensions;
|
||||
std::list<QuestInterface*> _load_precedence;
|
||||
std::map<uint32, std::string> _extensions;
|
||||
std::list<QuestInterface*> _load_precedence;
|
||||
|
||||
//0x00 = Unloaded
|
||||
//0xFFFFFFFF = Failed to Load
|
||||
std::map<uint32, uint32> _npc_quest_status;
|
||||
uint32 _global_npc_quest_status;
|
||||
uint32 _player_quest_status;
|
||||
uint32 _global_player_quest_status;
|
||||
uint32 _bot_quest_status;
|
||||
uint32 _global_bot_quest_status;
|
||||
std::map<uint32, uint32> _spell_quest_status;
|
||||
std::map<uint32, uint32> _item_quest_status;
|
||||
std::map<uint32, uint32> _npc_quest_status;
|
||||
uint32 _global_npc_quest_status;
|
||||
uint32 _player_quest_status;
|
||||
uint32 _global_player_quest_status;
|
||||
uint32 _bot_quest_status;
|
||||
uint32 _global_bot_quest_status;
|
||||
std::map<uint32, uint32> _spell_quest_status;
|
||||
std::map<uint32, uint32> _item_quest_status;
|
||||
std::map<std::string, uint32> _encounter_quest_status;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user