Skip to content

Commit

Permalink
Merge branch 'master' into shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Parik27 committed Sep 4, 2022
2 parents 7bcf20b + c20d796 commit a4ff668
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 41 deletions.
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ VoiceLineRandomizer = true
SfxRandomizer = true
TimecycleRandomizer = true
PedRandomizer = true
MissionRandomizer = true
HandlingRandomizer = false
SwitchSceneRandomizer = false
RespawnRandomizer = true
Expand Down Expand Up @@ -158,6 +159,8 @@ ForceSeedOnSaves = false

ForcedMission = "" # All missions will start this instead of a random mission.

ForcedOrder = "" # https://parik.eu.org/order.html

EnableFastSkips = false # Mission skips will be enabled after failing the mission once. Useful for testing

#######################################################
Expand Down
17 changes: 16 additions & 1 deletion lib/scrThread.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#pragma once

#include <cstdint>
#include <cstdint>
#include <string>

Expand Down Expand Up @@ -246,7 +247,8 @@ public:
scrThreadContext m_Context;
uint64_t * m_pStack = nullptr;
uint8_t field_0xb8[24] = {0};
char m_szScriptName[64] = {0}; // TODO: Move to GtaThread

char m_ScriptName[64] = {0};

class Info
{
Expand Down Expand Up @@ -355,6 +357,19 @@ public:
return *sm_pActiveThread;
}

const char *
GetName ()
{
// Hacky Compatibility for b2699+ builds which have additional field
// before script name to store the hash.
uint32_t scriptHash = *reinterpret_cast<uint32_t *> (m_ScriptName);

if (scriptHash == m_Context.m_nScriptHash)
return &m_ScriptName[4];

return m_ScriptName;
}

static bool
CheckActiveThread (uint32_t hash)
{
Expand Down
232 changes: 232 additions & 0 deletions scripts/order.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<!doctype html>
<html>
<header>
<title>Mission Randomizer Order Editor</title>
</header>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<style>
body
{
padding: 32px;
background: white;
}

html
{
background: blue;
}
</style>

<script>
var missions = ["Cleaning Out the Bureau",
"Architect's Plans",
"The Bureau Raid (Covert)",
"The Bureau Raid (Roof)",
"Franklin and Lamar",
"Repossession",
"Complications",
"The Bus Assassination",
"The Construction Assassination",
"The Vice Assassination",
"The Multi Target Assassination",
"The Hotel Assassination",
"I Fought the Law...",
"Eye in the Sky",
"Deep Inside",
"Pack Man",
"Trevor Philips Industries",
"Crystal Maze",
"The Merryweather Heist (Freighter)",
"The Merryweather Heist (Offshore)",
"Minisub",
"Cargobob",
"Scouting the Port",
"Minor Turbulence",
"Predator",
"Derailed",
"Father/Son",
"Daddy's Little Girl",
"Marriage Counseling",
"Fame or Shame",
"Did Somebody Say Yoga?",
"Reuniting the Family",
"Dead Man Walking",
"Three's Company",
"By the Book",
"Blitz Play",
"Trash Truck",
"Tow Truck",
"Masks",
"Boiler Suits",
"Monkey Business",
"Stingers",
"Driller",
"Sidetracked",
"Surveying the Score",
"The Big Score (Subtle)",
"The Big Score (Obvious)",
"Finale (Cutscene)",
"Something Sensible",
"The Time's Come",
"The Third Way (Part 1)",
"The Third Way (Part 2)",
"Chop",
"Hood Safari",
"Lamar Down",
"The Jewel Store Job",
"Bugstars Equipment",
"Carbine Rifles",
"BZ Gas Grenades",
"Casing the Jewel Store",
"The Long Stretch",
"Friend Request",
"Caida Libre",
"Bury the Hatchet",
"Fresh Meat",
"The Wrap Up",
"Meltdown",
"Prologue",
"The Paleto Score",
"Military Hardware",
"Paleto Score Setup",
"Mr. Richards",
"The Ballad of Rocco",
"Legal Trouble",
"Mr. Philips",
"Nervous Ron",
"Friends Reunited",
"Hang Ten"];

var choices = [true, true, true, true];

function generateDefaultMissMap () {
let arr = []
for (let mission in missions) {
arr[mission] = parseInt(mission);
}
return arr;
}

var missMap = generateDefaultMissMap ();

function generateMissionsDataList (elem) {
for (let mission in missions) {
elem.append(`<option value="${mission}">${missions[mission]}</option>`);
}
return elem;
}

function updateMap(missId, value) {
missMap[missId] = parseInt(value);
updateOrderString();
}

function updateOrderString () {
let str = ""
for (let mission of missMap) {
str += String.fromCharCode(parseInt(mission)+44);
}
str += $("#jewel").val();
str += $("#finale").val();
str += $("#docks").val();
str += $("#agency").val();

$("#generated").val(str);
}

function refreshMainDiv () {
for (let mission in missMap) {
$(`#selection_${mission}`).val(missMap[mission]);
}
}

function updateMissMapFromOrderString () {
let orderStr = $("#generated").val();
if (orderStr.length != missMap.length+4) {
updateOrderString ();
return;
}

for (let i = 0; i < orderStr.length-4; i++) {
if (orderStr.charCodeAt (i) < 44 || orderStr.charCodeAt (i) >= 44 + missMap.length)
{
console.log(orderStr.charCodeAt(i));
updateOrderString ();
refreshMainDiv ();
return;
}

missMap[i] = orderStr.charCodeAt (i) - 44;
}

$("#jewel").val(orderStr[missMap.length]);
$("#finale").val(orderStr[missMap.length+1]);
$("#docks").val(orderStr[missMap.length+2]);
$("#agency").val(orderStr[missMap.length+3]);

refreshMainDiv();
}

function generateMainDiv () {
for (let mission in missions) {
let row = $(`<tr></tr>`);
row.append(`<td> ${mission}. </td>`);
row.append(`<td> ${missions[mission]}</td>`);
row.append($(`<td></td>`).append(generateMissionsDataList(
$(`<select list="missions" id="selection_${mission}" onchange="updateMap(${mission},this.value)">`))));
$('#main').append(row);
}
updateOrderString ();
refreshMainDiv ();
}
</script>

<body onload="generateMainDiv()">
<h2>Mission Randomizer - Order Editor</h2>
Generated order: <input style="width:78ch" id="generated" onchange="updateMissMapFromOrderString ()"></input>

<p>
<table>
<tr>
<td>Bureau Raid Approach: </td>
<td>
<select onchange="updateOrderString ()" id="agency">
<option value="1">Covert</option>
<option value="0">Roof</option>
</select>
</td>
</tr>
<tr>
<td>Merryweather Heist Approach: </td>
<td>
<select onchange="updateOrderString ()" id="docks">
<option value="1">Freighter</option>
<option value="0">Offshore</option>
</select>
</td>
</tr>
<tr>
<td>The Big Score Approach: </td>
<td>
<select onchange="updateOrderString ()" id="finale">
<option value="0">Subtle</option>
<option value="1">Obvious</option>
</select>
</td>
</tr>
<tr>
<td>Jewelry Heist Approach: </td>
<td>
<select onchange="updateOrderString ()" id="jewel">
<option value="0">Loud</option>
<option value="1">Smart</option>
</select>
</td>
</tr>
</table>
<p>
<table id="main">
</table>
</p>
</body>
20 changes: 17 additions & 3 deletions src/common/PatchFilterDLC2612.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Source:
// https://github.com/citizenfx/fivem/blob/a7ff9cb6701406c15d9391c1ed89c058e9591c96/code/components/gta-core-five/src/PatchFilterDLC2612.cpp
// https://github.com/citizenfx/fivem/blob/315653e9b3f712d6b478f143f23ff97017520df3/code/components/gta-core-five/src/PatchFilterDLC.cpp

#include "common/minhook.hh"
#include <unordered_set>

//
// Ignore 'stub' assets from dlc_mpG9EC, as of b2612 at least these are weird
// and may crash the game.
// Ignore 'stub' assets (exclusive content) that may crash the game.
// - dlc_mpG9EC, as of b2612
// - dlc_mpSum2_g9ec, as of b2699
//

struct CDataFileMgr
Expand Down Expand Up @@ -47,6 +48,19 @@ static std::unordered_set<std::string> g_badFiles{
"dlc_mpG9EC:/x64/models/cdimages/mpg9ec_male.rpf",
"dlc_mpG9ECCRC:/common/data/mp_f_freemode_01_mpg9ec_shop.meta",
"dlc_mpG9EC:/x64/models/cdimages/mpg9ec_female.rpf",

"dlc_mpSum2_g9ec:/x64/levels/mpsum2_g9ec/vehiclemods/feltzer3hsw_mods.rpf",
"dlc_mpSum2_g9ec:/x64/levels/mpsum2_g9ec/vehiclemods/vigero2hsw_mods.rpf",
"dlc_mpSum2_g9ec:/x64/models/cdimages/mpSum2_g9ec_female.rpf",
"dlc_mpSum2_g9ec:/x64/models/cdimages/mpSum2_g9ec_female_p.rpf",
"dlc_mpSum2_g9ec:/x64/models/cdimages/mpSum2_g9ec_male.rpf",
"dlc_mpSum2_g9ec:/x64/models/cdimages/mpSum2_g9ec_male_p.rpf",
"dlc_mpSum2_g9ecCRC:/common/data/mp_f_freemode_01_mpSum2_g9ec_shop.meta",
"dlc_mpSum2_g9ecCRC:/common/data/mp_m_freemode_01_mpSum2_g9ec_shop.meta",
"dlc_mpSum2_g9ec:/x64/anim/creaturemetadata.rpf",
"dlc_mpSum2_g9ec:/common/data/effects/peds/first_person_alternates.meta",
"dlc_mpSum2_g9ec:/common/data/effects/peds/first_person.meta",
"dlc_mpSum2_g9ecCRC:/common/data/pedalternatevariations.meta",
};

static void (*_applyChangeSetEntry)(ChangeSetEntry* entry);
Expand Down
1 change: 1 addition & 0 deletions src/common/configDefault.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ VoiceLineRandomizer = true
SfxRandomizer = true
TimecycleRandomizer = true
PedRandomizer = true
MissionRandomizer = true
HandlingRandomizer = false
SwitchSceneRandomizer = false
RespawnRandomizer = true
Expand Down
4 changes: 2 additions & 2 deletions src/common/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#ifndef NDEBUG
#define RAINBOMIZER_BUILD "Debug Build: " __DATE__ " " __TIME__
#else
#define RAINBOMIZER_BUILD "Release v3.3: " __DATE__ " " __TIME__
#define RAINBOMIZER_BUILD_SHORT "Release v3.3"
#define RAINBOMIZER_BUILD "Release v3.3.1: " __DATE__ " " __TIME__
#define RAINBOMIZER_BUILD_SHORT "Release v3.3.1"
#endif

constexpr int RAINBOMIZER_BUILD_NUMBER =
Expand Down
8 changes: 4 additions & 4 deletions src/debug/scripts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class TTDFile
char MagicNumber[] = "RBTTD";
fwrite (MagicNumber, 1, sizeof (MagicNumber), m_File);

fwrite (thread->m_szScriptName, 1, 64, m_File);
fwrite (thread->GetName (), 1, 64, m_File);
fwrite (&thread->m_Context.m_nThreadId, 4, 1, m_File);
fwrite (&thread->m_pStack, 8, 1, m_File);

Expand Down Expand Up @@ -343,7 +343,7 @@ class TTDFile
return;

m_File = Rainbomizer::Common::GetRainbomizerFile (
fmt::format ("{}_{}.{}.ttd", thread->m_szScriptName,
fmt::format ("{}_{}.{}.ttd", thread->GetName (),
thread->m_Context.m_nThreadId, time (nullptr)),
"wb", "ttd/");

Expand All @@ -368,7 +368,7 @@ class TTDFile
return true;

Rainbomizer::Logger::LogMessage ("Starting capture thread: %s",
thread->m_szScriptName);
thread->GetName ());

if (CFlowOnly)
m_eState = CAPTURING_CFLOW;
Expand Down Expand Up @@ -594,7 +594,7 @@ class TimeTravelDebugInterface : public DebugInterface
m_Files.erase (ctx->m_nScriptHash);
Rainbomizer::Logger::LogMessage (
"Finished tracing thread: %s",
scrThread::GetActiveThread ()->m_szScriptName);
scrThread::GetActiveThread ()->GetName ());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/exceptions/exceptions_Threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ExceptionHandler_Threads : public ExceptionHandler
void
DumpStatics (scrThread *thread)
{
FILE *f = Common::GetRainbomizerFile (thread->m_szScriptName
FILE *f = Common::GetRainbomizerFile (thread->GetName ()
+ std::string (".stack.bin"),
"w", "logs/threads/");

Expand Down Expand Up @@ -62,7 +62,7 @@ class ExceptionHandler_Threads : public ExceptionHandler
"%s %s, Hash: %x, SP: %x, IP: "
"%x, FSP: %x, State: %s",
thread == scrThread::GetActiveThread () ? "=>" : " ",
thread->m_szScriptName, thread->m_Context.m_nScriptHash,
thread->GetName (), thread->m_Context.m_nScriptHash,
thread->m_Context.m_nSP, thread->m_Context.m_nIp,
thread->m_Context.m_nFrameSP,
GetStateName (thread->m_Context.m_nState));
Expand Down
Loading

0 comments on commit a4ff668

Please sign in to comment.