… | |
… | |
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 |
|
|
336 | object * |
|
|
337 | object::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") |
336 | static sint32 |
372 | static sint32 |
337 | weight_adjust (object *op, sint32 weight) |
373 | weight_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. |
… | |
… | |
880 | object::destroy_inv (bool drop_to_ground) |
918 | object::destroy_inv (bool drop_to_ground) |
881 | { |
919 | { |
882 | // need to check first, because the checks below might segfault |
920 | // need to check first, because the checks below might segfault |
883 | // as we might be on an invalid mapspace and crossfire code |
921 | // as we might be on an invalid mapspace and crossfire code |
884 | // is too buggy to ensure that the inventory is empty. |
922 | // is too buggy to ensure that the inventory is empty. |
885 | // corollary: if you create arrows etc. with stuff in tis inventory, |
923 | // corollary: if you create arrows etc. with stuff in its inventory, |
886 | // cf will crash below with off-map x and y |
924 | // cf will crash below with off-map x and y |
887 | if (!inv) |
925 | if (!inv) |
888 | return; |
926 | return; |
889 | |
927 | |
890 | /* Only if the space blocks everything do we not process - |
928 | /* Only if the space blocks everything do we not process - |
… | |
… | |
897 | || map->nodrop |
935 | || map->nodrop |
898 | || ms ().move_block == MOVE_ALL) |
936 | || ms ().move_block == MOVE_ALL) |
899 | { |
937 | { |
900 | while (inv) |
938 | while (inv) |
901 | { |
939 | { |
902 | inv->destroy_inv (drop_to_ground); |
940 | inv->destroy_inv (false); |
903 | inv->destroy (); |
941 | inv->destroy (); |
904 | } |
942 | } |
905 | } |
943 | } |
906 | else |
944 | else |
907 | { /* Put objects in inventory onto this space */ |
945 | { /* Put objects in inventory onto this space */ |
… | |
… | |
913 | || op->flag [FLAG_NO_DROP] |
951 | || op->flag [FLAG_NO_DROP] |
914 | || op->type == RUNE |
952 | || op->type == RUNE |
915 | || op->type == TRAP |
953 | || op->type == TRAP |
916 | || op->flag [FLAG_IS_A_TEMPLATE] |
954 | || op->flag [FLAG_IS_A_TEMPLATE] |
917 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
955 | || op->flag [FLAG_DESTROY_ON_DEATH]) |
918 | op->destroy (); |
956 | op->destroy (true); |
919 | else |
957 | else |
920 | map->insert (op, x, y); |
958 | map->insert (op, x, y); |
921 | } |
959 | } |
922 | } |
960 | } |
923 | } |
961 | } |
… | |
… | |
939 | remove_friendly_object (this); |
977 | remove_friendly_object (this); |
940 | |
978 | |
941 | remove (); |
979 | remove (); |
942 | |
980 | |
943 | attachable::do_destroy (); |
981 | attachable::do_destroy (); |
944 | |
|
|
945 | destroy_inv (true); |
|
|
946 | |
982 | |
947 | deactivate (); |
983 | deactivate (); |
948 | unlink (); |
984 | unlink (); |
949 | |
985 | |
950 | flag [FLAG_FREED] = 1; |
986 | flag [FLAG_FREED] = 1; |
… | |
… | |
991 | object::destroy (bool destroy_inventory) |
1027 | object::destroy (bool destroy_inventory) |
992 | { |
1028 | { |
993 | if (destroyed ()) |
1029 | if (destroyed ()) |
994 | return; |
1030 | return; |
995 | |
1031 | |
|
|
1032 | if (!is_head () && !head->destroyed ()) |
|
|
1033 | { |
|
|
1034 | LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); |
|
|
1035 | head->destroy (destroy_inventory); |
|
|
1036 | } |
|
|
1037 | |
996 | if (destroy_inventory) |
1038 | destroy_inv (!destroy_inventory); |
997 | destroy_inv (false); |
|
|
998 | |
1039 | |
999 | if (is_head ()) |
1040 | if (is_head ()) |
1000 | if (sound_destroy) |
1041 | if (sound_destroy) |
1001 | play_sound (sound_destroy); |
1042 | play_sound (sound_destroy); |
1002 | else if (flag [FLAG_MONSTER]) |
1043 | else if (flag [FLAG_MONSTER]) |
… | |
… | |
1021 | if (flag [FLAG_REMOVED]) |
1062 | if (flag [FLAG_REMOVED]) |
1022 | return; |
1063 | return; |
1023 | |
1064 | |
1024 | INVOKE_OBJECT (REMOVE, this); |
1065 | INVOKE_OBJECT (REMOVE, this); |
1025 | |
1066 | |
1026 | if (object *pl = visible_to ()) |
|
|
1027 | esrv_del_item (pl->contr, count); |
|
|
1028 | |
|
|
1029 | flag [FLAG_REMOVED] = true; |
1067 | flag [FLAG_REMOVED] = true; |
1030 | |
1068 | |
1031 | if (more) |
1069 | if (more) |
1032 | more->remove (); |
1070 | more->remove (); |
1033 | |
1071 | |
… | |
… | |
1035 | * In this case, the object to be removed is in someones |
1073 | * In this case, the object to be removed is in someones |
1036 | * inventory. |
1074 | * inventory. |
1037 | */ |
1075 | */ |
1038 | if (env) |
1076 | if (env) |
1039 | { |
1077 | { |
|
|
1078 | if (object *pl = visible_to ()) |
|
|
1079 | esrv_del_item (pl->contr, count); |
|
|
1080 | |
1040 | adjust_weight (env, -total_weight ()); |
1081 | adjust_weight (env, -total_weight ()); |
1041 | |
1082 | |
1042 | *(above ? &above->below : &env->inv) = below; |
1083 | *(above ? &above->below : &env->inv) = below; |
1043 | |
1084 | |
1044 | if (below) |
1085 | if (below) |
… | |
… | |
1062 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1103 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1063 | otmp->update_stats (); |
1104 | otmp->update_stats (); |
1064 | } |
1105 | } |
1065 | else if (map) |
1106 | else if (map) |
1066 | { |
1107 | { |
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; |
1108 | map->dirty = true; |
1080 | mapspace &ms = this->ms (); |
1109 | mapspace &ms = this->ms (); |
|
|
1110 | |
|
|
1111 | if (object *pl = ms.player ()) |
|
|
1112 | { |
|
|
1113 | if (type == PLAYER) // this == pl(!) |
|
|
1114 | { |
|
|
1115 | // leaving a spot always closes any open container on the ground |
|
|
1116 | if (container && !container->env) |
|
|
1117 | // this causes spurious floorbox updates, but it ensures |
|
|
1118 | // that the CLOSE event is being sent. |
|
|
1119 | close_container (); |
|
|
1120 | |
|
|
1121 | --map->players; |
|
|
1122 | map->touch (); |
|
|
1123 | } |
|
|
1124 | else if (pl->container == this) |
|
|
1125 | { |
|
|
1126 | // removing a container should close it |
|
|
1127 | close_container (); |
|
|
1128 | } |
|
|
1129 | |
|
|
1130 | esrv_del_item (pl->contr, count); |
|
|
1131 | } |
1081 | |
1132 | |
1082 | /* link the object above us */ |
1133 | /* link the object above us */ |
1083 | if (above) |
1134 | if (above) |
1084 | above->below = below; |
1135 | above->below = below; |
1085 | else |
1136 | else |
… | |
… | |
1115 | * removed (most likely destroyed), update the player view |
1166 | * removed (most likely destroyed), update the player view |
1116 | * appropriately. |
1167 | * appropriately. |
1117 | */ |
1168 | */ |
1118 | pl->close_container (); |
1169 | pl->close_container (); |
1119 | |
1170 | |
1120 | pl->contr->ns->floorbox_update (); |
1171 | //TODO: the floorbox prev/next might need updating |
|
|
1172 | esrv_del_item (pl->contr, count); |
1121 | } |
1173 | } |
1122 | |
1174 | |
1123 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1175 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1124 | { |
1176 | { |
1125 | /* No point updating the players look faces if he is the object |
1177 | /* No point updating the players look faces if he is the object |
… | |
… | |
1169 | if (!top) |
1221 | if (!top) |
1170 | for (top = op; top && top->above; top = top->above) |
1222 | for (top = op; top && top->above; top = top->above) |
1171 | ; |
1223 | ; |
1172 | |
1224 | |
1173 | for (; top; top = top->below) |
1225 | for (; top; top = top->below) |
1174 | { |
|
|
1175 | if (top == op) |
|
|
1176 | continue; |
|
|
1177 | |
|
|
1178 | if (object::can_merge (op, top)) |
1226 | if (object::can_merge (op, top)) |
1179 | { |
1227 | { |
1180 | top->nrof += op->nrof; |
1228 | top->nrof += op->nrof; |
1181 | |
1229 | |
1182 | /* CLEAR_FLAG(top,FLAG_STARTEQUIP);*/ |
1230 | if (object *pl = top->visible_to ()) |
1183 | op->weight = 0; /* Don't want any adjustements now */ |
1231 | esrv_update_item (UPD_NROF, pl, top); |
|
|
1232 | |
|
|
1233 | op->weight = 0; // cancel the addition above |
|
|
1234 | op->carrying = 0; // must be 0 already |
|
|
1235 | |
1184 | op->destroy (); |
1236 | op->destroy (1); |
|
|
1237 | |
1185 | return top; |
1238 | return top; |
1186 | } |
1239 | } |
1187 | } |
|
|
1188 | |
1240 | |
1189 | return 0; |
1241 | return 0; |
1190 | } |
1242 | } |
1191 | |
1243 | |
1192 | void |
1244 | void |
… | |
… | |
1251 | object * |
1303 | object * |
1252 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1304 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1253 | { |
1305 | { |
1254 | assert (!op->flag [FLAG_FREED]); |
1306 | assert (!op->flag [FLAG_FREED]); |
1255 | |
1307 | |
1256 | object *top, *floor = NULL; |
|
|
1257 | |
|
|
1258 | op->remove (); |
1308 | op->remove (); |
1259 | |
1309 | |
1260 | /* Ideally, the caller figures this out. However, it complicates a lot |
1310 | /* 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 |
1311 | * of areas of callers (eg, anything that uses find_free_spot would now |
1262 | * need extra work |
1312 | * need extra work |
1263 | */ |
1313 | */ |
1264 | if (!xy_normalise (m, op->x, op->y)) |
1314 | if (!xy_normalise (m, op->x, op->y)) |
1265 | { |
1315 | { |
1266 | op->destroy (); |
1316 | op->destroy (1); |
1267 | return 0; |
1317 | return 0; |
1268 | } |
1318 | } |
1269 | |
1319 | |
1270 | if (object *more = op->more) |
1320 | if (object *more = op->more) |
1271 | if (!insert_ob_in_map (more, m, originator, flag)) |
1321 | if (!insert_ob_in_map (more, m, originator, flag)) |
… | |
… | |
1280 | */ |
1330 | */ |
1281 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1331 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1282 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1332 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1283 | if (object::can_merge (op, tmp)) |
1333 | if (object::can_merge (op, tmp)) |
1284 | { |
1334 | { |
|
|
1335 | // TODO: we atcually want to update tmp, not op, |
|
|
1336 | // but some caller surely breaks when we return tmp |
|
|
1337 | // from here :/ |
1285 | op->nrof += tmp->nrof; |
1338 | op->nrof += tmp->nrof; |
1286 | tmp->destroy (1); |
1339 | tmp->destroy (1); |
1287 | } |
1340 | } |
1288 | |
1341 | |
1289 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
1342 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
… | |
… | |
1311 | /* since *below* originator, no need to update top */ |
1364 | /* since *below* originator, no need to update top */ |
1312 | originator->below = op; |
1365 | originator->below = op; |
1313 | } |
1366 | } |
1314 | else |
1367 | else |
1315 | { |
1368 | { |
|
|
1369 | object *top, *floor = NULL; |
|
|
1370 | |
1316 | top = ms.bot; |
1371 | top = ms.bot; |
1317 | |
1372 | |
1318 | /* If there are other objects, then */ |
1373 | /* If there are other objects, then */ |
1319 | if (top) |
1374 | if (top) |
1320 | { |
1375 | { |
… | |
… | |
1419 | } |
1474 | } |
1420 | |
1475 | |
1421 | op->map->dirty = true; |
1476 | op->map->dirty = true; |
1422 | |
1477 | |
1423 | if (object *pl = ms.player ()) |
1478 | if (object *pl = ms.player ()) |
1424 | pl->contr->ns->floorbox_update (); |
1479 | //TODO: the floorbox prev/next might need updating |
|
|
1480 | esrv_send_item (pl, op); |
1425 | |
1481 | |
1426 | /* If this object glows, it may affect lighting conditions that are |
1482 | /* If this object glows, it may affect lighting conditions that are |
1427 | * visible to others on this map. But update_all_los is really |
1483 | * 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 |
1484 | * 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 |
1485 | * on the map will get recalculated. The players could very well |
… | |
… | |
1494 | return where->env->insert (this); |
1550 | return where->env->insert (this); |
1495 | else |
1551 | else |
1496 | return where->map->insert (this, where->x, where->y, originator, flags); |
1552 | return where->map->insert (this, where->x, where->y, originator, flags); |
1497 | } |
1553 | } |
1498 | |
1554 | |
1499 | // find player who can see this object |
|
|
1500 | object * |
|
|
1501 | object::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 | /* |
1555 | /* |
1535 | * decrease(object, number) decreases a specified number from |
1556 | * decrease(object, number) decreases a specified number from |
1536 | * the amount of an object. If the amount reaches 0, the object |
1557 | * the amount of an object. If the amount reaches 0, the object |
1537 | * is subsequently removed and freed. |
1558 | * is subsequently removed and freed. |
1538 | * |
1559 | * |
… | |
… | |
1638 | if (object::can_merge (tmp, op)) |
1659 | if (object::can_merge (tmp, op)) |
1639 | { |
1660 | { |
1640 | /* return the original object and remove inserted object |
1661 | /* return the original object and remove inserted object |
1641 | (client needs the original object) */ |
1662 | (client needs the original object) */ |
1642 | tmp->nrof += op->nrof; |
1663 | tmp->nrof += op->nrof; |
|
|
1664 | |
|
|
1665 | if (object *pl = tmp->visible_to ()) |
|
|
1666 | esrv_update_item (UPD_NROF, pl, tmp); |
|
|
1667 | |
1643 | adjust_weight (this, op->total_weight ()); |
1668 | adjust_weight (this, op->total_weight ()); |
1644 | |
1669 | |
1645 | op->destroy (1); |
1670 | op->destroy (1); |
1646 | op = tmp; |
1671 | op = tmp; |
1647 | goto inserted; |
1672 | goto inserted; |
… | |
… | |
1661 | |
1686 | |
1662 | inv = op; |
1687 | inv = op; |
1663 | |
1688 | |
1664 | op->flag [FLAG_REMOVED] = 0; |
1689 | op->flag [FLAG_REMOVED] = 0; |
1665 | |
1690 | |
|
|
1691 | if (object *pl = op->visible_to ()) |
|
|
1692 | esrv_send_item (pl, op); |
|
|
1693 | |
1666 | adjust_weight (this, op->total_weight ()); |
1694 | adjust_weight (this, op->total_weight ()); |
1667 | |
1695 | |
1668 | inserted: |
1696 | inserted: |
1669 | /* reset the light list and los of the players on the map */ |
1697 | /* reset the light list and los of the players on the map */ |
1670 | if (op->glow_radius && map && map->darkness) |
1698 | if (op->glow_radius && map && map->darkness) |
1671 | update_all_los (map, x, y); |
1699 | update_all_los (map, x, y); |
1672 | |
1700 | |
1673 | if (object *otmp = in_player ()) |
1701 | // if this is a player's inventory, update stats |
1674 | if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1702 | if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) |
1675 | otmp->update_stats (); |
1703 | update_stats (); |
1676 | |
1704 | |
1677 | INVOKE_OBJECT (INSERT, this); |
1705 | INVOKE_OBJECT (INSERT, this); |
1678 | |
1706 | |
1679 | return op; |
1707 | return op; |
1680 | } |
1708 | } |
… | |
… | |
2558 | &name, |
2586 | &name, |
2559 | title ? "\",title:\"" : "", |
2587 | title ? "\",title:\"" : "", |
2560 | title ? (const char *)title : "", |
2588 | title ? (const char *)title : "", |
2561 | flag_desc (flagdesc, 512), type); |
2589 | flag_desc (flagdesc, 512), type); |
2562 | |
2590 | |
2563 | if (!this->flag[FLAG_REMOVED] && env) |
2591 | if (!flag[FLAG_REMOVED] && env) |
2564 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2592 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2565 | |
2593 | |
2566 | if (map) |
2594 | if (map) |
2567 | 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); |
2568 | |
2596 | |
… | |
… | |
2598 | object::open_container (object *new_container) |
2626 | object::open_container (object *new_container) |
2599 | { |
2627 | { |
2600 | if (container == new_container) |
2628 | if (container == new_container) |
2601 | return; |
2629 | return; |
2602 | |
2630 | |
2603 | if (object *old_container = container) |
2631 | object *old_container = container; |
|
|
2632 | |
|
|
2633 | if (old_container) |
2604 | { |
2634 | { |
2605 | if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) |
2635 | if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) |
2606 | return; |
2636 | return; |
2607 | |
2637 | |
2608 | #if 0 |
2638 | #if 0 |
… | |
… | |
2610 | if (object *closer = old_container->inv) |
2640 | if (object *closer = old_container->inv) |
2611 | if (closer->type == CLOSE_CON) |
2641 | if (closer->type == CLOSE_CON) |
2612 | closer->destroy (); |
2642 | closer->destroy (); |
2613 | #endif |
2643 | #endif |
2614 | |
2644 | |
|
|
2645 | // make sure the container is available |
|
|
2646 | esrv_send_item (this, old_container); |
|
|
2647 | |
2615 | old_container->flag [FLAG_APPLIED] = 0; |
2648 | old_container->flag [FLAG_APPLIED] = false; |
2616 | container = 0; |
2649 | container = 0; |
2617 | |
2650 | |
|
|
2651 | // client needs item update to make it work, client bug requires this to be separate |
2618 | esrv_update_item (UPD_FLAGS, this, old_container); |
2652 | esrv_update_item (UPD_FLAGS, this, old_container); |
|
|
2653 | |
2619 | 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)); |
2620 | play_sound (sound_find ("chest_close")); |
2655 | play_sound (sound_find ("chest_close")); |
2621 | } |
2656 | } |
2622 | |
2657 | |
2623 | if (new_container) |
2658 | if (new_container) |
… | |
… | |
2636 | } |
2671 | } |
2637 | #endif |
2672 | #endif |
2638 | |
2673 | |
2639 | 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)); |
2640 | |
2675 | |
|
|
2676 | // make sure the container is available, client bug requires this to be separate |
|
|
2677 | esrv_send_item (this, new_container); |
|
|
2678 | |
2641 | new_container->flag [FLAG_APPLIED] = 1; |
2679 | new_container->flag [FLAG_APPLIED] = true; |
2642 | container = new_container; |
2680 | container = new_container; |
2643 | |
2681 | |
|
|
2682 | // client needs flag change |
2644 | esrv_update_item (UPD_FLAGS, this, new_container); |
2683 | esrv_update_item (UPD_FLAGS, this, new_container); |
2645 | esrv_send_inventory (this, new_container); |
2684 | esrv_send_inventory (this, new_container); |
2646 | play_sound (sound_find ("chest_open")); |
2685 | play_sound (sound_find ("chest_open")); |
2647 | } |
2686 | } |
|
|
2687 | // else if (!old_container->env && contr && contr->ns) |
|
|
2688 | // contr->ns->floorbox_reset (); |
2648 | } |
2689 | } |
2649 | |
2690 | |
2650 | object * |
2691 | object * |
2651 | object::force_find (const shstr name) |
2692 | object::force_find (const shstr name) |
2652 | { |
2693 | { |