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.215 by root, Tue Apr 22 07:28:05 2008 UTC vs.
Revision 1.218 by root, Wed Apr 23 07:25:54 2008 UTC

917object::destroy_inv (bool drop_to_ground) 917object::destroy_inv (bool drop_to_ground)
918{ 918{
919 // need to check first, because the checks below might segfault 919 // need to check first, because the checks below might segfault
920 // as we might be on an invalid mapspace and crossfire code 920 // as we might be on an invalid mapspace and crossfire code
921 // is too buggy to ensure that the inventory is empty. 921 // is too buggy to ensure that the inventory is empty.
922 // corollary: if you create arrows etc. with stuff in tis inventory, 922 // corollary: if you create arrows etc. with stuff in its inventory,
923 // cf will crash below with off-map x and y 923 // cf will crash below with off-map x and y
924 if (!inv) 924 if (!inv)
925 return; 925 return;
926 926
927 /* Only if the space blocks everything do we not process - 927 /* Only if the space blocks everything do we not process -
934 || map->nodrop 934 || map->nodrop
935 || ms ().move_block == MOVE_ALL) 935 || ms ().move_block == MOVE_ALL)
936 { 936 {
937 while (inv) 937 while (inv)
938 { 938 {
939 inv->destroy_inv (drop_to_ground); 939 inv->destroy_inv (false);
940 inv->destroy (); 940 inv->destroy ();
941 } 941 }
942 } 942 }
943 else 943 else
944 { /* Put objects in inventory onto this space */ 944 { /* Put objects in inventory onto this space */
950 || op->flag [FLAG_NO_DROP] 950 || op->flag [FLAG_NO_DROP]
951 || op->type == RUNE 951 || op->type == RUNE
952 || op->type == TRAP 952 || op->type == TRAP
953 || op->flag [FLAG_IS_A_TEMPLATE] 953 || op->flag [FLAG_IS_A_TEMPLATE]
954 || op->flag [FLAG_DESTROY_ON_DEATH]) 954 || op->flag [FLAG_DESTROY_ON_DEATH])
955 op->destroy (); 955 op->destroy (true);
956 else 956 else
957 map->insert (op, x, y); 957 map->insert (op, x, y);
958 } 958 }
959 } 959 }
960} 960}
976 remove_friendly_object (this); 976 remove_friendly_object (this);
977 977
978 remove (); 978 remove ();
979 979
980 attachable::do_destroy (); 980 attachable::do_destroy ();
981
982 destroy_inv (true);
983 981
984 deactivate (); 982 deactivate ();
985 unlink (); 983 unlink ();
986 984
987 flag [FLAG_FREED] = 1; 985 flag [FLAG_FREED] = 1;
1028object::destroy (bool destroy_inventory) 1026object::destroy (bool destroy_inventory)
1029{ 1027{
1030 if (destroyed ()) 1028 if (destroyed ())
1031 return; 1029 return;
1032 1030
1033 if (destroy_inventory) 1031 destroy_inv (!destroy_inventory);
1034 destroy_inv (false);
1035 1032
1036 if (is_head ()) 1033 if (is_head ())
1037 if (sound_destroy) 1034 if (sound_destroy)
1038 play_sound (sound_destroy); 1035 play_sound (sound_destroy);
1039 else if (flag [FLAG_MONSTER]) 1036 else if (flag [FLAG_MONSTER])
1152 * removed (most likely destroyed), update the player view 1149 * removed (most likely destroyed), update the player view
1153 * appropriately. 1150 * appropriately.
1154 */ 1151 */
1155 pl->close_container (); 1152 pl->close_container ();
1156 1153
1157 pl->contr->ns->floorbox_update (); 1154 //TODO: the floorbox prev/next might need updating
1155 esrv_del_item (pl->contr, count);
1158 } 1156 }
1159 1157
1160 for (tmp = ms.bot; tmp; tmp = tmp->above) 1158 for (tmp = ms.bot; tmp; tmp = tmp->above)
1161 { 1159 {
1162 /* No point updating the players look faces if he is the object 1160 /* No point updating the players look faces if he is the object
1288object * 1286object *
1289insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1287insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1290{ 1288{
1291 assert (!op->flag [FLAG_FREED]); 1289 assert (!op->flag [FLAG_FREED]);
1292 1290
1293 object *top, *floor = NULL;
1294
1295 op->remove (); 1291 op->remove ();
1296 1292
1297 /* Ideally, the caller figures this out. However, it complicates a lot 1293 /* 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 1294 * of areas of callers (eg, anything that uses find_free_spot would now
1299 * need extra work 1295 * need extra work
1300 */ 1296 */
1301 if (!xy_normalise (m, op->x, op->y)) 1297 if (!xy_normalise (m, op->x, op->y))
1302 { 1298 {
1303 op->destroy (); 1299 op->destroy (1);
1304 return 0; 1300 return 0;
1305 } 1301 }
1306 1302
1307 if (object *more = op->more) 1303 if (object *more = op->more)
1308 if (!insert_ob_in_map (more, m, originator, flag)) 1304 if (!insert_ob_in_map (more, m, originator, flag))
1317 */ 1313 */
1318 if (op->nrof && !(flag & INS_NO_MERGE)) 1314 if (op->nrof && !(flag & INS_NO_MERGE))
1319 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 1315 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
1320 if (object::can_merge (op, tmp)) 1316 if (object::can_merge (op, tmp))
1321 { 1317 {
1318 // TODO: we atcually want to update tmp, not op,
1319 // but some caller surely breaks when we return tmp
1320 // from here :/
1322 op->nrof += tmp->nrof; 1321 op->nrof += tmp->nrof;
1323 tmp->destroy (1); 1322 tmp->destroy (1);
1324 } 1323 }
1325 1324
1326 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1325 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1348 /* since *below* originator, no need to update top */ 1347 /* since *below* originator, no need to update top */
1349 originator->below = op; 1348 originator->below = op;
1350 } 1349 }
1351 else 1350 else
1352 { 1351 {
1352 object *top, *floor = NULL;
1353
1353 top = ms.bot; 1354 top = ms.bot;
1354 1355
1355 /* If there are other objects, then */ 1356 /* If there are other objects, then */
1356 if (top) 1357 if (top)
1357 { 1358 {
1456 } 1457 }
1457 1458
1458 op->map->dirty = true; 1459 op->map->dirty = true;
1459 1460
1460 if (object *pl = ms.player ()) 1461 if (object *pl = ms.player ())
1461 pl->contr->ns->floorbox_update (); 1462 //TODO: the floorbox prev/next might need updating
1463 esrv_send_item (pl, op);
1462 1464
1463 /* If this object glows, it may affect lighting conditions that are 1465 /* If this object glows, it may affect lighting conditions that are
1464 * visible to others on this map. But update_all_los is really 1466 * 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 1467 * 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 1468 * on the map will get recalculated. The players could very well
2567 &name, 2569 &name,
2568 title ? "\",title:\"" : "", 2570 title ? "\",title:\"" : "",
2569 title ? (const char *)title : "", 2571 title ? (const char *)title : "",
2570 flag_desc (flagdesc, 512), type); 2572 flag_desc (flagdesc, 512), type);
2571 2573
2572 if (!this->flag[FLAG_REMOVED] && env) 2574 if (!flag[FLAG_REMOVED] && env)
2573 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); 2575 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2574 2576
2575 if (map) 2577 if (map)
2576 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); 2578 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y);
2577 2579
2619 if (object *closer = old_container->inv) 2621 if (object *closer = old_container->inv)
2620 if (closer->type == CLOSE_CON) 2622 if (closer->type == CLOSE_CON)
2621 closer->destroy (); 2623 closer->destroy ();
2622#endif 2624#endif
2623 2625
2624 old_container->flag [FLAG_APPLIED] = 0; 2626 old_container->flag [FLAG_APPLIED] = false;
2625 container = 0; 2627 container = 0;
2626 2628
2627 esrv_update_item (UPD_FLAGS, this, old_container); 2629 esrv_update_item (UPD_FLAGS, this, old_container);
2628 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); 2630 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container));
2629 play_sound (sound_find ("chest_close")); 2631 play_sound (sound_find ("chest_close"));
2645 } 2647 }
2646#endif 2648#endif
2647 2649
2648 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); 2650 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container));
2649 2651
2650 new_container->flag [FLAG_APPLIED] = 1; 2652 new_container->flag [FLAG_APPLIED] = true;
2651 container = new_container; 2653 container = new_container;
2652 2654
2653 esrv_update_item (UPD_FLAGS, this, new_container); 2655 esrv_update_item (UPD_FLAGS, this, new_container);
2654 esrv_send_inventory (this, new_container); 2656 esrv_send_inventory (this, new_container);
2655 play_sound (sound_find ("chest_open")); 2657 play_sound (sound_find ("chest_open"));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines