… | |
… | |
391 | return; |
391 | return; |
392 | |
392 | |
393 | op->carrying += weight; |
393 | op->carrying += weight; |
394 | |
394 | |
395 | if (object *pl = op->visible_to ()) |
395 | if (object *pl = op->visible_to ()) |
|
|
396 | if (pl != op) // player is handled lazily |
396 | esrv_update_item (UPD_WEIGHT, pl, op); |
397 | esrv_update_item (UPD_WEIGHT, pl, op); |
397 | |
398 | |
398 | op = op->env; |
399 | op = op->env; |
399 | } |
400 | } |
400 | } |
401 | } |
401 | |
402 | |
… | |
… | |
422 | if (sum != carrying) |
423 | if (sum != carrying) |
423 | { |
424 | { |
424 | carrying = sum; |
425 | carrying = sum; |
425 | |
426 | |
426 | if (object *pl = visible_to ()) |
427 | if (object *pl = visible_to ()) |
|
|
428 | if (pl != this) // player is handled lazily |
427 | esrv_update_item (UPD_WEIGHT, pl, this); |
429 | esrv_update_item (UPD_WEIGHT, pl, this); |
428 | } |
430 | } |
429 | } |
431 | } |
430 | |
432 | |
431 | /* |
433 | /* |
432 | * Used by: Server DM commands: dumpbelow, dump. Some error messages. |
434 | * Used by: Server DM commands: dumpbelow, dump. Some error messages. |
… | |
… | |
915 | object::destroy_inv (bool drop_to_ground) |
917 | object::destroy_inv (bool drop_to_ground) |
916 | { |
918 | { |
917 | // need to check first, because the checks below might segfault |
919 | // need to check first, because the checks below might segfault |
918 | // as we might be on an invalid mapspace and crossfire code |
920 | // as we might be on an invalid mapspace and crossfire code |
919 | // is too buggy to ensure that the inventory is empty. |
921 | // is too buggy to ensure that the inventory is empty. |
920 | // corollary: if you create arrows etc. with stuff in tis inventory, |
922 | // corollary: if you create arrows etc. with stuff in its inventory, |
921 | // cf will crash below with off-map x and y |
923 | // cf will crash below with off-map x and y |
922 | if (!inv) |
924 | if (!inv) |
923 | return; |
925 | return; |
924 | |
926 | |
925 | /* Only if the space blocks everything do we not process - |
927 | /* Only if the space blocks everything do we not process - |
… | |
… | |
932 | || map->nodrop |
934 | || map->nodrop |
933 | || ms ().move_block == MOVE_ALL) |
935 | || ms ().move_block == MOVE_ALL) |
934 | { |
936 | { |
935 | while (inv) |
937 | while (inv) |
936 | { |
938 | { |
937 | inv->destroy_inv (drop_to_ground); |
939 | inv->destroy_inv (false); |
938 | inv->destroy (); |
940 | inv->destroy (); |
939 | } |
941 | } |
940 | } |
942 | } |
941 | else |
943 | else |
942 | { /* Put objects in inventory onto this space */ |
944 | { /* Put objects in inventory onto this space */ |
… | |
… | |
948 | || op->flag [FLAG_NO_DROP] |
950 | || op->flag [FLAG_NO_DROP] |
949 | || op->type == RUNE |
951 | || op->type == RUNE |
950 | || op->type == TRAP |
952 | || op->type == TRAP |
951 | || op->flag [FLAG_IS_A_TEMPLATE] |
953 | || op->flag [FLAG_IS_A_TEMPLATE] |
952 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
954 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
953 | op->destroy (); |
955 | op->destroy (true); |
954 | else |
956 | else |
955 | map->insert (op, x, y); |
957 | map->insert (op, x, y); |
956 | } |
958 | } |
957 | } |
959 | } |
958 | } |
960 | } |
… | |
… | |
974 | remove_friendly_object (this); |
976 | remove_friendly_object (this); |
975 | |
977 | |
976 | remove (); |
978 | remove (); |
977 | |
979 | |
978 | attachable::do_destroy (); |
980 | attachable::do_destroy (); |
979 | |
|
|
980 | destroy_inv (true); |
|
|
981 | |
981 | |
982 | deactivate (); |
982 | deactivate (); |
983 | unlink (); |
983 | unlink (); |
984 | |
984 | |
985 | flag [FLAG_FREED] = 1; |
985 | flag [FLAG_FREED] = 1; |
… | |
… | |
1026 | object::destroy (bool destroy_inventory) |
1026 | object::destroy (bool destroy_inventory) |
1027 | { |
1027 | { |
1028 | if (destroyed ()) |
1028 | if (destroyed ()) |
1029 | return; |
1029 | return; |
1030 | |
1030 | |
1031 | if (destroy_inventory) |
1031 | destroy_inv (!destroy_inventory); |
1032 | destroy_inv (false); |
|
|
1033 | |
1032 | |
1034 | if (is_head ()) |
1033 | if (is_head ()) |
1035 | if (sound_destroy) |
1034 | if (sound_destroy) |
1036 | play_sound (sound_destroy); |
1035 | play_sound (sound_destroy); |
1037 | else if (flag [FLAG_MONSTER]) |
1036 | else if (flag [FLAG_MONSTER]) |
… | |
… | |
1150 | * removed (most likely destroyed), update the player view |
1149 | * removed (most likely destroyed), update the player view |
1151 | * appropriately. |
1150 | * appropriately. |
1152 | */ |
1151 | */ |
1153 | pl->close_container (); |
1152 | pl->close_container (); |
1154 | |
1153 | |
1155 | pl->contr->ns->floorbox_update (); |
1154 | esrv_del_item (pl, count); |
1156 | } |
1155 | } |
1157 | |
1156 | |
1158 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1157 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1159 | { |
1158 | { |
1160 | /* No point updating the players look faces if he is the object |
1159 | /* No point updating the players look faces if he is the object |
… | |
… | |
1296 | * of areas of callers (eg, anything that uses find_free_spot would now |
1295 | * of areas of callers (eg, anything that uses find_free_spot would now |
1297 | * need extra work |
1296 | * need extra work |
1298 | */ |
1297 | */ |
1299 | if (!xy_normalise (m, op->x, op->y)) |
1298 | if (!xy_normalise (m, op->x, op->y)) |
1300 | { |
1299 | { |
1301 | op->destroy (); |
1300 | op->destroy (1); |
1302 | return 0; |
1301 | return 0; |
1303 | } |
1302 | } |
1304 | |
1303 | |
1305 | if (object *more = op->more) |
1304 | if (object *more = op->more) |
1306 | if (!insert_ob_in_map (more, m, originator, flag)) |
1305 | if (!insert_ob_in_map (more, m, originator, flag)) |
… | |
… | |
1454 | } |
1453 | } |
1455 | |
1454 | |
1456 | op->map->dirty = true; |
1455 | op->map->dirty = true; |
1457 | |
1456 | |
1458 | if (object *pl = ms.player ()) |
1457 | if (object *pl = ms.player ()) |
1459 | pl->contr->ns->floorbox_update (); |
1458 | esrv_send_item (pl, op); |
1460 | |
1459 | |
1461 | /* If this object glows, it may affect lighting conditions that are |
1460 | /* If this object glows, it may affect lighting conditions that are |
1462 | * visible to others on this map. But update_all_los is really |
1461 | * visible to others on this map. But update_all_los is really |
1463 | * an inefficient way to do this, as it means los for all players |
1462 | * an inefficient way to do this, as it means los for all players |
1464 | * on the map will get recalculated. The players could very well |
1463 | * on the map will get recalculated. The players could very well |
… | |
… | |
2565 | &name, |
2564 | &name, |
2566 | title ? "\",title:\"" : "", |
2565 | title ? "\",title:\"" : "", |
2567 | title ? (const char *)title : "", |
2566 | title ? (const char *)title : "", |
2568 | flag_desc (flagdesc, 512), type); |
2567 | flag_desc (flagdesc, 512), type); |
2569 | |
2568 | |
2570 | if (!this->flag[FLAG_REMOVED] && env) |
2569 | if (!flag[FLAG_REMOVED] && env) |
2571 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2570 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2572 | |
2571 | |
2573 | if (map) |
2572 | if (map) |
2574 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2573 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2575 | |
2574 | |
… | |
… | |
2617 | if (object *closer = old_container->inv) |
2616 | if (object *closer = old_container->inv) |
2618 | if (closer->type == CLOSE_CON) |
2617 | if (closer->type == CLOSE_CON) |
2619 | closer->destroy (); |
2618 | closer->destroy (); |
2620 | #endif |
2619 | #endif |
2621 | |
2620 | |
2622 | old_container->flag [FLAG_APPLIED] = 0; |
2621 | old_container->flag [FLAG_APPLIED] = false; |
2623 | container = 0; |
2622 | container = 0; |
2624 | |
2623 | |
2625 | esrv_update_item (UPD_FLAGS, this, old_container); |
2624 | esrv_update_item (UPD_FLAGS, this, old_container); |
2626 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
2625 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
2627 | play_sound (sound_find ("chest_close")); |
2626 | play_sound (sound_find ("chest_close")); |
… | |
… | |
2643 | } |
2642 | } |
2644 | #endif |
2643 | #endif |
2645 | |
2644 | |
2646 | new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); |
2645 | new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); |
2647 | |
2646 | |
2648 | new_container->flag [FLAG_APPLIED] = 1; |
2647 | new_container->flag [FLAG_APPLIED] = true; |
2649 | container = new_container; |
2648 | container = new_container; |
2650 | |
2649 | |
2651 | esrv_update_item (UPD_FLAGS, this, new_container); |
2650 | esrv_update_item (UPD_FLAGS, this, new_container); |
2652 | esrv_send_inventory (this, new_container); |
2651 | esrv_send_inventory (this, new_container); |
2653 | play_sound (sound_find ("chest_open")); |
2652 | play_sound (sound_find ("chest_open")); |