… | |
… | |
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 | |
|
|
30 | sint8 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 |
… | |
… | |
963 | /* |
965 | /* |
964 | * This routine is supposed to find out the difficulty of the map. |
966 | * This routine is supposed to find out the difficulty of the map. |
965 | * difficulty does not have a lot to do with character level, |
967 | * difficulty does not have a lot to do with character level, |
966 | * but does have a lot to do with treasure on the map. |
968 | * but does have a lot to do with treasure on the map. |
967 | * |
969 | * |
968 | * Difficulty can now be set by the map creature. If the value stored |
970 | * Difficulty can now be set by the map creator. If the value stored |
969 | * in the map is zero, then use this routine. Maps should really |
971 | * in the map is zero, then use this routine. Maps should really |
970 | * have a difficulty set than using this function - human calculation |
972 | * have a difficulty set rather than using this function - human calculation |
971 | * is much better than this functions guesswork. |
973 | * is much better than this function's guesswork. |
972 | */ |
974 | */ |
973 | int |
975 | int |
974 | maptile::estimate_difficulty () const |
976 | maptile::estimate_difficulty () const |
975 | { |
977 | { |
976 | long monster_cnt = 0; |
978 | long monster_cnt = 0; |
… | |
… | |
1021 | * postive values make it darker, negative make it brighter |
1023 | * postive values make it darker, negative make it brighter |
1022 | */ |
1024 | */ |
1023 | int |
1025 | int |
1024 | maptile::change_map_light (int change) |
1026 | maptile::change_map_light (int change) |
1025 | { |
1027 | { |
1026 | int new_level = darkness + change; |
|
|
1027 | |
|
|
1028 | /* Nothing to do */ |
1028 | /* Nothing to do */ |
1029 | if (!change || (new_level <= 0 && darkness == 0) || (new_level >= MAX_DARKNESS && darkness >= MAX_DARKNESS)) |
1029 | if (!change) |
1030 | return 0; |
1030 | return 0; |
1031 | |
1031 | |
1032 | /* inform all players on the map */ |
1032 | /* inform all players on the map */ |
1033 | if (change > 0) |
1033 | if (change > 0) |
1034 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker."); |
1034 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker."); |
1035 | else |
1035 | else |
1036 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter."); |
1036 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter."); |
1037 | |
1037 | |
1038 | /* Do extra checking. since darkness is a unsigned value, |
1038 | darkness = clamp (darkness + change, -MAX_DARKNESS, MAX_DARKNESS); |
1039 | * we need to be extra careful about negative values. |
|
|
1040 | * In general, the checks below are only needed if change |
|
|
1041 | * is not +/-1 |
|
|
1042 | */ |
|
|
1043 | if (new_level < 0) |
|
|
1044 | darkness = 0; |
|
|
1045 | else if (new_level >= MAX_DARKNESS) |
|
|
1046 | darkness = MAX_DARKNESS; |
|
|
1047 | else |
|
|
1048 | darkness = new_level; |
|
|
1049 | |
1039 | |
1050 | /* All clients need to get re-updated for the change */ |
1040 | /* All clients need to get re-updated for the change */ |
1051 | update_all_map_los (this); |
1041 | update_all_map_los (this); |
1052 | |
1042 | |
1053 | return 1; |
1043 | return 1; |
… | |
… | |
1625 | maptile::play_sound (faceidx sound, int x, int y) const |
1615 | maptile::play_sound (faceidx sound, int x, int y) const |
1626 | { |
1616 | { |
1627 | if (!sound) |
1617 | if (!sound) |
1628 | return; |
1618 | return; |
1629 | |
1619 | |
1630 | for_all_players (pl) |
1620 | for_all_players_on_map (pl, this) |
1631 | if (pl->ob->map == this) |
|
|
1632 | if (client *ns = pl->ns) |
1621 | if (client *ns = pl->ns) |
1633 | { |
1622 | { |
1634 | int dx = x - pl->ob->x; |
1623 | int dx = x - pl->ob->x; |
1635 | int dy = y - pl->ob->y; |
1624 | int dy = y - pl->ob->y; |
1636 | |
1625 | |
1637 | int distance = idistance (dx, dy); |
1626 | int distance = idistance (dx, dy); |
1638 | |
1627 | |
1639 | if (distance <= MAX_SOUND_DISTANCE) |
1628 | if (distance <= MAX_SOUND_DISTANCE) |
1640 | ns->play_sound (sound, dx, dy); |
1629 | ns->play_sound (sound, dx, dy); |
1641 | } |
1630 | } |
1642 | } |
1631 | } |
1643 | |
1632 | |