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.258 by root, Mon Sep 29 09:04:50 2008 UTC vs.
Revision 1.264 by root, Sun Dec 21 23:29:27 2008 UTC

909 || map->in_memory != MAP_ACTIVE 909 || map->in_memory != MAP_ACTIVE
910 || map->no_drop 910 || map->no_drop
911 || ms ().move_block == MOVE_ALL) 911 || ms ().move_block == MOVE_ALL)
912 { 912 {
913 while (inv) 913 while (inv)
914 inv->destroy (true); 914 inv->destroy ();
915 } 915 }
916 else 916 else
917 { /* Put objects in inventory onto this space */ 917 { /* Put objects in inventory onto this space */
918 while (inv) 918 while (inv)
919 { 919 {
923 || op->flag [FLAG_NO_DROP] 923 || op->flag [FLAG_NO_DROP]
924 || op->type == RUNE 924 || op->type == RUNE
925 || op->type == TRAP 925 || op->type == TRAP
926 || op->flag [FLAG_IS_A_TEMPLATE] 926 || op->flag [FLAG_IS_A_TEMPLATE]
927 || op->flag [FLAG_DESTROY_ON_DEATH]) 927 || op->flag [FLAG_DESTROY_ON_DEATH])
928 op->destroy (true); 928 op->destroy ();
929 else 929 else
930 map->insert (op, x, y); 930 map->insert (op, x, y);
931 } 931 }
932 } 932 }
933} 933}
983 x = 1; 983 x = 1;
984 y = 1; 984 y = 1;
985 985
986 if (more) 986 if (more)
987 { 987 {
988 more->destroy (true); 988 more->destroy ();
989 more = 0; 989 more = 0;
990 } 990 }
991 991
992 head = 0; 992 head = 0;
993 993
997 attacked_by = 0; 997 attacked_by = 0;
998 current_weapon = 0; 998 current_weapon = 0;
999} 999}
1000 1000
1001void 1001void
1002object::destroy (bool destroy_inventory) 1002object::destroy ()
1003{ 1003{
1004 if (destroyed ()) 1004 if (destroyed ())
1005 return; 1005 return;
1006 1006
1007 if (!is_head () && !head->destroyed ()) 1007 if (!is_head () && !head->destroyed ())
1008 { 1008 {
1009 LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); 1009 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1010 head->destroy (destroy_inventory); 1010 head->destroy ();
1011 return; 1011 return;
1012 } 1012 }
1013 1013
1014 destroy_inv (!destroy_inventory); 1014 destroy_inv (false);
1015 1015
1016 if (is_head ()) 1016 if (is_head ())
1017 if (sound_destroy) 1017 if (sound_destroy)
1018 play_sound (sound_destroy); 1018 play_sound (sound_destroy);
1019 else if (flag [FLAG_MONSTER]) 1019 else if (flag [FLAG_MONSTER])
1157 } 1157 }
1158 1158
1159 last = tmp; 1159 last = tmp;
1160 } 1160 }
1161 1161
1162 if (flag [FLAG_BLOCKSVIEW] || glow_radius) 1162 if (map->darkness && (glow_radius || flag [FLAG_BLOCKSVIEW]))
1163 update_all_los (map, x, y); 1163 update_all_los (map, x, y);
1164 } 1164 }
1165} 1165}
1166 1166
1167/* 1167/*
1191 esrv_update_item (UPD_NROF, pl, top); 1191 esrv_update_item (UPD_NROF, pl, top);
1192 1192
1193 op->weight = 0; // cancel the addition above 1193 op->weight = 0; // cancel the addition above
1194 op->carrying = 0; // must be 0 already 1194 op->carrying = 0; // must be 0 already
1195 1195
1196 op->destroy (true); 1196 op->destroy ();
1197 1197
1198 return top; 1198 return top;
1199 } 1199 }
1200 1200
1201 return 0; 1201 return 0;
1263 * just 'op' otherwise 1263 * just 'op' otherwise
1264 */ 1264 */
1265object * 1265object *
1266insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1266insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1267{ 1267{
1268 if (op->is_on_map ())
1269 {
1270 LOG (llevError, "insert_ob_in_map called for object already on map");
1271 abort ();
1272 }
1273
1274 if (op->env)
1275 {
1276 LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)");
1277 op->remove (); 1268 op->remove ();
1278 }
1279 1269
1280 if (m == &freed_map)//D TODO: remove soon 1270 if (m == &freed_map)//D TODO: remove soon
1281 {//D 1271 {//D
1282 LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D 1272 LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D
1283 }//D 1273 }//D
1286 * of areas of callers (eg, anything that uses find_free_spot would now 1276 * of areas of callers (eg, anything that uses find_free_spot would now
1287 * need extra work 1277 * need extra work
1288 */ 1278 */
1289 if (!xy_normalise (m, op->x, op->y)) 1279 if (!xy_normalise (m, op->x, op->y))
1290 { 1280 {
1291 op->head_ ()->destroy (true);// remove head_ once all tail object destroyers found 1281 op->head_ ()->destroy ();// remove head_ once all tail object destroyers found
1292 return 0; 1282 return 0;
1293 } 1283 }
1294 1284
1295 if (object *more = op->more) 1285 if (object *more = op->more)
1296 if (!insert_ob_in_map (more, m, originator, flag)) 1286 if (!insert_ob_in_map (more, m, originator, flag))
1309 { 1299 {
1310 // TODO: we actually want to update tmp, not op, 1300 // TODO: we actually want to update tmp, not op,
1311 // but some caller surely breaks when we return tmp 1301 // but some caller surely breaks when we return tmp
1312 // from here :/ 1302 // from here :/
1313 op->nrof += tmp->nrof; 1303 op->nrof += tmp->nrof;
1314 tmp->destroy (true); 1304 tmp->destroy ();
1315 } 1305 }
1316 1306
1317 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1307 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1318 CLEAR_FLAG (op, FLAG_INV_LOCKED); 1308 CLEAR_FLAG (op, FLAG_INV_LOCKED);
1319 1309
1449 * be far away from this change and not affected in any way - 1439 * be far away from this change and not affected in any way -
1450 * this should get redone to only look for players within range, 1440 * this should get redone to only look for players within range,
1451 * or just updating the P_UPTODATE for spaces within this area 1441 * or just updating the P_UPTODATE for spaces within this area
1452 * of effect may be sufficient. 1442 * of effect may be sufficient.
1453 */ 1443 */
1454 if (op->map->darkness && (op->glow_radius != 0)) 1444 if (op->map->darkness && (op->glow_radius || op->flag [FLAG_BLOCKSVIEW]))
1455 update_all_los (op->map, op->x, op->y); 1445 update_all_los (op->map, op->x, op->y);
1456 1446
1457 /* updates flags (blocked, alive, no magic, etc) for this map space */ 1447 /* updates flags (blocked, alive, no magic, etc) for this map space */
1458 update_object (op, UP_OBJ_INSERT); 1448 update_object (op, UP_OBJ_INSERT);
1459 1449
1494{ 1484{
1495 /* first search for itself and remove any old instances */ 1485 /* first search for itself and remove any old instances */
1496 1486
1497 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above) 1487 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above)
1498 if (!strcmp (tmp->arch->archname, arch_string)) /* same archetype */ 1488 if (!strcmp (tmp->arch->archname, arch_string)) /* same archetype */
1499 tmp->destroy (true); 1489 tmp->destroy ();
1500 1490
1501 object *tmp = arch_to_object (archetype::find (arch_string)); 1491 object *tmp = arch_to_object (archetype::find (arch_string));
1502 1492
1503 tmp->x = op->x; 1493 tmp->x = op->x;
1504 tmp->y = op->y; 1494 tmp->y = op->y;
1627 if (object *pl = tmp->visible_to ()) 1617 if (object *pl = tmp->visible_to ())
1628 esrv_update_item (UPD_NROF, pl, tmp); 1618 esrv_update_item (UPD_NROF, pl, tmp);
1629 1619
1630 adjust_weight (this, op->total_weight ()); 1620 adjust_weight (this, op->total_weight ());
1631 1621
1632 op->destroy (true); 1622 op->destroy ();
1633 op = tmp; 1623 op = tmp;
1634 goto inserted; 1624 goto inserted;
1635 } 1625 }
1636 1626
1637 op->owner = 0; // it's his/hers now. period. 1627 op->owner = 0; // it's his/hers now. period.
1971 * head of the object should correspond for the entire object. 1961 * head of the object should correspond for the entire object.
1972 */ 1962 */
1973 if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) 1963 if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block))
1974 continue; 1964 continue;
1975 1965
1976 if (ob->blocked (m, pos.x, pos.y)) 1966 if (ob->blocked (pos.m, pos.x, pos.y))
1977 continue; 1967 continue;
1978 1968
1979 altern [index++] = i; 1969 altern [index++] = i;
1980 } 1970 }
1981 1971
2486 2476
2487#if 0 2477#if 0
2488 // remove the "Close old_container" object. 2478 // remove the "Close old_container" object.
2489 if (object *closer = old_container->inv) 2479 if (object *closer = old_container->inv)
2490 if (closer->type == CLOSE_CON) 2480 if (closer->type == CLOSE_CON)
2491 closer->destroy (true); 2481 closer->destroy ();
2492#endif 2482#endif
2493 2483
2494 // make sure the container is available 2484 // make sure the container is available
2495 esrv_send_item (this, old_container); 2485 esrv_send_item (this, old_container);
2496 2486
2552 2542
2553void 2543void
2554object::force_add (const shstr name, int duration) 2544object::force_add (const shstr name, int duration)
2555{ 2545{
2556 if (object *force = force_find (name)) 2546 if (object *force = force_find (name))
2557 force->destroy (true); 2547 force->destroy ();
2558 2548
2559 object *force = get_archetype (FORCE_NAME); 2549 object *force = get_archetype (FORCE_NAME);
2560 2550
2561 force->slaying = name; 2551 force->slaying = name;
2562 force->stats.food = 1; 2552 force->stats.food = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines