Crossfire Server, Branches 1.12  R18729
swap.c File Reference
#include <global.h>
#include <sproto.h>
#include <object.h>
+ Include dependency graph for swap.c:

Go to the source code of this file.

Functions

void check_active_maps (void)
 
void flush_old_maps (void)
 
static mapstructmap_least_timeout (const char *except_level)
 
int players_on_map (mapstruct *m, int show_all)
 
void read_map_log (void)
 
void swap_below_max (const char *except_level)
 
int swap_map (mapstruct *map)
 
static void write_map_log (void)
 

Detailed Description

All those functions deal with swapping maps to disk to claim memory space.

Definition in file swap.c.

Function Documentation

void check_active_maps ( void  )

Finds maps in memory to reset.

Todo:
The check for MAX_OBJECTS_LWM is wrongly placed, and should be moved elsewhere.

Definition at line 206 of file swap.c.

References first_map, mapdef::in_memory, MAP_IN_MEMORY, mapdef::next, swap_map(), and mapdef::timeout.

Referenced by server_main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void flush_old_maps ( void  )

Removes tmp-files of maps which are going to be reset next time they are visited. This is very useful if the tmp-disk is very full.

Definition at line 305 of file swap.c.

References clean_tmp_map(), delete_map(), EVENT_MAPRESET, execute_global_event(), first_map, mapdef::in_memory, mapdef::is_template, llevDebug, LOG(), MAP_IN_MEMORY, MAP_SWAPPED, mapdef::next, mapdef::path, players_on_map(), seconds(), set_map_timeout(), mapdef::timeout, mapdef::tmpname, TRUE, and mapdef::unique.

Referenced by block_until_new_connection(), command_reset(), and do_specials().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static mapstruct* map_least_timeout ( const char *  except_level)
static

Returns the map with the lowest timeout variable (not 0).

Parameters
except_levelpath of map to ignore for reset. Musn't be NULL.
Returns
map, or NULL if no map is ready for reset.

Definition at line 232 of file swap.c.

References first_map, mapdef::in_memory, MAP_IN_MEMORY, MAP_MAXTIMEOUT, mapdef::next, mapdef::path, and mapdef::timeout.

Referenced by swap_below_max().

+ Here is the caller graph for this function:

int players_on_map ( mapstruct m,
int  show_all 
)

Returns the count of players on a map, calculated from player list.

Parameters
mmap we want the count of players on.
show_allif true, show everyone. If not, don't show hidden players (dms)
Returns
player count.
Todo:
this doesn't take into account transports. Should be removed when mapstruct::players is valid.

Definition at line 287 of file swap.c.

References first_player, FLAG_REMOVED, pl::hidden, obj::map, pl::next, pl::ob, and QUERY_FLAG.

Referenced by flush_old_maps(), and map_info().

+ Here is the caller graph for this function:

void read_map_log ( void  )

Reads temporary maps information from disk.

Will LOG() in case of error.

Definition at line 83 of file swap.c.

References mapdef::darkness, mapdef::difficulty, get_linked_map(), mapdef::in_memory, llevDebug, Settings::localdir, LOG(), MAP_MAXRESET, MAP_SWAPPED, MAX_BUF, mapdef::path, mapdef::reset_time, seconds(), settings, snprintf(), strdup_local(), mapdef::timeout, and mapdef::tmpname.

Referenced by init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void swap_below_max ( const char *  except_level)

Tries to swap out maps which are still in memory, because of MAP_TIMEOUT until used objects is below MAX_OBJECTS or there are no more maps to swap.

Parameters
except_levelpath of map to ignore for reset. Musn't be NULL.

Definition at line 253 of file swap.c.

References llevDebug, LOG(), map_least_timeout(), MAX_OBJECTS, nrofallocobjects, nroffreeobjects, mapdef::path, swap_map(), and mapdef::timeout.

Referenced by enter_map().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int swap_map ( mapstruct map)
static void write_map_log ( void  )
static

Writes out information on all the temporary maps. It is called by swap_map().

Will LOG() in case of error.

Definition at line 46 of file swap.c.

References mapdef::darkness, mapdef::difficulty, first_map, mapdef::in_memory, llevError, Settings::localdir, LOG(), MAP_IN_MEMORY, MAX_BUF, mapdef::next, mapdef::path, mapdef::reset_time, settings, snprintf(), and mapdef::tmpname.

Referenced by swap_map().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: