… | |
… | |
1532 | if (!m->in_memory) |
1532 | if (!m->in_memory) |
1533 | { |
1533 | { |
1534 | LOG (llevError, "Trying to free freed map.\n"); |
1534 | LOG (llevError, "Trying to free freed map.\n"); |
1535 | return; |
1535 | return; |
1536 | } |
1536 | } |
|
|
1537 | |
|
|
1538 | // TODO: use new/delete |
|
|
1539 | #define FREE_AND_CLEAR(p) { free (p); p = NULL; } |
|
|
1540 | |
1537 | if (flag && m->spaces) |
1541 | if (flag && m->spaces) |
1538 | free_all_objects (m); |
1542 | free_all_objects (m); |
1539 | if (m->name) |
1543 | if (m->name) |
1540 | FREE_AND_CLEAR (m->name); |
1544 | FREE_AND_CLEAR (m->name); |
1541 | if (m->spaces) |
1545 | if (m->spaces) |
1542 | FREE_AND_CLEAR (m->spaces); |
1546 | FREE_AND_CLEAR (m->spaces); |
1543 | if (m->msg) |
1547 | if (m->msg) |
1544 | FREE_AND_CLEAR (m->msg); |
1548 | FREE_AND_CLEAR (m->msg); |
1545 | if (m->maplore) |
1549 | if (m->maplore) |
1546 | FREE_AND_CLEAR (m->maplore); |
1550 | FREE_AND_CLEAR (m->maplore); |
1547 | if (m->shopitems) |
1551 | |
1548 | delete[]m->shopitems; |
1552 | delete [] m->shopitems; |
1549 | m->shopitems = 0; |
1553 | m->shopitems = 0; |
|
|
1554 | |
1550 | if (m->shoprace) |
1555 | if (m->shoprace) |
1551 | FREE_AND_CLEAR (m->shoprace); |
1556 | FREE_AND_CLEAR (m->shoprace); |
|
|
1557 | |
1552 | if (m->buttons) |
1558 | if (m->buttons) |
1553 | free_objectlinkpt (m->buttons); |
1559 | free_objectlinkpt (m->buttons); |
|
|
1560 | |
1554 | m->buttons = NULL; |
1561 | m->buttons = NULL; |
|
|
1562 | |
1555 | for (i = 0; i < 4; i++) |
1563 | for (i = 0; i < 4; i++) |
1556 | { |
1564 | { |
1557 | if (m->tile_path[i]) |
1565 | if (m->tile_path[i]) |
1558 | FREE_AND_CLEAR (m->tile_path[i]); |
1566 | FREE_AND_CLEAR (m->tile_path[i]); |
1559 | m->tile_map[i] = NULL; |
1567 | m->tile_map[i] = NULL; |
1560 | } |
1568 | } |
|
|
1569 | |
1561 | m->in_memory = MAP_SWAPPED; |
1570 | m->in_memory = MAP_SWAPPED; |
|
|
1571 | |
|
|
1572 | #undef FREE_AND_CLEAR |
|
|
1573 | |
1562 | } |
1574 | } |
1563 | |
1575 | |
1564 | /* |
1576 | /* |
1565 | * function: vanish maptile |
1577 | * function: vanish maptile |
1566 | * m : pointer to maptile, if NULL no action |
1578 | * m : pointer to maptile, if NULL no action |
… | |
… | |
2096 | timeout = MAP_RESET_TIMEOUT (map); |
2108 | timeout = MAP_RESET_TIMEOUT (map); |
2097 | if (timeout <= 0) |
2109 | if (timeout <= 0) |
2098 | timeout = MAP_DEFAULTRESET; |
2110 | timeout = MAP_DEFAULTRESET; |
2099 | if (timeout >= MAP_MAXRESET) |
2111 | if (timeout >= MAP_MAXRESET) |
2100 | timeout = MAP_MAXRESET; |
2112 | timeout = MAP_MAXRESET; |
2101 | MAP_WHEN_RESET (map) = seconds () + timeout; |
2113 | MAP_WHEN_RESET (map) = time (0) + timeout; |
2102 | } |
2114 | } |
2103 | |
2115 | |
2104 | /* this updates the orig_map->tile_map[tile_num] value after loading |
2116 | /* this updates the orig_map->tile_map[tile_num] value after loading |
2105 | * the map. It also takes care of linking back the freshly loaded |
2117 | * the map. It also takes care of linking back the freshly loaded |
2106 | * maps tile_map values if it tiles back to this one. It returns |
2118 | * maps tile_map values if it tiles back to this one. It returns |