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,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 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 |
… | |
… | |
1005 | |
1005 | |
1006 | freelist = li; |
1006 | freelist = li; |
1007 | ++free_count; |
1007 | ++free_count; |
1008 | } |
1008 | } |
1009 | |
1009 | |
1010 | // special "grave" map used to store all removed objects |
|
|
1011 | // till they can be destroyed - saves a lot of checks in the rest |
|
|
1012 | // of the code |
|
|
1013 | static struct freed_map |
|
|
1014 | : maptile |
|
|
1015 | { |
|
|
1016 | freed_map () |
|
|
1017 | : maptile (3, 3) |
|
|
1018 | { |
|
|
1019 | path = "<freed objects map>"; |
|
|
1020 | name = "/internal/freed_objects_map"; |
|
|
1021 | no_drop = 1; |
|
|
1022 | no_reset = 1; |
|
|
1023 | |
|
|
1024 | state = MAP_ACTIVE; |
|
|
1025 | } |
|
|
1026 | |
|
|
1027 | ~freed_map () |
|
|
1028 | { |
|
|
1029 | destroy (); |
|
|
1030 | } |
|
|
1031 | } freed_map; // freed objects are moved here to avoid crashes |
|
|
1032 | |
|
|
1033 | void |
1010 | void |
1034 | object::do_destroy () |
1011 | object::do_destroy () |
1035 | { |
1012 | { |
1036 | if (flag [FLAG_IS_LINKED]) |
1013 | if (flag [FLAG_IS_LINKED]) |
1037 | remove_link (); |
1014 | remove_link (); |
… | |
… | |
2031 | */ |
2008 | */ |
2032 | int |
2009 | int |
2033 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2010 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2034 | { |
2011 | { |
2035 | int altern[SIZEOFFREE]; |
2012 | int altern[SIZEOFFREE]; |
2036 | int index = 0, flag; |
2013 | int index = 0; |
2037 | |
2014 | |
2038 | for (int i = start; i < stop; i++) |
2015 | for (int i = start; i < stop; i++) |
2039 | { |
2016 | { |
2040 | mapxy pos (m, x, y); pos.move (i); |
2017 | mapxy pos (m, x, y); pos.move (i); |
2041 | |
2018 | |
… | |
… | |
2153 | * there is capable of. |
2130 | * there is capable of. |
2154 | */ |
2131 | */ |
2155 | int |
2132 | int |
2156 | find_dir (maptile *m, int x, int y, object *exclude) |
2133 | find_dir (maptile *m, int x, int y, object *exclude) |
2157 | { |
2134 | { |
2158 | int max = SIZEOFFREE, mflags; |
2135 | int max = SIZEOFFREE; |
2159 | MoveType move_type; |
2136 | MoveType move_type; |
2160 | |
2137 | |
2161 | if (exclude && exclude->head_ () != exclude) |
2138 | if (exclude && exclude->head_ () != exclude) |
2162 | { |
2139 | { |
2163 | exclude = exclude->head; |
2140 | exclude = exclude->head; |