24 #include "../bscript/berror.h" 25 #include "../bscript/impstr.h" 26 #include "../clib/cfgelem.h" 27 #include "../clib/cfgfile.h" 28 #include "../clib/clib.h" 29 #include "../clib/clib_endian.h" 30 #include "../clib/esignal.h" 31 #include "../clib/fileutil.h" 32 #include "../clib/logfacility.h" 33 #include "../clib/opnew.h" 34 #include "../clib/rawtypes.h" 35 #include "../clib/refptr.h" 36 #include "../clib/spinlock.h" 37 #include "../clib/stlutil.h" 38 #include "../clib/strutil.h" 39 #include "../clib/threadhelp.h" 40 #include "../plib/pkg.h" 41 #include "../plib/systemstate.h" 76 size_t len = std::min( lhs.size(), rhs.size() );
78 return ( strnicmp( lhs.c_str(), rhs.c_str(), len ) < 0 );
96 while ( cf.
read( elem ) )
98 if ( !elem.
type_is(
"Equipment" ) )
100 const char* rest = elem.
rest();
101 if ( rest ==
nullptr || *rest ==
'\0' )
103 if ( stricmp( rest, template_name ) == 0 )
127 std::string objtype_str;
128 if ( is >> objtype_str )
130 unsigned int objtype;
131 const char* ot_str = objtype_str.c_str();
132 if ( isdigit( *ot_str ) )
134 objtype =
static_cast<u32>( strtoul( ot_str,
nullptr, 0 ) );
141 ERROR_PRINT <<
"Blech! Can't find '" << ot_str <<
"' named in equip.cfg\n";
145 std::string color_str;
146 unsigned short color = 0;
147 if ( is >> color_str )
149 color =
static_cast<unsigned short>( strtoul( color_str.c_str(),
nullptr, 0 ) );
190 [&](
Mobile::Character* zonechr ) { send_move_if_inrange2( zonechr, client ); } );
198 [&](
Mobile::Character* zonechr ) { send_move_if_inrange2( zonechr, client ); } );
205 [&](
Mobile::Character* zonechr ) { send_client_char_data( zonechr, client ); } );
215 if ( chr->
client !=
nullptr )
218 sprintf( s,
"Serial: 0x%8.08lX, %ld, ObjType 0x%4.04X",
269 for ( Mobile::Character::MobileCont::const_iterator itr = mob->
aggressor_to_.begin();
272 send_sysmessage( client,
"Aggressor to " + ( *itr ).first->name() +
" for " +
277 for ( Mobile::Character::MobileCont::const_iterator itr = mob->
lawfully_damaged_.begin();
280 send_sysmessage( client,
"Lawfully Damaged " + ( *itr ).first->name() +
" for " +
285 for ( Mobile::Character::ToBeReportableList::const_iterator itr = mob->
to_be_reportable_.begin();
292 for ( Mobile::Character::ReportableList::const_iterator itr = mob->
reportable_.begin();
314 send_sysmessage( client,
"Please target a mobile to display repdata for." );
325 std::string filename =
"log/";
345 send_sysmessage( client,
"Please target a player to start packet logging for." );
351 if ( client->
fpLog.empty() )
353 std::string filename =
"log/";
357 if ( !client->
fpLog.empty() )
393 send_sysmessage( client,
"Please target a player to stop packet logging for." );
399 if ( !client->
fpLog.empty() )
402 FLEXLOG( client->
fpLog ) <<
"Log closed at %s" << asctime( &time_tm ) <<
"\n";
404 client->
fpLog.clear();
456 send_sysmessage( client,
"Script profile written to logfile and cleared" );
480 os << i <<
": " << ( *itr )->status() <<
" ";
490 unsigned short wx, wy;
506 send_sysmessage( client,
"Item integrity problems detected. Check logfile" );
519 if ( !isalpha( *t ) && ( *t !=
'_' ) )
527 std::string upp( cmd );
529 if ( upp ==
"AUX" || upp ==
"CON" || upp ==
"PRN" || upp ==
"NUL" )
532 for (
int i = chr->
cmdlevel(); i >= 0; --i )
535 for (
unsigned diridx = 0; diridx < cmdlevel.
searchlist.size(); ++diridx )
537 std::string filename;
540 filename = cmdlevel.
searchlist[diridx].dir + cmd + std::string(
".txt" );
542 filename = pkg->
dir() + filename;
553 ifs.read( temp,
sizeof temp );
555 result.append( temp, static_cast<size_t>( ifs.gcount() ) );
556 }
while ( !ifs.eof() );
565 const char* lang =
nullptr )
567 std::string scriptname;
569 const char* t = strchr( text,
' ' );
572 scriptname = std::string( text, t );
583 t = scriptname.c_str();
586 if ( !isalnum( *t ) && ( *t !=
'_' ) )
594 std::string upp( scriptname );
596 if ( upp ==
"AUX" || upp ==
"CON" || upp ==
"PRN" || upp ==
"NUL" )
599 for (
int i = client->
chr->
cmdlevel(); i >= 0; --i )
603 for (
unsigned diridx = 0; diridx < cmdlevel.
searchlist.size(); ++diridx )
619 if ( prog.
get() != nullptr )
624 if ( prog->haveProgram )
633 woffset =
static_cast<size_t>( scriptname.length() + ( params ==
"" ? 1 : 2 ) );
637 while ( *( wtext + woffset + wtlen ) )
647 ex->pushArg(
new Bscript::BError(
"Invalid Unicode speech received." ) );
654 ex->addModule( uoemod );
655 ex->os_module->priority = 100;
657 if ( ex->setProgram( prog.
get() ) )
666 ERROR_PRINT <<
"script " << scriptname <<
": setProgram failed\n";
725 ( *f )( client, text + ( *itr1 ).first.size() );
ToBeReportableList to_be_reportable_
static Item * create(u32 objtype, u32 serial=0)
bool check_single_zone_item_integrity(int, int, Realms::Realm *)
void textcmd_list_scripts(Network::Client *)
ref_ptr< Bscript::EScriptProgram > find_script2(const ScriptDef &script, bool complain_if_not_found, bool cache_script)
void quickconfig(const Plib::Package *pkg, const std::string &name_ecl)
unsigned int get_objtype_byname(const char *str)
bool is_criminal() const
A Mobile is Criminal if: he has an active Criminal Timer, which has not timed out. OR he is a murderer.
static void show_repdata(Network::Client *client, Mobile::Character *mob)
Internal Command: .i_repdata Show Reputation System Data for a Targetted Mobile Displays: Murderer st...
bool process_command(Network::Client *client, const char *text, const u16 *wtext, const char *lang)
void textcmd_stoplog(Network::Client *client)
void start_packetlog(Mobile::Character *looker, Mobile::Character *mob)
FullMsgTargetCursor ident_cursor
void send_move_if_inrange2(Mobile::Character *chr, Network::Client *client)
void check_character_integrity()
void stop_packetlog(Mobile::Character *looker, Mobile::Character *mob)
void textcmd_shutdown(Network::Client *)
void PrintAllocationData()
void textcmd_singlezone_integ_item(Network::Client *client)
void textcmd_log_profile(Network::Client *client)
void log_all_script_cycle_counts(bool clear_counters)
MobileCont lawfully_damaged_
unsigned char tilelayer(unsigned short tilenum)
void textcmd_listarmor(Network::Client *client)
const HoldList & getHoldlist()
void mkupper(std::string &str)
char * binary(unsigned int val, int nbits)
Core::polclock_t polclock
std::tm localtime(const std::time_t &t)
threadsafe version of localtime
std::string decint(unsigned short v)
void show_repdata(Mobile::Character *looker, Mobile::Character *mob)
bool FindEquipTemplate(const char *template_name, Clib::ConfigElem &elem)
const unsigned VALID_ITEM_COLOR_MASK
bool inrange(const UObject *c1, unsigned short x, unsigned short y)
void(* TextCmdFunc)(Network::Client *)
void list_scripts(const char *desc, const ExecList &ls)
unsigned char cmdlevel() const
void textcmd_procs(Network::Client *client)
#define OSTRINGSTREAM_STR(x)
void handle_ident_cursor(Mobile::Character *chr, PKTBI_6C *msgin)
Core::CharacterRef controller_
const ExecList & getRunlist()
bool operator()(const std::string &lhs, const std::string &rhs) const
void textcmd_integ_item(Network::Client *client)
std::string timeoutstr(polclock_t at)
std::string hexint(unsigned short v)
const char * rest() const
void textcmd_flag2(Network::Client *client, const char *text)
Bscript::BObjectImp * equip_from_template(Mobile::Character *chr, const char *template_name)
void send_move(Client *client, const Character *chr)
void textcmd_constat(Network::Client *client)
void(* ParamTextCmdFunc)(Network::Client *, const char *)
UOExecutor * create_script_executor()
polclock_t next_run_clock() const
NetworkManager networkManager
Core::OneShotTask * repsys_task_
const char * name() const
#define OPEN_FLEXLOG(filename, open_timestamp)
void textcmd_flag1(Network::Client *client, const char *text)
ParamTextCmds paramtextcmds
void register_command(const char *cmd, TextCmdFunc f)
NoLosCharacterCursor repdata_cursor
void textcmd_threads(Network::Client *client)
bool convertUCtoArray(const u16 *in_wtext, Bscript::ObjArray *&out_text, size_t textlen, bool ConvFromBE)
void textcmd_heapcheck(Network::Client *)
ReportableList reportable_
void textcmd_startlog(Network::Client *client)
void equip(Items::Item *item)
static void InVisualRange(const UObject *obj, F &&f)
StateManager stateManager
void zone_convert(unsigned short x, unsigned short y, unsigned short *wx, unsigned short *wy, const Realms::Realm *realm)
std::atomic< unsigned int > child_threads
ScriptScheduler scriptScheduler
NoLosCharacterCursor stoplog_cursor
bool start_textcmd_script(Network::Client *client, const char *text, const u16 *wtext=nullptr, const char *lang=nullptr)
bool remove_prop(const char *propname, std::string *value)
NoLosCharacterCursor startlog_cursor
Core::polclock_t criminal_until_
bool type_is(const char *name) const
void textcmd_repdata(Network::Client *client)
bool send_object_cursor(Network::Client *client, PKTBI_6C::CURSOR_TYPE crstype=PKTBI_6C::CURSOR_TYPE_NEUTRAL)
void textcmd_log_profile_clear(Network::Client *client)
void textcmd_orphans(Network::Client *client)
void list_crit_scripts(const char *desc, const ExecList &ls)
void schedule_executor(UOExecutor *ex)
void send_client_char_data(Mobile::Character *chr, Network::Client *client)
bool FileExists(const char *filename)
void textcmd_ident(Network::Client *client)
bool read(ConfigElem &elem)
void textcmd_integ_chr(Network::Client *)
std::string get_textcmd_help(Mobile::Character *chr, const char *cmd)
bool equippable(const Items::Item *item) const
virtual std::string name() const
void textcmd_list_crit_scripts(Network::Client *)
std::lock_guard< SpinLock > SpinLockGuard
Clib::SpinLock _fpLog_lock
const polclock_t POLCLOCKS_PER_SEC
std::atomic< bool > exit_signalled
bool check_item_integrity()
void textcmd_resendchars(Network::Client *client)
void send_sysmessage(Network::Client *client, const char *text, unsigned short font, unsigned short color)
void update_item_to_inrange(const Item *item)
const std::string & dir() const
#define CLOSE_FLEXLOG(id)