Quellcode durchsuchen

- Fixed hidden GMs being processed in the PVP ranking timer

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15083 54d463be-8e91-2dee-dedb-b68131a5f0ec
epoque11 vor 13 Jahren
Ursprung
Commit
5d1438cced
5 geänderte Dateien mit 44 neuen und 3 gelöschten Zeilen
  1. 21 0
      src/map/atcommand.c
  2. 5 1
      src/map/clif.c
  3. 1 0
      src/map/map.h
  4. 13 2
      src/map/pc.c
  5. 4 0
      src/map/unit.c

+ 21 - 0
src/map/atcommand.c

@@ -1233,10 +1233,31 @@ ACMD_FUNC(hide)
 		else
 			status_set_viewdata(&sd->bl, sd->status.class_);
 		clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
+
+		if( map[sd->bl.m].flag.pvp )
+		{// increment the number of pvp players on the map
+			map[sd->bl.m].users_pvp++;
+
+			if( !map[sd->bl.m].flag.pvp_nocalcrank )
+			{// register the player for ranking calculations
+				sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
+			}
+		}
 	} else {
 		sd->sc.option |= OPTION_INVISIBLE;
 		sd->vd.class_ = INVISIBLE_CLASS;
 		clif_displaymessage(fd, msg_txt(11)); // Invisible: On
+
+		if( map[sd->bl.m].flag.pvp )
+		{// decrement the number of pvp players on the map
+			map[sd->bl.m].users_pvp--;
+
+			if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
+			{// unregister the player for ranking
+				delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
+				sd->pvp_timer = INVALID_TIMER;
+			}
+		}
 	}
 	clif_changeoption(&sd->bl);
 

+ 5 - 1
src/map/clif.c

@@ -8661,6 +8661,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
 
 	if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs )
 		map_spawnmobs(sd->bl.m);
+	if( !(sd->sc.option&OPTION_INVISIBLE) )
+	{// increment the number of pvp players on the map
+		map[sd->bl.m].users_pvp++;
+	}
 	if( map[sd->bl.m].instance_id )
 	{
 		instance[map[sd->bl.m].instance_id].users++;
@@ -8680,7 +8684,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
 
 	if( sd->bg_id ) clif_bg_hp(sd); // BattleGround System
 
-	if(map[sd->bl.m].flag.pvp) {
+	if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) {
 		if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
 			if (!map[sd->bl.m].flag.pvp_nocalcrank)
 				sd->pvp_timer = add_timer(gettick()+200, pc_calc_pvprank_timer, sd->bl.id, 0);

+ 1 - 0
src/map/map.h

@@ -473,6 +473,7 @@ struct map_data {
 	short bgscore_lion, bgscore_eagle; // Battleground ScoreBoard
 	int npc_num;
 	int users;
+	int users_pvp;
 	int iwall_num; // Total of invisible walls in this map
 	struct map_flag {
 		unsigned town : 1; // [Suggestion to protect Mail System]

+ 13 - 2
src/map/pc.c

@@ -7628,6 +7628,11 @@ 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 )
+	{// cannot register pvp rank for hidden GMs
+		return 0;
+	}
+
 	if( sd1->pvp_point > sd2->pvp_point )
 		sd2->pvp_rank++;
 	return 0;
@@ -7643,8 +7648,8 @@ int pc_calc_pvprank(struct map_session_data *sd)
 	old=sd->pvp_rank;
 	sd->pvp_rank=1;
 	map_foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd);
-	if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users)
-		clif_pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users,0);
+	if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users_pvp)
+		clif_pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users_pvp,0);
 	return sd->pvp_rank;
 }
 /*==========================================
@@ -7658,6 +7663,12 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data)
 	if(sd==NULL)
 		return 0;
 	sd->pvp_timer = INVALID_TIMER;
+
+	if( sd->sc.option&OPTION_INVISIBLE )
+	{// do not calculate the pvp rank for a hidden GM
+		return 0;
+	}
+
 	if( pc_calc_pvprank(sd) > 0 )
 		sd->pvp_timer = add_timer(gettick()+PVP_CALCRANK_INTERVAL,pc_calc_pvprank_timer,id,data);
 	return 0;

+ 4 - 0
src/map/unit.c

@@ -2002,6 +2002,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
 		else
 		if (--map[bl->m].users == 0 && battle_config.dynamic_mobs)	//[Skotlex]
 			map_removemobs(bl->m);
+		if( !(sd->sc.option&OPTION_INVISIBLE) )
+		{// decrement the number of active pvp players on the map
+			--map[bl->m].users_pvp;
+		}
 		if( map[bl->m].instance_id )
 		{
 			instance[map[bl->m].instance_id].users--;