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.147 by root, Mon Sep 29 10:20:48 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 */
340 ms.flags_ = 0; 351 ms.flags_ = 0;
341 } 352 }
342 else 353 else
343 { 354 {
344 f.parse_warn (format ("object %s out of range", op->debug_desc ())); 355 f.parse_warn (format ("object %s out of range", op->debug_desc ()));
356 op->destroy_inv (false); // be explicit about dropping
345 op->destroy (); 357 op->destroy (true);
346 } 358 }
347 } 359 }
348 360
349 continue; 361 continue;
350 362
641 case KW_sky: thawer.get (sky); break; 653 case KW_sky: thawer.get (sky); break;
642 654
643 case KW_per_player: thawer.get (per_player); break; 655 case KW_per_player: thawer.get (per_player); break;
644 case KW_per_party: thawer.get (per_party); break; 656 case KW_per_party: thawer.get (per_party); break;
645 case KW_no_reset: thawer.get (no_reset); break; 657 case KW_no_reset: thawer.get (no_reset); break;
658 case KW_no_drop: thawer.get (no_drop); break;
646 659
647 case KW_region: default_region = region::find (thawer.get_str ()); break; 660 case KW_region: default_region = region::find (thawer.get_str ()); break;
648 case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; 661 case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break;
649 662
650 // old names new names 663 // old names new names
702 unique = 1; 715 unique = 1;
703 716
704 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 717 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
705 { 718 {
706 op->destroy_inv (false); 719 op->destroy_inv (false);
707 op->destroy (); 720 op->destroy (true);
708 } 721 }
709 722
710 op = above; 723 op = above;
711 } 724 }
712 } 725 }
724 MAP_OUT (swap_time); 737 MAP_OUT (swap_time);
725 MAP_OUT (reset_time); 738 MAP_OUT (reset_time);
726 MAP_OUT (reset_timeout); 739 MAP_OUT (reset_timeout);
727 MAP_OUT (fixed_resettime); 740 MAP_OUT (fixed_resettime);
728 MAP_OUT (no_reset); 741 MAP_OUT (no_reset);
742 MAP_OUT (no_drop);
729 MAP_OUT (difficulty); 743 MAP_OUT (difficulty);
730 744
731 if (default_region) MAP_OUT2 (region, default_region->name); 745 if (default_region) MAP_OUT2 (region, default_region->name);
732 746
733 if (shopitems) 747 if (shopitems)
802 816
803 object *head = op->head_ (); 817 object *head = op->head_ ();
804 if (op == head) 818 if (op == head)
805 { 819 {
806 op->destroy_inv (false); 820 op->destroy_inv (false);
807 op->destroy (); 821 op->destroy (true);
808 } 822 }
809 else if (head->map != op->map) 823 else if (head->map != op->map)
810 { 824 {
811 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); 825 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ());
812 head->destroy (); 826 head->destroy (true);
813 } 827 }
814 } 828 }
815 829
816 sfree0 (spaces, size ()); 830 sfree0 (spaces, size ());
817 } 831 }
923 destroy = 1; 937 destroy = 1;
924 } 938 }
925 939
926 /* adjust overall chance below */ 940 /* adjust overall chance below */
927 if (destroy && rndm (0, 1)) 941 if (destroy && rndm (0, 1))
928 op->destroy (); 942 op->destroy (true);
929 } 943 }
930} 944}
931 945
932/* 946/*
933 * Updates every button on the map (by calling update_button() for them). 947 * Updates every button on the map (by calling update_button() for them).
1040 else 1054 else
1041 darkness = new_level; 1055 darkness = new_level;
1042 1056
1043 /* All clients need to get re-updated for the change */ 1057 /* All clients need to get re-updated for the change */
1044 update_all_map_los (this); 1058 update_all_map_los (this);
1059
1045 return 1; 1060 return 1;
1046} 1061}
1047 1062
1048/* 1063/*
1049 * This function updates various attributes about a specific space 1064 * This function updates various attributes about a specific space
1052 * through, etc) 1067 * through, etc)
1053 */ 1068 */
1054void 1069void
1055mapspace::update_ () 1070mapspace::update_ ()
1056{ 1071{
1057 object *tmp, *last = 0; 1072 object *last = 0;
1058 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1073 uint8 flags = P_UPTODATE, light = 0, anywhere = 0;
1059 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1074 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1060 1075
1061 //object *middle = 0; 1076 //object *middle = 0;
1062 //object *top = 0; 1077 //object *top = 0;
1064 // this seems to generate better code than using locals, above 1079 // this seems to generate better code than using locals, above
1065 object *&top = faces_obj[0] = 0; 1080 object *&top = faces_obj[0] = 0;
1066 object *&middle = faces_obj[1] = 0; 1081 object *&middle = faces_obj[1] = 0;
1067 object *&floor = faces_obj[2] = 0; 1082 object *&floor = faces_obj[2] = 0;
1068 1083
1069 for (tmp = bot; tmp; last = tmp, tmp = tmp->above) 1084 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1070 { 1085 {
1071 /* This could be made additive I guess (two lights better than 1086 /* This could be made additive I guess (two lights better than
1072 * one). But if so, it shouldn't be a simple additive - 2 1087 * one). But if so, it shouldn't be a simple additive - 2
1073 * light bulbs do not illuminate twice as far as once since 1088 * light bulbs do not illuminate twice as far as once since
1074 * it is a dissapation factor that is cubed. 1089 * it is a dissapation factor that is cubed.
1100 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) 1115 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE))
1101 { 1116 {
1102 middle = tmp; 1117 middle = tmp;
1103 anywhere = 1; 1118 anywhere = 1;
1104 } 1119 }
1120
1105 /* Find the highest visible face around. If equal 1121 /* Find the highest visible face around. If equal
1106 * visibilities, we still want the one nearer to the 1122 * visibilities, we still want the one nearer to the
1107 * top 1123 * top
1108 */ 1124 */
1109 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) 1125 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere))
1158 * 1) top face is set, need middle to be set. 1174 * 1) top face is set, need middle to be set.
1159 * 2) middle is set, need to set top. 1175 * 2) middle is set, need to set top.
1160 * 3) neither middle or top is set - need to set both. 1176 * 3) neither middle or top is set - need to set both.
1161 */ 1177 */
1162 1178
1163 for (tmp = last; tmp; tmp = tmp->below) 1179 for (object *tmp = last; tmp; tmp = tmp->below)
1164 { 1180 {
1165 /* Once we get to a floor, stop, since we already have a floor object */ 1181 /* Once we get to a floor, stop, since we already have a floor object */
1166 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1182 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1167 break; 1183 break;
1168 1184
1571} 1587}
1572 1588
1573object * 1589object *
1574maptile::insert (object *op, int x, int y, object *originator, int flags) 1590maptile::insert (object *op, int x, int y, object *originator, int flags)
1575{ 1591{
1576 if (!op->flag [FLAG_REMOVED])
1577 op->remove ();
1578
1579 return insert_ob_in_map_at (op, this, originator, flags, x, y); 1592 return insert_ob_in_map_at (op, this, originator, flags, x, y);
1580} 1593}
1581 1594
1582region * 1595region *
1583maptile::region (int x, int y) const 1596maptile::region (int x, int y) const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines