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