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.219 by root, Wed Apr 23 21:09:10 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}
1061 if (flag [FLAG_REMOVED]) 1062 if (flag [FLAG_REMOVED])
1062 return; 1063 return;
1063 1064
1064 INVOKE_OBJECT (REMOVE, this); 1065 INVOKE_OBJECT (REMOVE, this);
1065 1066
1066 if (object *pl = visible_to ())
1067 esrv_del_item (pl->contr, count);
1068
1069 flag [FLAG_REMOVED] = true; 1067 flag [FLAG_REMOVED] = true;
1070 1068
1071 if (more) 1069 if (more)
1072 more->remove (); 1070 more->remove ();
1073 1071
1075 * In this case, the object to be removed is in someones 1073 * In this case, the object to be removed is in someones
1076 * inventory. 1074 * inventory.
1077 */ 1075 */
1078 if (env) 1076 if (env)
1079 { 1077 {
1078 if (object *pl = visible_to ())
1079 esrv_del_item (pl->contr, count);
1080
1080 adjust_weight (env, -total_weight ()); 1081 adjust_weight (env, -total_weight ());
1081 1082
1082 *(above ? &above->below : &env->inv) = below; 1083 *(above ? &above->below : &env->inv) = below;
1083 1084
1084 if (below) 1085 if (below)
1102 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))
1103 otmp->update_stats (); 1104 otmp->update_stats ();
1104 } 1105 }
1105 else if (map) 1106 else if (map)
1106 { 1107 {
1107 if (type == PLAYER)
1108 {
1109 // leaving a spot always closes any open container on the ground
1110 if (container && !container->env)
1111 // this causes spurious floorbox updates, but it ensures
1112 // that the CLOSE event is being sent.
1113 close_container ();
1114
1115 --map->players;
1116 map->touch ();
1117 }
1118
1119 map->dirty = true; 1108 map->dirty = true;
1120 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 }
1121 1132
1122 /* link the object above us */ 1133 /* link the object above us */
1123 if (above) 1134 if (above)
1124 above->below = below; 1135 above->below = below;
1125 else 1136 else
2615object::open_container (object *new_container) 2626object::open_container (object *new_container)
2616{ 2627{
2617 if (container == new_container) 2628 if (container == new_container)
2618 return; 2629 return;
2619 2630
2620 if (object *old_container = container) 2631 object *old_container = container;
2632
2633 if (old_container)
2621 { 2634 {
2622 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) 2635 if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this)))
2623 return; 2636 return;
2624 2637
2625#if 0 2638#if 0
2627 if (object *closer = old_container->inv) 2640 if (object *closer = old_container->inv)
2628 if (closer->type == CLOSE_CON) 2641 if (closer->type == CLOSE_CON)
2629 closer->destroy (); 2642 closer->destroy ();
2630#endif 2643#endif
2631 2644
2645 // make sure the container is available
2646 esrv_send_item (this, old_container);
2647
2632 old_container->flag [FLAG_APPLIED] = false; 2648 old_container->flag [FLAG_APPLIED] = false;
2633 container = 0; 2649 container = 0;
2634 2650
2651 // client needs item update to make it work, client bug requires this to be separate
2635 esrv_update_item (UPD_FLAGS, this, old_container); 2652 esrv_update_item (UPD_FLAGS, this, old_container);
2653
2636 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));
2637 play_sound (sound_find ("chest_close")); 2655 play_sound (sound_find ("chest_close"));
2638 } 2656 }
2639 2657
2640 if (new_container) 2658 if (new_container)
2653 } 2671 }
2654#endif 2672#endif
2655 2673
2656 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));
2657 2675
2676 // make sure the container is available, client bug requires this to be separate
2677 esrv_send_item (this, new_container);
2678
2658 new_container->flag [FLAG_APPLIED] = true; 2679 new_container->flag [FLAG_APPLIED] = true;
2659 container = new_container; 2680 container = new_container;
2660 2681
2682 // client needs flag change
2661 esrv_update_item (UPD_FLAGS, this, new_container); 2683 esrv_update_item (UPD_FLAGS, this, new_container);
2662 esrv_send_inventory (this, new_container); 2684 esrv_send_inventory (this, new_container);
2663 play_sound (sound_find ("chest_open")); 2685 play_sound (sound_find ("chest_open"));
2664 } 2686 }
2687// else if (!old_container->env && contr && contr->ns)
2688// contr->ns->floorbox_reset ();
2665} 2689}
2666 2690
2667object * 2691object *
2668object::force_find (const shstr name) 2692object::force_find (const shstr name)
2669{ 2693{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines