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.222 by root, Wed Apr 30 05:06:36 2008 UTC vs.
Revision 1.226 by root, Sat May 3 08:50:30 2008 UTC

606} 606}
607 607
608object & 608object &
609object::operator =(const object &src) 609object::operator =(const object &src)
610{ 610{
611 bool is_freed = flag [FLAG_FREED]; 611 remove ();
612 bool is_removed = flag [FLAG_REMOVED];
613 612
614 *(object_copy *)this = src; 613 *(object_copy *)this = src;
615 614
616 flag [FLAG_FREED] = is_freed;
617 flag [FLAG_REMOVED] = is_removed; 615 flag [FLAG_REMOVED] = true;
618 616
619 /* Copy over key_values, if any. */ 617 /* Copy over key_values, if any. */
620 if (src.key_values) 618 if (src.key_values)
621 { 619 {
622 key_value *tail = 0; 620 key_value *tail = 0;
686object * 684object *
687object::clone () 685object::clone ()
688{ 686{
689 object *neu = create (); 687 object *neu = create ();
690 copy_to (neu); 688 copy_to (neu);
689 neu->map = map; // not copied by copy_to
691 return neu; 690 return neu;
692} 691}
693 692
694/* 693/*
695 * If an object with the IS_TURNABLE() flag needs to be turned due 694 * If an object with the IS_TURNABLE() flag needs to be turned due
959 object *op = new object; 958 object *op = new object;
960 op->link (); 959 op->link ();
961 return op; 960 return op;
962} 961}
963 962
963static struct freed_map : maptile
964{
965 freed_map ()
966 {
967 path = "<freed objects map>";
968 name = "/internal/freed_objects_map";
969 width = 3;
970 height = 3;
971 nodrop = 1;
972
973 alloc ();
974 in_memory = MAP_ACTIVE;
975 }
976} freed_map; // freed objects are moved here to avoid crashes
977
964void 978void
965object::do_destroy () 979object::do_destroy ()
966{ 980{
967 if (flag [FLAG_IS_LINKED]) 981 if (flag [FLAG_IS_LINKED])
968 remove_button_link (this); 982 remove_button_link (this);
978 unlink (); 992 unlink ();
979 993
980 flag [FLAG_FREED] = 1; 994 flag [FLAG_FREED] = 1;
981 995
982 // hack to ensure that freed objects still have a valid map 996 // hack to ensure that freed objects still have a valid map
983 {
984 static maptile *freed_map; // freed objects are moved here to avoid crashes
985
986 if (!freed_map)
987 {
988 freed_map = new maptile;
989
990 freed_map->path = "<freed objects map>";
991 freed_map->name = "/internal/freed_objects_map";
992 freed_map->width = 3;
993 freed_map->height = 3;
994 freed_map->nodrop = 1;
995
996 freed_map->alloc ();
997 freed_map->in_memory = MAP_ACTIVE;
998 }
999
1000 map = freed_map; 997 map = &freed_map;
1001 x = 1; 998 x = 1;
1002 y = 1; 999 y = 1;
1003 }
1004 1000
1005 if (more) 1001 if (more)
1006 { 1002 {
1007 more->destroy (); 1003 more->destroy ();
1008 more = 0; 1004 more = 0;
1025 1021
1026 if (!is_head () && !head->destroyed ()) 1022 if (!is_head () && !head->destroyed ())
1027 { 1023 {
1028 LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); 1024 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1029 head->destroy (destroy_inventory); 1025 head->destroy (destroy_inventory);
1026 return;
1030 } 1027 }
1031 1028
1032 destroy_inv (!destroy_inventory); 1029 destroy_inv (!destroy_inventory);
1033 1030
1034 if (is_head ()) 1031 if (is_head ())
1163 * appropriately. 1160 * appropriately.
1164 */ 1161 */
1165 pl->close_container (); 1162 pl->close_container ();
1166 1163
1167 //TODO: the floorbox prev/next might need updating 1164 //TODO: the floorbox prev/next might need updating
1168 esrv_del_item (pl->contr, count); 1165 //esrv_del_item (pl->contr, count);
1166 //TODO: update floorbox to preserve ordering
1167 if (pl->contr->ns)
1168 pl->contr->ns->floorbox_update ();
1169 } 1169 }
1170 1170
1171 for (tmp = ms.bot; tmp; tmp = tmp->above) 1171 for (tmp = ms.bot; tmp; tmp = tmp->above)
1172 { 1172 {
1173 /* No point updating the players look faces if he is the object 1173 /* No point updating the players look faces if he is the object
1471 1471
1472 op->map->dirty = true; 1472 op->map->dirty = true;
1473 1473
1474 if (object *pl = ms.player ()) 1474 if (object *pl = ms.player ())
1475 //TODO: the floorbox prev/next might need updating 1475 //TODO: the floorbox prev/next might need updating
1476 esrv_send_item (pl, op); 1476 //esrv_send_item (pl, op);
1477 //TODO: update floorbox to preserve ordering
1478 if (pl->contr->ns)
1479 pl->contr->ns->floorbox_update ();
1477 1480
1478 /* If this object glows, it may affect lighting conditions that are 1481 /* If this object glows, it may affect lighting conditions that are
1479 * visible to others on this map. But update_all_los is really 1482 * visible to others on this map. But update_all_los is really
1480 * an inefficient way to do this, as it means los for all players 1483 * an inefficient way to do this, as it means los for all players
1481 * on the map will get recalculated. The players could very well 1484 * on the map will get recalculated. The players could very well
2328 * create clone from object to another 2331 * create clone from object to another
2329 */ 2332 */
2330object * 2333object *
2331object_create_clone (object *asrc) 2334object_create_clone (object *asrc)
2332{ 2335{
2333 object *dst = 0, *tmp, *src, *prev, *item; 2336 object *dst = 0;
2334 2337
2335 if (!asrc) 2338 if (!asrc)
2336 return 0; 2339 return 0;
2337 2340
2338 src = asrc->head_ (); 2341 object *src = asrc->head_ ();
2339 2342
2340 prev = 0; 2343 object *prev = 0;
2341 for (object *part = src; part; part = part->more) 2344 for (object *part = src; part; part = part->more)
2342 { 2345 {
2343 tmp = part->clone (); 2346 object *tmp = part->clone ();
2347
2344 tmp->x -= src->x; 2348 tmp->x -= src->x;
2345 tmp->y -= src->y; 2349 tmp->y -= src->y;
2346 2350
2347 if (!part->head) 2351 if (!part->head)
2348 { 2352 {
2358 prev->more = tmp; 2362 prev->more = tmp;
2359 2363
2360 prev = tmp; 2364 prev = tmp;
2361 } 2365 }
2362 2366
2363 for (item = src->inv; item; item = item->below) 2367 for (object *item = src->inv; item; item = item->below)
2364 insert_ob_in_ob (object_create_clone (item), dst); 2368 insert_ob_in_ob (object_create_clone (item), dst);
2365 2369
2366 return dst; 2370 return dst;
2367} 2371}
2368 2372

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines