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.147 by root, Mon Sep 29 10:20:48 2008 UTC vs.
Revision 1.152 by root, Tue Dec 23 01:51:27 2008 UTC

24#include <unistd.h> 24#include <unistd.h>
25 25
26#include "global.h" 26#include "global.h"
27#include "loader.h" 27#include "loader.h"
28#include "path.h" 28#include "path.h"
29
30sint8 maptile::outdoor_darkness;
29 31
30/* This rolls up wall, blocks_magic, blocks_view, etc, all into 32/* This rolls up wall, blocks_magic, blocks_view, etc, all into
31 * one function that just returns a P_.. value (see map.h) 33 * one function that just returns a P_.. value (see map.h)
32 * it will also do map translation for tiled maps, returning 34 * it will also do map translation for tiled maps, returning
33 * new values into newmap, nx, and ny. Any and all of those 35 * new values into newmap, nx, and ny. Any and all of those
351 ms.flags_ = 0; 353 ms.flags_ = 0;
352 } 354 }
353 else 355 else
354 { 356 {
355 f.parse_warn (format ("object %s out of range", op->debug_desc ())); 357 f.parse_warn (format ("object %s out of range", op->debug_desc ()));
356 op->destroy_inv (false); // be explicit about dropping
357 op->destroy (true); 358 op->destroy ();
358 } 359 }
359 } 360 }
360 361
361 continue; 362 continue;
362 363
713 714
714 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) 715 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE))
715 unique = 1; 716 unique = 1;
716 717
717 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 718 if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
718 {
719 op->destroy_inv (false);
720 op->destroy (true); 719 op->destroy ();
721 }
722 720
723 op = above; 721 op = above;
724 } 722 }
725 } 723 }
726} 724}
814 812
815 op->flag [FLAG_REMOVED] = true; 813 op->flag [FLAG_REMOVED] = true;
816 814
817 object *head = op->head_ (); 815 object *head = op->head_ ();
818 if (op == head) 816 if (op == head)
819 {
820 op->destroy_inv (false);
821 op->destroy (true); 817 op->destroy ();
822 }
823 else if (head->map != op->map) 818 else if (head->map != op->map)
824 { 819 {
825 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); 820 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ());
826 head->destroy (true); 821 head->destroy ();
827 } 822 }
828 } 823 }
829 824
830 sfree0 (spaces, size ()); 825 sfree0 (spaces, size ());
831 } 826 }
937 destroy = 1; 932 destroy = 1;
938 } 933 }
939 934
940 /* adjust overall chance below */ 935 /* adjust overall chance below */
941 if (destroy && rndm (0, 1)) 936 if (destroy && rndm (0, 1))
942 op->destroy (true); 937 op->destroy ();
943 } 938 }
944} 939}
945 940
946/* 941/*
947 * Updates every button on the map (by calling update_button() for them). 942 * Updates every button on the map (by calling update_button() for them).
1068 */ 1063 */
1069void 1064void
1070mapspace::update_ () 1065mapspace::update_ ()
1071{ 1066{
1072 object *last = 0; 1067 object *last = 0;
1073 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1068 uint8 flags = P_UPTODATE, anywhere = 0;
1069 sint8 light = 0;
1074 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1070 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1075 1071
1076 //object *middle = 0; 1072 //object *middle = 0;
1077 //object *top = 0; 1073 //object *top = 0;
1078 //object *floor = 0; 1074 //object *floor = 0;
1081 object *&middle = faces_obj[1] = 0; 1077 object *&middle = faces_obj[1] = 0;
1082 object *&floor = faces_obj[2] = 0; 1078 object *&floor = faces_obj[2] = 0;
1083 1079
1084 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) 1080 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1085 { 1081 {
1086 /* This could be made additive I guess (two lights better than 1082 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C)
1087 * one). But if so, it shouldn't be a simple additive - 2
1088 * light bulbs do not illuminate twice as far as once since
1089 * it is a dissapation factor that is cubed.
1090 */
1091 light = max (light, tmp->glow_radius); 1083 light += tmp->glow_radius;
1092 1084
1093 /* This call is needed in order to update objects the player 1085 /* This call is needed in order to update objects the player
1094 * is standing in that have animations (ie, grass, fire, etc). 1086 * is standing in that have animations (ie, grass, fire, etc).
1095 * However, it also causes the look window to be re-drawn 1087 * However, it also causes the look window to be re-drawn
1096 * 3 times each time the player moves, because many of the 1088 * 3 times each time the player moves, because many of the
1144 if (tmp->type == SAFE_GROUND) flags |= P_SAFE; 1136 if (tmp->type == SAFE_GROUND) flags |= P_SAFE;
1145 if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; 1137 if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE;
1146 if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; 1138 if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC;
1147 } 1139 }
1148 1140
1149 this->light = light; 1141 this->light = min (light, MAX_LIGHT_RADIUS);
1150 this->flags_ = flags; 1142 this->flags_ = flags;
1151 this->move_block = move_block & ~move_allow; 1143 this->move_block = move_block & ~move_allow;
1152 this->move_on = move_on; 1144 this->move_on = move_on;
1153 this->move_off = move_off; 1145 this->move_off = move_off;
1154 this->move_slow = move_slow; 1146 this->move_slow = move_slow;
1635maptile::play_sound (faceidx sound, int x, int y) const 1627maptile::play_sound (faceidx sound, int x, int y) const
1636{ 1628{
1637 if (!sound) 1629 if (!sound)
1638 return; 1630 return;
1639 1631
1640 for_all_players (pl) 1632 for_all_players_on_map (pl, this)
1641 if (pl->ob->map == this)
1642 if (client *ns = pl->ns) 1633 if (client *ns = pl->ns)
1643 { 1634 {
1644 int dx = x - pl->ob->x; 1635 int dx = x - pl->ob->x;
1645 int dy = y - pl->ob->y; 1636 int dy = y - pl->ob->y;
1646 1637
1647 int distance = idistance (dx, dy); 1638 int distance = idistance (dx, dy);
1648 1639
1649 if (distance <= MAX_SOUND_DISTANCE) 1640 if (distance <= MAX_SOUND_DISTANCE)
1650 ns->play_sound (sound, dx, dy); 1641 ns->play_sound (sound, dx, dy);
1651 } 1642 }
1652} 1643}
1653 1644

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines