Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add engineSet/GetModelVisibleTime #752

Merged
merged 18 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Missed reset function
  • Loading branch information
CrosRoad95 committed Jan 1, 2019
commit d29b0aa2ed48d50fc26d0caa9c16e7a6e810dbcf
5 changes: 5 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,11 @@ void CGameSA::ResetModelLodDistances(void)
CModelInfoSA::StaticResetLodDistances();
}

void CGameSA::ResetModelTimes(void)
{
CModelInfoSA::StaticResetModelTimes();
}

void CGameSA::ResetAlphaTransparencies(void)
{
CModelInfoSA::StaticResetAlphaTransparencies();
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ class CGameSA : public CGame
void FlushPendingRestreamIPL(void);
void ResetModelLodDistances(void);
void ResetAlphaTransparencies(void);
void ResetModelTimes(void);
void DisableVSync(void);

void OnPedContextChange(CPed* pPedContext);
Expand Down
25 changes: 21 additions & 4 deletions Client/game_sa/CModelInfoSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ std::map<unsigned short, int>
std::map<DWORD, float> CModelInfoSA::ms_ModelDefaultLodDistanceMap;
std::map<DWORD, BYTE> CModelInfoSA::ms_ModelDefaultAlphaTransparencyMap;
std::unordered_map<CVehicleModelInfoSAInterface*, std::map<eVehicleDummies, CVector>> CModelInfoSA::ms_ModelDefaultDummiesPosition;
std::map<TimeInfo*, TimeInfo*> CModelInfoSA::ms_ModelDefaultModelTimeInfo;

CModelInfoSA::CModelInfoSA(void)
{
Expand Down Expand Up @@ -569,11 +570,15 @@ bool CModelInfoSA::SetTime(char cHourOn, char cHourOff)
m_pInterface = ppModelInfo[m_dwModelID];
if (m_pInterface)
{
TimeInfo* time = ((TimeInfo*(*)(void))m_pInterface->VFTBL->GetTimeInfo)();
if (time)
TimeInfo* pTime = ((TimeInfo*(*)(void))m_pInterface->VFTBL->GetTimeInfo)();
if (pTime)
{
time->m_nTimeOn = cHourOn;
time->m_nTimeOff = cHourOff;
if (!MapContains(ms_ModelDefaultModelTimeInfo, pTime))
{
MapSet(ms_ModelDefaultModelTimeInfo, pTime, new TimeInfo(pTime->m_nTimeOn, pTime->m_nTimeOff, pTime->m_wOtherTimeModel));
}
pTime->m_nTimeOn = cHourOn;
pTime->m_nTimeOff = cHourOff;
return true;
}
}
Expand All @@ -596,6 +601,18 @@ bool CModelInfoSA::GetTime(char& cHourOn, char& cHourOff)
return false;
}

void CModelInfoSA::StaticResetModelTimes()
{
// Restore default values
for (std::map<TimeInfo*, TimeInfo*>::const_iterator iter = ms_ModelDefaultModelTimeInfo.begin(); iter != ms_ModelDefaultModelTimeInfo.end(); ++iter)
{
iter->first->m_nTimeOn = iter->second->m_nTimeOn;
iter->first->m_nTimeOff = iter->second->m_nTimeOff;
}

ms_ModelDefaultModelTimeInfo.clear();
}

void CModelInfoSA::SetLODDistance(float fDistance)
{
#if 0
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/CModelInfoSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class CModelInfoSA : public CModelInfo
static std::map<DWORD, float> ms_ModelDefaultLodDistanceMap;
static std::map<DWORD, BYTE> ms_ModelDefaultAlphaTransparencyMap;
static std::unordered_map<CVehicleModelInfoSAInterface*, std::map<eVehicleDummies, CVector>> ms_ModelDefaultDummiesPosition;
static std::map<TimeInfo*, TimeInfo*> ms_ModelDefaultModelTimeInfo;
bool m_bAddedRefForCollision;
SVehicleSupportedUpgrades m_ModelSupportedUpgrades;

Expand Down Expand Up @@ -328,6 +329,7 @@ class CModelInfoSA : public CModelInfo
static void StaticSetHooks(void);
bool GetTime(char& cHourOn, char& cHourOff);
bool SetTime(char cHourOn, char cHourOff);
static void StaticResetModelTimes(void);

void SetAlphaTransparencyEnabled(BOOL bEnabled);
bool IsAlphaTransparencyEnabled();
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3541,6 +3541,7 @@ void CClientGame::Event_OnIngame(void)

g_pGame->ResetModelLodDistances();
g_pGame->ResetAlphaTransparencies();
g_pGame->ResetModelTimes();

// Make sure we can access all areas
g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0);
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/game/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class __declspec(novtable) CGame
virtual void FlushPendingRestreamIPL(void) = 0;
virtual void ResetModelLodDistances(void) = 0;
virtual void ResetAlphaTransparencies(void) = 0;
virtual void ResetModelTimes(void) = 0;
virtual void DisableVSync(void) = 0;

virtual void OnPedContextChange(CPed* pPedContext) = 0;
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/game/RenderWare.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ struct RwError
};

struct TimeInfo {
TimeInfo(char timeOn, char timeOff, short OtherTimeModel) : m_nTimeOn(timeOn), m_nTimeOff(timeOff), m_wOtherTimeModel(OtherTimeModel) {};
char m_nTimeOn;
char m_nTimeOff;
short m_wOtherTimeModel;
Expand Down