Crossfire Server, Trunk  1.75.0
Weather module

Adds weather effects to the world map. More...

Data Structures

struct  DensityConfig
 Structure to hold density data entries. More...
 
struct  weather_avoids_t
 Defines a tile the weather system should avoid. More...
 
struct  weather_grow_t
 Defines a tile where something can grow. More...
 
struct  weather_replace_t
 Defines a tile the weather system can change to another tile. More...
 
struct  weather_settings_t
 Weather settings definition structure Stolen from the settings file, as they are unused by everything that isn't weather. More...
 
struct  weathermap_t
 This is an overlay structure of the whole world. More...
 

Macros

#define BLUE   2
 
#define EQUATOR_BASE_TEMP   30 /* C */
 
#define GREEN   1
 
#define GULF_STREAM_BASE_SPEED   40 /* base speed of gulf stream */
 
#define GULF_STREAM_WIDTH   3 /* width of gulf stream */
 
#define POLAR_BASE_TEMP   0 /* C */
 
#define PRESSURE_AREA   180
 
#define PRESSURE_ITERATIONS   30
 
#define PRESSURE_MAX   1040
 
#define PRESSURE_MIN   960
 
#define PRESSURE_ROUNDING_FACTOR   2
 
#define PRESSURE_ROUNDING_ITER   1
 
#define PRESSURE_SPIKES   3
 
#define RED   0
 
#define SEASONAL_ADJUST   10 /* polar distance */
 
#define SKY_BLIZZARD   16
 
#define SKY_CLEAR   0
 
#define SKY_FOG   7
 
#define SKY_HAIL   8
 
#define SKY_HEAVY_RAIN   5
 
#define SKY_HEAVY_SNOW   15
 
#define SKY_HURRICANE   6
 
#define SKY_LIGHT_RAIN   3
 
#define SKY_LIGHT_SNOW   13 /* add 10 to rain to get snow */
 
#define SKY_LIGHTCLOUD   1
 
#define SKY_OVERCAST   2
 
#define SKY_RAIN   4 /* rain -> storm has lightning */
 
#define SKY_SNOW   14
 
#define WEATHER_NO_FLOOR   2 /* If set, we clear FLAG_IS_FLOOR */
 
#define WEATHER_NO_SAVE   4 /* If set, we set FLAG_NO_SAVE */
 
#define WEATHER_OVERLAY   1 /* If set, we set FLAG_OVERLAY_FLOOR */
 Weather insert flags. More...
 
#define WEATHERMAPTILESX   100
 
#define WEATHERMAPTILESY   100
 
#define WIND_FACTOR   4.0
 This is a multiplier for the wind caused by pressure differences. More...
 

Functions

static objectavoid_weather (int *const av, const mapstruct *m, const int x, const int y, int *const gs, const int grow)
 Check the current square to see if we should avoid this one for weather processing. More...
 
static void calculate_temperature (mapstruct *m)
 Temperature is used in a lot of weather function. More...
 
void cfweather_close ()
 
void cfweather_init (Settings *settings, ServerSettings *serv)
 Weather module initialisation. More...
 
static void change_the_world (mapstruct *const m)
 Process worldmap regrowth. More...
 
static int check_replace_match (const object *ob, const weather_replace_t *rep_struct)
 Refactor the code to look for arch or object name as it's own code. More...
 
static void command_weather (object *op, const char *params)
 Player is wondering about the weather. More...
 
void compute_sky ()
 Let the madness, begin. More...
 
static void do_map_precipitation (mapstruct *const m)
 Do the precipitation for a given map. More...
 
static void do_precipitation (mapstruct *const m, const int x, const int y, const int temp, const int sky)
 Handle adding precipitation to the map. More...
 
static int do_water_elev_calc (mapstruct *const m, const int x, const int y, int *const water, int64_t *const elev, int *const trees)
 Do the water and elevation updates on the given map tile. More...
 
static void do_weather_insert (mapstruct *const m, int x, int y, const archetype *at, const int8_t object_flags, uint16_t material, int insert_flags)
 Do an object insert for weather effects. More...
 
static int get_config_tile (const int x, const int y, const mapstruct *m, const DensityConfig *list)
 Get config tile retrieves the desired tile's associated value from a given space. More...
 
static char * get_next_field (char *line)
 Finds the start of the next field in the provided string Skips past interceding commas and spaces. More...
 
static int humid_tile (const int x, const int y, const int dark)
 Calculate the humidity of the given weather tile. More...
 
static int init_config_vals (const Settings *settings, const char *conf_filename, DensityConfig **list)
 Read a config file that tells how many units (for an arbitrary purpose) a given arch is worth during calculations. More...
 
static void init_gulfstreammap ()
 Initialize the gulf stream. More...
 
static void init_humid_elev (const Settings *settings)
 Initialize humidity, water, forestry, and elevation. More...
 
static void init_pressure ()
 Reset pressure map. More...
 
static void init_rainfall ()
 Initialize rainfall. More...
 
static void init_temperature ()
 Initialize the temperature based on the time. More...
 
static int init_weather_replace (const Settings *settings, const char *conf_filename, weather_replace_t **list)
 Load the weather replacement definitions from file. More...
 
static void init_weather_settings (Settings *settings)
 
static int init_weatheravoid (const Settings *settings, const char *conf_filename, weather_avoids_t **wa)
 Load the weather/growth avoid defintions from file. More...
 
static void init_wind ()
 Initialize the wind randomly. More...
 
static void let_it_snow (mapstruct *const m)
 Put or remove snow. More...
 
static int load_humidity_map_part (mapstruct **m, const int dir, const int x, const int y, int *const tx, int *const ty)
 Method to abstract some of the mess of the humidity map. More...
 
static void perform_pressure ()
 Perform small randomizations in the pressure map. More...
 
void perform_weather ()
 This routine slowly loads the world, patches it up due to the weather, and saves it back to disk. More...
 
static void plant_a_garden (mapstruct *const m)
 Process growth of various plants. More...
 
static void plot_gulfstream ()
 Plot the gulfstream map over the wind map. More...
 
static int polar_distance (int x, int y, const int equator)
 Calculates the distance to the nearest pole. More...
 
void process_rain ()
 Keep track of how much rain has fallen in a given weathermap square. More...
 
static int read_elevmap (const Settings *settings)
 Load the elevation information. More...
 
static int read_forestrymap (const Settings *settings)
 Read the forestry map from the localdir. More...
 
static int read_gulfstreammap (const Settings *settings)
 Read the gulf stream, or initialize it if no saved information. More...
 
static int read_humidmap (const Settings *settings)
 Attempt to read humidity information, or barring that, read the maps and initialize elevation, humidity, water, and forestry maps. More...
 
static int read_pressuremap (const Settings *settings)
 Read the pressure information from disk. More...
 
static int read_rainfallmap (const Settings *settings)
 Read or initialize rainfall information. More...
 
static int read_temperaturemap (const Settings *settings)
 Load or initialize temperature information. More...
 
static int read_watermap (const Settings *settings)
 Load water information from localdir. More...
 
static int read_weatherposition (const Settings *settings)
 Read the weather map position from file. More...
 
static int read_winddirmap (const Settings *settings)
 Read the wind direction. More...
 
static int read_windspeedmap (const Settings *settings)
 Read the wind speed. More...
 
static int real_temperature (int x, int y, const timeofday_t *tod)
 Compute the real (adjusted) temperature of a given weathermap tile. More...
 
int real_world_temperature (int x, int y, mapstruct *m)
 Compute the temperature for a specific square. More...
 
static void singing_in_the_rain (mapstruct *const m)
 Process rain. More...
 
static void smooth_pressure ()
 This code simply smooths the pressure map. More...
 
static void smooth_wind ()
 It doesn't really smooth it as such. More...
 
static void spin_globe ()
 The world spinning drags the weather with it. More...
 
static void temperature_calc (const int x, const int y, const timeofday_t *tod)
 Calculate temperature of a spot. More...
 
void tick_weather ()
 Do the weather calculations in order. More...
 
static void update_humid ()
 Update the humidity for all weathermap tiles. More...
 
static int weather_clock_listener (int *type,...)
 Global clock event handling for weather. More...
 
static void weather_effect (mapstruct *const m)
 Perform actual effect of weather. More...
 
static int weather_listener (int *type,...)
 Global event handling for weather. More...
 
static int weather_object_listener (int *type,...)
 Global object-process handling for weather. More...
 
static char * weathermap_to_worldmap_corner (const int wx, const int wy, int *const x, int *const y, const int dir, char *const buffer, const int bufsize)
 Return the path of the map in specified direction. More...
 
static uint8_t wind_blow_object (mapstruct *const m, const int x, const int y, const MoveType move_type, int32_t wt, const living *stats)
 Calculate the direction to push an object from wind. More...
 
static int worldmap_to_weathermap (const int x, const int y, int *const wx, int *const wy, mapstruct *const m)
 Convert coordinates from world map to weather tiles. More...
 
static int write_elevmap (const Settings *settings)
 Save the average elevation information to localdir. More...
 
static int write_forestrymap (const Settings *settings)
 Write the forestry map to the localdir. More...
 
