Browse Source

- Changed unit_free so that it receives which cleartype should be used when the character is still on a map. Used this on status_damage so that mobs that do not respawn when killed will properly display the death animation.
- Should have fixed the signed/unsigned comparison warnings in the main regen function.
- Fixed Energy Coat consuming 10x less SP per hit than it should.


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

skotlex 19 years ago
parent
commit
b5508efe38
11 changed files with 35 additions and 31 deletions
  1. 5 0
      Changelog-Trunk.txt
  2. 1 1
      src/map/battle.c
  3. 5 5
      src/map/map.c
  4. 3 3
      src/map/mercenary.c
  5. 5 6
      src/map/mob.c
  6. 1 1
      src/map/npc.c
  7. 1 1
      src/map/pet.c
  8. 1 1
      src/map/script.c
  9. 7 7
      src/map/status.c
  10. 5 5
      src/map/unit.c
  11. 1 1
      src/map/unit.h

+ 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.
 
 2006/08/18
+	* Changed unit_free so that it receives which cleartype should be used when
+	  the character is still on a map. Used this on status_damage so that mobs
+	  that do not respawn when killed will properly display the death animation.
+	  [Skotlex]
+	* Fixed Energy Coat consuming 10x less SP per hit than it should.
 	* Fixed signed/unsigned comparison issues with natural heal system [Toms]
 2006/08/17
 	* Vaporize will no fail when the homun is dead. [Skotlex]

+ 1 - 1
src/map/battle.c

@@ -375,7 +375,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i
 			int per = 100*status->sp / status->max_sp;
 			per /=20; //Uses 20% SP intervals.
 			//SP Cost: 1% + 0.5% per every 20% SP
-			if (!status_charge(bl, 0, (10+5*per)*status->max_sp/10000))
+			if (!status_charge(bl, 0, (10+5*per)*status->max_sp/1000))
 				status_change_end( bl,SC_ENERGYCOAT,-1 );
 			//Reduction: 6% + 6% every 20%
 			damage -= damage * 6 * (1+per) / 100;

+ 5 - 5
src/map/map.c

@@ -1670,9 +1670,9 @@ int map_quit(struct map_session_data *sd) {
 			npc_script_event(sd, NPCE_LOGOUT);
 
 		sd->state.waitingdisconnect = 1;
-		if (sd->pd) unit_free(&sd->pd->bl);
-		if (sd->hd) unit_free(&sd->hd->bl);
-		unit_free(&sd->bl);
+		if (sd->pd) unit_free(&sd->pd->bl,0);
+		if (sd->hd) unit_free(&sd->hd->bl,0);
+		unit_free(&sd->bl,3);
 		chrif_save(sd,1);
 	} else { //Try to free some data, without saving anything (this could be invoked on map server change. [Skotlex]
 		if (sd->bl.prev != NULL)
@@ -1991,7 +1991,7 @@ int mob_cache_cleanup_sub(struct block_list *bl, va_list ap) {
 		md->status.hp < md->status.max_hp)
 		return 0; //Do not remove damaged mobs.
 	
-	unit_free(&md->bl);
+	unit_free(&md->bl,0);
 
 	return 1;
 }
@@ -3617,7 +3617,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) {
 			npc_unload((struct npc_data *)bl);
 			break;
 		case BL_MOB:
-			unit_free(bl);
+			unit_free(bl,0);
 			break;
 		case BL_PET:
 		//There is no need for this, the pet is removed together with the player. [Skotlex]

+ 3 - 3
src/map/mercenary.c

@@ -170,7 +170,7 @@ int merc_hom_delete(struct homun_data *hd, int emote)
 	sd = hd->master;
 
 	if (!sd)
-		return unit_free(&hd->bl);
+		return unit_free(&hd->bl,1);
 
 	if (emote >= 0)
 		clif_emotion(&sd->bl, emote);
@@ -180,7 +180,7 @@ int merc_hom_delete(struct homun_data *hd, int emote)
 	// Send homunculus_dead to client
 	sd->homunculus.hp = 0;
 	clif_hominfo(sd, hd, 0);
-	return unit_free(&hd->bl);
+	return unit_free(&hd->bl,1);
 }
 
 int merc_hom_calc_skilltree(struct map_session_data *sd)
@@ -342,7 +342,7 @@ int merc_hom_evolution(struct homun_data *hd)
 	x = hd->bl.x;
 	y = hd->bl.y;
 	merc_hom_vaporize(sd, 0);
-	unit_free(&hd->bl);
+	unit_free(&hd->bl,0);
 	merc_call_homunculus(sd, x, y);
 	clif_emotion(&sd->bl, 21) ;	//no1
 	clif_misceffect2(&hd->bl,568);

+ 5 - 6
src/map/mob.c

@@ -418,7 +418,7 @@ static int mob_spawn_guardian_sub(int tid,unsigned int tick,int id,int data)
 				guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
 				guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
 			}
-			unit_free(&md->bl); //Remove guardian.
+			unit_free(&md->bl,0); //Remove guardian.
 		}
 		return 0;
 	}
@@ -594,7 +594,7 @@ int mob_setdelayspawn(struct mob_data *md)
 
 
 	if (!md->spawn) //Doesn't has respawn data!
-		return unit_free(&md->bl);
+		return unit_free(&md->bl,1);
 
 	spawntime1 = md->last_spawntime + md->spawn->delay1;
 	spawntime2 = md->last_deadtime + md->spawn->delay2;
@@ -1494,8 +1494,7 @@ int mob_timer_delete(int tid, unsigned int tick, int id, int data)
 		return 0; //??
 //for Alchemist CANNIBALIZE [Lupus]
 	((TBL_MOB*)bl)->deletetimer = -1;
-	unit_remove_map(bl, 3);
-	unit_free(bl);
+	unit_free(bl,3);
 	return 0;
 }
 
@@ -2205,7 +2204,7 @@ int mob_guardian_guildchange(struct block_list *bl,va_list ap)
 				guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
 				guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
 			}
-			unit_free(&md->bl); //Remove guardian.
+			unit_free(&md->bl,0); //Remove guardian.
 		}
 		return 0;
 	}
@@ -2217,7 +2216,7 @@ int mob_guardian_guildchange(struct block_list *bl,va_list ap)
 		md->guardian_data->castle->guardian[md->guardian_data->number].visible = 0;
 		guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
 		guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
-		unit_free(&md->bl);
+		unit_free(&md->bl,0);
 		return 0;
 	}
 

+ 1 - 1
src/map/npc.c

@@ -2780,7 +2780,7 @@ static int npc_cleanup_sub (struct block_list *bl, va_list ap) {
 		npc_unload((struct npc_data *)bl);
 		break;
 	case BL_MOB:
-		unit_free(bl);
+		unit_free(bl,0);
 		break;
 	}
 

+ 1 - 1
src/map/pet.c

@@ -364,7 +364,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
 		pd->state.skillbonus = 0;
 		status_calc_pc(sd,0);
 	}
-	unit_free(&pd->bl);
+	unit_free(&pd->bl,0);
 	sd->status.pet_id = 0;
 
 	return 1;

+ 1 - 1
src/map/script.c

@@ -11795,7 +11795,7 @@ int buildin_mobremove(struct script_state *st) {
 
 	bl = map_id2bl(id);
 	if (bl && bl->type == BL_MOB)
-		unit_free(bl);
+		unit_free(bl,0);
 
 	return 0;
 }

+ 7 - 7
src/map/status.c

@@ -712,7 +712,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
 			memset(&regen->tick, 0, sizeof(regen->tick));
 	}
 	if(flag&4) //Delete from memory. (also invokes map removal code)
-		unit_free(target);
+		unit_free(target,1);
 	else
 	if(flag&2) //remove from map
 		unit_remove_map(target,1);
@@ -6843,13 +6843,13 @@ static int status_natural_heal(DBKey key,void * data,va_list app)
 			rate/=2;
 		regen->tick.hp += rate;
 		
-		if(regen->tick.hp >= battle_config.natural_healhp_interval)
+		if(regen->tick.hp >= (unsigned int)battle_config.natural_healhp_interval)
 		{
 			val = 0;
 			do {
 				val += regen->hp;
 				regen->tick.hp -= battle_config.natural_healhp_interval;
-			} while(regen->tick.hp >= battle_config.natural_healhp_interval);
+			} while(regen->tick.hp >= (unsigned int)battle_config.natural_healhp_interval);
 			if (status_heal(bl, val, 0, 1) < val)
 				flag&=~RGN_SHP; //full.
 		}
