From 733ab6e9119f056a7472b1d4166f00dc3a35da17 Mon Sep 17 00:00:00 2001 From: Cyp Date: Tue, 15 Feb 2011 14:25:41 +0100 Subject: [PATCH] Fix compilation with C++0x compilers. Can't use nullptr, until switching to C++0x. --- lib/netplay/nettypes.cpp | 6 +++--- src/pointtree.cpp | 4 ++-- src/raycast.cpp | 2 +- src/terrain.cpp | 16 ++++++++-------- src/visibility.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/netplay/nettypes.cpp b/lib/netplay/nettypes.cpp index 86d7281cb..ce142a7a2 100644 --- a/lib/netplay/nettypes.cpp +++ b/lib/netplay/nettypes.cpp @@ -83,7 +83,7 @@ static void queue(const Q &q, uint8_t &v) template static void queue(const Q &q, uint16_t &v) { - uint8_t b[2] = {v>>8, v}; + uint8_t b[2] = {uint8_t(v>>8), uint8_t(v)}; queue(q, b[0]); queue(q, b[1]); if (Q::Direction == Q::Read) @@ -124,7 +124,7 @@ static void queue(const Q &q, uint32_t &vOrig) template static void queueLarge(const Q &q, uint32_t &v) { - uint16_t b[2] = {v>>16, v}; + uint16_t b[2] = {uint16_t(v>>16), uint16_t(v)}; queue(q, b[0]); queue(q, b[1]); if (Q::Direction == Q::Read) @@ -136,7 +136,7 @@ static void queueLarge(const Q &q, uint32_t &v) template static void queue(const Q &q, uint64_t &v) { - uint32_t b[2] = {v>>32, v}; + uint32_t b[2] = {uint32_t(v>>32), uint32_t(v)}; queue(q, b[0]); queue(q, b[1]); if (Q::Direction == Q::Read) diff --git a/src/pointtree.cpp b/src/pointtree.cpp index 0619b49bf..a356e9c56 100644 --- a/src/pointtree.cpp +++ b/src/pointtree.cpp @@ -236,8 +236,8 @@ PointTree::ResultVector &PointTree::queryMaybeFilter(Filter &filter, int32_t x, for (int r = 0; r != numRanges; ++r) { // Find range of points which may be close enough. Range is [i1 ... i2 - 1]. The pointers are ignored when searching. - unsigned i1 = std::lower_bound(points.begin(), points.end(), Point(ranges[r].a, NULL), pointTreeSortFunction) - points.begin(); - unsigned i2 = std::upper_bound(points.begin() + i1, points.end(), Point(ranges[r].z, NULL), pointTreeSortFunction) - points.begin(); + unsigned i1 = std::lower_bound(points.begin(), points.end(), Point(ranges[r].a, (void *)NULL), pointTreeSortFunction) - points.begin(); + unsigned i2 = std::upper_bound(points.begin() + i1, points.end(), Point(ranges[r].z, (void *)NULL), pointTreeSortFunction) - points.begin(); for (unsigned i = current(filter.data, i1); i < i2; i = current(filter.data, i + 1)) { diff --git a/src/raycast.cpp b/src/raycast.cpp index 0111a3c69..ff08faa03 100644 --- a/src/raycast.cpp +++ b/src/raycast.cpp @@ -123,7 +123,7 @@ static bool getTileHeightCallback(Vector3i pos, int32_t dist, void *data) void getBestPitchToEdgeOfGrid(UDWORD x, UDWORD y, uint16_t direction, uint16_t *pitch) { - HeightCallbackHelp_t help = { map_Height(x,y), 0.0f }; + HeightCallbackHelp_t help = {map_Height(x,y), 0}; rayCast(Vector3i(x, y, 0), direction, 5430, getTileHeightCallback, &help); // FIXME Magic value diff --git a/src/terrain.cpp b/src/terrain.cpp index 312576d53..606da9f91 100644 --- a/src/terrain.cpp +++ b/src/terrain.cpp @@ -1077,8 +1077,8 @@ void drawTerrain(void) int layer; int offset, size; float xPos, yPos, distance; - const GLfloat paramsX[4] = {1.0/world_coord(mapWidth)*((float)mapWidth/lightmapWidth), 0, 0, 0}; - const GLfloat paramsY[4] = {0, 0, -1.0/world_coord(mapHeight)*((float)mapHeight/lightmapHeight), 0}; + const GLfloat paramsX[4] = {1.0f/world_coord(mapWidth)*((float)mapWidth/lightmapWidth), 0, 0, 0}; + const GLfloat paramsY[4] = {0, 0, -1.0f/world_coord(mapHeight)*((float)mapHeight/lightmapHeight), 0}; /////////////////////////////////// // set up the lightmap texture @@ -1280,8 +1280,8 @@ void drawTerrain(void) // draw each layer separately for (layer = 0; layer < numGroundTypes; layer++) { - const GLfloat paramsX[4] = {0, 0, -1.0/world_coord(psGroundTypes[layer].textureSize), 0}; - const GLfloat paramsY[4] = {1.0/world_coord(psGroundTypes[layer].textureSize), 0, 0, 0}; + const GLfloat paramsX[4] = {0, 0, -1.0f/world_coord(psGroundTypes[layer].textureSize), 0}; + const GLfloat paramsY[4] = {1.0f/world_coord(psGroundTypes[layer].textureSize), 0, 0, 0}; // load the texture texPage = iV_GetTexture(psGroundTypes[layer].textureName); @@ -1400,10 +1400,10 @@ void drawTerrain(void) void drawWater(void) { int x, y; - const GLfloat paramsX[4] = {0, 0, -1.0/world_coord(4), 0}; - const GLfloat paramsY[4] = {1.0/world_coord(4), 0, 0, 0}; - const GLfloat paramsX2[4] = {0, 0, -1.0/world_coord(5), 0}; - const GLfloat paramsY2[4] = {1.0/world_coord(5), 0, 0, 0}; + const GLfloat paramsX[4] = {0, 0, -1.0f/world_coord(4), 0}; + const GLfloat paramsY[4] = {1.0f/world_coord(4), 0, 0, 0}; + const GLfloat paramsX2[4] = {0, 0, -1.0f/world_coord(5), 0}; + const GLfloat paramsY2[4] = {1.0f/world_coord(5), 0, 0, 0}; const GLfloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; const GLfloat fogColour[4] = {pie_GetFogColour().byte.r/255.f, pie_GetFogColour().byte.g/255.f, diff --git a/src/visibility.cpp b/src/visibility.cpp index 6ca691d50..d70756efa 100644 --- a/src/visibility.cpp +++ b/src/visibility.cpp @@ -126,7 +126,7 @@ static inline void visMarkTile(int mapX, int mapY, MAPTILE *psTile, int rayPlaye { if (psTile->watchers[rayPlayer] < UBYTE_MAX && *lastRecordTilePos < MAX_SEEN_TILES) { - TILEPOS tilePos = {mapX, mapY}; + TILEPOS tilePos = {uint8_t(mapX), uint8_t(mapY)}; psTile->watchers[rayPlayer]++; // we see this tile psTile->sensorBits |= (1 << rayPlayer); // mark it as being seen recordTilePos[*lastRecordTilePos] = tilePos; // record having seen it