ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.49 by root, Mon Dec 25 14:54:44 2006 UTC vs.
Revision 1.50 by root, Mon Dec 25 15:28:35 2006 UTC

1289 return; 1289 return;
1290 1290
1291 m->in_memory = MAP_LOADING; 1291 m->in_memory = MAP_LOADING;
1292 if (m->tmpname == NULL) /* if we have loaded unique items from */ 1292 if (m->tmpname == NULL) /* if we have loaded unique items from */
1293 delete_unique_items (m); /* original map before, don't duplicate them */ 1293 delete_unique_items (m); /* original map before, don't duplicate them */
1294
1294 load_objects (m, thawer, 0); 1295 load_objects (m, thawer, 0);
1295 1296
1296 m->in_memory = MAP_IN_MEMORY; 1297 m->in_memory = MAP_IN_MEMORY;
1297} 1298}
1298
1299 1299
1300/* 1300/*
1301 * Saves a map to file. If flag is set, it is saved into the same 1301 * Saves a map to file. If flag is set, it is saved into the same
1302 * file it was (originally) loaded from. Otherwise a temporary 1302 * file it was (originally) loaded from. Otherwise a temporary
1303 * filename will be genarated, and the file will be stored there. 1303 * filename will be genarated, and the file will be stored there.
1304 * The temporary filename will be stored in the maptileure. 1304 * The temporary filename will be stored in the maptileure.
1305 * If the map is unique, we also save to the filename in the map 1305 * If the map is unique, we also save to the filename in the map
1306 * (this should have been updated when first loaded) 1306 * (this should have been updated when first loaded)
1307 */ 1307 */
1308
1309int 1308int
1310new_save_map (maptile *m, int flag) 1309new_save_map (maptile *m, int flag)
1311{ 1310{
1312 char filename[MAX_BUF], buf[MAX_BUF], shop[MAX_BUF]; 1311 char filename[MAX_BUF], buf[MAX_BUF], shop[MAX_BUF];
1313 int i; 1312 int i;
1477 * don't free tmpname - our caller is left to do that 1476 * don't free tmpname - our caller is left to do that
1478 */ 1477 */
1479void 1478void
1480free_map (maptile *m, int flag) 1479free_map (maptile *m, int flag)
1481{ 1480{
1482 if (m->in_memory != MAP_IN_MEMORY) 1481 if (!m->in_memory) //TODO: makes no sense to me?
1483 return; 1482 return;
1484 1483
1485 m->in_memory = MAP_SAVING; 1484 m->in_memory = MAP_SAVING;
1486 1485
1487 // TODO: use new/delete 1486 // TODO: use new/delete
1488#define FREE_AND_CLEAR(p) { free (p); p = NULL; }
1489 1487
1490 if (flag && m->spaces) 1488 if (flag && m->spaces)
1491 free_all_objects (m); 1489 free_all_objects (m);
1492 if (m->name)
1493 FREE_AND_CLEAR (m->name);
1494 if (m->spaces)
1495 FREE_AND_CLEAR (m->spaces);
1496 if (m->msg)
1497 FREE_AND_CLEAR (m->msg);
1498 if (m->maplore)
1499 FREE_AND_CLEAR (m->maplore);
1500 1490
1501 delete [] m->shopitems; 1491 free (m->name), m->name = 0;
1502 m->shopitems = 0; 1492 free (m->spaces), m->spaces = 0;
1503 1493 free (m->msg), m->msg = 0;
1504 if (m->shoprace) 1494 free (m->maplore), m->maplore = 0;
1505 FREE_AND_CLEAR (m->shoprace); 1495 free (m->shoprace), m->shoprace = 0;
1496 delete [] m->shopitems, m->shopitems = 0;
1506 1497
1507 if (m->buttons) 1498 if (m->buttons)
1508 free_objectlinkpt (m->buttons); 1499 free_objectlinkpt (m->buttons), m->buttons = 0;
1509
1510 m->buttons = NULL;
1511 1500
1512 for (int i = 0; i < 4; i++) 1501 for (int i = 0; i < 4; i++)
1513 { 1502 {
1514 if (m->tile_path[i]) 1503 if (m->tile_path[i])
1515 FREE_AND_CLEAR (m->tile_path[i]); 1504 free (m->tile_path[i]), m->tile_path[i] = 0;
1516 1505
1517 m->tile_map[i] = 0; 1506 m->tile_map[i] = 0;
1518 } 1507 }
1519 1508
1520 m->in_memory = MAP_SWAPPED; 1509 m->in_memory = MAP_SWAPPED;
1521
1522#undef FREE_AND_CLEAR
1523} 1510}
1524 1511
1525maptile::~maptile () 1512maptile::~maptile ()
1526{ 1513{
1527 free_map (this, 1); 1514 free_map (this, 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines