ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.140 by root, Sun May 4 20:40:52 2008 UTC vs.
Revision 1.150 by root, Thu Dec 4 03:48:19 2008 UTC

22 */ 22 */
23 23
24#include <unistd.h> 24#include <unistd.h>
25 25
26#include "global.h" 26#include "global.h"
27
28#include "loader.h" 27#include "loader.h"
29
30#include "path.h" 28#include "path.h"
31 29
32/* This rolls up wall, blocks_magic, blocks_view, etc, all into 30/* This rolls up wall, blocks_magic, blocks_view, etc, all into
33 * one function that just returns a P_.. value (see map.h) 31 * one function that just returns a P_.. value (see map.h)
34 * it will also do map translation for tiled maps, returning 32 * it will also do map translation for tiled maps, returning
260 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 258 for (mapspace *ms = spaces + size (); ms-- > spaces; )
261 for (object *tmp = ms->bot; tmp; tmp = tmp->above) 259 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
262 tmp->flag [flag] = value; 260 tmp->flag [flag] = value;
263} 261}
264 262
263void
264maptile::post_load_original ()
265{
266 if (!spaces)
267 return;
268
269 set_object_flag (FLAG_OBJ_ORIGINAL);
270
271 for (mapspace *ms = spaces + size (); ms-- > spaces; )
272 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
273 INVOKE_OBJECT (RESET, tmp);
274}
275
265/* link_multipart_objects go through all the objects on the map looking 276/* link_multipart_objects go through all the objects on the map looking
266 * for objects whose arch says they are multipart yet according to the 277 * for objects whose arch says they are multipart yet according to the
267 * info we have, they only have the head (as would be expected when 278 * info we have, they only have the head (as would be expected when
268 * they are saved). 279 * they are saved).
269 */ 280 */
641 case KW_sky: thawer.get (sky); break; 652 case KW_sky: thawer.get (sky); break;
642 653
643 case KW_per_player: thawer.get (per_player); break; 654 case KW_per_player: thawer.get (per_player); break;
644 case KW_per_party: thawer.get (per_party); break; 655 case KW_per_party: thawer.get (per_party); break;
645 case KW_no_reset: thawer.get (no_reset); break; 656 case KW_no_reset: thawer.get (no_reset); break;
657 case KW_no_drop: thawer.get (no_drop); break;
646 658
647 case KW_region: default_region = region::find (thawer.get_str ()); break; 659 case KW_region: default_region = region::find (thawer.get_str ()); break;
648 case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; 660 case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break;
649 661
650 // old names new names 662 // old names new names
700 712
701 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) 713 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE))
702 unique = 1; 714 unique = 1;
703 715
704 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 716 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
705 {
706 op->destroy_inv (false);
707 op->destroy (); 717 op->destroy ();
708 }
709 718
710 op = above; 719 op = above;
711 } 720 }
712 } 721 }
713} 722}
724 MAP_OUT (swap_time); 733 MAP_OUT (swap_time);
725 MAP_OUT (reset_time); 734 MAP_OUT (reset_time);
726 MAP_OUT (reset_timeout); 735 MAP_OUT (reset_timeout);
727 MAP_OUT (fixed_resettime); 736 MAP_OUT (fixed_resettime);
728 MAP_OUT (no_reset); 737 MAP_OUT (no_reset);
738 MAP_OUT (no_drop);
729 MAP_OUT (difficulty); 739 MAP_OUT (difficulty);
730 740
731 if (default_region) MAP_OUT2 (region, default_region->name); 741 if (default_region) MAP_OUT2 (region, default_region->name);
732 742
733 if (shopitems) 743 if (shopitems)
800 810
801 op->flag [FLAG_REMOVED] = true; 811 op->flag [FLAG_REMOVED] = true;
802 812
803 object *head = op->head_ (); 813 object *head = op->head_ ();
804 if (op == head) 814 if (op == head)
805 {
806 op->destroy_inv (false);
807 op->destroy (); 815 op->destroy ();
808 }
809 else if (head->map != op->map) 816 else if (head->map != op->map)
810 { 817 {
811 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); 818 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ());
812 head->destroy (); 819 head->destroy ();
813 } 820 }
1040 else 1047 else
1041 darkness = new_level; 1048 darkness = new_level;
1042 1049
1043 /* All clients need to get re-updated for the change */ 1050 /* All clients need to get re-updated for the change */
1044 update_all_map_los (this); 1051 update_all_map_los (this);
1052
1045 return 1; 1053 return 1;
1046} 1054}
1047 1055
1048/* 1056/*
1049 * This function updates various attributes about a specific space 1057 * This function updates various attributes about a specific space
1052 * through, etc) 1060 * through, etc)
1053 */ 1061 */
1054void 1062void
1055mapspace::update_ () 1063mapspace::update_ ()
1056{ 1064{
1057 object *tmp, *last = 0; 1065 object *last = 0;
1058 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1066 uint8 flags = P_UPTODATE, anywhere = 0;
1067 sint8 light = 0;
1059 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1068 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1060 1069
1061 //object *middle = 0; 1070 //object *middle = 0;
1062 //object *top = 0; 1071 //object *top = 0;
1063 //object *floor = 0; 1072 //object *floor = 0;
1064 // this seems to generate better code than using locals, above 1073 // this seems to generate better code than using locals, above
1065 object *&top = faces_obj[0] = 0; 1074 object *&top = faces_obj[0] = 0;
1066 object *&middle = faces_obj[1] = 0; 1075 object *&middle = faces_obj[1] = 0;
1067 object *&floor = faces_obj[2] = 0; 1076 object *&floor = faces_obj[2] = 0;
1068 1077
1069 for (tmp = bot; tmp; last = tmp, tmp = tmp->above) 1078 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1070 { 1079 {
1071 /* This could be made additive I guess (two lights better than 1080 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C)
1072 * one). But if so, it shouldn't be a simple additive - 2
1073 * light bulbs do not illuminate twice as far as once since
1074 * it is a dissapation factor that is cubed.
1075 */
1076 light = max (light, tmp->glow_radius); 1081 light += tmp->glow_radius;
1077 1082
1078 /* This call is needed in order to update objects the player 1083 /* This call is needed in order to update objects the player
1079 * is standing in that have animations (ie, grass, fire, etc). 1084 * is standing in that have animations (ie, grass, fire, etc).
1080 * However, it also causes the look window to be re-drawn 1085 * However, it also causes the look window to be re-drawn
1081 * 3 times each time the player moves, because many of the 1086 * 3 times each time the player moves, because many of the
1100 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) 1105 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE))
1101 { 1106 {
1102 middle = tmp; 1107 middle = tmp;
1103 anywhere = 1; 1108 anywhere = 1;
1104 } 1109 }
1110
1105 /* Find the highest visible face around. If equal 1111 /* Find the highest visible face around. If equal
1106 * visibilities, we still want the one nearer to the 1112 * visibilities, we still want the one nearer to the
1107 * top 1113 * top
1108 */ 1114 */
1109 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) 1115 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere))
1128 if (tmp->type == SAFE_GROUND) flags |= P_SAFE; 1134 if (tmp->type == SAFE_GROUND) flags |= P_SAFE;
1129 if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; 1135 if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE;
1130 if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; 1136 if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC;
1131 } 1137 }
1132 1138
1133 this->light = light; 1139 this->light = min (light, MAX_LIGHT_RADIUS);
1134 this->flags_ = flags; 1140 this->flags_ = flags;
1135 this->move_block = move_block & ~move_allow; 1141 this->move_block = move_block & ~move_allow;
1136 this->move_on = move_on; 1142 this->move_on = move_on;
1137 this->move_off = move_off; 1143 this->move_off = move_off;
1138 this->move_slow = move_slow; 1144 this->move_slow = move_slow;
1158 * 1) top face is set, need middle to be set. 1164 * 1) top face is set, need middle to be set.
1159 * 2) middle is set, need to set top. 1165 * 2) middle is set, need to set top.
1160 * 3) neither middle or top is set - need to set both. 1166 * 3) neither middle or top is set - need to set both.
1161 */ 1167 */
1162 1168
1163 for (tmp = last; tmp; tmp = tmp->below) 1169 for (object *tmp = last; tmp; tmp = tmp->below)
1164 { 1170 {
1165 /* Once we get to a floor, stop, since we already have a floor object */ 1171 /* Once we get to a floor, stop, since we already have a floor object */
1166 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1172 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1167 break; 1173 break;
1168 1174
1571} 1577}
1572 1578
1573object * 1579object *
1574maptile::insert (object *op, int x, int y, object *originator, int flags) 1580maptile::insert (object *op, int x, int y, object *originator, int flags)
1575{ 1581{
1576 if (!op->flag [FLAG_REMOVED])
1577 op->remove ();
1578
1579 return insert_ob_in_map_at (op, this, originator, flags, x, y); 1582 return insert_ob_in_map_at (op, this, originator, flags, x, y);
1580} 1583}
1581 1584
1582region * 1585region *
1583maptile::region (int x, int y) const 1586maptile::region (int x, int y) const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines