Skip to content

Commit 39f0394

Browse files
authored
Fix #2872: Add ability to restream LOD models (PR #2873)
1 parent 01fcf9f commit 39f0394

File tree

8 files changed

+22
-7
lines changed

8 files changed

+22
-7
lines changed

Client/game_sa/CStreamingSA.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,8 @@ std::uint32_t CStreamingSA::GetMemoryUsed() const
306306
{
307307
return *reinterpret_cast<std::uint32_t*>(0x8E4CB4);
308308
}
309+
310+
void CStreamingSA::RemoveBigBuildings()
311+
{
312+
(reinterpret_cast<void(__cdecl*)()>(0x4093B0))();
313+
}

Client/game_sa/CStreamingSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class CStreamingSA final : public CStreaming
5757
bool HasModelLoaded(DWORD dwModelID);
5858
void RequestSpecialModel(DWORD model, const char* szTexture, DWORD channel);
5959
void ReinitStreaming();
60+
void RemoveBigBuildings() override;
6061

6162
CStreamingInfo* GetStreamingInfo(uint32 id);
6263
void SetStreamingInfo(uint32 modelid, unsigned char usStreamID, uint uiOffset, ushort usSize, uint uiNextInImg = -1);

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5424,7 +5424,7 @@ void CClientGame::ResetMapInfo()
54245424
if (pPlayerInfo)
54255425
pPlayerInfo->SetCamDrunkLevel(static_cast<byte>(0));
54265426

5427-
RestreamWorld();
5427+
RestreamWorld(true);
54285428
}
54295429

54305430
void CClientGame::SendPedWastedPacket(CClientPed* Ped, ElementID damagerID, unsigned char ucWeapon, unsigned char ucBodyPiece, AssocGroupId animGroup,
@@ -6546,7 +6546,7 @@ void CClientGame::RestreamModel(unsigned short usModel)
65466546
m_pManager->GetVehicleManager()->RestreamVehicleUpgrades(usModel);
65476547
}
65486548

6549-
void CClientGame::RestreamWorld()
6549+
void CClientGame::RestreamWorld(bool removeBigBuildings)
65506550
{
65516551
unsigned int numberOfFileIDs = g_pGame->GetCountOfAllFileIDs();
65526552

@@ -6559,6 +6559,9 @@ void CClientGame::RestreamWorld()
65596559
m_pManager->GetPedManager()->RestreamAllPeds();
65606560
m_pManager->GetPickupManager()->RestreamAllPickups();
65616561

6562+
if (removeBigBuildings)
6563+
g_pGame->GetStreaming()->RemoveBigBuildings();
6564+
65626565
g_pGame->GetStreaming()->ReinitStreaming();
65636566
}
65646567

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class CClientGame
439439

440440
bool TriggerBrowserRequestResultEvent(const std::unordered_set<SString>& newPages);
441441
void RestreamModel(unsigned short usModel);
442-
void RestreamWorld();
442+
void RestreamWorld(bool removeBigBuildings);
443443

444444
void OnWindowFocusChange(bool state);
445445

Client/mods/deathmatch/logic/CClientIMG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool CClientIMG::StreamDisable()
185185

186186
m_pImgManager->UpdateStreamerBufferSize();
187187

188-
g_pClientGame->RestreamWorld();
188+
g_pClientGame->RestreamWorld(true);
189189
return true;
190190
}
191191

Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,8 +2311,13 @@ bool CLuaEngineDefs::EngineResetModelFlags(uint uiModelID)
23112311
return false;
23122312
}
23132313

2314-
bool CLuaEngineDefs::EngineRestreamWorld()
2314+
bool CLuaEngineDefs::EngineRestreamWorld(lua_State* const luaVM)
23152315
{
2316-
g_pClientGame->RestreamWorld();
2316+
bool restreamLODs{};
2317+
2318+
CScriptArgReader argStream(luaVM);
2319+
argStream.ReadBool(restreamLODs, false);
2320+
2321+
g_pClientGame->RestreamWorld(restreamLODs);
23172322
return true;
23182323
}

Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CLuaEngineDefs : public CLuaDefs
7474
static bool EngineRestoreTXDImage(uint uiModelID);
7575
static std::vector<std::string_view> EngineImageGetFileList(CClientIMG* pImg);
7676
static std::string EngineImageGetFile(CClientIMG* pImg, std::variant<size_t, std::string_view> file);
77-
static bool EngineRestreamWorld();
77+
static bool EngineRestreamWorld(lua_State* const luaVM);
7878
static bool EngineSetModelVisibleTime(std::string strModelId, char cHourOn, char cHourOff);
7979
static std::variant<bool, CLuaMultiReturn<char, char>> EngineGetModelVisibleTime(std::string strModelId);
8080

Client/sdk/game/CStreaming.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ class CStreaming
4343
virtual uint32 GetStreamingBufferSize() = 0;
4444
virtual void MakeSpaceFor(std::uint32_t memoryToCleanInBytes) = 0;
4545
virtual std::uint32_t GetMemoryUsed() const = 0;
46+
virtual void RemoveBigBuildings() = 0;
4647
};

0 commit comments

Comments
 (0)