int write_gulfstreammap (const Settings *settings)
 Save the gulf stream to localdir. More...
 
int write_humidmap (const Settings *settings)
 Save humidity information to localdir. More...
 
int write_pressuremap (const Settings *settings)
 Save pressure information to localdir. More...
 
int write_rainfallmap (const Settings *settings)
 Save rainfall information to localdir. More...
 
int write_skymap (void)
 Write the sky map. More...
 
int write_temperaturemap (const Settings *settings)
 Save temperature information to localdir. More...
 
static int write_watermap (const Settings *settings)
 Save water percent information to localdir. More...
 
int write_weather_images ()
 Dump all the weather data as an image. More...
 
int write_winddirmap (const Settings *settings)
 Save wind direction to localdir. More...
 
int write_windspeedmap (const Settings *settings)
 Save the wind speed to localdir. More...
 

Variables

int weather_replace_t::arch_or_name
 If set, tile matches the archetype name, else the object's name. More...
 
int32_t weathermap_t::avgelev
 Average elevation. More...
 
static command_registration command_handler = 0
 
uint8_t weathermap_t::darkness
 Indicates level of darkness of map. More...
 
static const uint32_t directions []
 Colours used for wind directions. More...
 
archetypeweather_replace_t::doublestack_arch
 If set, this other archetype will be added atop special_snow. More...
 
uint16_t weather_settings_t::dynamiclevel
 How dynamic is the world? More...
 
int weather_grow_t::elevmax
 Maximum elevation for herb to grow. More...
 
int weather_grow_t::elevmin
 Minimum elevation for herb to grow. More...
 
DensityConfigforest_list = NULL
 
int8_t weathermap_t::forestry
 Range of forestedness. More...
 
static event_registration global_clock_handler = 0
 
static event_registration global_map_handler = 0
 
static event_registration global_mapload_handler = 0
 
static event_registration global_object_handler = 0
 
weather_avoids_tgrowth_avoids = NULL
 
static int gulf_stream_dir [GULF_STREAM_WIDTH][WEATHERMAPTILESY]
 Direction of the gulf stream. More...
 
static int gulf_stream_direction
 
static int gulf_stream_speed [GULF_STREAM_WIDTH][WEATHERMAPTILESY]
 Gulf stream variables. More...
 
static int gulf_stream_start
 
const char * weather_grow_t::herb
 Arch name of item to grow. More...
 
int weather_grow_t::humax
 Maximum humidity for herb to grow. More...
 
int8_t weathermap_t::humid
 Humitidy of this tile. More...
 
int weather_grow_t::humin
 Minimum humidity for herb to grow. More...
 
int DensityConfig::is_obj
 
sstring DensityConfig::name
 
sstring weather_avoids_t::name
 Tile archetype name. More...
 
DensityConfigDensityConfig::next
 
weather_avoids_tweather_avoids_t::next
 The next item in the avoid list. More...
 
weather_replace_tweather_replace_t::next
 The next item in the replace list. More...
 
int16_t weathermap_t::pressure
 Barometric pressure (mb). More...
 
uint32_t weathermap_t::rainfall
 Cumulative rainfall. More...
 
int weather_grow_t::random
 Random apparition factor. More...
 
int16_t weathermap_t::realtemp
 Temperature at a given calculation step for this tile. More...
 
float weather_grow_t::rfmax
 Maximum rainfall for herb to grow (inches/day). More...
 
float weather_grow_t::rfmin
 Minimum rainfall for herb to grow (inches/day). More...
 
int weather_grow_t::season
 Season the herb can grow. More...
 
static const int season_tempchange [HOURS_PER_DAY]
 How to alter the temperature, based on the hour of the day. More...
 
static const uint32_t skies []
 Colours used for weather types. More...
 
int8_t weathermap_t::sky
 Sky conditions. More...
 
int weather_avoids_t::snow
 Is this a long-term weather effect, like snow or a puddle? Used for various tests. More...
 
archetypeweather_replace_t::special_snow
 The archetype name of the tile to place over specified tile. More...
 
int16_t weathermap_t::temp
 Base temperature of this tile (F). More...
 
int weather_grow_t::tempmax
 Maximum temperature for herb to grow. More...
 
int weather_grow_t::tempmin
 Minimum temperature for herb to grow. More...
 
sstring weather_replace_t::tile
 Tile archetype or object name. More...
 
const char * weather_grow_t::tile
 Arch tile to grow on, NULL if anything. More...
 
unsigned long todtick
 Game world time, in in-game hours. More...
 
int DensityConfig::value_density
 
int8_t weathermap_t::water
 -100 - 100 percentage of water tiles. More...
 
DensityConfigwater_list = NULL
 
weather_avoids_tweather_avoids = NULL
 
weather_replace_tweather_evaporate = NULL
 
static const weather_grow_t weather_grow []
 The table below is used to grow things on the map. More...
 
weather_replace_tweather_replace = NULL
 
weather_replace_tweather_snowmelt = NULL
 
static const weather_grow_t weather_tile []
 The table below uses the same format as the one above. More...
 
weathermap_t ** weathermap
 
int8_t weathermap_t::winddir
 Direction of wind. More...
 
int8_t weathermap_t::windspeed
 Windspeed of this tile. More...
 
static int wmperformstartx
 Current weather tile position. More...
 
static int wmperformstarty
 Current weather tile position. More...
 
uint32_t weather_settings_t::worldmaptilesizex
 Number of squares wide in a wm tile. More...
 
uint32_t weather_settings_t::worldmaptilesizey
 Number of squares high in a wm tile. More...
 
static weather_settings_t wset
 

Detailed Description

Adds weather effects to the world map.

Macro Definition Documentation

◆ BLUE

#define BLUE   2

Definition at line 3499 of file cfweather.cpp.

◆ EQUATOR_BASE_TEMP

#define EQUATOR_BASE_TEMP   30 /* C */

Definition at line 34 of file cfweather.cpp.

◆ GREEN

#define GREEN   1

Definition at line 3498 of file cfweather.cpp.

◆ GULF_STREAM_BASE_SPEED

#define GULF_STREAM_BASE_SPEED   40 /* base speed of gulf stream */

Definition at line 37 of file cfweather.cpp.

◆ GULF_STREAM_WIDTH

#define GULF_STREAM_WIDTH   3 /* width of gulf stream */

Definition at line 36 of file cfweather.cpp.

◆ POLAR_BASE_TEMP

#define POLAR_BASE_TEMP   0 /* C */

Definition at line 33 of file cfweather.cpp.

◆ PRESSURE_AREA

#define PRESSURE_AREA   180

Definition at line 41 of file cfweather.cpp.

◆ PRESSURE_ITERATIONS

#define PRESSURE_ITERATIONS   30

Definition at line 40 of file cfweather.cpp.

◆ PRESSURE_MAX

#define PRESSURE_MAX   1040

Definition at line 45 of file cfweather.cpp.

◆ PRESSURE_MIN

#define PRESSURE_MIN   960

Definition at line 46 of file cfweather.cpp.

◆ PRESSURE_ROUNDING_FACTOR

#define PRESSURE_ROUNDING_FACTOR   2

Definition at line 42 of file cfweather.cpp.

◆ PRESSURE_ROUNDING_ITER

#define PRESSURE_ROUNDING_ITER   1

Definition at line 43 of file cfweather.cpp.

◆ PRESSURE_SPIKES

#define PRESSURE_SPIKES   3

Definition at line 44 of file cfweather.cpp.

◆ RED

#define RED   0

Definition at line 3497 of file cfweather.cpp.

◆ SEASONAL_ADJUST

#define SEASONAL_ADJUST   10 /* polar distance */

Definition at line 35 of file cfweather.cpp.

◆ SKY_BLIZZARD

#define SKY_BLIZZARD   16

Definition at line 63 of file cfweather.cpp.

◆ SKY_CLEAR

#define SKY_CLEAR   0

Definition at line 49 of file cfweather.cpp.

◆ SKY_FOG

#define SKY_FOG   7

Definition at line 57 of file cfweather.cpp.

◆ SKY_HAIL

#define SKY_HAIL   8

Definition at line 58 of file cfweather.cpp.

◆ SKY_HEAVY_RAIN

#define SKY_HEAVY_RAIN   5

Definition at line 54 of file cfweather.cpp.

◆ SKY_HEAVY_SNOW

#define SKY_HEAVY_SNOW   15

Definition at line 62 of file cfweather.cpp.

◆ SKY_HURRICANE

#define SKY_HURRICANE   6

Definition at line 55 of file cfweather.cpp.

◆ SKY_LIGHT_RAIN

#define SKY_LIGHT_RAIN   3

Definition at line 52 of file cfweather.cpp.

◆ SKY_LIGHT_SNOW

#define SKY_LIGHT_SNOW   13 /* add 10 to rain to get snow */

Definition at line 60 of file cfweather.cpp.

◆ SKY_LIGHTCLOUD

#define SKY_LIGHTCLOUD   1

Definition at line 50 of file cfweather.cpp.

◆ SKY_OVERCAST

#define SKY_OVERCAST   2

Definition at line 51 of file cfweather.cpp.

