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