Skip to content

Commit b66a597

Browse files
committed
Added ability to change the corona size of emergency lights
1 parent dcd9f03 commit b66a597

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

ModelVariations/LoadedModules.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ void LoadedModules::Refresh()
101101
loadedMods[MOD_OLA] = true;
102102
else if (strcasestr(szModName, "fastman92limitAdjuster"))
103103
loadedMods[MOD_FLA] = true;
104-
else if (strcasestr(szModName, "WantedLevelEditor"))
105-
loadedMods[MOD_WLE] = true;
106104

107105
#ifdef _DEBUG
108106
assert(_stricmp("ModelVariations.asi", getFilenameFromPath(szModName).c_str()) != 0);

ModelVariations/LoadedModules.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
enum loadedModNames
1010
{
1111
MOD_FLA,
12-
MOD_OLA,
13-
MOD_WLE
12+
MOD_OLA
1413
};
1514

1615

ModelVariations/Vehicles.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct tVehVars {
9494
std::unordered_map<unsigned short, std::pair<CVector, float>> lightPositions;
9595
std::unordered_map<unsigned short, RwRGBA> lightColors;
9696
std::unordered_map<unsigned short, RwRGBA> lightColors2;
97+
std::unordered_map<unsigned short, float> lightSizes;
9798
std::unordered_map<unsigned short, std::vector<unsigned short>> *currentTuning = nullptr;
9899
std::unordered_map<unsigned short, std::string> vehModels;
99100
std::unordered_map<unsigned short, BYTE> tuningChances;
@@ -593,6 +594,7 @@ void VehicleVariations::LoadData()
593594

594595
if (vehOptions->enableLights)
595596
{
597+
const float lightSize = dataFile.ReadFloat(section, "LightSize", -1.0);
596598
const float lightWidth = dataFile.ReadFloat(section, "LightWidth", -999.0);
597599
const float lightX = dataFile.ReadFloat(section, "LightX", 0.0);
598600
const float lightY = dataFile.ReadFloat(section, "LightY", 0.0);
@@ -603,6 +605,9 @@ void VehicleVariations::LoadData()
603605
int b = dataFile.ReadInteger(section, "LightB", -1);
604606
int a = dataFile.ReadInteger(section, "LightA", -1);
605607

608+
if (lightSize > 0.0)
609+
vehVars->lightSizes.insert({ modelid, lightSize });
610+
606611
if ((uint8_t)r == r && (uint8_t)g == g && (uint8_t)b == b && (uint8_t)a == a)
607612
{
608613
RwRGBA colors = { (uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a };
@@ -1692,41 +1697,51 @@ bool __fastcall UsesSirenHooked(CVehicle* veh)
16921697

16931698
//enableLights
16941699
template <std::uintptr_t address, bool second = false>
1695-
void __cdecl RegisterCoronaHooked(void* _this, CEntity* a2, unsigned char a3, unsigned char a4, unsigned char a5, unsigned char a6, CVector* a7, const CVector* a8,
1700+
void __cdecl RegisterCoronaHooked(void* _this, CEntity* a2, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha, CVector* coors, float size,
16961701
float a9, void* texture, unsigned char a11, unsigned char a12, unsigned char a13, int a14, float a15, float a16, float a17, float a18,
16971702
float a19, float a20, bool a21)
16981703
{
1699-
if (a7 && a2)
1704+
if (!a2 || !coors)
1705+
callOriginal<address>(_this, a2, red, green, blue, alpha, coors, size, a9, texture, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21);
1706+
1707+
//size
1708+
{
1709+
const auto it = vehVars->lightSizes.find(lightsModel);
1710+
if (it != vehVars->lightSizes.end())
1711+
size = it->second;
1712+
}
1713+
1714+
//position
17001715
{
17011716
const auto it = vehVars->lightPositions.find(lightsModel);
17021717
if (it != vehVars->lightPositions.end())
17031718
{
17041719
if (it->second.second > -900.0)
1705-
a7->x *= it->second.second;
1720+
coors->x *= it->second.second;
17061721
if (it->second.first.x != 0.0)
1707-
a7->x += it->second.first.x;
1722+
coors->x += it->second.first.x;
17081723
if (it->second.first.y != 0.0)
1709-
a7->y += it->second.first.y;
1724+
coors->y += it->second.first.y;
17101725
if (it->second.first.z != 0.0)
1711-
a7->z += it->second.first.z;
1726+
coors->z += it->second.first.z;
17121727
}
17131728
}
17141729

1715-
if (a2)
1730+
//colors
17161731
{
17171732
auto& lightsMap = (second ? vehVars->lightColors2 : vehVars->lightColors);
17181733

17191734
const auto it = lightsMap.find(lightsModel);
17201735
if (it != lightsMap.end())
17211736
{
1722-
a3 = it->second.red;
1723-
a4 = it->second.green;
1724-
a5 = it->second.blue;
1725-
a6 = it->second.alpha;
1737+
red = it->second.red;
1738+
green = it->second.green;
1739+
blue = it->second.blue;
1740+
alpha = it->second.alpha;
17261741
}
17271742
}
17281743

1729-
callOriginal<address>(_this, a2, a3, a4, a5, a6, a7, a8, a9, texture, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21);
1744+
callOriginal<address>(_this, a2, red, green, blue, alpha, coors, size, a9, texture, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21);
17301745
}
17311746

17321747
template <std::uintptr_t address>
@@ -1747,6 +1762,10 @@ void __cdecl AddLightHooked(char type, float x, float y, float z, float dir_x, f
17471762
if (it->second.first.z != 0.0f)
17481763
z += it->second.first.z;
17491764
}
1765+
1766+
const auto it2 = vehVars->lightSizes.find(lightsModel);
1767+
if (it2 != vehVars->lightSizes.end())
1768+
radius = it2->second;
17501769
}
17511770

17521771
callOriginal<address>(type, x, y, z, dir_x, dir_y, dir_z, radius, r, g, b, fogType, generateExtraShadows, attachedTo);

0 commit comments

Comments
 (0)