Cleanup perl parsers

This commit is contained in:
KimLS 2013-05-09 21:25:50 -07:00
parent 0e4ac63b6b
commit 43d0350870
11 changed files with 806 additions and 2715 deletions

View File

@ -17,6 +17,7 @@ SET(zone_sources
doors.cpp doors.cpp
effects.cpp effects.cpp
embparser.cpp embparser.cpp
embparser_api.cpp
embperl.cpp embperl.cpp
embxs.cpp embxs.cpp
entity.cpp entity.cpp
@ -53,7 +54,6 @@ SET(zone_sources
perl_questitem.cpp perl_questitem.cpp
perl_raids.cpp perl_raids.cpp
perlpacket.cpp perlpacket.cpp
perlparser.cpp
petitions.cpp petitions.cpp
pets.cpp pets.cpp
PlayerCorpse.cpp PlayerCorpse.cpp

View File

@ -1,3 +1,21 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQE_QUESTINTERFACE_H #ifndef _EQE_QUESTINTERFACE_H
#define _EQE_QUESTINTERFACE_H #define _EQE_QUESTINTERFACE_H

View File

@ -1,10 +1,27 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/MiscFunctions.h" #include "../common/MiscFunctions.h"
#include "../common/features.h" #include "../common/features.h"
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include "QuestInterface.h" #include "QuestInterface.h"
#include "zone.h" #include "zone.h"
#include "zonedb.h"
#include "questmgr.h" #include "questmgr.h"
#include <stdio.h> #include <stdio.h>

View File

@ -1,16 +1,35 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQE_QUESTPARSERCOLLECTION_H #ifndef _EQE_QUESTPARSERCOLLECTION_H
#define _EQE_QUESTPARSERCOLLECTION_H #define _EQE_QUESTPARSERCOLLECTION_H
#include "../common/types.h" #include "../common/types.h"
#include "../common/Item.h"
#include "masterentity.h"
#include "QuestInterface.h"
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
#include "masterentity.h"
#include "../common/Item.h"
#include "QuestInterface.h"
#define QuestFailedToLoad 0xFFFFFFFF #define QuestFailedToLoad 0xFFFFFFFF
#define QuestUnloaded 0x00 #define QuestUnloaded 0x00

View File

@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -16,16 +16,15 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef EMBPERL #ifdef EMBPERL
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/seperator.h"
#include "../common/MiscFunctions.h"
#include "../common/features.h"
#include "masterentity.h" #include "masterentity.h"
#include "embparser.h" #include "embparser.h"
#include "questmgr.h" #include "questmgr.h"
#include "command.h"
#include "../common/seperator.h"
#include "../common/MiscFunctions.h"
#include "QGlobals.h" #include "QGlobals.h"
#include "zone.h" #include "zone.h"
#include <algorithm> #include <algorithm>

View File

@ -1,17 +1,37 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQEMU_EMBPARSER_H #ifndef EQEMU_EMBPARSER_H
#define EQMEU_EMBPARSER_H #define EQMEU_EMBPARSER_H
#ifdef EMBPERL #ifdef EMBPERL
#include "client.h"
#include "../common/features.h"
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include "QuestInterface.h" #include "QuestInterface.h"
#include <string> #include <string>
#include <map>
#include <queue> #include <queue>
#include <map>
#include "embperl.h" #include "embperl.h"
class ItemInst;
class Mob;
class Client;
class NPC;
typedef enum typedef enum
{ {
questUnloaded, questUnloaded,
@ -111,167 +131,3 @@ private:
#endif #endif
#endif #endif
////extends the parser to include perl
////Eglin
//
//#ifndef EMBPARSER_H
//#define EMBPARSER_H
//
//#ifdef EMBPERL
//
//#include "client.h"
//#include "parser.h"
//#include "embperl.h"
//#include "../common/features.h"
//#include "QuestParserCollection.h"
//#include "QuestInterface.h"
//
//#include <string>
//#include <map>
//#include <queue>
//using namespace std;
//
//class Seperator;
//
//typedef enum {
// questDefault = 1,
// questDefaultByZone,
// questByName,
// questTemplate,
// questTemplateByID,
// questByID
//} questMode;
//
//typedef enum {
// itemQuestUnloaded = 1,
// itemQuestScale,
// itemQuestLore,
// itemQuestID,
// itemScriptFileID
//} itemQuestMode;
//
//typedef enum {
// pQuestLoaded = 1,
// pQuestUnloaded,
// pQuestEventCast, // player.pl loaded, has an EVENT_CAST sub
// pQuestReadyToLoad
//} playerQuestMode;
//
//typedef enum {
// nQuestLoaded = 1,
// nQuestUnloaded,
// nQuestReadyToLoad
//} GlobalNPCQuestMode;
//
//typedef enum {
// spellQuestUnloaded = 1,
// spellQuestFullyLoaded,
// spellQuestFailed
//} spellQuestMode;
//
//
//struct EventRecord {
// QuestEventID event;
// uint32 objid;
// string data;
// NPC* npcmob;
// ItemInst* iteminst;
// Mob* mob;
// uint32 extradata;
// bool global;
//};
//
//class PerlembParser : public Parser
//{
//protected:
//
// //could prolly get rid of this map now, since I check for the
// //actual subroutine in the quest package as opposed to just seeing
// //if they do not have a quest or the default.
// map<uint32, questMode> hasQuests; //npcid -> questMode
// map<std::string, playerQuestMode> playerQuestLoaded; //zone shortname -> playerQuestMode
// playerQuestMode globalPlayerQuestLoaded;
// GlobalNPCQuestMode globalNPCQuestLoaded;
// map<std::string, itemQuestMode> itemQuestLoaded; // package name - > itemQuestMode
// map<uint32, spellQuestMode> spellQuestLoaded;
//
// queue<EventRecord> eventQueue; //for events that happen when perl is in use.
// bool eventQueueProcessing;
//
// void HandleQueue();
//
// void EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global = false);
//
// Embperl * perl;
// //export a symbol table of sorts
// virtual void map_funs();
//public:
// PerlembParser(void);
// ~PerlembParser();
// Embperl * getperl(void) { return perl; };
// //todo, consider making the following two methods static (need to check for perl!=null, first, then)
// bool isloaded(const char *packagename) const;
//
// //interface stuff
// virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
// virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
// virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
// virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
// virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
// virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
//
// virtual bool HasQuestSub(uint32 npcid, const char *subname);
// virtual bool HasGlobalQuestSub(const char *subname);
// virtual bool PlayerHasQuestSub(const char *subname);
// virtual bool GlobalPlayerHasQuestSub(const char *subname);
// virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname);
// virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname);
//
// virtual void ReloadQuests(bool with_timers = false);
// virtual void AddVar(std::string name, std::string val) { Parser::AddVar(name, val); };
// virtual uint32 GetIdentifier() { return 0xf8b05c11; }
//
// virtual void LoadNPCScript(std::string filename, int npc_id);
// virtual void LoadGlobalNPCScript(std::string filename);
// virtual void LoadPlayerScript(std::string filename);
// virtual void LoadGlobalPlayerScript(std::string filename);
// virtual void LoadItemScript(std::string filename, std::string item_script);
// virtual void LoadSpellScript(std::string filename, uint32 spell_id);
//
// //int LoadScript(int npcid, const char * zone, Mob* activater=0);
// //int LoadGlobalNPCScript();
// //int LoadPlayerScript(const char *zone);
// //int LoadGlobalPlayerScript();
// //int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype);
// //int LoadSpellScript(uint32 id);
//
// //expose a var to the script (probably parallels addvar))
// //i.e. exportvar("qst1234", "name", "somemob");
// //would expose the variable $name='somemob' to the script that handles npc1234
// void ExportHash(const char *pkgprefix, const char *hashname, std::map<string,string> &vals);
// void ExportVar(const char * pkgprefix, const char * varname, const char * value) const;
// void ExportVar(const char * pkgprefix, const char * varname, int value) const;
// void ExportVar(const char * pkgprefix, const char * varname, unsigned int value) const;
// void ExportVar(const char * pkgprefix, const char * varname, float value) const;
// //I don't escape the strings, so use caution!!
// //Same as export var, except value is not quoted, and is evaluated as perl
// void ExportVarComplex(const char * pkgprefix, const char * varname, const char * value) const;
//
// //get an appropriate namespage/packagename from an npcid
// std::string GetPkgPrefix(uint32 npcid, bool defaultOK = true);
// //call the appropriate perl handler. afterwards, parse and dispatch the command queue
// //SendCommands("qst1234", "EVENT_SAY") would trigger sub EVENT_SAY() from the qst1234.pl file
// virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst);
//
// int HasQuestFile(uint32 npcid);
//
//
//};
//
//#endif //EMBPERL
//
//#endif //EMBPARSER_H

View File

@ -22,12 +22,13 @@
#ifdef EMBPERL_XS #ifdef EMBPERL_XS
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/MiscFunctions.h"
#include "embparser.h" #include "embparser.h"
#include "questmgr.h" #include "questmgr.h"
#include "embxs.h" #include "embxs.h"
#include "entity.h" #include "entity.h"
#include "../common/MiscFunctions.h"
#include "zone.h" #include "zone.h"
extern Zone* zone; extern Zone* zone;
/* /*

View File

@ -54,7 +54,6 @@ extern volatile bool ZoneLoaded;
#include "../common/Mutex.h" #include "../common/Mutex.h"
#include "../common/version.h" #include "../common/version.h"
#include "../common/EQEMuError.h" #include "../common/EQEMuError.h"
#include "ZoneConfig.h"
#include "../common/packet_dump_file.h" #include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/guilds.h" #include "../common/guilds.h"
@ -67,22 +66,23 @@ extern volatile bool ZoneLoaded;
#include "../common/ipc_mutex.h" #include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h" #include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h" #include "../common/eqemu_exception.h"
#include "../common/spdat.h"
#include "masterentity.h" #include "masterentity.h"
#include "worldserver.h" #include "worldserver.h"
#include "net.h" #include "net.h"
#include "../common/spdat.h"
#include "zone.h" #include "zone.h"
#include "command.h" #include "command.h"
#include "embparser.h" #include "ZoneConfig.h"
#include "perlparser.h"
#include "lua_parser.h"
#include "client_logs.h"
#include "questmgr.h"
#include "titles.h" #include "titles.h"
#include "guild_mgr.h" #include "guild_mgr.h"
#include "tasks.h" #include "tasks.h"
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include "embparser.h"
#include "lua_parser.h"
#include "client_logs.h"
#include "questmgr.h"
TimeoutManager timeout_manager; TimeoutManager timeout_manager;
NetConnection net; NetConnection net;

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
#ifndef PARSER_H
#define PARSER_H
#define Parser_MaxVars 1024
#include "../common/timer.h"
#include <string>
#include <list>
#include "event_codes.h"
#include "QuestInterface.h"
struct EventList {
std::string event;
std::string command;
};
struct Events {
uint32 npcid;
std::list<EventList*> Event;
};
struct Alias {
int index;
uint32 npcid;
char name[100][100];
char command[100][1024];
};
struct vars {
std::string name;
std::string value;
};
struct command_list {
char command_name[100];
int param_amount[17];
};
class Parser : public QuestInterface
{
public:
Parser();
virtual ~Parser();
int mindex;
const std::string DEFAULT_QUEST_PREFIX;
typedef list<Events*>::iterator iter_events;
typedef list<EventList*>::iterator iter_eventlist;
std::list<Events*> MainList;
std::list<vars*> varlist;
std::list<Alias*> AliasList;
uint32 npcarrayindex;
uint32 AddNPCQuestID(uint32 npcid);
uint32 FindNPCQuestID(int32 npcid);
int CheckAliases(const char * alias, uint32 npcid, Mob* npcmob, Mob* mob);
void ClearAliasesByNPCID(uint32 iNPCID);
void ClearCache();
void ClearEventsByNPCID(uint32 iNPCID);
void DelChatAndItemVars(uint32 npcid);
void DeleteVar(std::string name);
void ExCommands(std::string command, std::string parms, int argnums, uint32 npcid, Mob* other, Mob* mob );
void GetCommandName(char * command1, char * arg);
int GetFreeID();
int GetItemCount(std::string itemid, uint32 npcid);
int32 GetNPCqstID(uint32 iNPCID);
std::string GetVar(std::string varname, uint32 npcid);
void HandleVars(std::string varname, std::string varparms, std::string& origstring, std::string format, uint32 npcid, Mob* mob);
bool LoadAttempted(uint32 iNPCID);
void LoadCommands(const char * filename);
virtual int LoadScript(int npcid, const char * zone, Mob* activater=0);
void MakeParms(const char * string, uint32 npcid);
void MakeVars(std::string text, uint32 npcid);
int numtok(const char *text, char character);
int ParseCommands(std::string text, int line, int justcheck, uint32 npcid, Mob* other, Mob* mob, std::string filename=string("none"));
int ParseIf(std::string text);
int pcalc(const char * string);
void ParseVars(std::string& text, uint32 npcid, Mob* mob);
void Replace(std::string& string1, std::string repstr, std::string rep, int all=0);
void scanformat(char *string, const char *format, char arg[10][1024]);
bool SetNPCqstID(uint32 iNPCID, int32 iValue);
char * strrstr(char* string, const char * sub);
virtual void SendCommands(const char * event, uint32 npcid, NPC* npcmob, Mob* mob);
int HasQuestFile(uint32 npcid);
//interface stuff
virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {}
virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {}
virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {}
virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {}
virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {}
virtual bool HasQuestSub(uint32 npcid, const char *subname) { return HasQuestFile(npcid) != 0; }
virtual bool PlayerHasQuestSub(const char *subname) { return true; }
virtual bool GlobalPlayerHasQuestSub(const char *subname) { return true; }
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname) { return true; }
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname) { return true; }
virtual void AddVar(std::string varname, std::string varval);
virtual void ReloadQuests(bool with_timers = false);
virtual uint32 GetIdentifier() { return 0x04629fff; }
private:
//void Event(int event, uint32 npcid, const char * data, Mob* npcmob, Mob* mob);
//changed - Eglin. more reasonable (IMHO) than changing every single referance to the global pointer.
//that's what you get for using globals! :)
virtual void Event(QuestEventID event, uint32 npcid, const char * data, NPC* npcmob, Mob* mob, uint32 extradata = 0);
uint32 pMaxNPCID;
int32* pNPCqstID;
};
#endif

View File

@ -1 +0,0 @@