… | |
… | |
361 | } |
361 | } |
362 | |
362 | |
363 | void |
363 | void |
364 | maptile::activate () |
364 | maptile::activate () |
365 | { |
365 | { |
366 | if (spaces) |
366 | if (state != MAP_INACTIVE) |
|
|
367 | return; |
|
|
368 | |
367 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
369 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
368 | for (object *op = ms->bot; op; op = op->above) |
370 | for (object *op = ms->bot; op; op = op->above) |
369 | op->activate_recursive (); |
371 | op->activate_recursive (); |
|
|
372 | |
|
|
373 | state = MAP_ACTIVE; |
|
|
374 | |
|
|
375 | activate_physics (); |
370 | } |
376 | } |
371 | |
377 | |
372 | void |
378 | void |
373 | maptile::deactivate () |
379 | maptile::deactivate () |
374 | { |
380 | { |
375 | if (spaces) |
381 | if (state != MAP_ACTIVE) |
|
|
382 | return; |
|
|
383 | |
376 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
384 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
377 | for (object *op = ms->bot; op; op = op->above) |
385 | for (object *op = ms->bot; op; op = op->above) |
378 | op->deactivate_recursive (); |
386 | op->deactivate_recursive (); |
|
|
387 | |
|
|
388 | state = MAP_INACTIVE; |
379 | } |
389 | } |
380 | |
390 | |
381 | bool |
391 | bool |
382 | maptile::_save_objects (object_freezer &f, int flags) |
392 | maptile::_save_objects (object_freezer &f, int flags) |
383 | { |
393 | { |
… | |
… | |
427 | } |
437 | } |
428 | |
438 | |
429 | void |
439 | void |
430 | maptile::init () |
440 | maptile::init () |
431 | { |
441 | { |
432 | in_memory = MAP_SWAPPED; |
442 | state = MAP_SWAPPED; |
433 | |
443 | |
434 | /* The maps used to pick up default x and y values from the |
444 | /* The maps used to pick up default x and y values from the |
435 | * map archetype. Mimic that behaviour. |
445 | * map archetype. Mimic that behaviour. |
436 | */ |
446 | */ |
437 | width = 16; |
447 | width = 16; |
… | |
… | |
827 | msg = 0; |
837 | msg = 0; |
828 | maplore = 0; |
838 | maplore = 0; |
829 | shoprace = 0; |
839 | shoprace = 0; |
830 | delete [] shopitems, shopitems = 0; |
840 | delete [] shopitems, shopitems = 0; |
831 | |
841 | |
832 | for (int i = 0; i < TILE_NUM; i++) |
842 | for (int i = 0; i < array_length (tile_path); i++) |
833 | tile_path [i] = 0; |
843 | tile_path [i] = 0; |
834 | } |
844 | } |
835 | |
845 | |
836 | maptile::~maptile () |
846 | maptile::~maptile () |
837 | { |
847 | { |
… | |
… | |
844 | /* We need to look through all the maps and see if any maps |
854 | /* We need to look through all the maps and see if any maps |
845 | * are pointing at this one for tiling information. Since |
855 | * are pointing at this one for tiling information. Since |
846 | * tiling can be asymetric, we just can not look to see which |
856 | * tiling can be asymetric, we just can not look to see which |
847 | * maps this map tiles with and clears those. |
857 | * maps this map tiles with and clears those. |
848 | */ |
858 | */ |
849 | for (int i = 0; i < 4; i++) |
859 | for (int i = 0; i < array_length (tile_path); i++) |
850 | if (tile_map[i] == m) |
860 | if (tile_map[i] == m) |
851 | tile_map[i] = 0; |
861 | tile_map[i] = 0; |
852 | } |
862 | } |
853 | |
863 | |
854 | void |
864 | void |
… | |
… | |
1198 | maptile::tile_available (int dir, bool load) |
1208 | maptile::tile_available (int dir, bool load) |
1199 | { |
1209 | { |
1200 | if (tile_path[dir]) |
1210 | if (tile_path[dir]) |
1201 | { |
1211 | { |
1202 | // map is there and we don't need to load it OR it's loaded => return what we have |
1212 | // map is there and we don't need to load it OR it's loaded => return what we have |
1203 | if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_ACTIVE)) |
1213 | if (tile_map[dir] && (!load || tile_map[dir]->linkable ())) |
1204 | return tile_map[dir]; |
1214 | return tile_map[dir]; |
1205 | |
1215 | |
1206 | // well, try to locate it then, if possible - maybe it's there already |
1216 | // well, try to locate it then, if possible - maybe it's there already |
1207 | if ((tile_map[dir] = find_async (tile_path[dir], this, load))) |
1217 | if ((tile_map[dir] = find_async (tile_path[dir], this, load))) |
1208 | return tile_map[dir]; |
1218 | return tile_map[dir]; |