diff options
author | toms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-18 14:15:49 +0000 |
---|---|---|
committer | toms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-18 14:15:49 +0000 |
commit | 67213795d8e2c020d0e7d743e98238b65b35630e (patch) | |
tree | 3814dae50d00710f0fa93c1a50d0b7a375bfe8cd /src/map/mercenary.c | |
parent | a2b971ef0af9491bdbd93e07e600a69df97a46a1 (diff) | |
download | hercules-67213795d8e2c020d0e7d743e98238b65b35630e.tar.gz hercules-67213795d8e2c020d0e7d743e98238b65b35630e.tar.bz2 hercules-67213795d8e2c020d0e7d743e98238b65b35630e.tar.xz hercules-67213795d8e2c020d0e7d743e98238b65b35630e.zip |
- Little code cleanup
- Cleaned merc_hom_evolution to avoid free'ing/realloc'ing
- Fixed "args of aFree is freed pointer" on Homunc deletion
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8341 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mercenary.c')
-rw-r--r-- | src/map/mercenary.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 00759fe0d..5c3378540 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -34,9 +34,6 @@ #include "mercenary.h"
#include "charsave.h"
-static int dirx[8]={0,-1,-1,-1,0,1,1,1}; //[orn]
-static int diry[8]={1,1,0,-1,-1,-1,0,1}; //[orn]
-
//Better equiprobability than rand()% [orn]
#define rand(a, b) a+(int) ((float)(b-a+1)*rand()/(RAND_MAX+1.0))
@@ -180,7 +177,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,1);
+ return unit_remove_map(&hd->bl,0);
}
int merc_hom_calc_skilltree(struct map_session_data *sd)
@@ -323,10 +320,22 @@ int merc_hom_levelup(struct homun_data *hd) return 1 ;
}
+int merc_hom_change_class(struct homun_data *hd, short class_)
+{
+ int i;
+ i = search_homunculusDB_index(class_,HOMUNCULUS_CLASS);
+ if(i < 0) {
+ return 0;
+ }
+ hd->homunculusDB = &homunculus_db[i];
+ hd->master->homunculus.class_ = class_;
+ status_set_viewdata(&hd->bl, class_);
+ return 1;
+}
+
int merc_hom_evolution(struct homun_data *hd)
{
struct map_session_data *sd;
- short x,y;
nullpo_retr(0, hd);
if(!hd->homunculusDB->evo_class)
@@ -337,13 +346,12 @@ int merc_hom_evolution(struct homun_data *hd) sd = hd->master;
if (!sd) return 0;
- //TODO: Clean this up to avoid free'ing/realloc'ing.
- sd->homunculus.class_ = hd->homunculusDB->evo_class;
- x = hd->bl.x;
- y = hd->bl.y;
merc_hom_vaporize(sd, 0);
- unit_free(&hd->bl,0);
- merc_call_homunculus(sd, x, y);
+
+ if (!merc_hom_change_class(hd, hd->homunculusDB->evo_class))
+ ShowError("merc_hom_evolution: Can't evoluate homunc from %d to %d", hd->master->homunculus.class_, hd->homunculusDB->evo_class);
+
+ merc_call_homunculus(sd, hd->bl.x, hd->bl.y);
clif_emotion(&sd->bl, 21) ; //no1
clif_misceffect2(&hd->bl,568);
return 1 ;
|