--- deliantra/server/common/map.C 2006/12/12 22:37:05 1.41 +++ deliantra/server/common/map.C 2006/12/18 04:07:30 1.44 @@ -30,7 +30,6 @@ #include "path.h" - /* * Returns the maptile which has a name matching the given argument. * return NULL if no match is found. @@ -732,7 +731,7 @@ int i = 0, number_of_entries = 0; const typedata *current_type; - shop_string = strdup_local (input_string); + shop_string = strdup (input_string); p = shop_string; /* first we'll count the entries, we'll need that for allocating the array shortly */ while (p) @@ -928,7 +927,7 @@ * when msgpos is zero, so copying it results in crashes */ if (msgpos != 0) - m->msg = strdup_local (msgbuf); + m->msg = strdup (msgbuf); } else if (!strcmp (key, "maplore")) { @@ -944,7 +943,7 @@ } } if (maplorepos != 0) - m->maplore = strdup_local (maplorebuf); + m->maplore = strdup (maplorebuf); } else if (!strcmp (key, "end")) { @@ -963,7 +962,7 @@ else if (!strcmp (key, "name")) { *end = 0; - m->name = strdup_local (value); + m->name = strdup (value); } /* first strcmp value on these are old names supported * for compatibility reasons. The new values (second) are @@ -1011,7 +1010,7 @@ else if (!strcmp (key, "shoprace")) { *end = 0; - m->shoprace = strdup_local (value); + m->shoprace = strdup (value); } else if (!strcmp (key, "outdoor")) m->outdoor = atoi (value); @@ -1071,12 +1070,12 @@ if (editor) { /* Use the value as in the file. */ - m->tile_path[tile - 1] = strdup_local (value); + m->tile_path[tile - 1] = strdup (value); } else if (path != NULL) { /* Use the normalized value. */ - m->tile_path[tile - 1] = strdup_local (path); + m->tile_path[tile - 1] = strdup (path); } } /* end if tile direction (in)valid */ } @@ -1345,7 +1344,7 @@ else { if (!m->tmpname) - m->tmpname = tempnam_local (settings.tmpdir, NULL); + m->tmpname = tempnam (settings.tmpdir, NULL); strcpy (filename, m->tmpname); } @@ -1534,6 +1533,10 @@ LOG (llevError, "Trying to free freed map.\n"); return; } + + // TODO: use new/delete +#define FREE_AND_CLEAR(p) { free (p); p = NULL; } + if (flag && m->spaces) free_all_objects (m); if (m->name) @@ -1544,21 +1547,29 @@ FREE_AND_CLEAR (m->msg); if (m->maplore) FREE_AND_CLEAR (m->maplore); - if (m->shopitems) - delete[]m->shopitems; + + delete [] m->shopitems; m->shopitems = 0; + if (m->shoprace) FREE_AND_CLEAR (m->shoprace); + if (m->buttons) free_objectlinkpt (m->buttons); + m->buttons = NULL; + for (i = 0; i < 4; i++) { if (m->tile_path[i]) FREE_AND_CLEAR (m->tile_path[i]); m->tile_map[i] = NULL; } + m->in_memory = MAP_SWAPPED; + +#undef FREE_AND_CLEAR + } /* @@ -1629,8 +1640,6 @@ delete m; } - - /* * Makes sure the given map is loaded and swapped in. * name is path name of the map. @@ -1642,7 +1651,6 @@ * * Returns a pointer to the given map. */ - maptile * ready_map_name (const char *name, int flags) { @@ -2098,7 +2106,7 @@ timeout = MAP_DEFAULTRESET; if (timeout >= MAP_MAXRESET) timeout = MAP_MAXRESET; - MAP_WHEN_RESET (map) = seconds () + timeout; + MAP_WHEN_RESET (map) = time (0) + timeout; } /* this updates the orig_map->tile_map[tile_num] value after loading