Skip to content

Commit

Permalink
Fix saving water level heights. Existing savegames with wrong heights…
Browse files Browse the repository at this point in the history
… remain wrong.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9815 4a71c877-e1ca-e34f-864e-861f7616d084
(cherry picked from commit 47beb57)
  • Loading branch information
perim authored and buginator committed Oct 23, 2010
1 parent 0f82ada commit e98e49f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ BOOL mapLoad(char *filename)
environReset();

// set the river bed
for (i=0;i<mapWidth;i++)
for (i = 0; i < mapWidth; i++)
{
for (j=0;j<mapHeight;j++)
for (j = 0; j < mapHeight; j++)
{
// FIXME: magic number
mapTile(i, j)->waterLevel = mapTile(i, j)->height - world_coord(1) / 3.0f / (float)ELEVATION_SCALE;
Expand Down Expand Up @@ -1690,7 +1690,14 @@ BOOL mapSave(char **ppFileData, UDWORD *pFileSize)
for(i=0; i<mapWidth*mapHeight; i++)
{
psTileData->texture = psTile->texture;
psTileData->height = psTile->height;
if (psTile->ground == waterGroundType)
{
psTileData->height = MIN(255.0f, psTile->height + (WATER_DEPTH - 2.0f * environGetData(i % mapWidth, i / mapWidth)) / (float)ELEVATION_SCALE);
}
else
{
psTileData->height = psTile->height;
}

/* MAP_SAVETILE */
endian_uword(&psTileData->texture);
Expand Down

0 comments on commit e98e49f

Please sign in to comment.