@@ -6858,7 +6858,7 @@ static int status_natural_heal(DBKey key,void * data,va_list app)
 	{
 		regen->tick.shp += natural_heal_diff_tick * regen->rate.shp;
 		
-		while(regen->tick.shp >= battle_config.natural_heal_skill_interval)
+		while(regen->tick.shp >= (unsigned int)battle_config.natural_heal_skill_interval)
 		{
 			regen->tick.shp -= battle_config.natural_heal_skill_interval;
 			if(status_heal(bl, regen->shp, 0, 3) < regen->shp)
@@ -6869,13 +6869,13 @@ static int status_natural_heal(DBKey key,void * data,va_list app)
 	{
 		regen->tick.sp += natural_heal_diff_tick*(regen->rate.sp+bonus);
 		
-		if(regen->tick.sp >= battle_config.natural_healsp_interval)
+		if(regen->tick.sp >= (unsigned int)battle_config.natural_healsp_interval)
 		{
 			val = 0;
 			do {
 				val += regen->sp;
 				regen->tick.sp -= battle_config.natural_healsp_interval;
-			} while(regen->tick.sp >= battle_config.natural_healsp_interval);
+			} while(regen->tick.sp >= (unsigned int)battle_config.natural_healsp_interval);
 			if (status_heal(bl, 0, val, 1) < val)
 				flag&=~RGN_SSP; //full.
 		}
@@ -6883,7 +6883,7 @@ static int status_natural_heal(DBKey key,void * data,va_list app)
 	if(flag&RGN_SSP)
 	{
 		regen->tick.ssp += natural_heal_diff_tick * regen->rate.ssp;
-		while(regen->tick.ssp >= battle_config.natural_heal_skill_interval)
+		while(regen->tick.ssp >= (unsigned int)battle_config.natural_heal_skill_interval)
 		{
 			regen->tick.ssp -= battle_config.natural_heal_skill_interval;
 			if(status_heal(bl, 0, regen->ssp, 3) < regen->ssp)

+ 5 - 5
src/map/unit.c

@@ -1579,7 +1579,7 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
 		if(pd->pet.intimate <= 0) {
 			clif_clearchar_area(bl,clrtype);
 			map_delblock(bl);
-			unit_free(bl);
+			unit_free(bl,0);
 			map_freeblock_unlock();
 			return 0;
 		}
@@ -1591,7 +1591,7 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
 			clif_emotion(bl, 28) ;	//sob
 			clif_clearchar_area(bl,clrtype);
 			map_delblock(bl);
-			unit_free(bl);
+			unit_free(bl,0);
 			map_freeblock_unlock();
 			return 0;
 		}
@@ -1604,17 +1604,17 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
 
 /*==========================================
  * Function to free all related resources to the bl
- * if unit is on map, it is removed using clrtype 0.
+ * if unit is on map, it is removed using the clrtype specified
  *------------------------------------------
  */
 
-int unit_free(struct block_list *bl) {
+int unit_free(struct block_list *bl, int clrtype) {
 	struct unit_data *ud = unit_bl2ud( bl );
 	nullpo_retr(0, ud);
 
 	map_freeblock_lock();
 	if( bl->prev )	//Players are supposed to logout with a "warp" effect.
-		unit_remove_map(bl, bl->type==BL_PC?3:0);
+		unit_remove_map(bl, clrtype);
 	
 	if( bl->type == BL_PC ) {
 		struct map_session_data *sd = (struct map_session_data*)bl;

+ 1 - 1
src/map/unit.h

@@ -60,7 +60,7 @@ int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int
 // ‚»‚Ì‘¼
 struct unit_data* unit_bl2ud(struct block_list *bl);
 int unit_remove_map(struct block_list *bl, int clrtype);
-int unit_free(struct block_list *bl);
+int unit_free(struct block_list *bl, int clrtype);
 int unit_changeviewsize(struct block_list *bl,short size);
 
 // �‰Šú‰»ƒ‹�[ƒ`ƒ“