◆ SKY_RAIN

#define SKY_RAIN   4 /* rain -> storm has lightning */

Definition at line 53 of file cfweather.cpp.

◆ SKY_SNOW

#define SKY_SNOW   14

Definition at line 61 of file cfweather.cpp.

◆ WEATHER_NO_FLOOR

#define WEATHER_NO_FLOOR   2 /* If set, we clear FLAG_IS_FLOOR */

Definition at line 618 of file cfweather.cpp.

◆ WEATHER_NO_SAVE

#define WEATHER_NO_SAVE   4 /* If set, we set FLAG_NO_SAVE */

Definition at line 619 of file cfweather.cpp.

◆ WEATHER_OVERLAY

#define WEATHER_OVERLAY   1 /* If set, we set FLAG_OVERLAY_FLOOR */

Weather insert flags.

Definition at line 617 of file cfweather.cpp.

◆ WEATHERMAPTILESX

#define WEATHERMAPTILESX   100

Definition at line 75 of file cfweather.cpp.

◆ WEATHERMAPTILESY

#define WEATHERMAPTILESY   100

Definition at line 76 of file cfweather.cpp.

◆ WIND_FACTOR

#define WIND_FACTOR   4.0

This is a multiplier for the wind caused by pressure differences.

The type of overal climate you get depends on this. Too little wind, and the rain hugs the coast. Too much wind, and there are hurricanes and blizzards everywhere. 1 is too little.

Definition at line 72 of file cfweather.cpp.

Function Documentation

◆ avoid_weather()

static object* avoid_weather ( int *const  av,
const mapstruct m,
const int  x,
const int  y,
int *const  gs,
const int  grow 
)
static

Check the current square to see if we should avoid this one for weather processing.

Parameters
[out]avwill contain how many tiles should be avoided. Mustn't be NULL.
mmap to process.
x
ycoordinates to process.
[out]gswill contain how many snow/rain tiles are here. Mustn't be NULL.
growif 1, use the growth table, rather than the avoidance table.
Returns
object pointer for any snow item it found, so you can destroy/melt it.

Definition at line 533 of file cfweather.cpp.

References object::above, object::arch, FLAG_IS_FLOOR, GET_MAP_OB, growth_avoids, m, M_ICE, M_LIQUID, object::material, weather_avoids_t::name, archetype::name, weather_avoids_t::next, QUERY_FLAG, weather_avoids_t::snow, and weather_avoids.

Referenced by change_the_world(), let_it_snow(), plant_a_garden(), and singing_in_the_rain().

+ Here is the caller graph for this function:

◆ calculate_temperature()

static void calculate_temperature ( mapstruct m)
static

Temperature is used in a lot of weather function.

This need to be precalculated before used.

Parameters
mmap for which to calculate the temperature. Must be a world map.
Todo:
The results of this seem rather dubious, as we are really just overwriting about 15x15 times per tile calculated.

Definition at line 1428 of file cfweather.cpp.

References m, real_world_temperature(), weathermap_t::realtemp, weathermap, worldmap_to_weathermap(), weather_settings_t::worldmaptilesizex, weather_settings_t::worldmaptilesizey, and wset.

Referenced by weather_effect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cfweather_close()

◆ cfweather_init()

◆ change_the_world()

◆ check_replace_match()

static int check_replace_match ( const object ob,
const weather_replace_t rep_struct 
)
static

Refactor the code to look for arch or object name as it's own code.

Since we are using shared strings to store our arch/object names, we can simply use pointer arithmetic in order to compare.

Parameters
obThe external object we are checking Should not be NULL
rep_structThe weather_replace struct we are looking at. Should not be NULL
Returns
1 if a match occurred, 0 otherwise.

Definition at line 601 of file cfweather.cpp.

References object::arch, weather_replace_t::arch_or_name, object::name, archetype::name, and weather_replace_t::tile.

Referenced by let_it_snow(), and singing_in_the_rain().

+ Here is the caller graph for this function:

◆ command_weather()

static void command_weather ( object op,
const char *  params 
)
static

Player is wondering about the weather.

Parameters
opplayer asking for information.
paramsunused.

Definition at line 4638 of file cfweather.cpp.

References buf, draw_ext_info, draw_ext_info_format(), weather_settings_t::dynamiclevel, FLAG_WIZ, object::map, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_WEATHER, NDI_UNIQUE, QUERY_FLAG, real_world_temperature(), weathermap_t::sky, SKY_BLIZZARD, SKY_CLEAR, SKY_FOG, SKY_HAIL, SKY_HEAVY_RAIN, SKY_HEAVY_SNOW, SKY_HURRICANE, SKY_LIGHT_RAIN, SKY_LIGHT_SNOW, SKY_LIGHTCLOUD, SKY_OVERCAST, SKY_RAIN, SKY_SNOW, weathermap, worldmap_to_weathermap(), wset, object::x, and object::y.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_sky()

void compute_sky ( )

Let the madness, begin.

This function is the one that ties everything together. Here we loop over all the weathermaps, and compare the various conditions we have calculated up to now, to figure out what the sky conditions are for each square.

Todo:
Rework fog/hail generation Fog could certainly be less rare.

Definition at line 1101 of file cfweather.cpp.

References get_tod(), MAX, MIN, PRESSURE_MAX, PRESSURE_MIN, real_temperature(), weathermap_t::sky, SKY_FOG, SKY_HAIL, SKY_HURRICANE, SKY_LIGHT_RAIN, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by cfweather_init(), and perform_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_map_precipitation()

static void do_map_precipitation ( mapstruct *const  m)
static

Do the precipitation for a given map.

Parameters
mThe map we wish to process.

Definition at line 1559 of file cfweather.cpp.

References do_precipitation(), m, real_world_temperature(), weathermap_t::realtemp, weathermap_t::sky, weathermap, and worldmap_to_weathermap().

Referenced by weather_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_precipitation()

static void do_precipitation ( mapstruct *const  m,
const int  x,
const int  y,
const int  temp,
const int  sky 
)
static

Handle adding precipitation to the map.

Parameters
mThe map we are acting on.
x,yThe coordinates on the map we are handling.
tempThe temperature at the tile we are handling.
skyThe current sky conditions.

Definition at line 1481 of file cfweather.cpp.

References object::above, object::arch, do_weather_insert(), find_archetype(), find_string(), GET_MAP_OB, INS_NO_MERGE, INS_NO_WALK_ON, INS_ON_TOP, m, archetype::name, object_free(), object_remove(), rndm(), SKY_BLIZZARD, SKY_HEAVY_RAIN, SKY_HEAVY_SNOW, SKY_HURRICANE, SKY_LIGHT_RAIN, SKY_LIGHT_SNOW, SKY_RAIN, SKY_SNOW, sstring, and WEATHER_NO_SAVE.

Referenced by do_map_precipitation(), and singing_in_the_rain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_water_elev_calc()

static int do_water_elev_calc ( mapstruct *const  m,
const int  x,
const int  y,
int *const  water,
int64_t *const  elev,
int *const  trees 
)
static

Do the water and elevation updates on the given map tile.

Parameters
mThe map we are working on
x
yThe x,y coordinates we are handling for the current space.
waterPointer to a water count variable. Will be updated by this function.
elevPointer to an elevation sum variable. Will be updated by this function.
treesPointer to a forestry sum variable. Will be updated by this function.
Returns
0 if successful, -1 if failure

Definition at line 2711 of file cfweather.cpp.

References object::elevation, FLAG_IS_WATER, forest_list, get_config_tile(), GET_MAP_OB, m, QUERY_FLAG, and water_list.

Referenced by init_humid_elev().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_weather_insert()

static void do_weather_insert ( mapstruct *const  m,
int  x,
int  y,
const archetype at,
const int8_t  object_flags,
uint16_t  material,
int  insert_flags 
)
static

Do an object insert for weather effects.

Parameters
mThe map to insert the weather effect on. Must not be NULL.
x
yThe location to insert the object at.
atThe archetype to create an object from.
object_flagsIf first bit is 1, sets FLAG_OVERLAY_FLOOR on the created object. If second bit is 1, clears FLAG_IS_FLOOR. If third bit is 1, sets FLAG_NO_SAVE. Used for precipitation.
materialThe material of the object. If 0, will skip setting the material
insert_flagsThe flags to pass to object_insert_in_map

Definition at line 647 of file cfweather.cpp.

References CLEAR_FLAG, archetype::clone, FLAG_IS_FLOOR, FLAG_NO_SAVE, FLAG_OVERLAY_FLOOR, m, object::material, object_copy(), object_insert_in_map(), object_new(), SET_FLAG, WEATHER_NO_FLOOR, WEATHER_NO_SAVE, WEATHER_OVERLAY, object::x, and object::y.

Referenced by change_the_world(), do_precipitation(), let_it_snow(), plant_a_garden(), and singing_in_the_rain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_config_tile()

static int get_config_tile ( const int  x,
const int  y,
const mapstruct m,
const DensityConfig list 
)
static

Get config tile retrieves the desired tile's associated value from a given space.

This can be used for trees, deserts, water, anything of the sort.

