Make the prevailing type of planet topo data signed; also gets rid of several warnings

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3455 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-20 03:33:53 +00:00
parent f6959074cb
commit 8096eeca2c
2 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ struct planet_orbit
{ {
FRAME TopoZoomFrame; FRAME TopoZoomFrame;
// 4x scaled topo image for planet-side // 4x scaled topo image for planet-side
BYTE *lpTopoData; SBYTE *lpTopoData;
// normal topo data; expressed in elevation levels // normal topo data; expressed in elevation levels
// data is signed for planets other than gas giants // data is signed for planets other than gas giants
// transformed to light variance map for 3d planet // transformed to light variance map for 3d planet
+9 -10
View File
@@ -102,7 +102,7 @@ typedef struct
} POINT3; } POINT3;
static void static void
RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h) RenderTopography (FRAME DstFrame, SBYTE *pTopoData, int w, int h)
{ {
FRAME OldFrame; FRAME OldFrame;
@@ -123,7 +123,7 @@ RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h)
const PlanetFrame *PlanDataPtr; const PlanetFrame *PlanDataPtr;
PRIMITIVE BatchArray[NUM_BATCH_POINTS]; PRIMITIVE BatchArray[NUM_BATCH_POINTS];
PRIMITIVE *pBatch; PRIMITIVE *pBatch;
BYTE *pSrc; SBYTE *pSrc;
BYTE *xlat_tab; BYTE *xlat_tab;
BYTE *cbase; BYTE *cbase;
POINT oldOrigin; POINT oldOrigin;
@@ -158,9 +158,9 @@ RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h)
{ {
BYTE *ctab; BYTE *ctab;
d = (SBYTE)*pSrc; d = *pSrc;
if (AlgoType == GAS_GIANT_ALGO) if (AlgoType == GAS_GIANT_ALGO)
{ { // make elevation value non-negative
d &= 255; d &= 255;
} }
else else
@@ -1341,7 +1341,7 @@ TopoVarianceCalc (int factor)
} }
static void static void
TopoScale4x (BYTE *pDstTopo, BYTE *pSrcTopo, int num_faults, int fault_var) TopoScale4x (SBYTE *pDstTopo, SBYTE *pSrcTopo, int num_faults, int fault_var)
{ {
// Interpolate the topographical data by connecting the elevations // Interpolate the topographical data by connecting the elevations
// to their nearest neighboors using straight lines (in random // to their nearest neighboors using straight lines (in random
@@ -1731,7 +1731,6 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
CONTEXT OldContext; CONTEXT OldContext;
CONTEXT TopoContext; CONTEXT TopoContext;
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
BYTE *pScaledTopo = 0;
BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0; BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0;
old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed);
@@ -1764,7 +1763,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
if (GetFrameCount (SurfDefFrame) > 1) if (GetFrameCount (SurfDefFrame) > 1)
{ // 2nd frame is elevation data { // 2nd frame is elevation data
int i; int i;
BYTE* elev; SBYTE* elev;
ElevFrame = SetAbsFrameIndex (SurfDefFrame, 1); ElevFrame = SetAbsFrameIndex (SurfDefFrame, 1);
if (GetFrameWidth (ElevFrame) != MAP_WIDTH if (GetFrameWidth (ElevFrame) != MAP_WIDTH
@@ -1782,7 +1781,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
i < MAP_WIDTH * MAP_HEIGHT; i < MAP_WIDTH * MAP_HEIGHT;
++i, ++elev) ++i, ++elev)
{ {
*elev -= 128; *elev = *(BYTE *)elev - 128;
} }
} }
else else
@@ -1884,14 +1883,14 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
} }
pSolarSysState->XlatPtr = GetStringAddress (pSolarSysState->XlatRef); pSolarSysState->XlatPtr = GetStringAddress (pSolarSysState->XlatRef);
RenderTopography (pSolarSysState->TopoFrame, RenderTopography (pSolarSysState->TopoFrame,
pSolarSysState->Orbit.lpTopoData, MAP_WIDTH, MAP_HEIGHT); Orbit->lpTopoData, MAP_WIDTH, MAP_HEIGHT);
} }
if (!shielded && PlanetInfo->AtmoDensity != GAS_GIANT_ATMOSPHERE) if (!shielded && PlanetInfo->AtmoDensity != GAS_GIANT_ATMOSPHERE)
{ // produce 4x scaled topo image for Planetside { // produce 4x scaled topo image for Planetside
// for the planets that we can land on // for the planets that we can land on
pScaledTopo = HMalloc (MAP_WIDTH * 4 * MAP_HEIGHT * 4); SBYTE *pScaledTopo = HMalloc (MAP_WIDTH * 4 * MAP_HEIGHT * 4);
if (pScaledTopo) if (pScaledTopo)
{ {
TopoScale4x (pScaledTopo, Orbit->lpTopoData, TopoScale4x (pScaledTopo, Orbit->lpTopoData,