summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2019-08-15 04:06:52 +0200
committerGitHub <noreply@github.com>2019-08-15 04:06:52 +0200
commit6909fa283a25410a6d5f2fc93259b71770512ca2 (patch)
treecc187ba965eb71352fae028d3eb7f9f8db463153 /src/core
parentCParticleObject done, cDMAudio done (diff)
parentMerge pull request #189 from Nick007J/master (diff)
downloadre3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar.gz
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar.bz2
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar.lz
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar.xz
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.tar.zst
re3-6909fa283a25410a6d5f2fc93259b71770512ca2.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Camera.cpp10
-rw-r--r--src/core/Camera.h5
-rw-r--r--src/core/Collision.cpp2
-rw-r--r--src/core/General.h18
-rw-r--r--src/core/IniFile.cpp28
-rw-r--r--src/core/IniFile.h10
-rw-r--r--src/core/Radar.cpp16
-rw-r--r--src/core/Radar.h8
-rw-r--r--src/core/Stats.cpp4
-rw-r--r--src/core/Stats.h2
-rw-r--r--src/core/Wanted.h2
-rw-r--r--src/core/World.cpp2
-rw-r--r--src/core/World.h4
-rw-r--r--src/core/common.h2
-rw-r--r--src/core/config.h6
-rw-r--r--src/core/re3.cpp54
16 files changed, 128 insertions, 45 deletions
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index b5ba76db..f3582c67 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -24,6 +24,16 @@ WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); }
WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); }
WRAPPER void CCamera::SetWidescreenOff(void) { EAXJMP(0x46FF10); }
WRAPPER void CamShakeNoPos(CCamera*, float) { EAXJMP(0x46B100); }
+WRAPPER void CCamera::TakeControl(CEntity*, int16, int16, int32) { EAXJMP(0x471500); }
+WRAPPER void CCamera::TakeControlNoEntity(const CVector&, int16, int32) { EAXJMP(0x4715B0); }
+WRAPPER void CCamera::SetCamPositionForFixedMode(const CVector&, const CVector&) { EAXJMP(0x46FCC0); }
+
+
+bool
+CCamera::GetFading()
+{
+ return m_bFading;
+}
bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 3ce0d9a6..97ed79f4 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -471,6 +471,11 @@ int m_iModeObbeCamIsInForCar;
float Find3rdPersonQuickAimPitch(void);
+ void TakeControl(CEntity*, int16, int16, int32);
+ void TakeControlNoEntity(const CVector&, int16, int32);
+ void SetCamPositionForFixedMode(const CVector&, const CVector&);
+ bool GetFading();
+
void dtor(void) { this->CCamera::~CCamera(); }
};
static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error");
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index df1dcd63..66b29d9f 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -144,7 +144,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
if(veh && veh->IsTrain()){
if(((CTrain*)veh)->m_nDoorState != TRAIN_DOOR_OPEN)
return;
- }else if(playerCoors.z < 4.0f && !CCullZones::DoINeedToLoadCollision())
+ }else if(playerCoors.z < -4.0f && !CCullZones::DoINeedToLoadCollision())
return;
// Figure out whose level's collisions we're most likely to be interested in
diff --git a/src/core/General.h b/src/core/General.h
index 7c0c9562..8f9aa044 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -74,6 +74,7 @@ public:
return result;
}
+ // Returns an angle such that x2/y2 looks at x1/y1 with its forward vector if rotated by that angle
static float GetRadianAngleBetweenPoints(float x1, float y1, float x2, float y2)
{
float x = x2 - x1;
@@ -95,9 +96,26 @@ public:
}
}
+ // should return direction in 0-8 range. fits perfectly to peds' path directions.
+ static int CGeneral::GetNodeHeadingFromVector(float x, float y)
+ {
+ float angle = CGeneral::GetRadianAngleBetweenPoints(x, y, 0.0f, 0.0f);
+ if (angle < 0.0f)
+ angle += TWOPI;
+
+ angle = DEGTORAD(22.5f) + TWOPI - angle;
+
+ if (angle >= TWOPI)
+ angle -= TWOPI;
+
+ return (int)floorf(angle / DEGTORAD(45.0f));
+ }
+
// not too sure about all these...
static uint16 GetRandomNumber(void)
{ return myrand() & MYRAND_MAX; }
+ static bool GetRandomTrueFalse(void)
+ { return GetRandomNumber() < MYRAND_MAX / 2; }
// Probably don't want to ever reach high
static float GetRandomNumberInRange(float low, float high)
{ return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); }
diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp
new file mode 100644
index 00000000..08b30876
--- /dev/null
+++ b/src/core/IniFile.cpp
@@ -0,0 +1,28 @@
+#include "common.h"
+#include "patcher.h"
+#include "IniFile.h"
+
+#include "CarCtrl.h"
+#include "FileMgr.h"
+#include "main.h"
+#include "Population.h"
+
+float &CIniFile::PedNumberMultiplier = *(float*)0x6182F4;
+float &CIniFile::CarNumberMultiplier = *(float*)0x6182F8;
+
+void CIniFile::LoadIniFile()
+{
+ CFileMgr::SetDir("");
+ int f = CFileMgr::OpenFile("gta3.ini", "r");
+ if (f){
+ CFileMgr::ReadLine(f, gString, 200);
+ sscanf(gString, "%f", &PedNumberMultiplier);
+ PedNumberMultiplier = min(3.0f, max(0.5f, PedNumberMultiplier));
+ CFileMgr::ReadLine(f, gString, 200);
+ sscanf(gString, "%f", &CarNumberMultiplier);
+ CarNumberMultiplier = min(3.0f, max(0.5f, CarNumberMultiplier));
+ CFileMgr::CloseFile(f);
+ }
+ CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier;
+ CCarCtrl::MaxNumberOfCarsInUse = 12.0f * CarNumberMultiplier;
+} \ No newline at end of file
diff --git a/src/core/IniFile.h b/src/core/IniFile.h
new file mode 100644
index 00000000..9a98151b
--- /dev/null
+++ b/src/core/IniFile.h
@@ -0,0 +1,10 @@
+#pragma once
+
+class CIniFile
+{
+public:
+ static void LoadIniFile();
+
+ static float& PedNumberMultiplier;
+ static float& CarNumberMultiplier;
+};
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index ea7a7ffa..f04e14d1 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -100,9 +100,9 @@ void CRadar::ChangeBlipBrightness(int32 i, int32 bright)
#endif
#if 1
-WRAPPER void CRadar::ChangeBlipColour(int32) { EAXJMP(0x4A5770); }
+WRAPPER void CRadar::ChangeBlipColour(int32, int32) { EAXJMP(0x4A5770); }
#else
-void CRadar::ChangeBlipColour(int32 i)
+void CRadar::ChangeBlipColour(int32 i, int32)
{
}
@@ -571,9 +571,9 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float
#endif
#if 1
-WRAPPER int32 CRadar::GetActualBlipArray(int32) { EAXJMP(0x4A41C0); }
+WRAPPER int32 CRadar::GetActualBlipArrayIndex(int32) { EAXJMP(0x4A41C0); }
#else
-int32 CRadar::GetActualBlipArray(int32 i)
+int32 CRadar::GetActualBlipArrayIndex(int32 i)
{
return int32();
}
@@ -737,18 +737,18 @@ void CRadar::SetBlipSprite(int32 i, int32 icon)
#endif
#if 1
-WRAPPER int CRadar::SetCoordBlip(int32, CVector, int32) { EAXJMP(0x4A5590); }
+WRAPPER int32 CRadar::SetCoordBlip(eBlipType, CVector, int32, eBlipDisplay) { EAXJMP(0x4A5590); }
#else
-int CRadar::SetCoordBlip(int32 type, CVector pos, int32 flag)
+int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 flag, eBlipDisplay)
{
return 0;
}
#endif
#if 1
-WRAPPER int CRadar::SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag) { EAXJMP(0x4A5640); }
+WRAPPER int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) { EAXJMP(0x4A5640); }
#else
-int CRadar::SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag)
+int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay)
{
return 0;
}
diff --git a/src/core/Radar.h b/src/core/Radar.h
index e5396a50..1ec28070 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -98,7 +98,7 @@ public:
public:
static int CalculateBlipAlpha(float dist);
static void ChangeBlipBrightness(int32 i, int32 bright);
- static void ChangeBlipColour(int32 i);
+ static void ChangeBlipColour(int32 i, int32);
static void ChangeBlipDisplay(int32 i, int16 flag);
static void ChangeBlipScale(int32 i, int16 scale);
static void ClearBlip(int32 i);
@@ -113,7 +113,7 @@ public:
static void DrawRadarSection(int32 x, int32 y);
static void DrawRadarSprite(int32 sprite, float x, float y, int32 alpha);
static void DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha);
- static int32 GetActualBlipArray(int32 i);
+ static int32 GetActualBlipArrayIndex(int32 i);
static int32 GetNewUniqueBlipIndex(int32 i);
static int32 GetRadarTraceColour(int32 color, bool bright);
static void Initialise();
@@ -125,8 +125,8 @@ public:
static void RequestMapSection(int32 x, int32 y);
static void SaveAllRadarBlips(int32);
static void SetBlipSprite(int32 i, int32 icon);
- static int SetCoordBlip(int32 type, CVector pos, int32 flag);
- static int SetEntityBlip(int32 type, CVector pos, int32 color, int32 flag);
+ static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay flag);
+ static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay);
static void SetRadarMarkerState(int32 i, int32 flag);
static void ShowRadarMarker(CVector pos, int16 color, float radius);
static void ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha);
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index 01bbf82e..9d0e7df1 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -7,8 +7,10 @@ bool& CStats::CommercialPassed = *(bool*)0x8F4334;
bool& CStats::IndustrialPassed = *(bool*)0x8E2A68;
int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C;
int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50;
+int32 &CStats::HelisDestroyed = *(int32*)0x8E2A64;
+int32 *CStats::PedsKilledOfThisType = (int32*)0x880DBC;
void CStats::AnotherKillFrenzyPassed()
{
++NumberKillFrenziesPassed;
-} \ No newline at end of file
+}
diff --git a/src/core/Stats.h b/src/core/Stats.h
index c536465f..90db25e8 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -9,6 +9,8 @@ public:
static bool& IndustrialPassed;
static int32 &NumberKillFrenziesPassed;
static int32 &PeopleKilledByOthers;
+ static int32 &HelisDestroyed;
+ static int32 *PedsKilledOfThisType; //[NUM_PEDTYPES]
public:
static void AnotherKillFrenzyPassed();
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index 7cd89b7e..34a4b58d 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -77,6 +77,8 @@ public:
void ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesntCare);
void UpdateWantedLevel();
+ bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; }
+
static int32 WorkOutPolicePresence(CVector posn, float radius);
static void SetMaximumWantedLevel(int32 level);
};
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 0440a951..c6eb831c 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -646,7 +646,7 @@ CWorld::FindObjectsInRange(CVector &centre, float distance, bool ignoreZ, short
}
CEntity*
-CWorld::TestSphereAgainstWorld(CVector centre, float distance, CEntity* entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects)
+CWorld::TestSphereAgainstWorld(CVector centre, float distance, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects)
{
CEntity* foundE = nil;
diff --git a/src/core/World.h b/src/core/World.h
index e4f46589..6c52da5a 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -95,8 +95,8 @@ public:
static bool GetIsLineOfSightSectorClear(CSector &sector, const CColLine &line, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false);
static bool GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, bool ignoreSomeObjects = false);
- static CEntity* TestSphereAgainstWorld(CVector, float, CEntity*, bool, bool, bool, bool, bool, bool);
- static CEntity* TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool);
+ static CEntity *TestSphereAgainstWorld(CVector centre, float distance, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects);
+ static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool);
static void FindObjectsInRangeSectorList(CPtrList&, CVector&, float, bool, short*, short, CEntity**);
static void FindObjectsInRange(CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
static float FindGroundZForCoord(float x, float y);
diff --git a/src/core/common.h b/src/core/common.h
index 62cb2baa..36f67bfa 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -197,7 +197,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define ABS(a) (((a) < 0) ? (-a) : (a))
+#define ABS(a) (((a) < 0) ? (-(a)) : (a))
#define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min)))))
diff --git a/src/core/config.h b/src/core/config.h
index 52d1dab8..8eda6187 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -33,6 +33,12 @@ enum Config {
NUMTEMPOBJECTS = 30,
+ // Path data
+ NUM_PATHNODES = 4930,
+ NUM_CARPATHLINKS = 2076,
+ NUM_MAPOBJECTS = 1250,
+ NUM_PATHCONNECTIONS = 10260,
+
// Link list lengths
// TODO: alpha list
NUMCOLCACHELINKS = 200,
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 35b3cfa4..dc501075 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -14,7 +14,9 @@
#include "Streaming.h"
#include "PathFind.h"
#include "Boat.h"
+#include "Heli.h"
#include "Automobile.h"
+#include "Ped.h"
#include "debugmenu_public.h"
#include <vector>
@@ -138,6 +140,20 @@ SpawnCar(int id)
}
static void
+LetThemFollowYou(void) {
+ CPed* player = (CPed*) FindPlayerPed();
+ for (int i = 0; i < player->m_numNearPeds; i++) {
+
+ CPed* nearPed = player->m_nearPeds[i];
+ if (nearPed && !nearPed->IsPlayer()) {
+ nearPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, (void*)player);
+ nearPed->m_pedFormation = rand() & 7;
+ nearPed->bScriptObjectiveCompleted = false;
+ }
+ }
+}
+
+static void
FixCar(void)
{
CVehicle *veh = FindPlayerVehicle();
@@ -318,6 +334,12 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy);
DebugMenuAddCmd("Debug", "Place Car on Road", PlaceOnRoad);
+ DebugMenuAddVarBool8("Debug", "Catalina Heli On", (int8*)&CHeli::CatalinaHeliOn, nil);
+ DebugMenuAddCmd("Debug", "Catalina Fly By", CHeli::StartCatalinaFlyBy);
+ DebugMenuAddCmd("Debug", "Catalina Take Off", CHeli::CatalinaTakeOff);
+ DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway);
+ DebugMenuAddVarBool8("Debug", "Script Heli On", (int8*)0x95CD43, nil);
+
DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", (int8*)&gbShowPedRoadGroups, nil);
DebugMenuAddVarBool8("Debug", "Show Car Road Groups", (int8*)&gbShowCarRoadGroups, nil);
DebugMenuAddVarBool8("Debug", "Show Collision Lines", (int8*)&gbShowCollisionLines, nil);
@@ -328,6 +350,11 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil);
+ DebugMenuAddCmd("Debug", "Make peds around you follow you", LetThemFollowYou);
+#ifndef FINAL
+ DebugMenuAddVarBool8("Debug", "Toggle unused fight feature", (int8*)&CPed::bUnusedFightThingOnPlayer, nil);
+#endif
+
DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start);
DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop);
@@ -347,29 +374,6 @@ delayedPatches10(int a, int b)
}
*/
-void __declspec(naked) HeadlightsFix()
-{
- static const float fMinusOne = -1.0f;
- _asm
- {
- fld [esp+708h-690h]
- fcomp fMinusOne
- fnstsw ax
- and ah, 5
- cmp ah, 1
- jnz HeadlightsFix_DontLimit
- fld fMinusOne
- fstp [esp+708h-690h]
-
-HeadlightsFix_DontLimit:
- fld [esp+708h-690h]
- fabs
- fld st
- push 0x5382F2
- retn
- }
-}
-
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
@@ -454,10 +458,6 @@ patch()
InjectHook(0x475E00, printf, PATCH_JUMP); // _Error
- // stolen from silentpatch (sorry)
- Patch<WORD>(0x5382BF, 0x0EEB);
- InjectHook(0x5382EC, HeadlightsFix, PATCH_JUMP);
-
// InterceptCall(&open_script_orig, open_script, 0x438869);
// InterceptCall(&RsEventHandler_orig, delayedPatches10, 0x58275E);