Vip_followup

Fix bugreport:8301 were groupid wasn't keeping in vip state at new
logon.
Fix groupid wasn't reload without logout when we wasn't vip anymore
Fix decreasing vip_time scenario
Add a timer so vip_member doesn't keep status until they logout.
This commit is contained in:
lighta 2013-12-20 02:01:51 -05:00
parent 854f8fc502
commit 3b5e527c7f
11 changed files with 66 additions and 50 deletions

View File

@ -88,9 +88,8 @@ max_connect_user: -1
// See: conf/groups.conf // See: conf/groups.conf
gm_allow_group: 99 gm_allow_group: 99
// How often should the server save all files? (In seconds) // How often should the server save guild infos? (In seconds)
// Note: Applies to all data files on TXT servers. // (character save interval is defined on the map config (autosave_time))
// On SQL servers, it applies to guilds (character save interval is defined on the map config)
autosave_time: 60 autosave_time: 60
// Display information on the console whenever characters/guilds/parties/pets are loaded/saved? // Display information on the console whenever characters/guilds/parties/pets are loaded/saved?

View File

@ -2309,14 +2309,14 @@ int mapif_vipack(int mapfd, uint32 aid, uint32 vip_time, uint8 isvip, uint32 gro
* @param mapfd: link to mapserv for ack * @param mapfd: link to mapserv for ack
* @return 0 if succes * @return 0 if succes
*/ */
int loginif_reqviddata(uint32 aid, uint8 type, int add_vip_time, int mapfd) { int loginif_reqviddata(uint32 aid, uint8 type, int32 timediff, int mapfd) {
loginif_check(-1); loginif_check(-1);
#ifdef VIP_ENABLE #ifdef VIP_ENABLE
WFIFOHEAD(login_fd,15); WFIFOHEAD(login_fd,15);
WFIFOW(login_fd,0) = 0x2742; WFIFOW(login_fd,0) = 0x2742;
WFIFOL(login_fd,2) = aid; //aid WFIFOL(login_fd,2) = aid; //aid
WFIFOB(login_fd,6) = type; //type WFIFOB(login_fd,6) = type; //type
WFIFOL(login_fd,7) = add_vip_time; //req_inc_duration WFIFOL(login_fd,7) = timediff; //req_inc_duration
WFIFOL(login_fd,11) = mapfd; //req_inc_duration WFIFOL(login_fd,11) = mapfd; //req_inc_duration
WFIFOSET(login_fd,15); WFIFOSET(login_fd,15);
#endif #endif
@ -3091,7 +3091,7 @@ int mapif_parse_req_alter_acc(int fd){
int aid = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request) int aid = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
const char* name = (char*)RFIFOP(fd,6); // name of the target character const char* name = (char*)RFIFOP(fd,6); // name of the target character
int operation = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5 changesex, 6 vip, 7 bank int operation = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5 changesex, 6 vip, 7 bank
int timediff = RFIFOL(fd,32); int32 timediff = RFIFOL(fd,32);
int val1 = RFIFOL(fd,36); int val1 = RFIFOL(fd,36);
int val2 = RFIFOL(fd,40); int val2 = RFIFOL(fd,40);
RFIFOSKIP(fd,44); RFIFOSKIP(fd,44);
@ -3157,7 +3157,7 @@ int mapif_parse_req_alter_acc(int fd){
break; break;
case 6: case 6:
anwser=(val1&4); // vip_req val1=type, &1 login send return, &2 upd timestamp &4 map send awnser anwser=(val1&4); // vip_req val1=type, &1 login send return, &2 upd timestamp &4 map send awnser
loginif_reqviddata(aid, val1, timediff, fd); loginif_reqviddata(account_id, val1, timediff, fd);
break; break;
case 7: case 7:
anwser=(val1&1); //val&1 request anwser, val1&2 save data anwser=(val1&1); //val&1 request anwser, val1&2 save data

View File

@ -514,7 +514,7 @@ int chrif_parse_reqvipdata(int fd) {
struct mmo_account acc; struct mmo_account acc;
int aid = RFIFOL(fd,2); int aid = RFIFOL(fd,2);
int8 type = RFIFOB(fd,6); int8 type = RFIFOB(fd,6);
int req_duration = RFIFOL(fd,7); int32 timediff = RFIFOL(fd,7);
int mapfd = RFIFOL(fd,11); int mapfd = RFIFOL(fd,11);
RFIFOSKIP(fd,15); RFIFOSKIP(fd,15);
@ -523,14 +523,17 @@ int chrif_parse_reqvipdata(int fd) {
time_t vip_time = acc.vip_time; time_t vip_time = acc.vip_time;
bool isvip = false; bool isvip = false;
if( type&2 ) vip_time = now + req_duration; // set new duration if( type&2 ){
if( now < vip_time ) { //isvip if(!vip_time) vip_time = now; //new entry
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; acc.old_group = acc.group_id;
acc.group_id = login_config.vip_sys.group; acc.group_id = login_config.vip_sys.group;
acc.char_slots = login_config.char_per_account + login_config.vip_sys.char_increase; acc.char_slots = login_config.char_per_account + login_config.vip_sys.char_increase;
isvip = true; isvip = true;
} else if (vip_time) { //expired or @vip -xx } else { //expired or @vip -xx
vip_time = 0; vip_time = 0;
if(acc.group_id == login_config.vip_sys.group) //prevent alteration in case we wasn't registered vip yet if(acc.group_id == login_config.vip_sys.group) //prevent alteration in case we wasn't registered vip yet
acc.group_id = acc.old_group; acc.group_id = acc.old_group;
@ -1233,10 +1236,6 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S"); timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S");
safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip)); safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip));
acc.unban_time = 0; acc.unban_time = 0;
#ifdef VIP_ENABLE
acc.vip_time = 0;
acc.old_group = 0;
#endif
acc.logincount++; acc.logincount++;
accounts->save(accounts, &acc); accounts->save(accounts, &acc);

View File

@ -2788,7 +2788,7 @@ ACMD_FUNC(char_block)
ACMD_FUNC(char_ban) ACMD_FUNC(char_ban)
{ {
char * modif_p; char * modif_p;
int timediff=0; int32 timediff=0; //don't set this as uint as we may want to decrease banned time
int bantype=2; //2=account block, 6=char specific int bantype=2; //2=account block, 6=char specific
char output[256]; char output[256];
@ -2807,7 +2807,7 @@ ACMD_FUNC(char_ban)
modif_p = atcmd_output; modif_p = atcmd_output;
timediff = (int)solve_time(modif_p); //discard seconds timediff = (int32)solve_time(modif_p); //discard seconds
if (timediff == 0) { //allow negative ? if (timediff == 0) { //allow negative ?
char output[256]; char output[256];
@ -9160,7 +9160,7 @@ ACMD_FUNC(langtype)
ACMD_FUNC(vip) { ACMD_FUNC(vip) {
struct map_session_data *pl_sd = NULL; struct map_session_data *pl_sd = NULL;
char * modif_p; char * modif_p;
int vipdifftime = 0; int32 vipdifftime = 0;
time_t now=time(NULL); time_t now=time(NULL);
nullpo_retr(-1, sd); nullpo_retr(-1, sd);
@ -9175,7 +9175,7 @@ ACMD_FUNC(vip) {
atcmd_output[sizeof(atcmd_output)-1] = '\0'; atcmd_output[sizeof(atcmd_output)-1] = '\0';
modif_p = atcmd_output; modif_p = atcmd_output;
vipdifftime = (int)solve_time(modif_p); vipdifftime = (int32)solve_time(modif_p);
if (vipdifftime == 0) { if (vipdifftime == 0) {
clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.

View File

@ -823,7 +823,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) {
* @val1 : extra data value to transfer for operation * @val1 : extra data value to transfer for operation
* @val2 : extra data value to transfer for operation * @val2 : extra data value to transfer for operation
*/ */
int chrif_req_login_operation(int aid, const char* character_name, unsigned short operation_type, int timediff, int val1, int val2) { int chrif_req_login_operation(int aid, const char* character_name, unsigned short operation_type, int32 timediff, int val1, int val2) {
chrif_check(-1); chrif_check(-1);
WFIFOHEAD(char_fd,44); WFIFOHEAD(char_fd,44);
@ -1071,7 +1071,7 @@ int chrif_ban(int fd) {
return 0; return 0;
} }
int chrif_req_charban(int aid, const char* character_name, int timediff){ int chrif_req_charban(int aid, const char* character_name, int32 timediff){
chrif_check(-1); chrif_check(-1);
WFIFOHEAD(char_fd,10+NAME_LENGTH); WFIFOHEAD(char_fd,10+NAME_LENGTH);
@ -1520,20 +1520,25 @@ void chrif_keepalive_ack(int fd) {
session[fd]->flag.ping = 0;/* reset ping state, we received a packet */ session[fd]->flag.ping = 0;/* reset ping state, we received a packet */
} }
/**
* Received vip-data from char-serv, fill map-serv data
* @param fd : char-serv file descriptor (link to char-serv)
*/
void chrif_parse_ack_vipActive(int fd) { void chrif_parse_ack_vipActive(int fd) {
#ifdef VIP_ENABLE #ifdef VIP_ENABLE
int aid = RFIFOL(char_fd,2); int aid = RFIFOL(fd,2);
uint32 vip_time = RFIFOL(char_fd,6); uint32 vip_time = RFIFOL(fd,6);
bool isvip = RFIFOB(char_fd,10); bool isvip = RFIFOB(fd,10);
uint32 groupid = RFIFOL(char_fd,11); uint32 groupid = RFIFOL(fd,11);
TBL_PC *sd = map_id2sd(aid); TBL_PC *sd = map_id2sd(aid);
if (sd && isvip) { if(sd == NULL) return ;
sd->group_id = groupid;
pc_group_pc_load(sd);
if(isvip) {
sd->vip.enabled = 1; sd->vip.enabled = 1;
sd->vip.time = vip_time; sd->vip.time = vip_time;
sd->group_id = groupid;
pc_group_pc_load(sd);
// Increase storage size for VIP. // Increase storage size for VIP.
sd->storage_size = battle_config.vip_storage_increase + MIN_STORAGE; sd->storage_size = battle_config.vip_storage_increase + MIN_STORAGE;
if (sd->storage_size > MAX_STORAGE) { if (sd->storage_size > MAX_STORAGE) {
@ -1541,9 +1546,16 @@ void chrif_parse_ack_vipActive(int fd) {
sd->storage_size = MAX_STORAGE; sd->storage_size = MAX_STORAGE;
} }
// Magic Stone requirement avoidance for VIP. // Magic Stone requirement avoidance for VIP.
if (battle_config.vip_gemstone && pc_isvip(sd)) if (battle_config.vip_gemstone)
sd->special_state.no_gemstone = 2; // need to be done after status_calc_bl(bl,first); sd->special_state.no_gemstone = 2; // need to be done after status_calc_bl(bl,first);
} }
else if (sd->vip.enabled){
sd->vip.enabled = 0;
sd->vip.time = 0;
sd->storage_size = MIN_STORAGE;
sd->special_state.no_gemstone = 0;
clif_displaymessage(sd->fd,"You're no longer a VIP_Member");
}
#endif #endif
} }

View File

@ -89,14 +89,14 @@ char log_db_db[32] = "log";
Sql* logmysql_handle; Sql* logmysql_handle;
// DBMap declaartion // DBMap declaartion
static DBMap* id_db=NULL; // int id -> struct block_list* static DBMap* id_db=NULL; /// int id -> struct block_list*
static DBMap* pc_db=NULL; // int id -> struct map_session_data* static DBMap* pc_db=NULL; /// int id -> struct map_session_data*
static DBMap* mobid_db=NULL; // int id -> struct mob_data* static DBMap* mobid_db=NULL; /// int id -> struct mob_data*
static DBMap* bossid_db=NULL; // int id -> struct mob_data* (MVP db) static DBMap* bossid_db=NULL; /// int id -> struct mob_data* (MVP db)
static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data* static DBMap* map_db=NULL; /// unsigned int mapindex -> struct map_data*
static DBMap* nick_db=NULL; // int char_id -> struct charid2nick* (requested names of offline characters) static DBMap* nick_db=NULL; /// int char_id -> struct charid2nick* (requested names of offline characters)
static DBMap* charid_db=NULL; // int char_id -> struct map_session_data* static DBMap* charid_db=NULL; /// int char_id -> struct map_session_data*
static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_heal processing) static DBMap* regen_db=NULL; /// int id -> struct block_list* (status_natural_heal processing)
static DBMap* map_msg_db=NULL; static DBMap* map_msg_db=NULL;
static int map_users=0; static int map_users=0;

View File

@ -9415,7 +9415,10 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data)
//Save char. //Save char.
last_save_id = sd->bl.id; last_save_id = sd->bl.id;
save_flag = 2; save_flag = 2;
#ifdef VIP_ENABLE
if(sd->vip.enabled) //check if we're still vip
chrif_req_login_operation(1, sd->status.name, 6, 0, 1, 0);
#endif
chrif_save(sd,0); chrif_save(sd,0);
break; break;
} }

View File

@ -123,10 +123,17 @@ struct s_autobonus {
}; };
struct skill_cooldown_entry { struct skill_cooldown_entry {
unsigned short skill_id; unsigned short skill_id;
int timer; int timer;
}; };
#ifdef VIP_ENABLE
struct vip_info {
unsigned int enabled : 1;
time_t time;
};
#endif
enum npc_timeout_type { enum npc_timeout_type {
NPCT_INPUT = 0, NPCT_INPUT = 0,
NPCT_MENU = 1, NPCT_MENU = 1,
@ -553,12 +560,8 @@ struct map_session_data {
int storage_size; // Holds player storage size (VIP system). int storage_size; // Holds player storage size (VIP system).
#ifdef VIP_ENABLE #ifdef VIP_ENABLE
struct { struct vip_info vip;
unsigned int enabled : 1;
time_t time;
} vip;
#endif #endif
//Timed bonus 'bonus_script' struct [Cydh] //Timed bonus 'bonus_script' struct [Cydh]
struct s_script { struct s_script {
struct script_code *script; struct script_code *script;