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.141 by root, Wed May 7 11:02:50 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
703 unique = 1; 715 unique = 1;
704 716
705 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 717 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
706 { 718 {
707 op->destroy_inv (false); 719 op->destroy_inv (false);
708 op->destroy (); 720 op->destroy (true);
709 } 721 }
710 722
711 op = above; 723 op = above;
712 } 724 }
713 } 725 }
804 816
805 object *head = op->head_ (); 817 object *head = op->head_ ();
806 if (op == head) 818 if (op == head)
807 { 819 {
808 op->destroy_inv (false); 820 op->destroy_inv (false);
809 op->destroy (); 821 op->destroy (true);
810 } 822 }
811 else if (head->map != op->map) 823 else if (head->map != op->map)
812 { 824 {
813 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 ());
814 head->destroy (); 826 head->destroy (true);
815 } 827 }
816 } 828 }
817 829
818 sfree0 (spaces, size ()); 830 sfree0 (spaces, size ());
819 } 831 }
925 destroy = 1; 937 destroy = 1;
926 } 938 }
927 939
928 /* adjust overall chance below */ 940 /* adjust overall chance below */
929 if (destroy && rndm (0, 1)) 941 if (destroy && rndm (0, 1))
930 op->destroy (); 942 op->destroy (true);
931 } 943 }
932} 944}
933 945
934/* 946/*
935 * 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).
1042 else 1054 else
1043 darkness = new_level; 1055 darkness = new_level;
1044 1056
1045 /* All clients need to get re-updated for the change */ 1057 /* All clients need to get re-updated for the change */
1046 update_all_map_los (this); 1058 update_all_map_los (this);
1059
1047 return 1; 1060 return 1;
1048} 1061}
1049 1062
1050/* 1063/*
1051 * This function updates various attributes about a specific space 1064 * This function updates various attributes about a specific space
1054 * through, etc) 1067 * through, etc)
1055 */ 1068 */
1056void 1069void
1057mapspace::update_ () 1070mapspace::update_ ()
1058{ 1071{
1059 object *tmp, *last = 0; 1072 object *last = 0;
1060 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1073 uint8 flags = P_UPTODATE, light = 0, anywhere = 0;
1061 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;
1062 1075
1063 //object *middle = 0; 1076 //object *middle = 0;
1064 //object *top = 0; 1077 //object *top = 0;
1066 // this seems to generate better code than using locals, above 1079 // this seems to generate better code than using locals, above
1067 object *&top = faces_obj[0] = 0; 1080 object *&top = faces_obj[0] = 0;
1068 object *&middle = faces_obj[1] = 0; 1081 object *&middle = faces_obj[1] = 0;
1069 object *&floor = faces_obj[2] = 0; 1082 object *&floor = faces_obj[2] = 0;
1070 1083
1071 for (tmp = bot; tmp; last = tmp, tmp = tmp->above) 1084 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1072 { 1085 {
1073 /* This could be made additive I guess (two lights better than 1086 /* This could be made additive I guess (two lights better than
1074 * 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
1075 * light bulbs do not illuminate twice as far as once since 1088 * light bulbs do not illuminate twice as far as once since
1076 * it is a dissapation factor that is cubed. 1089 * it is a dissapation factor that is cubed.
1102 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) 1115 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE))
1103 { 1116 {
1104 middle = tmp; 1117 middle = tmp;
1105 anywhere = 1; 1118 anywhere = 1;
1106 } 1119 }
1120
1107 /* Find the highest visible face around. If equal 1121 /* Find the highest visible face around. If equal
1108 * visibilities, we still want the one nearer to the 1122 * visibilities, we still want the one nearer to the
1109 * top 1123 * top
1110 */ 1124 */
1111 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))
1160 * 1) top face is set, need middle to be set. 1174 * 1) top face is set, need middle to be set.
1161 * 2) middle is set, need to set top. 1175 * 2) middle is set, need to set top.
1162 * 3) neither middle or top is set - need to set both. 1176 * 3) neither middle or top is set - need to set both.
1163 */ 1177 */
1164 1178
1165 for (tmp = last; tmp; tmp = tmp->below) 1179 for (object *tmp = last; tmp; tmp = tmp->below)
1166 { 1180 {
1167 /* 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 */
1168 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1182 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1169 break; 1183 break;
1170 1184
1573} 1587}
1574 1588
1575object * 1589object *
1576maptile::insert (object *op, int x, int y, object *originator, int flags) 1590maptile::insert (object *op, int x, int y, object *originator, int flags)
1577{ 1591{
1578 if (!op->flag [FLAG_REMOVED])
1579 op->remove ();
1580
1581 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);
1582} 1593}
1583 1594
1584region * 1595region *
1585maptile::region (int x, int y) const 1596maptile::region (int x, int y) const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines