Browse Source

- Vaporize will no fail when the homun is dead.
- Corrected thhe double free issue that occurs when a homun dies and has no intimacy left.
- Fixed the charsave_method:1 saving/loading exp as signed ints rather than unsigned.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8335 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 years ago
parent
commit
6babc24b69
4 changed files with 22 additions and 14 deletions
  1. 5 0
      Changelog-Trunk.txt
  2. 0 2
      src/map/battle.c
  3. 6 3
      src/map/charsave.c
  4. 11 9
      src/map/mercenary.c

+ 5 - 0
Changelog-Trunk.txt

@@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/08/17
 2006/08/17
+	* Vaporize will no fail when the homun is dead. [Skotlex]
+	* Corrected thhe double free issue that occurs when a homun dies and has no
+	  intimacy left. [Skotlex]
+	* Fixed the charsave_method:1 saving/loading exp as signed ints rather than
+	  unsigned. [Skotlex]
 	* Applied use of structure regen_data for a unified regen module. Natural
 	* Applied use of structure regen_data for a unified regen module. Natural
 	  and skill-heal is handled by this structure, while sitting-skill-heal is
 	  and skill-heal is handled by this structure, while sitting-skill-heal is
 	  still player dependant (mostly because the other object types can't sit)
 	  still player dependant (mostly because the other object types can't sit)

+ 0 - 2
src/map/battle.c

@@ -1213,8 +1213,6 @@ static struct Damage battle_calc_weapon_attack(
 				case W_SHOTGUN:
 				case W_SHOTGUN:
 				case W_GATLING:
 				case W_GATLING:
 				case W_GRENADE:
 				case W_GRENADE:
-				case W_WHIP:	//These two do use arrow based skills.
-				case W_MUSICAL:
 				  break;
 				  break;
 				default:
 				default:
 				  i |= 16; // for ex. shuriken must not be influenced by DEX
 				  i |= 16; // for ex. shuriken must not be influenced by DEX

+ 6 - 3
src/map/charsave.c

@@ -24,6 +24,7 @@ struct mmo_charstatus *charsave_loadchar(int charid){
 	int i,j, friends;
 	int i,j, friends;
 	struct mmo_charstatus *c;
 	struct mmo_charstatus *c;
 	char *str_p;
 	char *str_p;
+	double exp;
 	friends = 0;
 	friends = 0;
 
 
 	c = (struct mmo_charstatus *)aCalloc(1,sizeof(struct mmo_charstatus));
 	c = (struct mmo_charstatus *)aCalloc(1,sizeof(struct mmo_charstatus));
@@ -62,8 +63,10 @@ struct mmo_charstatus *charsave_loadchar(int charid){
          c->class_ = atoi(charsql_row[4]);
          c->class_ = atoi(charsql_row[4]);
          c->base_level = atoi(charsql_row[5]);
          c->base_level = atoi(charsql_row[5]);
          c->job_level = atoi(charsql_row[6]);
          c->job_level = atoi(charsql_row[6]);
-         c->base_exp = atoi(charsql_row[7]);
-         c->job_exp = atoi(charsql_row[8]);
+			exp = atof(charsql_row[7]);
+			c->base_exp = (unsigned int)cap_value(exp,0,UINT_MAX);
+			exp = atof(charsql_row[8]);
+			c->job_exp = (unsigned int)cap_value(exp,0,UINT_MAX);
          c->zeny = atoi(charsql_row[9]);
          c->zeny = atoi(charsql_row[9]);
          c->str = atoi(charsql_row[10]);
          c->str = atoi(charsql_row[10]);
          c->agi = atoi(charsql_row[11]);
          c->agi = atoi(charsql_row[11]);
@@ -276,7 +279,7 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){
 //	char tmp_str2[512];
 //	char tmp_str2[512];
          //First save the 'char'
          //First save the 'char'
 	sprintf(tmp_sql ,"UPDATE `char` SET `class`='%d', `base_level`='%d', `job_level`='%d',"
 	sprintf(tmp_sql ,"UPDATE `char` SET `class`='%d', `base_level`='%d', `job_level`='%d',"
-		"`base_exp`='%d', `job_exp`='%d', `zeny`='%d',"
+		"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
 		"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
 		"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
 		"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
 		"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
 		"`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',"
 		"`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',"

+ 11 - 9
src/map/mercenary.c

@@ -114,26 +114,25 @@ void merc_damage(struct homun_data *hd,struct block_list *src,int hp,int sp)
 int merc_hom_dead(struct homun_data *hd, struct block_list *src)
 int merc_hom_dead(struct homun_data *hd, struct block_list *src)
 {
 {
 	struct map_session_data *sd = hd->master;
 	struct map_session_data *sd = hd->master;
+
+	clif_emotion(&hd->bl, 16) ;	//wah
 	if (!sd)
 	if (!sd)
-	{
-		clif_emotion(&hd->bl, 16) ;	//wah
 		return 7;
 		return 7;
-	}
 
 
 	//Delete timers when dead.
 	//Delete timers when dead.
 	merc_hom_hungry_timer_delete(hd);
 	merc_hom_hungry_timer_delete(hd);
 	sd->homunculus.hp = 0 ;
 	sd->homunculus.hp = 0 ;
 	clif_hominfo(sd,hd,0); // Send dead flag
 	clif_hominfo(sd,hd,0); // Send dead flag
 
 
-	if(!merc_hom_decrease_intimacy(hd, 100)) { // Intimacy was < 100
+	if(!merc_hom_decrease_intimacy(hd, 100)) // Intimacy was < 100
 		clif_emotion(&sd->bl, 23) ;	//omg
 		clif_emotion(&sd->bl, 23) ;	//omg
-		return 7; //Delete from memory.
+	else {
+		clif_emotion(&sd->bl, 28) ;	//sob
+		clif_send_homdata(hd->master,SP_INTIMATE,hd->master->homunculus.intimacy / 100);
 	}
 	}
 
 
-	clif_send_homdata(hd->master,SP_INTIMATE,hd->master->homunculus.intimacy / 100);
-	clif_emotion(&hd->bl, 16) ;	//wah
-	clif_emotion(&sd->bl, 28) ;	//sob
-	return 3; //Remove from map.
+	//Remove from map (if it has no intimacy, it is auto-removed from memory)
+	return 3;
 }
 }
 
 
 //Vaporize a character's homun. If flag, HP needs to be 80% or above.
 //Vaporize a character's homun. If flag, HP needs to be 80% or above.
@@ -147,6 +146,9 @@ int merc_hom_vaporize(struct map_session_data *sd, int flag)
 	if (!hd || sd->homunculus.vaporize)
 	if (!hd || sd->homunculus.vaporize)
 		return 0;
 		return 0;
 	
 	
+	if (status_isdead(&hd->bl))
+		return 0; //Can't vaporize a dead homun.
+
 	if (flag && hd->battle_status.hp < (hd->battle_status.max_hp*80/100))
 	if (flag && hd->battle_status.hp < (hd->battle_status.max_hp*80/100))
 		return 0;
 		return 0;