diff options
Diffstat (limited to 'src/plugins/mapcache.c')
-rw-r--r-- | src/plugins/mapcache.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/plugins/mapcache.c b/src/plugins/mapcache.c index 5e44492f6..3dc6e3b34 100644 --- a/src/plugins/mapcache.c +++ b/src/plugins/mapcache.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * -* Copyright (C) 2013-2015 Hercules Dev Team +* Copyright (C) 2013-2020 Hercules Dev Team * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -281,7 +281,28 @@ bool mapcache_cache_map(const char *mapname) if (rsw == NULL) { water_height = NO_WATER; } else { - water_height = (int)GetFloat(rsw + 166); + if (memcmp(rsw, "GRSW", 4) != 0) { + ShowError("mapcache_cache_map: file %s is not in rsw format\n", filepath); + aFree(rsw); + return false; + } + int major_version = rsw[4]; + int minor_version = rsw[5]; + if (major_version > 2 || (major_version == 2 && minor_version > 2)) { + ShowError("mapcache_cache_map: Unsupported version %d.%d for rsw file %s\n", major_version, minor_version, filepath); + aFree(rsw); + return false; + } + if (major_version < 1 || (major_version == 1 && minor_version <= 4)) { + ShowError("mapcache_cache_map: Unsupported version %d.%d for rsw file %s\n", major_version, minor_version, filepath); + aFree(rsw); + return false; + } + int offset = 166; + if (major_version == 2 && minor_version >= 2) { + offset = 167; + } + water_height = (int)GetFloat(rsw + offset); aFree(rsw); } |