summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c90
1 files changed, 70 insertions, 20 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 6f9401dad..dde922f39 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2894,13 +2894,54 @@ int map_delmap(char* mapname)
return 0;
}
+void do_final_maps(void) {
+ int i, v = 0;
+
+ for( i = 0; i < map_num; i++ ) {
+
+ if(map[i].cell) aFree(map[i].cell);
+ if(map[i].block) aFree(map[i].block);
+ if(map[i].block_mob) aFree(map[i].block_mob);
+
+ if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random]
+ int j;
+ if(map[i].mob_delete_timer != INVALID_TIMER)
+ delete_timer(map[i].mob_delete_timer, map_removemobs_timer);
+ for (j=0; j<MAX_MOB_LIST_PER_MAP; j++)
+ if (map[i].moblist[j]) aFree(map[i].moblist[j]);
+ }
+
+ if( map[i].unit_count ) {
+ for(v = 0; v < map[i].unit_count; v++) {
+ aFree(map[i].units[v]);
+ }
+ if( map[i].units ) {
+ aFree(map[i].units);
+ map[i].units = NULL;
+ }
+ map[i].unit_count = 0;
+ }
+
+ if( map[i].skill_count ) {
+ for(v = 0; v < map[i].skill_count; v++) {
+ aFree(map[i].skills[v]);
+ }
+ if( map[i].skills ) {
+ aFree(map[i].skills);
+ map[i].skills = NULL;
+ }
+ map[i].skill_count = 0;
+ }
+
+ }
+
+}
+
/// Initializes map flags and adjusts them depending on configuration.
-void map_flags_init(void)
-{
- int i;
+void map_flags_init(void) {
+ int i, v = 0;
- for( i = 0; i < map_num; i++ )
- {
+ for( i = 0; i < map_num; i++ ) {
// mapflags
memset(&map[i].flag, 0, sizeof(map[i].flag));
@@ -2911,6 +2952,24 @@ void map_flags_init(void)
map[i].jexp = 100; // per map job exp multiplicator
memset(map[i].drop_list, 0, sizeof(map[i].drop_list)); // pvp nightmare drop list
+ if( map[i].unit_count ) {
+ for(v = 0; v < map[i].unit_count; v++) {
+ aFree(map[i].units[v]);
+ }
+ aFree(map[i].units);
+ }
+ map[i].units = NULL;
+ map[i].unit_count = 0;
+
+ if( map[i].skill_count ) {
+ for(v = 0; v < map[i].skill_count; v++) {
+ aFree(map[i].skills[v]);
+ }
+ aFree(map[i].skills);
+ }
+ map[i].skills = NULL;
+ map[i].skill_count = 0;
+
// adjustments
if( battle_config.pk_mode )
map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
@@ -3552,7 +3611,7 @@ static int cleanup_db_sub(DBKey key, DBData *data, va_list va)
*------------------------------------------*/
void do_final(void)
{
- int i, j;
+ int i;
struct map_session_data* sd;
struct s_mapiterator* iter;
@@ -3600,21 +3659,10 @@ void do_final(void)
do_final_battleground();
do_final_duel();
do_final_elemental();
-
+ do_final_maps();
+
map_db->destroy(map_db, map_db_final);
-
- for (i=0; i<map_num; i++) {
- if(map[i].cell) aFree(map[i].cell);
- if(map[i].block) aFree(map[i].block);
- if(map[i].block_mob) aFree(map[i].block_mob);
- if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random]
- if(map[i].mob_delete_timer != INVALID_TIMER)
- delete_timer(map[i].mob_delete_timer, map_removemobs_timer);
- for (j=0; j<MAX_MOB_LIST_PER_MAP; j++)
- if (map[i].moblist[j]) aFree(map[i].moblist[j]);
- }
- }
-
+
mapindex_final();
if(enable_grf)
grfio_final();
@@ -3939,6 +3987,8 @@ int do_init(int argc, char *argv[])
ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port);
+ Sql_HerculesUpdateCheck(mmysql_handle);
+
if( runflag != CORE_ST_STOP )
{
shutdown_callback = do_shutdown;