28 #include "../../bscript/berror.h" 29 #include "../../bscript/executor.h" 30 #include "../../bscript/impstr.h" 31 #include "../../bscript/objmembers.h" 32 #include "../../bscript/objmethods.h" 33 #include "../../clib/clib_MD5.h" 34 #include "../../plib/systemstate.h" 36 #include "../globals/uvars.h" 37 #include "../mobile/charactr.h" 38 #include "../network/client.h" 39 #include "../polcfg.h" 41 #include "../uoscrobj.h" 51 void delete_character( Accounts::Account* acct, Mobile::Character* chr,
int charidx );
52 void createchar2( Accounts::Account* acct,
unsigned index );
58 const char* AccountObjImp::typeOf()
const 62 u8 AccountObjImp::typeOfInt()
const 83 using namespace Bscript;
84 BObjectImp* result =
nullptr;
91 return new BError(
"Not enough parameters" );
96 BObjectRef ref_temp = get_member( mname->value().c_str() );
97 BObjectRef& ref = ref_temp;
98 BObject* bo = ref.get();
99 BObjectImp* ret = bo->impptr();
101 if ( ret->isa( OTUninit ) )
103 std::string message = std::string(
"Member " ) + std::string( mname->value() ) +
104 std::string(
" not found on that object" );
105 return new BError( message );
113 return new BError(
"Invalid parameter type" );
122 obj_->banned_ =
true;
131 return new BError(
"account.Ban() doesn't take parameters." );
138 obj_->banned_ =
false;
140 return new BError(
"account.Unban() doesn't take parameters." );
147 obj_->enabled_ =
true;
149 return new BError(
"account.Enable() doesn't take parameters." );
157 obj_->enabled_ =
false;
167 return new BError(
"account.Disable() doesn't take parameters." );
178 obj_->password_ = pwstr->value();
182 obj_->passwordhash_ = temp;
187 return new BError(
"Invalid parameter type" );
191 return new BError(
"account.SetPassword(newpass) requires a parameter." );
207 result =
new BLong( ret );
211 return new BError(
"Invalid parameter type" );
215 return new BError(
"account.CheckPassword(password) requires a parameter." );
232 if ( nmstr->value().empty() )
233 return new BError(
"Account name must not be empty." );
236 obj_->name_ = nmstr->value();
238 obj_->passwordhash_ = temp;
242 return new BError(
"Invalid parameter type" );
252 if ( nmstr->value().empty() )
253 return new BError(
"Account name must not be empty." );
254 obj_->name_ = nmstr->value();
257 obj_->password_ = pwstr->value();
261 obj_->passwordhash_ = temp;
265 return new BError(
"Invalid parameter type" );
269 return new BError(
"Usage: account.SetName(name,pass) if RetainCleartextPasswords is off." );
271 return new BError(
"account.SetName needs at least 1 parameter." );
291 bool changed =
false;
293 if ( result && !changed )
300 return new BError(
"account.SetDefaultCmdLevel(int) requires a parameter." );
304 return new BError(
"Invalid parameter type." );
305 else if ( cmdlevel >= static_cast<int>(
Core::gamestate.cmdlevels.size() ) )
308 obj_->default_cmdlevel_ = char( cmdlevel );
319 return new BError(
"account.GetCharacter(index) requires a parameter." );
325 if ( chr ==
nullptr )
326 return new BError(
"No such character on this account" );
336 return new BError(
"account.DeleteCharacter(index) requires a parameter." );
342 if ( chr ==
nullptr )
343 return new BError(
"No such character on this account" );
345 return new BError(
"That character is in use" );
353 return new BError(
"CanDelete blocks Character deletion." );
364 return new BError(
"account.Set_UO_Expansion(string) requires a parameter." );
366 const String* expansion_str;
369 if ( expansion_str->value().empty() || ( expansion_str->value() ==
"TOL" ) ||
370 ( expansion_str->value() ==
"HSA" ) || ( expansion_str->value() ==
"SA" ) ||
371 ( expansion_str->value() ==
"KR" ) || ( expansion_str->value() ==
"ML" ) ||
372 ( expansion_str->value() ==
"SE" ) || ( expansion_str->value() ==
"AOS" ) ||
373 ( expansion_str->value() ==
"LBR" ) || ( expansion_str->value() ==
"T2A" ) )
375 obj_->uo_expansion_ = obj_->convert_uo_expansion( expansion_str->value() );
385 "Invalid Parameter Value. Supported Values: \"\", T2A, LBR, AOS, SE, ML, KR, SA, HSA, " 389 return new BError(
"Invalid Parameter Type" );
399 return new BError(
"You must delete all Character first." );
400 else if ( _result == -2 )
401 return new BError(
"Invalid Account Name." );
404 return new BError(
"account.Delete() doesn't take parameters." );
413 const String* acctname;
418 if ( acctname->value().empty() )
419 return new BError(
"Account name must not be empty." );
422 return new BError(
"Account already exists." );
426 if ( chr ==
nullptr )
427 return new BError(
"No such character on this account." );
429 return new BError(
"That character is in use." );
432 if ( account !=
nullptr )
439 return new BError(
"Was impossible to create new Account." );
442 return new BError(
"Invalid parameter type." );
445 return new BError(
"account.Split requires two parameters." );
454 const String* acctname;
459 if ( acctname->value().empty() )
460 return new BError(
"Account name must not be empty." );
463 if ( account ==
nullptr )
464 return new BError(
"Account doesn't exists." );
468 if ( chr ==
nullptr )
469 return new BError(
"No such character on this account." );
471 return new BError(
"That character is in use." );
476 obj_->clear_character( index - 1 );
481 return new BError(
"Account is full." );
484 return new BError(
"Invalid parameter type." );
487 return new BError(
"account.Move_Char requires two parameters." );
493 return new BError(
"Account.AddCharacter() requires one parameter." );
497 index = obj_->getnextfreeslot();
499 return new BError(
"Account has no free character slots." );
506 if ( obj_->get_character( index ) )
508 return new BError(
"That character slot is already in use." );
511 result =
new BLong( index + 1 );
513 if ( acct ==
nullptr )
515 return new BError(
"Account doesn't exist." );
530 return result ? result :
new BLong( 1 );
545 if ( objmethod !=
nullptr )
546 return this->call_method_id( objmethod->
id, ex );
561 using namespace Bscript;
565 return BObjectRef(
new String( obj_->name() ) );
568 return BObjectRef(
new BLong( obj_->enabled() ) );
571 return BObjectRef(
new BLong( obj_->banned() ) );
574 return BObjectRef(
new String( obj_->passwordhash() ) );
577 return BObjectRef(
new String( obj_->uo_expansion() ) );
580 return BObjectRef(
new BLong( obj_->default_cmdlevel_ ) );
590 using namespace Bscript;
592 if ( objmember !=
nullptr )
593 return this->get_member_id( objmember->id );
bool MD5_Encrypt(const std::string &in, std::string &out)
void set_character(int index, Mobile::Character *chr)
void clear_character(int index)
Account * duplicate_account(const std::string &oldacctname, const std::string &newacctname)
ObjMember * getKnownObjMember(const char *token)
void delete_character(Accounts::Account *acct, Mobile::Character *chr, int charidx)
void write_account_data()
Bscript::BApplicObjType accountobjimp_type
bool has_active_client() const
const int DELETE_BY_SCRIPT
void call_ondelete_scripts(Mobile::Character *chr)
ObjMethod * getKnownObjMethod(const char *token)
Bscript::BObjectImp * CallPropertyListMethod_id(PropertyList &proplist, const int id, Bscript::Executor &ex, bool &changed)
int getnextfreeslot() const
void send_feature_enable(Client *client)
static UninitObject * create()
void createchar2(Accounts::Account *acct, unsigned index)
int delete_account(const char *acctname)
const String * getStringParam(unsigned param)
bool MD5_Compare(const std::string &a, const std::string &b)
bool hasParams(unsigned howmany) const
bool can_delete_character(Mobile::Character *chr, int delete_by)
unsigned short character_slots
Account * find_account(const char *acctname)
bool getParam(unsigned param, int &value)