1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 08:20:00 +00:00

Merge branch 'master' of github.com:GTAmodding/re3

This commit is contained in:
aap 2019-07-08 21:38:11 +02:00
commit 192fb45098
4 changed files with 1360 additions and 27 deletions

View file

@ -2,17 +2,21 @@
#include "patcher.h"
#include "Script.h"
#include "ScriptCommands.h"
#include "Camera.h"
#include "CarCtrl.h"
#include "DMAudio.h"
#include "FileMgr.h"
#include "Hud.h"
#include "Messages.h"
#include "ModelIndices.h"
#include "Pad.h"
#include "PlayerInfo.h"
#include "PlayerPed.h"
#include "Pools.h"
#include "Population.h"
#include "Replay.h"
#include "Streaming.h"
#include "User.h"
#include "Weather.h"
@ -32,7 +36,7 @@ int32(&CTheScripts::MultiScriptArray)[MAX_NUM_MISSION_SCRIPTS] = *(int32(*)[MAX_
tBuildingSwap(&CTheScripts::BuildingSwapArray)[MAX_NUM_BUILDING_SWAPS] = *(tBuildingSwap(*)[MAX_NUM_BUILDING_SWAPS])*(uintptr*)0x880E30;
CEntity*(&CTheScripts::InvisibilitySettingArray)[MAX_NUM_INVISIBILITY_SETTINGS] = *(CEntity*(*)[MAX_NUM_INVISIBILITY_SETTINGS])*(uintptr*)0x8620F0;
bool &CTheScripts::DbgFlag = *(bool*)0x95CD87;
uint32 &CTheScripts::OnAMissionFlag = *(uint32*)0x8F2A24;
uint32 &CTheScripts::OnAMissionFlag = *(uint32*)0x8F1B64;
int32 &CTheScripts::StoreVehicleIndex = *(int32*)0x8F5F3C;
bool &CTheScripts::StoreVehicleWasRandom = *(bool*)0x95CDBC;
CRunningScript *&CTheScripts::pIdleScripts = *(CRunningScript**)0x9430D4;
@ -55,6 +59,8 @@ bool &CTheScripts::UseTextCommands = *(bool*)0x95CD57;
CMissionCleanup (&CTheScripts::MissionCleanup) = *(CMissionCleanup*)0x8F2A24;
CUpsideDownCarCheck (&CTheScripts::UpsideDownCars) = *(CUpsideDownCarCheck*)0x6EE450;
CStuckCarCheck (&CTheScripts::StuckCars) = *(CStuckCarCheck*)0x87C588;
uint16 &CTheScripts::CommandsExecuted = *(uint16*)0x95CCA6;
uint16 &CTheScripts::ScriptsUpdated = *(uint16*)0x95CC5E;
int32(&ScriptParams)[32] = *(int32(*)[32])*(uintptr*)0x6ED460;
CMissionCleanup::CMissionCleanup()
@ -403,7 +409,7 @@ void CRunningScript::Init()
m_nStackPointer = 0;
m_nWakeTime = 0;
m_bCondResult = false;
m_bIsMissionThread = false;
m_bIsMissionScript = false;
m_bSkipWakeTime = false;
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
m_anLocalVariables[i] = 0;
@ -435,6 +441,27 @@ int open_script()
}
#endif
void CTextLine::Reset()
{
m_fScaleX = 0.48f;
m_fScaleY = 1.12f;
m_sColor = CRGBA(225, 225, 225, 255);
m_bJustify = false;
m_bRightJustify = false;
m_bCentered = false;
m_bBackground = false;
m_bBackgroundOnly = false;
m_fWrapX = 182.0f; /* TODO: scaling as bugfix */
m_fCenterSize = 640.0f; /* --||-- */
m_sBackgroundColor = CRGBA(128, 128, 128, 128);
m_bTextProportional = true;
m_bTextBeforeFade = false;
m_nFont = 2; /* enum? */
m_fAtX = 0.0f;
m_fAtY = 0.0f;
memset(&m_Text, 0, sizeof(m_Text));
}
void CTheScripts::Init()
{
for (int i = 0; i < SIZE_SCRIPT_SPACE; i++)
@ -497,29 +524,13 @@ void CTheScripts::Init()
ScriptSphereArray[i].m_fRadius = 0.0f;
}
for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++){
IntroTextLines[i].m_fScaleX = 0.48f;
IntroTextLines[i].m_fScaleY = 1.12f;
IntroTextLines[i].m_sColor = CRGBA(225, 225, 225, 255);
IntroTextLines[i].m_bJustify = false;
IntroTextLines[i].m_bRightJustify = false;
IntroTextLines[i].m_bCentered = false;
IntroTextLines[i].m_bBackground = false;
IntroTextLines[i].m_bBackgroundOnly = false;
IntroTextLines[i].m_fWrapX = 182.0f; /* TODO: scaling as bugfix */
IntroTextLines[i].m_fCenterSize = 640.0f; /* --||-- */
IntroTextLines[i].m_sBackgroundColor = CRGBA(128, 128, 128, 128);
IntroTextLines[i].m_bTextProportional = true;
IntroTextLines[i].m_bTextBeforeFade = false;
IntroTextLines[i].m_nFont = 2; /* enum? */
IntroTextLines[i].m_fAtX = 0.0f;
IntroTextLines[i].m_fAtY = 0.0f;
memset(&IntroTextLines[i].m_Text, 0, sizeof(IntroTextLines[i].m_Text));
IntroTextLines[i].Reset();
}
NumberOfIntroTextLinesThisFrame = 0;
UseTextCommands = false;
for (int i = 0; i < MAX_NUM_INTRO_RECTANGLES; i++){
IntroRectangles[i].m_bIsUsed = false;
IntroRectangles[i].m_bIsAntialiased = false;
IntroRectangles[i].m_bBeforeFade = false;
IntroRectangles[i].m_nTextureId = -1;
IntroRectangles[i].m_sRect = CRect(0.0f, 0.0f, 0.0f, 0.0f);
IntroRectangles[i].m_sColor = CRGBA(255, 255, 255, 255);
@ -553,7 +564,138 @@ void CRunningScript::AddScriptToList(CRunningScript** ppScript)
*ppScript = this;
}
WRAPPER bool CTheScripts::IsPlayerOnAMission() { EAXJMP(0x439410); }
CRunningScript* CTheScripts::StartNewScript(uint32 ip)
{
CRunningScript* pNew = pIdleScripts;
assert(pNew);
pNew->RemoveScriptFromList(&pIdleScripts);
pNew->Init();
pNew->SetIP(ip);
pNew->AddScriptToList(&pActiveScripts);
return pNew;
}
void CTheScripts::Process()
{
if (CReplay::IsPlayingBack())
return;
CommandsExecuted = 0;
ScriptsUpdated = 0;
float timeStep = CTimer::GetTimeStepInMilliseconds();
UpsideDownCars.UpdateTimers();
StuckCars.Process();
DrawScriptSpheres();
if (FailCurrentMission)
--FailCurrentMission;
if (CountdownToMakePlayerUnsafe){
if (--CountdownToMakePlayerUnsafe == 0)
CWorld::Players[0].MakePlayerSafe(false);
}
if (UseTextCommands){
for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++)
IntroTextLines[i].Reset();
NumberOfIntroRectanglesThisFrame = 0;
for (int i = 0; i < MAX_NUM_INTRO_RECTANGLES; i++){
IntroRectangles[i].m_bIsUsed = false;
IntroRectangles[i].m_bBeforeFade = false;
}
NumberOfIntroRectanglesThisFrame = 0;
if (UseTextCommands == 1)
UseTextCommands = 0;
}
CRunningScript* script = pActiveScripts;
while (script != nil){
CRunningScript* next = script->GetNext();
++ScriptsUpdated;
script->UpdateTimers(timeStep);
script->Process();
script = next;
}
DbgFlag = false;
}
CRunningScript* CTheScripts::StartTestScript()
{
return StartNewScript(0);
}
bool CTheScripts::IsPlayerOnAMission()
{
return OnAMissionFlag && *(int32*)&ScriptSpace[OnAMissionFlag] == 1;
}
void CRunningScript::Process()
{
if (m_bIsMissionScript)
DoDeatharrestCheck();
if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1)
m_nIp = m_anStack[--m_nStackPointer];
if (CTimer::GetTimeInMilliseconds() >= m_nWakeTime){
while (!ProcessOneCommand())
;
return;
}
if (!m_bSkipWakeTime)
return;
if (!CPad::GetPad(0)->GetCrossJustDown())
return;
m_nWakeTime = 0;
for (int i = 0; i < 6; i++){ /* TODO: add constant for number of messages */
if (CMessages::BIGMessages[i].m_Current.m_pText)
CMessages::BIGMessages[i].m_Current.m_nStartTime = 0;
if (CMessages::BriefMessages[0].m_pText)
CMessages::BriefMessages[0].m_nStartTime = 0;
}
}
int8 CRunningScript::ProcessOneCommand()
{
++CTheScripts::CommandsExecuted;
int32 command = CTheScripts::Read2BytesFromScript(&m_nIp);
m_bNotFlag = (command & 0x8000);
command &= 0x7FFF;
if (command < 100)
return ProcessCommandsFrom0To99(command);
if (command < 200)
return ProcessCommandsFrom100To199(command);
if (command < 300)
return ProcessCommandsFrom200To299(command);
if (command < 400)
return ProcessCommandsFrom300To399(command);
if (command < 500)
return ProcessCommandsFrom400To499(command);
if (command < 600)
return ProcessCommandsFrom500To599(command);
if (command < 700)
return ProcessCommandsFrom600To699(command);
if (command < 800)
return ProcessCommandsFrom700To799(command);
if (command < 900)
return ProcessCommandsFrom800To899(command);
if (command < 1000)
return ProcessCommandsFrom900To999(command);
if (command < 1100)
return ProcessCommandsFrom1000To1099(command);
if (command < 1200)
return ProcessCommandsFrom1100To1199(command);
return -1;
}
WRAPPER int8 CRunningScript::ProcessCommandsFrom0To99(int32 command) { EAXJMP(0x439650); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) { EAXJMP(0x43AEA0); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom200To299(int32 command) { EAXJMP(0x43D530); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom300To399(int32 command) { EAXJMP(0x43ED30); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom400To499(int32 command) { EAXJMP(0x440CB0); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom500To599(int32 command) { EAXJMP(0x4429C0); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom600To699(int32 command) { EAXJMP(0x444B20); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom700To799(int32 command) { EAXJMP(0x4458A0); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom800To899(int32 command) { EAXJMP(0x448240); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom900To999(int32 command) { EAXJMP(0x44CB80); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom1000To1099(int32 command) { EAXJMP(0x588490); }
WRAPPER int8 CRunningScript::ProcessCommandsFrom1100To1199(int32 command) { EAXJMP(0x589D00); }
WRAPPER void CTheScripts::DrawScriptSpheres() { EAXJMP(0x44FAC0); }
WRAPPER void CRunningScript::DoDeatharrestCheck() { EAXJMP(0x452A30); }
WRAPPER void CTheScripts::ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2) { EAXJMP(0x4534E0); }
WRAPPER void CTheScripts::CleanUpThisVehicle(CVehicle*) { EAXJMP(0x4548D0); }
WRAPPER void CTheScripts::CleanUpThisPed(CPed*) { EAXJMP(0x4547A0); }
@ -582,6 +724,9 @@ InjectHook(0x4382E0, &CRunningScript::CollectParameters, PATCH_JUMP);
InjectHook(0x438460, &CRunningScript::CollectNextParameterWithoutIncreasingPC, PATCH_JUMP);
InjectHook(0x4385A0, &CRunningScript::StoreParameters, PATCH_JUMP);
InjectHook(0x438640, &CRunningScript::GetPointerToScriptVariable, PATCH_JUMP);
InjectHook(0x4386C0, &CRunningScript::Init, PATCH_JUMP);
InjectHook(0x438790, &CTheScripts::Init, PATCH_JUMP);
InjectHook(0x439000, &CTheScripts::StartNewScript, PATCH_JUMP);
InjectHook(0x439040, &CTheScripts::Process, PATCH_JUMP);
InjectHook(0x439400, &CTheScripts::StartTestScript, PATCH_JUMP);
InjectHook(0x439410, &CTheScripts::IsPlayerOnAMission, PATCH_JUMP);
ENDPATCHES

View file

@ -10,8 +10,8 @@ class CObject;
struct CScriptRectangle
{
bool m_bIsUsed;
bool m_bIsAntialiased;
int8 m_bIsUsed;
bool m_bBeforeFade;
int16 m_nTextureId;
CRect m_sRect;
CRGBA m_sColor;
@ -42,6 +42,8 @@ struct CTextLine
float m_fAtX;
float m_fAtY;
wchar m_Text[SCRIPT_TEXT_MAX_LENGTH];
void Reset();
};
static_assert(sizeof(CTextLine) == 0x414, "Script.h: error");
@ -71,7 +73,7 @@ class CRunningScript
uint16 m_nStackPointer;
int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
bool m_bCondResult;
bool m_bIsMissionThread;
bool m_bIsMissionScript;
bool m_bSkipWakeTime;
uint32 m_nWakeTime;
uint16 m_nAndOrState;
@ -81,6 +83,13 @@ class CRunningScript
bool m_bMissionFlag;
public:
void SetIP(uint32 ip) { m_nIp = ip; }
CRunningScript* GetNext() { return next; }
void UpdateTimers(float timeStep){
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
}
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
@ -88,6 +97,21 @@ public:
void Init();
void RemoveScriptFromList(CRunningScript**);
void AddScriptToList(CRunningScript**);
void Process();
int8 ProcessOneCommand();
void DoDeatharrestCheck();
int8 ProcessCommandsFrom0To99(int32);
int8 ProcessCommandsFrom100To199(int32);
int8 ProcessCommandsFrom200To299(int32);
int8 ProcessCommandsFrom300To399(int32);
int8 ProcessCommandsFrom400To499(int32);
int8 ProcessCommandsFrom500To599(int32);
int8 ProcessCommandsFrom600To699(int32);
int8 ProcessCommandsFrom700To799(int32);
int8 ProcessCommandsFrom800To899(int32);
int8 ProcessCommandsFrom900To999(int32);
int8 ProcessCommandsFrom1000To1099(int32);
int8 ProcessCommandsFrom1100To1199(int32);
};
enum {
@ -266,17 +290,23 @@ public:
static uint16 &NumberOfIntroRectanglesThisFrame;
static uint16 &NumberOfIntroTextLinesThisFrame;
static bool &UseTextCommands;
static uint16 &CommandsExecuted;
static uint16 &ScriptsUpdated;
public:
static bool IsPlayerOnAMission();
static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2);
static void CleanUpThisVehicle(CVehicle*);
static void CleanUpThisPed(CPed*);
static void CleanUpThisObject(CObject*);
static void Init();
static CRunningScript* StartNewScript(uint32);
static void Process();
static CRunningScript* StartTestScript();
static bool IsPlayerOnAMission();
static void ReadObjectNamesFromScript();
static void UpdateObjectIndices();
static void ReadMultiScriptFileOffsetsFromScript();
static void DrawScriptSpheres();
static int32 Read4BytesFromScript(uint32* pIp){
int32 retval = 0;

1158
src/control/ScriptCommands.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -862,7 +862,7 @@ void CHud::Draw()
CScriptRectangle* IntroRect = CTheScripts::IntroRectangles;
for (int i = 0; i < 16; i++) {
if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bIsAntialiased) {
if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bBeforeFade) {
if (CTheScripts::IntroRectangles[i].m_nTextureId >= 0) {
CRect rect = {
CTheScripts::IntroRectangles[i].m_sRect.left,