… | |
… | |
965 | /* |
965 | /* |
966 | * 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. |
967 | * difficulty does not have a lot to do with character level, |
967 | * difficulty does not have a lot to do with character level, |
968 | * 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. |
969 | * |
969 | * |
970 | * 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 |
971 | * 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 |
972 | * have a difficulty set than using this function - human calculation |
972 | * have a difficulty set rather than using this function - human calculation |
973 | * is much better than this functions guesswork. |
973 | * is much better than this function's guesswork. |
974 | */ |
974 | */ |
975 | int |
975 | int |
976 | maptile::estimate_difficulty () const |
976 | maptile::estimate_difficulty () const |
977 | { |
977 | { |
978 | long monster_cnt = 0; |
978 | long monster_cnt = 0; |
… | |
… | |
1023 | * postive values make it darker, negative make it brighter |
1023 | * postive values make it darker, negative make it brighter |
1024 | */ |
1024 | */ |
1025 | int |
1025 | int |
1026 | maptile::change_map_light (int change) |
1026 | maptile::change_map_light (int change) |
1027 | { |
1027 | { |
1028 | int new_level = darkness + change; |
|
|
1029 | |
|
|
1030 | /* Nothing to do */ |
1028 | /* Nothing to do */ |
1031 | if (!change || (new_level <= 0 && darkness == 0) || (new_level >= MAX_DARKNESS && darkness >= MAX_DARKNESS)) |
1029 | if (!change) |
1032 | return 0; |
1030 | return 0; |
1033 | |
1031 | |
1034 | /* inform all players on the map */ |
1032 | /* inform all players on the map */ |
1035 | if (change > 0) |
1033 | if (change > 0) |
1036 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker."); |
1034 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker."); |
1037 | else |
1035 | else |
1038 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter."); |
1036 | new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter."); |
1039 | |
1037 | |
1040 | /* Do extra checking. since darkness is a unsigned value, |
1038 | darkness = clamp (darkness + change, -MAX_DARKNESS, MAX_DARKNESS); |
1041 | * we need to be extra careful about negative values. |
|
|
1042 | * In general, the checks below are only needed if change |
|
|
1043 | * is not +/-1 |
|
|
1044 | */ |
|
|
1045 | if (new_level < 0) |
|
|
1046 | darkness = 0; |
|
|
1047 | else if (new_level >= MAX_DARKNESS) |
|
|
1048 | darkness = MAX_DARKNESS; |
|
|
1049 | else |
|
|
1050 | darkness = new_level; |
|
|
1051 | |
1039 | |
1052 | /* All clients need to get re-updated for the change */ |
1040 | /* All clients need to get re-updated for the change */ |
1053 | update_all_map_los (this); |
1041 | update_all_map_los (this); |
1054 | |
1042 | |
1055 | return 1; |
1043 | return 1; |