Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ This page lists all the individual contributions to the project by their author.
- Show designator & inhibitor range
- Dump variables to file on scenario end / hotkey
- "House owns TechnoType" and "House doesn't own TechnoType" trigger events
- Fixed units, buildings and tiberiums not being affected by map lighting color tint
- Help with docs
- Voxel light source position customization
- **ChrisLv_CN** (work relicensed under [following permission](https://github.com/Phobos-developers/Phobos/blob/develop/images/ChrisLv-relicense.png)):
Expand Down
1 change: 1 addition & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<ClCompile Include="src\Utilities\AresAddressTable.cpp" />
<ClCompile Include="src\Misc\SyncLogging.cpp" />
<ClCompile Include="YRpp\StaticInits.cpp" />
<ClCompile Include="src\Misc\Hooks.MapTint.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
Expand Down
3 changes: 3 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast.
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
- Fixed Nuke & Dominator Level lighting not applying to AircraftTypes.
- Fixed units, buildings and tiberiums not being affected by map lighting color tint.
- This can be disabled with `FixUnitLightingTint=false` and `FixTiberiumLightingTint=false` under `[General]` in `rulesmd.ini`
- `FixTiberiumLightingTint=true` requires `FixUnitLightingTint=true` to work.

## Fixes / interactions with other extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ Vanilla fixes:
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast (by NetsuNegi)
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
- Fixed Nuke & Dominator Level lighting not applying to AircraftTypes (by Starkku)
- Fixed units, buildings and tiberiums not being affected by map lighting color tint (by Morton)

Phobos fixes:
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
Expand Down
10 changes: 10 additions & 0 deletions src/Ext/TAction/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ DEFINE_HOOK(0x6E2EA7, TActionClass_Retint_LightSourceFix, 0x3) // Red
return 0;
}

// Same as above, but needed to work with pr#1202.
// See Misc/Hooks.MapTint.cpp hook @ 0x683E7F.
DEFINE_HOOK(0x683E94, Start_Scenario_RetintLightSourceFix, 0x5)
{
// Flag the light sources to update, actually do it later and only once to prevent redundancy.
RetintTemp::UpdateLightSources = true;

return 0;
}

// Update light sources if they have been flagged to be updated.
DEFINE_HOOK(0x6D4455, Tactical_Render_UpdateLightSources, 0x8)
{
Expand Down
82 changes: 82 additions & 0 deletions src/Misc/Hooks.MapTint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include <Utilities/Macro.h>
#include <Helpers/Macro.h>
#include <ScenarioClass.h>
#include <Utilities/TemplateDef.h>

namespace MapTintFix
{
LightConvertClass* TiberiumLightDrawer;
}

DEFINE_HOOK(0x53C441, ScenarioClass_UpdateLighting, 5)
{
if (!Phobos::Config::FixUnitLightingTint)
return 0;

auto tint = ScenarioClass::Instance->NormalLighting.Tint;
ScenarioClass::RecalcLighting(tint.Red * 10, tint.Green * 10, tint.Blue * 10, true);
return 0;
}

DEFINE_HOOK(0x683E7F, Start_Scenario_SetInitialTint, 7)
{
if (!Phobos::Config::FixUnitLightingTint)
return 0;

auto tint = ScenarioClass::Instance->NormalLighting.Tint;
ScenarioClass::RecalcLighting(tint.Red * 10, tint.Green * 10, tint.Blue * 10, true);
return 0;
}

DEFINE_HOOK(0x52BE3B, InitGame_CreateTiberiumDrawer, 0x5)
{
MapTintFix::TiberiumLightDrawer = GameCreate<LightConvertClass>(
&FileSystem::TEMPERAT_PAL, &FileSystem::TEMPERAT_PAL,
DSurface::Primary, 1000, 1000, 1000, false, nullptr, 53);

return 0;
}

DEFINE_HOOK(0x53AD00, ScenarioClass_RecalcLighting_TintTiberiumDrawer, 5)
{
if (!Phobos::Config::FixTiberiumLightingTint)
return 0;

GET(int, red, ECX);
GET(int, green, EDX);
GET_STACK(int, blue, STACK_OFFSET(0x0, 0x4));
GET_STACK(bool, tint, STACK_OFFSET(0x0,0x8));

MapTintFix::TiberiumLightDrawer->UpdateColors(red, green, blue, tint);
return 0;
}

DEFINE_HOOK(0x47F94B, CellClass_DrawOverlay_ReplaceTiberiumDrawer_1, 6)
{
R->EDX(MapTintFix::TiberiumLightDrawer);
return 0x47F951;
}

DEFINE_HOOK(0x47FA5C, CellClass_DrawOverlay_ReplaceTiberiumDrawer_2, 6)
{
R->EDX(MapTintFix::TiberiumLightDrawer);
return 0x47FA62;
}

DEFINE_HOOK(0x47FA1F, CellClass_DrawOverlay_ReplaceWeirdDrawer, 6)
{
R->EDX(MapTintFix::TiberiumLightDrawer);
return 0x47FA25;
}

DEFINE_HOOK(0x5FE5F9, OverlayTypeClass_DrawIt_ReplaceTiberiumDrawer, 6)
{
R->EDX(MapTintFix::TiberiumLightDrawer);
return 0x5FE5FF;
}

DEFINE_HOOK(0x6BE468, Prog_End_DeleteTiberiumDrawer, 6)
{
GameDelete(MapTintFix::TiberiumLightDrawer);
return 0;
}
5 changes: 4 additions & 1 deletion src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ bool Phobos::Config::ShowBriefing = true;
bool Phobos::Config::ShowHarvesterCounter = false;
bool Phobos::Config::ShowPowerDelta = true;
bool Phobos::Config::ShowWeedsCounter = false;
bool Phobos::Config::FixUnitLightingTint = true;
bool Phobos::Config::FixTiberiumLightingTint = true;

bool Phobos::Misc::CustomGS = false;
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
Expand Down Expand Up @@ -176,7 +178,8 @@ DEFINE_HOOK(0x52D21F, InitRules_ThingsThatShouldntBeSerailized, 0x6)
RulesClass::Instance->Read_JumpjetControls(pINI_RULESMD);

Phobos::Config::ArtImageSwap = pINI_RULESMD->ReadBool(GameStrings::General, "ArtImageSwap", false);

Phobos::Config::FixUnitLightingTint = pINI_RULESMD->ReadBool(GameStrings::General, "FixUnitLightingTint", true);
Phobos::Config::FixTiberiumLightingTint = pINI_RULESMD->ReadBool(GameStrings::General, "FixTiberiumLightingTint", true);

Phobos::Misc::CustomGS = pINI_RULESMD->ReadBool(GameStrings::General, "CustomGS", false);

Expand Down
2 changes: 2 additions & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class Phobos
static bool ShowHarvesterCounter;
static bool ShowWeedsCounter;
static bool ShowPlanningPath;
static bool FixUnitLightingTint;
static bool FixTiberiumLightingTint;
};

class Misc
Expand Down