Parameters
x
yThe coordinates on the map we wish to check
mThe map the coordinates belong to.
listThe list we are pulling from. This allows us to use the same code for denoting water as for denoting trees.
Returns
The associated value of the bottommost config-specified tile at this location, or 0 if there are no matches here.

Definition at line 416 of file cfweather.cpp.

References object::above, object::arch, GET_MAP_OB, DensityConfig::is_obj, list, m, DensityConfig::name, object::name, archetype::name, DensityConfig::next, and DensityConfig::value_density.

Referenced by do_water_elev_calc(), and real_world_temperature().

+ Here is the caller graph for this function:

◆ get_next_field()

static char* get_next_field ( char *  line)
static

Finds the start of the next field in the provided string Skips past interceding commas and spaces.

Used in all the config initializations, but not the weathermap initializations

Parameters
lineThe line to process. We will null terminate the end of the current field directly here, so we must pass as non-const.
Returns
NULL if no next field could be found, or the address of the start of that field if found

Definition at line 680 of file cfweather.cpp.

References is_valid_types_gen::line.

Referenced by init_config_vals(), init_weather_replace(), and init_weatheravoid().

+ Here is the caller graph for this function:

◆ humid_tile()

static int humid_tile ( const int  x,
const int  y,
const int  dark 
)
static

Calculate the humidity of the given weather tile.

Parameters
x
yweathermap coordinates we wish to calculate humidity for.
darkThe darkness amount on the world. Presumably from get_world_darkness().
Returns
the humidity of the weathermap square, trimmed to the range [0, 100]

Definition at line 1202 of file cfweather.cpp.

References weathermap_t::humid, MAX, MAX_DARKNESS, rndm(), SKY_BLIZZARD, SKY_CLEAR, SKY_FOG, SKY_HAIL, SKY_HEAVY_RAIN, SKY_HEAVY_SNOW, SKY_HURRICANE, SKY_LIGHT_RAIN, SKY_LIGHT_SNOW, SKY_LIGHTCLOUD, SKY_OVERCAST, SKY_RAIN, SKY_SNOW, weathermap_t::water, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, and weathermap_t::windspeed.

Referenced by update_humid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_config_vals()

static int init_config_vals ( const Settings settings,
const char *  conf_filename,
DensityConfig **  list 
)
static

Read a config file that tells how many units (for an arbitrary purpose) a given arch is worth during calculations.

By defining in a file, we get our structure to be non-static, so we can do pointer comparisons on the object name or arch rather than string comparisons on the name.

Parameters
settingsPointer to the settings structure, so we can get the directory where the config is stored.
conf_filenameThe name of the config file we are loading.
listPointer to the list we are appending entries to.
Returns
0 if successful (even if lines are malformed in the file), 1 otherwise

Definition at line 2386 of file cfweather.cpp.

References add_string(), bufferreader_current_line(), bufferreader_destroy(), bufferreader_init_from_file(), bufferreader_next_line(), Settings::confdir, fatal(), is_valid_types_gen::found, get_next_field(), DensityConfig::is_obj, is_valid_types_gen::line, list, llevError, LOG(), MAX_BUF, name, DensityConfig::name, DensityConfig::next, OUT_OF_MEMORY, settings, and DensityConfig::value_density.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_gulfstreammap()

static void init_gulfstreammap ( )
static

Initialize the gulf stream.

Definition at line 2909 of file cfweather.cpp.

References dirdiff(), GULF_STREAM_BASE_SPEED, gulf_stream_dir, gulf_stream_direction, gulf_stream_speed, gulf_stream_start, GULF_STREAM_WIDTH, rndm(), WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_gulfstreammap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_humid_elev()

static void init_humid_elev ( const Settings settings)
static

Initialize humidity, water, forestry, and elevation.

This is a fairly expensive operation, so we only do this if the elevation map is not already existant.

Parameters
settingsPointer to the settings structure. We use multiple values from it.

Definition at line 2742 of file cfweather.cpp.

References weathermap_t::avgelev, delete_map(), do_water_elev_calc(), weathermap_t::forestry, weathermap_t::humid, load_humidity_map_part(), m, MAX, MIN, settings, update_humid(), weathermap_t::water, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, weather_settings_t::worldmaptilesizex, weather_settings_t::worldmaptilesizey, Settings::worldmaptilesx, Settings::worldmaptilesy, and wset.

Referenced by read_humidmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_pressure()

static void init_pressure ( )
static

Reset pressure map.

Sets the whole map to 1013 mbar, then adds some disturbances in two different ways.

Definition at line 3008 of file cfweather.cpp.

References weathermap_t::pressure, PRESSURE_AREA, PRESSURE_ITERATIONS, PRESSURE_MAX, PRESSURE_MIN, PRESSURE_SPIKES, rndm(), smooth_pressure(), weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_pressuremap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_rainfall()

static void init_rainfall ( )
static

Initialize rainfall.

Appears to just give a very rough estimate of rainfall amounts. Could probably be better, but should be fine despite this.

Definition at line 2878 of file cfweather.cpp.

References days, HOURS_PER_DAY, weathermap_t::rainfall, todtick, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_rainfallmap().

+ Here is the caller graph for this function:

◆ init_temperature()

static void init_temperature ( )
static

Initialize the temperature based on the time.

This is actually used at every recalculation step, too. Calls temperature_calc to do the heavy lifting.

Definition at line 2861 of file cfweather.cpp.

References get_tod(), temperature_calc(), WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_temperaturemap(), and tick_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_weather_replace()

static int init_weather_replace ( const Settings settings,
const char *  conf_filename,
weather_replace_t **  list 
)
static

Load the weather replacement definitions from file.

Parameters
settingsThe settings structure we wish to use for install paths. We want confdir specifically for this one.
conf_filenameThe name of the file we are loading.
listpointer to a list to link elements of the weatheravoid to.
Returns
0 if successful, 1 if failure.

Definition at line 2553 of file cfweather.cpp.

References add_string(), weather_replace_t::arch_or_name, bufferreader_current_line(), bufferreader_destroy(), bufferreader_init_from_file(), bufferreader_next_line(), Settings::confdir, weather_replace_t::doublestack_arch, fatal(), find_archetype(), is_valid_types_gen::found, get_next_field(), is_valid_types_gen::line, list, llevError, LOG(), MAX_BUF, name, weather_replace_t::next, OUT_OF_MEMORY, settings, weather_replace_t::special_snow, and weather_replace_t::tile.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_weather_settings()

static void init_weather_settings ( Settings settings)
static

Definition at line 3045 of file cfweather.cpp.

References buf, Settings::confdir, weather_settings_t::dynamiclevel, llevError, LOG(), MAX_BUF, settings, strcasecmp(), weather_settings_t::worldmaptilesizex, weather_settings_t::worldmaptilesizey, and wset.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_weatheravoid()

static int init_weatheravoid ( const Settings settings,
const char *  conf_filename,
weather_avoids_t **  wa 
)
static

Load the weather/growth avoid defintions from file.

Parameters
settingsThe settings structure we wish to use for install paths. We want confdir specifically for this one.
conf_filenameThe name of the file we are loading.
wapointer to a list to link elements of the weatheravoid to.
Returns
0 if successful, 1 if failure.

Definition at line 2471 of file cfweather.cpp.

References add_string(), bufferreader_current_line(), bufferreader_destroy(), bufferreader_init_from_file(), bufferreader_next_line(), Settings::confdir, fatal(), is_valid_types_gen::found, get_next_field(), is_valid_types_gen::line, llevError, LOG(), MAX_BUF, name, weather_avoids_t::name, weather_avoids_t::next, OUT_OF_MEMORY, settings, and weather_avoids_t::snow.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_wind()

static void init_wind ( )
static

Initialize the wind randomly.

Does both direction and speed in one pass

Values for speed are fairly low – the calculations for wind are built in a way where this is not a problem.

Definition at line 2991 of file cfweather.cpp.

References rndm(), weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, weathermap_t::winddir, and weathermap_t::windspeed.

Referenced by read_winddirmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ let_it_snow()

◆ load_humidity_map_part()

static int load_humidity_map_part ( mapstruct **  m,
const int  dir,
const int  x,
const int  y,
int *const  tx,
int *const  ty 
)
static

Method to abstract some of the mess of the humidity map.

Loads a specific corner of the map based on dir.

Parameters
dirThe map corner to handle. Should be one of 2, 4, 6, or 8.
x
yThe x,y coordinates of the weather map we are handling.
tx
tyPointers to the coordinates on the map we are loading. The looping structure needs these.
Returns
0 if successful, -1 on failure.

Definition at line 2668 of file cfweather.cpp.

References load_overlay_map(), m, mapfile_load(), MAX_BUF, and weathermap_to_worldmap_corner().

Referenced by init_humid_elev().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ perform_pressure()

static void perform_pressure ( )
static

Perform small randomizations in the pressure map.

Then, apply the smoothing algorithim.. This causes the pressure to change very slowly

Definition at line 827 of file cfweather.cpp.

References weathermap_t::humid, weathermap_t::pressure, PRESSURE_SPIKES, rndm(), smooth_pressure(), weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by tick_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ perform_weather()

