ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.48 by root, Thu Sep 14 23:13:48 2006 UTC vs.
Revision 1.52 by root, Wed Sep 27 00:36:08 2006 UTC

911 mortals.erase (i); 911 mortals.erase (i);
912 } 912 }
913 913
914 static int lastmortals = 0;//D 914 static int lastmortals = 0;//D
915 915
916 if (mortals.size() != lastmortals)//D 916 if (mortals.size() != lastmortals && lastmortals > 100)//D
917 { 917 {
918 lastmortals = mortals.size ();//D 918 lastmortals = mortals.size ();//D
919 LOG (llevDebug, "%d objects in mortal queue\n", lastmortals);//D 919 LOG (llevDebug, "%d objects in mortal queue\n", lastmortals);//D
920 } 920 }
921} 921}
972 * it from the list of used objects, and puts it on the list of 972 * it from the list of used objects, and puts it on the list of
973 * free objects. The IS_FREED() flag is set in the object. 973 * free objects. The IS_FREED() flag is set in the object.
974 * The object must have been removed by remove_ob() first for 974 * The object must have been removed by remove_ob() first for
975 * this function to succeed. 975 * this function to succeed.
976 * 976 *
977 * If free_inventory is set, free inventory as well. Else drop items in 977 * If destroy_inventory is set, free inventory as well. Else drop items in
978 * inventory to the ground. 978 * inventory to the ground.
979 */ 979 */
980void object::free (bool free_inventory) 980void object::destroy (bool destroy_inventory)
981{ 981{
982 if (QUERY_FLAG (this, FLAG_FREED)) 982 if (QUERY_FLAG (this, FLAG_FREED))
983 return; 983 return;
984 984
985 if (QUERY_FLAG (this, FLAG_FRIENDLY)) 985 if (QUERY_FLAG (this, FLAG_FRIENDLY))
990 990
991 SET_FLAG (this, FLAG_FREED); 991 SET_FLAG (this, FLAG_FREED);
992 992
993 if (more) 993 if (more)
994 { 994 {
995 more->free (free_inventory); 995 more->destroy (destroy_inventory);
996 more = 0; 996 more = 0;
997 } 997 }
998 998
999 if (inv) 999 if (inv)
1000 { 1000 {
1001 /* Only if the space blocks everything do we not process - 1001 /* Only if the space blocks everything do we not process -
1002 * if some form of movement is allowed, let objects 1002 * if some form of movement is allowed, let objects
1003 * drop on that space. 1003 * drop on that space.
1004 */ 1004 */
1005 if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) 1005 if (destroy_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)
1006 { 1006 {
1007 object *op = inv; 1007 object *op = inv;
1008 1008
1009 while (op) 1009 while (op)
1010 { 1010 {
1011 object *tmp = op->below; 1011 object *tmp = op->below;
1012 op->free (free_inventory); 1012 op->destroy (destroy_inventory);
1013 op = tmp; 1013 op = tmp;
1014 } 1014 }
1015 } 1015 }
1016 else 1016 else
1017 { /* Put objects in inventory onto this space */ 1017 { /* Put objects in inventory onto this space */
1041 // clear those pointers that likely might have circular references to us 1041 // clear those pointers that likely might have circular references to us
1042 owner = 0; 1042 owner = 0;
1043 enemy = 0; 1043 enemy = 0;
1044 attacked_by = 0; 1044 attacked_by = 0;
1045 1045
1046 // only relevant for players(?), but make sure of it anyways
1047 contr = 0;
1048
1046 /* Remove object from the active list */ 1049 /* Remove object from the active list */
1047 speed = 0; 1050 speed = 0;
1048 update_ob_speed (this); 1051 update_ob_speed (this);
1049 1052
1050 unlink (); 1053 unlink ();
1084{ 1087{
1085 object *tmp, *last = 0; 1088 object *tmp, *last = 0;
1086 object *otmp; 1089 object *otmp;
1087 1090
1088 int check_walk_off; 1091 int check_walk_off;
1089 mapstruct *m; 1092 maptile *m;
1090 1093
1091 sint16 x, y; 1094 sint16 x, y;
1092 1095
1093 if (QUERY_FLAG (op, FLAG_REMOVED)) 1096 if (QUERY_FLAG (op, FLAG_REMOVED))
1094 return; 1097 return;
1213 1216
1214 tmp->contr->socket.update_look = 1; 1217 tmp->contr->socket.update_look = 1;
1215 } 1218 }
1216 1219
1217 /* See if player moving off should effect something */ 1220 /* See if player moving off should effect something */
1218 if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) 1221 if (check_walk_off
1222 && ((op->move_type & tmp->move_off)
1223 && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0))
1219 { 1224 {
1220 move_apply (tmp, op, NULL); 1225 move_apply (tmp, op, NULL);
1221 1226
1222 if (op->destroyed ()); 1227 if (op->destroyed ())
1223 LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); 1228 LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ());
1224 } 1229 }
1225 1230
1226 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ 1231 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */
1227 1232
1228 if (tmp->above == tmp) 1233 if (tmp->above == tmp)
1289/* 1294/*
1290 * same as insert_ob_in_map except it handle separate coordinates and do a clean 1295 * same as insert_ob_in_map except it handle separate coordinates and do a clean
1291 * job preparing multi-part monsters 1296 * job preparing multi-part monsters
1292 */ 1297 */
1293object * 1298object *
1294insert_ob_in_map_at (object *op, mapstruct *m, object *originator, int flag, int x, int y) 1299insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y)
1295{ 1300{
1296 object *tmp; 1301 object *tmp;
1297 1302
1298 if (op->head) 1303 if (op->head)
1299 op = op->head; 1304 op = op->head;
1327 * NULL if 'op' was destroyed 1332 * NULL if 'op' was destroyed
1328 * just 'op' otherwise 1333 * just 'op' otherwise
1329 */ 1334 */
1330 1335
1331object * 1336object *
1332insert_ob_in_map (object *op, mapstruct *m, object *originator, int flag) 1337insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1333{ 1338{
1334 object *tmp, *top, *floor = NULL; 1339 object *tmp, *top, *floor = NULL;
1335 sint16 x, y; 1340 sint16 x, y;
1336 1341
1337 if (QUERY_FLAG (op, FLAG_FREED)) 1342 if (QUERY_FLAG (op, FLAG_FREED))
1928 1933
1929int 1934int
1930check_move_on (object *op, object *originator) 1935check_move_on (object *op, object *originator)
1931{ 1936{
1932 object *tmp; 1937 object *tmp;
1933 mapstruct *m = op->map; 1938 maptile *m = op->map;
1934 int x = op->x, y = op->y; 1939 int x = op->x, y = op->y;
1935 1940
1936 MoveType move_on, move_slow, move_block; 1941 MoveType move_on, move_slow, move_block;
1937 1942
1938 if (QUERY_FLAG (op, FLAG_NO_APPLY)) 1943 if (QUERY_FLAG (op, FLAG_NO_APPLY))
2027 * a matching archetype at the given map and coordinates. 2032 * a matching archetype at the given map and coordinates.
2028 * The first matching object is returned, or NULL if none. 2033 * The first matching object is returned, or NULL if none.
2029 */ 2034 */
2030 2035
2031object * 2036object *
2032present_arch (const archetype *at, mapstruct *m, int x, int y) 2037present_arch (const archetype *at, maptile *m, int x, int y)
2033{ 2038{
2034 object * 2039 object *
2035 tmp; 2040 tmp;
2036 2041
2037 if (m == NULL || out_of_map (m, x, y)) 2042 if (m == NULL || out_of_map (m, x, y))
2050 * a matching type variable at the given map and coordinates. 2055 * a matching type variable at the given map and coordinates.
2051 * The first matching object is returned, or NULL if none. 2056 * The first matching object is returned, or NULL if none.
2052 */ 2057 */
2053 2058
2054object * 2059object *
2055present (unsigned char type, mapstruct *m, int x, int y) 2060present (unsigned char type, maptile *m, int x, int y)
2056{ 2061{
2057 object * 2062 object *
2058 tmp; 2063 tmp;
2059 2064
2060 if (out_of_map (m, x, y)) 2065 if (out_of_map (m, x, y))
2200 * the archetype because that isn't correct if the monster has been 2205 * the archetype because that isn't correct if the monster has been
2201 * customized, changed states, etc. 2206 * customized, changed states, etc.
2202 */ 2207 */
2203 2208
2204int 2209int
2205find_free_spot (const object *ob, mapstruct *m, int x, int y, int start, int stop) 2210find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)
2206{ 2211{
2207 int 2212 int
2208 i, 2213 i,
2209 index = 0, flag; 2214 index = 0, flag;
2210 static int 2215 static int
2231 return -1; 2236 return -1;
2232 return altern[RANDOM () % index]; 2237 return altern[RANDOM () % index];
2233} 2238}
2234 2239
2235/* 2240/*
2236 * find_first_free_spot(archetype, mapstruct, x, y) works like 2241 * find_first_free_spot(archetype, maptile, x, y) works like
2237 * find_free_spot(), but it will search max number of squares. 2242 * find_free_spot(), but it will search max number of squares.
2238 * But it will return the first available spot, not a random choice. 2243 * But it will return the first available spot, not a random choice.
2239 * Changed 0.93.2: Have it return -1 if there is no free spot available. 2244 * Changed 0.93.2: Have it return -1 if there is no free spot available.
2240 */ 2245 */
2241 2246
2242int 2247int
2243find_first_free_spot (const object *ob, mapstruct *m, int x, int y) 2248find_first_free_spot (const object *ob, maptile *m, int x, int y)
2244{ 2249{
2245 int 2250 int
2246 i; 2251 i;
2247 2252
2248 for (i = 0; i < SIZEOFFREE; i++) 2253 for (i = 0; i < SIZEOFFREE; i++)
2312 * because we have to know what movement the thing looking to move 2317 * because we have to know what movement the thing looking to move
2313 * there is capable of. 2318 * there is capable of.
2314 */ 2319 */
2315 2320
2316int 2321int
2317find_dir (mapstruct *m, int x, int y, object *exclude) 2322find_dir (maptile *m, int x, int y, object *exclude)
2318{ 2323{
2319 int 2324 int
2320 i, 2325 i,
2321 max = SIZEOFFREE, mflags; 2326 max = SIZEOFFREE, mflags;
2322 2327
2323 sint16 nx, ny; 2328 sint16 nx, ny;
2324 object * 2329 object *
2325 tmp; 2330 tmp;
2326 mapstruct * 2331 maptile *
2327 mp; 2332 mp;
2328 2333
2329 MoveType blocked, move_type; 2334 MoveType blocked, move_type;
2330 2335
2331 if (exclude && exclude->head) 2336 if (exclude && exclude->head)
2539 * Modified to be map tile aware -.MSW 2544 * Modified to be map tile aware -.MSW
2540 */ 2545 */
2541 2546
2542 2547
2543int 2548int
2544can_see_monsterP (mapstruct *m, int x, int y, int dir) 2549can_see_monsterP (maptile *m, int x, int y, int dir)
2545{ 2550{
2546 sint16 dx, dy; 2551 sint16 dx, dy;
2547 int 2552 int
2548 mflags; 2553 mflags;
2549 2554

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines