![]() |
Crossfire Server, Trunk
1.75.0
|
#include "global.h"
#include <string.h>
#include "object.h"
#include "output_file.h"
#include "sproto.h"
#include "stats.h"
Go to the source code of this file.
Functions | |
void | check_active_maps (void) |
Finds maps in memory to swap. More... | |
void | flush_old_maps (void) |
Reset maps that need to, remove their swap file. More... | |
bool | map_can_reset (const mapstruct *map, long current_time) |
Returns whether a map can be reset, including all other maps in the same reset group. More... | |
static bool | map_can_reset_no_group (const mapstruct *map, long current_time) |
Returns whether a map can be reset, without taking its reset group into account. More... | |
int | players_on_map (mapstruct *m, int show_all) |
Returns the count of players on a map, calculated from player list. More... | |
void | read_map_log (void) |
Reads temporary maps information from disk. More... | |
int | swap_map (mapstruct *map) |
Swaps a map to disk. More... | |
static void | write_map_log (void) |
Writes out information on all the temporary maps. More... | |
Functions that deal with swapping maps to disk to reclaim memory.
Definition in file swap.cpp.
void check_active_maps | ( | void | ) |
Finds maps in memory to swap.
Definition at line 201 of file swap.cpp.
References first_map, mapstruct::in_memory, MAP_IN_MEMORY, mapstruct::next, swap_map(), and mapstruct::timeout.
Referenced by server_main().
void flush_old_maps | ( | void | ) |
Reset maps that need to, remove their swap file.
This is very useful if the tmp-disk is very full.
Definition at line 291 of file swap.cpp.
References clean_tmp_map(), delete_map(), EVENT_MAPRESET, events_execute_global_event(), first_map, llevDebug, LOG(), m, map_can_reset(), MAP_IN_MEMORY, MAP_SWAPPED, players_on_map(), seconds(), set_map_timeout(), and TRUE.
Referenced by command_reset(), and do_specials().
bool map_can_reset | ( | const mapstruct * | map, |
long | current_time | ||
) |
Returns whether a map can be reset, including all other maps in the same reset group.
map | map to consider. |
current_time | current time. |
Definition at line 266 of file swap.cpp.
References first_map, map_can_reset_no_group(), mapstruct::next, and mapstruct::reset_group.
Referenced by flush_old_maps().
|
static |
Returns whether a map can be reset, without taking its reset group into account.
map | map to consider. |
current_time | current time. |
Definition at line 253 of file swap.cpp.
References mapstruct::in_memory, MAP_SWAPPED, mapstruct::reset_time, and mapstruct::tmpname.
Referenced by map_can_reset().
int players_on_map | ( | mapstruct * | m, |
int | show_all | ||
) |
Returns the count of players on a map, calculated from player list.
m | map we want the count of players on. |
show_all | if true, show everyone. If not, don't show hidden players (dms) |
Definition at line 234 of file swap.cpp.
References first_player, FLAG_REMOVED, m, object::map, object::next, unpaid_count::pl, and QUERY_FLAG.
Referenced by flush_old_maps().
void read_map_log | ( | void | ) |
Reads temporary maps information from disk.
Will LOG() in case of error.
Definition at line 71 of file swap.cpp.
References buf, mapstruct::darkness, mapstruct::difficulty, get_linked_map(), mapstruct::in_memory, llevDebug, Settings::localdir, LOG(), MAP_MAXRESET, MAP_SWAPPED, MAX_BUF, mapstruct::path, mapstruct::reset_time, safe_strncpy, seconds(), settings, split_string(), strdup_local, mapstruct::timeout, and mapstruct::tmpname.
Referenced by init().
int swap_map | ( | mapstruct * | map | ) |
Swaps a map to disk.
After calling this function, the map will be:
map | map to swap. |
Definition at line 136 of file swap.cpp.
References delete_map(), draw_ext_info_format(), EVENT_MAPRESET, events_execute_global_event(), first_player, mapstruct::fixed_resettime, FLAG_REMOVED, free_map(), mapstruct::in_memory, llevDebug, llevError, LOG(), object::map, MAP_IN_MEMORY, maps_swapped_total, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOADSAVE, NDI_ALL_DMS, NDI_RED, NDI_UNIQUE, object::next, mapstruct::next, mapstruct::path, pets_attempt_follow(), unpaid_count::pl, QUERY_FLAG, Settings::recycle_tmp_maps, mapstruct::reset_group, mapstruct::reset_time, rndm(), SAVE_ERROR_NOT_IN_MEMORY, SAVE_ERROR_OK, SAVE_ERROR_PLAYER, save_map(), SAVE_MODE_NORMAL, seconds(), set_map_reset_time(), settings, mapstruct::timeout, TRUE, and write_map_log().
Referenced by check_active_maps(), clean_tmp_files(), and command_reset().
|
static |
Writes out information on all the temporary maps.
It is called by swap_map().
Will LOG() in case of error.
Definition at line 34 of file swap.cpp.
References buf, mapstruct::darkness, mapstruct::difficulty, first_map, mapstruct::in_memory, Settings::localdir, MAP_IN_MEMORY, MAX_BUF, mapstruct::next, of_close(), of_open(), mapstruct::path, mapstruct::reset_time, settings, time, and mapstruct::tmpname.
Referenced by swap_map().