1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
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 |
… | |
… | |
1185 | middle = 0; |
1195 | middle = 0; |
1186 | |
1196 | |
1187 | if (top == middle) |
1197 | if (top == middle) |
1188 | middle = 0; |
1198 | middle = 0; |
1189 | |
1199 | |
|
|
1200 | // dire hack to handle "transparent" floors - currently only open_space |
|
|
1201 | if (floor && floor->arch->archname == shstr_quad_open_space) |
|
|
1202 | { |
|
|
1203 | floor->set_anim_frame (0); |
|
|
1204 | |
|
|
1205 | if (maptile *m = floor->map->tile_map [TILE_DOWN]) |
|
|
1206 | { |
|
|
1207 | // mirror the floor - very unreliable because usually outdated, |
|
|
1208 | // but somewhta works because floors do not change often :/ |
|
|
1209 | middle = floor; |
|
|
1210 | |
|
|
1211 | mapspace &ms = m->at (floor->x, floor->y); |
|
|
1212 | |
|
|
1213 | ms.update (); |
|
|
1214 | |
|
|
1215 | if (object *floor2 = ms.faces_obj [2]) |
|
|
1216 | if (floor2->arch->archname != shstr_quad_open_space && !middle) |
|
|
1217 | { |
|
|
1218 | floor->set_anim_frame (1); |
|
|
1219 | middle = floor; |
|
|
1220 | floor = floor2; |
|
|
1221 | } |
|
|
1222 | } |
|
|
1223 | } |
|
|
1224 | |
1190 | #if 0 |
1225 | #if 0 |
1191 | faces_obj [0] = top; |
1226 | faces_obj [0] = top; |
1192 | faces_obj [1] = middle; |
1227 | faces_obj [1] = middle; |
1193 | faces_obj [2] = floor; |
1228 | faces_obj [2] = floor; |
1194 | #endif |
1229 | #endif |
… | |
… | |
1198 | maptile::tile_available (int dir, bool load) |
1233 | maptile::tile_available (int dir, bool load) |
1199 | { |
1234 | { |
1200 | if (tile_path[dir]) |
1235 | if (tile_path[dir]) |
1201 | { |
1236 | { |
1202 | // map is there and we don't need to load it OR it's loaded => return what we have |
1237 | // 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)) |
1238 | if (tile_map[dir] && (!load || tile_map[dir]->linkable ())) |
1204 | return tile_map[dir]; |
1239 | return tile_map[dir]; |
1205 | |
1240 | |
1206 | // well, try to locate it then, if possible - maybe it's there already |
1241 | // 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))) |
1242 | if ((tile_map[dir] = find_async (tile_path[dir], this, load))) |
1208 | return tile_map[dir]; |
1243 | return tile_map[dir]; |