mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Perl parser works, still needs a little cleanup
This commit is contained in:
parent
b6c0e7c302
commit
0e4ac63b6b
@ -51,9 +51,6 @@ Core Zone features
|
||||
//this seems to make perl very unhappy on reload, and crashes
|
||||
#define EMBPERL_IO_CAPTURE
|
||||
|
||||
//enable perl-based in-game command, pretty useless without EMBPERL_XS_CLASSES
|
||||
#define EMBPERL_COMMANDS
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@ -123,7 +123,6 @@ SET(zone_headers
|
||||
object.h
|
||||
pathing.h
|
||||
perlpacket.h
|
||||
perlparser.h
|
||||
petitions.h
|
||||
pets.h
|
||||
PlayerCorpse.h
|
||||
|
||||
@ -559,64 +559,6 @@ int command_add(const char *command_string, const char *desc, int access, CmdFun
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
/*
|
||||
* command_add_perl
|
||||
* adds a command to the command list, as a perl function
|
||||
*
|
||||
* Parameters:
|
||||
* command_string - the command ex: "spawn"
|
||||
* desc - text description of command for #help
|
||||
* access - default access level required to use command
|
||||
*
|
||||
*/
|
||||
int command_add_perl(const char *command_string, const char *desc, int access) {
|
||||
string cstr(command_string);
|
||||
|
||||
if(commandlist.count(cstr) != 0) {
|
||||
#ifdef COMMANDS_PERL_OVERRIDE
|
||||
//print a warning so people dont get too confused when this happens
|
||||
LogFile->write(EQEMuLog::Status, "command_add_perl() - Perl Command '%s' is overriding the compiled command." , command_string);
|
||||
CommandRecord *tmp = commandlist[cstr];
|
||||
safe_delete(tmp);
|
||||
#else
|
||||
LogFile->write(EQEMuLog::Error, "command_add_perl() - Command '%s' is a duplicate - check commands.pl." , command_string);
|
||||
return(-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
CommandRecord *c = new CommandRecord;
|
||||
c->desc = desc;
|
||||
c->access = access;
|
||||
c->function = nullptr;
|
||||
|
||||
commandlist[cstr] = c;
|
||||
|
||||
commandcount++;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//clear out any perl commands.
|
||||
//should restore any overridden C++ commands, but thats a lot of work.
|
||||
void command_clear_perl() {
|
||||
map<string, CommandRecord *>::iterator cur,end,del;
|
||||
cur = commandlist.begin();
|
||||
end = commandlist.end();
|
||||
for(; cur != end;) {
|
||||
del = cur;
|
||||
cur++;
|
||||
if(del->second->function == nullptr) {
|
||||
safe_delete(del->second);
|
||||
commandlist.erase(del);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //EMBPERL_COMMANDS
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* command_realdispatch
|
||||
@ -657,15 +599,8 @@ int command_realdispatch(Client *c, const char *message)
|
||||
#endif
|
||||
|
||||
if(cur->function == nullptr) {
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
//todo reimplement this stuff
|
||||
//dispatch perl command
|
||||
//PerlembParser *embparse = (PerlembParser *) parse;
|
||||
//embparse->ExecCommand(c, &sep);
|
||||
#else
|
||||
LogFile->write(EQEMuLog::Error, "Command '%s' has a null function, but perl commands are diabled!\n", cstr.c_str());
|
||||
LogFile->write(EQEMuLog::Error, "Command '%s' has a null function\n", cstr.c_str());
|
||||
return(-1);
|
||||
#endif
|
||||
} else {
|
||||
//dispatch C++ command
|
||||
cur->function(c, &sep); // dispatch command
|
||||
|
||||
@ -60,8 +60,6 @@ int command_add(const char *command_string, const char *desc, int access, CmdFun
|
||||
int command_notavail(Client *c, const char *message);
|
||||
int command_realdispatch(Client *c, char const *message);
|
||||
void command_logcommand(Client *c, const char *message);
|
||||
int command_add_perl(const char *command_string, const char *desc, int access);
|
||||
void command_clear_perl();
|
||||
|
||||
//commands
|
||||
void command_resetaa(Client* c,const Seperator *sep);
|
||||
|
||||
1820
zone/embparser.cpp
1820
zone/embparser.cpp
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@ class PerlembParser : public QuestInterface {
|
||||
typedef struct {
|
||||
QuestEventID event;
|
||||
uint32 objid;
|
||||
const char *data;
|
||||
std::string data;
|
||||
NPC* npcmob;
|
||||
ItemInst* iteminst;
|
||||
Mob* mob;
|
||||
@ -75,13 +75,37 @@ private:
|
||||
void SendCommands(const char *pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst);
|
||||
void MapFunctions();
|
||||
|
||||
void HandleQueue();
|
||||
void AddQueueEvent(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob,
|
||||
uint32 extradata, bool global);
|
||||
|
||||
void GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
||||
bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global);
|
||||
void GetQuestPackageName(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
||||
bool &isSpellQuest, std::string &package_name, QuestEventID event, uint32 objid, const char * data,
|
||||
NPC* npcmob, ItemInst* iteminst, bool global);
|
||||
void ExportCharID(const std::string &package_name, int &char_id, NPC *npcmob, Mob *mob);
|
||||
void ExportQGlobals(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
||||
bool isSpellQuest, std::string &package_name, NPC *npcmob, Mob *mob, int char_id);
|
||||
void ExportMobVariables(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
||||
bool isSpellQuest, std::string &package_name, Mob *mob, NPC *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,
|
||||
NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata);
|
||||
|
||||
std::map<uint32, PerlQuestStatus> npc_quest_status_;
|
||||
PerlQuestStatus global_npc_quest_status_;
|
||||
PerlQuestStatus player_quest_status_;
|
||||
PerlQuestStatus global_player_quest_status_;
|
||||
std::map<std::string, PerlQuestStatus> item_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_;
|
||||
SV *_empty_sv;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -245,9 +269,6 @@ private:
|
||||
//
|
||||
// int HasQuestFile(uint32 npcid);
|
||||
//
|
||||
//#ifdef EMBPERL_COMMANDS
|
||||
// void ExecCommand(Client *c, Seperator *sep);
|
||||
//#endif
|
||||
//
|
||||
//};
|
||||
//
|
||||
|
||||
101
zone/embperl.cpp
101
zone/embperl.cpp
@ -21,26 +21,22 @@ Eglin
|
||||
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
|
||||
#endif
|
||||
|
||||
//PERL_TODO:
|
||||
//#ifdef EMBPERL_XS
|
||||
//EXTERN_C XS(boot_quest);
|
||||
//#ifdef EMBPERL_XS_CLASSES
|
||||
//EXTERN_C XS(boot_Mob);
|
||||
//EXTERN_C XS(boot_NPC);
|
||||
//EXTERN_C XS(boot_Client);
|
||||
//EXTERN_C XS(boot_Corpse);
|
||||
//EXTERN_C XS(boot_EntityList);
|
||||
//EXTERN_C XS(boot_Group);
|
||||
//EXTERN_C XS(boot_Raid);
|
||||
//EXTERN_C XS(boot_QuestItem);
|
||||
//EXTERN_C XS(boot_HateEntry);
|
||||
//EXTERN_C XS(boot_Object);
|
||||
//EXTERN_C XS(boot_Doors);
|
||||
//EXTERN_C XS(boot_PerlPacket);
|
||||
//#endif
|
||||
//#endif
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
XS(XS_command_add);
|
||||
#ifdef EMBPERL_XS
|
||||
EXTERN_C XS(boot_quest);
|
||||
#ifdef EMBPERL_XS_CLASSES
|
||||
EXTERN_C XS(boot_Mob);
|
||||
EXTERN_C XS(boot_NPC);
|
||||
EXTERN_C XS(boot_Client);
|
||||
EXTERN_C XS(boot_Corpse);
|
||||
EXTERN_C XS(boot_EntityList);
|
||||
EXTERN_C XS(boot_Group);
|
||||
EXTERN_C XS(boot_Raid);
|
||||
EXTERN_C XS(boot_QuestItem);
|
||||
EXTERN_C XS(boot_HateEntry);
|
||||
EXTERN_C XS(boot_Object);
|
||||
EXTERN_C XS(boot_Doors);
|
||||
EXTERN_C XS(boot_PerlPacket);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
@ -61,33 +57,26 @@ EXTERN_C void xs_init(pTHX)
|
||||
|
||||
newXS(strcpy(buf, "DynaLoader::boot_DynaLoader"), boot_DynaLoader, file);
|
||||
newXS(strcpy(buf, "quest::boot_qc"), boot_qc, file);
|
||||
//PERL_TODO:
|
||||
//#ifdef EMBPERL_XS
|
||||
// newXS(strcpy(buf, "quest::boot_quest"), boot_quest, file);
|
||||
//#ifdef EMBPERL_XS_CLASSES
|
||||
// newXS(strcpy(buf, "Mob::boot_Mob"), boot_Mob, file);
|
||||
// newXS(strcpy(buf, "NPC::boot_Mob"), boot_Mob, file);
|
||||
// newXS(strcpy(buf, "NPC::boot_NPC"), boot_NPC, file);
|
||||
///// newXS(strcpy(buf, "NPC::new"), XS_NPC_new, file);
|
||||
// newXS(strcpy(buf, "Corpse::boot_Mob"), boot_Mob, file);
|
||||
// newXS(strcpy(buf, "Corpse::boot_Corpse"), boot_Corpse, file);
|
||||
// newXS(strcpy(buf, "Client::boot_Mob"), boot_Mob, file);
|
||||
// newXS(strcpy(buf, "Client::boot_Client"), boot_Client, file);
|
||||
//// newXS(strcpy(buf, "Client::new"), XS_Client_new, file);
|
||||
// newXS(strcpy(buf, "EntityList::boot_EntityList"), boot_EntityList, file);
|
||||
//// newXS(strcpy(buf, "EntityList::new"), XS_EntityList_new, file);
|
||||
// newXS(strcpy(buf, "PerlPacket::boot_PerlPacket"), boot_PerlPacket, file);
|
||||
// newXS(strcpy(buf, "Group::boot_Group"), boot_Group, file);
|
||||
// newXS(strcpy(buf, "Raid::boot_Raid"), boot_Raid, file);
|
||||
// newXS(strcpy(buf, "QuestItem::boot_QuestItem"), boot_QuestItem, file);
|
||||
// newXS(strcpy(buf, "HateEntry::boot_HateEntry"), boot_HateEntry, file);
|
||||
// newXS(strcpy(buf, "Object::boot_Object"), boot_Object, file);
|
||||
// newXS(strcpy(buf, "Doors::boot_Doors"), boot_Doors, file);
|
||||
//;
|
||||
//#endif
|
||||
//#endif
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
newXS(strcpy(buf, "commands::command_add"), XS_command_add, file);
|
||||
#ifdef EMBPERL_XS
|
||||
newXS(strcpy(buf, "quest::boot_quest"), boot_quest, file);
|
||||
#ifdef EMBPERL_XS_CLASSES
|
||||
newXS(strcpy(buf, "Mob::boot_Mob"), boot_Mob, file);
|
||||
newXS(strcpy(buf, "NPC::boot_Mob"), boot_Mob, file);
|
||||
newXS(strcpy(buf, "NPC::boot_NPC"), boot_NPC, file);
|
||||
newXS(strcpy(buf, "Corpse::boot_Mob"), boot_Mob, file);
|
||||
newXS(strcpy(buf, "Corpse::boot_Corpse"), boot_Corpse, file);
|
||||
newXS(strcpy(buf, "Client::boot_Mob"), boot_Mob, file);
|
||||
newXS(strcpy(buf, "Client::boot_Client"), boot_Client, file);
|
||||
newXS(strcpy(buf, "EntityList::boot_EntityList"), boot_EntityList, file);
|
||||
newXS(strcpy(buf, "PerlPacket::boot_PerlPacket"), boot_PerlPacket, file);
|
||||
newXS(strcpy(buf, "Group::boot_Group"), boot_Group, file);
|
||||
newXS(strcpy(buf, "Raid::boot_Raid"), boot_Raid, file);
|
||||
newXS(strcpy(buf, "QuestItem::boot_QuestItem"), boot_QuestItem, file);
|
||||
newXS(strcpy(buf, "HateEntry::boot_HateEntry"), boot_HateEntry, file);
|
||||
newXS(strcpy(buf, "Object::boot_Object"), boot_Object, file);
|
||||
newXS(strcpy(buf, "Doors::boot_Doors"), boot_Doors, file);
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EMBPERL_IO_CAPTURE
|
||||
newXS(strcpy(buf, "EQEmuIO::PRINT"), XS_EQEmuIO_PRINT, file);
|
||||
@ -161,14 +150,13 @@ void Embperl::DoInit() {
|
||||
//make a tieable class to capture IO and pass it into EQEMuLog
|
||||
eval_pv(
|
||||
"package EQEmuIO; "
|
||||
// "&boot_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
|
||||
//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); }"
|
||||
@ -211,21 +199,6 @@ void Embperl::DoInit() {
|
||||
LogFile->write(EQEMuLog::Quest, "Perl warning: %s", err);
|
||||
}
|
||||
#endif //EMBPERL_PLUGIN
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
LogFile->write(EQEMuLog::Quest, "Loading perl commands...");
|
||||
try
|
||||
{
|
||||
eval_pv(
|
||||
"package commands;"
|
||||
"main::eval_file('commands', 'commands.pl');"
|
||||
"&commands::commands_init();"
|
||||
, FALSE);
|
||||
}
|
||||
catch(const char *err)
|
||||
{
|
||||
LogFile->write(EQEMuLog::Quest, "Warning - commands.pl: %s", err);
|
||||
}
|
||||
#endif //EMBPERL_COMMANDS
|
||||
in_use = false;
|
||||
}
|
||||
|
||||
|
||||
@ -112,25 +112,4 @@ XS(XS_EQEmuIO_PRINT)
|
||||
}
|
||||
#endif //EMBPERL_IO_CAPTURE
|
||||
|
||||
|
||||
#ifdef EMBPERL_COMMANDS
|
||||
|
||||
XS(XS_command_add); /* prototype to pass -Wmissing-prototypes */
|
||||
XS(XS_command_add)
|
||||
{
|
||||
dXSARGS;
|
||||
if (items != 3)
|
||||
Perl_croak(aTHX_ "Usage: commands::command_add(name, desc, access)");
|
||||
|
||||
char *name = SvPV_nolen(ST(0));
|
||||
char *desc = SvPV_nolen(ST(1));
|
||||
int access = (int)SvIV(ST(2));
|
||||
|
||||
command_add_perl(name, desc, access);
|
||||
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
#endif //EMBPERL_COMMANDS
|
||||
|
||||
#endif // EMBPERL
|
||||
|
||||
7285
zone/perlparser.cpp
7285
zone/perlparser.cpp
File diff suppressed because it is too large
Load Diff
@ -1,46 +1 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.org)
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
//extends the perl parser to use C methods
|
||||
//instead of the command queue.
|
||||
|
||||
//#ifndef PERLPARSER_H
|
||||
//#define PERLPARSER_H
|
||||
//
|
||||
//#ifdef EMBPERL
|
||||
//#ifdef EMBPERL_XS
|
||||
//
|
||||
//#include "embparser.h"
|
||||
//
|
||||
//class PerlXSParser : public PerlembParser {
|
||||
//public:
|
||||
// PerlXSParser();
|
||||
//// ~PerlXSParser();
|
||||
//
|
||||
// virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst);
|
||||
//protected:
|
||||
// void map_funs();
|
||||
//
|
||||
// SV *_empty_sv;
|
||||
//};
|
||||
//
|
||||
//
|
||||
//#endif //EMBPERL_XS
|
||||
//#endif //EMBPERL
|
||||
//
|
||||
//#endif //PERLPARSER_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user