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.214 by root, Tue Apr 22 07:01:46 2008 UTC vs.
Revision 1.219 by root, Wed Apr 23 21:09:10 2008 UTC

391 return; 391 return;
392 392
393 op->carrying += weight; 393 op->carrying += weight;
394 394
395 if (object *pl = op->visible_to ()) 395 if (object *pl = op->visible_to ())
396 if (pl != op) // player is handled lazily
396 esrv_update_item (UPD_WEIGHT, pl, op); 397 esrv_update_item (UPD_WEIGHT, pl, op);
397 398
398 op = op->env; 399 op = op->env;
399 } 400 }
400} 401}
401 402
422 if (sum != carrying) 423 if (sum != carrying)
423 { 424 {
424 carrying = sum; 425 carrying = sum;
425 426
426 if (object *pl = visible_to ()) 427 if (object *pl = visible_to ())
428 if (pl != this) // player is handled lazily
427 esrv_update_item (UPD_WEIGHT, pl, this); 429 esrv_update_item (UPD_WEIGHT, pl, this);
428 } 430 }
429} 431}
430 432
431/* 433/*
432 * Used by: Server DM commands: dumpbelow, dump. Some error messages. 434 * Used by: Server DM commands: dumpbelow, dump. Some error messages.
915object::destroy_inv (bool drop_to_ground) 917object::destroy_inv (bool drop_to_ground)
916{ 918{
917 // need to check first, because the checks below might segfault 919 // need to check first, because the checks below might segfault
918 // as we might be on an invalid mapspace and crossfire code 920 // as we might be on an invalid mapspace and crossfire code
919 // is too buggy to ensure that the inventory is empty. 921 // is too buggy to ensure that the inventory is empty.
920 // corollary: if you create arrows etc. with stuff in tis inventory, 922 // corollary: if you create arrows etc. with stuff in its inventory,
921 // cf will crash below with off-map x and y 923 // cf will crash below with off-map x and y
922 if (!inv) 924 if (!inv)
923 return; 925 return;
924 926
925 /* Only if the space blocks everything do we not process - 927 /* Only if the space blocks everything do we not process -
932 || map->nodrop 934 || map->nodrop
933 || ms ().move_block == MOVE_ALL) 935 || ms ().move_block == MOVE_ALL)
934 { 936 {
935 while (inv) 937 while (inv)
936 { 938 {
937 inv->destroy_inv (drop_to_ground); 939 inv->destroy_inv (false);
938 inv->destroy (); 940 inv->destroy ();
939 } 941 }
940 } 942 }
941 else 943 else
942 { /* Put objects in inventory onto this space */ 944 { /* Put objects in inventory onto this space */
948 || op->flag [FLAG_NO_DROP] 950 || op->flag [FLAG_NO_DROP]
949 || op->type == RUNE 951 || op->type == RUNE
950 || op->type == TRAP 952 || op->type == TRAP
951 || op->flag [FLAG_IS_A_TEMPLATE] 953 || op->flag [FLAG_IS_A_TEMPLATE]
952 || op->flag [FLAG_DESTROY_ON_DEATH]) 954 || op->flag [FLAG_DESTROY_ON_DEATH])
953 op->destroy (); 955 op->destroy (true);
954 else 956 else
955 map->insert (op, x, y); 957 map->insert (op, x, y);
956 } 958 }
957 } 959 }
958} 960}
974 remove_friendly_object (this); 976 remove_friendly_object (this);
975 977
976 remove (); 978 remove ();
977 979
978 attachable::do_destroy (); 980 attachable::do_destroy ();
979
980 destroy_inv (true);
981 981
982 deactivate (); 982 deactivate ();
983 unlink (); 983 unlink ();
984 984
985 flag [FLAG_FREED] = 1; 985 flag [FLAG_FREED] = 1;
1026object::destroy (bool destroy_inventory) 1026object::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 if (destroy_inventory) 1037 destroy_inv (!destroy_inventory);
1032 destroy_inv (false);
1033 1038
1034 if (is_head ()) 1039 if (is_head ())
1035 if (sound_destroy) 1040 if (sound_destroy)
1036 play_sound (sound_destroy); 1041 play_sound (sound_destroy);
1037 else if (flag [FLAG_MONSTER]) 1042 else if (flag [FLAG_MONSTER])
1150 * removed (most likely destroyed), update the player view 1155 * removed (most likely destroyed), update the player view
1151 * appropriately. 1156 * appropriately.
1152 */ 1157 */
1153 pl->close_container (); 1158 pl->close_container ();
1154 1159
1155 pl->contr->ns->floorbox_update (); 1160 //TODO: the floorbox prev/next might need updating
1161 esrv_del_item (pl->contr, count);
1156 } 1162 }
1157 1163
1158 for (tmp = ms.bot; tmp; tmp = tmp->above) 1164 for (tmp = ms.bot; tmp; tmp = tmp->above)
1159 { 1165 {
1160 /* 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
1286object * 1292object *
1287insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1293insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1288{ 1294{
1289 assert (!op->flag [FLAG_FREED]); 1295 assert (!op->flag [FLAG_FREED]);
1290 1296
1291 object *top, *floor = NULL;
1292
1293 op->remove (); 1297 op->remove ();
1294 1298
1295 /* Ideally, the caller figures this out. However, it complicates a lot 1299 /* Ideally, the caller figures this out. However, it complicates a lot
1296 * 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
1297 * need extra work 1301 * need extra work
1298 */ 1302 */
1299 if (!xy_normalise (m, op->x, op->y)) 1303 if (!xy_normalise (m, op->x, op->y))
1300 { 1304 {
1301 op->destroy (); 1305 op->destroy (1);
1302 return 0; 1306 return 0;
1303 } 1307 }
1304 1308
1305 if (object *more = op->more) 1309 if (object *more = op->more)
1306 if (!insert_ob_in_map (more, m, originator, flag)) 1310 if (!insert_ob_in_map (more, m, originator, flag))
1315 */ 1319 */
1316 if (op->nrof && !(flag & INS_NO_MERGE)) 1320 if (op->nrof && !(flag & INS_NO_MERGE))
1317 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 1321 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
1318 if (object::can_merge (op, tmp)) 1322 if (object::can_merge (op, tmp))
1319 { 1323 {
1324 // TODO: we atcually want to update tmp, not op,
1325 // but some caller surely breaks when we return tmp
1326 // from here :/
1320 op->nrof += tmp->nrof; 1327 op->nrof += tmp->nrof;
1321 tmp->destroy (1); 1328 tmp->destroy (1);
1322 } 1329 }
1323 1330
1324 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 */
1346 /* since *below* originator, no need to update top */ 1353 /* since *below* originator, no need to update top */
1347 originator->below = op; 1354 originator->below = op;
1348 } 1355 }
1349 else 1356 else
1350 { 1357 {
1358 object *top, *floor = NULL;
1359
1351 top = ms.bot; 1360 top = ms.bot;
1352 1361
1353 /* If there are other objects, then */ 1362 /* If there are other objects, then */
1354 if (top) 1363 if (top)
1355 { 1364 {
1454 } 1463 }
1455 1464
1456 op->map->dirty = true; 1465 op->map->dirty = true;
1457 1466
1458 if (object *pl = ms.player ()) 1467 if (object *pl = ms.player ())
1459 pl->contr->ns->floorbox_update (); 1468 //TODO: the floorbox prev/next might need updating
1469 esrv_send_item (pl, op);
1460 1470
1461 /* If this object glows, it may affect lighting conditions that are 1471 /* If this object glows, it may affect lighting conditions that are
1462 * 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
1463 * 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
1464 * on the map will get recalculated. The players could very well 1474 * on the map will get recalculated. The players could very well
2565 &name, 2575 &name,
2566 title ? "\",title:\"" : "", 2576 title ? "\",title:\"" : "",
2567 title ? (const char *)title : "", 2577 title ? (const char *)title : "",
2568 flag_desc (flagdesc, 512), type); 2578 flag_desc (flagdesc, 512), type);
2569 2579
2570 if (!this->flag[FLAG_REMOVED] && env) 2580 if (!flag[FLAG_REMOVED] && env)
2571 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); 2581 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2572 2582
2573 if (map) 2583 if (map)
2574 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); 2584 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y);
2575 2585
2617 if (object *closer = old_container->inv) 2627 if (object *closer = old_container->inv)
2618 if (closer->type == CLOSE_CON) 2628 if (closer->type == CLOSE_CON)
2619 closer->destroy (); 2629 closer->destroy ();
2620#endif 2630#endif
2621 2631
2622 old_container->flag [FLAG_APPLIED] = 0; 2632 old_container->flag [FLAG_APPLIED] = false;
2623 container = 0; 2633 container = 0;
2624 2634
2625 esrv_update_item (UPD_FLAGS, this, old_container); 2635 esrv_update_item (UPD_FLAGS, this, old_container);
2626 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); 2636 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container));
2627 play_sound (sound_find ("chest_close")); 2637 play_sound (sound_find ("chest_close"));
2643 } 2653 }
2644#endif 2654#endif
2645 2655
2646 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); 2656 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container));
2647 2657
2648 new_container->flag [FLAG_APPLIED] = 1; 2658 new_container->flag [FLAG_APPLIED] = true;
2649 container = new_container; 2659 container = new_container;
2650 2660
2651 esrv_update_item (UPD_FLAGS, this, new_container); 2661 esrv_update_item (UPD_FLAGS, this, new_container);
2652 esrv_send_inventory (this, new_container); 2662 esrv_send_inventory (this, new_container);
2653 play_sound (sound_find ("chest_open")); 2663 play_sound (sound_find ("chest_open"));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines