Skip to content

Commit

Permalink
1.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
GTAMadman committed Jul 15, 2020
1 parent 1dec961 commit 1be1a9a
Show file tree
Hide file tree
Showing 26 changed files with 732 additions and 511 deletions.
10 changes: 5 additions & 5 deletions src/Autosave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void __fastcall Autosave::RequestAutosave(CRunningScript* script, void* edx, int

if (opcode == 78 && script->m_bIsMission && ShouldSave)
{
int slot = Config::Autosave::slot;
int slot = Config::autosave.slot;
bool inVehicle = FindPlayerPed()->m_bInVehicle;

script->m_bIsActive = false;
Expand All @@ -25,9 +25,9 @@ void __fastcall Autosave::RequestAutosave(CRunningScript* script, void* edx, int
FindPlayerPed()->m_bInVehicle = inVehicle;
}
}
void __fastcall Autosave::SetTotalNumberMissions(CRunningScript* thisScript, void* edx, int* arg0, short count)
void __fastcall Autosave::IncreaseMissionsPassed(CRunningScript* script, void* edx, int* arg0, short count)
{
thisScript->CollectParameters(arg0, count);
script->CollectParameters(arg0, count);
ShouldSave = true;
}
char* Autosave::MakeValidSaveName(int slot)
Expand All @@ -44,9 +44,9 @@ char Autosave::ProcessCommands0to99(CRunningScript* script, int opcode)
}
void Autosave::Initialise()
{
if (Config::Autosave::Enabled)
if (Config::autosave.Enabled)
{
plugin::patch::RedirectCall(0x439552, RequestAutosave);
plugin::patch::RedirectCall(0x447D88, SetTotalNumberMissions);
plugin::patch::RedirectCall(0x447D88, IncreaseMissionsPassed);
}
}
2 changes: 1 addition & 1 deletion src/Autosave.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Autosave
static void Initialise();
private:
static void __fastcall RequestAutosave(CRunningScript* script, void* edx, int opcode);
static void __fastcall SetTotalNumberMissions(CRunningScript* thisScript, void* edx, int* arg0, short count);
static void __fastcall IncreaseMissionsPassed(CRunningScript* script, void* edx, int* arg0, short count);
static bool ShouldSave;
static char* MakeValidSaveName(int slot);
static void GenericSave(int fileHandle);
Expand Down
82 changes: 73 additions & 9 deletions src/Colours.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Colours.h"

std::vector<Colours::Pattern> Colours::Patterns;
std::vector<Colours::Pattern> Colours::PickupPatterns;
int Colours::GetColour(int pattern, int rgb)
{
for (int i = 0; i < Patterns.size(); i++)
Expand All @@ -17,9 +18,25 @@ int Colours::GetColour(int pattern, int rgb)
}
return 0;
}
int Colours::GetPickupsColour(int pattern, int rgb)
{
for (int i = 0; i < PickupPatterns.size(); i++)
{
if (PickupPatterns[i].ID == pattern)
{
if (rgb == 0)
return PickupPatterns[i].colours[0];
if (rgb == 1)
return PickupPatterns[i].colours[1];
if (rgb == 2)
return PickupPatterns[i].colours[2];
}
}
return 0;
}
void* __fastcall Colours::RandomizeColours(CRGBA* colour, void* edx, int r, int g, int b, int a)
{
if (Config::ColourRandomizer::rainbowTextEnabled)
if (Config::colours.rainbowTextEnabled)
{
CRGBA rainbow = GetRainbowColour(r, g, b);
if (r != g && g != b)
Expand All @@ -40,10 +57,10 @@ void* __fastcall Colours::RandomizeColours(CRGBA* colour, void* edx, int r, int
}
else
{
int pattern = r + b + g;
int pattern = r + g + b;
if (GetColour(pattern, 0) == 0)
{
Pattern pat = { r + g + b, {RandomNumber(1, 255), RandomNumber(1, 255), RandomNumber(1, 255)} };
Pattern pat = { pattern, {RandomNumber(1, 255), RandomNumber(1, 255), RandomNumber(1, 255)} };
Patterns.push_back(pat);
}

Expand All @@ -67,7 +84,7 @@ void* __fastcall Colours::RandomizeColours(CRGBA* colour, void* edx, int r, int
/* Had to put armour into it's own hooked function due to some issues with it */
void* __fastcall Colours::RandomizeMiscColours(CRGBA* colour, void* edx, int r, int g, int b, int a)
{
if (Config::ColourRandomizer::rainbowTextEnabled)
if (Config::colours.rainbowTextEnabled)
{
CRGBA rainbow = GetRainbowColour(r, g, b);
colour->r = rainbow.r;
Expand All @@ -77,10 +94,10 @@ void* __fastcall Colours::RandomizeMiscColours(CRGBA* colour, void* edx, int r,
}
else
{
int pattern = r + b + g;
int pattern = r + g + b;
if (GetColour(pattern, 0) == 0)
{
Pattern obj = { r + g + b, {RandomNumber(1, 255), RandomNumber(1, 255), RandomNumber(1, 255)} };
Pattern obj = { pattern, {RandomNumber(1, 255), RandomNumber(1, 255), RandomNumber(1, 255)} };
Patterns.push_back(obj);
}
colour->r = GetColour(pattern, 0);
Expand All @@ -101,6 +118,40 @@ void __fastcall Colours::RandomizeMarkerColours(C3dMarker* marker)
marker->Render();
marker->m_colour = original;
}
void Colours::RandomizePickupColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, char coronaType, char flareType, char refl, char obstacles, char arg12, float normalAngle)
{
int pattern = ID;
if (GetPickupsColour(pattern, 0) == 0)
{
Pattern col = { pattern, {r, g, b} };
PickupPatterns.push_back(col);
}
int origR = GetPickupsColour(pattern, 0);
int origG = GetPickupsColour(pattern, 1);
int origB = GetPickupsColour(pattern, 2);

CRGBA rainbow = GetRainbowColour(origR, origG, origB);

CCoronas::RegisterCorona(ID, rainbow.r, rainbow.g, rainbow.b, a, posn, radius, farClip, coronaType, flareType, refl, obstacles, arg12, normalAngle);
}
void Colours::RandomizeRaceMarkerColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, char coronaType, char flareType, char refl, char obstacles, char arg12, float normalAngle)
{
static int origR = 200;
static int origG = 0;
static int origB = 0;

CRGBA rainbow = GetRainbowColour(origR, origG, origB);

CCoronas::RegisterCorona(ID, rainbow.r, rainbow.g, rainbow.b, a, posn, radius, farClip, coronaType, flareType, refl, obstacles, arg12, normalAngle);
}
void Colours::RandomizeExplosionColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, RwTexture* texture, char flareType, char refl, char obstacles, char arg12, float normalAngle)
{
CRGBA rainbow = GetRainbowColour(r, g, b);
CCoronas::RegisterCorona(ID, rainbow.r, rainbow.g, rainbow.b, a, posn, radius, farClip, texture, flareType, refl, obstacles, arg12, normalAngle);
}
CRGBA Colours::GetRainbowColour(int r, int g, int b)
{
CRGBA colour;
Expand Down Expand Up @@ -193,21 +244,34 @@ void __fastcall Colours::ScriptVehicleColourRandomizer(CRunningScript* thisScrip
}
void Colours::Initialise()
{
if (Config::ColourRandomizer::vehicleEnabled)
if (Config::colours.vehicleEnabled)
{
// Vehicle Colours
plugin::patch::RedirectCall(0x48C04A, RandomizeColourTable);
plugin::patch::RedirectJump(0x520FD0, ChooseVehicleColour);
// Using this as a sort of workaround due to a fix
plugin::patch::RedirectCall(0x443B1E, ScriptVehicleColourRandomizer);
}
if (Config::ColourRandomizer::textEnabled)
if (Config::colours.textEnabled)
{
// Text Colours
plugin::patch::RedirectJump(0x4F8C20, RandomizeColours);
for (int textColourAddresses : {0x506332, 0x506BF2}) // Ammo, Faded Wanted Stars
plugin::patch::RedirectCall(textColourAddresses, RandomizeMiscColours);
}
if (Config::ColourRandomizer::markersEnabled)
if (Config::colours.markersEnabled)
{
plugin::patch::RedirectCall(0x51B441, RandomizeMarkerColours);
plugin::patch::RedirectCall(0x4448B3, RandomizeRaceMarkerColours);
}
if (Config::colours.pickupsEnabled)
{
for (int addr : {0x43196C, 0x431E7C, 0x4320FC, 0x43237C})
plugin::patch::RedirectCall(addr, RandomizePickupColours);
}
if (Config::colours.explosionsEnabled)
{
for (int addr : {0x55A574, 0x55A5AD, 0x55A6A9, 0x55A6E2})
plugin::patch::RedirectCall(addr, RandomizeExplosionColours);
}
}
11 changes: 10 additions & 1 deletion src/Colours.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CRunningScript.h"
#include "CTheScripts.h"
#include "C3dMarker.h"
#include "CCoronas.h"

class Colours : Functions
{
Expand All @@ -15,15 +16,23 @@ class Colours : Functions
static void* __fastcall RandomizeMiscColours(CRGBA* colour, void* edx, int r, int g, int b, int a);
static void __fastcall ScriptVehicleColourRandomizer(CRunningScript* thisScript, void* edx, int* arg0, short count);
static void __fastcall ChooseVehicleColour(CVehicleModelInfo* thisInfo, void* edx, int* prim, int* sec);
static void RandomizePickupColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, char coronaType, char flareType, char refl, char obstacles, char arg12, float normalAngle);
static void RandomizeRaceMarkerColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, char coronaType, char flareType, char refl, char obstacles, char arg12, float normalAngle);
static void RandomizeExplosionColours(int ID, char r, char g, char b, char a, CVector& posn, float radius,
float farClip, RwTexture* texture, char flareType, char refl, char obstacles, char arg12, float normalAngle);
static void __fastcall RandomizeMarkerColours(C3dMarker* marker);
static int RandomizeColourTable();
static int GetColour(int pattern, int rgb);
static int GetPickupsColour(int pattern, int rgb);
static CRGBA GetRainbowColour(int r, int g, int b);
static void HSVtoRGB(int H, double S, double V, int output[3]);
static struct Pattern
struct Pattern
{
int ID;
int colours[3];
};
static std::vector<Pattern> Patterns;
static std::vector<Pattern> PickupPatterns;
};
Loading

0 comments on commit 1be1a9a

Please sign in to comment.