Fixed billing slots (#7219)
The login-server ignored the value stored in the `character_slots` column of the `login` table. Also some additional logic fixes and safeguards. Thanks to @Pokye
This commit is contained in:
parent
df57b5b7d4
commit
c29fef7323
@ -1136,11 +1136,8 @@ struct clan{
|
||||
#error MAX_PARTY is too small, you need at least 2 players for a party
|
||||
#endif
|
||||
|
||||
#ifndef VIP_ENABLE
|
||||
#define MIN_STORAGE MAX_STORAGE // If the VIP system is disabled the min = max.
|
||||
#define MIN_CHARS MAX_CHARS // Default number of characters per account.
|
||||
#define MAX_CHAR_BILLING 0
|
||||
#define MAX_CHAR_VIP 0
|
||||
#ifndef MIN_CHARS
|
||||
#define MIN_CHARS ( MAX_CHARS - MAX_CHAR_VIP - MAX_CHAR_BILLING ) // Default number of characters per account.
|
||||
#endif
|
||||
|
||||
#if (MIN_CHARS + MAX_CHAR_VIP + MAX_CHAR_BILLING) > MAX_CHARS
|
||||
|
@ -56,9 +56,22 @@
|
||||
#define VIP_SCRIPT 0
|
||||
|
||||
#ifdef VIP_ENABLE
|
||||
#define MIN_STORAGE 300 // Default number of storage slots.
|
||||
#define MIN_CHARS 3 // Default number of characters per account.
|
||||
#define MAX_CHAR_VIP 6 // This must be less than MAX_CHARS
|
||||
#ifndef MIN_STORAGE
|
||||
#define MIN_STORAGE 300 // Default number of storage slots.
|
||||
#endif
|
||||
#ifndef MAX_CHAR_VIP
|
||||
#define MAX_CHAR_VIP 6 // This must be less than MAX_CHARS
|
||||
#endif
|
||||
#else
|
||||
#ifndef MIN_STORAGE
|
||||
#define MIN_STORAGE MAX_STORAGE // If the VIP system is disabled the min = max.
|
||||
#endif
|
||||
#ifndef MAX_CHAR_VIP
|
||||
#define MAX_CHAR_VIP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX_CHAR_BILLING
|
||||
#define MAX_CHAR_BILLING 0 // This must be less than MAX_CHARS
|
||||
#endif
|
||||
|
||||
|
@ -549,6 +549,11 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32
|
||||
Sql_FreeResult(sql_handle);
|
||||
acc->web_auth_token[0] = '\0';
|
||||
|
||||
if( acc->char_slots > MAX_CHARS ){
|
||||
ShowError( "Account %s (AID=%u) exceeds MAX_CHARS. Capping...\n", acc->userid, acc->account_id );
|
||||
acc->char_slots = MAX_CHARS;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -684,11 +684,11 @@ bool login_config_read(const char* cfgName, bool normal) {
|
||||
login_config.usercount_high = atoi(w2);
|
||||
else if(strcmpi(w1, "chars_per_account") == 0) { //maxchars per account [Sirius]
|
||||
login_config.char_per_account = atoi(w2);
|
||||
if( login_config.char_per_account <= 0 || login_config.char_per_account > MAX_CHARS ) {
|
||||
if( login_config.char_per_account > MAX_CHARS ) {
|
||||
ShowWarning("Max chars per account '%d' exceeded limit. Defaulting to '%d'.\n", login_config.char_per_account, MAX_CHARS);
|
||||
login_config.char_per_account = MAX_CHARS;
|
||||
}
|
||||
if( login_config.char_per_account > MAX_CHARS ) {
|
||||
ShowWarning("Exceeded limit of max chars per account '%d'. Capping to '%d'.\n", login_config.char_per_account, MAX_CHARS);
|
||||
login_config.char_per_account = MAX_CHARS;
|
||||
}else if( login_config.char_per_account < 0 ){
|
||||
ShowWarning("Max chars per account '%d' is negative. Capping to '%d'.\n", login_config.char_per_account, MIN_CHARS);
|
||||
login_config.char_per_account = MIN_CHARS;
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ int logchrif_send_accdata(int fd, uint32 aid) {
|
||||
char birthdate[10+1] = "";
|
||||
char pincode[PINCODE_LENGTH+1];
|
||||
char isvip = false;
|
||||
uint8 char_slots = MIN_CHARS, char_vip = 0, char_billing = 0;
|
||||
uint8 char_slots = MIN_CHARS, char_vip = 0, char_billing = MAX_CHAR_BILLING;
|
||||
AccountDB* accounts = login_get_accounts_db();
|
||||
|
||||
memset(pincode,0,PINCODE_LENGTH+1);
|
||||
@ -171,14 +171,19 @@ int logchrif_send_accdata(int fd, uint32 aid) {
|
||||
|
||||
safestrncpy(birthdate, acc.birthdate, sizeof(birthdate));
|
||||
safestrncpy(pincode, acc.pincode, sizeof(pincode));
|
||||
char_slots = login_config.char_per_account;
|
||||
|
||||
// Respect account information from login-server
|
||||
if( acc.char_slots > 0 ){
|
||||
char_slots = acc.char_slots;
|
||||
}
|
||||
|
||||
#ifdef VIP_ENABLE
|
||||
char_vip = login_config.vip_sys.char_increase;
|
||||
if( acc.vip_time > time(NULL) ) {
|
||||
isvip = true;
|
||||
char_slots = login_config.char_per_account + char_vip;
|
||||
} else
|
||||
char_slots = login_config.char_per_account;
|
||||
char_billing = MAX_CHAR_BILLING; //TODO create a config for this
|
||||
char_slots += char_vip;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -676,17 +681,26 @@ int logchrif_parse_reqvipdata(int fd) {
|
||||
vip_time += timediff; // set new duration
|
||||
}
|
||||
if( now < vip_time ) { //isvip
|
||||
if(acc.group_id != login_config.vip_sys.group) //only upd this if we're not vip already
|
||||
if(acc.group_id != login_config.vip_sys.group){ //only upd this if we're not vip already
|
||||
acc.old_group = acc.group_id;
|
||||
if( acc.char_slots == 0 ){
|
||||
acc.char_slots = MIN_CHARS;
|
||||
}
|
||||
acc.char_slots += login_config.vip_sys.char_increase;
|
||||
}
|
||||
acc.group_id = login_config.vip_sys.group;
|
||||
acc.char_slots = login_config.char_per_account + login_config.vip_sys.char_increase;
|
||||
isvip = true;
|
||||
} else { //expired or @vip -xx
|
||||
vip_time = 0;
|
||||
if(acc.group_id == login_config.vip_sys.group) //prevent alteration in case account wasn't registered as vip yet
|
||||
if(acc.group_id == login_config.vip_sys.group){ //prevent alteration in case account wasn't registered as vip yet
|
||||
acc.group_id = acc.old_group;
|
||||
if( acc.char_slots == 0 ){
|
||||
acc.char_slots = MIN_CHARS;
|
||||
}else{
|
||||
acc.char_slots -= login_config.vip_sys.char_increase;
|
||||
}
|
||||
}
|
||||
acc.old_group = 0;
|
||||
acc.char_slots = login_config.char_per_account;
|
||||
}
|
||||
acc.vip_time = vip_time;
|
||||
accounts->save(accounts,&acc, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user