summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-04-12 02:16:48 +0200
committerHaru <haru@dotalux.com>2018-02-17 15:10:13 +0100
commite2ba5d8b144c1251ce68fc8b1c95ee89250cf169 (patch)
treef75872f67fff65181d34a2a09db21b6c937c3d5b /src
parent9b8256a63047a6a873025ae346b0804c4db52912 (diff)
downloadhercules-e2ba5d8b144c1251ce68fc8b1c95ee89250cf169.tar.gz
hercules-e2ba5d8b144c1251ce68fc8b1c95ee89250cf169.tar.bz2
hercules-e2ba5d8b144c1251ce68fc8b1c95ee89250cf169.tar.xz
hercules-e2ba5d8b144c1251ce68fc8b1c95ee89250cf169.zip
Add option to recache individual maps
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/mapcache.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/plugins/mapcache.c b/src/plugins/mapcache.c
index 95e6ead04..f1dab97c1 100644
--- a/src/plugins/mapcache.c
+++ b/src/plugins/mapcache.c
@@ -70,6 +70,7 @@ struct old_mapcache_map_info {
#define NO_WATER 1000000
VECTOR_DECL(char *) maplist;
+bool needs_grfio;
/**
@@ -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);
@@ -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));
@@ -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();
}