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

@@ -3704,8 +3704,6 @@ void map_data_copyall (void) {
}
}
#define NO_WATER 1000000
/*
* Reads from the .rsw for each map
* Returns water height (or NO_WATER if file doesn't exist) or other error is encountered.
@@ -3715,7 +3713,7 @@ void map_data_copyall (void) {
int map_waterheight(char* mapname)
{
char fn[256];
char *rsw, *found;
char *found;
//Look up for the rsw
sprintf(fn, "data\\%s.rsw", mapname);
@@ -3724,15 +3722,7 @@ int map_waterheight(char* mapname)
if (found) strcpy(fn, found); // replace with real name
// read & convert fn
rsw = (char *) grfio_read (fn);
if (rsw)
{ //Load water height from file
int wh = (int) *(float*)(rsw+166); //FIXME Casting between integer* and float* which have an incompatible binary data representation.
aFree(rsw);
return wh;
}
ShowWarning("Failed to find water level for (%s)\n", mapname, fn);
return NO_WATER;
return grfio_read_rsw_water_level( fn );
}
/*==================================
@@ -3767,7 +3757,7 @@ int map_readgat (struct map_data* m)
uint32 type = *(uint32*)( 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->cell[xy] = map_gat2cell(type);