void perform_weather ( )

This routine slowly loads the world, patches it up due to the weather, and saves it back to disk.

In this way, the world constantly feels the effects of weather uniformly, without relying on players wandering.

The main point of this is stuff like growing herbs, soil, decaying crap, etc etc etc. Not actual weather, but weather effects.

Definition at line 2248 of file cfweather.cpp.

References compute_sky(), delete_map(), weather_settings_t::dynamiclevel, llevError, Settings::localdir, LOG(), m, MAP_IN_MEMORY, MAX_BUF, players_on_map(), ready_map_name(), save_map(), SAVE_MODE_OVERLAY, settings, TRUE, weather_effect(), wmperformstartx, wmperformstarty, Settings::worldmapstartx, Settings::worldmapstarty, Settings::worldmaptilesx, Settings::worldmaptilesy, and wset.

Referenced by weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ plant_a_garden()

◆ plot_gulfstream()

static void plot_gulfstream ( )
static

Plot the gulfstream map over the wind map.

This is done after the wind, to avoid the windsmoothing scrambling the jet stream.

Definition at line 1304 of file cfweather.cpp.

References dirdiff(), GULF_STREAM_BASE_SPEED, gulf_stream_dir, gulf_stream_direction, gulf_stream_speed, gulf_stream_start, GULF_STREAM_WIDTH, rndm(), similar_direction(), weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, weathermap_t::winddir, and weathermap_t::windspeed.

Referenced by tick_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ polar_distance()

static int polar_distance ( int  x,
int  y,
const int  equator 
)
static

Calculates the distance to the nearest pole.

Parameters
x
yweathermap coordinates.
equatorcurrent location of the equator.
Returns
distance as an int.

Definition at line 384 of file cfweather.cpp.

References WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by temperature_calc().

+ Here is the caller graph for this function:

◆ process_rain()

void process_rain ( )

Keep track of how much rain has fallen in a given weathermap square.

This is called at the beginning of every in-game hour (tod.minute == 0) To make some amount of sampling effect out of totals.

Definition at line 1400 of file cfweather.cpp.

References weathermap_t::rainfall, weathermap_t::sky, SKY_FOG, SKY_LIGHT_SNOW, SKY_OVERCAST, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by weather_clock_listener().

+ Here is the caller graph for this function:

◆ read_elevmap()

static int read_elevmap ( const Settings settings)
static

Load the elevation information.

Does not attempt to initalize elevation, since humidity should have tried to do that already.

Parameters
settingsThe settings information structure we wish to use. Specifically, we grab localdir from it
Returns
0 if successful, -1 if failure.

Definition at line 3906 of file cfweather.cpp.

References weathermap_t::avgelev, bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), llevDebug, llevError, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_forestrymap()

static int read_forestrymap ( const Settings settings)
static

Read the forestry map from the localdir.

The forestry map contains the measure of how forested a given weather map tile is. The values of each tree tile are defined in the forestry data (and initialized in init_config_vals(), and the values read here are calculated at the same time as humidity, water, and elevation. Here we merely read the resultant values in.

Parameters
settingsPointer to the Settings structure that designates where different install directories are located. In this case, we care about localdir.
Returns
0 if successful, -1 if failed.

Definition at line 3779 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), weathermap_t::forestry, llevDebug, llevError, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_gulfstreammap()

static int read_gulfstreammap ( const Settings settings)
static

Read the gulf stream, or initialize it if no saved information.

Parameters
settingsThe settings structure we use to locate config folders. Here we want localdir specifically.
Returns
0 if success without initialization, 1 if success with initialization. Returns -1 on failure.

Definition at line 4142 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), gulf_stream_dir, gulf_stream_speed, gulf_stream_start, GULF_STREAM_WIDTH, in, init_gulfstreammap(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, rndm(), settings, WEATHERMAPTILESY, and write_gulfstreammap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_humidmap()

static int read_humidmap ( const Settings settings)
static

Attempt to read humidity information, or barring that, read the maps and initialize elevation, humidity, water, and forestry maps.

Must be called before attempting to read elevation, humidity, water, or forestry, as those all do not attempt initialization if they cannot find their file to read from.

Parameters
settingsThe settings structure. We use this for localdir and to pass to initialization if needed.
Returns
0 if successful and no initialization done, 1 if successful and initialization done. Returns -1 on failure.

Definition at line 3842 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), weathermap_t::humid, init_humid_elev(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, write_elevmap(), write_forestrymap(), write_humidmap(), and write_watermap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_pressuremap()

static int read_pressuremap ( const Settings settings)
static

Read the pressure information from disk.

If it doesn't exist, initialize pressure.

Parameters
settingsPointer to the settings structure so we can reach localdir
Returns
0 if successful without initialization, 1 if successful with initialization Returns -1 on failure.

Definition at line 4357 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), init_pressure(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, weathermap_t::pressure, PRESSURE_MAX, PRESSURE_MIN, settings, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, and write_pressuremap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_rainfallmap()

static int read_rainfallmap ( const Settings settings)
static

Read or initialize rainfall information.

Initialization depends on humidity, so it must be called after humidity is initialized.

Parameters
settingsThe settings structure we use to locate config folders. Here we want localdir specifically.
Returns
0 if success without initialization, 1 if success with initialization. Returns -1 on failure.

Definition at line 4085 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), init_rainfall(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX_BUF, settings, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, and write_rainfallmap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_temperaturemap()

static int read_temperaturemap ( const Settings settings)
static

Load or initialize temperature information.

Depends on water info, so must be initialized after humidity.

Parameters
settingsThe settings structure we're using.
Returns
0 on success without initialization, 1 on success with initialization. Returns -1 on failure.

Definition at line 4023 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), init_temperature(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap_t::temp, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, and write_temperaturemap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_watermap()

static int read_watermap ( const Settings settings)
static

Load water information from localdir.

Since This requires us to look at all the map pieces, it should be initialized by the humidity code before we reach here.

Parameters
settingsThe settings structure. We specifically want localdir.
Returns
0 if successful, -1 if failure.

Definition at line 3965 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), llevDebug, llevError, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap_t::water, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_weatherposition()

static int read_weatherposition ( const Settings settings)
static

Read the weather map position from file.

Parameters
settingsA pointer to the settings structure. We actually use a couple of these instead of just localdir.
Returns
0 if successful, -1 if failed. When failed, the map position fields that are set here will be set to default values, so subsequent use will just result in a lost position.

Definition at line 4419 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, settings, wmperformstartx, wmperformstarty, Settings::worldmaptilesx, and Settings::worldmaptilesy.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_winddirmap()

static int read_winddirmap ( const Settings settings)
static

Read the wind direction.

Will initialize the entirety of wind if file doesn't exist.

Parameters
settingsThe settings structure we will use to find localdir
Returns
0 if success without initialization, 1 if success with initialization returns -1 on failure

Definition at line 4293 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), d, init_wind(), llevDebug, llevError, llevInfo, Settings::localdir, LOG(), MAX_BUF, rndm(), settings, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, weathermap_t::winddir, write_winddirmap(), and write_windspeedmap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_windspeedmap()

static int read_windspeedmap ( const Settings settings)
static

Read the wind speed.

We do not init here, since winddir should have handled that already. Depends on wind direction loading having been run before it as a result.

Parameters
settingsPointer to the settings structure. We want localdir from it.
Returns
0 if sucessfully loaded, -1 if failed. There is no init, so it won't return 1 ever.

Definition at line 4238 of file cfweather.cpp.

References bufferreader_data(), bufferreader_destroy(), bufferreader_init_from_file(), llevDebug, llevError, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, settings, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, and weathermap_t::windspeed.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ real_temperature()

static int real_temperature ( int  x,
int  y,
const timeofday_t tod 
)
static

Compute the real (adjusted) temperature of a given weathermap tile.

This takes into account the wind, base temp, sunlight, and other fun things. Seasons are automatically handled by moving the equator. Elevation is partially considered in the base temp. x and y are the weathermap coordinates.

Parameters
x
yweathermap coordinates.
todPointer to an already-filled-out time-of-day structure.
Returns
The temperature of the provided weathermap tile.

Definition at line 895 of file cfweather.cpp.

References timeofday_t::hour, HOURS_PER_DAY, season_tempchange, SKY_BLIZZARD, SKY_CLEAR, SKY_HURRICANE, SKY_LIGHTCLOUD, weathermap_t::temp, weathermap_t::water, weathermap, and weathermap_t::windspeed.

Referenced by compute_sky(), real_world_temperature(), and write_weather_images().

+ Here is the caller graph for this function:

◆ real_world_temperature()

int real_world_temperature ( int  x,
int  y,
mapstruct m 
)

Compute the temperature for a specific square.

Used to normalize elevation.

Parameters
x
ymap coordinates.
mmap we're on.
Returns
temperature on the provided space.

Definition at line 968 of file cfweather.cpp.

References weathermap_t::avgelev, object::elevation, forest_list, get_config_tile(), GET_MAP_OB, get_tod(), m, real_temperature(), weathermap, and worldmap_to_weathermap().

Referenced by calculate_temperature(), command_weather(), and do_map_precipitation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ singing_in_the_rain()

