summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/map/map.c3
-rw-r--r--src/map/mercenary.c30
-rw-r--r--src/map/pet.c3
-rw-r--r--src/map/skill.c3
-rw-r--r--src/map/unit.c6
-rw-r--r--src/map/unit.h2
7 files changed, 27 insertions, 23 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 29e3b4729..24be9c9e0 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,9 @@ 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
+ * Little code cleanup [Toms]
+ * Cleaned merc_hom_evolution to avoid free'ing/realloc'ing [Toms]
+ * Fixed "args of aFree is freed pointer" on Homunc deletion [Toms]
* 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.
diff --git a/src/map/map.c b/src/map/map.c
index 6d359e412..c3e7d8f67 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -196,9 +196,6 @@ char wisp_server_name[NAME_LENGTH] = "Server"; // can be modified in char-server
int console = 0;
int enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex]
-static const int dirx[8]={0,-1,-1,-1,0,1,1,1};
-static const int diry[8]={1,1,0,-1,-1,-1,0,1};
-
/*==========================================
* 全map鯖?計での接??設定
* (char鯖から送られてくる)
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 ;
diff --git a/src/map/pet.c b/src/map/pet.c
index 895ad5e89..48427c4fc 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -34,9 +34,6 @@ struct pet_db pet_db[MAX_PET_DB];
static struct eri *item_drop_ers; //For loot drops delay structures.
static struct eri *item_drop_list_ers;
-static int dirx[8]={0,-1,-1,-1,0,1,1,1};
-static int diry[8]={1,1,0,-1,-1,-1,0,1};
-
int pet_hungry_val(struct pet_data *pd)
{
nullpo_retr(0, pd);
diff --git a/src/map/skill.c b/src/map/skill.c
index 05592fefa..ff184fb20 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -627,9 +627,6 @@ const struct skill_name_db skill_names[] = {
{ 0, "UNKNOWN_SKILL", "Unknown_Skill" }
};
-static const int dirx[8]={0,-1,-1,-1,0,1,1,1};
-static const int diry[8]={1,1,0,-1,-1,-1,0,1};
-
static struct eri *skill_unit_ers = NULL; //For handling skill_unit's [Skotlex]
static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Skotlex]
diff --git a/src/map/unit.c b/src/map/unit.c
index ea1efcca7..4d6fdc29f 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -15,7 +15,7 @@
#include "pc.h"
#include "mob.h"
#include "pet.h"
-#include "mercenary.h" ///[orn]
+#include "mercenary.h"
#include "skill.h"
#include "clif.h"
#include "npc.h"
@@ -30,8 +30,8 @@
#include "chrif.h"
#include "script.h"
-static int dirx[8]={0,-1,-1,-1,0,1,1,1};
-static int diry[8]={1,1,0,-1,-1,-1,0,1};
+const int dirx[8]={0,-1,-1,-1,0,1,1,1};
+const int diry[8]={1,1,0,-1,-1,-1,0,1};
struct unit_data* unit_bl2ud(struct block_list *bl) {
if( bl == NULL) return NULL;
diff --git a/src/map/unit.h b/src/map/unit.h
index 007cda5e6..1e4ff3956 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -67,4 +67,6 @@ int unit_changeviewsize(struct block_list *bl,short size);
int do_init_unit(void);
int do_final_unit(void);
+extern const int dirx[8];
+extern const int diry[8];
#endif /* _UNIT_H_ */