diff --git a/bin/conf/PseuWoW.conf.default b/bin/conf/PseuWoW.conf.default new file mode 100644 index 0000000..118e553 --- /dev/null +++ b/bin/conf/PseuWoW.conf.default @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////// +// PseuWoW config file +// +// still under development :D +/////////////////////////////////////////////////////////////////////////// +// +// use // for comments (C++ style) + +// its important to read & store the main conf variables UPPERCASED!! +[#uppercase] +[#noprefix] + +// 3=max, 0=no debug output +debug=0 + +// defines if the program should quit on error/exception or stay opened (for debugging) +exitonerror=0 + +// reconnect on failure/disconnect +reconnect=0 + +// 0 - show none +// 1 - show only known/handled +// 2 - show only unknown/unhandled +// 3 - show all +showopcodes=3 + + +// the IP or hostname the wow server is running on +realmlist=localhost + +// port on which the realm server is listening (default=3724) +realmport=3724 + +// PseuWoW will login on this realm +realmname=My WoW Realm + +// your account name +accname=test + +// your account password +accpass=test + +// the character name PseuWoW should choose to enter the world +charname=PseuWoW + + +// Client emulation configuration +ClientVersion=1.12.1 +ClientBuild=5875 +ClientLanguage=enUS +// or change to enGB, deDE, ... + + +// packets get fetched every xx msecs. default=50 +// setting this to 0 will let PseuWoW eat up all CPU power +// 1 is a good setting for maximum network performance and lowest ping times +NetworkSleepTime=50 + + diff --git a/bin/conf/todo.txt b/bin/conf/todo.txt new file mode 100644 index 0000000..de927d4 --- /dev/null +++ b/bin/conf/todo.txt @@ -0,0 +1 @@ +RENAME or COPY *.conf.default to *.conf and modify it to your needs. \ No newline at end of file diff --git a/bin/conf/users.conf.default b/bin/conf/users.conf.default new file mode 100644 index 0000000..4986202 --- /dev/null +++ b/bin/conf/users.conf.default @@ -0,0 +1,18 @@ +///////////////////////////////////////////////////////////// +// Player Permission Configuration file +///////////////////////////////////////////////////////////// +// Permission reaches from 0 to 255 + +[USERS] + +Gamemaster=100 +Admin=255 +Trusted=30 +Niceplayer=10 +Falsegenesis=150 +//... +// Add your names here + + + +// rest is 0 automatically \ No newline at end of file diff --git a/bin/scripts/_enterworld.def b/bin/scripts/_enterworld.def new file mode 100644 index 0000000..88dd6ab --- /dev/null +++ b/bin/scripts/_enterworld.def @@ -0,0 +1,28 @@ +#permission=255 + +// PSEUWOW DEF_SCRIPT WORLD-ENTER FILE + +OUT * World entered, executing appropriate script... + +// not yet implemented +// CASTSPELL 836 + +// yaay we are online +EMOTE 5 + +// MaNGOS: make PseuWoW invincible +SAY .gmon + +// you can also teleport on every startup to a certain player... +// simple: use the .goname command as usual. +// SAY .goname Gamemaster + +// to know everything worked fine, etc +SAY [${@version_short}] login successful. + + +// add your own stuff here +// ... + + +OUT * finished executing script. \ No newline at end of file diff --git a/bin/scripts/_onwhisper.def b/bin/scripts/_onwhisper.def new file mode 100644 index 0000000..c6c2454 --- /dev/null +++ b/bin/scripts/_onwhisper.def @@ -0,0 +1,6 @@ +#permission=255 + +// EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED + + +REPLY No need to whisper me, i am not yet programmed for it! \ No newline at end of file diff --git a/bin/scripts/_startup.def b/bin/scripts/_startup.def new file mode 100644 index 0000000..9d9f204 --- /dev/null +++ b/bin/scripts/_startup.def @@ -0,0 +1,33 @@ +#permission=255 + + +// PSEUWOW DEF_SCRIPT STARTUP FILE + +OUT * DefScript StartUp [${@version_short}]... + +// preload the script here, however its not important to load it now. it will get +// loaded automatically if needed +loaddef _enterworld +loaddef _onwhisper +loaddef _nopermission +loaddef _setconf +loaddef yell +loaddef say +loaddef whisper +loaddef outv +loaddef sayv +loaddef reply +loaddef quit +// ... + +// remove dangerous variables +OUT * Cleaning up variables... +UNSET #ACCPASS +UNSET #ACCNAME +OUT * Dangerous variables removed. + + +// do more stuff here in future... + +OUT * StartUp complete! + diff --git a/bin/scripts/reply.def b/bin/scripts/reply.def new file mode 100644 index 0000000..dce5c42 --- /dev/null +++ b/bin/scripts/reply.def @@ -0,0 +1,11 @@ +#permission=255 + +SET,player ${@thiswhisper_name} +SET,lang ${@thiswhisper_lang} +SET,msg ${@def} + +WHISPER,{${player}},{${lang}} ${msg} + +UNSET player +UNSET lang +UNSET msg \ No newline at end of file diff --git a/bin/scripts/say.def b/bin/scripts/say.def new file mode 100644 index 0000000..9b4e233 --- /dev/null +++ b/bin/scripts/say.def @@ -0,0 +1,12 @@ +#permission=255 +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +OUT * Saying '${msg}' in lang ${lang} + +SENDCHATMESSAGE,0,${lang},{${msg}} +UNSET lang +UNSET msg \ No newline at end of file diff --git a/bin/scripts/whisper.def b/bin/scripts/whisper.def new file mode 100644 index 0000000..0ecc2c1 --- /dev/null +++ b/bin/scripts/whisper.def @@ -0,0 +1,15 @@ +#permissionn=255 + +// setup some default values +SET,msg ${@def} +SET,player ${@0} +SET,lang ${@1} + +DEFAULT,lang 0 + +OUT * Whisp to '{${player}}' '{${msg}}' in lang '${lang}' + +SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}} +UNSET lang +UNSET msg +UNSET player \ No newline at end of file diff --git a/bin/scripts/yell.def b/bin/scripts/yell.def new file mode 100644 index 0000000..81a7c9f --- /dev/null +++ b/bin/scripts/yell.def @@ -0,0 +1,13 @@ +#permission=255 + +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +OUT * Yelling '${msg}' in lang ${lang} + +SENDCHATMESSAGE,5,${lang},{${msg}} +UNSET lang +UNSET msg diff --git a/src/Client/DefScript/DefScript.cpp b/src/Client/DefScript/DefScript.cpp index 2035cbf..978bc73 100644 --- a/src/Client/DefScript/DefScript.cpp +++ b/src/Client/DefScript/DefScript.cpp @@ -7,26 +7,15 @@ #include "VarSet.h" #include "DefScript.h" -struct DefScriptXChgResult { - std::string str; - bool change; -}; - // --- SECTION FOR SCRIPT PACKAGES --- -DefScriptPackage::DefScriptPackage(){ - scripts=0; - Script=NULL; - curIsDebug=false; - recursionLevel=0; - functions=0; +DefScriptPackage::DefScriptPackage() +{ functionTable=_GetFunctionTable(); - - - // printf("---> DefScriptPackage inited!\n"); } -DefScriptPackage::~DefScriptPackage(){ +DefScriptPackage::~DefScriptPackage() +{ Clear(); } @@ -35,21 +24,23 @@ void DefScriptPackage::SetParentMethod(void *p) parentMethod = p; } -void DefScriptPackage::Clear(void){ - //for(unsigned int i=0;i::iterator i = Script.begin(); i != Script.end(); i++) + { + delete i->second; // delete each script + } + + Script.empty(); } DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const { static DefScriptFunctionTable table[] = { // basic functions: + {"out",&DefScriptPackage::func_out}, {"set",&DefScriptPackage::func_set}, - {"defult",&DefScriptPackage::func_default}, + {"default",&DefScriptPackage::func_default}, {"unset",&DefScriptPackage::func_unset}, {"shdn",&DefScriptPackage::func_shdn}, {"loaddef",&DefScriptPackage::func_loaddef}, @@ -69,7 +60,8 @@ DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const return table; } -void DefScriptPackage::SetFunctionTable(DefScriptFunctionTable *tab){ +void DefScriptPackage::SetFunctionTable(DefScriptFunctionTable *tab) +{ functionTable=tab; } @@ -77,38 +69,26 @@ void DefScriptPackage::SetPath(std::string p){ scPath=p; } -DefScript DefScriptPackage::GetScript(unsigned int id){ - return Script[id]; +DefScript *DefScriptPackage::GetScript(std::string scname){ + if(Script.find(scname) != NULL) + return Script[scname]; + else + return NULL; } unsigned int DefScriptPackage::GetScripts(void){ - return scripts; + return Script.size(); } -std::string DefScriptPackage::GetScriptName(unsigned int id){ - if(id>scripts) return NULL; - return Script[id].GetName(); -} - -// returns array position! -unsigned int DefScriptPackage::GetScriptID(std::string name){ - for(unsigned int i=0;i::iterator i = Script.begin();i != Script.end();i++) + if(i->first == name && i->second != NULL) + return true; + for(unsigned int i=0;functionTable[i].func!=NULL;i++) + if(name == functionTable[i].name) + return true; + return false; } bool DefScriptPackage::LoadByName(std::string name){ @@ -116,32 +96,8 @@ bool DefScriptPackage::LoadByName(std::string name){ } bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){ - bool increase_flag=false; std::string label, value; - unsigned int id; - if(fn.empty() || sn.empty()) return false; - if(ScriptExists(sn)){ // if the script already exists, clear it and reassign content - id=GetScriptID(sn); // script exists, get ID... - Script[id].Clear(); // ... and remove content to refill it later on - } else { // if not, set scripts as ID for new script. scripts is equal to new array index then - id=scripts; - increase_flag=true; - - // Script does not yet exist, since the scriptcount will be increased we have to alloc mem before - DefScript *Script_old; - if(scripts){ - Script_old=new DefScript[scripts]; - memcpy(Script_old,Script,scripts*sizeof(DefScript)); - delete [] Script; - } - Script = new DefScript[scripts+1]; - if(scripts){ - memcpy(Script,Script_old,scripts*sizeof(DefScript)); - delete [] Script_old; - } - - } - + if(fn.empty() || sn.empty()) return false; std::fstream f; f.open(fn.c_str(),std::ios_base::in); if(!f.is_open()) @@ -149,6 +105,10 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){ std::string line; char z; bool load_debug=false,load_notify=false; + if(GetScript(sn)) + delete GetScript(sn); + DefScript *newscript = new DefScript(this); + Script[sn] = newscript; while(!f.eof()){ line.clear(); while (true) { @@ -166,175 +126,160 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){ continue; if(line.at(0)=='/' && line.at(1)=='/') continue; // line is comment, proceed with next line - if(line.at(0)=='#'){ + if(line.at(0)=='#') + { line.erase(0,1); // remove # label=line.substr(0,line.find('=',0)); value=line.substr(line.find('=',0)+1,line.length()); - if(label=="permission"){ - Script[id].SetPermission((unsigned char)atoi(value.c_str())); // MAYBE: instead of this use Var @permission + if(label=="permission") + { + scriptPermissionMap[sn] = atoi(value.c_str()); } // ... if(line=="load_debug") load_debug=true; if(line=="load_notify") load_notify=true; if(line=="debug") - Script[id].SetDebug(true); + Script[sn]->SetDebug(true); //... continue; // line was an option, not script content } if(load_debug) std::cout<<"~LOAD: "<AddLine(line); } f.close(); - //Script[id].AddLine("eof"); // to be sure the script is terminated correctly - Script[id].SetName(sn); + Script[sn]->SetName(sn); // necessary that the script knows its own name if(load_notify) std::cout << "+> Script '" << sn << "' [" << fn << "] successfully loaded.\n"; // ... - if(increase_flag) scripts++; return true; } // --- SECTION FOR THE INDIVIDUAL SCRIPTS IN A PACKAGE --- -DefScript::DefScript(){ - lines=0; - Line=NULL; - permission=0; +DefScript::DefScript(DefScriptPackage *p) +{ + _parent=p; scriptname="{NONAME}"; debugmode=false; // printf("--> DefScript inited!\n"); } -DefScript::~DefScript(){ +DefScript::~DefScript() +{ Clear(); } -void DefScript::Clear(void){ - //if(lines) - // delete [] Line; //?! causes crash! - Line=NULL; - lines=0; - permission=0; +void DefScript::Clear(void) +{ + Line.clear(); } -void DefScript::SetDebug(bool d){ +void DefScript::SetDebug(bool d) +{ debugmode=d; } -bool DefScript::GetDebug(void){ +bool DefScript::GetDebug(void) +{ return debugmode; } -void DefScript::SetName(std::string name){ +void DefScript::SetName(std::string name) +{ scriptname=name; } -std::string DefScript::GetName(void){ +std::string DefScript::GetName(void) +{ return scriptname; } -void DefScript::SetPermission(unsigned char p){ - permission=p; +unsigned int DefScript::GetLines(void) +{ + return Line.size(); } -unsigned char DefScript::GetPermission(void){ - return permission; -} - -unsigned int DefScript::GetLines(void){ - return lines; -} - -std::string DefScript::GetLine(unsigned int id){ - if(id>lines) - return ""; +std::string DefScript::GetLine(unsigned int id) +{ return Line[id]; } bool DefScript::AddLine(std::string l){ if(l.empty()) return false; - std::string *Line_old=new std::string[lines]; - for(unsigned int i=0;iGetScripts()) + +// the referred pSet is the parent from which RunScript() has been called +bool DefScriptPackage::RunScript(std::string name, CmdSet *pSet) +{ + if(!ScriptExists(name)) + if(!LoadByName(name)) + return false; // doesnt exist & cant be loaded + + DefScript *sc = GetScript(name); + if(!sc) return false; - curIsDebug=GetScript(id).GetDebug(); + CmdSet temp(sc); + if(!pSet) + { + pSet = &temp; + } + pSet->caller=pSet->myname; + pSet->myname=name; - for(unsigned int cur_line=0;cur_lineGetLines();i++) + { + CmdSet curSet(NULL); + DefXChgResult final=ReplaceVars(sc->GetLine(i),pSet,false); + //printf("SC: \"%s\"\n",final.str.c_str()); + curSet=SplitLine(final.str); + curSet.owner=sc; // must set the owner after SplitLine() + curSet.myname=name; + curSet.caller=pSet?pSet->myname:""; + Interpret(curSet); + } return true; } -bool DefScriptPackage::RunScriptByName(std::string scname, CmdSet *pSet, unsigned char p){ - if(scname.empty()) - return false; - if(ScriptExists(scname)){ - RunScriptByID(GetScriptID(scname),pSet,p); - return true; - } else { - bool result=LoadByName(scname); - if(result){ - RunScriptByID(GetScriptID(scname),pSet,p); - return true; - } - } - return false; - -} - -bool DefScriptPackage::RunSingleLine(std::string line, unsigned char p){ - unsigned int temp=0; - std::string final=ReplaceVars(line,NULL,false,temp,""); - CmdSet curSet=SplitLine(final); - return Interpret(curSet,"",p); +bool DefScriptPackage::RunSingleLine(std::string line){ + DefXChgResult final=ReplaceVars(line,NULL,false); + CmdSet curSet=SplitLine(final.str); + return Interpret(curSet); } CmdSet DefScriptPackage::SplitLine(std::string line){ @@ -343,7 +288,7 @@ CmdSet DefScriptPackage::SplitLine(std::string line){ unsigned int bracketsOpen=0,curParam=0; bool cmdDefined=false; std::string tempLine; - CmdSet outSet; + CmdSet outSet(NULL); // extract cmd+params and txt for(i=0;i>ReplaceVars: '"<myname); if(vname[0]=='@') { std::stringstream vns; std::string subs=vname.substr(1,str.length()-1); unsigned int vn=atoi( subs.c_str() ); vns << vn; - if(pSet && vns.str()==subs) + if(pSet && vns.str()==subs) // resolve arg macros @0 - @99 str=pSet->arg[vn]; else if(pSet && subs=="def") str=pSet->defaultarg; + else if(pSet && subs=="myname") + str=pSet->myname; else if(pSet && subs=="cmd") str=pSet->cmd; - //else if(pSet && subs=="parent") - // str=pSet->parent; + else if(pSet && subs=="caller") + str=pSet->caller; else if(variables.Exists(vname)) str=variables.Get(vname); else @@ -571,18 +522,21 @@ std::string DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, bool is //... str.clear(); } - - + xchg.changed=true; } else if(variables.Exists(vname)) + { str=variables.Get(vname); - else if(!variables.Exists(vname) && !subStr.empty()) - str="${"+str+"}"; + xchg.changed=true; + } } - - return str; + xchg.str = str; + if(hasChanged) + xchg.changed=true; + //printf("XCHG:%u: \"%s\"\n",xchg.changed,xchg.str.c_str()); + return xchg; } std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string sn){ @@ -600,39 +554,33 @@ std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string s return vn; } -bool DefScriptPackage::Interpret(CmdSet Set, std::string sc_name, unsigned char p){ +bool DefScriptPackage::Interpret(CmdSet Set) +{ bool result=false; - for(unsigned int i=0;result==false;i++){ - if(functionTable[i].func==NULL || functionTable[i].name==NULL){ // reached the end of the table? + // first search if the script is defined in the internal functions + for(unsigned int i=0;result==false;i++) + { + if(functionTable[i].func==NULL || functionTable[i].name==NULL) // reached the end of the table? + { break; } - if(Set.cmd==functionTable[i].name){ + if(Set.cmd==functionTable[i].name) + { result=(this->*functionTable[i].func)(Set); break; } } - // if still nothing has been found its maybe a script command - if(!result){ - unsigned int perm=GetScript(GetScriptID(Set.cmd)).GetPermission(); - if(pGetDebug()*/) std::cout << "Could not execute script command '" << Set.cmd << "'\n"; } return result; } -// TODO: how to get this work?! -/* -bool DefScriptPackage::CallFunction(bool *func, CmdSet *pSet){ - //bool result = *func(pSet, this); - //return result; -} -*/ - diff --git a/src/Client/DefScript/DefScript.h b/src/Client/DefScript/DefScript.h index c3bc506..0a55e1a 100644 --- a/src/Client/DefScript/DefScript.h +++ b/src/Client/DefScript/DefScript.h @@ -10,20 +10,29 @@ #endif #include +#include #include "VarSet.h" class DefScriptPackage; +class DefScript; + +struct DefXChgResult { + DefXChgResult() { changed=false; } + bool changed; + std::string str; +}; class CmdSet { public: - CmdSet(); + CmdSet(DefScript *p); ~CmdSet(); void Clear(); std::string cmd; std::string arg[MAXARGS]; std::string defaultarg; - DefScriptPackage *pack; + std::string myname; std::string caller; + DefScript *owner; void *ptr; }; @@ -34,7 +43,7 @@ struct DefScriptFunctionTable { class DefScript { public: - DefScript(); + DefScript(DefScriptPackage *p); ~DefScript(); std::string GetLine(unsigned int); unsigned int GetLines(void); @@ -50,13 +59,13 @@ public: private: - std::string *Line; + std::deque Line; unsigned int lines; std::string scriptname; unsigned char permission; bool debugmode; - //DefScriptPackage *_parent; + DefScriptPackage *_parent; //CmdSet _mySet; }; @@ -66,43 +75,36 @@ class DefScriptPackage { public: DefScriptPackage(); ~DefScriptPackage(); - void SetParentMethod(void*); + void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions void Clear(void); - DefScript GetScript(unsigned int); + DefScript *GetScript(std::string); unsigned int GetScripts(void); bool LoadScriptFromFile(std::string,std::string); - bool RunScriptByName(std::string,CmdSet*,unsigned char); - bool RunScriptByID(unsigned int,CmdSet*,unsigned char); - std::string GetScriptName(unsigned int); + bool RunScript(std::string,CmdSet*); unsigned int GetScriptID(std::string); - bool RunSingleLine(std::string, unsigned char); + bool RunSingleLine(std::string); bool ScriptExists(std::string); VarSet variables; void SetPath(std::string); bool LoadByName(std::string); void SetFunctionTable(DefScriptFunctionTable*); std::string _NormalizeVarName(std::string, std::string); - bool DefScriptPackage::CallFunction(bool *func, CmdSet *pSet); std::string scPath; private: - std::string ReplaceVars(std::string, CmdSet*, bool, unsigned int, std::string); // changes the string directly + DefXChgResult ReplaceVars(std::string, CmdSet*, bool); CmdSet SplitLine(std::string); - bool Interpret(CmdSet, std::string, unsigned char); + bool Interpret(CmdSet); CmdSet RemoveBrackets(CmdSet); std::string RemoveBracketsFromString(std::string); DefScriptFunctionTable *_GetFunctionTable(void) const; - - bool curIsDebug; - unsigned int scripts; - DefScript *Script; - unsigned int recursionLevel; DefScriptFunctionTable *functionTable; unsigned int functions; void *parentMethod; - std::map permissionMap; + std::map scriptPermissionMap; + std::map Script; // Usable internal basic functions: bool func_default(CmdSet); diff --git a/src/Client/DefScript/DefScriptFunctions.cpp b/src/Client/DefScript/DefScriptFunctions.cpp index 408bd13..ca5dcb6 100644 --- a/src/Client/DefScript/DefScriptFunctions.cpp +++ b/src/Client/DefScript/DefScriptFunctions.cpp @@ -92,13 +92,16 @@ bool DefScriptPackage::func_set(CmdSet Set){ return false; } std::string vname,vval=Set.defaultarg; - vname=_NormalizeVarName(Set.arg[0], Set.caller); + vname=_NormalizeVarName(Set.arg[0], Set.myname); if(!stricmp(Set.arg[1].c_str(),"onfail") && vval.find("${")!=std::string::npos) vval=Set.arg[2]; variables.Set(vname,vval); + if(Set.owner && Set.owner->GetDebug()) + printf("VAR: %s = '%s'\n",vname.c_str(),vval.c_str()); + return true; } diff --git a/src/Client/DefScript/VarSet.cpp b/src/Client/DefScript/VarSet.cpp index be978b7..a77ea9e 100644 --- a/src/Client/DefScript/VarSet.cpp +++ b/src/Client/DefScript/VarSet.cpp @@ -133,6 +133,10 @@ bool VarSet::ReadVarsFromFile(std::string fn) upper=false; prefix.clear(); } + else if(prefix=="#noprefix") + { + prefix.clear(); + } else { prefix+="::"; diff --git a/src/Client/DefScriptInterface.cpp b/src/Client/DefScriptInterface.cpp index 9b9ab70..81744c5 100644 --- a/src/Client/DefScriptInterface.cpp +++ b/src/Client/DefScriptInterface.cpp @@ -12,7 +12,7 @@ bool DefScriptPackage::SCpause(CmdSet Set){ - SDL_Delay(atoi(Set.defaultarg.c_str())); + ((PseuInstance*)parentMethod)->Sleep(atoi(Set.defaultarg.c_str())); return true; } diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index 2622a38..3def836 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -99,18 +99,16 @@ bool PseuInstance::Init(void) { // //DEBUG1(printf("Main_Init: Setting up DefScripts path '%s'\n",defScpPath.c_str());); _scp->SetPath(_scpdir); - // //DEBUG1(printf("Main_Init: Setting up custom DefScript function interface...\n");); - //_scp->SetFunctionTable(_GetSCTable()); - // //DEBUG1(printf("Main_Init: Setting up predefined DefScript macros...\n");); _scp->variables.Set("@version_short",_ver_short); _scp->variables.Set("@version",_ver); // //DEBUG1(printf("Main_Init: Loading DefScripts from folder '%s'\n",defScpPath.c_str());); - //if(!_scp->RunScriptByName("_startup",NULL,255)){ - // printf("Main_Init: Error executing '_startup.def'\n"); - //} + if(!_scp->RunScript("_startup",NULL)) + { + printf("Main_Init: Error executing '_startup.def'\n"); + } if(_stop){ printf("Errors while initializing, proc halted!!\n"); @@ -319,6 +317,7 @@ void PseuInstanceConf::ApplyFromVarSet(VarSet &v) realmname=v.Get("REALMNAME"); charname=v.Get("CHARNAME"); networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str()); + showopcodes=atoi(v.Get("SHOWOPCODES").c_str()); // clientversion is a bit more complicated to add { diff --git a/src/Client/PseuWoW.h b/src/Client/PseuWoW.h index 2051faa..3a761e3 100644 --- a/src/Client/PseuWoW.h +++ b/src/Client/PseuWoW.h @@ -37,6 +37,7 @@ class PseuInstanceConf std::string charname; std::string worldhost; uint16 networksleeptime; + uint8 showopcodes; }; diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 9a6af35..ccf5f92 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -94,7 +94,6 @@ void WorldSession::Update(void) while(!pktQueue.empty()) { WorldPacket *packet = pktQueue.next(); - printf(">> Opcode %u [%s]\n",packet->GetOpcode(),LookupName(packet->GetOpcode(),g_worldOpcodeNames)); for (uint16 i = 0; table[i].handler != NULL; i++) { @@ -105,7 +104,13 @@ void WorldSession::Update(void) break; } } - //if(!known) + if( (known && GetInstance()->GetConf()->showopcodes==1) + || ((!known) && GetInstance()->GetConf()->showopcodes==2) + || (GetInstance()->GetConf()->showopcodes==3) ) + { + printf(">> Opcode %u [%s]\n",packet->GetOpcode(),LookupName(packet->GetOpcode(),g_worldOpcodeNames)); + } + delete packet; @@ -170,7 +175,7 @@ void WorldSession::_OnEnterWorld(void) if(!_logged) { _logged=true; - //GetInstance()->GetScripts()->RunScriptByName("_enterworld",NULL,255); + GetInstance()->GetScripts()->RunScript("_enterworld",NULL); } } @@ -426,8 +431,8 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket) defScp.variables.Set("@lastwhisper_lang",defScp.variables.Get("@thiswhisper_lang")); defScp.variables.Set("@thiswhisper_name",plrname); defScp.variables.Set("@thiswhisper",toString(target_guid)); - defScp.variables.Set("@thiswhisper_lang",toString((uint64)lang)); - defScp.RunScriptByName("_onwhisper",NULL,255);*/ + defScp.variables.Set("@thiswhisper_lang",toString((uint64)lang));*/ + GetInstance()->GetScripts()->RunScript("_onwhisper",NULL); } } void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket)