16 #include <format/format.h> 17 #include "../clib/clib_endian.h" 18 #include "../clib/logfacility.h" 19 #include "../clib/rawtypes.h" 20 #include "../clib/refptr.h" 21 #include "../plib/systemstate.h" 125 if ( ( ( 0x203B <= HairStyle ) && ( HairStyle <= 0x203D ) ) ||
126 ( ( 0x2044 <= HairStyle ) && ( HairStyle <= 0x204A ) ) ||
127 ( ( 0x2FBF <= HairStyle ) && ( HairStyle <= 0x2FC2 ) ) ||
128 ( ( 0x2FCC <= HairStyle ) && ( HairStyle <= 0x2FD2 ) ) ||
129 ( ( 0x4258 <= HairStyle ) && ( HairStyle <= 0x425F ) ) ||
130 ( ( 0x4261 <= HairStyle ) && ( HairStyle <= 0x4262 ) ) ||
131 ( ( 0x4273 <= HairStyle ) && ( HairStyle <= 0x4275 ) ) ||
132 ( ( 0x42aa <= HairStyle ) && ( HairStyle <= 0x42ab ) ) || ( HairStyle == 0x42B1 ) )
155 if ( ( ( 0x203E <= BeardStyle ) && ( BeardStyle <= 0x2041 ) ) ||
156 ( ( 0x204B <= BeardStyle ) && ( BeardStyle <= 0x204D ) ) ||
157 ( ( 0x42AD <= BeardStyle ) && ( BeardStyle <= 0x42B0 ) &&
190 if ( ( 0x3B44 <= FaceStyle ) && ( FaceStyle <= 0x3B4D ) )
194 if ( ( 0x3B4E <= FaceStyle ) && ( FaceStyle <= 0x3B57 ) )
203 if ( client->
acct ==
nullptr )
206 <<
" tried to create a character without an account!\n";
220 ERROR_PRINT <<
"Create Character: Invalid parameters.\n";
233 unsigned short graphic;
245 if ( ( msg->
Sex & 0x6 ) == 0x6 )
250 else if ( ( msg->
Sex & 0x4 ) == 0x4 )
288 std::string tmpstr( msg->
Name,
sizeof msg->
Name );
289 const char* tstr = tmpstr.c_str();
290 for (
unsigned int i = 0; i < strlen( tstr ); i++ )
292 char tmpchr = tstr[i];
293 if ( tmpchr >=
' ' && tmpchr <=
'~' )
295 if ( tmpchr !=
'{' && tmpchr !=
'}' )
299 ERROR_PRINT <<
"Create Character: Attempted to use invalid character '" << tmpchr <<
"' pos '" 300 << i <<
"' in name '" << tstr <<
"'. Client IP: " << client->
ipaddrAsString()
301 <<
" Client Name: " << client->
acct->
name() <<
"\n";
330 bool valid_stats =
false;
332 unsigned int stat_min, stat_max;
334 std::vector<std::string>::size_type sidx;
339 stat_max = ( stat_min = strtoul( statstr, &maxpos, 0 ) );
340 if ( *( maxpos++ ) ==
'-' )
341 stat_max = strtoul( maxpos, 0, 0 );
342 if ( stat_total >= stat_min && stat_total <= stat_max )
348 tmp <<
"Create Character: Stats sum to " << stat_total <<
".\n" 349 <<
"Valid values/ranges are: ";
362 ERROR_PRINT <<
"Create Character: A stat was too small." 380 ERROR_PRINT <<
"Create Character: A skill number was out of range\n";
386 if ( ( !noskills ) &&
390 ERROR_PRINT <<
"Create Character: Starting skill values incorrect\n";
428 chr->
equip( tmpitem );
431 ERROR_PRINT.Format(
"Create Character: Failed to equip hair 0x{:X}\n" ) << tmpitem->
graphic;
443 chr->
equip( tmpitem );
446 ERROR_PRINT.Format(
"Create Character: Failed to equip beard 0x{:X}\n" ) << tmpitem->
graphic;
454 chr->
equip( backpack );
472 move_item( tmpitem, tmpitem->
x, tmpitem->
y, tmpitem->
z,
nullptr );
475 backpack->
add( tmpitem );
484 tmpitem->
color = 0x021F;
486 chr->
equip( tmpitem );
492 chr->
equip( tmpitem );
494 unsigned short pantstype, shirttype;
511 chr->
equip( tmpitem );
518 chr->
equip( tmpitem );
527 chr->
equip( tmpitem );
533 POLLOG.Format(
"Account {} created character 0x{:X}\n" ) << client->
acct->
name() << chr->
serial;
543 if ( prog.
get() != nullptr )
565 ERROR_PRINT <<
"script misc/oncreate: setProgram failed\n";
575 chr->
setname(
"new character" );
580 chr->
x = chr->
y = chr->
z = chr->
facing = 1;
598 if ( client->
acct ==
nullptr )
601 <<
" tried to create a character without an account!\n";
614 ERROR_PRINT <<
"Create Character: Invalid parameters.\n";
627 unsigned short graphic;
647 std::string tmpstr( msg->
name,
sizeof msg->
name );
648 const char* tstr = tmpstr.c_str();
649 for (
unsigned int i = 0; i < strlen( tstr ); i++ )
651 char tmpchr = tstr[i];
652 if ( tmpchr >=
' ' && tmpchr <=
'~' )
654 if ( tmpchr !=
'{' && tmpchr !=
'}' )
658 ERROR_PRINT <<
"Create Character: Attempted to use invalid character '" << tmpchr <<
"' pos '" 659 << i <<
"' in name '" << tstr <<
"'. Client IP: " << client->
ipaddrAsString()
660 <<
" Client Name: " << client->
acct->
name() <<
"\n";
689 bool valid_stats =
false;
691 unsigned int stat_min, stat_max;
693 std::vector<std::string>::size_type sidx;
698 stat_max = ( stat_min = strtoul( statstr, &maxpos, 0 ) );
699 if ( *( maxpos++ ) ==
'-' )
700 stat_max = strtoul( maxpos, 0, 0 );
701 if ( stat_total >= stat_min && stat_total <= stat_max )
707 tmp <<
"Create Character: Stats sum to " << stat_total <<
".\n" 708 <<
"Valid values/ranges are: ";
721 ERROR_PRINT <<
"Create Character: A stat was too small." 741 ERROR_PRINT <<
"Create Character: A skill number was out of range\n";
749 if ( ( !noskills ) &&
754 ERROR_PRINT <<
"Create Character: Starting skill values incorrect\n";
795 chr->
equip( tmpitem );
798 ERROR_PRINT.Format(
"Create Character: Failed to equip hair 0x{:X}\n" ) << tmpitem->
graphic;
810 chr->
equip( tmpitem );
813 ERROR_PRINT.Format(
"Create Character: Failed to equip beard 0x{:X}\n" ) << tmpitem->
graphic;
825 chr->
equip( tmpitem );
828 ERROR_PRINT.Format(
"Create Character: Failed to equip face 0x{:X}\n" ) << tmpitem->
graphic;
836 chr->
equip( backpack );
854 move_item( tmpitem, tmpitem->
x, tmpitem->
y, tmpitem->
z,
nullptr );
857 backpack->
add( tmpitem );
866 tmpitem->
color = 0x021F;
868 chr->
equip( tmpitem );
874 chr->
equip( tmpitem );
876 unsigned short pantstype, shirttype;
893 chr->
equip( tmpitem );
900 chr->
equip( tmpitem );
909 chr->
equip( tmpitem );
915 POLLOG.Format(
"Account {} created character 0x{:X}\n" ) << client->
acct->
name() << chr->
serial;
925 if ( prog.
get() != nullptr )
948 ERROR_PRINT <<
"script misc/oncreate: setProgram failed\n";
955 if ( client->
acct ==
nullptr )
958 <<
" tried to create a character without an account!\n";
972 ERROR_PRINT <<
"Create Character: Invalid parameters.\n";
985 unsigned short graphic;
997 if ( ( msg->
Sex & 0x6 ) == 0x6 )
1002 else if ( ( msg->
Sex & 0x4 ) == 0x4 )
1040 std::string tmpstr( msg->
Name,
sizeof msg->
Name );
1041 const char* tstr = tmpstr.c_str();
1042 for (
unsigned int i = 0; i < strlen( tstr ); i++ )
1044 char tmpchr = tstr[i];
1045 if ( tmpchr >=
' ' && tmpchr <=
'~' )
1047 if ( tmpchr !=
'{' && tmpchr !=
'}' )
1051 ERROR_PRINT <<
"Create Character: Attempted to use invalid character '" << tmpchr <<
"' pos '" 1052 << i <<
"' in name '" << tstr <<
"'. Client IP: " << client->
ipaddrAsString()
1053 <<
" Client Name: " << client->
acct->
name() <<
"\n";
1082 bool valid_stats =
false;
1084 unsigned int stat_min, stat_max;
1086 std::vector<std::string>::size_type sidx;
1091 stat_max = ( stat_min = strtoul( statstr, &maxpos, 0 ) );
1092 if ( *( maxpos++ ) ==
'-' )
1093 stat_max = strtoul( maxpos, 0, 0 );
1094 if ( stat_total >= stat_min && stat_total <= stat_max )
1100 tmp <<
"Create Character: Stats sum to " << stat_total <<
".\n" 1101 <<
"Valid values/ranges are: ";
1114 ERROR_PRINT <<
"Create Character: A stat was too small." 1137 unsigned char temp_skillid = 0;
1173 ERROR_PRINT <<
"Create Character: A skill number was out of range\n";
1182 if ( ( !noskills ) &&
1187 ERROR_PRINT <<
"Create Character: Starting skill values incorrect\n";
1228 chr->
equip( tmpitem );
1231 ERROR_PRINT.Format(
"Create Character: Failed to equip hair 0x{:X}\n" ) << tmpitem->
graphic;
1243 chr->
equip( tmpitem );
1246 ERROR_PRINT.Format(
"Create Character: Failed to equip beard 0x{:X}\n" ) << tmpitem->
graphic;
1254 chr->
equip( backpack );
1267 tmpitem->
x = chr->
x;
1268 tmpitem->
y = chr->
y;
1269 tmpitem->
z = chr->
z;
1272 move_item( tmpitem, tmpitem->
x, tmpitem->
y, tmpitem->
z,
nullptr );
1275 backpack->
add( tmpitem );
1284 tmpitem->
color = 0x021F;
1286 chr->
equip( tmpitem );
1292 chr->
equip( tmpitem );
1294 unsigned short pantstype, shirttype;
1311 chr->
equip( tmpitem );
1318 chr->
equip( tmpitem );
1327 chr->
equip( tmpitem );
1333 POLLOG.Format(
"Account {} created character 0x{:X}\n" ) << client->
acct->
name() << chr->
serial;
1343 if ( prog.
get() != nullptr )
1366 ERROR_PRINT <<
"script misc/oncreate: setProgram failed\n";
#define UOBJ_GARGOYLE_FEMALE
void ClientCreateChar(Network::Client *client, PKTIN_00 *msg)
void register_with_supporting_multi(Item *item)
static Item * create(u32 objtype, u32 serial=0)
std::vector< std::string > total_stats_at_creation
#define UOBJ_GARGOYLE_MALE
bool can_add_to_slot(u8 &slotIndex)
Core::gameclock_t created_at
void set_character(int index, Mobile::Character *chr)
void add_item_to_world(Items::Item *item)
void set_vitals_to_maximum()
const Mobile::Attribute * pAttr
bool newbie_starting_equipment
void SetCharacterWorldPosition(Mobile::Character *chr, Realms::WorldChangeReason reason)
unsigned char tilelayer(unsigned short tilenum)
void addModule(ExecutorModule *module)
u32 GetNextSerialNumber(void)
ref_ptr< Core::WornItemsContainer > wornitems
void calc_vital_stuff(bool i_mod=true, bool v_mod=true)
Mobile::Character * get_character(int index)
unsigned char cmdlevel() const
void start_client_char(Network::Client *client)
bool validface(u16 FaceStyle)
bool has_active_characters()
Returns true if at least one character from this account is already logged in.
virtual void add(Items::Item *item)
unsigned short starting_gold
void setamount(u16 amount)
void pushArg(BObjectImp *arg)
void send_login_error(Network::Client *client, unsigned char reason)
const UOSkill & GetUOSkill(unsigned skillid)
UOExecutor * create_script_executor()
const Mobile::Attribute * pAttrStrength
NetworkManager networkManager
const AttributeValue & attribute(unsigned attrid) const
const char * name() const
bool setProgram(EScriptProgram *prog)
void createchar2(Accounts::Account *acct, unsigned index)
const char * AddressToString(struct sockaddr *addr)
bool validhair(u16 HairStyle)
gameclock_t read_gameclock()
Reads the current value of the game clock.
void setname(const std::string &)
void equip(Items::Item *item)
void move_item(Item *item, UFACING facing)
SettingsManager settingsManager
bool Insert(UObject *obj)
short validhaircolor(u16)
#define UOBJ_HUMAN_FEMALE
const Core::MessageTypeFilter * msgtype_filter
const Mobile::Attribute * pAttrIntelligence
unsigned char support_faces
void position_changed(void)
std::string ipaddrAsString() const
ObjectStorageManager objStorageManager
void run_logon_script(Mobile::Character *chr)
std::string default_privlist() const
u32 UOExpansionFlagClient
Realms::Realm * find_realm(const std::string &name)
std::unique_ptr< MessageTypeFilter > game_filter
void schedule_executor(UOExecutor *ex)
const Mobile::Attribute * pAttrDexterity
StartingLocations startlocations
void set_privs(const std::string &privlist)
ref_ptr< Bscript::EScriptProgram > find_script(const std::string &name, bool complain_if_not_found, bool cache_script)
bool equippable(const Items::Item *item) const
unsigned short character_slots
void ClientCreateCharKR(Network::Client *client, PKTIN_8D *msg)
Bscript::BObjectImp * make_mobileref(Mobile::Character *chr)
unsigned char default_cmdlevel() const
#define LOGIN_ERROR_OTHER_CHAR_INUSE
boost_utils::object_name_flystring name_
Module::OSExecutorModule * os_module
void ClientCreateChar70160(Network::Client *client, PKTIN_F8 *msg)
bool validbeard(u16 BeardStyle)
UoClientGeneral uoclient_general