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.139 by root, Sun May 4 19:14:23 2008 UTC vs.
Revision 1.148 by root, Mon Sep 29 10:31:32 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 }
923 destroy = 1; 930 destroy = 1;
924 } 931 }
925 932
926 /* adjust overall chance below */ 933 /* adjust overall chance below */
927 if (destroy && rndm (0, 1)) 934 if (destroy && rndm (0, 1))
928 op->destroy (); 935 op->destroy (true);
929 } 936 }
930} 937}
931 938
932/* 939/*
933 * Updates every button on the map (by calling update_button() for them). 940 * Updates every button on the map (by calling update_button() for them).
981 988
982 if (QUERY_FLAG (op, FLAG_GENERATOR)) 989 if (QUERY_FLAG (op, FLAG_GENERATOR))
983 { 990 {
984 total_exp += op->stats.exp; 991 total_exp += op->stats.exp;
985 992
986 if (archetype *at = type_to_archetype (GENERATE_TYPE (op))) 993 if (archetype *at = op->other_arch)
994 {
987 total_exp += at->stats.exp * 8; 995 total_exp += at->stats.exp * 8;
988
989 monster_cnt++; 996 monster_cnt++;
997 }
998
999 for (object *inv = op->inv; inv; inv = inv->below)
1000 {
1001 total_exp += op->stats.exp * 8;
1002 monster_cnt++;
1003 }
990 } 1004 }
991 } 1005 }
992 1006
993 avgexp = (double) total_exp / monster_cnt; 1007 avgexp = (double) total_exp / monster_cnt;
994 1008
1033 else 1047 else
1034 darkness = new_level; 1048 darkness = new_level;
1035 1049
1036 /* All clients need to get re-updated for the change */ 1050 /* All clients need to get re-updated for the change */
1037 update_all_map_los (this); 1051 update_all_map_los (this);
1052
1038 return 1; 1053 return 1;
1039} 1054}
1040 1055
1041/* 1056/*
1042 * This function updates various attributes about a specific space 1057 * This function updates various attributes about a specific space
1045 * through, etc) 1060 * through, etc)
1046 */ 1061 */
1047void 1062void
1048mapspace::update_ () 1063mapspace::update_ ()
1049{ 1064{
1050 object *tmp, *last = 0; 1065 object *last = 0;
1051 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1066 uint8 flags = P_UPTODATE, light = 0, anywhere = 0;
1052 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1067 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1053 1068
1054 //object *middle = 0; 1069 //object *middle = 0;
1055 //object *top = 0; 1070 //object *top = 0;
1057 // this seems to generate better code than using locals, above 1072 // this seems to generate better code than using locals, above
1058 object *&top = faces_obj[0] = 0; 1073 object *&top = faces_obj[0] = 0;
1059 object *&middle = faces_obj[1] = 0; 1074 object *&middle = faces_obj[1] = 0;
1060 object *&floor = faces_obj[2] = 0; 1075 object *&floor = faces_obj[2] = 0;
1061 1076
1062 for (tmp = bot; tmp; last = tmp, tmp = tmp->above) 1077 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1063 { 1078 {
1064 /* This could be made additive I guess (two lights better than 1079 /* This could be made additive I guess (two lights better than
1065 * one). But if so, it shouldn't be a simple additive - 2 1080 * one). But if so, it shouldn't be a simple additive - 2
1066 * light bulbs do not illuminate twice as far as once since 1081 * light bulbs do not illuminate twice as far as once since
1067 * it is a dissapation factor that is cubed. 1082 * it is a dissapation factor that is cubed.
1093 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) 1108 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE))
1094 { 1109 {
1095 middle = tmp; 1110 middle = tmp;
1096 anywhere = 1; 1111 anywhere = 1;
1097 } 1112 }
1113
1098 /* Find the highest visible face around. If equal 1114 /* Find the highest visible face around. If equal
1099 * visibilities, we still want the one nearer to the 1115 * visibilities, we still want the one nearer to the
1100 * top 1116 * top
1101 */ 1117 */
1102 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) 1118 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere))
1151 * 1) top face is set, need middle to be set. 1167 * 1) top face is set, need middle to be set.
1152 * 2) middle is set, need to set top. 1168 * 2) middle is set, need to set top.
1153 * 3) neither middle or top is set - need to set both. 1169 * 3) neither middle or top is set - need to set both.
1154 */ 1170 */
1155 1171
1156 for (tmp = last; tmp; tmp = tmp->below) 1172 for (object *tmp = last; tmp; tmp = tmp->below)
1157 { 1173 {
1158 /* Once we get to a floor, stop, since we already have a floor object */ 1174 /* Once we get to a floor, stop, since we already have a floor object */
1159 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1175 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1160 break; 1176 break;
1161 1177
1564} 1580}
1565 1581
1566object * 1582object *
1567maptile::insert (object *op, int x, int y, object *originator, int flags) 1583maptile::insert (object *op, int x, int y, object *originator, int flags)
1568{ 1584{
1569 if (!op->flag [FLAG_REMOVED])
1570 op->remove ();
1571
1572 return insert_ob_in_map_at (op, this, originator, flags, x, y); 1585 return insert_ob_in_map_at (op, this, originator, flags, x, y);
1573} 1586}
1574 1587
1575region * 1588region *
1576maptile::region (int x, int y) const 1589maptile::region (int x, int y) const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines