mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18: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
1260
zone/embparser.cpp
1260
zone/embparser.cpp
File diff suppressed because it is too large
Load Diff
188
zone/embparser.h
188
zone/embparser.h
@ -31,13 +31,11 @@ class Mob;
|
|||||||
class Client;
|
class Client;
|
||||||
class NPC;
|
class NPC;
|
||||||
|
|
||||||
namespace EQ
|
namespace EQ {
|
||||||
{
|
|
||||||
class ItemInstance;
|
class ItemInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
questUnloaded,
|
questUnloaded,
|
||||||
questLoaded,
|
questLoaded,
|
||||||
questFailedToLoad
|
questFailedToLoad
|
||||||
@ -49,37 +47,41 @@ public:
|
|||||||
~PerlembParser();
|
~PerlembParser();
|
||||||
|
|
||||||
virtual int EventNPC(
|
virtual int EventNPC(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
NPC* npc,
|
NPC* npc,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventGlobalNPC(
|
virtual int EventGlobalNPC(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
NPC* npc,
|
NPC* npc,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventPlayer(
|
virtual int EventPlayer(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Client* client,
|
Client* client,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventGlobalPlayer(
|
virtual int EventGlobalPlayer(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Client* client,
|
Client* client,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventItem(
|
virtual int EventItem(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Client* client,
|
Client* client,
|
||||||
EQ::ItemInstance* item,
|
EQ::ItemInstance* item,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
@ -87,8 +89,9 @@ public:
|
|||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventSpell(
|
virtual int EventSpell(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
Client* client,
|
Client* client,
|
||||||
uint32 spell_id,
|
uint32 spell_id,
|
||||||
@ -96,16 +99,9 @@ public:
|
|||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual int EventBot(
|
virtual int EventBot(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Bot *bot,
|
|
||||||
Mob *init,
|
|
||||||
std::string data,
|
|
||||||
uint32 extra_data,
|
|
||||||
std::vector<std::any> *extra_pointers
|
|
||||||
);
|
|
||||||
virtual int EventGlobalBot(
|
|
||||||
QuestEventID evt,
|
|
||||||
Bot* bot,
|
Bot* bot,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
@ -113,20 +109,29 @@ public:
|
|||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual bool HasQuestSub(uint32 npcid, QuestEventID evt);
|
virtual int EventGlobalBot(
|
||||||
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
QuestEventID event_id,
|
||||||
virtual bool PlayerHasQuestSub(QuestEventID evt);
|
Bot* bot,
|
||||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
|
Mob* init,
|
||||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
std::string data,
|
||||||
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
uint32 extra_data,
|
||||||
virtual bool BotHasQuestSub(QuestEventID evt);
|
std::vector<std::any>* extra_pointers
|
||||||
virtual bool GlobalBotHasQuestSub(QuestEventID evt);
|
);
|
||||||
|
|
||||||
|
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 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 LoadPlayerScript(std::string filename);
|
||||||
virtual void LoadGlobalPlayerScript(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 LoadSpellScript(std::string filename, uint32 spell_id);
|
||||||
virtual void LoadBotScript(std::string filename);
|
virtual void LoadBotScript(std::string filename);
|
||||||
virtual void LoadGlobalBotScript(std::string filename);
|
virtual void LoadGlobalBotScript(std::string filename);
|
||||||
@ -139,117 +144,128 @@ public:
|
|||||||
private:
|
private:
|
||||||
Embperl* perl;
|
Embperl* perl;
|
||||||
|
|
||||||
void ExportHash(const char *pkgprefix, const char *hashname, std::map<std::string, std::string> &vals);
|
void ExportHash(const char* prefix, const char* hash_name, std::map<std::string, std::string>& vals);
|
||||||
void ExportVar(const char *pkgprefix, const char *varname, const char *value);
|
void ExportVar(const char* prefix, const char* variable_name, const char* value);
|
||||||
void ExportVar(const char *pkgprefix, const char *varname, int32 value);
|
void ExportVar(const char* prefix, const char* variable_name, int32 value);
|
||||||
void ExportVar(const char *pkgprefix, const char *varname, uint32 value);
|
void ExportVar(const char* prefix, const char* variable_name, uint32 value);
|
||||||
void ExportVar(const char *pkgprefix, const char *varname, float value);
|
void ExportVar(const char* prefix, const char* variable_name, float value);
|
||||||
void ExportVar(const char* pkgprefix, const char* varname, const char* classname, void* value);
|
void ExportVar(const char* prefix, const char* variable_name, const char* class_name, void* value);
|
||||||
|
|
||||||
int EventCommon(
|
int EventCommon(
|
||||||
QuestEventID event,
|
QuestEventID event,
|
||||||
uint32 objid,
|
uint32 object_id,
|
||||||
const char* data,
|
const char* data,
|
||||||
Mob* npcmob,
|
Mob* npc_mob,
|
||||||
EQ::ItemInstance* item_inst,
|
EQ::ItemInstance* inst,
|
||||||
const SPDat_Spell_Struct* spell,
|
const SPDat_Spell_Struct* spell,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
uint32 extradata,
|
uint32 extra_data,
|
||||||
bool global,
|
bool is_global,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
int SendCommands(
|
int SendCommands(
|
||||||
const char *pkgprefix,
|
const char* prefix,
|
||||||
const char* event,
|
const char* event,
|
||||||
uint32 spell_id,
|
uint32 spell_id,
|
||||||
Mob* other,
|
Mob* other,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
EQ::ItemInstance *item_inst,
|
EQ::ItemInstance* inst,
|
||||||
const SPDat_Spell_Struct* spell
|
const SPDat_Spell_Struct* spell
|
||||||
);
|
);
|
||||||
|
|
||||||
void MapFunctions();
|
void MapFunctions();
|
||||||
|
|
||||||
void GetQuestTypes(
|
void GetQuestTypes(
|
||||||
bool &isPlayerQuest,
|
bool& is_player_quest,
|
||||||
bool &isGlobalPlayerQuest,
|
bool& is_global_player_quest,
|
||||||
bool &isBotQuest,
|
bool& is_bot_quest,
|
||||||
bool &isGlobalBotQuest,
|
bool& is_global_bot_quest,
|
||||||
bool &isGlobalNPC,
|
bool& is_global_npc_quest,
|
||||||
bool &isItemQuest,
|
bool& is_item_quest,
|
||||||
bool &isSpellQuest,
|
bool& is_spell_quest,
|
||||||
QuestEventID event,
|
QuestEventID event,
|
||||||
Mob* npcmob,
|
Mob* npc_mob,
|
||||||
EQ::ItemInstance* item_inst,
|
EQ::ItemInstance* inst,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
bool global
|
bool is_global
|
||||||
);
|
);
|
||||||
|
|
||||||
void GetQuestPackageName(
|
void GetQuestPackageName(
|
||||||
bool &isPlayerQuest,
|
bool& is_player_quest,
|
||||||
bool &isGlobalPlayerQuest,
|
bool& is_global_player_quest,
|
||||||
bool &isBotQuest,
|
bool& is_bot_quest,
|
||||||
bool &isGlobalBotQuest,
|
bool& is_global_bot_quest,
|
||||||
bool &isGlobalNPC,
|
bool& is_global_npc_quest,
|
||||||
bool &isItemQuest,
|
bool& is_item_quest,
|
||||||
bool &isSpellQuest,
|
bool& is_spell_quest,
|
||||||
std::string& package_name,
|
std::string& package_name,
|
||||||
QuestEventID event,
|
QuestEventID event,
|
||||||
uint32 objid,
|
uint32 object_id,
|
||||||
const char* data,
|
const char* data,
|
||||||
Mob* npcmob,
|
Mob* npc_mob,
|
||||||
EQ::ItemInstance* item_inst,
|
EQ::ItemInstance* inst,
|
||||||
bool global
|
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(
|
void ExportQGlobals(
|
||||||
bool isPlayerQuest,
|
bool is_player_quest,
|
||||||
bool isGlobalPlayerQuest,
|
bool is_global_player_quest,
|
||||||
bool isBotQuest,
|
bool is_bot_quest,
|
||||||
bool isGlobalBotQuest,
|
bool is_global_bot_quest,
|
||||||
bool isGlobalNPC,
|
bool is_global_npc_quest,
|
||||||
bool isItemQuest,
|
bool is_item_quest,
|
||||||
bool isSpellQuest,
|
bool is_spell_quest,
|
||||||
std::string& package_name,
|
std::string& package_name,
|
||||||
Mob *npcmob,
|
Mob* npc_mob,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
int char_id
|
int char_id
|
||||||
);
|
);
|
||||||
|
|
||||||
void ExportMobVariables(
|
void ExportMobVariables(
|
||||||
bool isPlayerQuest,
|
bool is_player_quest,
|
||||||
bool isGlobalPlayerQuest,
|
bool is_global_player_quest,
|
||||||
bool isBotQuest,
|
bool is_bot_quest,
|
||||||
bool isGlobalBotQuest,
|
bool is_global_bot_quest,
|
||||||
bool isGlobalNPC,
|
bool is_global_npc_quest,
|
||||||
bool isItemQuest,
|
bool is_item_quest,
|
||||||
bool isSpellQuest,
|
bool is_spell_quest,
|
||||||
std::string& package_name,
|
std::string& package_name,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
Mob *npcmob
|
Mob* npc_mob
|
||||||
);
|
);
|
||||||
|
|
||||||
void ExportZoneVariables(std::string& package_name);
|
void ExportZoneVariables(std::string& package_name);
|
||||||
|
|
||||||
void ExportItemVariables(std::string& package_name, Mob* mob);
|
void ExportItemVariables(std::string& package_name, Mob* mob);
|
||||||
|
|
||||||
void ExportEventVariables(
|
void ExportEventVariables(
|
||||||
std::string& package_name,
|
std::string& package_name,
|
||||||
QuestEventID event,
|
QuestEventID event,
|
||||||
uint32 objid,
|
uint32 object_id,
|
||||||
const char* data,
|
const char* data,
|
||||||
Mob* npcmob,
|
Mob* npc_mob,
|
||||||
EQ::ItemInstance* item_inst,
|
EQ::ItemInstance* inst,
|
||||||
Mob* mob,
|
Mob* mob,
|
||||||
uint32 extradata,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
std::map<uint32, PerlQuestStatus> npc_quest_status_;
|
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 global_npc_quest_status_;
|
||||||
PerlQuestStatus player_quest_status_;
|
PerlQuestStatus player_quest_status_;
|
||||||
PerlQuestStatus global_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 bot_quest_status_;
|
||||||
PerlQuestStatus global_bot_quest_status_;
|
PerlQuestStatus global_bot_quest_status_;
|
||||||
|
|
||||||
std::map<std::string, std::string> vars_;
|
|
||||||
SV* _empty_sv;
|
SV* _empty_sv;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> vars_;
|
||||||
std::map<std::string, int> clear_vars_;
|
std::map<std::string, int> clear_vars_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,11 +27,13 @@ Eglin
|
|||||||
XS(XS_EQEmuIO_PRINT);
|
XS(XS_EQEmuIO_PRINT);
|
||||||
#endif //EMBPERL_IO_CAPTURE
|
#endif //EMBPERL_IO_CAPTURE
|
||||||
|
|
||||||
const char *argv_eqemu[] = { "",
|
const char* argv_eqemu[] = {
|
||||||
|
"",
|
||||||
#ifdef EMBPERL_IO_CAPTURE
|
#ifdef EMBPERL_IO_CAPTURE
|
||||||
"-w", "-W",
|
"-w", "-W",
|
||||||
#endif
|
#endif
|
||||||
"-e", "0;", nullptr };
|
"-e", "0;", nullptr
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef EMBPERL_IO_CAPTURE
|
#ifdef EMBPERL_IO_CAPTURE
|
||||||
int argc = 5;
|
int argc = 5;
|
||||||
@ -60,18 +62,18 @@ Embperl::Embperl()
|
|||||||
{
|
{
|
||||||
char** argv = (char**) argv_eqemu;
|
char** argv = (char**) argv_eqemu;
|
||||||
char** env = { nullptr };
|
char** env = { nullptr };
|
||||||
in_use = true; //in case one of these files generates an event
|
|
||||||
PERL_SYS_INIT3(&argc, &argv, &env);
|
PERL_SYS_INIT3(&argc, &argv, &env);
|
||||||
DoInit();
|
DoInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Embperl::DoInit() {
|
void Embperl::DoInit()
|
||||||
|
{
|
||||||
char** argv = (char**) argv_eqemu;
|
char** argv = (char**) argv_eqemu;
|
||||||
char **env = { nullptr };
|
|
||||||
my_perl = perl_alloc();
|
my_perl = perl_alloc();
|
||||||
//setup perl...
|
//setup perl...
|
||||||
if(!my_perl)
|
if (!my_perl) {
|
||||||
throw "Failed to init Perl (perl_alloc)";
|
throw "Failed to init Perl (perl_alloc)";
|
||||||
|
}
|
||||||
PERL_SET_CONTEXT(my_perl);
|
PERL_SET_CONTEXT(my_perl);
|
||||||
PERL_SET_INTERP(my_perl);
|
PERL_SET_INTERP(my_perl);
|
||||||
PL_perl_destruct_level = 1;
|
PL_perl_destruct_level = 1;
|
||||||
@ -98,8 +100,7 @@ void Embperl::DoInit() {
|
|||||||
try {
|
try {
|
||||||
init_eval_file();
|
init_eval_file();
|
||||||
}
|
}
|
||||||
catch(std::string& e)
|
catch (std::string& e) {
|
||||||
{
|
|
||||||
//remember... lasterr() is no good if we crap out here, in construction
|
//remember... lasterr() is no good if we crap out here, in construction
|
||||||
LogQuests("Perl Error [{}]", e);
|
LogQuests("Perl Error [{}]", e);
|
||||||
throw "failed to install eval_file hook";
|
throw "failed to install eval_file hook";
|
||||||
@ -112,67 +113,60 @@ void Embperl::DoInit() {
|
|||||||
"package EQEmuIO; "
|
"package EQEmuIO; "
|
||||||
"sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '. $me); return($me); } "
|
"sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '. $me); return($me); } "
|
||||||
"sub WRITE { } "
|
"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 PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } "
|
||||||
"sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } "
|
"sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } "
|
||||||
"sub DESTROY { my $me = shift; $me->PRINT('Destroying '.$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;"
|
"package quest;"
|
||||||
" if(tied *STDOUT) { untie(*STDOUT); }"
|
" if(tied *STDOUT) { untie(*STDOUT); }"
|
||||||
" if(tied *STDERR) { untie(*STDERR); }"
|
" if(tied *STDERR) { untie(*STDERR); }"
|
||||||
" tie *STDOUT, 'EQEmuIO';"
|
" tie *STDOUT, 'EQEmuIO';"
|
||||||
" tie *STDERR, 'EQEmuIO';"
|
" tie *STDERR, 'EQEmuIO';", FALSE);
|
||||||
,FALSE);
|
|
||||||
#endif //EMBPERL_IO_CAPTURE
|
#endif //EMBPERL_IO_CAPTURE
|
||||||
|
|
||||||
#ifdef EMBPERL_PLUGIN
|
#ifdef EMBPERL_PLUGIN
|
||||||
eval_pv(
|
eval_pv(
|
||||||
"package plugin; "
|
"package plugin; ", FALSE
|
||||||
,FALSE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
LogQuests("Loading perlemb plugins");
|
LogQuests("Loading perlemb plugins");
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
std::string perl_command;
|
std::string perl_command;
|
||||||
perl_command = "main::eval_file('plugin', '" + Config->PluginPlFile + "');";
|
perl_command = "main::eval_file('plugin', '" + Config->PluginPlFile + "');";
|
||||||
eval_pv(perl_command.c_str(), FALSE);
|
eval_pv(perl_command.c_str(), FALSE);
|
||||||
}
|
}
|
||||||
catch(std::string& e)
|
catch (std::string& e) {
|
||||||
{
|
|
||||||
LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e);
|
LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e);
|
||||||
}
|
}
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
//should probably read the directory in c, instead, so that
|
//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
|
//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 =
|
const std::string& perl_command = (
|
||||||
"if(opendir(D,'" + path.GetPluginsPath() +"')) { "
|
"if(opendir(D,'" +
|
||||||
|
path.GetPluginsPath() +
|
||||||
|
"')) { "
|
||||||
" my @d = readdir(D);"
|
" my @d = readdir(D);"
|
||||||
" closedir(D);"
|
" closedir(D);"
|
||||||
" foreach(@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);
|
LogQuests("Warning [{}]", e);
|
||||||
}
|
}
|
||||||
#endif //EMBPERL_PLUGIN
|
#endif //EMBPERL_PLUGIN
|
||||||
in_use = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Embperl::~Embperl()
|
Embperl::~Embperl()
|
||||||
{
|
{
|
||||||
in_use = true;
|
|
||||||
#ifdef EMBPERL_IO_CAPTURE
|
#ifdef EMBPERL_IO_CAPTURE
|
||||||
eval_pv(
|
eval_pv(
|
||||||
"package quest;"
|
"package quest;"
|
||||||
" if(tied *STDOUT) { untie(*STDOUT); }"
|
" if(tied *STDOUT) { untie(*STDOUT); }"
|
||||||
" if(tied *STDERR) { untie(*STDERR); }"
|
" if(tied *STDERR) { untie(*STDERR); }", FALSE);
|
||||||
,FALSE);
|
|
||||||
#endif
|
#endif
|
||||||
PL_perl_destruct_level = 1;
|
PL_perl_destruct_level = 1;
|
||||||
perl_destruct(my_perl);
|
perl_destruct(my_perl);
|
||||||
@ -181,17 +175,15 @@ Embperl::~Embperl()
|
|||||||
my_perl = NULL;
|
my_perl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Embperl::Reinit() {
|
void Embperl::Reinit()
|
||||||
in_use = true;
|
{
|
||||||
PERL_SET_CONTEXT(my_perl);
|
PERL_SET_CONTEXT(my_perl);
|
||||||
PERL_SET_INTERP(my_perl);
|
PERL_SET_INTERP(my_perl);
|
||||||
PL_perl_destruct_level = 1;
|
PL_perl_destruct_level = 1;
|
||||||
perl_destruct(my_perl);
|
perl_destruct(my_perl);
|
||||||
perl_free(my_perl);
|
perl_free(my_perl);
|
||||||
my_perl = NULL;
|
my_perl = NULL;
|
||||||
//Now reinit...
|
|
||||||
DoInit();
|
DoInit();
|
||||||
in_use = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Embperl::init_eval_file(void)
|
void Embperl::init_eval_file(void)
|
||||||
@ -211,28 +203,20 @@ void Embperl::init_eval_file(void)
|
|||||||
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
// 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'; \");"
|
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
||||||
" print $@ if $@;"
|
" 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;}"
|
|
||||||
*/
|
|
||||||
"}"
|
"}"
|
||||||
"}"
|
"}", 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;
|
std::vector<std::string> args;
|
||||||
args.push_back(packagename);
|
args.push_back(package_name);
|
||||||
args.push_back(filename);
|
args.push_back(filename);
|
||||||
|
|
||||||
return dosub("main::eval_file", &args);
|
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;
|
dSP;
|
||||||
int ret_value = 0;
|
int ret_value = 0;
|
||||||
@ -242,27 +226,29 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
|||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
|
||||||
if (args && !args->empty()) {
|
if (args && !args->empty()) {
|
||||||
for (auto i = args->begin(); i != args->end(); ++i) {
|
for (auto i = args->begin(); i != args->end(); ++i) {
|
||||||
XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
|
XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
|
||||||
count = call_pv(subname, mode);
|
count = call_pv(sub_name, mode);
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
|
|
||||||
if (SvTRUE(ERRSV)) {
|
if (SvTRUE(ERRSV)) {
|
||||||
error = SvPV_nolen(ERRSV);
|
error = SvPV_nolen(ERRSV);
|
||||||
POPs;
|
POPs;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
SV* ret = POPs;
|
SV* ret = POPs;
|
||||||
if (SvTYPE(ret) == SVt_IV) {
|
if (SvTYPE(ret) == SVt_IV) {
|
||||||
IV v = SvIV(ret);
|
IV v = SvIV(ret);
|
||||||
ret_value = v;
|
ret_value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +260,7 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
|||||||
// check for syntax errors
|
// check for syntax errors
|
||||||
if (args && !args->empty()) {
|
if (args && !args->empty()) {
|
||||||
const std::string& filename = args->back();
|
const std::string& filename = args->back();
|
||||||
std::string sub = subname;
|
std::string sub = sub_name;
|
||||||
if (sub == "main::eval_file" && !filename.empty() && File::Exists(filename)) {
|
if (sub == "main::eval_file" && !filename.empty() && File::Exists(filename)) {
|
||||||
BenchTimer benchmark;
|
BenchTimer benchmark;
|
||||||
|
|
||||||
@ -286,8 +272,10 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
|||||||
std::string syntax_error = Process::execute(
|
std::string syntax_error = Process::execute(
|
||||||
fmt::format("{} -c {} 2>&1", perl, filename)
|
fmt::format("{} -c {} 2>&1", perl, filename)
|
||||||
);
|
);
|
||||||
|
|
||||||
LogQuests("Perl eval [{}] took [{}]", filename, benchmark.elapsed());
|
LogQuests("Perl eval [{}] took [{}]", filename, benchmark.elapsed());
|
||||||
syntax_error = Strings::Trim(syntax_error);
|
syntax_error = Strings::Trim(syntax_error);
|
||||||
|
|
||||||
if (!Strings::Contains(syntax_error, "syntax OK")) {
|
if (!Strings::Contains(syntax_error, "syntax OK")) {
|
||||||
syntax_error += SvPVX(ERRSV);
|
syntax_error += SvPVX(ERRSV);
|
||||||
throw syntax_error;
|
throw syntax_error;
|
||||||
@ -312,10 +300,13 @@ int Embperl::eval(const char * 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) {
|
bool Embperl::SubExists(const char* package, const char* sub)
|
||||||
|
{
|
||||||
HV* stash = gv_stashpv(package, false);
|
HV* stash = gv_stashpv(package, false);
|
||||||
if(!stash)
|
if (!stash) {
|
||||||
return (false);
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
int len = strlen(sub);
|
int len = strlen(sub);
|
||||||
return (hv_exists(stash, sub, len));
|
return (hv_exists(stash, sub, len));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,6 @@ private:
|
|||||||
//install a perl func
|
//install a perl func
|
||||||
void init_eval_file(void);
|
void init_eval_file(void);
|
||||||
|
|
||||||
bool in_use; //true if perl is executing
|
|
||||||
protected:
|
protected:
|
||||||
//the embedded interpreter
|
//the embedded interpreter
|
||||||
PerlInterpreter * my_perl;
|
PerlInterpreter * my_perl;
|
||||||
@ -89,54 +88,61 @@ public:
|
|||||||
//evaluate an expression. throws string errors on fail
|
//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
|
//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
|
//put an integer into a perl varable
|
||||||
void seti(const char *varname, int val) const {
|
void seti(const char* variable_name, int val) const
|
||||||
SV *t = get_sv(varname, true);
|
{
|
||||||
|
SV* t = get_sv(variable_name, true);
|
||||||
sv_setiv(t, val);
|
sv_setiv(t, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
//put a real into a perl varable
|
//put a real into a perl varable
|
||||||
void setd(const char *varname, float val) const {
|
void setd(const char* variable_name, float val) const
|
||||||
SV *t = get_sv(varname, true);
|
{
|
||||||
|
SV* t = get_sv(variable_name, true);
|
||||||
sv_setnv(t, val);
|
sv_setnv(t, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
//put a string into a perl varable
|
//put a string into a perl varable
|
||||||
void setstr(const char *varname, const char *val) const {
|
void setstr(const char* variable_name, const char* val) const
|
||||||
SV *t = get_sv(varname, true);
|
{
|
||||||
|
SV* t = get_sv(variable_name, true);
|
||||||
sv_setpv(t, val);
|
sv_setpv(t, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put a pointer into a blessed perl variable
|
// put a pointer into a blessed perl variable
|
||||||
void setptr(const char* varname, const char* classname, void* val) const {
|
void setptr(const char* variable_name, const char* class_name, void* val) const
|
||||||
SV* t = get_sv(varname, GV_ADD);
|
{
|
||||||
sv_setref_pv(t, classname, val);
|
SV* t = get_sv(variable_name, GV_ADD);
|
||||||
|
sv_setref_pv(t, class_name, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put key-value pairs in hash
|
// 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.
|
// Get hash and clear it.
|
||||||
HV *hv = get_hv(varname, TRUE);
|
HV* hv = get_hv(variable_name, TRUE);
|
||||||
hv_clear(hv);
|
hv_clear(hv);
|
||||||
|
|
||||||
// Iterate through key-value pairs, storing them in hash
|
// Iterate through key-value pairs, storing them in hash
|
||||||
for (it = vals.begin(); it != vals.end(); ++it)
|
for (it = vals.begin(); it != vals.end(); ++it) {
|
||||||
{
|
int key_length = static_cast<int>(it->first.length());
|
||||||
int keylen = 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 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;
|
val->sv_refcnt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//loads a file and compiles it into our interpreter (assuming it hasn't already been read in)
|
//loads a file and compiles it into our interpreter (assuming it hasn't already been read in)
|
||||||
//idea borrowed from perlembed
|
//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
|
//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);
|
||||||
|
|||||||
@ -26,105 +26,262 @@
|
|||||||
class Client;
|
class Client;
|
||||||
class NPC;
|
class NPC;
|
||||||
|
|
||||||
namespace EQ
|
namespace EQ {
|
||||||
{
|
|
||||||
class ItemInstance;
|
class ItemInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QuestInterface {
|
class QuestInterface {
|
||||||
public:
|
public:
|
||||||
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
virtual int EventNPC(
|
||||||
std::vector<std::any> *extra_pointers) { return 0; }
|
QuestEventID event_id,
|
||||||
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
NPC* npc,
|
||||||
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,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any> *extra_pointer
|
std::vector<std::any>* extra_pointers
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int EventGlobalBot(
|
virtual int EventGlobalNPC(
|
||||||
QuestEventID evt,
|
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,
|
Bot* bot,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasQuestSub(uint32 npcid, QuestEventID evt) { return false; }
|
virtual int EventGlobalBot(
|
||||||
virtual bool HasGlobalQuestSub(QuestEventID evt) { return false; }
|
QuestEventID event_id,
|
||||||
virtual bool PlayerHasQuestSub(QuestEventID evt) { return false; }
|
Bot* bot,
|
||||||
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt) { return false; }
|
Mob* init,
|
||||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt) { return false; }
|
std::string data,
|
||||||
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt) { return false; }
|
uint32 extra_data,
|
||||||
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt) { return false; }
|
std::vector<std::any>* extra_pointers
|
||||||
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; }
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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 LoadPlayerScript(std::string filename) { }
|
||||||
virtual void LoadGlobalPlayerScript(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 LoadSpellScript(std::string filename, uint32 spell_id) { }
|
||||||
virtual void LoadEncounterScript(std::string filename, std::string encounter_name) { }
|
virtual void LoadEncounterScript(std::string filename, std::string encounter_name) { }
|
||||||
virtual void LoadBotScript(std::string filename) { }
|
virtual void LoadBotScript(std::string filename) { }
|
||||||
virtual void LoadGlobalBotScript(std::string filename) { }
|
virtual void LoadGlobalBotScript(std::string filename) { }
|
||||||
|
|
||||||
virtual int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
virtual int DispatchEventNPC(
|
||||||
std::vector<std::any> *extra_pointers) { return 0; }
|
QuestEventID event_id,
|
||||||
virtual int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
NPC* npc,
|
||||||
std::vector<std::any> *extra_pointers) { return 0; }
|
Mob* init,
|
||||||
virtual int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
std::string data,
|
||||||
std::vector<std::any> *extra_pointers) { return 0; }
|
uint32 extra_data,
|
||||||
virtual int DispatchEventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
std::vector<std::any>* extra_pointers
|
||||||
std::vector<std::any> *extra_pointers) { return 0; }
|
)
|
||||||
|
{
|
||||||
|
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(
|
virtual int DispatchEventBot(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Bot* bot,
|
Bot* bot,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
uint32 extra_data,
|
uint32 extra_data,
|
||||||
std::vector<std::any>* extra_pointers
|
std::vector<std::any>* extra_pointers
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void AddVar(std::string name, std::string val) { }
|
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 Init() { }
|
||||||
virtual void ReloadQuests() { }
|
virtual void ReloadQuests() { }
|
||||||
virtual uint32 GetIdentifier() = 0;
|
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());
|
quest_errors.insert(quest_errors.end(), errors_.begin(), errors_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void AddError(std::string error) {
|
virtual void AddError(std::string error)
|
||||||
|
{
|
||||||
LogQuests("{}", error);
|
LogQuests("{}", error);
|
||||||
LogQuestErrors("{}", Strings::Trim(error));
|
LogQuestErrors("{}", Strings::Trim(error));
|
||||||
|
|
||||||
errors_.push_back(error);
|
errors_.push_back(error);
|
||||||
|
|
||||||
if (errors_.size() > RuleI(World, MaximumQuestErrors)) {
|
if (errors_.size() > RuleI(World, MaximumQuestErrors)) {
|
||||||
errors_.pop_front();
|
errors_.pop_front();
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -60,32 +60,65 @@ public:
|
|||||||
~QuestParserCollection();
|
~QuestParserCollection();
|
||||||
|
|
||||||
void RegisterQuestInterface(QuestInterface* qi, std::string ext);
|
void RegisterQuestInterface(QuestInterface* qi, std::string ext);
|
||||||
void UnRegisterQuestInterface(QuestInterface *qi, std::string ext);
|
|
||||||
void ClearInterfaces();
|
void ClearInterfaces();
|
||||||
void AddVar(std::string name, std::string val);
|
void AddVar(std::string name, std::string val);
|
||||||
void Init();
|
void Init();
|
||||||
void ReloadQuests(bool reset_timers = true);
|
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 HasQuestSub(uint32 npc_id, QuestEventID event_id);
|
||||||
bool PlayerHasQuestSub(QuestEventID evt);
|
bool PlayerHasQuestSub(QuestEventID event_id);
|
||||||
bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
bool SpellHasQuestSub(uint32 spell_id, QuestEventID event_id);
|
||||||
bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
bool ItemHasQuestSub(EQ::ItemInstance* inst, QuestEventID event_id);
|
||||||
bool BotHasQuestSub(QuestEventID evt);
|
bool BotHasQuestSub(QuestEventID event_id);
|
||||||
|
|
||||||
int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
int EventNPC(
|
||||||
std::vector<std::any> *extra_pointers = nullptr);
|
QuestEventID event_id,
|
||||||
int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
NPC* npc,
|
||||||
std::vector<std::any> *extra_pointers = nullptr);
|
Mob* init,
|
||||||
int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
std::string data,
|
||||||
std::vector<std::any> *extra_pointers = nullptr);
|
uint32 extra_data,
|
||||||
int EventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
std::vector<std::any>* extra_pointers = nullptr
|
||||||
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 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(
|
int EventBot(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Bot *bot,
|
Bot *bot,
|
||||||
Mob *init,
|
Mob *init,
|
||||||
std::string data,
|
std::string data,
|
||||||
@ -117,32 +150,54 @@ public:
|
|||||||
void LoadPerlEventExportSettings(PerlEventExportSettings* s);
|
void LoadPerlEventExportSettings(PerlEventExportSettings* s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool HasQuestSubLocal(uint32 npcid, QuestEventID evt);
|
bool HasQuestSubLocal(uint32 npc_id, QuestEventID event_id);
|
||||||
bool HasQuestSubGlobal(QuestEventID evt);
|
bool HasQuestSubGlobal(QuestEventID event_id);
|
||||||
bool NPCHasEncounterSub(uint32 npc_id, QuestEventID evt);
|
bool NPCHasEncounterSub(uint32 npc_id, QuestEventID event_id);
|
||||||
bool PlayerHasQuestSubLocal(QuestEventID evt);
|
bool PlayerHasQuestSubLocal(QuestEventID event_id);
|
||||||
bool PlayerHasQuestSubGlobal(QuestEventID evt);
|
bool PlayerHasQuestSubGlobal(QuestEventID event_id);
|
||||||
bool PlayerHasEncounterSub(QuestEventID evt);
|
bool PlayerHasEncounterSub(QuestEventID event_id);
|
||||||
bool SpellHasEncounterSub(uint32 spell_id, QuestEventID evt);
|
bool SpellHasEncounterSub(uint32 spell_id, QuestEventID event_id);
|
||||||
bool ItemHasEncounterSub(EQ::ItemInstance* item, QuestEventID evt);
|
bool ItemHasEncounterSub(EQ::ItemInstance* inst, QuestEventID event_id);
|
||||||
bool HasEncounterSub(QuestEventID evt, const std::string& package_name);
|
bool HasEncounterSub(QuestEventID event_id, const std::string& package_name);
|
||||||
bool BotHasQuestSubLocal(QuestEventID evt);
|
bool BotHasQuestSubLocal(QuestEventID event_id);
|
||||||
bool BotHasQuestSubGlobal(QuestEventID evt);
|
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(
|
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,
|
|
||||||
Bot *bot,
|
Bot *bot,
|
||||||
Mob *init,
|
Mob *init,
|
||||||
std::string data,
|
std::string data,
|
||||||
@ -150,7 +205,16 @@ private:
|
|||||||
std::vector<std::any> *extra_pointers
|
std::vector<std::any> *extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
QuestInterface *GetQIByNPCQuest(uint32 npcid, std::string &filename);
|
int EventBotGlobal(
|
||||||
|
QuestEventID event_id,
|
||||||
|
Bot *bot,
|
||||||
|
Mob *init,
|
||||||
|
std::string data,
|
||||||
|
uint32 extra_data,
|
||||||
|
std::vector<std::any> *extra_pointers
|
||||||
|
);
|
||||||
|
|
||||||
|
QuestInterface* GetQIByNPCQuest(uint32 npc_id, std::string& filename);
|
||||||
QuestInterface* GetQIByGlobalNPCQuest(std::string& filename);
|
QuestInterface* GetQIByGlobalNPCQuest(std::string& filename);
|
||||||
QuestInterface* GetQIByPlayerQuest(std::string& filename);
|
QuestInterface* GetQIByPlayerQuest(std::string& filename);
|
||||||
QuestInterface* GetQIByGlobalPlayerQuest(std::string& filename);
|
QuestInterface* GetQIByGlobalPlayerQuest(std::string& filename);
|
||||||
@ -160,16 +224,45 @@ private:
|
|||||||
QuestInterface* GetQIByBotQuest(std::string& filename);
|
QuestInterface* GetQIByBotQuest(std::string& filename);
|
||||||
QuestInterface* GetQIByGlobalBotQuest(std::string& filename);
|
QuestInterface* GetQIByGlobalBotQuest(std::string& filename);
|
||||||
|
|
||||||
int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
int DispatchEventNPC(
|
||||||
std::vector<std::any> *extra_pointers);
|
QuestEventID event_id,
|
||||||
int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
NPC* npc,
|
||||||
std::vector<std::any> *extra_pointers);
|
Mob* init,
|
||||||
int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
std::string data,
|
||||||
std::vector<std::any> *extra_pointers);
|
uint32 extra_data,
|
||||||
int DispatchEventSpell(QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, 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(
|
int DispatchEventBot(
|
||||||
QuestEventID evt,
|
QuestEventID event_id,
|
||||||
Bot* bot,
|
Bot* bot,
|
||||||
Mob* init,
|
Mob* init,
|
||||||
std::string data,
|
std::string data,
|
||||||
@ -181,8 +274,6 @@ private:
|
|||||||
std::map<uint32, std::string> _extensions;
|
std::map<uint32, std::string> _extensions;
|
||||||
std::list<QuestInterface*> _load_precedence;
|
std::list<QuestInterface*> _load_precedence;
|
||||||
|
|
||||||
//0x00 = Unloaded
|
|
||||||
//0xFFFFFFFF = Failed to Load
|
|
||||||
std::map<uint32, uint32> _npc_quest_status;
|
std::map<uint32, uint32> _npc_quest_status;
|
||||||
uint32 _global_npc_quest_status;
|
uint32 _global_npc_quest_status;
|
||||||
uint32 _player_quest_status;
|
uint32 _player_quest_status;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user