Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/map/atcommand.c b/src/map/atcommand.c
- index 6177fad..42f5e10 100644
- --- a/src/map/atcommand.c
- +++ b/src/map/atcommand.c
- @@ -868,13 +868,16 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) {
- else
- status->set_viewdata(&sd->bl, sd->status.class_);
- clif->message(fd, msg_txt(10)); // Invisible: Off
- +
- + if( !pc_out_of_pvp(sd) )
- + {
- + // increment the number of pvp players on the map
- + map->list[sd->bl.m].users_pvp++;
- - // increment the number of pvp players on the map
- - map->list[sd->bl.m].users_pvp++;
- -
- - if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) {
- - // register the player for ranking calculations
- - sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );
- + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) {
- + // register the player for ranking calculations
- + sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );
- + }
- }
- //bugreport:2266
- map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
- @@ -882,14 +885,17 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) {
- sd->sc.option |= OPTION_INVISIBLE;
- sd->vd.class_ = INVISIBLE_CLASS;
- clif->message(fd, msg_txt(11)); // Invisible: On
- +
- + if( !pc_out_of_pvp(sd) )
- + {
- + // decrement the number of pvp players on the map
- + map->list[sd->bl.m].users_pvp--;
- - // decrement the number of pvp players on the map
- - map->list[sd->bl.m].users_pvp--;
- -
- - if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {
- - // unregister the player for ranking
- - timer->delete( sd->pvp_timer, pc->calc_pvprank_timer );
- - sd->pvp_timer = INVALID_TIMER;
- + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {
- + // unregister the player for ranking
- + timer->delete( sd->pvp_timer, pc->calc_pvprank_timer );
- + sd->pvp_timer = INVALID_TIMER;
- + }
- }
- }
- clif->changeoption(&sd->bl);
- @@ -1477,9 +1483,12 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
- {
- TBL_PC* sd = (TBL_PC*)bl;
- clif->pvpset(sd, 0, 0, 2);
- - if (sd->pvp_timer != INVALID_TIMER) {
- - timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
- - sd->pvp_timer = INVALID_TIMER;
- + if( !pc_out_of_pvp(sd) )
- + {
- + if (sd->pvp_timer != INVALID_TIMER) {
- + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
- + sd->pvp_timer = INVALID_TIMER;
- + }
- }
- return 0;
- }
- @@ -1510,6 +1519,10 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
- int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
- {
- TBL_PC* sd = (TBL_PC*)bl;
- +
- + if( pc_out_of_pvp(sd) )
- + return 0;
- +
- if (sd->pvp_timer == INVALID_TIMER) {
- sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
- sd->pvp_rank = 0;
- diff --git a/src/map/clif.c b/src/map/clif.c
- index 1e1a98e..b6b15a0 100644
- --- a/src/map/clif.c
- +++ b/src/map/clif.c
- @@ -5785,6 +5785,9 @@ void clif_map_type(struct map_session_data* sd, enum map_type type) {
- /// 019a <id>.L <ranking>.L <total>.L
- void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
- {
- + if( pc_out_of_pvp(sd) )
- + return;
- +
- if(type == 2) {
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len(0x19a));
- @@ -9306,7 +9309,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
- sd->state.hpmeter_visible = 1;
- }
- - if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map
- + if( !(sd->sc.option&OPTION_INVISIBLE) && !pc_out_of_pvp(sd) ) { // increment the number of pvp players on the map
- map->list[sd->bl.m].users_pvp++;
- }
- @@ -9327,7 +9330,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
- if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System
- - if(map->list[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) {
- + if(map->list[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE) && !pc_out_of_pvp(sd)) {
- if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
- if (!map->list[sd->bl.m].flag.pvp_nocalcrank)
- sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0);
- @@ -1323,7 +1359,7 @@ int pc_reg_received(struct map_session_data *sd)
- clif->pLoadEndAck(sd->fd, sd);
- }
- - if( sd->sc.option & OPTION_INVISIBLE ) {
- + if( sd->sc.option & OPTION_INVISIBLE && !pc_out_of_pvp(sd) ) {
- sd->vd.class_ = INVISIBLE_CLASS;
- clif->message(sd->fd, msg_txt(11)); // Invisible: On
- // decrement the number of pvp players on the map
- @@ -9070,7 +9106,8 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap)
- sd1=(struct map_session_data *)bl;
- sd2=va_arg(ap,struct map_session_data *);
- - if( sd1->sc.option&OPTION_INVISIBLE || sd2->sc.option&OPTION_INVISIBLE )
- + if( sd1->sc.option&OPTION_INVISIBLE || sd2->sc.option&OPTION_INVISIBLE
- + || pc_out_of_pvp(sd1) || pc_out_of_pvp(sd2) )
- {// cannot register pvp rank for hidden GMs
- return 0;
- }
- @@ -9105,7 +9142,7 @@ int pc_calc_pvprank_timer(int tid, int64 tick, int id, intptr_t data) {
- return 0;
- sd->pvp_timer = INVALID_TIMER;
- - if( sd->sc.option&OPTION_INVISIBLE )
- + if( sd->sc.option&OPTION_INVISIBLE || pc_out_of_pvp(sd) )
- {// do not calculate the pvp rank for a hidden GM
- return 0;
- }
- diff --git a/src/map/pc.h b/src/map/pc.h
- index 30a24c0..2ae2e5d 100644
- --- a/src/map/pc.h
- +++ b/src/map/pc.h
- @@ -698,6 +698,7 @@ enum equip_pos {
- #define pc_has_permission(sd,permission) ( ((sd)->extra_temp_permissions&(permission)) != 0 || ((sd)->group->e_permissions&(permission)) != 0 )
- #define pc_can_give_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE) )
- #define pc_can_give_bound_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE_BOUND) )
- +#define pc_out_of_pvp(sd) ( pc_has_permission((sd), PC_OUT_PVP) )
- struct skill_tree_entry {
- short id;
- diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
- index 906462c..2dd4419 100644
- --- a/src/map/pc_groups.c
- +++ b/src/map/pc_groups.c
- @@ -418,6 +418,7 @@ void do_init_pc_groups(void) {
- { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD },
- { "hchsys_admin", PC_PERM_HCHSYS_ADMIN },
- { "can_trade_bound", PC_PERM_TRADE_BOUND },
- + { "disable_pvp_rank", PC_OUT_PVP },
- };
- unsigned char i, len = ARRAYLENGTH(pc_g_defaults);
- diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
- index 5c03f99..d76738e 100644
- --- a/src/map/pc_groups.h
- +++ b/src/map/pc_groups.h
- @@ -31,6 +31,7 @@ enum e_pc_permission {
- PC_PERM_DISABLE_CMD_DEAD = 0x100000,
- PC_PERM_HCHSYS_ADMIN = 0x200000,
- PC_PERM_TRADE_BOUND = 0x400000,
- + PC_OUT_PVP = 0x800000,
- };
- // Cached config settings for quick lookup
- diff --git a/src/map/script.c b/src/map/script.c
- index 21d55ca..829671d 100644
- --- a/src/map/script.c
- +++ b/src/map/script.c
- @@ -10746,7 +10746,7 @@ void script_detach_rid(struct script_state* st) {
- /* pvp timer handling */
- int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
- TBL_PC* sd = (TBL_PC*)bl;
- - if (sd->pvp_timer == INVALID_TIMER) {
- + if (sd->pvp_timer == INVALID_TIMER && !pc_out_of_pvp(sd)) {
- sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
- sd->pvp_rank = 0;
- sd->pvp_lastusers = 0;
- @@ -10977,7 +10977,7 @@ int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
- iter = mapit_getallusers();
- for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) )
- {
- - if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER )
- + if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER || pc_out_of_pvp(sd) )
- continue; // not applicable
- sd->pvp_timer = timer->add(timer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0);
- @@ -10996,7 +10996,7 @@ int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
- {
- TBL_PC* sd = (TBL_PC*)bl;
- clif->pvpset(sd, 0, 0, 2);
- - if (sd->pvp_timer != INVALID_TIMER) {
- + if (sd->pvp_timer != INVALID_TIMER && !pc_out_of_pvp(sd)) {
- timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
- sd->pvp_timer = INVALID_TIMER;
- }
- diff --git a/src/map/unit.c b/src/map/unit.c
- index 320649a..ba7766b 100644
- --- a/src/map/unit.c
- +++ b/src/map/unit.c
- @@ -2158,7 +2158,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
- sd->npc_shopid = 0;
- sd->adopt_invite = 0;
- - if(sd->pvp_timer != INVALID_TIMER) {
- + if(sd->pvp_timer != INVALID_TIMER && !pc_out_of_pvp(sd)) {
- timer->delete(sd->pvp_timer,pc->calc_pvprank_timer);
- sd->pvp_timer = INVALID_TIMER;
- sd->pvp_rank = 0;
- @@ -2192,7 +2192,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
- sd->debug_file, sd->debug_line, sd->debug_func, file, line, func);
- } else if (--map->list[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
- map->removemobs(bl->m);
- - if( !(sd->sc.option&OPTION_INVISIBLE) ) {
- + if( !(sd->sc.option&OPTION_INVISIBLE) || !pc_out_of_pvp(sd) ) {
- // decrement the number of active pvp players on the map
- --map->list[bl->m].users_pvp;
- }
Advertisement
Add Comment
Please, Sign In to add comment