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.215 by root, Tue Apr 22 07:28:05 2008 UTC vs.
Revision 1.219 by root, Wed Apr 23 21:09:10 2008 UTC

917object::destroy_inv (bool drop_to_ground) 917object::destroy_inv (bool drop_to_ground)
918{ 918{
919 // need to check first, because the checks below might segfault 919 // need to check first, because the checks below might segfault
920 // as we might be on an invalid mapspace and crossfire code 920 // as we might be on an invalid mapspace and crossfire code
921 // is too buggy to ensure that the inventory is empty. 921 // is too buggy to ensure that the inventory is empty.
922 // corollary: if you create arrows etc. with stuff in tis inventory, 922 // corollary: if you create arrows etc. with stuff in its inventory,
923 // cf will crash below with off-map x and y 923 // cf will crash below with off-map x and y
924 if (!inv) 924 if (!inv)
925 return; 925 return;
926 926
927 /* Only if the space blocks everything do we not process - 927 /* Only if the space blocks everything do we not process -
934 || map->nodrop 934 || map->nodrop
935 || ms ().move_block == MOVE_ALL) 935 || ms ().move_block == MOVE_ALL)
936 { 936 {
937 while (inv) 937 while (inv)
938 { 938 {
939 inv->destroy_inv (drop_to_ground); 939 inv->destroy_inv (false);
940 inv->destroy (); 940 inv->destroy ();
941 } 941 }
942 } 942 }
943 else 943 else
944 { /* Put objects in inventory onto this space */ 944 { /* Put objects in inventory onto this space */
950 || op->flag [FLAG_NO_DROP] 950 || op->flag [FLAG_NO_DROP]
951 || op->type == RUNE 951 || op->type == RUNE
952 || op->type == TRAP 952 || op->type == TRAP
953 || op->flag [FLAG_IS_A_TEMPLATE] 953 || op->flag [FLAG_IS_A_TEMPLATE]
954 || op->flag [FLAG_DESTROY_ON_DEATH]) 954 || op->flag [FLAG_DESTROY_ON_DEATH])
955 op->destroy (); 955 op->destroy (true);
956 else 956 else
957 map->insert (op, x, y); 957 map->insert (op, x, y);
958 } 958 }
959 } 959 }
960} 960}
976 remove_friendly_object (this); 976 remove_friendly_object (this);
977 977
978 remove (); 978 remove ();
979 979
980 attachable::do_destroy (); 980 attachable::do_destroy ();
981
982 destroy_inv (true);
983 981
984 deactivate (); 982 deactivate ();
985 unlink (); 983 unlink ();
986 984
987 flag [FLAG_FREED] = 1; 985 flag [FLAG_FREED] = 1;
1028object::destroy (bool destroy_inventory) 1026object::destroy (bool destroy_inventory)
1029{ 1027{
1030 if (destroyed ()) 1028 if (destroyed ())
1031 return; 1029 return;
1032 1030
1031 if (!is_head () && !head->destroyed ())
1032 {
1033 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1034 head->destroy (destroy_inventory);
1035 }
1036
1033 if (destroy_inventory) 1037 destroy_inv (!destroy_inventory);
1034 destroy_inv (false);
1035 1038
1036 if (is_head ()) 1039 if (is_head ())
1037 if (sound_destroy) 1040 if (sound_destroy)
1038 play_sound (sound_destroy); 1041 play_sound (sound_destroy);
1039 else if (flag [FLAG_MONSTER]) 1042 else if (flag [FLAG_MONSTER])
1152 * removed (most likely destroyed), update the player view 1155 * removed (most likely destroyed), update the player view
1153 * appropriately. 1156 * appropriately.
1154 */ 1157 */
1155 pl->close_container (); 1158 pl->close_container ();
1156 1159
1157 pl->contr->ns->floorbox_update (); 1160 //TODO: the floorbox prev/next might need updating
1161 esrv_del_item (pl->contr, count);
1158 } 1162 }
1159 1163
1160 for (tmp = ms.bot; tmp; tmp = tmp->above) 1164 for (tmp = ms.bot; tmp; tmp = tmp->above)
1161 { 1165 {
1162 /* No point updating the players look faces if he is the object 1166 /* No point updating the players look faces if he is the object
1288object * 1292object *
1289insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1293insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1290{ 1294{
1291 assert (!op->flag [FLAG_FREED]); 1295 assert (!op->flag [FLAG_FREED]);
1292 1296
1293 object *top, *floor = NULL;
1294
1295 op->remove (); 1297 op->remove ();
1296 1298
1297 /* Ideally, the caller figures this out. However, it complicates a lot 1299 /* Ideally, the caller figures this out. However, it complicates a lot
1298 * of areas of callers (eg, anything that uses find_free_spot would now 1300 * of areas of callers (eg, anything that uses find_free_spot would now
1299 * need extra work 1301 * need extra work
1300 */ 1302 */
1301 if (!xy_normalise (m, op->x, op->y)) 1303 if (!xy_normalise (m, op->x, op->y))
1302 { 1304 {
1303 op->destroy (); 1305 op->destroy (1);
1304 return 0; 1306 return 0;
1305 } 1307 }
1306 1308
1307 if (object *more = op->more) 1309 if (object *more = op->more)
1308 if (!insert_ob_in_map (more, m, originator, flag)) 1310 if (!insert_ob_in_map (more, m, originator, flag))
1317 */ 1319 */
1318 if (op->nrof && !(flag & INS_NO_MERGE)) 1320 if (op->nrof && !(flag & INS_NO_MERGE))
1319 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 1321 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
1320 if (object::can_merge (op, tmp)) 1322 if (object::can_merge (op, tmp))
1321 { 1323 {
1324 // TODO: we atcually want to update tmp, not op,
1325 // but some caller surely breaks when we return tmp
1326 // from here :/
1322 op->nrof += tmp->nrof; 1327 op->nrof += tmp->nrof;
1323 tmp->destroy (1); 1328 tmp->destroy (1);
1324 } 1329 }
1325 1330
1326 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1331 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1348 /* since *below* originator, no need to update top */ 1353 /* since *below* originator, no need to update top */
1349 originator->below = op; 1354 originator->below = op;
1350 } 1355 }
1351 else 1356 else
1352 { 1357 {
1358 object *top, *floor = NULL;
1359
1353 top = ms.bot; 1360 top = ms.bot;
1354 1361
1355 /* If there are other objects, then */ 1362 /* If there are other objects, then */
1356 if (top) 1363 if (top)
1357 { 1364 {
1456 } 1463 }
1457 1464
1458 op->map->dirty = true; 1465 op->map->dirty = true;
1459 1466
1460 if (object *pl = ms.player ()) 1467 if (object *pl = ms.player ())
1461 pl->contr->ns->floorbox_update (); 1468 //TODO: the floorbox prev/next might need updating
1469 esrv_send_item (pl, op);
1462 1470
1463 /* If this object glows, it may affect lighting conditions that are 1471 /* If this object glows, it may affect lighting conditions that are
1464 * visible to others on this map. But update_all_los is really 1472 * visible to others on this map. But update_all_los is really
1465 * an inefficient way to do this, as it means los for all players 1473 * an inefficient way to do this, as it means los for all players
1466 * on the map will get recalculated. The players could very well 1474 * on the map will get recalculated. The players could very well
2567 &name, 2575 &name,
2568 title ? "\",title:\"" : "", 2576 title ? "\",title:\"" : "",
2569 title ? (const char *)title : "", 2577 title ? (const char *)title : "",
2570 flag_desc (flagdesc, 512), type); 2578 flag_desc (flagdesc, 512), type);
2571 2579
2572 if (!this->flag[FLAG_REMOVED] && env) 2580 if (!flag[FLAG_REMOVED] && env)
2573 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); 2581 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2574 2582
2575 if (map) 2583 if (map)
2576 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); 2584 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y);
2577 2585
2619 if (object *closer = old_container->inv) 2627 if (object *closer = old_container->inv)
2620 if (closer->type == CLOSE_CON) 2628 if (closer->type == CLOSE_CON)
2621 closer->destroy (); 2629 closer->destroy ();
2622#endif 2630#endif
2623 2631
2624 old_container->flag [FLAG_APPLIED] = 0; 2632 old_container->flag [FLAG_APPLIED] = false;
2625 container = 0; 2633 container = 0;
2626 2634
2627 esrv_update_item (UPD_FLAGS, this, old_container); 2635 esrv_update_item (UPD_FLAGS, this, old_container);
2628 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); 2636 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container));
2629 play_sound (sound_find ("chest_close")); 2637 play_sound (sound_find ("chest_close"));
2645 } 2653 }
2646#endif 2654#endif
2647 2655
2648 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); 2656 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container));
2649 2657
2650 new_container->flag [FLAG_APPLIED] = 1; 2658 new_container->flag [FLAG_APPLIED] = true;
2651 container = new_container; 2659 container = new_container;
2652 2660
2653 esrv_update_item (UPD_FLAGS, this, new_container); 2661 esrv_update_item (UPD_FLAGS, this, new_container);
2654 esrv_send_inventory (this, new_container); 2662 esrv_send_inventory (this, new_container);
2655 play_sound (sound_find ("chest_open")); 2663 play_sound (sound_find ("chest_open"));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines