Skip to content

Commit

Permalink
Add option to recache individual maps
Browse files Browse the repository at this point in the history
Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Feb 17, 2018
1 parent 9b8256a commit e2ba5d8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/plugins/mapcache.c
Expand Up @@ -70,6 +70,7 @@ struct old_mapcache_map_info {
#define NO_WATER 1000000

VECTOR_DECL(char *) maplist;
bool needs_grfio;


/**
Expand Down Expand Up @@ -133,7 +134,7 @@ bool write_mapcache(const uint8 *buf, int32 buf_len, bool is_compressed, const c


snprintf(file_path, sizeof(file_path), "%s%s%s.%s", "maps/", DBPATH, mapname, "mcache");
new_mapcache_fp = fopen(file_path, "w+b");
new_mapcache_fp = fopen(file_path, "wb");

if (new_mapcache_fp == NULL) {
ShowWarning("Could not open file '%s', map cache creating failed.\n", file_path);
Expand Down Expand Up @@ -332,8 +333,6 @@ bool mapcache_rebuild(void)
}
}

grfio->init("conf/grf-files.txt");

for (i = 0; i < VECTOR_LENGTH(maplist); ++i) {
ShowStatus("Creating mapcache: %s"CL_CLL"\r", VECTOR_INDEX(maplist, i));
mapcache_cache_map(VECTOR_INDEX(maplist, i));
Expand All @@ -350,21 +349,36 @@ CMDLINEARG(convertmapcache)

CMDLINEARG(rebuild)
{
needs_grfio = true;
grfio->init("conf/grf-files.txt");
map->minimal = true;
return mapcache_rebuild();
}

CMDLINEARG(cachemap)
{
needs_grfio = true;
grfio->init("conf/grf-files.txt");
map->minimal = true;
return mapcache_cache_map(params);
}

HPExport void server_preinit(void)
{
addArg("--convert-old-mapcache", false, convertmapcache,
"Converts an old db/"DBPATH"map_cache.dat file to the new format.");
addArg("--rebuild-mapcache", false, rebuild,
"Rebuilds the entire mapcache folder (maps/"DBPATH"), using db/map_index.txt as index.");
addArg("--map", true, cachemap,
"Rebuilds an individual map's cache into maps/"DBPATH" (usage: --map <map_name_without_extension>).");

needs_grfio = false;
VECTOR_INIT(maplist);
}

HPExport void plugin_final(void)
{
VECTOR_CLEAR(maplist);
if (needs_grfio)
grfio->final();
}

0 comments on commit e2ba5d8

Please sign in to comment.