Skip to content

Commit

Permalink
Add getColorFilter (PR #2535)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisdp authored Aug 29, 2023
1 parent 8018e7a commit da113b9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void CLuaWorldDefs::LoadFunctions()
{
constexpr static const std::pair<const char*, lua_CFunction> functions[]{// World get functions
{"getTime", GetTime},
{"getColorFilter", ArgumentParser<GetColorFilter>},
{"getRoofPosition", GetRoofPosition},
{"getGroundPosition", GetGroundPosition},
{"processLineOfSight", ProcessLineOfSight},
Expand Down Expand Up @@ -2024,6 +2025,17 @@ bool CLuaWorldDefs::SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar u
return true;
}

CLuaMultiReturn<uchar, uchar, uchar, uchar, uchar, uchar, uchar, uchar> CLuaWorldDefs::GetColorFilter(bool isOriginal)
{
SColor uColor0 = 0;
SColor uColor1 = 0;
g_pMultiplayer->GetColorFilter(uColor0.ulARGB, uColor1.ulARGB, isOriginal);
return {
uColor0.R, uColor0.G, uColor0.B, uColor0.A,
uColor1.R, uColor1.G, uColor1.B, uColor1.A,
};
}

bool CLuaWorldDefs::SetGrainMultiplier(eGrainMultiplierType type, float fMultiplier)
{
g_pMultiplayer->SetGrainMultiplier(type, fMultiplier);
Expand Down
7 changes: 4 additions & 3 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ class CLuaWorldDefs : public CLuaDefs

LUA_DECLARE(CreateExplosion);

static bool ResetColorFilter();
static bool SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar ucPass0Blue, uchar ucPass0Alpha, uchar ucPass1Red, uchar ucPass1Green,
uchar ucPass1Blue, uchar ucPass1Alpha);
static bool ResetColorFilter();
static bool SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar ucPass0Blue, uchar ucPass0Alpha,
uchar ucPass1Red, uchar ucPass1Green, uchar ucPass1Blue, uchar ucPass1Alpha);
static CLuaMultiReturn<uchar, uchar, uchar, uchar, uchar, uchar, uchar, uchar> GetColorFilter(bool isOriginal = false);

static bool SetGrainMultiplier(eGrainMultiplierType type, float fMultiplier);
static bool SetGrainLevel(uchar ucLevel);
Expand Down
17 changes: 17 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,23 @@ void CMultiplayerSA::SetColorFilter(DWORD dwPass0Color, DWORD dwPass1Color)
}
}

void CMultiplayerSA::GetColorFilter(DWORD& dwPass0Color, DWORD& dwPass1Color, bool isOriginal)
{
// GTASA PC has 2 color filters, one of them is static color filter, and another one is blended by time cycle
bool bUseTimeCycle = *(BYTE*)0x7036EC == 0xC1;
if (bUseTimeCycle || isOriginal){ //If we are using color filter from time cycle or we specified color filter from time cycle
SColorRGBA pass0SColor(*(float*)0xB7C518, *(float*)0xB7C51C, *(float*)0xB7C520, *(float*)0xB7C524);
SColorRGBA pass1SColor(*(float*)0xB7C528, *(float*)0xB7C52C, *(float*)0xB7C530, *(float*)0xB7C534);
dwPass0Color = pass0SColor.ulARGB;
dwPass1Color = pass1SColor.ulARGB;
}
else
{
dwPass0Color = *(DWORD*)0x7036ED;
dwPass1Color = *(DWORD*)0x70373E;
}
}

void DoSetHeatHazePokes(const SHeatHazeSettings& settings, int iHourStart, int iHourEnd, float fFadeSpeed, float fInsideBuildingFadeSpeed,
bool bAllowAutoTypeChange)
{
Expand Down
1 change: 1 addition & 0 deletions Client/multiplayer_sa/CMultiplayerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class CMultiplayerSA : public CMultiplayer
void GetHeatHaze(SHeatHazeSettings& settings);
void ResetColorFilter();
void SetColorFilter(DWORD dwPass0Color, DWORD dwPass1Color);
void GetColorFilter(DWORD& dwPass0Color, DWORD& dwPass1Color, bool isOriginal);
void SetGrainMultiplier(eGrainMultiplierType type, float fMultiplier);
void SetGrainLevel(BYTE ucLevel);
void ResetHeatHaze();
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/multiplayer/CMultiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class CMultiplayer
virtual void GetHeatHaze(SHeatHazeSettings& settings) = 0;
virtual void ResetColorFilter() = 0;
virtual void SetColorFilter(DWORD dwPass0Color, DWORD dwPass1Color) = 0;
virtual void GetColorFilter(DWORD& dwPass0Color, DWORD& dwPass1Color, bool isOriginal) = 0;
virtual void SetGrainMultiplier(eGrainMultiplierType type, float fMultiplier) = 0;
virtual void SetGrainLevel(BYTE ucLevel) = 0;
virtual void ResetHeatHaze() = 0;
Expand Down

0 comments on commit da113b9

Please sign in to comment.