+ added default config files + SDL.dll
+ added some DefScripts + fixed the DefScript system. TODO: permissions & stuff will come in next rev. :)
This commit is contained in:
parent
0b1ae6f9ca
commit
889238cfb7
60
bin/conf/PseuWoW.conf.default
Normal file
60
bin/conf/PseuWoW.conf.default
Normal file
@ -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
|
||||||
|
|
||||||
|
|
||||||
1
bin/conf/todo.txt
Normal file
1
bin/conf/todo.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
RENAME or COPY *.conf.default to *.conf and modify it to your needs.
|
||||||
18
bin/conf/users.conf.default
Normal file
18
bin/conf/users.conf.default
Normal file
@ -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
|
||||||
28
bin/scripts/_enterworld.def
Normal file
28
bin/scripts/_enterworld.def
Normal file
@ -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.
|
||||||
6
bin/scripts/_onwhisper.def
Normal file
6
bin/scripts/_onwhisper.def
Normal file
@ -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!
|
||||||
33
bin/scripts/_startup.def
Normal file
33
bin/scripts/_startup.def
Normal file
@ -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!
|
||||||
|
|
||||||
11
bin/scripts/reply.def
Normal file
11
bin/scripts/reply.def
Normal file
@ -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
|
||||||
12
bin/scripts/say.def
Normal file
12
bin/scripts/say.def
Normal file
@ -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
|
||||||
15
bin/scripts/whisper.def
Normal file
15
bin/scripts/whisper.def
Normal file
@ -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
|
||||||
13
bin/scripts/yell.def
Normal file
13
bin/scripts/yell.def
Normal file
@ -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
|
||||||
@ -7,26 +7,15 @@
|
|||||||
#include "VarSet.h"
|
#include "VarSet.h"
|
||||||
#include "DefScript.h"
|
#include "DefScript.h"
|
||||||
|
|
||||||
struct DefScriptXChgResult {
|
|
||||||
std::string str;
|
|
||||||
bool change;
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- SECTION FOR SCRIPT PACKAGES ---
|
// --- SECTION FOR SCRIPT PACKAGES ---
|
||||||
DefScriptPackage::DefScriptPackage(){
|
DefScriptPackage::DefScriptPackage()
|
||||||
scripts=0;
|
{
|
||||||
Script=NULL;
|
|
||||||
curIsDebug=false;
|
|
||||||
recursionLevel=0;
|
|
||||||
functions=0;
|
|
||||||
functionTable=_GetFunctionTable();
|
functionTable=_GetFunctionTable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// printf("---> DefScriptPackage inited!\n");
|
// printf("---> DefScriptPackage inited!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
DefScriptPackage::~DefScriptPackage(){
|
DefScriptPackage::~DefScriptPackage()
|
||||||
|
{
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,21 +24,23 @@ void DefScriptPackage::SetParentMethod(void *p)
|
|||||||
parentMethod = p;
|
parentMethod = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScriptPackage::Clear(void){
|
void DefScriptPackage::Clear(void)
|
||||||
//for(unsigned int i=0;i<scripts;i++){
|
{
|
||||||
// Script[i].Clear();
|
for(std::map<std::string,DefScript*>::iterator i = Script.begin(); i != Script.end(); i++)
|
||||||
//}
|
{
|
||||||
delete [] Script;
|
delete i->second; // delete each script
|
||||||
Script=NULL;
|
}
|
||||||
scripts=0;
|
|
||||||
|
Script.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const
|
DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const
|
||||||
{
|
{
|
||||||
static DefScriptFunctionTable table[] = {
|
static DefScriptFunctionTable table[] = {
|
||||||
// basic functions:
|
// basic functions:
|
||||||
|
{"out",&DefScriptPackage::func_out},
|
||||||
{"set",&DefScriptPackage::func_set},
|
{"set",&DefScriptPackage::func_set},
|
||||||
{"defult",&DefScriptPackage::func_default},
|
{"default",&DefScriptPackage::func_default},
|
||||||
{"unset",&DefScriptPackage::func_unset},
|
{"unset",&DefScriptPackage::func_unset},
|
||||||
{"shdn",&DefScriptPackage::func_shdn},
|
{"shdn",&DefScriptPackage::func_shdn},
|
||||||
{"loaddef",&DefScriptPackage::func_loaddef},
|
{"loaddef",&DefScriptPackage::func_loaddef},
|
||||||
@ -69,7 +60,8 @@ DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScriptPackage::SetFunctionTable(DefScriptFunctionTable *tab){
|
void DefScriptPackage::SetFunctionTable(DefScriptFunctionTable *tab)
|
||||||
|
{
|
||||||
functionTable=tab;
|
functionTable=tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,37 +69,25 @@ void DefScriptPackage::SetPath(std::string p){
|
|||||||
scPath=p;
|
scPath=p;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefScript DefScriptPackage::GetScript(unsigned int id){
|
DefScript *DefScriptPackage::GetScript(std::string scname){
|
||||||
return Script[id];
|
if(Script.find(scname) != NULL)
|
||||||
|
return Script[scname];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DefScriptPackage::GetScripts(void){
|
unsigned int DefScriptPackage::GetScripts(void){
|
||||||
return scripts;
|
return Script.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DefScriptPackage::GetScriptName(unsigned int id){
|
bool DefScriptPackage::ScriptExists(std::string name)
|
||||||
if(id>scripts) return NULL;
|
{
|
||||||
return Script[id].GetName();
|
for (std::map<std::string,DefScript*>::iterator i = Script.begin();i != Script.end();i++)
|
||||||
}
|
if(i->first == name && i->second != NULL)
|
||||||
|
return true;
|
||||||
// returns array position!
|
for(unsigned int i=0;functionTable[i].func!=NULL;i++)
|
||||||
unsigned int DefScriptPackage::GetScriptID(std::string name){
|
if(name == functionTable[i].name)
|
||||||
for(unsigned int i=0;i<scripts;i++){
|
|
||||||
if( !Script[i].GetName().empty() && Script[i].GetName()==name ){
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0; // Be careful you check if the script exists before you trust it. this could
|
|
||||||
// also mean Script[0]!!
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DefScriptPackage::ScriptExists(std::string name){
|
|
||||||
if(Script==NULL) return false;
|
|
||||||
for(unsigned int i=0;i<scripts;i++){
|
|
||||||
if( !Script[i].GetName().empty() && Script[i].GetName()==name ){
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,32 +96,8 @@ bool DefScriptPackage::LoadByName(std::string name){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){
|
bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){
|
||||||
bool increase_flag=false;
|
|
||||||
std::string label, value;
|
std::string label, value;
|
||||||
unsigned int id;
|
|
||||||
if(fn.empty() || sn.empty()) return false;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::fstream f;
|
std::fstream f;
|
||||||
f.open(fn.c_str(),std::ios_base::in);
|
f.open(fn.c_str(),std::ios_base::in);
|
||||||
if(!f.is_open())
|
if(!f.is_open())
|
||||||
@ -149,6 +105,10 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){
|
|||||||
std::string line;
|
std::string line;
|
||||||
char z;
|
char z;
|
||||||
bool load_debug=false,load_notify=false;
|
bool load_debug=false,load_notify=false;
|
||||||
|
if(GetScript(sn))
|
||||||
|
delete GetScript(sn);
|
||||||
|
DefScript *newscript = new DefScript(this);
|
||||||
|
Script[sn] = newscript;
|
||||||
while(!f.eof()){
|
while(!f.eof()){
|
||||||
line.clear();
|
line.clear();
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -166,175 +126,160 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){
|
|||||||
continue;
|
continue;
|
||||||
if(line.at(0)=='/' && line.at(1)=='/')
|
if(line.at(0)=='/' && line.at(1)=='/')
|
||||||
continue; // line is comment, proceed with next line
|
continue; // line is comment, proceed with next line
|
||||||
if(line.at(0)=='#'){
|
if(line.at(0)=='#')
|
||||||
|
{
|
||||||
line.erase(0,1); // remove #
|
line.erase(0,1); // remove #
|
||||||
label=line.substr(0,line.find('=',0));
|
label=line.substr(0,line.find('=',0));
|
||||||
value=line.substr(line.find('=',0)+1,line.length());
|
value=line.substr(line.find('=',0)+1,line.length());
|
||||||
if(label=="permission"){
|
if(label=="permission")
|
||||||
Script[id].SetPermission((unsigned char)atoi(value.c_str())); // MAYBE: instead of this use Var @permission
|
{
|
||||||
|
scriptPermissionMap[sn] = atoi(value.c_str());
|
||||||
} // ...
|
} // ...
|
||||||
if(line=="load_debug")
|
if(line=="load_debug")
|
||||||
load_debug=true;
|
load_debug=true;
|
||||||
if(line=="load_notify")
|
if(line=="load_notify")
|
||||||
load_notify=true;
|
load_notify=true;
|
||||||
if(line=="debug")
|
if(line=="debug")
|
||||||
Script[id].SetDebug(true);
|
Script[sn]->SetDebug(true);
|
||||||
//...
|
//...
|
||||||
continue; // line was an option, not script content
|
continue; // line was an option, not script content
|
||||||
}
|
}
|
||||||
if(load_debug)
|
if(load_debug)
|
||||||
std::cout<<"~LOAD: "<<line<<"\n";
|
std::cout<<"~LOAD: "<<line<<"\n";
|
||||||
Script[id].AddLine(line);
|
Script[sn]->AddLine(line);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
f.close();
|
f.close();
|
||||||
//Script[id].AddLine("eof"); // to be sure the script is terminated correctly
|
Script[sn]->SetName(sn); // necessary that the script knows its own name
|
||||||
Script[id].SetName(sn);
|
|
||||||
if(load_notify)
|
if(load_notify)
|
||||||
std::cout << "+> Script '" << sn << "' [" << fn << "] successfully loaded.\n";
|
std::cout << "+> Script '" << sn << "' [" << fn << "] successfully loaded.\n";
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
if(increase_flag) scripts++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- SECTION FOR THE INDIVIDUAL SCRIPTS IN A PACKAGE ---
|
// --- SECTION FOR THE INDIVIDUAL SCRIPTS IN A PACKAGE ---
|
||||||
|
|
||||||
DefScript::DefScript(){
|
DefScript::DefScript(DefScriptPackage *p)
|
||||||
lines=0;
|
{
|
||||||
Line=NULL;
|
_parent=p;
|
||||||
permission=0;
|
|
||||||
scriptname="{NONAME}";
|
scriptname="{NONAME}";
|
||||||
debugmode=false;
|
debugmode=false;
|
||||||
// printf("--> DefScript inited!\n");
|
// printf("--> DefScript inited!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
DefScript::~DefScript(){
|
DefScript::~DefScript()
|
||||||
|
{
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScript::Clear(void){
|
void DefScript::Clear(void)
|
||||||
//if(lines)
|
{
|
||||||
// delete [] Line; //?! causes crash!
|
Line.clear();
|
||||||
Line=NULL;
|
|
||||||
lines=0;
|
|
||||||
permission=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScript::SetDebug(bool d){
|
void DefScript::SetDebug(bool d)
|
||||||
|
{
|
||||||
debugmode=d;
|
debugmode=d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefScript::GetDebug(void){
|
bool DefScript::GetDebug(void)
|
||||||
|
{
|
||||||
return debugmode;
|
return debugmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScript::SetName(std::string name){
|
void DefScript::SetName(std::string name)
|
||||||
|
{
|
||||||
scriptname=name;
|
scriptname=name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DefScript::GetName(void){
|
std::string DefScript::GetName(void)
|
||||||
|
{
|
||||||
return scriptname;
|
return scriptname;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefScript::SetPermission(unsigned char p){
|
unsigned int DefScript::GetLines(void)
|
||||||
permission=p;
|
{
|
||||||
|
return Line.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char DefScript::GetPermission(void){
|
std::string DefScript::GetLine(unsigned int id)
|
||||||
return permission;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int DefScript::GetLines(void){
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string DefScript::GetLine(unsigned int id){
|
|
||||||
if(id>lines)
|
|
||||||
return "";
|
|
||||||
return Line[id];
|
return Line[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefScript::AddLine(std::string l){
|
bool DefScript::AddLine(std::string l){
|
||||||
if(l.empty())
|
if(l.empty())
|
||||||
return false;
|
return false;
|
||||||
std::string *Line_old=new std::string[lines];
|
Line.insert(Line.end(),l);
|
||||||
for(unsigned int i=0;i<lines;i++)
|
|
||||||
Line_old[i]=Line[i];
|
|
||||||
delete [] Line;
|
|
||||||
Line=new std::string[lines+1];
|
|
||||||
for(unsigned int i=0;i<lines;i++)
|
|
||||||
Line[i]=Line_old[i];
|
|
||||||
Line[lines]=l;
|
|
||||||
lines++;
|
|
||||||
delete [] Line_old;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- SECTION FOR COMMAND SETS ---
|
// --- SECTION FOR COMMAND SETS ---
|
||||||
|
|
||||||
CmdSet::CmdSet(){
|
CmdSet::CmdSet(DefScript *p){
|
||||||
for(unsigned int i=0;i<MAXARGS;i++){
|
Clear();
|
||||||
arg[i]="";
|
owner = p;
|
||||||
}
|
|
||||||
cmd="";
|
|
||||||
defaultarg="";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdSet::~CmdSet(){
|
CmdSet::~CmdSet(){
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdSet::Clear(){
|
void CmdSet::Clear()
|
||||||
|
{
|
||||||
|
for(unsigned int i=0;i<MAXARGS;i++){
|
||||||
|
arg[i]="";
|
||||||
|
}
|
||||||
|
cmd="";
|
||||||
|
defaultarg="";
|
||||||
|
caller="";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- FUNCTIONS TO PARSE AND EXECUTE A SCRIPT --- PARENT: DefScriptPackage!
|
// --- FUNCTIONS TO PARSE AND EXECUTE A SCRIPT --- PARENT: DefScriptPackage!
|
||||||
|
|
||||||
bool DefScriptPackage::RunScriptByID(unsigned int id, CmdSet *pSet, unsigned char p){
|
|
||||||
if(id>GetScripts())
|
// 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;
|
return false;
|
||||||
|
|
||||||
curIsDebug=GetScript(id).GetDebug();
|
CmdSet temp(sc);
|
||||||
|
if(!pSet)
|
||||||
for(unsigned int cur_line=0;cur_line<GetScript(id).GetLines();cur_line++){
|
{
|
||||||
|
pSet = &temp;
|
||||||
std::string line=GetScript(id).GetLine(cur_line);
|
|
||||||
std::string final=ReplaceVars(line,pSet,false,0,GetScript(id).GetName()); // must only parse globals if pSet == NULL
|
|
||||||
CmdSet curSet=SplitLine(final);
|
|
||||||
Interpret(curSet,GetScript(id).GetName(), p);
|
|
||||||
}
|
}
|
||||||
|
pSet->caller=pSet->myname;
|
||||||
|
pSet->myname=name;
|
||||||
|
|
||||||
curIsDebug=false;
|
for(unsigned int i=0;i<sc->GetLines();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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefScriptPackage::RunScriptByName(std::string scname, CmdSet *pSet, unsigned char p){
|
bool DefScriptPackage::RunSingleLine(std::string line){
|
||||||
if(scname.empty())
|
DefXChgResult final=ReplaceVars(line,NULL,false);
|
||||||
return false;
|
CmdSet curSet=SplitLine(final.str);
|
||||||
if(ScriptExists(scname)){
|
return Interpret(curSet);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdSet DefScriptPackage::SplitLine(std::string line){
|
CmdSet DefScriptPackage::SplitLine(std::string line){
|
||||||
@ -343,7 +288,7 @@ CmdSet DefScriptPackage::SplitLine(std::string line){
|
|||||||
unsigned int bracketsOpen=0,curParam=0;
|
unsigned int bracketsOpen=0,curParam=0;
|
||||||
bool cmdDefined=false;
|
bool cmdDefined=false;
|
||||||
std::string tempLine;
|
std::string tempLine;
|
||||||
CmdSet outSet;
|
CmdSet outSet(NULL);
|
||||||
|
|
||||||
// extract cmd+params and txt
|
// extract cmd+params and txt
|
||||||
for(i=0;i<line.length();i++){
|
for(i=0;i<line.length();i++){
|
||||||
@ -391,7 +336,8 @@ CmdSet DefScriptPackage::SplitLine(std::string line){
|
|||||||
if(cmdDefined && !outSet.cmd.empty() && outSet.defaultarg.empty())
|
if(cmdDefined && !outSet.cmd.empty() && outSet.defaultarg.empty())
|
||||||
outSet.arg[curParam]=tempLine;
|
outSet.arg[curParam]=tempLine;
|
||||||
|
|
||||||
outSet.cmd.assign(strlwr((char*)outSet.cmd.c_str()));
|
outSet.cmd.assign(strlwr((char*)outSet.cmd.c_str())); // TODO: use toLower() instead!
|
||||||
|
outSet.owner=GetScript(outSet.cmd);
|
||||||
return RemoveBrackets(outSet);
|
return RemoveBrackets(outSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,28 +415,31 @@ CmdSet DefScriptPackage::RemoveBrackets(CmdSet oldSet){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, bool isVar, unsigned int vardepth, std::string sc_name){
|
DefXChgResult DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, bool isVar){
|
||||||
//std::cout<<">>ReplaceVars: '"<<str<<"' var="<<isVar<<"\n";
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
|
||||||
openingBracket=0, // defines the position from where the recursive call should be started
|
openingBracket=0, // defines the position from where the recursive call is started
|
||||||
closingBracket=0, // the closing bracket
|
closingBracket=0, // the closing bracket
|
||||||
bracketsOpen=0,
|
bracketsOpen=0, // amount of brackets opened
|
||||||
bLen=0; // the lenth of the string in brackets, e.g. ${abc} == 3
|
bLen=0; // the lenth of the string in brackets, e.g. ${abc} == 3
|
||||||
|
|
||||||
bool nextIsVar=false, hasVar=false;
|
bool
|
||||||
|
nextIsVar=false, // true if the last bracket was preceded by '$'
|
||||||
|
hasVar=false, // true if openingBracket (= the first bracket) was preceded by '$'
|
||||||
|
hasChanged=false; // additional helper. once true, xchg.result will be true later also
|
||||||
|
|
||||||
|
// isVar (arg) : defines if the current string is a variable (can only be true in recursive calls!)
|
||||||
|
|
||||||
|
|
||||||
std::string subStr,retStr;
|
std::string subStr;
|
||||||
char temp;
|
DefXChgResult xchg;
|
||||||
|
|
||||||
while(str.at(0)==' ' || str.at(0)=='\t')
|
|
||||||
str.erase(0,1); // trim spaces if there are any
|
|
||||||
|
|
||||||
for(unsigned int i=0;i<str.length();i++){
|
|
||||||
temp=str.at(i);
|
|
||||||
|
|
||||||
|
//while(str.at(0)==' ' || str.at(0)=='\t')
|
||||||
|
// str.erase(0,1); // trim spaces if there are any
|
||||||
|
|
||||||
|
for(unsigned int i=0;i<str.length();i++)
|
||||||
|
{
|
||||||
if(str[i]=='{')
|
if(str[i]=='{')
|
||||||
{
|
{
|
||||||
if(!bracketsOpen)
|
if(!bracketsOpen)
|
||||||
@ -515,54 +464,56 @@ std::string DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, bool is
|
|||||||
{
|
{
|
||||||
str.erase(closingBracket,1);
|
str.erase(closingBracket,1);
|
||||||
str.erase(openingBracket,1);
|
str.erase(openingBracket,1);
|
||||||
i-=2;
|
i=openingBracket; // jump to the pos where the opening bracket was
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bLen=closingBracket-openingBracket-1;
|
bLen=closingBracket-openingBracket-1;
|
||||||
subStr=str.substr(openingBracket+1,bLen);
|
subStr=str.substr(openingBracket+1,bLen);
|
||||||
retStr=ReplaceVars(subStr,pSet,nextIsVar,vardepth+(nextIsVar?1:0),sc_name);
|
//printf("SUBSTR: \"%s\"\n",subStr.c_str());
|
||||||
if( hasVar && !nextIsVar && subStr!=retStr )
|
xchg=ReplaceVars(subStr,pSet,nextIsVar);
|
||||||
|
if( (!nextIsVar) && hasVar && xchg.changed )
|
||||||
{
|
{
|
||||||
str.erase(openingBracket+1,subStr.length());
|
str.erase(openingBracket+1,subStr.length());
|
||||||
str.insert(openingBracket+1,retStr);
|
str.insert(openingBracket+1,xchg.str);
|
||||||
hasVar=false;
|
hasVar=false;
|
||||||
nextIsVar=false;
|
nextIsVar=false;
|
||||||
i-=(subStr.length()+1);
|
i-=(subStr.length()+1);
|
||||||
|
hasChanged=true;
|
||||||
}
|
}
|
||||||
else if( hasVar && nextIsVar && subStr!=retStr )
|
else if( nextIsVar && hasVar && xchg.changed )
|
||||||
{
|
{
|
||||||
str.erase(openingBracket-1,bLen+3); // remove {...
|
str.erase(openingBracket-1,bLen+3); // remove ${...} (+3 because of '${}')
|
||||||
i-=(bLen+2); // adjust position
|
i-=(bLen+2); // adjust position
|
||||||
str.insert(i,retStr);
|
str.insert(i,xchg.str);
|
||||||
//i--;
|
//i--;
|
||||||
hasVar=false;
|
hasVar=false;
|
||||||
nextIsVar=false;
|
nextIsVar=false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end if {
|
} // end if '}'
|
||||||
} // end for
|
} // end for
|
||||||
if(!bracketsOpen && isVar && vardepth)
|
if(!bracketsOpen && isVar)
|
||||||
{
|
{
|
||||||
std::string vname=_NormalizeVarName(str, sc_name);
|
std::string vname=_NormalizeVarName(str, (pSet==NULL) ? "" : pSet->myname);
|
||||||
if(vname[0]=='@')
|
if(vname[0]=='@')
|
||||||
{
|
{
|
||||||
std::stringstream vns;
|
std::stringstream vns;
|
||||||
std::string subs=vname.substr(1,str.length()-1);
|
std::string subs=vname.substr(1,str.length()-1);
|
||||||
unsigned int vn=atoi( subs.c_str() );
|
unsigned int vn=atoi( subs.c_str() );
|
||||||
vns << vn;
|
vns << vn;
|
||||||
if(pSet && vns.str()==subs)
|
if(pSet && vns.str()==subs) // resolve arg macros @0 - @99
|
||||||
str=pSet->arg[vn];
|
str=pSet->arg[vn];
|
||||||
else if(pSet && subs=="def")
|
else if(pSet && subs=="def")
|
||||||
str=pSet->defaultarg;
|
str=pSet->defaultarg;
|
||||||
|
else if(pSet && subs=="myname")
|
||||||
|
str=pSet->myname;
|
||||||
else if(pSet && subs=="cmd")
|
else if(pSet && subs=="cmd")
|
||||||
str=pSet->cmd;
|
str=pSet->cmd;
|
||||||
//else if(pSet && subs=="parent")
|
else if(pSet && subs=="caller")
|
||||||
// str=pSet->parent;
|
str=pSet->caller;
|
||||||
else if(variables.Exists(vname))
|
else if(variables.Exists(vname))
|
||||||
str=variables.Get(vname);
|
str=variables.Get(vname);
|
||||||
else
|
else
|
||||||
@ -571,18 +522,21 @@ std::string DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, bool is
|
|||||||
//...
|
//...
|
||||||
str.clear();
|
str.clear();
|
||||||
}
|
}
|
||||||
|
xchg.changed=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(variables.Exists(vname))
|
if(variables.Exists(vname))
|
||||||
|
{
|
||||||
str=variables.Get(vname);
|
str=variables.Get(vname);
|
||||||
else if(!variables.Exists(vname) && !subStr.empty())
|
xchg.changed=true;
|
||||||
str="${"+str+"}";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xchg.str = str;
|
||||||
return 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){
|
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;
|
return vn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefScriptPackage::Interpret(CmdSet Set, std::string sc_name, unsigned char p){
|
bool DefScriptPackage::Interpret(CmdSet Set)
|
||||||
|
{
|
||||||
bool result=false;
|
bool result=false;
|
||||||
|
|
||||||
for(unsigned int i=0;result==false;i++){
|
// first search if the script is defined in the internal functions
|
||||||
if(functionTable[i].func==NULL || functionTable[i].name==NULL){ // reached the end of the table?
|
for(unsigned int i=0;result==false;i++)
|
||||||
|
{
|
||||||
|
if(functionTable[i].func==NULL || functionTable[i].name==NULL) // reached the end of the table?
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(Set.cmd==functionTable[i].name){
|
if(Set.cmd==functionTable[i].name)
|
||||||
|
{
|
||||||
result=(this->*functionTable[i].func)(Set);
|
result=(this->*functionTable[i].func)(Set);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if still nothing has been found its maybe a script command
|
// if nothing has been found its maybe an external script file to run
|
||||||
if(!result){
|
if(!result)
|
||||||
unsigned int perm=GetScript(GetScriptID(Set.cmd)).GetPermission();
|
{
|
||||||
if(p<perm)
|
result=RunScript(Set.cmd, &Set);
|
||||||
return false; // permisson level too low
|
if((!result) /*&& Script[Set.cmd]->GetDebug()*/)
|
||||||
|
|
||||||
result=RunScriptByName(Set.cmd,&Set,255); // call the subscript, this time with full privileges
|
|
||||||
if(!result && curIsDebug)
|
|
||||||
std::cout << "Could not execute script command '" << Set.cmd << "'\n";
|
std::cout << "Could not execute script command '" << Set.cmd << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: how to get this work?!
|
|
||||||
/*
|
|
||||||
bool DefScriptPackage::CallFunction(bool *func, CmdSet *pSet){
|
|
||||||
//bool result = *func(pSet, this);
|
|
||||||
//return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,20 +10,29 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <deque>
|
||||||
#include "VarSet.h"
|
#include "VarSet.h"
|
||||||
|
|
||||||
class DefScriptPackage;
|
class DefScriptPackage;
|
||||||
|
class DefScript;
|
||||||
|
|
||||||
|
struct DefXChgResult {
|
||||||
|
DefXChgResult() { changed=false; }
|
||||||
|
bool changed;
|
||||||
|
std::string str;
|
||||||
|
};
|
||||||
|
|
||||||
class CmdSet {
|
class CmdSet {
|
||||||
public:
|
public:
|
||||||
CmdSet();
|
CmdSet(DefScript *p);
|
||||||
~CmdSet();
|
~CmdSet();
|
||||||
void Clear();
|
void Clear();
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
std::string arg[MAXARGS];
|
std::string arg[MAXARGS];
|
||||||
std::string defaultarg;
|
std::string defaultarg;
|
||||||
DefScriptPackage *pack;
|
std::string myname;
|
||||||
std::string caller;
|
std::string caller;
|
||||||
|
DefScript *owner;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,7 +43,7 @@ struct DefScriptFunctionTable {
|
|||||||
|
|
||||||
class DefScript {
|
class DefScript {
|
||||||
public:
|
public:
|
||||||
DefScript();
|
DefScript(DefScriptPackage *p);
|
||||||
~DefScript();
|
~DefScript();
|
||||||
std::string GetLine(unsigned int);
|
std::string GetLine(unsigned int);
|
||||||
unsigned int GetLines(void);
|
unsigned int GetLines(void);
|
||||||
@ -50,13 +59,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string *Line;
|
std::deque<std::string> Line;
|
||||||
unsigned int lines;
|
unsigned int lines;
|
||||||
std::string scriptname;
|
std::string scriptname;
|
||||||
unsigned char permission;
|
unsigned char permission;
|
||||||
bool debugmode;
|
bool debugmode;
|
||||||
|
|
||||||
//DefScriptPackage *_parent;
|
DefScriptPackage *_parent;
|
||||||
//CmdSet _mySet;
|
//CmdSet _mySet;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -66,43 +75,36 @@ class DefScriptPackage {
|
|||||||
public:
|
public:
|
||||||
DefScriptPackage();
|
DefScriptPackage();
|
||||||
~DefScriptPackage();
|
~DefScriptPackage();
|
||||||
void SetParentMethod(void*);
|
void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
DefScript GetScript(unsigned int);
|
DefScript *GetScript(std::string);
|
||||||
unsigned int GetScripts(void);
|
unsigned int GetScripts(void);
|
||||||
bool LoadScriptFromFile(std::string,std::string);
|
bool LoadScriptFromFile(std::string,std::string);
|
||||||
bool RunScriptByName(std::string,CmdSet*,unsigned char);
|
bool RunScript(std::string,CmdSet*);
|
||||||
bool RunScriptByID(unsigned int,CmdSet*,unsigned char);
|
|
||||||
std::string GetScriptName(unsigned int);
|
|
||||||
unsigned int GetScriptID(std::string);
|
unsigned int GetScriptID(std::string);
|
||||||
bool RunSingleLine(std::string, unsigned char);
|
bool RunSingleLine(std::string);
|
||||||
bool ScriptExists(std::string);
|
bool ScriptExists(std::string);
|
||||||
VarSet variables;
|
VarSet variables;
|
||||||
void SetPath(std::string);
|
void SetPath(std::string);
|
||||||
bool LoadByName(std::string);
|
bool LoadByName(std::string);
|
||||||
void SetFunctionTable(DefScriptFunctionTable*);
|
void SetFunctionTable(DefScriptFunctionTable*);
|
||||||
std::string _NormalizeVarName(std::string, std::string);
|
std::string _NormalizeVarName(std::string, std::string);
|
||||||
bool DefScriptPackage::CallFunction(bool *func, CmdSet *pSet);
|
|
||||||
|
|
||||||
std::string scPath;
|
std::string scPath;
|
||||||
|
|
||||||
private:
|
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);
|
CmdSet SplitLine(std::string);
|
||||||
bool Interpret(CmdSet, std::string, unsigned char);
|
bool Interpret(CmdSet);
|
||||||
CmdSet RemoveBrackets(CmdSet);
|
CmdSet RemoveBrackets(CmdSet);
|
||||||
std::string RemoveBracketsFromString(std::string);
|
std::string RemoveBracketsFromString(std::string);
|
||||||
DefScriptFunctionTable *_GetFunctionTable(void) const;
|
DefScriptFunctionTable *_GetFunctionTable(void) const;
|
||||||
|
|
||||||
bool curIsDebug;
|
|
||||||
unsigned int scripts;
|
|
||||||
DefScript *Script;
|
|
||||||
unsigned int recursionLevel;
|
|
||||||
DefScriptFunctionTable *functionTable;
|
DefScriptFunctionTable *functionTable;
|
||||||
unsigned int functions;
|
unsigned int functions;
|
||||||
void *parentMethod;
|
void *parentMethod;
|
||||||
|
|
||||||
std::map<std::string, unsigned int> permissionMap;
|
std::map<std::string, unsigned char> scriptPermissionMap;
|
||||||
|
std::map<std::string,DefScript*> Script;
|
||||||
|
|
||||||
// Usable internal basic functions:
|
// Usable internal basic functions:
|
||||||
bool func_default(CmdSet);
|
bool func_default(CmdSet);
|
||||||
|
|||||||
@ -92,13 +92,16 @@ bool DefScriptPackage::func_set(CmdSet Set){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string vname,vval=Set.defaultarg;
|
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)
|
if(!stricmp(Set.arg[1].c_str(),"onfail") && vval.find("${")!=std::string::npos)
|
||||||
vval=Set.arg[2];
|
vval=Set.arg[2];
|
||||||
|
|
||||||
variables.Set(vname,vval);
|
variables.Set(vname,vval);
|
||||||
|
|
||||||
|
if(Set.owner && Set.owner->GetDebug())
|
||||||
|
printf("VAR: %s = '%s'\n",vname.c_str(),vval.c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -133,6 +133,10 @@ bool VarSet::ReadVarsFromFile(std::string fn)
|
|||||||
upper=false;
|
upper=false;
|
||||||
prefix.clear();
|
prefix.clear();
|
||||||
}
|
}
|
||||||
|
else if(prefix=="#noprefix")
|
||||||
|
{
|
||||||
|
prefix.clear();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prefix+="::";
|
prefix+="::";
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
bool DefScriptPackage::SCpause(CmdSet Set){
|
bool DefScriptPackage::SCpause(CmdSet Set){
|
||||||
SDL_Delay(atoi(Set.defaultarg.c_str()));
|
((PseuInstance*)parentMethod)->Sleep(atoi(Set.defaultarg.c_str()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,18 +99,16 @@ bool PseuInstance::Init(void) {
|
|||||||
// //DEBUG1(printf("Main_Init: Setting up DefScripts path '%s'\n",defScpPath.c_str()););
|
// //DEBUG1(printf("Main_Init: Setting up DefScripts path '%s'\n",defScpPath.c_str()););
|
||||||
_scp->SetPath(_scpdir);
|
_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"););
|
// //DEBUG1(printf("Main_Init: Setting up predefined DefScript macros...\n"););
|
||||||
_scp->variables.Set("@version_short",_ver_short);
|
_scp->variables.Set("@version_short",_ver_short);
|
||||||
_scp->variables.Set("@version",_ver);
|
_scp->variables.Set("@version",_ver);
|
||||||
|
|
||||||
|
|
||||||
// //DEBUG1(printf("Main_Init: Loading DefScripts from folder '%s'\n",defScpPath.c_str()););
|
// //DEBUG1(printf("Main_Init: Loading DefScripts from folder '%s'\n",defScpPath.c_str()););
|
||||||
//if(!_scp->RunScriptByName("_startup",NULL,255)){
|
if(!_scp->RunScript("_startup",NULL))
|
||||||
// printf("Main_Init: Error executing '_startup.def'\n");
|
{
|
||||||
//}
|
printf("Main_Init: Error executing '_startup.def'\n");
|
||||||
|
}
|
||||||
|
|
||||||
if(_stop){
|
if(_stop){
|
||||||
printf("Errors while initializing, proc halted!!\n");
|
printf("Errors while initializing, proc halted!!\n");
|
||||||
@ -319,6 +317,7 @@ void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
|
|||||||
realmname=v.Get("REALMNAME");
|
realmname=v.Get("REALMNAME");
|
||||||
charname=v.Get("CHARNAME");
|
charname=v.Get("CHARNAME");
|
||||||
networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str());
|
networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str());
|
||||||
|
showopcodes=atoi(v.Get("SHOWOPCODES").c_str());
|
||||||
|
|
||||||
// clientversion is a bit more complicated to add
|
// clientversion is a bit more complicated to add
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class PseuInstanceConf
|
|||||||
std::string charname;
|
std::string charname;
|
||||||
std::string worldhost;
|
std::string worldhost;
|
||||||
uint16 networksleeptime;
|
uint16 networksleeptime;
|
||||||
|
uint8 showopcodes;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -94,7 +94,6 @@ void WorldSession::Update(void)
|
|||||||
while(!pktQueue.empty())
|
while(!pktQueue.empty())
|
||||||
{
|
{
|
||||||
WorldPacket *packet = pktQueue.next();
|
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++)
|
for (uint16 i = 0; table[i].handler != NULL; i++)
|
||||||
{
|
{
|
||||||
@ -105,7 +104,13 @@ void WorldSession::Update(void)
|
|||||||
break;
|
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;
|
delete packet;
|
||||||
@ -170,7 +175,7 @@ void WorldSession::_OnEnterWorld(void)
|
|||||||
if(!_logged)
|
if(!_logged)
|
||||||
{
|
{
|
||||||
_logged=true;
|
_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("@lastwhisper_lang",defScp.variables.Get("@thiswhisper_lang"));
|
||||||
defScp.variables.Set("@thiswhisper_name",plrname);
|
defScp.variables.Set("@thiswhisper_name",plrname);
|
||||||
defScp.variables.Set("@thiswhisper",toString(target_guid));
|
defScp.variables.Set("@thiswhisper",toString(target_guid));
|
||||||
defScp.variables.Set("@thiswhisper_lang",toString((uint64)lang));
|
defScp.variables.Set("@thiswhisper_lang",toString((uint64)lang));*/
|
||||||
defScp.RunScriptByName("_onwhisper",NULL,255);*/
|
GetInstance()->GetScripts()->RunScript("_onwhisper",NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket)
|
void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user