◆ smooth_pressure()

static void smooth_pressure ( )
static

This code simply smooths the pressure map.

It also does clipping to ensure we are within acceptable bounds.

Definition at line 787 of file cfweather.cpp.

References MAX, MIN, weathermap_t::pressure, PRESSURE_MAX, PRESSURE_MIN, PRESSURE_ROUNDING_FACTOR, PRESSURE_ROUNDING_ITER, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by init_pressure(), and perform_pressure().

+ Here is the caller graph for this function:

◆ smooth_wind()

static void smooth_wind ( )
static

It doesn't really smooth it as such.

The main function of this is to apply the pressuremap to the wind direction and speed, followed by some tree-driven disruption. Then, we run a quick pass to update the windspeed.

Definition at line 712 of file cfweather.cpp.

References find_dir_2(), weathermap_t::forestry, weathermap_t::pressure, PRESSURE_MAX, similar_direction(), weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, WIND_FACTOR, weathermap_t::winddir, and weathermap_t::windspeed.

Referenced by tick_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ spin_globe()

static void spin_globe ( )
static

The world spinning drags the weather with it.

The equator is diagonal, and the poles are 45 degrees from north /south. What the hell, lets spin the planet backwards.

Due to the polar layout, the weather moves from northeast to southwest. This does, however, make storms come from polar-east (in-game northeast). So the world is spinning backwards, even if it looks odd.

Definition at line 1158 of file cfweather.cpp.

References weathermap_t::humid, MIN, weathermap_t::pressure, weathermap_t::sky, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by tick_weather().

+ Here is the caller graph for this function:

◆ temperature_calc()

static void temperature_calc ( const int  x,
const int  y,
const timeofday_t tod 
)
static

Calculate temperature of a spot.

Parameters
x
yweathermap coordinates.
todtime of day.

Now we adjust for the presence of trees. Thick trees create a heat-holding canopy. Sparse trees don't hold so much heat in, and actually work to reduce temperatures.

Definition at line 1028 of file cfweather.cpp.

References EQUATOR_BASE_TEMP, weathermap_t::forestry, MIN, timeofday_t::month, MONTHS_PER_YEAR, POLAR_BASE_TEMP, polar_distance(), weathermap_t::pressure, SEASONAL_ADJUST, weathermap_t::temp, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by init_temperature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tick_weather()

void tick_weather ( )

Do the weather calculations in order.

Re-ordering these will probably produce unintended side effects.

Definition at line 1444 of file cfweather.cpp.

References weather_settings_t::dynamiclevel, init_temperature(), perform_pressure(), plot_gulfstream(), smooth_wind(), spin_globe(), update_humid(), and wset.

Referenced by weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_humid()

static void update_humid ( )
static

Update the humidity for all weathermap tiles.

Calls humid_tile for every weathermap tile. All the fun stuff happens in humid_tile

Definition at line 1290 of file cfweather.cpp.

References get_world_darkness(), weathermap_t::humid, humid_tile(), weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by init_humid_elev(), and tick_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weather_clock_listener()

static int weather_clock_listener ( int *  type,
  ... 
)
static

Global clock event handling for weather.

This is separate from the mapenter listener because I felt like it. They possibly could be merged, it just makes documenting the parameters for the function into a mess.

Parameters
typeThe event type.
Returns
0.

Definition at line 4516 of file cfweather.cpp.

References code, EVENT_CLOCK, Settings::fastclock, perform_weather(), process_rain(), pticks, PTICKS_PER_CLOCK, settings, tick_weather(), is_valid_types_gen::type, write_gulfstreammap(), write_humidmap(), write_pressuremap(), write_rainfallmap(), write_skymap(), write_temperaturemap(), write_weather_images(), write_winddirmap(), and write_windspeedmap().

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weather_effect()

static void weather_effect ( mapstruct *const  m)
static

Perform actual effect of weather.

Should be called from perform_weather(), or when a map is loaded. (player enter map).

This is where things like snow, herbs, earthly rototilling, etc should occur.

Nothing will happen if the map isn't a world map.

Parameters
mmap to alter.

Definition at line 2206 of file cfweather.cpp.

References calculate_temperature(), change_the_world(), weather_settings_t::dynamiclevel, let_it_snow(), m, plant_a_garden(), singing_in_the_rain(), worldmap_to_weathermap(), and wset.

Referenced by perform_weather().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weather_listener()

static int weather_listener ( int *  type,
  ... 
)
static

Global event handling for weather.

Parameters
typeThe event type.
mThe map being loaded.
Returns
0.

Definition at line 4477 of file cfweather.cpp.

References code, do_map_precipitation(), EVENT_MAPENTER, EVENT_MAPLOAD, EVENT_MAPREADY, m, and is_valid_types_gen::type.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weather_object_listener()

static int weather_object_listener ( int *  type,
  ... 
)
static

Global object-process handling for weather.

Parameters
typeThe event type.
opThe object being processed.
Returns
0.

Definition at line 4574 of file cfweather.cpp.

References blocked_link(), object::carrying, code, object::contr, esrv_map_scroll(), EVENT_TIME, FLAG_IS_FLOOR, FOR_INV_FINISH, FOR_INV_PREPARE, freearr_x, freearr_y, get_map_flags(), object::inv, socket_struct::look_position, m, object::map, object::move_type, object_insert_in_map_at(), object_remove(), P_OUT_OF_MAP, PLAYER, QUERY_FLAG, player::socket, object::stats, TRANSPORT, player::transport, is_valid_types_gen::type, object::type, socket_struct::update_look, object::weight, wind_blow_object(), object::x, and object::y.

Referenced by cfweather_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weathermap_to_worldmap_corner()

static char* weathermap_to_worldmap_corner ( const int  wx,
const int  wy,
int *const  x,
int *const  y,
const int  dir,
char *const  buffer,
const int  bufsize 
)
static

Return the path of the map in specified direction.

Parameters
wx
wyweather map coordinates.
[out]x
[out]ywill contain coordinates in the new map. Mustn't be NULL.
dirdirection to find map for. Valid values are 2 4 6 8 for the corners.
bufferbuffer that will contain the path of map in specified direction.
bufsizelength of buffer
Returns
buffer containing the path to the world map we want, or NULL if were weren't given a corner direction.

Definition at line 333 of file cfweather.cpp.

References buffer, llevError, LOG(), settings, WEATHERMAPTILESX, WEATHERMAPTILESY, Settings::worldmapstartx, Settings::worldmapstarty, weather_settings_t::worldmaptilesizex, weather_settings_t::worldmaptilesizey, Settings::worldmaptilesx, Settings::worldmaptilesy, and wset.

Referenced by load_humidity_map_part().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wind_blow_object()

static uint8_t wind_blow_object ( mapstruct *const  m,
const int  x,
const int  y,
const MoveType  move_type,
int32_t  wt,
const living stats 
)
static

Calculate the direction to push an object from wind.

Parameters
mThe map the player is on.
x,yThe coordinates of the player on the map
move_typeThe movement type the object is attempting to use.
wtThe total weight the object has (incl. carrying)
statsThe stat block of the object, or NULL if it is not alive.
Returns
The direction to push (1-8), or 0 if push does not occur

Definition at line 2318 of file cfweather.cpp.

References absdir(), m, MOVE_FLYING, rndm(), stats, weathermap, weathermap_t::windspeed, and worldmap_to_weathermap().

Referenced by weather_object_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ worldmap_to_weathermap()

static int worldmap_to_weathermap ( const int  x,
const int  y,
int *const  wx,
int *const  wy,
mapstruct *const  m 
)
static

Convert coordinates from world map to weather tiles.

Parameters
x
ycoordinates to convert.
[out]wx
[out]wyweather map coordinates.
mmap. Should be a world map.
Returns
-1 if you give it something it can't figure out. 0 normally.

Definition at line 458 of file cfweather.cpp.

References llevDebug, LOG(), m, MAP_WORLDPARTX, MAP_WORLDPARTY, settings, WEATHERMAPTILESX, WEATHERMAPTILESY, Settings::worldmapstartx, Settings::worldmapstarty, weather_settings_t::worldmaptilesizex, weather_settings_t::worldmaptilesizey, Settings::worldmaptilesx, Settings::worldmaptilesy, and wset.

Referenced by calculate_temperature(), change_the_world(), command_weather(), do_map_precipitation(), let_it_snow(), plant_a_garden(), real_world_temperature(), singing_in_the_rain(), weather_effect(), and wind_blow_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_elevmap()

static int write_elevmap ( const Settings settings)
static

Save the average elevation information to localdir.

Since this does not change over time, we call this only when we are initalizing humidity.

Parameters
settingsPointer to the settings structure. In particular, we want localdir.
Returns
0 if successful, 1 if failure.

Definition at line 3196 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_humidmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_forestrymap()

static int write_forestrymap ( const Settings settings)
static

Write the forestry map to the localdir.

Since this doesn't change over time, we can make this static and only call it from humidity initialization.

Parameters
settingsPointer to the settings structure. We want the localdir from this.
Returns
0 if successful, 1 if failure.

Definition at line 3126 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_humidmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_gulfstreammap()

