* implemented automatic conf file loading using newly added "lgetfiles" script func.
* forgot to mention on last commit: a) support almost infinite DefScript args now: @0 ... @4294967295; b) speeded up DefScript execution speed by ~10% * TODO: load .def files the same way as the conf files now.
This commit is contained in:
parent
dff2d2085e
commit
7ffc21bec5
@ -1,19 +1,33 @@
|
|||||||
#permission=255
|
#permission=255
|
||||||
// Load required conf files.
|
|
||||||
LOADCONF PseuWoW.conf
|
// Load all conf files from directory /conf/
|
||||||
LOADCONF users.conf
|
// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount'
|
||||||
LOADCONF ScriptConfig.conf
|
SET,fcount ?{LGETFILES,fl,conf conf}
|
||||||
|
LOGDETAIL * Loading ${fcount} conf files.
|
||||||
|
// iterate over all files and load them; if counter i is equal to the amount of files we are done.
|
||||||
|
SET,i 0
|
||||||
|
LOOP
|
||||||
|
IF ?{EQUAL,${i} ${fcount}}
|
||||||
|
EXITLOOP
|
||||||
|
ENDIF
|
||||||
|
SET,fn ?{LINDEX,fl ${i}}
|
||||||
|
LOG * Loading conf file [ ${fn} ]
|
||||||
|
LOADCONF ${fn}
|
||||||
|
ADD,i 1
|
||||||
|
ENDLOOP
|
||||||
|
|
||||||
|
UNSET fcount
|
||||||
|
UNSET i
|
||||||
|
UNSET fn
|
||||||
|
LDELETE fl
|
||||||
|
|
||||||
// Apply the configuration
|
// Apply the configuration
|
||||||
APPLYCONF
|
APPLYCONF
|
||||||
|
LOG * Configuration applied.
|
||||||
|
|
||||||
// Apply user permissions
|
// Apply user permissions
|
||||||
APPLYPERMISSIONS
|
APPLYPERMISSIONS
|
||||||
|
|
||||||
IF ${#ENABLEGUI}
|
|
||||||
LOADCONF gui.conf
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
// remove dangerous variables
|
// remove dangerous variables
|
||||||
CLEANUPVARS
|
CLEANUPVARS
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,7 @@ void DefScriptPackage::_InitDefScriptInterface(void)
|
|||||||
AddFunc("objectknown",&DefScriptPackage::SCObjectKnown);
|
AddFunc("objectknown",&DefScriptPackage::SCObjectKnown);
|
||||||
AddFunc("getplayerperm",&DefScriptPackage::SCGetPlayerPerm);
|
AddFunc("getplayerperm",&DefScriptPackage::SCGetPlayerPerm);
|
||||||
AddFunc("getscriptperm",&DefScriptPackage::SCGetScriptPerm);
|
AddFunc("getscriptperm",&DefScriptPackage::SCGetScriptPerm);
|
||||||
|
AddFunc("lgetfiles",&DefScriptPackage::SCGetFileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set)
|
DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set)
|
||||||
@ -187,7 +188,7 @@ DefReturnResult DefScriptPackage::SCloadconf(CmdSet& Set){
|
|||||||
|
|
||||||
if(variables.ReadVarsFromFile(fn))
|
if(variables.ReadVarsFromFile(fn))
|
||||||
{
|
{
|
||||||
log("Loaded conf file [%s]",fn.c_str());
|
logdev("Loaded conf file [%s]",fn.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,6 +722,32 @@ DefReturnResult DefScriptPackage::SCGetItemProtoValue(CmdSet& Set)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefReturnResult DefScriptPackage::SCGetFileList(CmdSet& Set)
|
||||||
|
{
|
||||||
|
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||||
|
l->clear();
|
||||||
|
*l = (DefList)GetFileList(Set.defaultarg);
|
||||||
|
if(Set.arg[1].length())
|
||||||
|
{
|
||||||
|
std::string ext = ".";
|
||||||
|
ext += Set.arg[1];
|
||||||
|
ext = stringToLower(ext);
|
||||||
|
for(DefList::iterator i = l->begin(); i != l->end(); )
|
||||||
|
{
|
||||||
|
std::string tmp = stringToLower(i->c_str() + (i->length() - ext.length()));
|
||||||
|
if( stringToLower(i->c_str() + (i->length() - ext.length())) != ext )
|
||||||
|
{
|
||||||
|
l->erase(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toString((uint64)l->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
||||||
{
|
{
|
||||||
static char *prefix = "USERS::";
|
static char *prefix = "USERS::";
|
||||||
|
|||||||
@ -35,5 +35,6 @@ DefReturnResult SCGetObjectType(CmdSet&);
|
|||||||
DefReturnResult SCObjectKnown(CmdSet&);
|
DefReturnResult SCObjectKnown(CmdSet&);
|
||||||
DefReturnResult SCGetPlayerPerm(CmdSet&);
|
DefReturnResult SCGetPlayerPerm(CmdSet&);
|
||||||
DefReturnResult SCGetScriptPerm(CmdSet&);
|
DefReturnResult SCGetScriptPerm(CmdSet&);
|
||||||
|
DefReturnResult SCGetFileList(CmdSet&);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -311,6 +311,7 @@ PseuInstanceConf::PseuInstanceConf()
|
|||||||
{
|
{
|
||||||
enablecli=false;
|
enablecli=false;
|
||||||
exitonerror=false;
|
exitonerror=false;
|
||||||
|
debug=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
|
void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user