Просмотр исходного кода

- Fixed the party HP packets to send max HP 10000 and scale HP accordingly when the player's HP doesn't fits in the packet's field. Fixes HP bars not correctly displaying the % of life when max HP is above 32k.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7218 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 лет назад
Родитель
Сommit
bf907b14ae
3 измененных файлов с 27 добавлено и 7 удалено
  1. 5 0
      Changelog-Trunk.txt
  2. 1 1
      src/map/battle.c
  3. 21 6
      src/map/clif.c

+ 5 - 0
Changelog-Trunk.txt

@@ -3,6 +3,11 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/06/17
+	* Fixed the party HP packets to send max HP 10000 and scale HP accordingly
+	  when the player's HP doesn't fits in the packet's field. Fixes HP bars not
+	  correctly displaying the % of life when max HP is above 32k. [Skotlex]
+
 2006/06/16
 	* Fixed option value being reset'ed on login (fixes cart/peco/falcon being
 	  lost) [Skotlex]

+ 1 - 1
src/map/battle.c

@@ -766,7 +766,7 @@ static struct Damage battle_calc_weapon_attack(
 		unsigned idef : 1;	//Ignore defense
 		unsigned idef2 : 1;	//Ignore defense (left weapon)
 		unsigned pdef : 2;	//Pierces defense (Investigate/Ice Pick)
-		unsigned pdef2 : 2;	//1: Use def+def2/50, 2: Use def+def2/100	
+		unsigned pdef2 : 2;	//1: Use def+def2/100, 2: Use def+def2/50	
 		unsigned infdef : 1;	//Infinite defense (plants)
 		unsigned arrow : 1;	//Attack is arrow-based
 		unsigned rh : 1;		//Attack considers right hand (wd.damage)

+ 21 - 6
src/map/clif.c

@@ -5941,8 +5941,13 @@ int clif_party_hp(struct map_session_data *sd)
 
 	WBUFW(buf,0)=0x106;
 	WBUFL(buf,2)=sd->status.account_id;
-	WBUFW(buf,6)=(sd->battle_status.hp > SHRT_MAX)?SHRT_MAX:sd->battle_status.hp;
-	WBUFW(buf,8)=(sd->battle_status.max_hp > SHRT_MAX)?SHRT_MAX:sd->battle_status.max_hp;
+	if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+		WBUFW(buf,6) = 10000*sd->battle_status.hp/sd->battle_status.max_hp;
+		WBUFW(buf,8) = 10000;
+	} else {
+		WBUFW(buf,6) = sd->battle_status.hp;
+		WBUFW(buf,8) = sd->battle_status.max_hp;
+	}
 	clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
 	return 0;
 }
@@ -5956,8 +5961,13 @@ static void clif_hpmeter_single(int fd, struct map_session_data *sd)
 	WFIFOHEAD(fd,packet_len_table[0x106]);
 	WFIFOW(fd,0) = 0x106;
 	WFIFOL(fd,2) = sd->status.account_id;
-	WFIFOW(fd,6) = (sd->battle_status.hp > SHRT_MAX) ? SHRT_MAX : sd->battle_status.hp;
-	WFIFOW(fd,8) = (sd->battle_status.max_hp > SHRT_MAX) ? SHRT_MAX : sd->battle_status.max_hp;
+	if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+		WFIFOW(fd,6) = 10000*sd->battle_status.hp/sd->battle_status.max_hp;
+		WFIFOW(fd,8) = 10000;
+	} else {
+		WFIFOW(fd,6) = sd->battle_status.hp;
+		WFIFOW(fd,8) = sd->battle_status.max_hp;
+	}
 	WFIFOSET (fd, packet_len_table[0x106]);
 }
 
@@ -5981,8 +5991,13 @@ int clif_hpmeter(struct map_session_data *sd)
 
 	WBUFW(buf,0) = 0x106;
 	WBUFL(buf,2) = sd->status.account_id;
-	WBUFW(buf,6) = (sd->battle_status.hp > SHRT_MAX) ? SHRT_MAX : sd->battle_status.hp;
-	WBUFW(buf,8) = (sd->battle_status.max_hp > SHRT_MAX) ? SHRT_MAX : sd->battle_status.max_hp;
+	if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+		WBUFW(buf,6) = 10000*sd->battle_status.hp/sd->battle_status.max_hp;
+		WBUFW(buf,8) = 10000;
+	} else {
+		WBUFW(buf,6) = sd->battle_status.hp;
+		WBUFW(buf,8) = sd->battle_status.max_hp;
+	}
 	for (i = 0; i < fd_max; i++) {
 		if (session[i] && (sd2 = (struct map_session_data*)session[i]->session_data) &&  sd != sd2 && sd2->state.auth) {
 			if (sd2->bl.m != sd->bl.m ||