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.218 by root, Wed Apr 23 07:25:54 2008 UTC vs.
Revision 1.220 by root, Thu Apr 24 00:30:52 2008 UTC

334 334
335// find player who can see this object 335// find player who can see this object
336object * 336object *
337object::visible_to () const 337object::visible_to () const
338{ 338{
339 if (!flag [FLAG_REMOVED]) 339 if (client_visible () && !flag [FLAG_REMOVED])
340 { 340 {
341 // see if we are in a container of sorts 341 // see if we are in a container of sorts
342 if (env) 342 if (env)
343 { 343 {
344 // the player inventory itself is always visible 344 // the player inventory itself is always visible
358 else 358 else
359 { 359 {
360 // maybe there is a player standing on the same mapspace 360 // maybe there is a player standing on the same mapspace
361 // this will catch the case where "this" is a player 361 // this will catch the case where "this" is a player
362 if (object *pl = ms ().player ()) 362 if (object *pl = ms ().player ())
363 if (!pl->container || this == pl->container)
363 return pl; 364 return pl;
364 } 365 }
365 } 366 }
366 367
367 return 0; 368 return 0;
368} 369}
1026object::destroy (bool destroy_inventory) 1027object::destroy (bool destroy_inventory)
1027{ 1028{
1028 if (destroyed ()) 1029 if (destroyed ())
1029 return; 1030 return;
1030 1031
1032 if (!is_head () && !head->destroyed ())
1033 {
1034 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1035 head->destroy (destroy_inventory);
1036 }
1037
1031 destroy_inv (!destroy_inventory); 1038 destroy_inv (!destroy_inventory);
1032 1039
1033 if (is_head ()) 1040 if (is_head ())
1034 if (sound_destroy) 1041 if (sound_destroy)
1035 play_sound (sound_destroy); 1042 play_sound (sound_destroy);
1055 if (flag [FLAG_REMOVED]) 1062 if (flag [FLAG_REMOVED])
1056 return; 1063 return;
1057 1064
1058 INVOKE_OBJECT (REMOVE, this); 1065 INVOKE_OBJECT (REMOVE, this);
1059 1066
1060 if (object *pl = visible_to ())
1061 esrv_del_item (pl->contr, count);
1062
1063 flag [FLAG_REMOVED] = true; 1067 flag [FLAG_REMOVED] = true;
1064 1068
1065 if (more) 1069 if (more)
1066 more->remove (); 1070 more->remove ();
1067 1071
1069 * In this case, the object to be removed is in someones 1073 * In this case, the object to be removed is in someones
1070 * inventory. 1074 * inventory.
1071 */ 1075 */
1072 if (env) 1076 if (env)
1073 { 1077 {
1078 if (object *pl = visible_to ())
1079 esrv_del_item (pl->contr, count);
1080
1074 adjust_weight (env, -total_weight ()); 1081 adjust_weight (env, -total_weight ());
1075 1082
1076 *(above ? &above->below : &env->inv) = below; 1083 *(above ? &above->below : &env->inv) = below;
1077 1084
1078 if (below) 1085 if (below)
1096 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1103 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1097 otmp->update_stats (); 1104 otmp->update_stats ();
1098 } 1105 }
1099 else if (map) 1106 else if (map)
1100 { 1107 {
1101 if (type == PLAYER)
1102 {
1103 // leaving a spot always closes any open container on the ground
1104 if (container && !container->env)
1105 // this causes spurious floorbox updates, but it ensures
1106 // that the CLOSE event is being sent.
1107 close_container ();
1108
1109 --map->players;
1110 map->touch ();
1111 }
1112
1113 map->dirty = true; 1108 map->dirty = true;
1114 mapspace &ms = this->ms (); 1109 mapspace &ms = this->ms ();
1110
1111 if (object *pl = ms.player ())
1112 {
1113 if (type == PLAYER) // this == pl(!)
1114 {
1115 // leaving a spot always closes any open container on the ground
1116 if (container && !container->env)
1117 // this causes spurious floorbox updates, but it ensures
1118 // that the CLOSE event is being sent.
1119 close_container ();
1120
1121 --map->players;
1122 map->touch ();
1123 }
1124 else if (pl->container == this)
1125 {
1126 // removing a container should close it
1127 close_container ();
1128 }
1129
1130 esrv_del_item (pl->contr, count);
1131 }
1115 1132
1116 /* link the object above us */ 1133 /* link the object above us */
1117 if (above) 1134 if (above)
1118 above->below = below; 1135 above->below = below;
1119 else 1136 else
2609object::open_container (object *new_container) 2626object::open_container (object *new_container)
2610{ 2627{
2611 if (container == new_container) 2628 if (container == new_container)
2612 return; 2629 return;
2613 2630
2614 if (object *old_container = container) 2631 object *old_container = container;
2632
2633 if (old_container)
2615 { 2634 {
2616 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) 2635 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this)))
2617 return; 2636 return;
2618 2637
2619#if 0 2638#if 0
2621 if (object *closer = old_container->inv) 2640 if (object *closer = old_container->inv)
2622 if (closer->type == CLOSE_CON) 2641 if (closer->type == CLOSE_CON)
2623 closer->destroy (); 2642 closer->destroy ();
2624#endif 2643#endif
2625 2644
2645 // make sure the container is available
2646 esrv_send_item (this, old_container);
2647
2626 old_container->flag [FLAG_APPLIED] = false; 2648 old_container->flag [FLAG_APPLIED] = false;
2627 container = 0; 2649 container = 0;
2628 2650
2651 // client needs item update to make it work, client bug requires this to be separate
2629 esrv_update_item (UPD_FLAGS, this, old_container); 2652 esrv_update_item (UPD_FLAGS, this, old_container);
2653
2630 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); 2654 new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container));
2631 play_sound (sound_find ("chest_close")); 2655 play_sound (sound_find ("chest_close"));
2632 } 2656 }
2633 2657
2634 if (new_container) 2658 if (new_container)
2647 } 2671 }
2648#endif 2672#endif
2649 2673
2650 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); 2674 new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container));
2651 2675
2676 // make sure the container is available, client bug requires this to be separate
2677 esrv_send_item (this, new_container);
2678
2652 new_container->flag [FLAG_APPLIED] = true; 2679 new_container->flag [FLAG_APPLIED] = true;
2653 container = new_container; 2680 container = new_container;
2654 2681
2682 // client needs flag change
2655 esrv_update_item (UPD_FLAGS, this, new_container); 2683 esrv_update_item (UPD_FLAGS, this, new_container);
2656 esrv_send_inventory (this, new_container); 2684 esrv_send_inventory (this, new_container);
2657 play_sound (sound_find ("chest_open")); 2685 play_sound (sound_find ("chest_open"));
2658 } 2686 }
2687// else if (!old_container->env && contr && contr->ns)
2688// contr->ns->floorbox_reset ();
2659} 2689}
2660 2690
2661object * 2691object *
2662object::force_find (const shstr name) 2692object::force_find (const shstr name)
2663{ 2693{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines