20 #include "../../bscript/berror.h" 21 #include "../../bscript/bobject.h" 22 #include "../../bscript/dict.h" 23 #include "../../bscript/impstr.h" 24 #include "../../clib/clib.h" 25 #include "../../clib/clib_MD5.h" 26 #include "../../clib/compilerspecifics.h" 27 #include "../../clib/fileutil.h" 28 #include "../../clib/rawtypes.h" 29 #include "../../clib/strutil.h" 30 #include "../../clib/threadhelp.h" 31 #include "../../plib/pkg.h" 32 #include "../../plib/systemstate.h" 33 #include "../cmdlevel.h" 35 #include "../globals/settings.h" 36 #include "../globals/uvars.h" 37 #include "../item/item.h" 38 #include "../item/itemdesc.h" 39 #include "../listenpt.h" 40 #include "../packetscrobj.h" 41 #include "../polcfg.h" 42 #include "../proplist.h" 43 #include "../realms.h" 44 #include "../realms/realm.h" 45 #include "../tooltips.h" 46 #include "../uobject.h" 47 #include "../uoexhelp.h" 76 typedef PackageObjImpBase
base;
82 virtual Bscript::
BObjectImp* copy() const POL_OVERRIDE;
83 virtual Bscript::
BObjectImp* call_method( const
char* methodname,
84 Bscript::
Executor& ex ) POL_OVERRIDE;
85 virtual Bscript::
BObjectRef get_member( const
char* membername ) POL_OVERRIDE;
88 : PackageObjImpBase( &packageobjimp_type, other )
94 using namespace Module;
120 using namespace Bscript;
136 return new BError(
"undefined method" );
140 if ( stricmp( membername,
"name" ) == 0 )
144 else if ( stricmp( membername,
"version" ) == 0 )
148 else if ( stricmp( membername,
"supports_http" ) == 0 )
153 else if ( stricmp( membername,
"npcdesc" ) == 0 )
177 return new BLong( 1 );
181 return new BError(
"Invalid parameter type" );
188 const String* cmdlevel_alias;
191 return new BError(
"Expected 1 parameter." );
192 else if (
getParam( 0, cmdlevel_num ) )
194 if ( cmdlevel_num >= static_cast<int>(
Core::gamestate.cmdlevels.size() ) )
202 if ( cmdlevel ==
nullptr )
203 return new BError(
"Could not find a command level with that alias." );
208 return new BError(
"Invalid parameter type." );
215 return new BError(
"Invalid parameter type." );
218 if ( cmdlevel_search ==
nullptr )
219 return new BError(
"Could not find a command level with that name." );
226 std::unique_ptr<ObjArray> arr(
new ObjArray );
230 arr->addElement( imp );
232 return arr.release();
239 return new BError(
"Invalid parameter type." );
244 return new BError(
"No package found by that name." );
251 std::unique_ptr<BDictionary> pkg_list(
new BDictionary );
254 std::unique_ptr<BDictionary> cmd_lvl_list(
new BDictionary );
258 if ( script_list ==
nullptr )
260 else if ( !script_list->
ref_arr.empty() )
261 cmd_lvl_list->addMember(
new BLong( num ), script_list );
263 if ( cmd_lvl_list->contents().size() > 0 )
264 pkg_list->addMember(
new String(
"" ), cmd_lvl_list.release() );
272 std::unique_ptr<BDictionary> cmd_lvl_list(
new BDictionary );
276 if ( script_list ==
nullptr )
278 else if ( !script_list->
ref_arr.empty() )
279 cmd_lvl_list->addMember(
new BLong( num ), script_list );
281 if ( cmd_lvl_list->contents().size() > 0 )
282 pkg_list->addMember(
new String( pkg->
name().c_str() ), cmd_lvl_list.release() );
284 return pkg_list.release();
291 return new BLong( 1 );
306 std::unique_ptr<BStruct> details(
new BStruct() );
307 details->addMember(
"width",
new BLong( realm->
width() ) );
308 details->addMember(
"height",
new BLong( realm->
height() ) );
309 details->addMember(
"season",
new BLong( realm->
season() ) );
316 return details.release();
326 realm_name =
static_cast<const String*
>( imp );
330 return new BError( std::string(
"Parameter must be a String or empty, got " ) +
334 if ( realm_name->
length() > 0 )
338 return new BError(
"Realm not found." );
345 std::vector<Realms::Realm*>::iterator itr;
362 return new BLong( 1 );
367 unsigned int objtype;
371 if (
id.objtype == 0 &&
id.graphic == 0 )
375 std::unique_ptr<BStruct> descriptor(
new BStruct() );
377 id.PopulateStruct( descriptor.get() );
379 return descriptor.release();
383 return new BError(
"Invalid parameter type" );
390 unsigned short amount;
399 return new BError(
"Invalid parameter type" );
410 return new BError(
"Packet type too high" );
412 return new Core::BPacket( static_cast<u8>( type ), static_cast<signed short>( size ) );
416 return new BError(
"Invalid parameter type" );
426 return new BError(
"Invalid parameter" );
430 return new BError(
"BaseRealm not found." );
432 return new BError(
"BaseRealm is a ShadowRealm." );
434 return new BError(
"Realmname already defined." );
440 std::ostringstream thname;
441 thname <<
"Decay_" << realm_name->
value();
446 return new BLong( 1 );
453 return new BError(
"Invalid parameter" );
458 return new BError(
"Realm not found." );
460 return new BError(
"Realm is not a ShadowRealm." );
462 return new BError(
"Mobiles in Realm." );
464 return new BError(
"Offline characters in Realm" );
466 return new BError(
"Items in Realm." );
468 return new BError(
"Multis in Realm." );
471 return new BLong( 1 );
478 return new BError(
"Invalid parameter" );
479 if ( string->
length() < 1 )
480 return new BError(
"String is empty" );
483 return new BError(
"Failed to encrypt" );
484 return new String( temp );
494 const std::string filepath =
"log/cpprofile.log";
495 std::ofstream ofs( filepath.c_str(), std::ios::out | std::ios::app );
497 if ( !ofs.is_open() )
498 return new BError(
"Unable to open file: " + filepath );
501 auto t = std::time(
nullptr );
503 ofs << std::string( 80,
'=' ) << std::endl;
504 ofs <<
"CProp profiling information dumped on " << std::asctime( &tm ) << std::endl;
505 ofs <<
"the profiler is using an estimated amount of " 507 ofs <<
"the profiler is currently " 515 ofs << std::string( 80,
'=' ) << std::endl;
518 return new BError(
"Error during write." );
521 return new BLong( 1 );
void decay_thread_shadow(void *arg)
std::string format_description(unsigned int polflags, const std::string &descdef, unsigned short amount, const std::string suffix)
Bscript::ObjArray * GetCommandsInPackage(Plib::Package *m_pkg, int cmdlvl_num)
bool MD5_Encrypt(const std::string &in, std::string &out)
bool defined_realm(const std::string &name)
const std::string & value() const
Bscript::BObjectImp * mf_SetSysTrayPopupText()
Bscript::BObjectImp * mf_GetCmdLevelNumber()
Bscript::BObjectImp * mf_IncRevision()
bool isa(BObjectType type) const
void remove_realm(const std::string &name)
static CPropProfiler & instance()
Bscript::BApplicObjType packageobjimp_type
std::tm localtime(const std::time_t &t)
threadsafe version of localtime
bool getParam(unsigned param, int &value)
unsigned getUOMapID() const
polticks_t polticks_t_to_ms(polticks_t ticks)
Bscript::BObjectImp * mf_CreatePacket()
const Plib::Package * operator->() const
void reload_configuration()
void start_thread(void(*entry)(void *), const char *thread_name, void *arg)
BObjectImp * getParamImp(unsigned param)
virtual Bscript::BObjectImp * call_method(const char *methodname, Bscript::Executor &ex) POL_OVERRIDE
const std::string & name() const
unsigned int mobile_count() const
void CoreSetSysTrayToolTip(const std::string &text, Priority priority)
const ItemDesc & find_itemdesc(unsigned int objtype)
PolSystemExecutorModule(Bscript::Executor &exec)
Package * find_package(const std::string &pkgname)
Bscript::BObjectImp * mf_ReadMillisecondClock()
const char * paramAsString(unsigned param)
Bscript::BObjectImp * mf_GetCmdLevelName()
unsigned int offline_mobile_count() const
std::string hexint(unsigned short v)
Bscript::BObjectImp * mf_ListTextCommands()
PackagePtrHolder(Plib::Package *pkg)
Bscript::BObjectImp * mf_MD5Encrypt()
Bscript::BObjectImp * mf_AddRealm()
std::vector< Realms::Realm * > Realms
Bscript::BObjectImp * mf_Realms()
unsigned short height() const
unsigned int multi_count() const
Bscript::BObjectImp * mf_ReloadConfiguration()
Bscript::BObjectImp * mf_FormatItemDescription()
Bscript::BObjectImp * mf_LogCPropProfile()
void addMember(const char *name, BObjectRef val)
Bscript::BObjectImp * mf_GetItemDescriptor()
size_t estimateSize() const
const String * getStringParam(unsigned param)
SettingsManager settingsManager
virtual Bscript::BObjectRef get_member(const char *membername) POL_OVERRIDE
bool getObjtypeParam(Executor &exec, unsigned param, unsigned int &objtype)
const Plib::Package * Ptr() const
Bscript::BObjectImp * mf_GetPackageByName()
bool getUObjectParam(Executor &exec, unsigned param, UObject *&objptr)
BStruct * SetupRealmDetails(Realms::Realm *realm)
unsigned int toplevel_item_count() const
CmdLevel * find_cmdlevel(const char *name)
unsigned short width() const
Realms::Realm * find_realm(const std::string &name)
Bscript::BObjectImp * mf_DeleteRealm()
Bscript::BObjectImp * GetListenPoints()
std::string GetPackageCfgPath(const Package *pkg, const std::string &filename)
bool FileExists(const char *filename)
virtual u8 typeOfInt() const POL_OVERRIDE
void send_object_cache_to_inrange(const UObject *obj)
Bscript::BApplicObj< PackagePtrHolder > PackageObjImpBase
void add_realm(const std::string &name, Realms::Realm *base)
void dumpProfile(std::ostream &os) const
Bscript::BObjectImp * mf_ListenPoints()
virtual Bscript::BObjectImp * copy() const POL_OVERRIDE
const char * data() const
Bscript::BObjectImp * mf_Packages()
static const char * typestr(BObjectType typ)
Plib::Package * operator->()
const std::string & dir() const
bool getParam(unsigned param, int &value)
CmdLevel * FindCmdLevelByAlias(const std::string &str)
virtual const char * typeOf() const POL_OVERRIDE