Added support for RSW 2.2 (#4627)

Merged mapserver and mapcache RSW reading code
This commit is contained in:
Lemongrass3110
2020-02-11 23:49:47 +01:00
committed by GitHub
parent 9b6976ea7b
commit d12b4fdca0
4 changed files with 44 additions and 22 deletions

View File

@@ -17,8 +17,6 @@
#include "../common/showmsg.hpp"
#include "../common/utils.hpp"
#define NO_WATER 1000000
std::string grf_list_file = "conf/grf-files.txt";
std::string map_list_file = "map_index.txt";
std::string map_cache_file;
@@ -66,14 +64,9 @@ int read_map(char *name, struct map_data *m)
// Open map RSW
sprintf(filename,"data\\%s.rsw", name);
rsw = (unsigned char *)grfio_read(filename);
// Read water height
if (rsw) {
water_height = (int)GetFloat(rsw+166);
aFree(rsw);
} else
water_height = NO_WATER;
water_height = grfio_read_rsw_water_level( filename );
// Read map size and allocate needed memory
m->xs = (int16)GetULong(gat+6);
@@ -95,7 +88,7 @@ int read_map(char *name, struct map_data *m)
uint32 type = GetULong( gat + off + 16 );
off += 20;
if (type == 0 && water_height != NO_WATER && height > water_height)
if (type == 0 && water_height != RSW_NO_WATER && height > water_height)
type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water)
m->cells[xy] = (unsigned char)type;