… | |
… | |
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 (!is_head () && !head->destroyed ()) |
|
|
1032 | { |
|
|
1033 | LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); |
|
|
1034 | head->destroy (destroy_inventory); |
|
|
1035 | } |
|
|
1036 | |
1031 | destroy_inv (!destroy_inventory); |
1037 | destroy_inv (!destroy_inventory); |
1032 | |
1038 | |
1033 | if (is_head ()) |
1039 | if (is_head ()) |
1034 | if (sound_destroy) |
1040 | if (sound_destroy) |
1035 | play_sound (sound_destroy); |
1041 | play_sound (sound_destroy); |
… | |
… | |
1149 | * removed (most likely destroyed), update the player view |
1155 | * removed (most likely destroyed), update the player view |
1150 | * appropriately. |
1156 | * appropriately. |
1151 | */ |
1157 | */ |
1152 | pl->close_container (); |
1158 | pl->close_container (); |
1153 | |
1159 | |
|
|
1160 | //TODO: the floorbox prev/next might need updating |
1154 | esrv_del_item (pl, count); |
1161 | esrv_del_item (pl->contr, count); |
1155 | } |
1162 | } |
1156 | |
1163 | |
1157 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1164 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1158 | { |
1165 | { |
1159 | /* No point updating the players look faces if he is the object |
1166 | /* No point updating the players look faces if he is the object |
… | |
… | |
1285 | object * |
1292 | object * |
1286 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1293 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1287 | { |
1294 | { |
1288 | assert (!op->flag [FLAG_FREED]); |
1295 | assert (!op->flag [FLAG_FREED]); |
1289 | |
1296 | |
1290 | object *top, *floor = NULL; |
|
|
1291 | |
|
|
1292 | op->remove (); |
1297 | op->remove (); |
1293 | |
1298 | |
1294 | /* Ideally, the caller figures this out. However, it complicates a lot |
1299 | /* Ideally, the caller figures this out. However, it complicates a lot |
1295 | * of areas of callers (eg, anything that uses find_free_spot would now |
1300 | * of areas of callers (eg, anything that uses find_free_spot would now |
1296 | * need extra work |
1301 | * need extra work |
… | |
… | |
1314 | */ |
1319 | */ |
1315 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1320 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1316 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1321 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1317 | if (object::can_merge (op, tmp)) |
1322 | if (object::can_merge (op, tmp)) |
1318 | { |
1323 | { |
|
|
1324 | // TODO: we atcually want to update tmp, not op, |
|
|
1325 | // but some caller surely breaks when we return tmp |
|
|
1326 | // from here :/ |
1319 | op->nrof += tmp->nrof; |
1327 | op->nrof += tmp->nrof; |
1320 | tmp->destroy (1); |
1328 | tmp->destroy (1); |
1321 | } |
1329 | } |
1322 | |
1330 | |
1323 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
1331 | CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
… | |
… | |
1345 | /* since *below* originator, no need to update top */ |
1353 | /* since *below* originator, no need to update top */ |
1346 | originator->below = op; |
1354 | originator->below = op; |
1347 | } |
1355 | } |
1348 | else |
1356 | else |
1349 | { |
1357 | { |
|
|
1358 | object *top, *floor = NULL; |
|
|
1359 | |
1350 | top = ms.bot; |
1360 | top = ms.bot; |
1351 | |
1361 | |
1352 | /* If there are other objects, then */ |
1362 | /* If there are other objects, then */ |
1353 | if (top) |
1363 | if (top) |
1354 | { |
1364 | { |
… | |
… | |
1453 | } |
1463 | } |
1454 | |
1464 | |
1455 | op->map->dirty = true; |
1465 | op->map->dirty = true; |
1456 | |
1466 | |
1457 | if (object *pl = ms.player ()) |
1467 | if (object *pl = ms.player ()) |
|
|
1468 | //TODO: the floorbox prev/next might need updating |
1458 | esrv_send_item (pl, op); |
1469 | esrv_send_item (pl, op); |
1459 | |
1470 | |
1460 | /* If this object glows, it may affect lighting conditions that are |
1471 | /* If this object glows, it may affect lighting conditions that are |
1461 | * visible to others on this map. But update_all_los is really |
1472 | * visible to others on this map. But update_all_los is really |
1462 | * an inefficient way to do this, as it means los for all players |
1473 | * an inefficient way to do this, as it means los for all players |