summaryrefslogtreecommitdiffstats
path: root/src/render/WaterLevel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/WaterLevel.cpp')
-rw-r--r--src/render/WaterLevel.cpp96
1 files changed, 52 insertions, 44 deletions
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index 49fc3a22..a0c7ae31 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -62,7 +62,11 @@ CWaterLevel::Initialise(Const char *pWaterDat)
#ifdef MASTER
int32 hFile = -1;
- while ((hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb")) < 0);
+ do
+ {
+ hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
+ }
+ while ( hFile < 0 );
#else
int32 hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
#endif
@@ -89,7 +93,11 @@ CWaterLevel::Initialise(Const char *pWaterDat)
while ((line = CFileLoader::LoadLine(hFile)))
{
+#ifdef FIX_BUGS
+ if (*line && *line != ';' && !strstr(line, "* ;end of file"))
+#else
if (*line && *line != ';')
+#endif
{
float z, l, b, r, t;
sscanf(line, "%f %f %f %f %f", &z, &l, &b, &r, &t);
@@ -217,8 +225,8 @@ CWaterLevel::Initialise(Const char *pWaterDat)
int32 slot = CTxdStore::FindTxdSlot("particle");
CTxdStore::SetCurrentTxd(slot);
- if ( gpWaterTex == NULL )
- gpWaterTex = RwTextureRead("water_old", NULL);
+ if ( gpWaterTex == nil )
+ gpWaterTex = RwTextureRead("water_old", nil);
gpWaterRaster = RwTextureGetRaster(gpWaterTex);
CTxdStore::PopCurrentTxd();
@@ -235,10 +243,10 @@ CWaterLevel::Shutdown()
FreeBoatWakeArray();
DestroyWavyAtomic();
- if ( gpWaterTex != NULL )
+ if ( gpWaterTex != nil )
{
RwTextureDestroy(gpWaterTex);
- gpWaterTex = NULL;
+ gpWaterTex = nil;
}
}
@@ -260,15 +268,15 @@ CWaterLevel::CreateWavyAtomic()
|rpGEOMETRYPRELIT
|rpGEOMETRYMODULATEMATERIALCOLOR);
- ASSERT(wavyGeometry != NULL);
+ ASSERT(wavyGeometry != nil);
}
{
wavyMaterial = RpMaterialCreate();
- ASSERT(wavyMaterial != NULL);
- ASSERT(gpWaterTex != NULL);
+ ASSERT(wavyMaterial != nil);
+ ASSERT(gpWaterTex != nil);
RpMaterialSetTexture(wavyMaterial, gpWaterTex);
}
@@ -276,7 +284,7 @@ CWaterLevel::CreateWavyAtomic()
{
wavyTriangles = RpGeometryGetTriangles(wavyGeometry);
- ASSERT(wavyTriangles != NULL);
+ ASSERT(wavyTriangles != nil);
/*
[B] [C]
***********
@@ -307,9 +315,9 @@ CWaterLevel::CreateWavyAtomic()
{
wavyMorphTarget = RpGeometryGetMorphTarget(wavyGeometry, 0);
- ASSERT(wavyMorphTarget != NULL);
+ ASSERT(wavyMorphTarget != nil);
wavyVert = RpMorphTargetGetVertices(wavyMorphTarget);
- ASSERT(wavyVert != NULL);
+ ASSERT(wavyVert != nil);
for ( int32 i = 0; i < 9; i++ )
{
@@ -329,10 +337,10 @@ CWaterLevel::CreateWavyAtomic()
{
wavyFrame = RwFrameCreate();
- ASSERT( wavyFrame != NULL );
+ ASSERT( wavyFrame != nil );
ms_pWavyAtomic = RpAtomicCreate();
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RpAtomicSetGeometry(ms_pWavyAtomic, wavyGeometry, 0);
RpAtomicSetFrame(ms_pWavyAtomic, wavyFrame);
@@ -531,7 +539,7 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
if ( nBlock == NO_WATER )
return false;
- ASSERT( pfOutLevel != NULL );
+ ASSERT( pfOutLevel != nil );
*pfOutLevel = ms_aWaterZs[nBlock];
float fAngle = (CTimer::GetTimeInMilliseconds() & 4095) * (TWOPI / 4096.0f);
@@ -570,7 +578,7 @@ CWaterLevel::GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLeve
if ( nBlock == NO_WATER )
return false;
- ASSERT( pfOutLevel != NULL );
+ ASSERT( pfOutLevel != nil );
*pfOutLevel = ms_aWaterZs[nBlock];
return true;
@@ -1243,19 +1251,19 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
CBoat::FillBoatList();
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RpGeometry *geometry = RpAtomicGetGeometry(ms_pWavyAtomic);
- ASSERT( geometry != NULL );
+ ASSERT( geometry != nil );
RwRGBA *wavyPreLights = RpGeometryGetPreLightColors(geometry);
RwTexCoords *wavyTexCoords = RpGeometryGetVertexTexCoords(geometry, rwTEXTURECOORDINATEINDEX0);
RwV3d *wavyVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geometry, 0));
- ASSERT( wavyPreLights != NULL );
- ASSERT( wavyTexCoords != NULL );
- ASSERT( wavyVertices != NULL );
+ ASSERT( wavyPreLights != nil );
+ ASSERT( wavyTexCoords != nil );
+ ASSERT( wavyVertices != nil );
RpGeometryLock(geometry, rpGEOMETRYLOCKVERTICES
| rpGEOMETRYLOCKPRELIGHT
@@ -1278,7 +1286,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RpGeometryUnlock(geometry);
}
- static CBoat *apBoatList[4] = { NULL };
+ static CBoat *apBoatList[4] = { nil };
if ( apGeomArray[0]
&& nGeomUsed < MAX_BOAT_WAKES
@@ -1292,16 +1300,16 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
RpGeometry *geom = apGeomArray[nGeomUsed++];
- ASSERT( wavyGeometry != NULL );
- ASSERT( geom != NULL );
+ ASSERT( wavyGeometry != nil );
+ ASSERT( geom != nil );
RpAtomic *atomic = RpAtomicCreate();
- ASSERT( atomic != NULL );
+ ASSERT( atomic != nil );
RpAtomicSetGeometry(atomic, geom, 0);
RwFrame *frame = RwFrameCreate();
- ASSERT( frame != NULL );
+ ASSERT( frame != nil );
RwMatrixCopy(RwFrameGetMatrix(frame), RwFrameGetMatrix(RpAtomicGetFrame(ms_pWavyAtomic)));
RpAtomicSetFrame(atomic, frame);
@@ -1312,11 +1320,11 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RwV3d *geomVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geom, 0));
RwV3d *wavyVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(wavyGeometry, 0));
- ASSERT( geomTexCoords != NULL );
- ASSERT( wavyTexCoord != NULL );
- ASSERT( geomPreLights != NULL );
- ASSERT( geomVertices != NULL );
- ASSERT( wavyVertices != NULL );
+ ASSERT( geomTexCoords != nil );
+ ASSERT( wavyTexCoord != nil );
+ ASSERT( geomPreLights != nil );
+ ASSERT( geomVertices != nil );
+ ASSERT( wavyVertices != nil );
RpGeometryLock(geom, rpGEOMETRYLOCKVERTICES | rpGEOMETRYLOCKPRELIGHT | rpGEOMETRYLOCKTEXCOORDS);
@@ -1333,7 +1341,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
for ( int32 k = 0; k < 4; k++ )
{
- if ( apBoatList[k] != NULL )
+ if ( apBoatList[k] != nil )
fDistMult += CBoat::IsVertexAffectedByWake(CVector(fVertexX, fVertexY, 0.0f), apBoatList[k]);
}
@@ -1382,7 +1390,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
pos.y = fY;
pos.z = fZ;
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RwFrameTranslate(RpAtomicGetFrame(ms_pWavyAtomic), &pos, rwCOMBINEREPLACE);
@@ -1437,7 +1445,7 @@ CWaterLevel::RenderAndEmptyRenderBuffer()
{
LittleTest();
- if ( RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, NULL, rwIM3D_VERTEXUV) )
+ if ( RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV) )
{
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
RwIm3DEnd();
@@ -1455,29 +1463,29 @@ CWaterLevel::AllocateBoatWakeArray()
PUSH_MEMID(MEMID_STREAM);
- ASSERT(ms_pWavyAtomic != NULL );
+ ASSERT(ms_pWavyAtomic != nil );
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
- ASSERT(wavyGeometry != NULL );
+ ASSERT(wavyGeometry != nil );
RpMorphTarget *wavyMorphTarget = RpGeometryGetMorphTarget(wavyGeometry, 0);
RpMaterial *wavyMaterial = RpGeometryGetMaterial(wavyGeometry, 0);
- ASSERT(wavyMorphTarget != NULL );
- ASSERT(wavyMaterial != NULL );
+ ASSERT(wavyMorphTarget != nil );
+ ASSERT(wavyMaterial != nil );
for ( int32 geom = 0; geom < MAX_BOAT_WAKES; geom++ )
{
- if ( apGeomArray[geom] == NULL )
+ if ( apGeomArray[geom] == nil )
{
apGeomArray[geom] = RpGeometryCreate(9*9, 8*8*2, rpGEOMETRYTRISTRIP
| rpGEOMETRYPRELIT
| rpGEOMETRYMODULATEMATERIALCOLOR
| rpGEOMETRYTEXTURED);
- ASSERT(apGeomArray[geom] != NULL);
+ ASSERT(apGeomArray[geom] != nil);
RpTriangle *geomTriangles = RpGeometryGetTriangles(apGeomArray[geom]);
- ASSERT( geomTriangles != NULL );
+ ASSERT( geomTriangles != nil );
for ( int32 i = 0; i < 8; i++ )
{
@@ -1511,8 +1519,8 @@ CWaterLevel::AllocateBoatWakeArray()
RpMorphTarget *geomMorphTarget = RpGeometryGetMorphTarget(apGeomArray[geom], 0);
RwV3d *geomVertices = RpMorphTargetGetVertices(geomMorphTarget);
- ASSERT( geomMorphTarget != NULL );
- ASSERT( geomVertices != NULL );
+ ASSERT( geomMorphTarget != nil );
+ ASSERT( geomVertices != nil );
for ( int32 i = 0; i < 9; i++ )
{
@@ -1537,10 +1545,10 @@ CWaterLevel::FreeBoatWakeArray()
{
for ( int32 i = 0; i < MAX_BOAT_WAKES; i++ )
{
- if ( apGeomArray[i] != NULL )
+ if ( apGeomArray[i] != nil )
{
RpGeometryDestroy(apGeomArray[i]);
- apGeomArray[i] = NULL;
+ apGeomArray[i] = nil;
}
}