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.220 by root, Thu Apr 24 00:30:52 2008 UTC vs.
Revision 1.223 by root, Wed Apr 30 08:29:31 2008 UTC

746 * UP_OBJ_FACE: only the objects face has changed. 746 * UP_OBJ_FACE: only the objects face has changed.
747 */ 747 */
748void 748void
749update_object (object *op, int action) 749update_object (object *op, int action)
750{ 750{
751 if (op == NULL) 751 if (!op)
752 { 752 {
753 /* this should never happen */ 753 /* this should never happen */
754 LOG (llevDebug, "update_object() called for NULL object.\n"); 754 LOG (llevError | logBacktrace, "update_object() called for NULL object.\n");
755 return; 755 return;
756 } 756 }
757 757
758 if (op->env) 758 if (!op->is_on_map ())
759 { 759 {
760 /* Animation is currently handled by client, so nothing 760 /* Animation is currently handled by client, so nothing
761 * to do in this case. 761 * to do in this case.
762 */ 762 */
763 return; 763 return;
764 } 764 }
765
766 /* If the map is saving, don't do anything as everything is
767 * going to get freed anyways.
768 */
769 if (!op->map || op->map->in_memory == MAP_SAVING)
770 return;
771 765
772 /* make sure the object is within map boundaries */ 766 /* make sure the object is within map boundaries */
773 if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height) 767 if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height)
774 { 768 {
775 LOG (llevError, "update_object() called for object out of map!\n"); 769 LOG (llevError, "update_object() called for object out of map!\n");
965 object *op = new object; 959 object *op = new object;
966 op->link (); 960 op->link ();
967 return op; 961 return op;
968} 962}
969 963
964static struct freed_map : maptile
965{
966 freed_map ()
967 {
968 path = "<freed objects map>";
969 name = "/internal/freed_objects_map";
970 width = 3;
971 height = 3;
972 nodrop = 1;
973
974 alloc ();
975 in_memory = MAP_ACTIVE;
976 }
977} freed_map; // freed objects are moved here to avoid crashes
978
970void 979void
971object::do_destroy () 980object::do_destroy ()
972{ 981{
973 if (flag [FLAG_IS_LINKED]) 982 if (flag [FLAG_IS_LINKED])
974 remove_button_link (this); 983 remove_button_link (this);
984 unlink (); 993 unlink ();
985 994
986 flag [FLAG_FREED] = 1; 995 flag [FLAG_FREED] = 1;
987 996
988 // hack to ensure that freed objects still have a valid map 997 // hack to ensure that freed objects still have a valid map
989 {
990 static maptile *freed_map; // freed objects are moved here to avoid crashes
991
992 if (!freed_map)
993 {
994 freed_map = new maptile;
995
996 freed_map->path = "<freed objects map>";
997 freed_map->name = "/internal/freed_objects_map";
998 freed_map->width = 3;
999 freed_map->height = 3;
1000 freed_map->nodrop = 1;
1001
1002 freed_map->alloc ();
1003 freed_map->in_memory = MAP_ACTIVE;
1004 }
1005
1006 map = freed_map; 998 map = &freed_map;
1007 x = 1; 999 x = 1;
1008 y = 1; 1000 y = 1;
1009 }
1010 1001
1011 if (more) 1002 if (more)
1012 { 1003 {
1013 more->destroy (); 1004 more->destroy ();
1014 more = 0; 1005 more = 0;
1031 1022
1032 if (!is_head () && !head->destroyed ()) 1023 if (!is_head () && !head->destroyed ())
1033 { 1024 {
1034 LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); 1025 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1035 head->destroy (destroy_inventory); 1026 head->destroy (destroy_inventory);
1027 return;
1036 } 1028 }
1037 1029
1038 destroy_inv (!destroy_inventory); 1030 destroy_inv (!destroy_inventory);
1039 1031
1040 if (is_head ()) 1032 if (is_head ())
1073 * In this case, the object to be removed is in someones 1065 * In this case, the object to be removed is in someones
1074 * inventory. 1066 * inventory.
1075 */ 1067 */
1076 if (env) 1068 if (env)
1077 { 1069 {
1070 flag [FLAG_REMOVED] = false; // hack around the issue of visible_to checking flag_removed
1078 if (object *pl = visible_to ()) 1071 if (object *pl = visible_to ())
1079 esrv_del_item (pl->contr, count); 1072 esrv_del_item (pl->contr, count);
1073 flag [FLAG_REMOVED] = true; // hack around the issue of visible_to checking flag_removed
1080 1074
1081 adjust_weight (env, -total_weight ()); 1075 adjust_weight (env, -total_weight ());
1082 1076
1083 *(above ? &above->below : &env->inv) = below; 1077 *(above ? &above->below : &env->inv) = below;
1084 1078

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines