From 232d990e6d76e52821a5cc69d51048a94ddec867 Mon Sep 17 00:00:00 2001 From: withmorten Date: Wed, 13 Jan 2021 00:18:58 +0100 Subject: move stuff back into class; securom comments --- src/control/Replay.cpp | 2 +- src/control/Replay.h | 6 +---- src/core/Game.cpp | 2 +- src/render/WaterLevel.cpp | 68 +++++++++++++++++++++++------------------------ src/render/WaterLevel.h | 3 +-- src/vehicles/Heli.cpp | 2 +- src/vehicles/Heli.h | 3 ++- 7 files changed, 41 insertions(+), 45 deletions(-) diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 37a54999..db768e17 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1729,7 +1729,7 @@ void CReplay::SaveReplayToHD(void) CFileMgr::SetDir(""); } -void PlayReplayFromHD(void) +void CReplay::PlayReplayFromHD(void) { CFileMgr::SetDirMyDocuments(); int fr = CFileMgr::OpenFile("replay.rep", "rb"); diff --git a/src/control/Replay.h b/src/control/Replay.h index 84a6bef0..5dd8b651 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -64,8 +64,6 @@ struct CStoredDetailedAnimationState uint8 aGroupId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; }; -void PlayReplayFromHD(void); - #ifdef GTA_REPLAY #define REPLAY_STUB #else @@ -410,12 +408,10 @@ private: static void EmptyAllPools(void); static void MarkEverythingAsNew(void); static void SaveReplayToHD(void); + static void PlayReplayFromHD(void); // out of class in III PC and later because of SecuROM static void FindFirstFocusCoordinate(CVector *coord); static void ProcessLookAroundCam(void); static size_t FindSizeOfPacket(uint8); static void GoToNextBlock(void); - - /* Absolute nonsense, but how could this function end up being outside of class? */ - friend void PlayReplayFromHD(void); #endif }; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8405c2ec..4cf99465 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -462,7 +462,7 @@ bool CGame::Initialise(const char* datFile) TestModelIndices(); LoadingScreen("Loading the Game", "Setup water", nil); - WaterLevelInitialise("DATA\\WATER.DAT"); + CWaterLevel::Initialise("DATA\\WATER.DAT"); TheConsole.Init(); CDraw::SetFOV(120.0f); CDraw::ms_fLODDistance = 500.0f; diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index 854653f0..08fd5e6e 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -113,9 +113,9 @@ float fMinWaterAlphaMult = -30.0f; void -WaterLevelInitialise(Const char *pWaterDat) +CWaterLevel::Initialise(Const char *pWaterDat) { - CWaterLevel::ms_nNoOfWaterLevels = 0; + ms_nNoOfWaterLevels = 0; #ifdef MASTER int32 hFile = -1; @@ -131,11 +131,11 @@ WaterLevelInitialise(Const char *pWaterDat) if (hFile > 0) { - CFileMgr::Read(hFile, (char *)&CWaterLevel::ms_nNoOfWaterLevels, sizeof(CWaterLevel::ms_nNoOfWaterLevels)); - CFileMgr::Read(hFile, (char *)CWaterLevel::ms_aWaterZs, sizeof(CWaterLevel::ms_aWaterZs)); - CFileMgr::Read(hFile, (char *)CWaterLevel::ms_aWaterRects, sizeof(CWaterLevel::ms_aWaterRects)); - CFileMgr::Read(hFile, (char *)CWaterLevel::aWaterBlockList, sizeof(CWaterLevel::aWaterBlockList)); - CFileMgr::Read(hFile, (char *)CWaterLevel::aWaterFineBlockList, sizeof(CWaterLevel::aWaterFineBlockList)); + CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels)); + CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs)); + CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects)); + CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList)); + CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList)); CFileMgr::CloseFile(hFile); } #ifndef MASTER @@ -157,7 +157,7 @@ WaterLevelInitialise(Const char *pWaterDat) { float z, l, b, r, t; sscanf(line, "%f %f %f %f %f", &z, &l, &b, &r, &t); - CWaterLevel::AddWaterLevel(l, b, r, t, z); + AddWaterLevel(l, b, r, t, z); } } @@ -167,17 +167,17 @@ WaterLevelInitialise(Const char *pWaterDat) { for (int32 y = 0; y < MAX_SMALL_SECTORS; y++) { - CWaterLevel::aWaterFineBlockList[x][y] = NO_WATER; + aWaterFineBlockList[x][y] = NO_WATER; } } // rasterize water rects read from file - for (int32 i = 0; i < CWaterLevel::ms_nNoOfWaterLevels; i++) + for (int32 i = 0; i < ms_nNoOfWaterLevels; i++) { - int32 l = WATER_HUGE_X(CWaterLevel::ms_aWaterRects[i].left + WATER_X_OFFSET); - int32 r = WATER_HUGE_X(CWaterLevel::ms_aWaterRects[i].right + WATER_X_OFFSET) + 1.0f; - int32 t = WATER_HUGE_Y(CWaterLevel::ms_aWaterRects[i].top); - int32 b = WATER_HUGE_Y(CWaterLevel::ms_aWaterRects[i].bottom) + 1.0f; + int32 l = WATER_HUGE_X(ms_aWaterRects[i].left + WATER_X_OFFSET); + int32 r = WATER_HUGE_X(ms_aWaterRects[i].right + WATER_X_OFFSET) + 1.0f; + int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top); + int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f; l = clamp(l, 0, MAX_SMALL_SECTORS - 1); r = clamp(r, 0, MAX_SMALL_SECTORS - 1); @@ -188,7 +188,7 @@ WaterLevelInitialise(Const char *pWaterDat) { for (int32 y = t; y <= b; y++) { - CWaterLevel::aWaterFineBlockList[x][y] = i; + aWaterFineBlockList[x][y] = i; } } } @@ -209,10 +209,10 @@ WaterLevelInitialise(Const char *pWaterDat) { for (int32 j = 0; j <= 8; j++) { - CVector worldPos = CVector(worldX + i * (SMALL_SECTOR_SIZE / 8), worldY + j * (SMALL_SECTOR_SIZE / 8), CWaterLevel::ms_aWaterZs[CWaterLevel::aWaterFineBlockList[x][y]]); + CVector worldPos = CVector(worldX + i * (SMALL_SECTOR_SIZE / 8), worldY + j * (SMALL_SECTOR_SIZE / 8), ms_aWaterZs[aWaterFineBlockList[x][y]]); if ((worldPos.x > WORLD_MIN_X && worldPos.x < WORLD_MAX_X) && (worldPos.y > WORLD_MIN_Y && worldPos.y < WORLD_MAX_Y) && - (!CWaterLevel::WaterLevelAccordingToRectangles(worldPos.x, worldPos.y) || CWaterLevel::TestVisibilityForFineWaterBlocks(worldPos))) + (!WaterLevelAccordingToRectangles(worldPos.x, worldPos.y) || TestVisibilityForFineWaterBlocks(worldPos))) continue; // at least one point in the tile wasn't blocked, so don't remove water @@ -222,37 +222,37 @@ WaterLevelInitialise(Const char *pWaterDat) } if (i < 1000) - CWaterLevel::aWaterFineBlockList[x][y] = NO_WATER; + aWaterFineBlockList[x][y] = NO_WATER; } } } - CWaterLevel::RemoveIsolatedWater(); + RemoveIsolatedWater(); // calculate coarse tiles from fine tiles for (int32 x = 0; x < MAX_LARGE_SECTORS; x++) { for (int32 y = 0; y < MAX_LARGE_SECTORS; y++) { - if (CWaterLevel::aWaterFineBlockList[x * 2][y * 2] >= 0) + if (aWaterFineBlockList[x * 2][y * 2] >= 0) { - CWaterLevel::aWaterBlockList[x][y] = CWaterLevel::aWaterFineBlockList[x * 2][y * 2]; + aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2]; } - else if (CWaterLevel::aWaterFineBlockList[x * 2 + 1][y * 2] >= 0) + else if (aWaterFineBlockList[x * 2 + 1][y * 2] >= 0) { - CWaterLevel::aWaterBlockList[x][y] = CWaterLevel::aWaterFineBlockList[x * 2 + 1][y * 2]; + aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2]; } - else if (CWaterLevel::aWaterFineBlockList[x * 2][y * 2 + 1] >= 0) + else if (aWaterFineBlockList[x * 2][y * 2 + 1] >= 0) { - CWaterLevel::aWaterBlockList[x][y] = CWaterLevel::aWaterFineBlockList[x * 2][y * 2 + 1]; + aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2 + 1]; } - else if (CWaterLevel::aWaterFineBlockList[x * 2 + 1][y * 2 + 1] >= 0) + else if (aWaterFineBlockList[x * 2 + 1][y * 2 + 1] >= 0) { - CWaterLevel::aWaterBlockList[x][y] = CWaterLevel::aWaterFineBlockList[x * 2 + 1][y * 2 + 1]; + aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2 + 1]; } else { - CWaterLevel::aWaterBlockList[x][y] = NO_WATER; + aWaterBlockList[x][y] = NO_WATER; } } } @@ -261,11 +261,11 @@ WaterLevelInitialise(Const char *pWaterDat) if (hFile > 0) { - CFileMgr::Write(hFile, (char *)&CWaterLevel::ms_nNoOfWaterLevels, sizeof(CWaterLevel::ms_nNoOfWaterLevels)); - CFileMgr::Write(hFile, (char *)CWaterLevel::ms_aWaterZs, sizeof(CWaterLevel::ms_aWaterZs)); - CFileMgr::Write(hFile, (char *)CWaterLevel::ms_aWaterRects, sizeof(CWaterLevel::ms_aWaterRects)); - CFileMgr::Write(hFile, (char *)CWaterLevel::aWaterBlockList, sizeof(CWaterLevel::aWaterBlockList)); - CFileMgr::Write(hFile, (char *)CWaterLevel::aWaterFineBlockList, sizeof(CWaterLevel::aWaterFineBlockList)); + CFileMgr::Write(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels)); + CFileMgr::Write(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs)); + CFileMgr::Write(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects)); + CFileMgr::Write(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList)); + CFileMgr::Write(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList)); CFileMgr::CloseFile(hFile); } @@ -300,7 +300,7 @@ WaterLevelInitialise(Const char *pWaterDat) CTxdStore::PopCurrentTxd(); - CWaterLevel::CreateWavyAtomic(); + CreateWavyAtomic(); printf("Done Initing waterlevels\n"); } diff --git a/src/render/WaterLevel.h b/src/render/WaterLevel.h index 5a497ddf..6d6614d8 100644 --- a/src/render/WaterLevel.h +++ b/src/render/WaterLevel.h @@ -116,6 +116,7 @@ public: static RpAtomic *ms_pWavyAtomic; static RpAtomic *ms_pMaskAtomic; + static void Initialise(Const char *pWaterDat); // out of class in III PC and later because of SecuROM static void Shutdown(); static void CreateWavyAtomic(); @@ -181,5 +182,3 @@ public: static void HandleBeachToysStuff(void); static CEntity *CreateBeachToy(CVector const &vec, eBeachToy beachtoy); }; - -extern void WaterLevelInitialise(Const char *datFile); \ No newline at end of file diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 644fdde8..7854f7fd 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -762,7 +762,7 @@ CHeli::InitHelis(void) } CHeli* -GenerateHeli(bool catalina) +CHeli::GenerateHeli(bool catalina) { CHeli *heli; CVector heliPos; diff --git a/src/vehicles/Heli.h b/src/vehicles/Heli.h index 1f372e42..c5ae08e2 100644 --- a/src/vehicles/Heli.h +++ b/src/vehicles/Heli.h @@ -83,13 +83,14 @@ public: bool SendDownSwat(void); static void InitHelis(void); + static CHeli *GenerateHeli(bool catalina); // out of class in III PC and later because of SecuROM static void UpdateHelis(void); static void SpecialHeliPreRender(void); static bool TestRocketCollision(CVector *coors); static bool TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, int32 damage); static bool TestSniperCollision(CVector *line0, CVector *line1); - static void StartCatalinaFlyBy(void); + static void StartCatalinaFlyBy(void); // out of class in III PC and later because of SecuROM static void RemoveCatalinaHeli(void); static CHeli *FindPointerToCatalinasHeli(void); static void CatalinaTakeOff(void); -- cgit v1.2.3