int write_gulfstreammap ( const Settings settings)

Save the gulf stream to localdir.

Parameters
settingsThe settings structure we are using to find localdir. Pretty sure it's the same one as the global settings, but oh well.
Returns
0 if successful, 1 if failure.

Definition at line 3331 of file cfweather.cpp.

References gulf_stream_dir, gulf_stream_speed, gulf_stream_start, GULF_STREAM_WIDTH, llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, and WEATHERMAPTILESY.

Referenced by read_gulfstreammap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_humidmap()

int write_humidmap ( const Settings settings)

Save humidity information to localdir.

Parameters
settingsThe settings structure to use for finding localdir
Returns
0 if successful, 1 if failure

Definition at line 3161 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_humidmap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_pressuremap()

int write_pressuremap ( const Settings settings)

Save pressure information to localdir.

Parameters
settingsThe settings structure we are using to find localdir. Pretty sure it's the same one as the global settings, but oh well.
Returns
0 if successful, 1 if failure.

Definition at line 3440 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_pressuremap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_rainfallmap()

int write_rainfallmap ( const Settings settings)

Save rainfall information to localdir.

Parameters
settingsThe current server settings In particular, we want localdir from this
Returns
0 if success, 1 if failure.

Definition at line 3298 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_rainfallmap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_skymap()

int write_skymap ( void  )

Write the sky map.

We never read this map, only write it for debugging purposes

Returns
0 if successful, 1 otherwise

Definition at line 3469 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_temperaturemap()

int write_temperaturemap ( const Settings settings)

Save temperature information to localdir.

Parameters
settingsThe settings structure we wish to pull localdir from. It's probably the only one, but oh well. I'm passing it as a function parameter anyway.
Returns
0 on success, 1 on failure.

Definition at line 3265 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_temperaturemap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_watermap()

static int write_watermap ( const Settings settings)
static

Save water percent information to localdir.

Since this does not actually change regularly, we can just call this when we initialize humidity.

Parameters
settingsPointer to the settings structure. In particular, we want localdir from it.
Returns
0 if successful, 1 if failure.

Definition at line 3231 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_humidmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_weather_images()

int write_weather_images ( )

Dump all the weather data as an image.

Does not write to the tod file, since that is already handled elsewhere. (It used to, though, probably because all the saves from within the weather subsytem were synchronized to the time of day. Since I changed that to lighten the load on those ticks, saving the tod is not nearly as relevant.)

The image created is a ppm image, so it is really easy to just write it without a library.

Returns
0 if successful, 1 if failed.

Definition at line 3556 of file cfweather.cpp.

References weathermap_t::avgelev, BLUE, directions, weathermap_t::forestry, get_tod(), GREEN, weathermap_t::humid, llevDebug, llevError, Settings::localdir, LOG(), MAX, MAX_BUF, MIN, of_close(), of_open(), weathermap_t::pressure, PRESSURE_MAX, PRESSURE_MIN, weathermap_t::rainfall, real_temperature(), RED, settings, skies, weathermap_t::sky, speed, weathermap_t::water, weathermap, WEATHERMAPTILESX, WEATHERMAPTILESY, weathermap_t::winddir, and weathermap_t::windspeed.

Referenced by weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_winddirmap()

int write_winddirmap ( const Settings settings)

Save wind direction to localdir.

Parameters
settingsThe settings structure we are using to find localdir. Pretty sure it's the same one as the global settings, but oh well.
Returns
0 if successful, 1 if failure.

Definition at line 3407 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_winddirmap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_windspeedmap()

int write_windspeedmap ( const Settings settings)

Save the wind speed to localdir.

Parameters
settingsThe settings structure we are using to find localdir. Pretty sure it's the same one as the global settings, but oh well.
Returns
0 if successful, 1 if failure.

Definition at line 3374 of file cfweather.cpp.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, of_close(), of_open(), settings, weathermap, WEATHERMAPTILESX, and WEATHERMAPTILESY.

Referenced by read_winddirmap(), and weather_clock_listener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ arch_or_name

int weather_replace_t::arch_or_name

If set, tile matches the archetype name, else the object's name.

Definition at line 146 of file cfweather.cpp.

Referenced by check_replace_match(), and init_weather_replace().

◆ avgelev

int32_t weathermap_t::avgelev

Average elevation.

Definition at line 104 of file cfweather.cpp.

Referenced by init_humid_elev(), read_elevmap(), real_world_temperature(), and write_weather_images().

◆ command_handler

command_registration command_handler = 0
static

Definition at line 4818 of file cfweather.cpp.

Referenced by cfweather_close(), and cfweather_init().

◆ darkness

uint8_t weathermap_t::darkness

Indicates level of darkness of map.

Definition at line 106 of file cfweather.cpp.

◆ directions

const uint32_t directions[]
static
Initial value:
= {
0x0000FFFF,
0x000000FF,
0x00FF00FF,
0x00FFFFFF,
0x00000000,
0x00FF0000,
0x00FFFF00,
0x0000FF00
}

Colours used for wind directions.

winddir is the direction wind is coming from. 812 456 7 3 3 7 654 218

Definition at line 3508 of file cfweather.cpp.

Referenced by write_weather_images().

◆ doublestack_arch

archetype* weather_replace_t::doublestack_arch

If set, this other archetype will be added atop special_snow.

Definition at line 145 of file cfweather.cpp.

Referenced by init_weather_replace().

◆ dynamiclevel

uint16_t weather_settings_t::dynamiclevel

How dynamic is the world?

Definition at line 175 of file cfweather.cpp.

Referenced by cfweather_init(), command_weather(), init_weather_settings(), perform_weather(), tick_weather(), and weather_effect().

◆ elevmax

int weather_grow_t::elevmax

Maximum elevation for herb to grow.

Definition at line 164 of file cfweather.cpp.

◆ elevmin

int weather_grow_t::elevmin

Minimum elevation for herb to grow.

Definition at line 163 of file cfweather.cpp.

◆ forest_list

DensityConfig* forest_list = NULL

◆ forestry

int8_t weathermap_t::forestry

Range of forestedness.

