SAGA2: Amend unsafe and strange pointer arithmetics in lineTerrain()

This commit is contained in:
Eugene Sandulenko 2021-06-23 18:54:12 +02:00
parent 14811e3202
commit a8600afb26
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -376,8 +376,8 @@ uint32 lineTerrain(
uint16 subTileMask_ = 0; uint16 subTileMask_ = 0;
int16 tileStartZ, int16 tileStartZ,
*minZ, minZ,
*maxZ; maxZ;
int32 curZ, int32 curZ,
zStep; zStep;
@ -423,11 +423,11 @@ uint32 lineTerrain(
curZ = (int32)curSubTile.z << 16; curZ = (int32)curSubTile.z << 16;
zStep = ((int32)(destSubTile.z - curSubTile.z) << 16); zStep = ((int32)(destSubTile.z - curSubTile.z) << 16);
if (zStep > 0) { if (zStep > 0) {
minZ = &tileStartZ; minZ = tileStartZ;
maxZ = &curSubTile.z; maxZ = curSubTile.z;
} else { } else {
minZ = &curSubTile.z; minZ = curSubTile.z;
maxZ = &tileStartZ; maxZ = tileStartZ;
} }
if (uDiff > vDiff) { if (uDiff > vDiff) {
@ -447,8 +447,8 @@ uint32 lineTerrain(
mapNum, mapNum,
tilePt, tilePt,
subTileMask_, subTileMask_,
*minZ, minZ,
*maxZ + 1); maxZ + 1);
if (terrain & opaqueTerrain) return terrain; if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> kTileSubShift; tilePt.u = curSubTile.u >> kTileSubShift;
@ -478,8 +478,8 @@ uint32 lineTerrain(
mapNum, mapNum,
tilePt, tilePt,
subTileMask_, subTileMask_,
*minZ, minZ,
*maxZ + 1); maxZ + 1);
if (terrain & opaqueTerrain) return terrain; if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> kTileSubShift; tilePt.v = curSubTile.v >> kTileSubShift;
@ -516,8 +516,8 @@ uint32 lineTerrain(
mapNum, mapNum,
tilePt, tilePt,
subTileMask_, subTileMask_,
*minZ, minZ,
*maxZ + 1); maxZ + 1);
if (terrain & opaqueTerrain) return terrain; if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> kTileSubShift; tilePt.v = curSubTile.v >> kTileSubShift;
@ -548,8 +548,8 @@ uint32 lineTerrain(
mapNum, mapNum,
tilePt, tilePt,
subTileMask_, subTileMask_,
*minZ, minZ,
*maxZ + 1); maxZ + 1);
if (terrain & opaqueTerrain) return terrain; if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> kTileSubShift; tilePt.u = curSubTile.u >> kTileSubShift;
@ -577,8 +577,8 @@ uint32 lineTerrain(
mapNum, mapNum,
tilePt, tilePt,
subTileMask_, subTileMask_,
*minZ, minZ,
*maxZ); maxZ);
return terrain; return terrain;
} }