Crossfire Server  1.75.0
weather.cpp File Reference

Time-related functions. More...

#include <global.h>
#include <tod.h>
#include <map.h>
#include <sproto.h>
#include <assert.h>

Go to the source code of this file.

Functions

static void dawn_to_dusk (const timeofday_t *tod)
 Compute the darkness level for all loaded maps in the game. More...
 
void set_darkness_map (mapstruct *m)
 Set the darkness level for a map, based on the time of the day. More...
 
void tick_the_clock (void)
 This performs the basic function of advancing the clock one tick forward. More...
 

Variables

static const int season_timechange [5][HOURS_PER_DAY]
 How to alter darkness, based on time of day and season. More...
 

Detailed Description

Time-related functions.

Definition in file weather.cpp.

Function Documentation

◆ dawn_to_dusk()

static void dawn_to_dusk ( const timeofday_t tod)
static

Compute the darkness level for all loaded maps in the game.

Parameters
todtime of day to compute darkness for.

Definition at line 68 of file weather.cpp.

References change_map_light(), first_map, timeofday_t::hour, m, mapstruct::next, mapstruct::outdoor, timeofday_t::season, and season_timechange.

Referenced by tick_the_clock().

◆ set_darkness_map()

void set_darkness_map ( mapstruct m)

Set the darkness level for a map, based on the time of the day.

Parameters
mmap to alter.

Definition at line 44 of file weather.cpp.

References change_map_light(), mapstruct::darkness, get_tod(), timeofday_t::hour, HOURS_PER_DAY, mapstruct::outdoor, timeofday_t::season, and season_timechange.

Referenced by do_auto_apply(), generate_random_map(), and ready_map_name().

◆ tick_the_clock()

void tick_the_clock ( void  )

This performs the basic function of advancing the clock one tick forward.

Every 20 ticks, the clock is saved to disk. It is also saved on shutdown. Any time dependant functions should be called from this function, and probably be passed tod as an argument. Please don't modify tod in the dependant function.

Definition at line 94 of file weather.cpp.

References dawn_to_dusk(), get_tod(), todtick, and write_todclock().

Referenced by do_specials().

Variable Documentation

◆ season_timechange

const int season_timechange[5][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 },
{ 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0 }
}

How to alter darkness, based on time of day and season.

Definition at line 29 of file weather.cpp.

Referenced by dawn_to_dusk(), and set_darkness_map().