100 is full forested. 0 is no trees. /*Dynamic parts

Definition at line 108 of file cfweather.cpp.

Referenced by init_humid_elev(), read_forestrymap(), smooth_wind(), temperature_calc(), and write_weather_images().

◆ global_clock_handler

event_registration global_clock_handler = 0
static

Definition at line 4814 of file cfweather.cpp.

Referenced by cfweather_close(), and cfweather_init().

◆ global_map_handler

event_registration global_map_handler = 0
static

Definition at line 4813 of file cfweather.cpp.

Referenced by cfweather_close(), and cfweather_init().

◆ global_mapload_handler

event_registration global_mapload_handler = 0
static

Definition at line 4816 of file cfweather.cpp.

◆ global_object_handler

event_registration global_object_handler = 0
static

Definition at line 4815 of file cfweather.cpp.

Referenced by cfweather_close(), and cfweather_init().

◆ growth_avoids

weather_avoids_t* growth_avoids = NULL

Definition at line 188 of file cfweather.cpp.

Referenced by avoid_weather(), cfweather_close(), and cfweather_init().

◆ gulf_stream_dir

int gulf_stream_dir[GULF_STREAM_WIDTH][WEATHERMAPTILESY]
static

Direction of the gulf stream.

Definition at line 202 of file cfweather.cpp.

Referenced by cfweather_init(), init_gulfstreammap(), plot_gulfstream(), read_gulfstreammap(), and write_gulfstreammap().

◆ gulf_stream_direction

int gulf_stream_direction
static

Definition at line 204 of file cfweather.cpp.

Referenced by cfweather_init(), init_gulfstreammap(), and plot_gulfstream().

◆ gulf_stream_speed

int gulf_stream_speed[GULF_STREAM_WIDTH][WEATHERMAPTILESY]
static

Gulf stream variables.

Todo:
These should probably be in a structure instead of loose variables.

Speed of the gulf stream.

Definition at line 200 of file cfweather.cpp.

Referenced by init_gulfstreammap(), plot_gulfstream(), read_gulfstreammap(), and write_gulfstreammap().

◆ gulf_stream_start

int gulf_stream_start
static

◆ herb

const char* weather_grow_t::herb

Arch name of item to grow.

Definition at line 154 of file cfweather.cpp.

Referenced by change_the_world(), and plant_a_garden().

◆ humax

int weather_grow_t::humax

Maximum humidity for herb to grow.

Definition at line 160 of file cfweather.cpp.

◆ humid

int8_t weathermap_t::humid

◆ humin

int weather_grow_t::humin

Minimum humidity for herb to grow.

Definition at line 159 of file cfweather.cpp.

◆ is_obj

int DensityConfig::is_obj

Definition at line 120 of file cfweather.cpp.

Referenced by get_config_tile(), and init_config_vals().

◆ name [1/2]

sstring DensityConfig::name

Definition at line 118 of file cfweather.cpp.

Referenced by cfweather_close(), get_config_tile(), and init_config_vals().

◆ name [2/2]

sstring weather_avoids_t::name

Tile archetype name.

It is always arch name, not object name.

Definition at line 133 of file cfweather.cpp.

Referenced by avoid_weather(), cfweather_close(), and init_weatheravoid().

◆ next [1/3]

DensityConfig* DensityConfig::next

Definition at line 126 of file cfweather.cpp.

Referenced by cfweather_close(), get_config_tile(), and init_config_vals().

◆ next [2/3]

weather_avoids_t* weather_avoids_t::next

The next item in the avoid list.

Definition at line 136 of file cfweather.cpp.

Referenced by avoid_weather(), cfweather_close(), and init_weatheravoid().

◆ next [3/3]

weather_replace_t* weather_replace_t::next

The next item in the replace list.

Definition at line 147 of file cfweather.cpp.

Referenced by cfweather_close(), init_weather_replace(), let_it_snow(), and singing_in_the_rain().

◆ pressure

int16_t weathermap_t::pressure

◆ rainfall

uint32_t weathermap_t::rainfall

Cumulative rainfall.

Definition at line 105 of file cfweather.cpp.

Referenced by change_the_world(), init_rainfall(), plant_a_garden(), process_rain(), and write_weather_images().

◆ random

int weather_grow_t::random

Random apparition factor.

Min 1, higher = lower chance of appearance.

Definition at line 156 of file cfweather.cpp.

◆ realtemp

int16_t weathermap_t::realtemp

Temperature at a given calculation step for this tile.

Definition at line 110 of file cfweather.cpp.

Referenced by calculate_temperature(), change_the_world(), do_map_precipitation(), let_it_snow(), plant_a_garden(), and singing_in_the_rain().

◆ rfmax

float weather_grow_t::rfmax

Maximum rainfall for herb to grow (inches/day).

Definition at line 158 of file cfweather.cpp.

◆ rfmin

float weather_grow_t::rfmin

Minimum rainfall for herb to grow (inches/day).

Definition at line 157 of file cfweather.cpp.

Referenced by change_the_world(), and plant_a_garden().

◆ season

int weather_grow_t::season

Season the herb can grow.

0=any or 1-5.

Definition at line 165 of file cfweather.cpp.

◆ season_tempchange

const int season_tempchange[HOURS_PER_DAY]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}

How to alter the temperature, based on the hour of the day.

This is used exclusively by real_temperature.

Todo:
Make different seasons affect temperature differently (becuase light/darkness)

Definition at line 874 of file cfweather.cpp.

Referenced by real_temperature().

◆ skies

const uint32_t skies[]
static
Initial value:
= {
0x000000FF,
0x000000BD,
0x0000007E,
0x0000FF00,
0x0000BD00,
0x00007E00,
0x00FFFF00,
0x00FF0000,
0x00FF00FF,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x003F3F3F,
0x007E7E7E,
0x00BDBDBD,
0x00FFFFFF
}

Colours used for weather types.

Definition at line 3522 of file cfweather.cpp.

Referenced by write_weather_images().

◆ sky

◆ snow

int weather_avoids_t::snow

Is this a long-term weather effect, like snow or a puddle? Used for various tests.

Definition at line 134 of file cfweather.cpp.

Referenced by avoid_weather(), and init_weatheravoid().

◆ special_snow

archetype* weather_replace_t::special_snow

The archetype name of the tile to place over specified tile.

Definition at line 144 of file cfweather.cpp.

Referenced by init_weather_replace(), and singing_in_the_rain().

◆ temp

int16_t weathermap_t::temp

Base temperature of this tile (F).

Definition at line 98 of file cfweather.cpp.

Referenced by read_temperaturemap(), real_temperature(), and temperature_calc().

◆ tempmax

int weather_grow_t::tempmax

Maximum temperature for herb to grow.

Definition at line 162 of file cfweather.cpp.

◆ tempmin

int weather_grow_t::tempmin

Minimum temperature for herb to grow.

Definition at line 161 of file cfweather.cpp.

◆ tile [1/2]

sstring weather_replace_t::tile

Tile archetype or object name.

Definition at line 143 of file cfweather.cpp.

Referenced by cfweather_close(), check_replace_match(), init_weather_replace(), and singing_in_the_rain().

◆ tile [2/2]

const char* weather_grow_t::tile

Arch tile to grow on, NULL if anything.

Definition at line 155 of file cfweather.cpp.

Referenced by change_the_world(), and plant_a_garden().

◆ todtick

unsigned long todtick

Game world time, in in-game hours.

See PTICKS_PER_CLOCK.

Definition at line 38 of file time.cpp.

Referenced by change_the_world(), get_tod(), init_clocks(), init_rainfall(), plant_a_garden(), tick_the_clock(), and write_todclock().

◆ value_density

int DensityConfig::value_density

Definition at line 122 of file cfweather.cpp.

Referenced by get_config_tile(), and init_config_vals().

◆ water

int8_t weathermap_t::water

-100 - 100 percentage of water tiles.

< 0 means it is a droughty spot

Definition at line 107 of file cfweather.cpp.

Referenced by humid_tile(), init_humid_elev(), read_watermap(), real_temperature(), and write_weather_images().

◆ water_list

DensityConfig* water_list = NULL

Definition at line 186 of file cfweather.cpp.

Referenced by cfweather_close(), cfweather_init(), and do_water_elev_calc().

◆ weather_avoids

weather_avoids_t* weather_avoids = NULL

Definition at line 187 of file cfweather.cpp.

Referenced by avoid_weather(), cfweather_close(), and cfweather_init().

◆ weather_evaporate

weather_replace_t* weather_evaporate = NULL

Definition at line 190 of file cfweather.cpp.

Referenced by cfweather_close(), cfweather_init(), and singing_in_the_rain().

◆ weather_grow

const weather_grow_t weather_grow[]
static
Initial value:
= {
{"mint", "grass", 10, 1.0, 2.0, 30, 100, 10, 25, -100, 9999, 2},
{"rose_red", "grass", 15, 1.0, 2.0, 30, 100, 10, 25, -100, 9999, 2},
{"rose_red", "hills", 15, 1.0, 2.0, 30, 100, 10, 25, -100, 9999, 2},
{"mint", "brush", 8, 1.0, 2.0, 30, 100, 10, 25, -100, 9999, 2},
{"blackroot", "swamp", 15, 1.6, 2.0, 60, 100, 20, 30, -100, 1500, 0},
{"mushroom_1", "grass", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"mushroom_2", "grass", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"mushroom_1", "swamp", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"mushroom_2", "swamp", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"mushroom_1", "hills", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"mushroom_2", "hills", 15, 1.6, 2.0, 60, 100, 3, 30, -100, 1500, 0},
{"pipeweed", "farmland", 20, 1.0, 2.0, 30, 100, 10, 25, 100, 5000, 0},
{"cabbage", "farmland", 10, 1.0, 2.0, 30, 100, 10, 25, -100, 9999, 0},
{"onion", "farmland", 10, 1.0, 2.0, 30, 100, 10, 25, 100, 9999, 0},
{"carrot", "farmland", 10, 1.0, 2.0, 30, 100, 10, 25, 100, 9999, 0},
{"thorns", "brush", 15, 0.5, 1.3, 30, 100, 10, 25, -100, 9999, 0},
{"mountain_foilage", "mountain", 6, 1.0, 2.0, 25, 100, 5, 30, 0, 15999, 2},
{NULL, NULL, 1, 0.0, 0.0, 0, 0, 0, 0, 0, 0, 0}
}

The table below is used to grow things on the map.

See include/tod.h for the meanings of all of the fields.

Definition at line 225 of file cfweather.cpp.

Referenced by plant_a_garden().

◆ weather_replace

weather_replace_t* weather_replace = NULL

Definition at line 189 of file cfweather.cpp.

Referenced by cfweather_close(), cfweather_init(), let_it_snow(), and singing_in_the_rain().

◆ weather_snowmelt

weather_replace_t* weather_snowmelt = NULL

Definition at line 191 of file cfweather.cpp.

Referenced by cfweather_close(), cfweather_init(), let_it_snow(), and singing_in_the_rain().

◆ weather_tile

const weather_grow_t weather_tile[]
static

The table below uses the same format as the one above.

However this table is used to change the layout of the worldmap itself. The tile parameter is a base tile to lay down underneath the herb tile.

Definition at line 256 of file cfweather.cpp.

Referenced by change_the_world().

◆ weathermap

◆ winddir

int8_t weathermap_t::winddir

Direction of wind.

Definition at line 102 of file cfweather.cpp.

Referenced by init_wind(), plot_gulfstream(), read_winddirmap(), smooth_wind(), and write_weather_images().

◆ windspeed

int8_t weathermap_t::windspeed

◆ wmperformstartx

int wmperformstartx
static

Current weather tile position.

Definition at line 207 of file cfweather.cpp.

Referenced by perform_weather(), and read_weatherposition().

◆ wmperformstarty

int wmperformstarty
static

Current weather tile position.

Definition at line 209 of file cfweather.cpp.

Referenced by perform_weather(), and read_weatherposition().

◆ worldmaptilesizex

uint32_t weather_settings_t::worldmaptilesizex

◆ worldmaptilesizey

uint32_t weather_settings_t::worldmaptilesizey

◆ wset