Removed quest queue from perl parser, should do events properly recursively

This commit is contained in:
KimLS 2013-07-05 01:46:24 -07:00
parent 9a63ee65c9
commit b11ed32bcf
3 changed files with 2 additions and 75 deletions

View File

@ -114,7 +114,7 @@ const char *QuestEventSubroutines[_LargestEventID] = {
"EVENT_DEATH_COMPLETE" "EVENT_DEATH_COMPLETE"
}; };
PerlembParser::PerlembParser() : perl(nullptr), event_queue_in_use_(false) { PerlembParser::PerlembParser() : perl(nullptr) {
global_npc_quest_status_ = questUnloaded; global_npc_quest_status_ = questUnloaded;
player_quest_status_ = questUnloaded; player_quest_status_ = questUnloaded;
global_player_quest_status_ = questUnloaded; global_player_quest_status_ = questUnloaded;
@ -161,11 +161,6 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d
if(event >= _LargestEventID) if(event >= _LargestEventID)
return; return;
if(perl->InUse()) {
AddQueueEvent(event, objid, data, npcmob, iteminst, mob, extradata, global, extra_pointers);
return;
}
bool isPlayerQuest = false; bool isPlayerQuest = false;
bool isGlobalPlayerQuest = false; bool isGlobalPlayerQuest = false;
bool isGlobalNPC = false; bool isGlobalNPC = false;
@ -212,8 +207,6 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d
else { else {
SendCommands(package_name.c_str(), sub_name, objid, npcmob, mob, nullptr); SendCommands(package_name.c_str(), sub_name, objid, npcmob, mob, nullptr);
} }
HandleQueue();
} }
int PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, int PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
@ -762,48 +755,6 @@ void PerlembParser::MapFunctions() {
); );
} }
void PerlembParser::HandleQueue() {
if(event_queue_in_use_)
return;
event_queue_in_use_ = true;
while(!event_queue_.empty()) {
EventRecord e = event_queue_.front();
event_queue_.pop();
EventCommon(e.event, e.objid, e.data.c_str(), e.npcmob, e.iteminst, e.mob, e.extradata, e.global, &e.extra_pointers);
for(size_t i = 0; i < e.extra_pointers.size(); ++i) {
delete e.extra_pointers[i];
}
}
event_queue_in_use_ = false;
}
void PerlembParser::AddQueueEvent(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob,
uint32 extradata, bool global, std::vector<void*> *extra_pointers)
{
EventRecord e;
e.event = event;
e.objid = objid;
e.data = data;
e.npcmob = npcmob;
e.iteminst = iteminst;
e.mob = mob;
e.extradata = extradata;
e.global = global;
if(extra_pointers) {
for(size_t i = 0; i < extra_pointers->size(); ++i) {
e.extra_pointers.push_back(reinterpret_cast<ItemInst*>(extra_pointers->at(i))->Clone());
}
}
event_queue_.push(e);
}
void PerlembParser::GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest, void PerlembParser::GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global) bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global)
{ {

View File

@ -40,18 +40,6 @@ typedef enum
} PerlQuestStatus; } PerlQuestStatus;
class PerlembParser : public QuestInterface { class PerlembParser : public QuestInterface {
typedef struct {
QuestEventID event;
uint32 objid;
std::string data;
NPC* npcmob;
ItemInst* iteminst;
Mob* mob;
uint32 extradata;
bool global;
std::vector<void*> extra_pointers;
} EventRecord;
public: public:
PerlembParser(); PerlembParser();
~PerlembParser(); ~PerlembParser();
@ -102,10 +90,6 @@ private:
void SendCommands(const char *pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst *iteminst); void SendCommands(const char *pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst *iteminst);
void MapFunctions(); void MapFunctions();
void HandleQueue();
void AddQueueEvent(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob,
uint32 extradata, bool global, std::vector<void*> *extra_pointers);
void GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest, void GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global); bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global);
void GetQuestPackageName(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest, void GetQuestPackageName(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
@ -128,9 +112,6 @@ private:
std::map<uint32, PerlQuestStatus> item_quest_status_; std::map<uint32, PerlQuestStatus> item_quest_status_;
std::map<uint32, PerlQuestStatus> spell_quest_status_; std::map<uint32, PerlQuestStatus> spell_quest_status_;
bool event_queue_in_use_;
std::queue<EventRecord> event_queue_;
std::map<std::string, std::string> vars_; std::map<std::string, std::string> vars_;
SV *_empty_sv; SV *_empty_sv;
}; };

View File

@ -259,12 +259,7 @@ void Embperl::eval_file(const char * packagename, const char * filename)
} }
void Embperl::dosub(const char * subname, const std::vector<std::string> * args, int mode) void Embperl::dosub(const char * subname, const std::vector<std::string> * args, int mode)
{//as seen in perlembed docs {
#if EQDEBUG >= 5
if(InUse()) {
LogFile->write(EQEMuLog::Debug, "Warning: Perl dosub called for %s when perl is allready in use.\n", subname);
}
#endif
in_use = true; in_use = true;
bool err = false; bool err = false;
dSP; /* initialize stack pointer */ dSP; /* initialize stack pointer */