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.344 by root, Sun May 1 13:18:23 2011 UTC vs.
Revision 1.349 by root, Sun May 8 11:44:43 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 ();
1015 path = "<freed objects map>"; 1015 path = "<freed objects map>";
1016 name = "/internal/freed_objects_map"; 1016 name = "/internal/freed_objects_map";
1017 no_drop = 1; 1017 no_drop = 1;
1018 no_reset = 1; 1018 no_reset = 1;
1019 1019
1020 in_memory = MAP_ACTIVE; 1020 state = MAP_ACTIVE;
1021 } 1021 }
1022 1022
1023 ~freed_map () 1023 ~freed_map ()
1024 { 1024 {
1025 destroy (); 1025 destroy ();
1198 1198
1199 above = 0; 1199 above = 0;
1200 below = 0; 1200 below = 0;
1201 1201
1202 ms.invalidate (); 1202 ms.invalidate ();
1203
1204 if (map->in_memory == MAP_SAVING)
1205 return;
1206 1203
1207 int check_walk_off = !flag [FLAG_NO_APPLY]; 1204 int check_walk_off = !flag [FLAG_NO_APPLY];
1208 1205
1209 if (object *pl = ms.player ()) 1206 if (object *pl = ms.player ())
1210 { 1207 {
1345{ 1342{
1346 op->remove (); 1343 op->remove ();
1347 1344
1348 if (m == &freed_map)//D TODO: remove soon 1345 if (m == &freed_map)//D TODO: remove soon
1349 {//D 1346 {//D
1350 LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D 1347 LOG (llevError | logBacktrace, "tries to insert object on freed objects map: %s", op->debug_desc ());//D
1351 }//D 1348 }//D
1352 1349
1353 /* Ideally, the caller figures this out. However, it complicates a lot 1350 /* Ideally, the caller figures this out. However, it complicates a lot
1354 * of areas of callers (eg, anything that uses find_free_spot would now 1351 * of areas of callers (eg, anything that uses find_free_spot would now
1355 * need extra work 1352 * need extra work
2413 return /*who->flag [FLAG_WIZ]|| */ 2410 return /*who->flag [FLAG_WIZ]|| */
2414 (item->weight > 0 && !item->flag [FLAG_NO_PICK] && 2411 (item->weight > 0 && !item->flag [FLAG_NO_PICK] &&
2415 !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); 2412 !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3));
2416} 2413}
2417 2414
2415//-GPL
2416
2418/* 2417/*
2419 * create clone from object to another 2418 * create clone from object to another
2420 */ 2419 */
2421object * 2420object *
2422object::deep_clone () 2421object::deep_clone ()
2634object::region () const 2633object::region () const
2635{ 2634{
2636 return map ? map->region (x, y) 2635 return map ? map->region (x, y)
2637 : region::default_region (); 2636 : region::default_region ();
2638} 2637}
2638
2639//+GPL
2639 2640
2640void 2641void
2641object::open_container (object *new_container) 2642object::open_container (object *new_container)
2642{ 2643{
2643 if (container == new_container) 2644 if (container == new_container)
2701 } 2702 }
2702// else if (!old_container->env && contr && contr->ns) 2703// else if (!old_container->env && contr && contr->ns)
2703// contr->ns->floorbox_reset (); 2704// contr->ns->floorbox_reset ();
2704} 2705}
2705 2706
2707//-GPL
2708
2709// prefetch some flat area around the player
2710static void
2711prefetch_surrounding_area (object *op, maptile *map, int range)
2712{
2713 for (maprect *rect = map->split_to_tiles (mapwalk_buf,
2714 op->x - range , op->y - range ,
2715 op->x + range + 1, op->y + range + 1);
2716 rect->m;
2717 ++rect)
2718 {
2719 rect->m->touch ();
2720 rect->m->activate ();
2721 }
2722}
2723
2724// prefetch a generous area around the player, also up and down
2725void
2726object::prefetch_surrounding_maps ()
2727{
2728 prefetch_surrounding_area (this, map, 40);
2729
2730 if (maptile *m = map->tile_available (TILE_DOWN))
2731 prefetch_surrounding_area (this, m, 20);
2732
2733 if (maptile *m = map->tile_available (TILE_UP))
2734 prefetch_surrounding_area (this, m, 20);
2735}
2736
2737//+GPL
2738
2706object * 2739object *
2707object::force_find (shstr_tmp name) 2740object::force_find (shstr_tmp name)
2708{ 2741{
2709 /* cycle through his inventory to look for the MARK we want to 2742 /* cycle through his inventory to look for the MARK we want to
2710 * place 2743 * place
2714 return splay (tmp); 2747 return splay (tmp);
2715 2748
2716 return 0; 2749 return 0;
2717} 2750}
2718 2751
2719//-GPL
2720
2721void 2752void
2722object::force_set_timer (int duration) 2753object::force_set_timer (int duration)
2723{ 2754{
2724 this->duration = 1; 2755 this->duration = 1;
2725 this->speed_left = -1.f; 2756 this->speed_left = -1.f;
2731object::force_add (shstr_tmp name, int duration) 2762object::force_add (shstr_tmp name, int duration)
2732{ 2763{
2733 if (object *force = force_find (name)) 2764 if (object *force = force_find (name))
2734 force->destroy (); 2765 force->destroy ();
2735 2766
2736 object *force = get_archetype (FORCE_NAME); 2767 object *force = archetype::get (FORCE_NAME);
2737 2768
2738 force->slaying = name; 2769 force->slaying = name;
2739 force->force_set_timer (duration); 2770 force->force_set_timer (duration);
2740 force->flag [FLAG_APPLIED] = true; 2771 force->flag [FLAG_APPLIED] = true;
2741 2772

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines