summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.txt2
-rw-r--r--src/map/map.c3
-rw-r--r--src/map/pet.c18
-rw-r--r--src/map/pet.h1
4 files changed, 19 insertions, 5 deletions
diff --git a/Changelog.txt b/Changelog.txt
index de465eae7..6c625db54 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,6 +1,8 @@
Date Added
01/27
+ * Added memory leak fixes with temporary script variables and pets-related
+ actions, by End_of_exam / jA 1109 [celest]
* Kick all characters when the char server disconnects from the map
server [celest]
* Added @changelook command for spriters to test view ID's [celest]
diff --git a/src/map/map.c b/src/map/map.c
index 16a8d5905..50f44c327 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1094,6 +1094,8 @@ int map_quit(struct map_session_data *sd) {
}
strdb_erase(nick_db,sd->status.name);
numdb_erase(charid_db,sd->status.char_id);
+ free(sd->reg);
+ free(sd->regstr);
return 0;
}
@@ -2626,6 +2628,7 @@ void do_final(void) {
do_final_itemdb();
do_final_storage();
do_final_guild();
+ do_final_pet();
/*
for(i=0;i<map_num;i++){
if(map[i].gat) {
diff --git a/src/map/pet.c b/src/map/pet.c
index 759e2d11b..c50e76087 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -610,6 +610,7 @@ int pet_remove_map(struct map_session_data *sd)
pet_hungry_timer_delete(sd);
clif_clearchar_area(&sd->pd->bl,0);
map_delblock(&sd->pd->bl);
+ free(sd->pd->lootitem);
map_deliddb(&sd->pd->bl);
}
return 0;
@@ -653,7 +654,8 @@ int pet_return_egg(struct map_session_data *sd)
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
if(sd->status.pet_id && sd->pd) {
- struct pet_data *pd=sd->pd;
+ // ルートしたItemを落とさせる
+ pet_lootitem_drop(sd->pd,sd);
pet_remove_map(sd);
sd->status.pet_id = 0;
sd->pd = NULL;
@@ -677,8 +679,6 @@ int pet_return_egg(struct map_session_data *sd)
else
status_calc_pc(sd,2);
}
- // ルートしたItemを落とさせる
- pet_lootitem_drop(pd,sd);
intif_save_petdata(sd->status.account_id,&sd->pet);
pc_makesavestatus(sd);
@@ -1382,8 +1382,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
else
add_timer(gettick()+540+i,pet_delay_item_drop2,(int)ditem,0);
}
- pd->lootitem=NULL;
- pd->lootitem=(struct item *)aCalloc(PETLOOT_SIZE,sizeof(struct item));
+ memset(pd->lootitem,0,LOOTITEM_SIZE * sizeof(struct item));
pd->lootitem_count = 0;
pd->lootitem_weight = 0;
pd->lootitem_timer = gettick()+10000; // 10*1000msの間拾わない
@@ -1701,3 +1700,12 @@ int do_init_pet(void)
return 0;
}
+int do_final_pet(void) {
+ int i;
+ for(i = 0;i < MAX_PET_DB; i++) {
+ if(pet_db[i].script) {
+ free(pet_db[i].script);
+ }
+ }
+ return 0;
+}
diff --git a/src/map/pet.h b/src/map/pet.h
index 1664f42d5..425bc6887 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -64,6 +64,7 @@ int pet_heal_timer(int tid,unsigned int tick,int id,int data); // [Valaris]
int pet_skillattack_timer(int tid,unsigned int tick,int id,int data); // [Valaris]
int do_init_pet(void);
+int do_final_pet(void);
#endif