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.345 by root, Sun May 1 16:58:15 2011 UTC vs.
Revision 1.350 by root, Sun May 8 12:40:41 2011 UTC

737 } 737 }
738 738
739 mapspace &m = op->ms (); 739 mapspace &m = op->ms ();
740 740
741 if (!(m.flags_ & P_UPTODATE)) 741 if (!(m.flags_ & P_UPTODATE))
742 /* nop */; 742 m.update_up (); // nothing to do except copy up
743 else if (action == UP_OBJ_INSERT) 743 else if (action == UP_OBJ_INSERT)
744 { 744 {
745#if 0 745#if 0
746 // this is likely overkill, TODO: revisit (schmorp) 746 // this is likely overkill, TODO: revisit (schmorp)
747 if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW)) 747 if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW))
768 * that is being removed. 768 * that is being removed.
769 */ 769 */
770 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) 770 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE)
771 m.invalidate (); 771 m.invalidate ();
772 else if (action == UP_OBJ_FACE) 772 else if (action == UP_OBJ_FACE)
773 /* Nothing to do for that case */ ; 773 m.update_up (); // nothing to do for that case, except copy up
774 else 774 else
775 LOG (llevError, "update_object called with invalid action: %d\n", action); 775 LOG (llevError, "update_object called with invalid action: %d\n", action);
776 776
777 if (op->more) 777 if (op->more)
778 update_object (op->more, action); 778 update_object (op->more, action);
898 * if some form of movement is allowed, let objects 898 * if some form of movement is allowed, let objects
899 * drop on that space. 899 * drop on that space.
900 */ 900 */
901 if (!drop_to_ground 901 if (!drop_to_ground
902 || !map 902 || !map
903 || map->in_memory != MAP_ACTIVE 903 || !map->linkable ()
904 || map->no_drop 904 || map->no_drop
905 || ms ().move_block == MOVE_ALL) 905 || ms ().move_block == MOVE_ALL)
906 { 906 {
907 while (inv) 907 while (inv)
908 inv->destroy (); 908 inv->destroy ();
1005 1005
1006 freelist = li; 1006 freelist = li;
1007 ++free_count; 1007 ++free_count;
1008} 1008}
1009 1009
1010// special "grave" map used to store all removed objects
1011// till they can be destroyed - saves a lot of checks in the rest
1012// of the code
1010static struct freed_map : maptile 1013static struct freed_map
1014: maptile
1011{ 1015{
1012 freed_map () 1016 freed_map ()
1013 : maptile (3, 3) 1017 : maptile (3, 3)
1014 { 1018 {
1015 path = "<freed objects map>"; 1019 path = "<freed objects map>";
1016 name = "/internal/freed_objects_map"; 1020 name = "/internal/freed_objects_map";
1017 no_drop = 1; 1021 no_drop = 1;
1018 no_reset = 1; 1022 no_reset = 1;
1019 1023
1020 in_memory = MAP_ACTIVE; 1024 state = MAP_ACTIVE;
1021 } 1025 }
1022 1026
1023 ~freed_map () 1027 ~freed_map ()
1024 { 1028 {
1025 destroy (); 1029 destroy ();
1198 1202
1199 above = 0; 1203 above = 0;
1200 below = 0; 1204 below = 0;
1201 1205
1202 ms.invalidate (); 1206 ms.invalidate ();
1203
1204 if (map->in_memory == MAP_SAVING)
1205 return;
1206 1207
1207 int check_walk_off = !flag [FLAG_NO_APPLY]; 1208 int check_walk_off = !flag [FLAG_NO_APPLY];
1208 1209
1209 if (object *pl = ms.player ()) 1210 if (object *pl = ms.player ())
1210 { 1211 {
2413 return /*who->flag [FLAG_WIZ]|| */ 2414 return /*who->flag [FLAG_WIZ]|| */
2414 (item->weight > 0 && !item->flag [FLAG_NO_PICK] && 2415 (item->weight > 0 && !item->flag [FLAG_NO_PICK] &&
2415 !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); 2416 !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3));
2416} 2417}
2417 2418
2419//-GPL
2420
2418/* 2421/*
2419 * create clone from object to another 2422 * create clone from object to another
2420 */ 2423 */
2421object * 2424object *
2422object::deep_clone () 2425object::deep_clone ()
2634object::region () const 2637object::region () const
2635{ 2638{
2636 return map ? map->region (x, y) 2639 return map ? map->region (x, y)
2637 : region::default_region (); 2640 : region::default_region ();
2638} 2641}
2642
2643//+GPL
2639 2644
2640void 2645void
2641object::open_container (object *new_container) 2646object::open_container (object *new_container)
2642{ 2647{
2643 if (container == new_container) 2648 if (container == new_container)
2701 } 2706 }
2702// else if (!old_container->env && contr && contr->ns) 2707// else if (!old_container->env && contr && contr->ns)
2703// contr->ns->floorbox_reset (); 2708// contr->ns->floorbox_reset ();
2704} 2709}
2705 2710
2711//-GPL
2712
2713// prefetch some flat area around the player
2714static void
2715prefetch_surrounding_area (object *op, maptile *map, int range)
2716{
2717 for (maprect *rect = map->split_to_tiles (mapwalk_buf,
2718 op->x - range , op->y - range ,
2719 op->x + range + 1, op->y + range + 1);
2720 rect->m;
2721 ++rect)
2722 {
2723 rect->m->touch ();
2724 rect->m->activate ();
2725 }
2726}
2727
2728// prefetch a generous area around the player, also up and down
2729void
2730object::prefetch_surrounding_maps ()
2731{
2732 prefetch_surrounding_area (this, map, 40);
2733
2734 if (maptile *m = map->tile_available (TILE_DOWN))
2735 prefetch_surrounding_area (this, m, 20);
2736
2737 if (maptile *m = map->tile_available (TILE_UP))
2738 prefetch_surrounding_area (this, m, 20);
2739}
2740
2741//+GPL
2742
2706object * 2743object *
2707object::force_find (shstr_tmp name) 2744object::force_find (shstr_tmp name)
2708{ 2745{
2709 /* cycle through his inventory to look for the MARK we want to 2746 /* cycle through his inventory to look for the MARK we want to
2710 * place 2747 * place
2714 return splay (tmp); 2751 return splay (tmp);
2715 2752
2716 return 0; 2753 return 0;
2717} 2754}
2718 2755
2719//-GPL
2720
2721void 2756void
2722object::force_set_timer (int duration) 2757object::force_set_timer (int duration)
2723{ 2758{
2724 this->duration = 1; 2759 this->duration = 1;
2725 this->speed_left = -1.f; 2760 this->speed_left = -1.f;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines