… | |
… | |
334 | |
334 | |
335 | // find player who can see this object |
335 | // find player who can see this object |
336 | object * |
336 | object * |
337 | object::visible_to () const |
337 | object::visible_to () const |
338 | { |
338 | { |
339 | if (!flag [FLAG_REMOVED]) |
339 | if (client_visible () && !flag [FLAG_REMOVED]) |
340 | { |
340 | { |
341 | // see if we are in a container of sorts |
341 | // see if we are in a container of sorts |
342 | if (env) |
342 | if (env) |
343 | { |
343 | { |
344 | // the player inventory itself is always visible |
344 | // the player inventory itself is always visible |
… | |
… | |
358 | else |
358 | else |
359 | { |
359 | { |
360 | // maybe there is a player standing on the same mapspace |
360 | // maybe there is a player standing on the same mapspace |
361 | // this will catch the case where "this" is a player |
361 | // this will catch the case where "this" is a player |
362 | if (object *pl = ms ().player ()) |
362 | if (object *pl = ms ().player ()) |
|
|
363 | if (!pl->container || this == pl->container) |
363 | return pl; |
364 | return pl; |
364 | } |
365 | } |
365 | } |
366 | } |
366 | |
367 | |
367 | return 0; |
368 | return 0; |
368 | } |
369 | } |
… | |
… | |
605 | } |
606 | } |
606 | |
607 | |
607 | object & |
608 | object & |
608 | object::operator =(const object &src) |
609 | object::operator =(const object &src) |
609 | { |
610 | { |
610 | bool is_freed = flag [FLAG_FREED]; |
611 | remove (); |
611 | bool is_removed = flag [FLAG_REMOVED]; |
|
|
612 | |
612 | |
613 | *(object_copy *)this = src; |
613 | *(object_copy *)this = src; |
614 | |
614 | |
615 | flag [FLAG_FREED] = is_freed; |
|
|
616 | flag [FLAG_REMOVED] = is_removed; |
615 | flag [FLAG_REMOVED] = true; |
617 | |
616 | |
618 | /* Copy over key_values, if any. */ |
617 | /* Copy over key_values, if any. */ |
619 | if (src.key_values) |
618 | if (src.key_values) |
620 | { |
619 | { |
621 | key_value *tail = 0; |
620 | key_value *tail = 0; |
… | |
… | |
745 | * UP_OBJ_FACE: only the objects face has changed. |
744 | * UP_OBJ_FACE: only the objects face has changed. |
746 | */ |
745 | */ |
747 | void |
746 | void |
748 | update_object (object *op, int action) |
747 | update_object (object *op, int action) |
749 | { |
748 | { |
750 | if (op == NULL) |
749 | if (!op) |
751 | { |
750 | { |
752 | /* this should never happen */ |
751 | /* this should never happen */ |
753 | LOG (llevDebug, "update_object() called for NULL object.\n"); |
752 | LOG (llevError | logBacktrace, "update_object() called for NULL object.\n"); |
754 | return; |
753 | return; |
755 | } |
754 | } |
756 | |
755 | |
757 | if (op->env) |
756 | if (!op->is_on_map ()) |
758 | { |
757 | { |
759 | /* Animation is currently handled by client, so nothing |
758 | /* Animation is currently handled by client, so nothing |
760 | * to do in this case. |
759 | * to do in this case. |
761 | */ |
760 | */ |
762 | return; |
761 | return; |
763 | } |
762 | } |
764 | |
|
|
765 | /* If the map is saving, don't do anything as everything is |
|
|
766 | * going to get freed anyways. |
|
|
767 | */ |
|
|
768 | if (!op->map || op->map->in_memory == MAP_SAVING) |
|
|
769 | return; |
|
|
770 | |
763 | |
771 | /* make sure the object is within map boundaries */ |
764 | /* make sure the object is within map boundaries */ |
772 | if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height) |
765 | if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height) |
773 | { |
766 | { |
774 | LOG (llevError, "update_object() called for object out of map!\n"); |
767 | LOG (llevError, "update_object() called for object out of map!\n"); |
… | |
… | |
917 | object::destroy_inv (bool drop_to_ground) |
910 | object::destroy_inv (bool drop_to_ground) |
918 | { |
911 | { |
919 | // need to check first, because the checks below might segfault |
912 | // need to check first, because the checks below might segfault |
920 | // as we might be on an invalid mapspace and crossfire code |
913 | // as we might be on an invalid mapspace and crossfire code |
921 | // is too buggy to ensure that the inventory is empty. |
914 | // is too buggy to ensure that the inventory is empty. |
922 | // corollary: if you create arrows etc. with stuff in tis inventory, |
915 | // corollary: if you create arrows etc. with stuff in its inventory, |
923 | // cf will crash below with off-map x and y |
916 | // cf will crash below with off-map x and y |
924 | if (!inv) |
917 | if (!inv) |
925 | return; |
918 | return; |
926 | |
919 | |
927 | /* Only if the space blocks everything do we not process - |
920 | /* Only if the space blocks everything do we not process - |
… | |
… | |
934 | || map->nodrop |
927 | || map->nodrop |
935 | || ms ().move_block == MOVE_ALL) |
928 | || ms ().move_block == MOVE_ALL) |
936 | { |
929 | { |
937 | while (inv) |
930 | while (inv) |
938 | { |
931 | { |
939 | inv->destroy_inv (drop_to_ground); |
932 | inv->destroy_inv (false); |
940 | inv->destroy (); |
933 | inv->destroy (); |
941 | } |
934 | } |
942 | } |
935 | } |
943 | else |
936 | else |
944 | { /* Put objects in inventory onto this space */ |
937 | { /* Put objects in inventory onto this space */ |
… | |
… | |
950 | || op->flag [FLAG_NO_DROP] |
943 | || op->flag [FLAG_NO_DROP] |
951 | || op->type == RUNE |
944 | || op->type == RUNE |
952 | || op->type == TRAP |
945 | || op->type == TRAP |
953 | || op->flag [FLAG_IS_A_TEMPLATE] |
946 | || op->flag [FLAG_IS_A_TEMPLATE] |
954 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
947 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
955 | op->destroy (); |
948 | op->destroy (true); |
956 | else |
949 | else |
957 | map->insert (op, x, y); |
950 | map->insert (op, x, y); |
958 | } |
951 | } |
959 | } |
952 | } |
960 | } |
953 | } |
… | |
… | |
964 | object *op = new object; |
957 | object *op = new object; |
965 | op->link (); |
958 | op->link (); |
966 | return op; |
959 | return op; |
967 | } |
960 | } |
968 | |
961 | |
|
|
962 | static struct freed_map : maptile |
|
|
963 | { |
|
|
964 | freed_map () |
|
|
965 | { |
|
|
966 | path = "<freed objects map>"; |
|
|
967 | name = "/internal/freed_objects_map"; |
|
|
968 | width = 3; |
|
|
969 | height = 3; |
|
|
970 | nodrop = 1; |
|
|
971 | |
|
|
972 | alloc (); |
|
|
973 | in_memory = MAP_ACTIVE; |
|
|
974 | } |
|
|
975 | } freed_map; // freed objects are moved here to avoid crashes |
|
|
976 | |
969 | void |
977 | void |
970 | object::do_destroy () |
978 | object::do_destroy () |
971 | { |
979 | { |
972 | if (flag [FLAG_IS_LINKED]) |
980 | if (flag [FLAG_IS_LINKED]) |
973 | remove_button_link (this); |
981 | remove_button_link (this); |
… | |
… | |
977 | |
985 | |
978 | remove (); |
986 | remove (); |
979 | |
987 | |
980 | attachable::do_destroy (); |
988 | attachable::do_destroy (); |
981 | |
989 | |
982 | destroy_inv (true); |
|
|
983 | |
|
|
984 | deactivate (); |
990 | deactivate (); |
985 | unlink (); |
991 | unlink (); |
986 | |
992 | |
987 | flag [FLAG_FREED] = 1; |
993 | flag [FLAG_FREED] = 1; |
988 | |
994 | |
989 | // hack to ensure that freed objects still have a valid map |
995 | // hack to ensure that freed objects still have a valid map |
990 | { |
|
|
991 | static maptile *freed_map; // freed objects are moved here to avoid crashes |
|
|
992 | |
|
|
993 | if (!freed_map) |
|
|
994 | { |
|
|
995 | freed_map = new maptile; |
|
|
996 | |
|
|
997 | freed_map->path = "<freed objects map>"; |
|
|
998 | freed_map->name = "/internal/freed_objects_map"; |
|
|
999 | freed_map->width = 3; |
|
|
1000 | freed_map->height = 3; |
|
|
1001 | freed_map->nodrop = 1; |
|
|
1002 | |
|
|
1003 | freed_map->alloc (); |
|
|
1004 | freed_map->in_memory = MAP_ACTIVE; |
|
|
1005 | } |
|
|
1006 | |
|
|
1007 | map = freed_map; |
996 | map = &freed_map; |
1008 | x = 1; |
997 | x = 1; |
1009 | y = 1; |
998 | y = 1; |
1010 | } |
|
|
1011 | |
999 | |
1012 | if (more) |
1000 | if (more) |
1013 | { |
1001 | { |
1014 | more->destroy (); |
1002 | more->destroy (); |
1015 | more = 0; |
1003 | more = 0; |
… | |
… | |
1028 | object::destroy (bool destroy_inventory) |
1016 | object::destroy (bool destroy_inventory) |
1029 | { |
1017 | { |
1030 | if (destroyed ()) |
1018 | if (destroyed ()) |
1031 | return; |
1019 | return; |
1032 | |
1020 | |
|
|
1021 | if (!is_head () && !head->destroyed ()) |
|
|
1022 | { |
|
|
1023 | LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); |
|
|
1024 | head->destroy (destroy_inventory); |
|
|
1025 | return; |
|
|
1026 | } |
|
|
1027 | |
1033 | if (destroy_inventory) |
1028 | destroy_inv (!destroy_inventory); |
1034 | destroy_inv (false); |
|
|
1035 | |
1029 | |
1036 | if (is_head ()) |
1030 | if (is_head ()) |
1037 | if (sound_destroy) |
1031 | if (sound_destroy) |
1038 | play_sound (sound_destroy); |
1032 | play_sound (sound_destroy); |
1039 | else if (flag [FLAG_MONSTER]) |
1033 | else if (flag [FLAG_MONSTER]) |
… | |
… | |
1058 | if (flag [FLAG_REMOVED]) |
1052 | if (flag [FLAG_REMOVED]) |
1059 | return; |
1053 | return; |
1060 | |
1054 | |
1061 | INVOKE_OBJECT (REMOVE, this); |
1055 | INVOKE_OBJECT (REMOVE, this); |
1062 | |
1056 | |
1063 | if (object *pl = visible_to ()) |
|
|
1064 | esrv_del_item (pl->contr, count); |
|
|
1065 | |
|
|
1066 | flag [FLAG_REMOVED] = true; |
1057 | flag [FLAG_REMOVED] = true; |
1067 | |
1058 | |
1068 | if (more) |
1059 | if (more) |
1069 | more->remove (); |
1060 | more->remove (); |
1070 | |
1061 | |
… | |
… | |
1072 | * In this case, the object to be removed is in someones |
1063 | * In this case, the object to be removed is in someones |
1073 | * inventory. |
1064 | * inventory. |
1074 | */ |
1065 | */ |
1075 | if (env) |
1066 | if (env) |
1076 | { |
1067 | { |
|
|
1068 | flag [FLAG_REMOVED] = false; // hack around the issue of visible_to checking flag_removed |
|
|
1069 | if (object *pl = visible_to ()) |
|
|
1070 | esrv_del_item (pl->contr, count); |
|
|
1071 | flag [FLAG_REMOVED] = true; // hack around the issue of visible_to checking flag_removed |
|
|
1072 | |
1077 | adjust_weight (env, -total_weight ()); |
1073 | adjust_weight (env, -total_weight ()); |
1078 | |
1074 | |
1079 | *(above ? &above->below : &env->inv) = below; |
1075 | *(above ? &above->below : &env->inv) = below; |
1080 | |
1076 | |
1081 | if (below) |
1077 | if (below) |
… | |
… | |
1099 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1095 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1100 | otmp->update_stats (); |
1096 | otmp->update_stats (); |
1101 | } |
1097 | } |
1102 | else if (map) |
1098 | else if (map) |
1103 | { |
1099 | { |
1104 | if (type == PLAYER) |
|
|
1105 | { |
|
|
1106 | // leaving a spot always closes any open container on the ground |
|
|
1107 | if (container && !container->env) |
|
|
1108 | // this causes spurious floorbox updates, but it ensures |
|
|
1109 | // that the CLOSE event is being sent. |
|
|
1110 | close_container (); |
|
|
1111 | |
|
|
1112 | --map->players; |
|
|
1113 | map->touch (); |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | map->dirty = true; |
1100 | map->dirty = true; |
1117 | mapspace &ms = this->ms (); |
1101 | mapspace &ms = this->ms (); |
|
|
1102 | |
|
|
1103 | if (object *pl = ms.player ()) |
|
|
1104 | { |
|
|
1105 | if (type == PLAYER) // this == pl(!) |
|
|
1106 | { |
|
|
1107 | // leaving a spot always closes any open container on the ground |
|
|
1108 | if (container && !container->env) |
|
|
1109 | // this causes spurious floorbox updates, but it ensures |
|
|
1110 | // that the CLOSE event is being sent. |
|
|
1111 | close_container (); |
|
|
1112 | |
|
|
1113 | --map->players; |
|
|
1114 | map->touch (); |
|
|
1115 | } |
|
|
1116 | else if (pl->container == this) |
|
|
1117 | { |
|
|
1118 | // removing a container should close it |
|
|
1119 | close_container (); |
|
|
1120 | } |
|
|
1121 | |
|
|
1122 | esrv_del_item (pl->contr, count); |
|
|
1123 | } |
1118 | |
1124 | |
1119 | /* link the object above us */ |
1125 | /* link the object above us */ |
1120 | if (above) |
1126 | if (above) |
1121 | above->below = below; |
1127 | above->below = below; |
1122 | else |
1128 | else |
… | |
… | |
1152 | * removed (most likely destroyed), update the player view |
1158 | * removed (most likely destroyed), update the player view |
1153 | * appropriately. |
1159 | * appropriately. |
1154 | */ |
1160 | */ |
1155 | pl->close_container (); |
1161 | pl->close_container (); |
1156 | |
1162 | |
1157 | pl->contr->ns->floorbox_update (); |
1163 | //TODO: the floorbox prev/next might need updating |
|
|
1164 | esrv_del_item (pl->contr, count); |
1158 | } |
1165 | } |
1159 | |
1166 | |
1160 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1167 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1161 | { |
1168 | { |
1162 | /* No point updating the players look faces if he is the object |
1169 | /* No point updating the players look faces if he is the object |
… | |
… | |
1288 | object * |
1295 | object * |
1289 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1296 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1290 | { |
1297 | { |
1291 | assert (!op->flag [FLAG_FREED]); |
1298 | assert (!op->flag [FLAG_FREED]); |
1292 | |
1299 | |
1293 | object *top, *floor = NULL; |
|
|
1294 | |
|
|
1295 | op->remove (); |
1300 | op->remove (); |
1296 | |
1301 | |
1297 | /* Ideally, the caller figures this out. However, it complicates a lot |
1302 | /* 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 |
1303 | * of areas of callers (eg, anything that uses find_free_spot would now |
1299 | * need extra work |
1304 | * need extra work |
1300 | */ |
1305 | */ |
1301 | if (!xy_normalise (m, op->x, op->y)) |
1306 | if (!xy_normalise (m, op->x, op->y)) |
1302 | { |
1307 | { |
1303 | op->destroy (); |
1308 | op->destroy (1); |
1304 | return 0; |
1309 | return 0; |
1305 | } |
1310 | } |
1306 | |
1311 | |
1307 | if (object *more = op->more) |
1312 | if (object *more = op->more) |
1308 | if (!insert_ob_in_map (more, m, originator, flag)) |
1313 | if (!insert_ob_in_map (more, m, originator, flag)) |
… | |
… | |
1317 | */ |
1322 | */ |
1318 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1323 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1319 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1324 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1320 | if (object::can_merge (op, tmp)) |
1325 | if (object::can_merge (op, tmp)) |
1321 | { |
1326 | { |
|
|
1327 | // TODO: we atcually want to update tmp, not op, |
|
|
1328 | // but some caller surely breaks when we return tmp |
|
|
1329 | // from here :/ |
1322 | op->nrof += tmp->nrof; |
1330 | op->nrof += tmp->nrof; |
1323 | tmp->destroy (1); |
1331 | tmp->destroy (1); |
1324 | } |
1332 | } |
1325 | |
1333 | |
1326 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
1334 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
… | |
… | |
1348 | /* since *below* originator, no need to update top */ |
1356 | /* since *below* originator, no need to update top */ |
1349 | originator->below = op; |
1357 | originator->below = op; |
1350 | } |
1358 | } |
1351 | else |
1359 | else |
1352 | { |
1360 | { |
|
|
1361 | object *top, *floor = NULL; |
|
|
1362 | |
1353 | top = ms.bot; |
1363 | top = ms.bot; |
1354 | |
1364 | |
1355 | /* If there are other objects, then */ |
1365 | /* If there are other objects, then */ |
1356 | if (top) |
1366 | if (top) |
1357 | { |
1367 | { |
… | |
… | |
1456 | } |
1466 | } |
1457 | |
1467 | |
1458 | op->map->dirty = true; |
1468 | op->map->dirty = true; |
1459 | |
1469 | |
1460 | if (object *pl = ms.player ()) |
1470 | if (object *pl = ms.player ()) |
1461 | pl->contr->ns->floorbox_update (); |
1471 | //TODO: the floorbox prev/next might need updating |
|
|
1472 | esrv_send_item (pl, op); |
1462 | |
1473 | |
1463 | /* If this object glows, it may affect lighting conditions that are |
1474 | /* If this object glows, it may affect lighting conditions that are |
1464 | * visible to others on this map. But update_all_los is really |
1475 | * 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 |
1476 | * 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 |
1477 | * on the map will get recalculated. The players could very well |
… | |
… | |
2313 | * create clone from object to another |
2324 | * create clone from object to another |
2314 | */ |
2325 | */ |
2315 | object * |
2326 | object * |
2316 | object_create_clone (object *asrc) |
2327 | object_create_clone (object *asrc) |
2317 | { |
2328 | { |
2318 | object *dst = 0, *tmp, *src, *prev, *item; |
2329 | object *dst = 0; |
2319 | |
2330 | |
2320 | if (!asrc) |
2331 | if (!asrc) |
2321 | return 0; |
2332 | return 0; |
2322 | |
2333 | |
2323 | src = asrc->head_ (); |
2334 | object *src = asrc->head_ (); |
2324 | |
2335 | |
2325 | prev = 0; |
2336 | object *prev = 0; |
2326 | for (object *part = src; part; part = part->more) |
2337 | for (object *part = src; part; part = part->more) |
2327 | { |
2338 | { |
2328 | tmp = part->clone (); |
2339 | object *tmp = part->clone (); |
|
|
2340 | |
2329 | tmp->x -= src->x; |
2341 | tmp->x -= src->x; |
2330 | tmp->y -= src->y; |
2342 | tmp->y -= src->y; |
2331 | |
2343 | |
2332 | if (!part->head) |
2344 | if (!part->head) |
2333 | { |
2345 | { |
… | |
… | |
2343 | prev->more = tmp; |
2355 | prev->more = tmp; |
2344 | |
2356 | |
2345 | prev = tmp; |
2357 | prev = tmp; |
2346 | } |
2358 | } |
2347 | |
2359 | |
2348 | for (item = src->inv; item; item = item->below) |
2360 | for (object *item = src->inv; item; item = item->below) |
2349 | insert_ob_in_ob (object_create_clone (item), dst); |
2361 | insert_ob_in_ob (object_create_clone (item), dst); |
2350 | |
2362 | |
2351 | return dst; |
2363 | return dst; |
2352 | } |
2364 | } |
2353 | |
2365 | |
… | |
… | |
2567 | &name, |
2579 | &name, |
2568 | title ? "\",title:\"" : "", |
2580 | title ? "\",title:\"" : "", |
2569 | title ? (const char *)title : "", |
2581 | title ? (const char *)title : "", |
2570 | flag_desc (flagdesc, 512), type); |
2582 | flag_desc (flagdesc, 512), type); |
2571 | |
2583 | |
2572 | if (!this->flag[FLAG_REMOVED] && env) |
2584 | if (!flag[FLAG_REMOVED] && env) |
2573 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2585 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2574 | |
2586 | |
2575 | if (map) |
2587 | if (map) |
2576 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2588 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2577 | |
2589 | |
… | |
… | |
2607 | object::open_container (object *new_container) |
2619 | object::open_container (object *new_container) |
2608 | { |
2620 | { |
2609 | if (container == new_container) |
2621 | if (container == new_container) |
2610 | return; |
2622 | return; |
2611 | |
2623 | |
2612 | if (object *old_container = container) |
2624 | object *old_container = container; |
|
|
2625 | |
|
|
2626 | if (old_container) |
2613 | { |
2627 | { |
2614 | if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) |
2628 | if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) |
2615 | return; |
2629 | return; |
2616 | |
2630 | |
2617 | #if 0 |
2631 | #if 0 |
… | |
… | |
2619 | if (object *closer = old_container->inv) |
2633 | if (object *closer = old_container->inv) |
2620 | if (closer->type == CLOSE_CON) |
2634 | if (closer->type == CLOSE_CON) |
2621 | closer->destroy (); |
2635 | closer->destroy (); |
2622 | #endif |
2636 | #endif |
2623 | |
2637 | |
|
|
2638 | // make sure the container is available |
|
|
2639 | esrv_send_item (this, old_container); |
|
|
2640 | |
2624 | old_container->flag [FLAG_APPLIED] = 0; |
2641 | old_container->flag [FLAG_APPLIED] = false; |
2625 | container = 0; |
2642 | container = 0; |
2626 | |
2643 | |
|
|
2644 | // client needs item update to make it work, client bug requires this to be separate |
2627 | esrv_update_item (UPD_FLAGS, this, old_container); |
2645 | esrv_update_item (UPD_FLAGS, this, old_container); |
|
|
2646 | |
2628 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
2647 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
2629 | play_sound (sound_find ("chest_close")); |
2648 | play_sound (sound_find ("chest_close")); |
2630 | } |
2649 | } |
2631 | |
2650 | |
2632 | if (new_container) |
2651 | if (new_container) |
… | |
… | |
2645 | } |
2664 | } |
2646 | #endif |
2665 | #endif |
2647 | |
2666 | |
2648 | new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); |
2667 | new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); |
2649 | |
2668 | |
|
|
2669 | // make sure the container is available, client bug requires this to be separate |
|
|
2670 | esrv_send_item (this, new_container); |
|
|
2671 | |
2650 | new_container->flag [FLAG_APPLIED] = 1; |
2672 | new_container->flag [FLAG_APPLIED] = true; |
2651 | container = new_container; |
2673 | container = new_container; |
2652 | |
2674 | |
|
|
2675 | // client needs flag change |
2653 | esrv_update_item (UPD_FLAGS, this, new_container); |
2676 | esrv_update_item (UPD_FLAGS, this, new_container); |
2654 | esrv_send_inventory (this, new_container); |
2677 | esrv_send_inventory (this, new_container); |
2655 | play_sound (sound_find ("chest_open")); |
2678 | play_sound (sound_find ("chest_open")); |
2656 | } |
2679 | } |
|
|
2680 | // else if (!old_container->env && contr && contr->ns) |
|
|
2681 | // contr->ns->floorbox_reset (); |
2657 | } |
2682 | } |
2658 | |
2683 | |
2659 | object * |
2684 | object * |
2660 | object::force_find (const shstr name) |
2685 | object::force_find (const shstr name) |
2661 | { |
2686 | { |