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.213 by root, Tue Apr 22 01:18:10 2008 UTC vs.
Revision 1.224 by root, Fri May 2 20:16:24 2008 UTC

330 330
331 /* Everything passes, must be OK. */ 331 /* Everything passes, must be OK. */
332 return 1; 332 return 1;
333} 333}
334 334
335// find player who can see this object
336object *
337object::visible_to () const
338{
339 if (client_visible () && !flag [FLAG_REMOVED])
340 {
341 // see if we are in a container of sorts
342 if (env)
343 {
344 // the player inventory itself is always visible
345 if (env->type == PLAYER)
346 return env;
347
348 // else a player could have our env open
349 object *envest = env->outer_env ();
350
351 // the player itself is always on a map, so we will find him here
352 // even if our inv is in a player.
353 if (envest->is_on_map ())
354 if (object *pl = envest->ms ().player ())
355 if (pl->container == env)
356 return pl;
357 }
358 else
359 {
360 // maybe there is a player standing on the same mapspace
361 // this will catch the case where "this" is a player
362 if (object *pl = ms ().player ())
363 if (!pl->container || this == pl->container)
364 return pl;
365 }
366 }
367
368 return 0;
369}
370
335// adjust weight per container type ("of holding") 371// adjust weight per container type ("of holding")
336static sint32 372static sint32
337weight_adjust (object *op, sint32 weight) 373weight_adjust (object *op, sint32 weight)
338{ 374{
339 return op->type == CONTAINER 375 return op->type == CONTAINER
356 return; 392 return;
357 393
358 op->carrying += weight; 394 op->carrying += weight;
359 395
360 if (object *pl = op->visible_to ()) 396 if (object *pl = op->visible_to ())
397 if (pl != op) // player is handled lazily
361 esrv_update_item (UPD_WEIGHT, pl, op); 398 esrv_update_item (UPD_WEIGHT, pl, op);
362 399
363 op = op->env; 400 op = op->env;
364 } 401 }
365} 402}
366 403
387 if (sum != carrying) 424 if (sum != carrying)
388 { 425 {
389 carrying = sum; 426 carrying = sum;
390 427
391 if (object *pl = visible_to ()) 428 if (object *pl = visible_to ())
429 if (pl != this) // player is handled lazily
392 esrv_update_item (UPD_WEIGHT, pl, this); 430 esrv_update_item (UPD_WEIGHT, pl, this);
393 } 431 }
394} 432}
395 433
396/* 434/*
397 * Used by: Server DM commands: dumpbelow, dump. Some error messages. 435 * Used by: Server DM commands: dumpbelow, dump. Some error messages.
568} 606}
569 607
570object & 608object &
571object::operator =(const object &src) 609object::operator =(const object &src)
572{ 610{
573 bool is_freed = flag [FLAG_FREED]; 611 remove ();
574 bool is_removed = flag [FLAG_REMOVED];
575 612
576 *(object_copy *)this = src; 613 *(object_copy *)this = src;
577 614
578 flag [FLAG_FREED] = is_freed;
579 flag [FLAG_REMOVED] = is_removed; 615 flag [FLAG_REMOVED] = true;
580 616
581 /* Copy over key_values, if any. */ 617 /* Copy over key_values, if any. */
582 if (src.key_values) 618 if (src.key_values)
583 { 619 {
584 key_value *tail = 0; 620 key_value *tail = 0;
708 * UP_OBJ_FACE: only the objects face has changed. 744 * UP_OBJ_FACE: only the objects face has changed.
709 */ 745 */
710void 746void
711update_object (object *op, int action) 747update_object (object *op, int action)
712{ 748{
713 if (op == NULL) 749 if (!op)
714 { 750 {
715 /* this should never happen */ 751 /* this should never happen */
716 LOG (llevDebug, "update_object() called for NULL object.\n"); 752 LOG (llevError | logBacktrace, "update_object() called for NULL object.\n");
717 return; 753 return;
718 } 754 }
719 755
720 if (op->env) 756 if (!op->is_on_map ())
721 { 757 {
722 /* Animation is currently handled by client, so nothing 758 /* Animation is currently handled by client, so nothing
723 * to do in this case. 759 * to do in this case.
724 */ 760 */
725 return; 761 return;
726 } 762 }
727
728 /* If the map is saving, don't do anything as everything is
729 * going to get freed anyways.
730 */
731 if (!op->map || op->map->in_memory == MAP_SAVING)
732 return;
733 763
734 /* make sure the object is within map boundaries */ 764 /* make sure the object is within map boundaries */
735 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)
736 { 766 {
737 LOG (llevError, "update_object() called for object out of map!\n"); 767 LOG (llevError, "update_object() called for object out of map!\n");
880object::destroy_inv (bool drop_to_ground) 910object::destroy_inv (bool drop_to_ground)
881{ 911{
882 // need to check first, because the checks below might segfault 912 // need to check first, because the checks below might segfault
883 // as we might be on an invalid mapspace and crossfire code 913 // as we might be on an invalid mapspace and crossfire code
884 // is too buggy to ensure that the inventory is empty. 914 // is too buggy to ensure that the inventory is empty.
885 // corollary: if you create arrows etc. with stuff in tis inventory, 915 // corollary: if you create arrows etc. with stuff in its inventory,
886 // cf will crash below with off-map x and y 916 // cf will crash below with off-map x and y
887 if (!inv) 917 if (!inv)
888 return; 918 return;
889 919
890 /* Only if the space blocks everything do we not process - 920 /* Only if the space blocks everything do we not process -
897 || map->nodrop 927 || map->nodrop
898 || ms ().move_block == MOVE_ALL) 928 || ms ().move_block == MOVE_ALL)
899 { 929 {
900 while (inv) 930 while (inv)
901 { 931 {
902 inv->destroy_inv (drop_to_ground); 932 inv->destroy_inv (false);
903 inv->destroy (); 933 inv->destroy ();
904 } 934 }
905 } 935 }
906 else 936 else
907 { /* Put objects in inventory onto this space */ 937 { /* Put objects in inventory onto this space */
913 || op->flag [FLAG_NO_DROP] 943 || op->flag [FLAG_NO_DROP]
914 || op->type == RUNE 944 || op->type == RUNE
915 || op->type == TRAP 945 || op->type == TRAP
916 || op->flag [FLAG_IS_A_TEMPLATE] 946 || op->flag [FLAG_IS_A_TEMPLATE]
917 || op->flag [FLAG_DESTROY_ON_DEATH]) 947 || op->flag [FLAG_DESTROY_ON_DEATH])
918 op->destroy (); 948 op->destroy (true);
919 else 949 else
920 map->insert (op, x, y); 950 map->insert (op, x, y);
921 } 951 }
922 } 952 }
923} 953}
927 object *op = new object; 957 object *op = new object;
928 op->link (); 958 op->link ();
929 return op; 959 return op;
930} 960}
931 961
962static 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
932void 977void
933object::do_destroy () 978object::do_destroy ()
934{ 979{
935 if (flag [FLAG_IS_LINKED]) 980 if (flag [FLAG_IS_LINKED])
936 remove_button_link (this); 981 remove_button_link (this);
940 985
941 remove (); 986 remove ();
942 987
943 attachable::do_destroy (); 988 attachable::do_destroy ();
944 989
945 destroy_inv (true);
946
947 deactivate (); 990 deactivate ();
948 unlink (); 991 unlink ();
949 992
950 flag [FLAG_FREED] = 1; 993 flag [FLAG_FREED] = 1;
951 994
952 // hack to ensure that freed objects still have a valid map 995 // hack to ensure that freed objects still have a valid map
953 {
954 static maptile *freed_map; // freed objects are moved here to avoid crashes
955
956 if (!freed_map)
957 {
958 freed_map = new maptile;
959
960 freed_map->path = "<freed objects map>";
961 freed_map->name = "/internal/freed_objects_map";
962 freed_map->width = 3;
963 freed_map->height = 3;
964 freed_map->nodrop = 1;
965
966 freed_map->alloc ();
967 freed_map->in_memory = MAP_ACTIVE;
968 }
969
970 map = freed_map; 996 map = &freed_map;
971 x = 1; 997 x = 1;
972 y = 1; 998 y = 1;
973 }
974 999
975 if (more) 1000 if (more)
976 { 1001 {
977 more->destroy (); 1002 more->destroy ();
978 more = 0; 1003 more = 0;
991object::destroy (bool destroy_inventory) 1016object::destroy (bool destroy_inventory)
992{ 1017{
993 if (destroyed ()) 1018 if (destroyed ())
994 return; 1019 return;
995 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
996 if (destroy_inventory) 1028 destroy_inv (!destroy_inventory);
997 destroy_inv (false);
998 1029
999 if (is_head ()) 1030 if (is_head ())
1000 if (sound_destroy) 1031 if (sound_destroy)
1001 play_sound (sound_destroy); 1032 play_sound (sound_destroy);
1002 else if (flag [FLAG_MONSTER]) 1033 else if (flag [FLAG_MONSTER])
1021 if (flag [FLAG_REMOVED]) 1052 if (flag [FLAG_REMOVED])
1022 return; 1053 return;
1023 1054
1024 INVOKE_OBJECT (REMOVE, this); 1055 INVOKE_OBJECT (REMOVE, this);
1025 1056
1026 if (object *pl = visible_to ())
1027 esrv_del_item (pl->contr, count);
1028
1029 flag [FLAG_REMOVED] = true; 1057 flag [FLAG_REMOVED] = true;
1030 1058
1031 if (more) 1059 if (more)
1032 more->remove (); 1060 more->remove ();
1033 1061
1035 * In this case, the object to be removed is in someones 1063 * In this case, the object to be removed is in someones
1036 * inventory. 1064 * inventory.
1037 */ 1065 */
1038 if (env) 1066 if (env)
1039 { 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
1040 adjust_weight (env, -total_weight ()); 1073 adjust_weight (env, -total_weight ());
1041 1074
1042 *(above ? &above->below : &env->inv) = below; 1075 *(above ? &above->below : &env->inv) = below;
1043 1076
1044 if (below) 1077 if (below)
1062 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))
1063 otmp->update_stats (); 1096 otmp->update_stats ();
1064 } 1097 }
1065 else if (map) 1098 else if (map)
1066 { 1099 {
1067 if (type == PLAYER)
1068 {
1069 // leaving a spot always closes any open container on the ground
1070 if (container && !container->env)
1071 // this causes spurious floorbox updates, but it ensures
1072 // that the CLOSE event is being sent.
1073 close_container ();
1074
1075 --map->players;
1076 map->touch ();
1077 }
1078
1079 map->dirty = true; 1100 map->dirty = true;
1080 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 }
1081 1124
1082 /* link the object above us */ 1125 /* link the object above us */
1083 if (above) 1126 if (above)
1084 above->below = below; 1127 above->below = below;
1085 else 1128 else
1115 * removed (most likely destroyed), update the player view 1158 * removed (most likely destroyed), update the player view
1116 * appropriately. 1159 * appropriately.
1117 */ 1160 */
1118 pl->close_container (); 1161 pl->close_container ();
1119 1162
1120 pl->contr->ns->floorbox_update (); 1163 //TODO: the floorbox prev/next might need updating
1164 esrv_del_item (pl->contr, count);
1121 } 1165 }
1122 1166
1123 for (tmp = ms.bot; tmp; tmp = tmp->above) 1167 for (tmp = ms.bot; tmp; tmp = tmp->above)
1124 { 1168 {
1125 /* 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
1169 if (!top) 1213 if (!top)
1170 for (top = op; top && top->above; top = top->above) 1214 for (top = op; top && top->above; top = top->above)
1171 ; 1215 ;
1172 1216
1173 for (; top; top = top->below) 1217 for (; top; top = top->below)
1174 {
1175 if (top == op)
1176 continue;
1177
1178 if (object::can_merge (op, top)) 1218 if (object::can_merge (op, top))
1179 { 1219 {
1180 top->nrof += op->nrof; 1220 top->nrof += op->nrof;
1181 1221
1182/* CLEAR_FLAG(top,FLAG_STARTEQUIP);*/ 1222 if (object *pl = top->visible_to ())
1183 op->weight = 0; /* Don't want any adjustements now */ 1223 esrv_update_item (UPD_NROF, pl, top);
1224
1225 op->weight = 0; // cancel the addition above
1226 op->carrying = 0; // must be 0 already
1227
1184 op->destroy (); 1228 op->destroy (1);
1229
1185 return top; 1230 return top;
1186 } 1231 }
1187 }
1188 1232
1189 return 0; 1233 return 0;
1190} 1234}
1191 1235
1192void 1236void
1251object * 1295object *
1252insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1296insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1253{ 1297{
1254 assert (!op->flag [FLAG_FREED]); 1298 assert (!op->flag [FLAG_FREED]);
1255 1299
1256 object *top, *floor = NULL;
1257
1258 op->remove (); 1300 op->remove ();
1259 1301
1260 /* Ideally, the caller figures this out. However, it complicates a lot 1302 /* Ideally, the caller figures this out. However, it complicates a lot
1261 * 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
1262 * need extra work 1304 * need extra work
1263 */ 1305 */
1264 if (!xy_normalise (m, op->x, op->y)) 1306 if (!xy_normalise (m, op->x, op->y))
1265 { 1307 {
1266 op->destroy (); 1308 op->destroy (1);
1267 return 0; 1309 return 0;
1268 } 1310 }
1269 1311
1270 if (object *more = op->more) 1312 if (object *more = op->more)
1271 if (!insert_ob_in_map (more, m, originator, flag)) 1313 if (!insert_ob_in_map (more, m, originator, flag))
1280 */ 1322 */
1281 if (op->nrof && !(flag & INS_NO_MERGE)) 1323 if (op->nrof && !(flag & INS_NO_MERGE))
1282 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 1324 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
1283 if (object::can_merge (op, tmp)) 1325 if (object::can_merge (op, tmp))
1284 { 1326 {
1327 // TODO: we atcually want to update tmp, not op,
1328 // but some caller surely breaks when we return tmp
1329 // from here :/
1285 op->nrof += tmp->nrof; 1330 op->nrof += tmp->nrof;
1286 tmp->destroy (1); 1331 tmp->destroy (1);
1287 } 1332 }
1288 1333
1289 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 */
1311 /* since *below* originator, no need to update top */ 1356 /* since *below* originator, no need to update top */
1312 originator->below = op; 1357 originator->below = op;
1313 } 1358 }
1314 else 1359 else
1315 { 1360 {
1361 object *top, *floor = NULL;
1362
1316 top = ms.bot; 1363 top = ms.bot;
1317 1364
1318 /* If there are other objects, then */ 1365 /* If there are other objects, then */
1319 if (top) 1366 if (top)
1320 { 1367 {
1419 } 1466 }
1420 1467
1421 op->map->dirty = true; 1468 op->map->dirty = true;
1422 1469
1423 if (object *pl = ms.player ()) 1470 if (object *pl = ms.player ())
1424 pl->contr->ns->floorbox_update (); 1471 //TODO: the floorbox prev/next might need updating
1472 esrv_send_item (pl, op);
1425 1473
1426 /* If this object glows, it may affect lighting conditions that are 1474 /* If this object glows, it may affect lighting conditions that are
1427 * 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
1428 * 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
1429 * on the map will get recalculated. The players could very well 1477 * on the map will get recalculated. The players could very well
1494 return where->env->insert (this); 1542 return where->env->insert (this);
1495 else 1543 else
1496 return where->map->insert (this, where->x, where->y, originator, flags); 1544 return where->map->insert (this, where->x, where->y, originator, flags);
1497} 1545}
1498 1546
1499// find player who can see this object
1500object *
1501object::visible_to () const
1502{
1503 if (!flag [FLAG_REMOVED])
1504 {
1505 // see if we are in a container of sorts
1506 if (env)
1507 {
1508 // the player inventory itself is always visible
1509 if (env->type == PLAYER)
1510 return env;
1511
1512 // else a player could have our env open
1513 object *envest = env->outer_env ();
1514
1515 // the player itself is always on a map, so we will find him here
1516 // even if our inv is in a player.
1517 if (envest->is_on_map ())
1518 if (object *pl = envest->ms ().player ())
1519 if (pl->container == env)
1520 return pl;
1521 }
1522 else
1523 {
1524 // maybe there is a player standing on the same mapspace
1525 // this will catch the case where "this" is a player
1526 if (object *pl = ms ().player ())
1527 return pl;
1528 }
1529 }
1530
1531 return 0;
1532}
1533
1534/* 1547/*
1535 * decrease(object, number) decreases a specified number from 1548 * decrease(object, number) decreases a specified number from
1536 * the amount of an object. If the amount reaches 0, the object 1549 * the amount of an object. If the amount reaches 0, the object
1537 * is subsequently removed and freed. 1550 * is subsequently removed and freed.
1538 * 1551 *
1638 if (object::can_merge (tmp, op)) 1651 if (object::can_merge (tmp, op))
1639 { 1652 {
1640 /* return the original object and remove inserted object 1653 /* return the original object and remove inserted object
1641 (client needs the original object) */ 1654 (client needs the original object) */
1642 tmp->nrof += op->nrof; 1655 tmp->nrof += op->nrof;
1656
1657 if (object *pl = tmp->visible_to ())
1658 esrv_update_item (UPD_NROF, pl, tmp);
1659
1643 adjust_weight (this, op->total_weight ()); 1660 adjust_weight (this, op->total_weight ());
1644 1661
1645 op->destroy (1); 1662 op->destroy (1);
1646 op = tmp; 1663 op = tmp;
1647 goto inserted; 1664 goto inserted;
1661 1678
1662 inv = op; 1679 inv = op;
1663 1680
1664 op->flag [FLAG_REMOVED] = 0; 1681 op->flag [FLAG_REMOVED] = 0;
1665 1682
1683 if (object *pl = op->visible_to ())
1684 esrv_send_item (pl, op);
1685
1666 adjust_weight (this, op->total_weight ()); 1686 adjust_weight (this, op->total_weight ());
1667 1687
1668inserted: 1688inserted:
1669 /* reset the light list and los of the players on the map */ 1689 /* reset the light list and los of the players on the map */
1670 if (op->glow_radius && map && map->darkness) 1690 if (op->glow_radius && map && map->darkness)
1671 update_all_los (map, x, y); 1691 update_all_los (map, x, y);
1672 1692
1673 if (object *otmp = in_player ()) 1693 // if this is a player's inventory, update stats
1674 if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1694 if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER])
1675 otmp->update_stats (); 1695 update_stats ();
1676 1696
1677 INVOKE_OBJECT (INSERT, this); 1697 INVOKE_OBJECT (INSERT, this);
1678 1698
1679 return op; 1699 return op;
1680} 1700}
2304 * create clone from object to another 2324 * create clone from object to another
2305 */ 2325 */
2306object * 2326object *
2307object_create_clone (object *asrc) 2327object_create_clone (object *asrc)
2308{ 2328{
2309 object *dst = 0, *tmp, *src, *prev, *item; 2329 object *dst = 0;
2310 2330
2311 if (!asrc) 2331 if (!asrc)
2312 return 0; 2332 return 0;
2313 2333
2314 src = asrc->head_ (); 2334 object *src = asrc->head_ ();
2315 2335
2316 prev = 0; 2336 object *prev = 0;
2317 for (object *part = src; part; part = part->more) 2337 for (object *part = src; part; part = part->more)
2318 { 2338 {
2319 tmp = part->clone (); 2339 object *tmp = part->clone ();
2340
2320 tmp->x -= src->x; 2341 tmp->x -= src->x;
2321 tmp->y -= src->y; 2342 tmp->y -= src->y;
2322 2343
2323 if (!part->head) 2344 if (!part->head)
2324 { 2345 {
2334 prev->more = tmp; 2355 prev->more = tmp;
2335 2356
2336 prev = tmp; 2357 prev = tmp;
2337 } 2358 }
2338 2359
2339 for (item = src->inv; item; item = item->below) 2360 for (object *item = src->inv; item; item = item->below)
2340 insert_ob_in_ob (object_create_clone (item), dst); 2361 insert_ob_in_ob (object_create_clone (item), dst);
2341 2362
2342 return dst; 2363 return dst;
2343} 2364}
2344 2365
2558 &name, 2579 &name,
2559 title ? "\",title:\"" : "", 2580 title ? "\",title:\"" : "",
2560 title ? (const char *)title : "", 2581 title ? (const char *)title : "",
2561 flag_desc (flagdesc, 512), type); 2582 flag_desc (flagdesc, 512), type);
2562 2583
2563 if (!this->flag[FLAG_REMOVED] && env) 2584 if (!flag[FLAG_REMOVED] && env)
2564 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); 2585 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2565 2586
2566 if (map) 2587 if (map)
2567 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);
2568 2589
2598object::open_container (object *new_container) 2619object::open_container (object *new_container)
2599{ 2620{
2600 if (container == new_container) 2621 if (container == new_container)
2601 return; 2622 return;
2602 2623
2603 if (object *old_container = container) 2624 object *old_container = container;
2625
2626 if (old_container)
2604 { 2627 {
2605 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) 2628 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this)))
2606 return; 2629 return;
2607 2630
2608#if 0 2631#if 0
2610 if (object *closer = old_container->inv) 2633 if (object *closer = old_container->inv)
2611 if (closer->type == CLOSE_CON) 2634 if (closer->type == CLOSE_CON)
2612 closer->destroy (); 2635 closer->destroy ();
2613#endif 2636#endif
2614 2637
2638 // make sure the container is available
2639 esrv_send_item (this, old_container);
2640
2615 old_container->flag [FLAG_APPLIED] = 0; 2641 old_container->flag [FLAG_APPLIED] = false;
2616 container = 0; 2642 container = 0;
2617 2643
2644 // client needs item update to make it work, client bug requires this to be separate
2618 esrv_update_item (UPD_FLAGS, this, old_container); 2645 esrv_update_item (UPD_FLAGS, this, old_container);
2646
2619 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));
2620 play_sound (sound_find ("chest_close")); 2648 play_sound (sound_find ("chest_close"));
2621 } 2649 }
2622 2650
2623 if (new_container) 2651 if (new_container)
2636 } 2664 }
2637#endif 2665#endif
2638 2666
2639 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));
2640 2668
2669 // make sure the container is available, client bug requires this to be separate
2670 esrv_send_item (this, new_container);
2671
2641 new_container->flag [FLAG_APPLIED] = 1; 2672 new_container->flag [FLAG_APPLIED] = true;
2642 container = new_container; 2673 container = new_container;
2643 2674
2675 // client needs flag change
2644 esrv_update_item (UPD_FLAGS, this, new_container); 2676 esrv_update_item (UPD_FLAGS, this, new_container);
2645 esrv_send_inventory (this, new_container); 2677 esrv_send_inventory (this, new_container);
2646 play_sound (sound_find ("chest_open")); 2678 play_sound (sound_find ("chest_open"));
2647 } 2679 }
2680// else if (!old_container->env && contr && contr->ns)
2681// contr->ns->floorbox_reset ();
2648} 2682}
2649 2683
2650object * 2684object *
2651object::force_find (const shstr name) 2685object::force_find (const shstr name)
2652{ 2686{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines