Crossfire Server, Trunk
swap.c File Reference
#include "global.h"
#include <string.h>
#include "object.h"
#include "output_file.h"
#include "sproto.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)
 
int players_on_map (mapstruct *m, int show_all)
 
void read_map_log (void)
 
int swap_map (mapstruct *map)
 
static void write_map_log (void)
 

Detailed Description

Functions that deal with swapping maps to disk to reclaim memory.

Definition in file swap.c.

Function Documentation

◆ check_active_maps()

void check_active_maps ( void  )

Finds maps in memory to swap.

Definition at line 196 of file swap.c.

References first_map, disinfect::map, MAP_IN_MEMORY, give::next, and swap_map().

Referenced by server_main().

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

◆ flush_old_maps()

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 247 of file swap.c.

References clean_tmp_map(), delete_map(), EVENT_MAPRESET, events_execute_global_event(), first_map, llevDebug, LOG(), m, MAP_IN_MEMORY, MAP_SWAPPED, players_on_map(), seconds(), set_map_timeout(), and TRUE.

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:

◆ players_on_map()

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 229 of file swap.c.

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

Referenced by flush_old_maps().

+ Here is the caller graph for this function:

◆ read_map_log()

void read_map_log ( void  )

Reads temporary maps information from disk.

Will LOG() in case of error.

Definition at line 70 of file swap.c.

References buf, get_linked_map(), llevDebug, Settings::localdir, LOG(), disinfect::map, MAP_MAXRESET, MAP_SWAPPED, MAX_BUF, safe_strncpy, seconds(), settings, split_string(), strdup_local, and Ice::tmp.

Referenced by init().

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

◆ swap_map()

int swap_map ( mapstruct map)

Swaps a map to disk.

After calling this function, the map will be:

  • swapped to disk
  • kept in memory in case of save error
Parameters
mapmap to swap.
Returns
one of SAVE_ERROR_xxx.

Definition at line 135 of file swap.c.

References delete_map(), draw_ext_info_format(), EVENT_MAPRESET, events_execute_global_event(), first_player, FLAG_REMOVED, free_map(), llevDebug, llevError, LOG(), disinfect::map, obj::map, MAP_IN_MEMORY, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOADSAVE, NDI_ALL_DMS, NDI_RED, NDI_UNIQUE, pl::next, pl::ob, pets_attempt_follow(), altar_valkyrie::pl, QUERY_FLAG, Settings::recycle_tmp_maps, altar_valkyrie::res, rndm(), SAVE_ERROR_NOT_IN_MEMORY, SAVE_ERROR_OK, SAVE_ERROR_PLAYER, save_map(), SAVE_MODE_NORMAL, seconds(), set_map_reset_time(), settings, TRUE, and write_map_log().

Referenced by check_active_maps(), clean_tmp_files(), command_reset(), and set_map_timeout().

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

◆ write_map_log()

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 33 of file swap.c.

References buf, first_map, Settings::localdir, disinfect::map, MAP_IN_MEMORY, MAX_BUF, of_close(), of_open(), and settings.

Referenced by swap_map().

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