summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFire-Head <Fire-Head@users.noreply.github.com>2020-12-19 20:33:17 +0100
committerFire-Head <Fire-Head@users.noreply.github.com>2020-12-19 20:33:17 +0100
commit0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3 (patch)
tree1661ba63db29b109ab9e759bc5b2d293eb0841de /src
parentscaling (diff)
parentanim fixes (diff)
downloadre3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar.gz
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar.bz2
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar.lz
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar.xz
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.tar.zst
re3-0bea6d039ba092a2c8677fdf52bf4fc6a6eeb3e3.zip
Diffstat (limited to '')
-rw-r--r--src/animation/AnimBlendHierarchy.cpp3
-rw-r--r--src/animation/AnimBlendHierarchy.h2
-rw-r--r--src/animation/AnimBlendSequence.cpp3
-rw-r--r--src/animation/AnimManager.cpp73
-rw-r--r--src/animation/RpAnimBlend.cpp3
-rw-r--r--src/audio/AudioLogic.cpp6
-rw-r--r--src/audio/AudioSamples.h2
-rw-r--r--src/audio/audio_enums.h2
-rw-r--r--src/audio/oal/oal_utils.cpp11
-rw-r--r--src/audio/oal/oal_utils.h7
-rw-r--r--src/audio/soundlist.h4
-rw-r--r--src/collision/Collision.cpp14
-rw-r--r--src/control/AutoPilot.cpp6
-rw-r--r--src/control/AutoPilot.h12
-rw-r--r--src/control/CarAI.cpp2
-rw-r--r--src/control/CarAI.h2
-rw-r--r--src/control/CarCtrl.cpp16
-rw-r--r--src/control/Garages.cpp10
-rw-r--r--src/control/Garages.h23
-rw-r--r--src/control/Phones.cpp6
-rw-r--r--src/control/Pickups.cpp2
-rw-r--r--src/control/Pickups.h4
-rw-r--r--src/control/Record.cpp10
-rw-r--r--src/control/Record.h2
-rw-r--r--src/control/Replay.cpp66
-rw-r--r--src/control/Replay.h5
-rw-r--r--src/control/RoadBlocks.cpp3
-rw-r--r--src/control/Script.cpp16
-rw-r--r--src/control/Script.h2
-rw-r--r--src/control/Script3.cpp8
-rw-r--r--src/control/Script4.cpp144
-rw-r--r--src/control/Script5.cpp143
-rw-r--r--src/control/Script6.cpp9
-rw-r--r--src/core/AnimViewer.cpp19
-rw-r--r--src/core/Cam.cpp144
-rw-r--r--src/core/FileLoader.cpp4
-rw-r--r--src/core/Fire.cpp10
-rw-r--r--src/core/Frontend.cpp717
-rw-r--r--src/core/Frontend.h17
-rw-r--r--src/core/Game.h3
-rw-r--r--src/core/MenuScreensCustom.cpp26
-rw-r--r--src/core/PlayerInfo.cpp642
-rw-r--r--src/core/PlayerInfo.h21
-rw-r--r--src/core/World.cpp115
-rw-r--r--src/core/World.h13
-rw-r--r--src/core/common.h8
-rw-r--r--src/core/config.h2
-rw-r--r--src/core/main.cpp83
-rw-r--r--src/core/main.h1
-rw-r--r--src/core/templates.h49
-rw-r--r--src/entities/Entity.h12
-rw-r--r--src/extras/screendroplets.cpp6
-rw-r--r--src/math/Quaternion.h5
-rw-r--r--src/math/Vector.h25
-rw-r--r--src/math/VuVector.h13
-rw-r--r--src/modelinfo/BaseModelInfo.h7
-rw-r--r--src/modelinfo/ModelInfo.cpp50
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp2
-rw-r--r--src/objects/Object.cpp44
-rw-r--r--src/peds/CivilianPed.cpp8
-rw-r--r--src/peds/CopPed.cpp15
-rw-r--r--src/peds/EmergencyPed.cpp30
-rw-r--r--src/peds/Ped.cpp101
-rw-r--r--src/peds/Ped.h21
-rw-r--r--src/peds/PedAI.cpp162
-rw-r--r--src/peds/PedFight.cpp20
-rw-r--r--src/peds/PedIK.cpp14
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PlayerPed.cpp165
-rw-r--r--src/peds/Population.cpp6
-rw-r--r--src/render/Clouds.cpp2
-rw-r--r--src/render/Coronas.cpp6
-rw-r--r--src/render/Fluff.cpp10
-rw-r--r--src/render/Particle.cpp4
-rw-r--r--src/render/PointLights.cpp4
-rw-r--r--src/render/Renderer.cpp4
-rw-r--r--src/render/WaterLevel.cpp455
-rw-r--r--src/render/WaterLevel.h13
-rw-r--r--src/render/Weather.cpp2
-rw-r--r--src/rw/VisibilityPlugins.cpp19
-rw-r--r--src/skel/crossplatform.h3
-rw-r--r--src/skel/glfw/glfw.cpp105
-rw-r--r--src/skel/skeleton.cpp5
-rw-r--r--src/skel/skeleton.h3
-rw-r--r--src/skel/win/win.cpp53
-rw-r--r--src/vehicles/Automobile.cpp16
-rw-r--r--src/vehicles/Automobile.h2
-rw-r--r--src/vehicles/Cranes.h8
-rw-r--r--src/vehicles/HandlingMgr.h2
-rw-r--r--src/vehicles/Vehicle.h8
-rw-r--r--src/weapons/Weapon.cpp4
91 files changed, 2172 insertions, 1759 deletions
diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp
index c7800de5..ea669999 100644
--- a/src/animation/AnimBlendHierarchy.cpp
+++ b/src/animation/AnimBlendHierarchy.cpp
@@ -52,8 +52,7 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void)
void
CAnimBlendHierarchy::RemoveAnimSequences(void)
{
- if(sequences)
- delete[] sequences;
+ delete[] sequences;
numSequences = 0;
}
diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h
index e35b4925..40d2731b 100644
--- a/src/animation/AnimBlendHierarchy.h
+++ b/src/animation/AnimBlendHierarchy.h
@@ -15,7 +15,7 @@ public:
char name[24];
CAnimBlendSequence *sequences;
int16 numSequences;
- int16 compressed; // not really used
+ int16 compressed;
float totalLength;
CLink<CAnimBlendHierarchy*> *linkPtr;
diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp
index c958b71a..2ae150c1 100644
--- a/src/animation/AnimBlendSequence.cpp
+++ b/src/animation/AnimBlendSequence.cpp
@@ -16,9 +16,10 @@ CAnimBlendSequence::CAnimBlendSequence(void)
CAnimBlendSequence::~CAnimBlendSequence(void)
{
- assert(keyFramesCompressed == nil);
if(keyFrames)
RwFree(keyFrames);
+ if(keyFramesCompressed)
+ RwFree(keyFramesCompressed);
}
void
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index 877dcd76..e701018e 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -841,54 +841,57 @@ CAnimManager::LoadAnimFile(int fd, bool compress)
ROUNDSIZE(anim.size);
CFileMgr::Read(fd, buf, anim.size);
int numFrames = *(int*)(buf+28);
+ seq->SetName(buf);
#ifdef PED_SKIN
if(anim.size == 44)
seq->SetBoneTag(*(int*)(buf+40));
#endif
- seq->SetName(buf);
if(numFrames == 0)
continue;
+ bool hasScale = false;
+ bool hasTranslation = false;
CFileMgr::Read(fd, (char*)&info, sizeof(info));
- if(strncmp(info.ident, "KR00", 4) == 0){
- seq->SetNumFrames(numFrames, false);
- KeyFrame *kf = seq->GetKeyFrame(0);
- for(l = 0; l < numFrames; l++, kf++){
- CFileMgr::Read(fd, buf, 0x14);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->deltaTime = fbuf[4]; // absolute time here
- }
- }else if(strncmp(info.ident, "KRT0", 4) == 0){
+ if(strncmp(info.ident, "KRTS", 4) == 0){
+ hasScale = true;
seq->SetNumFrames(numFrames, true);
- KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
- for(l = 0; l < numFrames; l++, kf++){
- CFileMgr::Read(fd, buf, 0x20);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->translation.x = fbuf[4];
- kf->translation.y = fbuf[5];
- kf->translation.z = fbuf[6];
- kf->deltaTime = fbuf[7]; // absolute time here
- }
- }else if(strncmp(info.ident, "KRTS", 4) == 0){
+ }else if(strncmp(info.ident, "KRT0", 4) == 0){
+ hasTranslation = true;
seq->SetNumFrames(numFrames, true);
- KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
- for(l = 0; l < numFrames; l++, kf++){
+ }else if(strncmp(info.ident, "KR00", 4) == 0){
+ seq->SetNumFrames(numFrames, false);
+ }
+
+ for(l = 0; l < numFrames; l++){
+ if(hasScale){
CFileMgr::Read(fd, buf, 0x2C);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->translation.x = fbuf[4];
- kf->translation.y = fbuf[5];
- kf->translation.z = fbuf[6];
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+ CVector trans(fbuf[4], fbuf[5], fbuf[6]);
+
+ KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->translation = trans;
// scaling ignored
kf->deltaTime = fbuf[10]; // absolute time here
+ }else if(hasTranslation){
+ CFileMgr::Read(fd, buf, 0x20);
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+ CVector trans(fbuf[4], fbuf[5], fbuf[6]);
+
+ KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->translation = trans;
+ kf->deltaTime = fbuf[7]; // absolute time here
+ }else{
+ CFileMgr::Read(fd, buf, 0x14);
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+
+ KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->deltaTime = fbuf[4]; // absolute time here
}
}
diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp
index dcb656ee..e430e52a 100644
--- a/src/animation/RpAnimBlend.cpp
+++ b/src/animation/RpAnimBlend.cpp
@@ -8,6 +8,7 @@
#include "AnimBlendClumpData.h"
#include "AnimBlendHierarchy.h"
#include "AnimBlendAssociation.h"
+#include "AnimManager.h"
#include "RpAnimBlend.h"
#ifdef PED_SKIN
#include "PedModelInfo.h"
@@ -441,7 +442,7 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta)
next = link->next;
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link);
if(assoc->UpdateBlend(timeDelta)){
- // CAnimManager::UncompressAnimation(v6->hierarchy)
+ CAnimManager::UncompressAnimation(assoc->hierarchy);
updateData.nodes[i++] = assoc->GetNode(0);
if(assoc->flags & ASSOC_MOVEMENT){
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount;
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 7340e73e..ca395136 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -52,8 +52,8 @@ uint32 gHomeNextTime;
uint32 gCellNextTime;
uint32 gNextCryTime;
-enum PLAY_STATUS : uint8 { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED };
-enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED };
+enum PLAY_STATUS { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED };
+enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED };
void
cAudioManager::PreInitialiseGameSpecificSetup() const
@@ -8121,7 +8121,7 @@ cAudioManager::ProcessGarages()
const float SOUND_INTENSITY = 80.0f;
CEntity *entity;
- eGarageState state;
+ uint8 state;
uint32 sampleIndex;
uint8 j;
float distSquared;
diff --git a/src/audio/AudioSamples.h b/src/audio/AudioSamples.h
index e2721888..df64521c 100644
--- a/src/audio/AudioSamples.h
+++ b/src/audio/AudioSamples.h
@@ -2,7 +2,7 @@
#include "common.h"
-enum eSfxSample : uint32
+enum eSfxSample
{
SFX_CAR_HORN_JEEP = 0,
SFX_CAR_HORN_BMW328,
diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h
index 20760859..8c6d35aa 100644
--- a/src/audio/audio_enums.h
+++ b/src/audio/audio_enums.h
@@ -235,7 +235,7 @@ enum AudioEntityHandle {
AEHANDLE_ERROR_BADAUDIOTYPE = -1,
};
-enum eAudioType : int32
+enum eAudioType
{
AUDIOTYPE_PHYSICAL = 0,
AUDIOTYPE_EXPLOSION,
diff --git a/src/audio/oal/oal_utils.cpp b/src/audio/oal/oal_utils.cpp
index e16de572..e4cb0b77 100644
--- a/src/audio/oal/oal_utils.cpp
+++ b/src/audio/oal/oal_utils.cpp
@@ -3,6 +3,14 @@
#ifdef AUDIO_OAL
+/*
+ * When linking to a static openal-soft library,
+ * the extension function inside the openal library conflict with the variables here.
+ * Therefore declare these re3 owned symbols in a private namespace.
+ */
+
+namespace re3_openal {
+
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
@@ -37,6 +45,9 @@ LPALGETFILTERIV alGetFilteriv;
LPALGETFILTERF alGetFilterf;
LPALGETFILTERFV alGetFilterfv;
+}
+
+using namespace re3_openal;
void EFXInit()
{
diff --git a/src/audio/oal/oal_utils.h b/src/audio/oal/oal_utils.h
index b89ccf36..f0fa090a 100644
--- a/src/audio/oal/oal_utils.h
+++ b/src/audio/oal/oal_utils.h
@@ -11,6 +11,8 @@ void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props);
void EAX3_SetReverbMix(ALuint filter, float mix);
void SetEffectsLevel(ALuint uiFilter, float level);
+namespace re3_openal {
+
extern LPALGENEFFECTS alGenEffects;
extern LPALDELETEEFFECTS alDeleteEffects;
extern LPALISEFFECT alIsEffect;
@@ -44,4 +46,9 @@ extern LPALGETFILTERI alGetFilteri;
extern LPALGETFILTERIV alGetFilteriv;
extern LPALGETFILTERF alGetFilterf;
extern LPALGETFILTERFV alGetFilterfv;
+
+}
+
+using namespace re3_openal;
+
#endif
diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h
index 225ed56e..7c3b30a7 100644
--- a/src/audio/soundlist.h
+++ b/src/audio/soundlist.h
@@ -1,6 +1,6 @@
#pragma once
-enum eSound : uint16
+enum eSound
{
SOUND_CAR_DOOR_CLOSE_BONNET = 0,
SOUND_CAR_DOOR_CLOSE_BUMPER,
@@ -173,7 +173,7 @@ enum eSound : uint16
};
-enum eScriptSounds : uint16 {
+enum eScriptSounds {
SCRIPT_SOUND_0 = 0,
SCRIPT_SOUND_1,
SCRIPT_SOUND_2,
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp
index 41997e32..7fb5c30b 100644
--- a/src/collision/Collision.cpp
+++ b/src/collision/Collision.cpp
@@ -665,7 +665,7 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod
// transform line to model space
Invert(matrix, matTransform);
CVuVector newline[2];
- TransformPoints(newline, 2, matTransform, (RwV3d*)&line.p0, sizeof(CColLine)/2);
+ TransformPoints(newline, 2, matTransform, &line.p0, sizeof(CColLine)/2);
// If we don't intersect with the bounding box, no chance on the rest
if(!TestLineBox(*(CColLine*)newline, model.boundingBox))
@@ -1474,7 +1474,7 @@ CCollision::ProcessLineOfSight(const CColLine &line,
// transform line to model space
Invert(matrix, matTransform);
CVuVector newline[2];
- TransformPoints(newline, 2, matTransform, (RwV3d*)&line.p0, sizeof(CColLine)/2);
+ TransformPoints(newline, 2, matTransform, &line.p0, sizeof(CColLine)/2);
if(mindist < 1.0f)
newline[1] = newline[0] + (newline[1] - newline[0])*mindist;
@@ -1606,7 +1606,7 @@ CCollision::ProcessVerticalLine(const CColLine &line,
// transform line to model space
Invert(matrix, matTransform);
CVuVector newline[2];
- TransformPoints(newline, 2, matTransform, (RwV3d*)&line.p0, sizeof(CColLine)/2);
+ TransformPoints(newline, 2, matTransform, &line.p0, sizeof(CColLine)/2);
if(mindist < 1.0f)
newline[1] = newline[0] + (newline[1] - newline[0])*mindist;
@@ -1806,16 +1806,16 @@ CCollision::ProcessColModels(const CMatrix &matrixA, CColModel &modelA,
matAB *= matrixA;
CVuVector bsphereAB; // bounding sphere of A in B space
- TransformPoint(bsphereAB, matAB, *(RwV3d*)modelA.boundingSphere.center); // inlined
+ TransformPoint(bsphereAB, matAB, modelA.boundingSphere.center); // inlined
bsphereAB.w = modelA.boundingSphere.radius;
if(!TestSphereBox(*(CColSphere*)&bsphereAB, modelB.boundingBox))
return 0;
// transform modelA's spheres and lines to B space
- TransformPoints(aSpheresA, modelA.numSpheres, matAB, (RwV3d*)&modelA.spheres->center, sizeof(CColSphere));
+ TransformPoints(aSpheresA, modelA.numSpheres, matAB, &modelA.spheres->center, sizeof(CColSphere));
for(i = 0; i < modelA.numSpheres; i++)
aSpheresA[i].w = modelA.spheres[i].radius;
- TransformPoints(aLinesA, modelA.numLines*2, matAB, (RwV3d*)&modelA.lines->p0, sizeof(CColLine)/2);
+ TransformPoints(aLinesA, modelA.numLines*2, matAB, &modelA.lines->p0, sizeof(CColLine)/2);
// Test them against model B's bounding volumes
int numSpheresA = 0;
@@ -1832,7 +1832,7 @@ CCollision::ProcessColModels(const CMatrix &matrixA, CColModel &modelA,
matBA *= matrixB;
// transform modelB's spheres to A space
- TransformPoints(aSpheresB, modelB.numSpheres, matBA, (RwV3d*)&modelB.spheres->center, sizeof(CColSphere));
+ TransformPoints(aSpheresB, modelB.numSpheres, matBA, &modelB.spheres->center, sizeof(CColSphere));
for(i = 0; i < modelB.numSpheres; i++)
aSpheresB[i].w = modelB.spheres[i].radius;
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp
index b1fce95f..4038c93e 100644
--- a/src/control/AutoPilot.cpp
+++ b/src/control/AutoPilot.cpp
@@ -103,9 +103,9 @@ void CAutoPilot::Load(uint8*& buf)
m_nNextDirection = ReadSaveBuf<int8>(buf);
m_nCurrentLane = ReadSaveBuf<int8>(buf);
m_nNextLane = ReadSaveBuf<int8>(buf);
- m_nDrivingStyle = (eCarDrivingStyle)ReadSaveBuf<uint8>(buf);
- m_nCarMission = (eCarMission)ReadSaveBuf<uint8>(buf);
- m_nTempAction = (eCarTempAction)ReadSaveBuf<uint8>(buf);
+ m_nDrivingStyle = ReadSaveBuf<uint8>(buf);
+ m_nCarMission = ReadSaveBuf<uint8>(buf);
+ m_nTempAction = ReadSaveBuf<uint8>(buf);
m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);
diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h
index 337a93c1..6349fce6 100644
--- a/src/control/AutoPilot.h
+++ b/src/control/AutoPilot.h
@@ -4,7 +4,7 @@
class CVehicle;
struct CPathNode;
-enum eCarMission : uint8
+enum eCarMission
{
MISSION_NONE,
MISSION_CRUISE,
@@ -28,7 +28,7 @@ enum eCarMission : uint8
MISSION_BLOCKCAR_HANDBRAKESTOP,
};
-enum eCarTempAction : uint8
+enum eCarTempAction
{
TEMPACT_NONE,
TEMPACT_WAIT,
@@ -43,7 +43,7 @@ enum eCarTempAction : uint8
TEMPACT_SWERVERIGHT
};
-enum eCarDrivingStyle : uint8
+enum eCarDrivingStyle
{
DRIVINGSTYLE_STOP_FOR_CARS,
DRIVINGSTYLE_SLOW_DOWN_FOR_CARS,
@@ -69,9 +69,9 @@ public:
int8 m_nNextDirection;
int8 m_nCurrentLane;
int8 m_nNextLane;
- eCarDrivingStyle m_nDrivingStyle;
- eCarMission m_nCarMission;
- eCarTempAction m_nTempAction;
+ uint8 m_nDrivingStyle;
+ uint8 m_nCarMission;
+ uint8 m_nTempAction;
uint32 m_nTimeTempAction;
float m_fMaxTrafficSpeed;
uint8 m_nCruiseSpeed;
diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp
index ab44510d..8c0c5966 100644
--- a/src/control/CarAI.cpp
+++ b/src/control/CarAI.cpp
@@ -539,7 +539,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
}
-eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
+uint8 CCarAI::FindPoliceCarMissionForWantedLevel()
{
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
case 0:
diff --git a/src/control/CarAI.h b/src/control/CarAI.h
index e88807c8..9b731ad5 100644
--- a/src/control/CarAI.h
+++ b/src/control/CarAI.h
@@ -19,7 +19,7 @@ public:
static void TellOccupantsToLeaveCar(CVehicle*);
static void TellCarToRamOtherCar(CVehicle*, CVehicle*);
static void TellCarToBlockOtherCar(CVehicle*, CVehicle*);
- static eCarMission FindPoliceCarMissionForWantedLevel();
+ static uint8 FindPoliceCarMissionForWantedLevel();
static int32 FindPoliceCarSpeedForWantedLevel(CVehicle*);
static void MellowOutChaseSpeed(CVehicle*);
static void MakeWayForCarWithSiren(CVehicle *veh);
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index 627d7bad..cb4229eb 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -408,11 +408,6 @@ CCarCtrl::GenerateOneRandomCar()
float directionNextLinkX;
float directionNextLinkY;
if (positionBetweenNodes < 0.5f) {
- float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
- float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
- float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
- float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
-
pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
positionOnCurrentLinkIncludingLane = CVector(
@@ -442,11 +437,6 @@ CCarCtrl::GenerateOneRandomCar()
pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(uint32)((positionBetweenNodes - 0.5f) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
- float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
- float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
- float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
- float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
-
pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
positionOnCurrentLinkIncludingLane = CVector(
@@ -2348,7 +2338,11 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
switch (pVehicle->AutoPilot.m_nDrivingStyle) {
case DRIVINGSTYLE_STOP_FOR_CARS:
case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS:
- speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed;
+ speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle);
+#ifdef FIX_BUGS
+ if (pVehicle->AutoPilot.m_nCruiseSpeed != 0)
+#endif
+ speedStyleMultiplier /= pVehicle->AutoPilot.m_nCruiseSpeed;
break;
default:
speedStyleMultiplier = 1.0f;
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index c70d9592..418195c7 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -179,10 +179,8 @@ void CGarages::Shutdown(void)
void CGarages::Update(void)
{
static int GarageToBeTidied = 0;
-#ifndef GTA_PS2
if (CReplay::IsPlayingBack())
return;
-#endif
bCamShouldBeOutisde = false;
TheCamera.pToGarageWeAreIn = nil;
TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = nil;
@@ -202,7 +200,7 @@ void CGarages::Update(void)
aGarages[GarageToBeTidied].TidyUpGarage();
}
-int16 CGarages::AddOne(CVector p1, CVector p2, eGarageType type, int32 targetId)
+int16 CGarages::AddOne(CVector p1, CVector p2, uint8 type, int32 targetId)
{
if (NumGarages >= NUM_GARAGES) {
assert(0);
@@ -285,7 +283,7 @@ int16 CGarages::AddOne(CVector p1, CVector p2, eGarageType type, int32 targetId)
return NumGarages++;
}
-void CGarages::ChangeGarageType(int16 garage, eGarageType type, int32 mi)
+void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi)
{
CGarage* pGarage = &aGarages[garage];
pGarage->m_eGarageType = type;
@@ -2198,7 +2196,7 @@ void CGarages::CloseHideOutGaragesBeforeSave()
}
}
-int32 CGarages::CountCarsInHideoutGarage(eGarageType type)
+int32 CGarages::CountCarsInHideoutGarage(uint8 type)
{
int32 total = 0;
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
@@ -2218,7 +2216,7 @@ int32 CGarages::CountCarsInHideoutGarage(eGarageType type)
return total;
}
-int32 CGarages::FindMaxNumStoredCarsForGarage(eGarageType type)
+int32 CGarages::FindMaxNumStoredCarsForGarage(uint8 type)
{
switch (type) {
case GARAGE_HIDEOUT_ONE:
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 41b2afb7..34b74fb6 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -7,7 +7,7 @@
class CVehicle;
class CCamera;
-enum eGarageState : int8
+enum eGarageState
{
GS_FULLYCLOSED,
GS_OPENED,
@@ -18,7 +18,7 @@ enum eGarageState : int8
GS_AFTERDROPOFF,
};
-enum eGarageType : int8
+enum eGarageType
{
GARAGE_NONE,
GARAGE_MISSION,
@@ -81,8 +81,8 @@ VALIDATE_SIZE(CStoredCar, 0x28);
class CGarage
{
- eGarageType m_eGarageType;
- eGarageState m_eGarageState;
+ uint8 m_eGarageType;
+ uint8 m_eGarageState;
bool field_2; // unused
bool m_bClosingWithoutTargetCar;
bool m_bDeactivated;
@@ -207,8 +207,8 @@ public:
#endif
static void Update(void);
- static int16 AddOne(CVector pos1, CVector pos2, eGarageType type, int32 targetId);
- static void ChangeGarageType(int16, eGarageType, int32);
+ static int16 AddOne(CVector pos1, CVector pos2, uint8 type, int32 targetId);
+ static void ChangeGarageType(int16, uint8, int32);
static void PrintMessages(void);
static void TriggerMessage(const char* text, int16, uint16 time, int16);
static void SetTargetCarForMissonGarage(int16, CVehicle*);
@@ -244,11 +244,14 @@ private:
static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32);
static void CloseHideOutGaragesBeforeSave(void);
- static int32 CountCarsInHideoutGarage(eGarageType);
- static int32 FindMaxNumStoredCarsForGarage(eGarageType);
- static int32 GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
- static int32 GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; }
+ static int32 CountCarsInHideoutGarage(uint8);
+ static int32 FindMaxNumStoredCarsForGarage(uint8);
+ static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; }
+ static int32 GetCarsCollectedIndexForGarageType(uint8 type) { return type - GARAGE_COLLECTCARS_1; }
friend class cAudioManager;
friend class CGarage;
+#ifdef FIX_BUGS
+ friend class CReplay;
+#endif
};
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index c951e868..4769559c 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -67,7 +67,7 @@ CPhoneInfo::Update(void)
} else {
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE);
if (player->m_nPedState == PED_MAKE_CALL)
- player->m_nPedState = PED_IDLE;
+ player->SetPedState(PED_IDLE);
}
}
bool notInCar;
@@ -114,7 +114,7 @@ CPhoneInfo::Update(void)
player->m_fRotationCur = angleToFace;
player->m_fRotationDest = angleToFace;
player->SetHeading(angleToFace);
- player->m_nPedState = PED_MAKE_CALL;
+ player->SetPedState(PED_MAKE_CALL);
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PHONE);
TheCamera.SetWideScreenOn();
playerInfo->MakePlayerSafe(true);
@@ -412,7 +412,7 @@ PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg)
ped->bUpdateAnimHeading = true;
if (ped->m_nPedState == PED_MAKE_CALL)
- ped->m_nPedState = PED_IDLE;
+ ped->SetPedState(PED_IDLE);
}
void
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index a6166554..857f74ec 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -535,7 +535,7 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan
if (slot >= NUMPICKUPS) return -1;
- aPickUps[slot].m_eType = (ePickupType)type;
+ aPickUps[slot].m_eType = type;
aPickUps[slot].m_bRemoved = false;
aPickUps[slot].m_nQuantity = quantity;
if (type == PICKUP_ONCE_TIMEOUT)
diff --git a/src/control/Pickups.h b/src/control/Pickups.h
index 95eb6fbf..72a37d99 100644
--- a/src/control/Pickups.h
+++ b/src/control/Pickups.h
@@ -1,7 +1,7 @@
#pragma once
#include "Weapon.h"
-enum ePickupType : uint8
+enum ePickupType
{
PICKUP_NONE = 0,
PICKUP_IN_SHOP,
@@ -29,7 +29,7 @@ class CPlayerPed;
class CPickup
{
public:
- ePickupType m_eType;
+ uint8 m_eType;
bool m_bRemoved;
uint16 m_nQuantity;
CObject *m_pObject;
diff --git a/src/control/Record.cpp b/src/control/Record.cpp
index 8a23ffde..7f636ec2 100644
--- a/src/control/Record.cpp
+++ b/src/control/Record.cpp
@@ -391,15 +391,17 @@ void CRecordDataForChase::ProcessControlCars(void)
}
}
-#if (defined(GTA_PS2) || defined(FIX_BUGS))
bool CRecordDataForChase::ShouldThisPadBeLeftAlone(uint8 pad)
{
// may be wrong
- if (Status == STATE_NONE || Status == STATE_PLAYBACK)
+ if (Status == STATE_PLAYBACK_INIT) // this is useless but ps2 def checks if it's STATE_PLAYBACK_INIT
return false;
- return pad != 0;
+
+ if (Status == STATE_RECORD)
+ return pad != 0;
+
+ return false;
}
-#endif
void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomobile** ppCar, uint8 colour1, uint8 colour2)
{
diff --git a/src/control/Record.h b/src/control/Record.h
index 8b55b1f4..6a94c408 100644
--- a/src/control/Record.h
+++ b/src/control/Record.h
@@ -57,9 +57,7 @@ public:
static void RestoreInfoForMatrix(CMatrix&, CCarStateEachFrame*);
static void RestoreInfoForCar(CAutomobile*, CCarStateEachFrame*, bool);
static void ProcessControlCars(void);
-#if (defined(GTA_PS2) || defined(FIX_BUGS))
static bool ShouldThisPadBeLeftAlone(uint8 pad);
-#endif
static void GiveUsACar(int32, CVector, float, CAutomobile**, uint8, uint8);
static void StartChaseScene(float);
static void CleanUpChaseScene(void);
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 071ca2b3..05880162 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -10,6 +10,10 @@
#include "DMAudio.h"
#include "Draw.h"
#include "FileMgr.h"
+#ifdef FIX_BUGS
+#include "Fire.h"
+#include "Garages.h"
+#endif
#include "Heli.h"
#include "main.h"
#include "Matrix.h"
@@ -22,6 +26,10 @@
#include "Plane.h"
#include "Pools.h"
#include "Population.h"
+#ifdef FIX_BUGS
+#include "Projectile.h"
+#include "ProjectileInfo.h"
+#endif
#include "Replay.h"
#include "References.h"
#include "Pools.h"
@@ -102,6 +110,11 @@ float CReplay::fDistanceLookAroundCam;
float CReplay::fBetaAngleLookAroundCam;
float CReplay::fAlphaAngleLookAroundCam;
#ifdef FIX_BUGS
+uint8* CReplay::pGarages;
+CFire* CReplay::FireArray;
+uint32 CReplay::NumOfFires;
+uint8* CReplay::paProjectileInfo;
+uint8* CReplay::paProjectiles;
int CReplay::nHandleOfPlayerPed[NUMPLAYERS];
#endif
@@ -1025,10 +1038,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
break;
}
case REPLAYCAMMODE_FIXED:
@@ -1044,10 +1057,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetMatrix().GetUp() = up;
TheCamera.GetMatrix().GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
+ pm->pos = TheCamera.GetMatrix().GetPosition();
+ pm->at = TheCamera.GetMatrix().GetForward();
+ pm->up = TheCamera.GetMatrix().GetUp();
+ pm->right = TheCamera.GetMatrix().GetRight();
break;
}
default:
@@ -1156,6 +1169,17 @@ void CReplay::StoreStuffInMem(void)
if (ped)
StoreDetailedPedAnimation(ped, &pPedAnims[i]);
}
+#ifdef FIX_BUGS
+ pGarages = new uint8[sizeof(CGarages::aGarages)];
+ memcpy(pGarages, CGarages::aGarages, sizeof(CGarages::aGarages));
+ FireArray = new CFire[NUM_FIRES];
+ memcpy(FireArray, gFireManager.m_aFires, sizeof(gFireManager.m_aFires));
+ NumOfFires = gFireManager.m_nTotalFires;
+ paProjectileInfo = new uint8[sizeof(gaProjectileInfo)];
+ memcpy(paProjectileInfo, gaProjectileInfo, sizeof(gaProjectileInfo));
+ paProjectiles = new uint8[sizeof(CProjectileInfo::ms_apProjectile)];
+ memcpy(paProjectiles, CProjectileInfo::ms_apProjectile, sizeof(CProjectileInfo::ms_apProjectile));
+#endif
}
void CReplay::RestoreStuffFromMem(void)
@@ -1206,7 +1230,7 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_rwObject = nil;
ped->m_modelIndex = -1;
ped->SetModelIndex(mi);
- ped->m_pVehicleAnim = 0;
+ ped->m_pVehicleAnim = nil;
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
@@ -1322,6 +1346,22 @@ void CReplay::RestoreStuffFromMem(void)
}
delete[] pPedAnims;
pPedAnims = nil;
+#ifdef FIX_BUGS
+ memcpy(CGarages::aGarages, pGarages, sizeof(CGarages::aGarages));
+ delete[] pGarages;
+ pGarages = nil;
+ memcpy(gFireManager.m_aFires, FireArray, sizeof(gFireManager.m_aFires));
+ delete[] FireArray;
+ FireArray = nil;
+ gFireManager.m_nTotalFires = NumOfFires;
+ memcpy(gaProjectileInfo, paProjectileInfo, sizeof(gaProjectileInfo));
+ delete[] paProjectileInfo;
+ paProjectileInfo = nil;
+ memcpy(CProjectileInfo::ms_apProjectile, paProjectiles, sizeof(CProjectileInfo::ms_apProjectile));
+ delete[] paProjectiles;
+ paProjectiles = nil;
+ //CExplosion::ClearAllExplosions(); not in III
+#endif
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.SetRadioInCar(OldRadioStation);
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
@@ -1541,10 +1581,10 @@ void CReplay::ProcessLookAroundCam(void)
TheCamera.GetRight() = right;
TheCamera.SetPosition(camera_pt);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
diff --git a/src/control/Replay.h b/src/control/Replay.h
index cb58a602..aa2ecd86 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -275,6 +275,11 @@ private:
static float fAlphaAngleLookAroundCam;
static float fBetaAngleLookAroundCam;
#ifdef FIX_BUGS
+ static uint8* pGarages;
+ static CFire* FireArray;
+ static uint32 NumOfFires;
+ static uint8* paProjectileInfo;
+ static uint8* paProjectiles;
static int nHandleOfPlayerPed[NUMPLAYERS];
#endif
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index 1496b307..170c5ff8 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -90,8 +90,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
pCopPed->m_nRoadblockNode = roadBlockNode;
pCopPed->bCrouchWhenShooting = roadBlockType != 2;
if (pEntityToAttack) {
- pCopPed->m_pPointGunAt = pEntityToAttack;
- pEntityToAttack->RegisterReference(&pCopPed->m_pPointGunAt);
+ pCopPed->SetWeaponLockOnTarget(pEntityToAttack);
pCopPed->SetAttack(pEntityToAttack);
}
pCopPed->m_pMyVehicle = pVehicle;
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index dbd477e2..67d2e618 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -238,12 +238,12 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="),
REGISTER_COMMAND(COMMAND_DIV_INT_LVAR_BY_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="),
REGISTER_COMMAND(COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
- REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
+ REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +=@"),
REGISTER_COMMAND(COMMAND_SUB_TIMED_VAL_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
REGISTER_COMMAND(COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
REGISTER_COMMAND(COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"),
@@ -3593,7 +3593,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
CollectParameters(&m_nIp, 2);
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(car);
- car->AutoPilot.m_nDrivingStyle = (eCarDrivingStyle)ScriptParams[1];
+ car->AutoPilot.m_nDrivingStyle = (uint8)ScriptParams[1];
return 0;
}
case COMMAND_SET_CAR_MISSION:
@@ -3601,7 +3601,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
CollectParameters(&m_nIp, 2);
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(car);
- car->AutoPilot.m_nCarMission = (eCarMission)ScriptParams[1];
+ car->AutoPilot.m_nCarMission = (uint8)ScriptParams[1];
car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
car->bEngineOn = true;
return 0;
diff --git a/src/control/Script.h b/src/control/Script.h
index 12f3233f..7fc18727 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -396,7 +396,7 @@ private:
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
-#ifdef FIX_BUGS
+#ifdef MISSION_REPLAY
friend void RetryMission(int, int);
#endif
diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp
index 23ab453c..1f1ed537 100644
--- a/src/control/Script3.cpp
+++ b/src/control/Script3.cpp
@@ -291,7 +291,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
infZ = *(float*)&ScriptParams[5];
supZ = *(float*)&ScriptParams[2];
}
- ScriptParams[0] = CGarages::AddOne(CVector(infX, infY, infZ), CVector(supX, supY, supZ), (eGarageType)ScriptParams[6], 0);
+ ScriptParams[0] = CGarages::AddOne(CVector(infX, infY, infZ), CVector(supX, supY, supZ), ScriptParams[6], 0);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -316,7 +316,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
infZ = *(float*)&ScriptParams[5];
supZ = *(float*)&ScriptParams[2];
}
- ScriptParams[0] = CGarages::AddOne(CVector(infX, infY, infZ), CVector(supX, supY, supZ), (eGarageType)ScriptParams[6], ScriptParams[7]);
+ ScriptParams[0] = CGarages::AddOne(CVector(infX, infY, infZ), CVector(supX, supY, supZ), ScriptParams[6], ScriptParams[7]);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -996,7 +996,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
CollectParameters(&m_nIp, 4);
int mi = ScriptParams[0] >= 0 ? ScriptParams[0] : CTheScripts::UsedObjectArray[-ScriptParams[0]].index;
CObject* pObj = new CObject(mi, false);
-; pObj->ObjectCreatedBy = MISSION_OBJECT;
+ pObj->ObjectCreatedBy = MISSION_OBJECT;
CVector pos = *(CVector*)&ScriptParams[1];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
@@ -1826,7 +1826,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
}
case COMMAND_CHANGE_GARAGE_TYPE:
CollectParameters(&m_nIp, 2);
- CGarages::ChangeGarageType(ScriptParams[0], (eGarageType)ScriptParams[1], 0);
+ CGarages::ChangeGarageType(ScriptParams[0], ScriptParams[1], 0);
return 0;
case COMMAND_ACTIVATE_CRUSHER_CRANE:
{
diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp
index 78da2d96..afd6eba4 100644
--- a/src/control/Script4.cpp
+++ b/src/control/Script4.cpp
@@ -1436,7 +1436,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
- pVehicle->SetStatus((eEntityStatus)ScriptParams[1]);
+ pVehicle->SetStatus(ScriptParams[1]);
return 0;
}
case COMMAND_IS_CHAR_MALE:
@@ -1459,7 +1459,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case COMMAND_CHANGE_GARAGE_TYPE_WITH_CAR_MODEL:
{
CollectParameters(&m_nIp, 3);
- CGarages::ChangeGarageType(ScriptParams[0], (eGarageType)ScriptParams[1], ScriptParams[2]);
+ CGarages::ChangeGarageType(ScriptParams[0], ScriptParams[1], ScriptParams[2]);
return 0;
}
case COMMAND_FIND_DRUG_PLANE_COORDINATES:
@@ -2025,3 +2025,143 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
}
return -1;
}
+
+int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index)
+{
+ if (ScriptSphereArray[index].m_Index >= UINT16_MAX - 1)
+ ScriptSphereArray[index].m_Index = 1;
+ else
+ ScriptSphereArray[index].m_Index++;
+ return (uint16)index | ScriptSphereArray[index].m_Index << 16;
+}
+
+int32 CTheScripts::GetActualScriptSphereIndex(int32 index)
+{
+ if (index == -1)
+ return -1;
+ uint16 check = (uint32)index >> 16;
+ uint16 array_idx = index & (0xFFFF);
+ script_assert(array_idx < ARRAY_SIZE(ScriptSphereArray));
+ if (check != ScriptSphereArray[array_idx].m_Index)
+ return -1;
+ return array_idx;
+}
+
+void CTheScripts::DrawScriptSpheres()
+{
+ for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
+ if (ScriptSphereArray[i].m_bInUse)
+ C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, MARKERTYPE_CYLINDER, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius,
+ SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0);
+ }
+}
+
+int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius)
+{
+ int16 i = 0;
+ for (i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
+ if (!ScriptSphereArray[i].m_bInUse)
+ break;
+ }
+#ifdef FIX_BUGS
+ if (i == MAX_NUM_SCRIPT_SPHERES)
+ return -1;
+#endif
+ ScriptSphereArray[i].m_bInUse = true;
+ ScriptSphereArray[i].m_Id = id;
+ ScriptSphereArray[i].m_vecCenter = pos;
+ ScriptSphereArray[i].m_fRadius = radius;
+ return GetNewUniqueScriptSphereIndex(i);
+}
+
+void CTheScripts::RemoveScriptSphere(int32 index)
+{
+ index = GetActualScriptSphereIndex(index);
+ if (index == -1)
+ return;
+ ScriptSphereArray[index].m_bInUse = false;
+ ScriptSphereArray[index].m_Id = 0;
+}
+
+void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model)
+{
+ int i = 0;
+ bool found = false;
+ while (i < MAX_NUM_BUILDING_SWAPS && !found) {
+ if (BuildingSwapArray[i].m_pBuilding == pBuilding)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ if (BuildingSwapArray[i].m_nOldModel == new_model) {
+ BuildingSwapArray[i].m_pBuilding = nil;
+ BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
+ }
+ else {
+ BuildingSwapArray[i].m_nNewModel = new_model;
+ }
+ }
+ else {
+ i = 0;
+ while (i < MAX_NUM_BUILDING_SWAPS && !found) {
+ if (BuildingSwapArray[i].m_pBuilding == nil)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ BuildingSwapArray[i].m_pBuilding = pBuilding;
+ BuildingSwapArray[i].m_nNewModel = new_model;
+ BuildingSwapArray[i].m_nOldModel = old_model;
+ }
+ }
+}
+
+void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove)
+{
+ int i = 0;
+ bool found = false;
+ while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
+ if (InvisibilitySettingArray[i] == pEntity)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ if (remove)
+ InvisibilitySettingArray[i] = nil;
+ }
+ else if (!remove) {
+ i = 0;
+ while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
+ if (InvisibilitySettingArray[i] == nil)
+ found = true;
+ else
+ i++;
+ }
+ if (found)
+ InvisibilitySettingArray[i] = pEntity;
+ }
+}
+
+void CTheScripts::UndoBuildingSwaps()
+{
+ for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
+ if (BuildingSwapArray[i].m_pBuilding) {
+ BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nOldModel);
+ BuildingSwapArray[i].m_pBuilding = nil;
+ BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
+ }
+ }
+}
+
+void CTheScripts::UndoEntityInvisibilitySettings()
+{
+ for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
+ if (InvisibilitySettingArray[i]) {
+ InvisibilitySettingArray[i]->bIsVisible = true;
+ InvisibilitySettingArray[i] = nil;
+ }
+ }
+}
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index 164ca036..153f2393 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -17,147 +17,6 @@
#include "World.h"
#include "main.h"
-int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index)
-{
- if (ScriptSphereArray[index].m_Index >= UINT16_MAX - 1)
- ScriptSphereArray[index].m_Index = 1;
- else
- ScriptSphereArray[index].m_Index++;
- return (uint16)index | ScriptSphereArray[index].m_Index << 16;
-}
-
-int32 CTheScripts::GetActualScriptSphereIndex(int32 index)
-{
- if (index == -1)
- return -1;
- uint16 check = (uint32)index >> 16;
- uint16 array_idx = index & (0xFFFF);
- script_assert(array_idx < ARRAY_SIZE(ScriptSphereArray));
- if (check != ScriptSphereArray[array_idx].m_Index)
- return -1;
- return array_idx;
-}
-
-void CTheScripts::DrawScriptSpheres()
-{
- for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
- if (ScriptSphereArray[i].m_bInUse)
- C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, MARKERTYPE_CYLINDER, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius,
- SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0);
- }
-}
-
-int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius)
-{
- int16 i = 0;
- for (i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
- if (!ScriptSphereArray[i].m_bInUse)
- break;
- }
-#ifdef FIX_BUGS
- if (i == MAX_NUM_SCRIPT_SPHERES)
- return -1;
-#endif
- ScriptSphereArray[i].m_bInUse = true;
- ScriptSphereArray[i].m_Id = id;
- ScriptSphereArray[i].m_vecCenter = pos;
- ScriptSphereArray[i].m_fRadius = radius;
- return GetNewUniqueScriptSphereIndex(i);
-}
-
-void CTheScripts::RemoveScriptSphere(int32 index)
-{
- index = GetActualScriptSphereIndex(index);
- if (index == -1)
- return;
- ScriptSphereArray[index].m_bInUse = false;
- ScriptSphereArray[index].m_Id = 0;
-}
-
-void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model)
-{
- int i = 0;
- bool found = false;
- while (i < MAX_NUM_BUILDING_SWAPS && !found) {
- if (BuildingSwapArray[i].m_pBuilding == pBuilding)
- found = true;
- else
- i++;
- }
- if (found) {
- if (BuildingSwapArray[i].m_nOldModel == new_model) {
- BuildingSwapArray[i].m_pBuilding = nil;
- BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
- }
- else {
- BuildingSwapArray[i].m_nNewModel = new_model;
- }
- }
- else {
- i = 0;
- while (i < MAX_NUM_BUILDING_SWAPS && !found) {
- if (BuildingSwapArray[i].m_pBuilding == nil)
- found = true;
- else
- i++;
- }
- if (found) {
- BuildingSwapArray[i].m_pBuilding = pBuilding;
- BuildingSwapArray[i].m_nNewModel = new_model;
- BuildingSwapArray[i].m_nOldModel = old_model;
- }
- }
-}
-
-void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove)
-{
- int i = 0;
- bool found = false;
- while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
- if (InvisibilitySettingArray[i] == pEntity)
- found = true;
- else
- i++;
- }
- if (found) {
- if (remove)
- InvisibilitySettingArray[i] = nil;
- }
- else if (!remove) {
- i = 0;
- while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
- if (InvisibilitySettingArray[i] == nil)
- found = true;
- else
- i++;
- }
- if (found)
- InvisibilitySettingArray[i] = pEntity;
- }
-}
-
-void CTheScripts::UndoBuildingSwaps()
-{
- for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
- if (BuildingSwapArray[i].m_pBuilding) {
- BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nOldModel);
- BuildingSwapArray[i].m_pBuilding = nil;
- BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
- }
- }
-}
-
-void CTheScripts::UndoEntityInvisibilitySettings()
-{
- for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
- if (InvisibilitySettingArray[i]) {
- InvisibilitySettingArray[i]->bIsVisible = true;
- InvisibilitySettingArray[i] = nil;
- }
- }
-}
-
-
void CRunningScript::UpdateCompareFlag(bool flag)
{
if (m_bNotFlag)
@@ -1921,7 +1780,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
if (pPed->IsPedInControl())
pPed->SetWanderPath(CGeneral::GetRandomNumber() & 7);
if (flees) {
- pPed->m_nPedState = state;
+ pPed->SetPedState(state);
pPed->SetMoveState(ms);
}
--CPopulation::ms_nTotalMissionPeds;
diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp
index acd9e424..c2937e1d 100644
--- a/src/control/Script6.cpp
+++ b/src/control/Script6.cpp
@@ -545,7 +545,14 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
CStats::RegisterHighestScore(ScriptParams[0], ScriptParams[1]);
return 0;
//case COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER:
- //case COMMAND_IS_CAR_PASSENGER_SEAT_FREE:
+ case COMMAND_IS_CAR_PASSENGER_SEAT_FREE:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ script_assert(pVehicle);
+ UpdateCompareFlag(ScriptParams[1] < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[ScriptParams[1]] == nil);
+ return 0;
+ }
case COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT:
{
CollectParameters(&m_nIp, 2);
diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp
index b8354d93..a888d528 100644
--- a/src/core/AnimViewer.cpp
+++ b/src/core/AnimViewer.cpp
@@ -45,7 +45,7 @@ CEntity *CAnimViewer::pTarget = nil;
void
CAnimViewer::Render(void) {
if (pTarget) {
-// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
+// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); // Only on Mobile
if (pTarget) {
#ifdef FIX_BUGS
#ifdef PED_SKIN
@@ -61,7 +61,9 @@ CAnimViewer::Render(void) {
void
CAnimViewer::Initialise(void) {
- LoadingScreen("Loading the ModelViewer", "", GetRandomSplashScreen());
+ // we need messages, messages needs hud, hud needs this
+ CHud::m_Wants_To_Draw_Hud = false;
+
animTxdSlot = CTxdStore::AddTxdSlot("generic");
CTxdStore::Create(animTxdSlot);
int hudSlot = CTxdStore::AddTxdSlot("hud");
@@ -75,9 +77,6 @@ CAnimViewer::Initialise(void) {
TheCamera.SetRwCamera(Scene.camera);
TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f;
- gbModelViewer = true;
- CHud::m_Wants_To_Draw_Hud = false;
-
ThePaths.Init();
ThePaths.AllocatePathFindInfoMem(4500);
CCollision::Init();
@@ -113,7 +112,7 @@ CAnimViewer::Initialise(void) {
CTimeCycle::Initialise();
CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed();
- player->SetPosition(0.0f, 0.0f, 0.0f);
+ player->SetPosition(0.0f, 0.0f, 0.0f); // This is 1000.f for all axes on Xbox, but 0.f on mobile?
CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
@@ -222,8 +221,7 @@ CAnimViewer::Update(void)
{
static int modelId = 0;
static int animId = 0;
- // Please don't make this bool, static bool's are problematic on my side.
- static int reloadIFP = 0;
+ static bool reloadIFP = false;
AssocGroupId animGroup = ASSOCGRP_STD;
int nextModelId = modelId;
@@ -248,7 +246,7 @@ CAnimViewer::Update(void)
CAnimManager::Initialise();
CAnimManager::LoadAnimFiles();
- reloadIFP = 0;
+ reloadIFP = false;
}
} else {
animGroup = ASSOCGRP_STD;
@@ -302,6 +300,7 @@ CAnimViewer::Update(void)
pTarget->GetMatrix().GetPosition().z = 10.0f;
#else
pTarget->GetMatrix().GetPosition().z = 0.0f;
+
#endif
if (modelInfo->GetModelType() == MITYPE_PED) {
@@ -309,7 +308,7 @@ CAnimViewer::Update(void)
// Triangle in mobile
if (pad->GetSquareJustDown()) {
- reloadIFP = 1;
+ reloadIFP = true;
AsciiToUnicode("IFP reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0);
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index b20e6db3..5906310b 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -2472,7 +2472,7 @@ CCam::Process_Rocket(const CVector &CameraTarget, float, float, float)
ResetStatics = false;
}
- ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
+ ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@@ -2573,7 +2573,7 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float)
}
#if GTA_VERSION < GTA3_PC_11
- ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
+ ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@@ -2611,7 +2611,7 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float)
HeadPos.x = 0.0f;
HeadPos.y = 0.0f;
HeadPos.z = 0.0f;
- ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
+ ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f * Cos(m_fInitialPlayerOrientation);
@@ -2700,7 +2700,7 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl
ResetStatics = false;
}
- ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
+ ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@@ -2868,7 +2868,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
Source = HeadPos;
// unused:
- // ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&MidPos, PED_MID);
+ // ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(MidPos, PED_MID);
// Source - MidPos;
// Look around
@@ -2963,7 +2963,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float
ResetStatics = false;
}
- ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
+ ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@@ -3003,8 +3003,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float
UseMouse = false;
int ZoomInButton = ControlsManager.GetMouseButtonAssociatedWithAction(PED_SNIPER_ZOOM_IN);
int ZoomOutButton = ControlsManager.GetMouseButtonAssociatedWithAction(PED_SNIPER_ZOOM_OUT);
- // TODO: enum? this should be mouse wheel up and down
- if(ZoomInButton == 4 || ZoomInButton == 5 || ZoomOutButton == 4 || ZoomOutButton == 5){
+ if(ZoomInButton == rsMOUSEWHEELUPBUTTON || ZoomInButton == rsMOUSEWHEELDOWNBUTTON || ZoomOutButton == rsMOUSEWHEELUPBUTTON || ZoomOutButton == rsMOUSEWHEELDOWNBUTTON){
if(CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetMouseWheelDown()){
if(CPad::GetPad(0)->SniperZoomIn()){
TargetFOV = FOV - 10.0f;
@@ -4894,13 +4893,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
if (FOV > DefaultFOV)
// 0.98f: CAR_FOV_FADE_MULT
- FOV = pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
+ FOV = Pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
- if (FOV <= DefaultFOV + 30.0f) {
- if (FOV < DefaultFOV)
- FOV = DefaultFOV;
- } else
- FOV = DefaultFOV + 30.0f;
+ FOV = clamp(FOV, DefaultFOV, DefaultFOV + 30.0f);
}
// WORKAROUND: I still don't know how looking behind works (m_bCamDirectlyInFront is unused in III, they seem to use m_bUseTransitionBeta)
@@ -5030,7 +5025,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
targetAlpha = maxAlphaAllowed;
}
float maxAlphaBlendAmount = CTimer::GetTimeStep() * CARCAM_SET[camSetArrPos][6];
- float targetAlphaBlendAmount = (1.0f - pow(CARCAM_SET[camSetArrPos][5], CTimer::GetTimeStep())) * (targetAlpha - Alpha);
+ float targetAlphaBlendAmount = (1.0f - Pow(CARCAM_SET[camSetArrPos][5], CTimer::GetTimeStep())) * (targetAlpha - Alpha);
if (targetAlphaBlendAmount <= maxAlphaBlendAmount) {
if (targetAlphaBlendAmount < -maxAlphaBlendAmount)
targetAlphaBlendAmount = -maxAlphaBlendAmount;
@@ -5042,9 +5037,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float stickX = -(pad->GetCarGunLeftRight());
float stickY = pad->GetCarGunUpDown();
- // In SA this checks for m_bUseMouse3rdPerson so num2/num8 do not move camera when Keyboard & Mouse controls are used.
- if (CCamera::m_bUseMouse3rdPerson)
- stickY = 0.0f;
+ // In SA this is for not let num2/num8 move camera when Keyboard & Mouse controls are used.
+ // if (CCamera::m_bUseMouse3rdPerson)
+ // stickY = 0.0f;
float xMovement = Abs(stickX) * (FOV / 80.0f * 5.f / 70.f) * stickX * 0.007f * 0.007f;
float yMovement = Abs(stickY) * (FOV / 80.0f * 3.f / 70.f) * stickY * 0.007f * 0.007f;
@@ -5122,7 +5117,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float betaSpeedFromStickX = xMovement * CARCAM_SET[camSetArrPos][12];
float newAngleSpeedMaxBlendAmount = CARCAM_SET[camSetArrPos][9];
- float angleChangeStep = pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep());
+ float angleChangeStep = Pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep());
float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / Max(CTimer::GetTimeStep(), 1.0f);
if (targetBetaWithStickBlendAmount < -newAngleSpeedMaxBlendAmount)
@@ -5234,69 +5229,78 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// SA calls SetColVarsVehicle in here
if (nextDirectionIsForward) {
- // This is new in LCS!
+ // LCS uses exactly the same collision code as FollowPedWithMouse, so we will do so.
+
+ // This is only in LCS!
float timestepFactor = Pow(0.99f, CTimer::GetTimeStep());
dontCollideWithCars = (timestepFactor * dontCollideWithCars) + ((1.0f - timestepFactor) * car->m_vecMoveSpeed.Magnitude());
- // Move cam if on collision
- CColPoint foundCol;
- CEntity* foundEnt;
+ // Our addition
+#define IS_TRAFFIC_LIGHT(ent) (ent->IsObject() && (IsStreetLight(ent->GetModelIndex())))
+
+ // Clip Source and fix near clip
+ CColPoint colPoint;
+ CEntity* entity;
CWorld::pIgnoreEntity = CamTargetEntity;
- if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
- float obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
- float obstacleCamDist = newDistance - obstacleTargetDist;
- if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
- Source = foundCol.point;
- if (obstacleTargetDist < 1.2f) {
- RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
- }
- } else {
- if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
- float lessClip = obstacleCamDist - 0.35f;
- if (lessClip <= DEFAULT_NEAR)
- RwCameraSetNearClipPlane(Scene.camera, lessClip);
- else
- RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
- } else {
- obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
- Source = foundCol.point;
- if (obstacleTargetDist < 1.2f) {
- float lessClip = obstacleTargetDist - 0.3f;
- if (lessClip >= 0.05f)
- RwCameraSetNearClipPlane(Scene.camera, lessClip);
- else
- RwCameraSetNearClipPlane(Scene.camera, 0.05f);
- }
+ if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, dontCollideWithCars < 0.1f, false, true, false, true, true) && !IS_TRAFFIC_LIGHT(entity)){
+ float PedColDist = (TargetCoors - colPoint.point).Magnitude();
+ float ColCamDist = newDistance - PedColDist;
+ if(entity->IsPed() && ColCamDist > DEFAULT_NEAR + 0.1f){
+ // Ped in the way but not clipping through
+ if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, dontCollideWithCars < 0.1f, false, true, false, true, true) || IS_TRAFFIC_LIGHT(entity)){
+ PedColDist = (TargetCoors - colPoint.point).Magnitude();
+ Source = colPoint.point;
+ if(PedColDist < DEFAULT_NEAR + 0.3f)
+ RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
+ }else{
+ RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR));
}
+ }else{
+ Source = colPoint.point;
+ if(PedColDist < DEFAULT_NEAR + 0.3f)
+ RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}
}
+
CWorld::pIgnoreEntity = nil;
- float nearClip = RwCameraGetNearClipPlane(Scene.camera);
- float radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
// If we're seeing blue hell due to camera intersects some surface, fix it.
// SA and LCS have this unrolled.
- for (int i = 0;
- i <= 5 && CWorld::TestSphereAgainstWorld((nearClip * Front) + Source, radius * nearClip, nil, true, true, false, true, false, false);
- i++) {
-
- CVector surfaceCamDist = gaTempSphereColPoints->point - Source;
- CVector frontButInvertedIfTouchesSurface = DotProduct(surfaceCamDist, Front) * Front;
- float newNearClip = (surfaceCamDist - frontButInvertedIfTouchesSurface).Magnitude() / radius;
-
- if (newNearClip > nearClip)
- newNearClip = nearClip;
- if (newNearClip < 0.1f)
- newNearClip = 0.1f;
- if (nearClip > newNearClip)
- RwCameraSetNearClipPlane(Scene.camera, newNearClip);
-
- if (newNearClip == 0.1f)
- Source += (TargetCoors - Source) * 0.3f;
-
- nearClip = RwCameraGetNearClipPlane(Scene.camera);
- radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
+
+ float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f);
+ float ViewPlaneWidth = ViewPlaneHeight * CDraw::FindAspectRatio() * fTweakFOV;
+ float Near = RwCameraGetNearClipPlane(Scene.camera);
+ float radius = ViewPlaneWidth*Near;
+ entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, true);
+ int i = 0;
+ while(entity){
+
+ if (IS_TRAFFIC_LIGHT(entity))
+ break;
+
+ CVector CamToCol = gaTempSphereColPoints[0].point - Source;
+ float frontDist = DotProduct(CamToCol, Front);
+ float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth;
+
+ // Try to decrease near clip
+ dist = Max(Min(Near, dist), 0.1f);
+ if(dist < Near)
+ RwCameraSetNearClipPlane(Scene.camera, dist);
+
+ // Move forward a bit
+ if(dist == 0.1f)
+ Source += (TargetCoors - Source)*0.3f;
+
+ // Keep testing
+ Near = RwCameraGetNearClipPlane(Scene.camera);
+ radius = ViewPlaneWidth*Near;
+ entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, true);
+
+ i++;
+ if(i > 5)
+ entity = nil;
}
+#undef IS_TRAFFIC_LIGHT
}
TheCamera.m_bCamDirectlyBehind = false;
TheCamera.m_bCamDirectlyInFront = false;
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index b9d475b8..0ad03f61 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -1065,7 +1065,7 @@ CFileLoader::LoadMLOInstance(int id, const char *line)
&rot.x, &rot.y, &rot.z,
&angle);
float rad = Acos(angle) * 2.0f;
- CInstance *inst = CModelInfo::GetMloInstanceStore().alloc();
+ CInstance *inst = CModelInfo::GetMloInstanceStore().Alloc();
minfo->lastInstance++;
RwMatrix *matrix = RwMatrixCreate();
@@ -1305,7 +1305,7 @@ CFileLoader::Load2dEffect(const char *line)
CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle"));
mi = CModelInfo::GetModelInfo(id);
- effect = CModelInfo::Get2dEffectStore().alloc();
+ effect = CModelInfo::Get2dEffectStore().Alloc();
mi->Add2dEffect(effect);
effect->pos = CVector(x, y, z);
effect->col = CRGBA(r, g, b, a);
diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp
index c6dece6a..2c57c066 100644
--- a/src/core/Fire.cpp
+++ b/src/core/Fire.cpp
@@ -90,7 +90,11 @@ CFire::ProcessFire(void)
}
}
}
- if (!FindPlayerVehicle() && !FindPlayerPed()->m_pFire && !(FindPlayerPed()->bFireProof)
+ if (!FindPlayerVehicle() &&
+#ifdef FIX_BUGS
+ FindPlayerPed() &&
+#endif
+ !FindPlayerPed()->m_pFire && !(FindPlayerPed()->bFireProof)
&& ((FindPlayerPed()->GetPosition() - m_vecPos).MagnitudeSqr() < 2.0f)) {
FindPlayerPed()->DoStuffToGoOnFire();
gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1);
@@ -224,7 +228,7 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
ped->bDrawLast = false;
ped->SetMoveState(PEDMOVE_SPRINT);
ped->SetMoveAnim();
- ped->m_nPedState = PED_ON_FIRE;
+ ped->SetPedState(PED_ON_FIRE);
}
if (fleeFrom) {
if (ped->m_nPedType == PEDTYPE_COP) {
@@ -397,7 +401,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt
CVector2D pos = target->GetPosition();
ped->SetFlee(pos, 10000);
ped->SetMoveAnim();
- ped->m_nPedState = PED_ON_FIRE;
+ ped->SetPedState(PED_ON_FIRE);
}
} else if (target->IsVehicle()) {
veh->m_pCarFire = fire;
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 5a99ad95..0f725f7d 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -39,10 +39,35 @@
#include "FileLoader.h"
#include "frontendoption.h"
+// Game has colors inlined in code.
+// For easier modification we collect them here:
+const CRGBA LABEL_COLOR(235, 170, 50, 255);
+const CRGBA SELECTION_HIGHLIGHTBG_COLOR(100, 200, 50, 50);
+const CRGBA MENUOPTION_COLOR = LABEL_COLOR;
+const CRGBA SELECTEDMENUOPTION_COLOR(255, 217, 106, 255);
+const CRGBA HEADER_COLOR(0, 0, 0, 255);
+const CRGBA DARKMENUOPTION_COLOR(155, 117, 6, 255);
+const CRGBA SLIDERON_COLOR = SELECTEDMENUOPTION_COLOR;
+const CRGBA SLIDEROFF_COLOR(185, 120, 0, 255);
+const CRGBA LIST_BACKGROUND_COLOR(200, 200, 50, 50);
+const CRGBA LIST_OPTION_COLOR(155, 155, 155, 255);
+const CRGBA INACTIVE_RADIO_COLOR(225, 0, 0, 170);
+const CRGBA SCROLLBAR_COLOR = LABEL_COLOR;
+const CRGBA CONTSETUP_HIGHLIGHTBG_COLOR(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, 210);
+const CRGBA CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, 150);
+
+// This is PS2 menu leftover, and variable name is original. They forgot it here and used in PrintBriefs once (but didn't use the output)
+#if defined(FIX_BUGS) && !defined(PS2_LIKE_MENU)
+const CRGBA TEXT_COLOR = LABEL_COLOR;
+#else
+const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255); // PS2 option color
+#endif
+
#define TIDY_UP_PBP // ProcessButtonPresses
#define MAX_VISIBLE_LIST_ROW 30
#define SCROLLBAR_MAX_HEIGHT 263.0f // not in end result
#define SCROLLABLE_PAGES
+#define RED_DELETE_BACKGROUND
#ifdef SCROLLABLE_STATS_PAGE
#define isPlainTextScreen(screen) (screen == MENUPAGE_BRIEFS)
@@ -56,6 +81,7 @@
#ifdef SCROLLABLE_PAGES
#define MAX_VISIBLE_OPTION 12
#define MAX_VISIBLE_OPTION_ON_SCREEN (hasNativeList(m_nCurrScreen) ? MAX_VISIBLE_LIST_ROW : MAX_VISIBLE_OPTION)
+#define SCREEN_HAS_AUTO_SCROLLBAR (m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen))
int GetOptionCount(int screen)
{
@@ -91,8 +117,6 @@ int GetOptionCount(int screen)
#ifdef MENU_MAP
bool CMenuManager::bMenuMapActive = false;
-bool CMenuManager::bMapMouseShownOnce = false;
-bool CMenuManager::bMapLoaded = false;
float CMenuManager::fMapSize;
float CMenuManager::fMapCenterY;
float CMenuManager::fMapCenterX;
@@ -121,18 +145,11 @@ int8 CMenuManager::m_nDisplayMSAALevel = 0;
int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW;
#endif
-// Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway)
-#ifdef PS2_LIKE_MENU
-const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255);
-#else
-const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color
-#endif
-
#ifdef USE_PRECISE_MEASUREMENT_CONVERTION
#define MILES_IN_METER 0.000621371192f
#define FEET_IN_METER 3.28084f
#else
-#define MILES_IN_METER 0.00059880241f
+#define MILES_IN_METER (1 / 1670.f)
#define FEET_IN_METER 3.33f
#endif
@@ -161,7 +178,6 @@ int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt;
int32 CMenuManager::m_PrefsMusicVolume = 102;
int32 CMenuManager::m_PrefsSfxVolume = 102;
-
char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME;
int32 CMenuManager::m_KeyPressedCode = -1;
@@ -193,7 +209,6 @@ bool CMenuManager::m_PrefsMarketing = false;
bool CMenuManager::m_PrefsDisableTutorials = false;
#endif // !MASTER
-// 0x5F311C
const char* FrontendFilenames[][2] = {
{"fe2_mainpanel_ul", "" },
{"fe2_mainpanel_ur", "" },
@@ -297,12 +312,33 @@ const char* MenuFilenames[][2] = {
m_nMenuFadeAlpha = 0; \
} while(0)
-#define PREPARE_MENU_HEADER \
- CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \
+#define SET_FONT_FOR_MENU_HEADER \
+ CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+#define RESET_FONT_FOR_NEW_PAGE \
+ CFont::SetBackgroundOff(); \
+ CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); \
+ CFont::SetPropOn(); \
+ CFont::SetCentreOff(); \
+ CFont::SetJustifyOn(); \
+ CFont::SetRightJustifyOff(); \
+ CFont::SetBackGroundOnlyTextOn(); \
+ CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); \
+ CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+
+#define SET_FONT_FOR_HELPER_TEXT \
+ CFont::SetCentreOn(); \
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); \
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+
+#define SET_FONT_FOR_LIST_ITEM \
+ CFont::SetRightJustifyOff(); \
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); \
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \
lastActiveBarX = DisplaySlider(MENU_X_RIGHT_ALIGNED(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \
@@ -322,7 +358,8 @@ const char* MenuFilenames[][2] = {
#define ProcessRadioIcon(sprite, x, y, radioId, hoverOpt) \
do { \
- sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); \
+ sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : \
+ CRGBA(INACTIVE_RADIO_COLOR.r, INACTIVE_RADIO_COLOR.g, INACTIVE_RADIO_COLOR.b, INACTIVE_RADIO_COLOR.a)); \
if (CheckHover(x, x + MENU_X(MENURADIO_ICON_SCALE), y, y + MENU_Y(MENURADIO_ICON_SCALE))) \
m_nHoverOption = hoverOpt; \
} while (0)
@@ -440,7 +477,7 @@ CMenuManager::ThingsToDoBeforeGoingBack()
}
#ifdef SCROLLABLE_PAGES
- if (m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen)) {
+ if (SCREEN_HAS_AUTO_SCROLLBAR) {
m_nSelectedListRow = 0;
m_nFirstVisibleRowOnList = 0;
m_nScrollbarTopMargin = 0;
@@ -496,6 +533,7 @@ CMenuManager::ProcessList(bool &goBack, bool &optionSelected)
m_nTotalListRow = m_nSkinsTotal;
}
if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) {
+ // GetNumOptionsCntrlConfigScreens would have been a better choice
m_nTotalListRow = m_ControlMethod == CONTROL_CLASSIC ? 30 : 25;
if (m_nSelectedListRow > m_nTotalListRow)
m_nSelectedListRow = m_nTotalListRow - 1;
@@ -916,10 +954,7 @@ CMenuManager::DisplayHelperText()
alpha = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha;
}
- CFont::SetCentreOn();
- CFont::SetScale(SCREEN_SCALE_X(SMALLESTTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
-
+ SET_FONT_FOR_HELPER_TEXT
// TODO: name this cases?
switch (m_nHelperTextMsgId) {
case 0:
@@ -927,25 +962,25 @@ CMenuManager::DisplayHelperText()
int action = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action;
if (action != MENUACTION_CHANGEMENU && action != MENUACTION_KEYBOARDCTRLS && action != MENUACTION_RESTOREDEF) {
CFont::SetColor(CRGBA(255, 255, 255, 255));
- CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_MIG"));
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(HELPER_TEXT_LEFT_MARGIN), SCREEN_SCALE_FROM_BOTTOM(HELPER_TEXT_BOTTOM_MARGIN), TheText.Get("FET_MIG"));
}
break;
}
case 1:
CFont::SetColor(CRGBA(255, 255, 255, 255));
- CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_APP"));
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(HELPER_TEXT_LEFT_MARGIN), SCREEN_SCALE_FROM_BOTTOM(HELPER_TEXT_BOTTOM_MARGIN), TheText.Get("FET_APP"));
break;
case 2:
CFont::SetColor(CRGBA(255, 255, 255, alpha));
- CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_HRD"));
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(HELPER_TEXT_LEFT_MARGIN), SCREEN_SCALE_FROM_BOTTOM(HELPER_TEXT_BOTTOM_MARGIN), TheText.Get("FET_HRD"));
break;
case 3:
CFont::SetColor(CRGBA(255, 255, 255, alpha));
- CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_RSO"));
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(HELPER_TEXT_LEFT_MARGIN), SCREEN_SCALE_FROM_BOTTOM(HELPER_TEXT_BOTTOM_MARGIN), TheText.Get("FET_RSO"));
break;
case 4:
CFont::SetColor(CRGBA(255, 255, 255, alpha));
- CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_RSC"));
+ CFont::PrintString(MENU_X_LEFT_ALIGNED(HELPER_TEXT_LEFT_MARGIN), SCREEN_SCALE_FROM_BOTTOM(HELPER_TEXT_BOTTOM_MARGIN), TheText.Get("FET_RSC"));
break;
default:
break;
@@ -966,10 +1001,10 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR
curBarX = i * rectSize/16.0f + x;
if (i / 16.0f + 1 / 32.0f < progress) {
- color = CRGBA(255, 217, 106, FadeIn(255));
+ color = CRGBA(SLIDERON_COLOR.r, SLIDERON_COLOR.g, SLIDERON_COLOR.b, FadeIn(255));
lastActiveBarX = curBarX;
} else
- color = CRGBA(185, 120, 0, FadeIn(255));
+ color = CRGBA(SLIDEROFF_COLOR.r, SLIDEROFF_COLOR.g, SLIDEROFF_COLOR.b, FadeIn(255));
maxBarHeight = Max(mostLeftBarSize, mostRightBarSize);
@@ -1010,9 +1045,8 @@ CMenuManager::Draw()
CFont::SetCentreOff();
CFont::SetJustifyOn();
CFont::SetBackGroundOnlyTextOn();
-#if GTA_VERSION >= GTA3_PC_11
-#ifdef DRAW_MENU_VERSION_TEXT
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+#if GTA_VERSION >= GTA3_PC_11 && defined(DRAW_MENU_VERSION_TEXT)
+ CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f));
@@ -1022,7 +1056,6 @@ CMenuManager::Draw()
AsciiToUnicode(gString, gUString);
CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString);
#endif
-#endif
CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
@@ -1049,7 +1082,7 @@ CMenuManager::Draw()
#endif
if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') {
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
// Weird place to put that.
@@ -1059,7 +1092,7 @@ CMenuManager::Draw()
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_X), MENU_Y(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_Y));
CFont::SetRightJustifyOff();
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
// Label
wchar *str;
@@ -1247,7 +1280,7 @@ CMenuManager::Draw()
// Back button
wchar *backTx = TheText.Get("FEDS_TB");
CFont::SetDropShadowPosition(1);
- CFont::SetDropColor(CRGBA(0, 0, 0, 255));
+ CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255)));
CFont::PrintString(MENU_X(60.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), backTx);
CFont::SetDropShadowPosition(0);
if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) {
@@ -1262,11 +1295,12 @@ CMenuManager::Draw()
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
+ // Thanks R*, for checking mouse hovering in Draw().
static int lastSelectedOpt = m_nCurrOption;
#endif
#ifdef SCROLLABLE_PAGES
- int firstOption = m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen) ? m_nFirstVisibleRowOnList : 0;
+ int firstOption = SCREEN_HAS_AUTO_SCROLLBAR ? m_nFirstVisibleRowOnList : 0;
for (int i = firstOption; i < firstOption + MAX_VISIBLE_OPTION && i < NUM_MENUROWS; ++i) {
#else
for (int i = 0; i < NUM_MENUROWS; ++i) {
@@ -1299,38 +1333,6 @@ CMenuManager::Draw()
leftText = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName);
}
-#ifdef CUSTOM_FRONTEND_OPTIONS
- if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action < MENUACTION_NOTHING) { // CFO check
- CMenuScreenCustom::CMenuEntry &option = aScreens[m_nCurrScreen].m_aEntries[i];
- if (option.m_Action == MENUACTION_CFO_SELECT) {
- if (option.m_CFOSelect->onlyApplyOnEnter){
- if (m_nCurrOption != i) {
- if (option.m_CFOSelect->displayedValue != option.m_CFOSelect->lastSavedValue)
- SetHelperText(3); // Restored original value
-
-// option.displayedValue = option.lastSavedValue = *option.m_CFO->value;
-
- } else {
- if (option.m_CFOSelect->displayedValue != *option.m_CFO->value)
- SetHelperText(1); // Enter to apply
- else if (m_nHelperTextMsgId == 1)
- ResetHelperText(); // Applied
- }
- }
- }
-
- if (m_nCurrOption != lastSelectedOpt && lastSelectedOpt == i) {
- CMenuScreenCustom::CMenuEntry &oldOption = aScreens[m_nCurrScreen].m_aEntries[lastSelectedOpt];
- if (oldOption.m_Action == MENUACTION_CFO_DYNAMIC)
- if(oldOption.m_CFODynamic->buttonPressFunc)
- oldOption.m_CFODynamic->buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS);
-
- if (oldOption.m_Action == MENUACTION_CFO_SELECT && oldOption.m_CFOSelect->onlyApplyOnEnter)
- oldOption.m_CFOSelect->displayedValue = oldOption.m_CFOSelect->lastSavedValue = *oldOption.m_CFO->value;
- }
- }
-#endif
-
switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) {
case MENUACTION_CHANGEMENU: {
switch (aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu) {
@@ -1549,7 +1551,25 @@ CMenuManager::Draw()
case MENUACTION_CFO_SELECT:
CMenuScreenCustom::CMenuEntry &option = aScreens[m_nCurrScreen].m_aEntries[i];
if (option.m_Action == MENUACTION_CFO_SELECT) {
- // To whom manipulate option.m_CFO->value of static options externally (like RestoreDef functions)
+
+ if (option.m_CFOSelect->onlyApplyOnEnter){
+ if (m_nCurrOption != i) {
+ if (option.m_CFOSelect->displayedValue != option.m_CFOSelect->lastSavedValue)
+ SetHelperText(3); // Restored original value
+
+ // If that was previously selected option, restore it to default value.
+ // if (m_nCurrOption != lastSelectedOpt && lastSelectedOpt == i)
+ option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *option.m_CFO->value;
+
+ } else {
+ if (option.m_CFOSelect->displayedValue != *option.m_CFO->value)
+ SetHelperText(1); // Enter to apply
+ else if (m_nHelperTextMsgId == 1)
+ ResetHelperText(); // Applied
+ }
+ }
+
+ // To whom manipulate option.m_CFO->value of select options externally (like RestoreDef functions)
if (*option.m_CFO->value != option.m_CFOSelect->lastSavedValue)
option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *option.m_CFO->value;
@@ -1559,6 +1579,11 @@ CMenuManager::Draw()
rightText = TheText.Get(option.m_CFOSelect->rightTexts[option.m_CFOSelect->displayedValue]);
} else if (option.m_Action == MENUACTION_CFO_DYNAMIC) {
+ if (m_nCurrOption != lastSelectedOpt && lastSelectedOpt == i) {
+ if(option.m_CFODynamic->buttonPressFunc)
+ option.m_CFODynamic->buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS);
+ }
+
if (option.m_CFODynamic->drawFunc) {
rightText = option.m_CFODynamic->drawFunc(&isOptionDisabled, m_nCurrOption == i);
}
@@ -1636,12 +1661,12 @@ CMenuManager::Draw()
#ifdef PS2_LIKE_MENU
CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(29.0f), MENU_Y(bitAboveNextItemY),
MENU_X_RIGHT_ALIGNED(29.0f), MENU_Y(usableLineHeight + nextItemY)),
- CRGBA(100, 200, 50, FadeIn(50)));
+ CRGBA(SELECTION_HIGHLIGHTBG_COLOR.r, SELECTION_HIGHLIGHTBG_COLOR.g, SELECTION_HIGHLIGHTBG_COLOR.b, FadeIn(SELECTION_HIGHLIGHTBG_COLOR.a)));
#else
// We keep stretching, because we also stretch background image and we want that bar to be aligned with borders of background
CSprite2d::DrawRect(CRect(StretchX(10.0f), MENU_Y(bitAboveNextItemY),
SCREEN_STRETCH_FROM_RIGHT(11.0f), MENU_Y(usableLineHeight + nextItemY)),
- CRGBA(100, 200, 50, FadeIn(50)));
+ CRGBA(SELECTION_HIGHLIGHTBG_COLOR.r, SELECTION_HIGHLIGHTBG_COLOR.g, SELECTION_HIGHLIGHTBG_COLOR.b, FadeIn(SELECTION_HIGHLIGHTBG_COLOR.a)));
#endif
}
@@ -1665,14 +1690,14 @@ CMenuManager::Draw()
|| isOptionDisabled
#endif
)
- CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255)));
+ CFont::SetColor(CRGBA(DARKMENUOPTION_COLOR.r, DARKMENUOPTION_COLOR.g, DARKMENUOPTION_COLOR.b, FadeIn(255)));
CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText);
}
if (i == m_nCurrOption && itemsAreSelectable){
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
} else {
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
}
@@ -1695,7 +1720,9 @@ CMenuManager::Draw()
if (m_nPrefsAudio3DProviderIndex != DMAudio.GetCurrent3DProviderIndex()) {
if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEA_3DH") != 0
// To make assigning built-in actions to new custom options possible.
-#ifndef CUSTOM_FRONTEND_OPTIONS
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ && ScreenHasOption(m_nCurrScreen, "FEA_3DH")
+#else
&& m_nCurrScreen == MENUPAGE_SOUND_SETTINGS
#endif
&& m_nPrefsAudio3DProviderIndex != -1) {
@@ -1772,21 +1799,21 @@ CMenuManager::Draw()
#endif
#ifdef SCROLLABLE_PAGES
- #define SCROLLBAR_BOTTOM_X 125.0f // only for background, scrollbar's itself is calculated
+ #define SCROLLBAR_BOTTOM_Y 125.0f // only for background, scrollbar's itself is calculated
#define SCROLLBAR_RIGHT_X 36.0f
#define SCROLLBAR_WIDTH 9.5f
- #define SCROLLBAR_TOP_X 64
+ #define SCROLLBAR_TOP_Y 64
- if (m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen)) {
+ if (SCREEN_HAS_AUTO_SCROLLBAR) {
// Scrollbar background
- CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 2), MENU_Y(SCROLLBAR_TOP_X),
- MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 2 - SCROLLBAR_WIDTH), SCREEN_SCALE_FROM_BOTTOM(SCROLLBAR_BOTTOM_X)), CRGBA(100, 100, 66, FadeIn(205)));
+ CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 2), MENU_Y(SCROLLBAR_TOP_Y),
+ MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 2 - SCROLLBAR_WIDTH), SCREEN_SCALE_FROM_BOTTOM(SCROLLBAR_BOTTOM_Y)), CRGBA(100, 100, 66, FadeIn(205)));
float scrollbarHeight = SCROLLBAR_MAX_HEIGHT / (m_nTotalListRow / (float) MAX_VISIBLE_OPTION);
float scrollbarBottom, scrollbarTop;
- scrollbarBottom = MENU_Y(SCROLLBAR_TOP_X - 8 + m_nScrollbarTopMargin + scrollbarHeight);
- scrollbarTop = MENU_Y(SCROLLBAR_TOP_X + m_nScrollbarTopMargin);
+ scrollbarBottom = MENU_Y(SCROLLBAR_TOP_Y - 8 + m_nScrollbarTopMargin + scrollbarHeight);
+ scrollbarTop = MENU_Y(SCROLLBAR_TOP_Y + m_nScrollbarTopMargin);
// Scrollbar shadow
CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 4), scrollbarTop,
MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 1 - SCROLLBAR_WIDTH), scrollbarBottom + MENU_Y(1.0f)),
@@ -1795,7 +1822,7 @@ CMenuManager::Draw()
// Scrollbar
CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - 4), scrollbarTop,
MENU_X_RIGHT_ALIGNED(SCROLLBAR_RIGHT_X - SCROLLBAR_WIDTH), scrollbarBottom),
- CRGBA(235, 170, 50, FadeIn(255)));
+ CRGBA(SCROLLBAR_COLOR.r, SCROLLBAR_COLOR.g, SCROLLBAR_COLOR.b, FadeIn(255)));
}
#endif
@@ -1860,6 +1887,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
int controllerAction = PED_FIREWEAPON;
// GetStartOptionsCntrlConfigScreens();
int numOptions = GetNumOptionsCntrlConfigScreens();
+ int nextY = MENU_Y(yStart);
int bindingMargin = MENU_X(3.0f);
float rowHeight;
switch (m_ControlMethod) {
@@ -1874,10 +1902,11 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
}
// MENU_Y(rowHeight * 0.0f + yStart);
- for (int optionIdx = 0, nextY = MENU_Y(yStart); optionIdx < numOptions; nextY = MENU_Y(++optionIdx * rowHeight + yStart)) {
+ for (int optionIdx = 0; optionIdx < numOptions; nextY = MENU_Y(++optionIdx * rowHeight + yStart)) {
int nextX = xStart;
int bindingsForThisOpt = 0;
- CFont::SetColor(CRGBA(155, 155, 155, FadeIn(255)));
+ int contSetOrder = SETORDER_1;
+ CFont::SetColor(CRGBA(LIST_OPTION_COLOR.r, LIST_OPTION_COLOR.g, LIST_OPTION_COLOR.b, FadeIn(LIST_OPTION_COLOR.a)));
if (column == CONTSETUP_PED_COLUMN) {
switch (optionIdx) {
@@ -2055,18 +2084,18 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
#ifdef FIX_BUGS
if (controllerAction == -1) {
CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH),
- MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150)));
+ MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.r, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.g, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.a)));
} else {
CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH),
- MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210)));
+ MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_HIGHLIGHTBG_COLOR.r, CONTSETUP_HIGHLIGHTBG_COLOR.g, CONTSETUP_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_HIGHLIGHTBG_COLOR.a)));
}
#else
if (controllerAction == -1) {
CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY),
- MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150)));
+ MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.r, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.g, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.a)));
} else {
CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY),
- MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210)));
+ MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_HIGHLIGHTBG_COLOR.r, CONTSETUP_HIGHLIGHTBG_COLOR.g, CONTSETUP_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_HIGHLIGHTBG_COLOR.a)));
}
#endif
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
@@ -2076,16 +2105,16 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
#ifdef FIX_BUGS
if (controllerAction == -1) {
CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH),
- MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150)));
+ MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.r, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.g, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.a)));
} else {
CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH),
- MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210)));
+ MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(CONTSETUP_HIGHLIGHTBG_COLOR.r, CONTSETUP_HIGHLIGHTBG_COLOR.g, CONTSETUP_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_HIGHLIGHTBG_COLOR.a)));
}
#else
if (controllerAction == -1) {
- CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(410.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(600.0f), MENU_Y(bgY + 10)), CRGBA(235, 170, 50, FadeIn(150)));
+ CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(410.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(600.0f), MENU_Y(bgY + 10)), CRGBA(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.r, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.g, CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_DISABLED_HIGHLIGHTBG_COLOR.a)));
} else {
- CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(410.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(600.0f), MENU_Y(bgY + 10)), CRGBA(255, 217, 106, FadeIn(210)));
+ CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(410.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(600.0f), MENU_Y(bgY + 10)), CRGBA(CONTSETUP_HIGHLIGHTBG_COLOR.r, CONTSETUP_HIGHLIGHTBG_COLOR.g, CONTSETUP_HIGHLIGHTBG_COLOR.b, FadeIn(CONTSETUP_HIGHLIGHTBG_COLOR.a)));
}
#endif
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
@@ -2095,8 +2124,8 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
}
// Print bindings, including seperator (-) between them
- CFont::SetScale(MENU_X(0.25f), MENU_Y(0.6f));
- for (int contSetOrder = SETORDER_1; contSetOrder < MAX_SETORDERS && controllerAction != -1; contSetOrder++) {
+ CFont::SetScale(MENU_X(0.25f), MENU_Y(SMALLESTTEXT_Y_SCALE));
+ for (; contSetOrder < MAX_SETORDERS && controllerAction != -1; contSetOrder++) {
wchar *settingText = ControlsManager.GetControllerSettingTextWithOrderNumber((e_ControllerAction)controllerAction, (eContSetOrder)contSetOrder);
if (settingText) {
++bindingsForThisOpt;
@@ -2160,9 +2189,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::SetColor(CRGBA(55, 55, 55, FadeIn(255)));
CFont::PrintString(nextX, nextY, TheText.Get("FEC_QUE")); // "???"
}
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
if (m_bKeyChangeNotProcessed) {
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
@@ -2170,34 +2197,24 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_RIG")); // SELECT A NEW CONTROL FOR THIS ACTION OR ESC TO CANCEL
}
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
if (!m_bKeyIsOK)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
m_bKeyIsOK = true;
} else {
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
m_bKeyIsOK = false;
m_bKeyChangeNotProcessed = false;
}
} else if (optionIdx == m_nSelectedListRow) {
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(55, 55, 55, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_EIG")); // CANNOT SET A CONTROL FOR THIS ACTION
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
}
}
}
@@ -2244,7 +2261,7 @@ CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeig
if (waitingTextVisible) {
CFont::SetColor(CRGBA(255, 255, 0, FadeIn(255)));
CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_QUE"));
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
}
yStart += lineHeight;
@@ -2273,17 +2290,9 @@ CMenuManager::DrawControllerSetupScreen()
default:
break;
}
- CFont::SetBackgroundOff();
- CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
- CFont::SetPropOn();
- CFont::SetCentreOff();
- CFont::SetJustifyOn();
- CFont::SetRightJustifyOff();
- CFont::SetBackGroundOnlyTextOn();
- CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
- CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+ RESET_FONT_FOR_NEW_PAGE
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
switch (m_ControlMethod) {
case CONTROL_STANDARD:
@@ -2344,12 +2353,12 @@ CMenuManager::DrawControllerSetupScreen()
// Gray panel background
CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT), MENU_Y(CONTSETUP_LIST_TOP),
MENU_X_RIGHT_ALIGNED(CONTSETUP_LIST_RIGHT), SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_LIST_BOTTOM)),
- CRGBA(200, 200, 50, FadeIn(50)));
+ CRGBA(LIST_BACKGROUND_COLOR.r, LIST_BACKGROUND_COLOR.g, LIST_BACKGROUND_COLOR.b, FadeIn(LIST_BACKGROUND_COLOR.a)));
if (m_nCurrExLayer == HOVEROPTION_LIST)
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
else
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
// List header
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
@@ -2358,15 +2367,15 @@ CMenuManager::DrawControllerSetupScreen()
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CAC"));
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CFT"));
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CCR"));
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X_LEFT_ALIGNED(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
+
int yStart;
if (m_ControlMethod == CONTROL_CLASSIC)
- yStart = CONTSETUP_LIST_HEADER_HEIGHT + 29;
+ yStart = CONTSETUP_LIST_TOP + CONTSETUP_LIST_HEADER_HEIGHT + 1;
else
- yStart = CONTSETUP_LIST_HEADER_HEIGHT + 34;
+ yStart = CONTSETUP_LIST_TOP + CONTSETUP_LIST_HEADER_HEIGHT + 5;
+ float optionYBottom = yStart + rowHeight;
for (int i = 0; i < ARRAY_SIZE(actionTexts); ++i) {
wchar *actionText = actionTexts[i];
if (!actionText)
@@ -2375,8 +2384,7 @@ CMenuManager::DrawControllerSetupScreen()
if (m_nMousePosX > MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT + 2.0f) &&
m_nMousePosX < MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X + CONTSETUP_BOUND_COLUMN_WIDTH)) {
- float curOptY = i * rowHeight + yStart;
- if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) {
+ if (m_nMousePosY > MENU_Y(i * rowHeight + yStart) && m_nMousePosY < MENU_Y(i * rowHeight + optionYBottom)) {
if (m_nOptionMouseHovering != i && m_nCurrExLayer == HOVEROPTION_LIST)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0);
@@ -2418,16 +2426,16 @@ CMenuManager::DrawControllerSetupScreen()
m_nHoverOption = HOVEROPTION_NOT_HOVERING;
}
}
- if (m_nSelectedListRow != 35)
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ if (m_nSelectedListRow != i)
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
else if (m_nCurrExLayer == HOVEROPTION_LIST)
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
CFont::SetRightJustifyOff();
- if (m_PrefsLanguage != LANGUAGE_GERMAN || i != 20 && i != 21)
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- else
+ if (m_PrefsLanguage == LANGUAGE_GERMAN && (i == 20 || i == 21))
CFont::SetScale(MENU_X(0.32f), MENU_Y(SMALLESTTEXT_Y_SCALE));
+ else
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(i * rowHeight + yStart), actionText);
}
@@ -2458,9 +2466,9 @@ CMenuManager::DrawControllerSetupScreen()
SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_BACK_BOTTOM - 4.0f - i), TheText.Get("FEDS_TB"));
if (m_nHoverOption == HOVEROPTION_BACK)
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
else
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
}
@@ -2730,12 +2738,12 @@ CMenuManager::DrawFrontEndNormal()
CFont::SetScale(MENU_X(0.35f), MENU_Y(0.7f));
CFont::SetRightJustifyOff();
if (hoveredBottomBarOption == i && hoveredBottomBarOption != curBottomBarOption)
- CFont::SetColor(CRGBA(235, 170, 50, 255));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, 255));
else {
if(bottomBarActive || curBottomBarOption == i)
- CFont::SetColor(CRGBA(0, 0, 0, 255));
+ CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, 255));
else
- CFont::SetColor(CRGBA(0, 0, 0, 110));
+ CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, 110));
}
str = TheText.Get(bbNames[i].name);
@@ -2931,6 +2939,45 @@ CMenuManager::DrawFrontEndNormal()
}
}
+#ifdef RED_DELETE_BACKGROUND
+ if (m_nCurrScreen == MENUPAGE_CHOOSE_DELETE_SLOT || m_nCurrScreen == MENUPAGE_DELETE_SLOT_CONFIRM) {
+ CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(18.0f), MENU_Y(8.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(20.0f), MENU_Y(8.0f),
+ SCREEN_STRETCH_X(12.0f), MENU_Y(11.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), MENU_Y(11.0f),
+ CRGBA(150, 0, 0, 140));
+
+ CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(12.0f), MENU_Y(11.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), MENU_Y(11.0f),
+ SCREEN_STRETCH_X(10.0f), MENU_Y(16.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), MENU_Y(16.0f),
+ CRGBA(150, 0, 0, 140));
+
+ CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(10.0f), MENU_Y(16.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), MENU_Y(16.0f),
+ SCREEN_STRETCH_X(10.0f), SCREEN_SCALE_Y(431.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(431.0f),
+ CRGBA(150, 0, 0, 140));
+
+ CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(10.0f), SCREEN_SCALE_Y(431.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(431.0f),
+ SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(435.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), SCREEN_SCALE_Y(435.0f),
+ CRGBA(150, 0, 0, 140));
+
+ CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(435.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), SCREEN_SCALE_Y(435.0f),
+ SCREEN_STRETCH_X(18.0f), SCREEN_SCALE_Y(438.0f),
+ SCREEN_WIDTH - SCREEN_STRETCH_X(20.0f), SCREEN_SCALE_Y(438.0f),
+ CRGBA(150, 0, 0, 140));
+
+ // yellow bar
+ CSprite2d::DrawRect(CRect(MENU_X(13.0f), SCREEN_STRETCH_FROM_BOTTOM(96.0f),
+ SCREEN_STRETCH_FROM_RIGHT(11.0f), SCREEN_STRETCH_FROM_BOTTOM(59.0f)),
+ CRGBA(235, 170, 50, 255));
+ }
+#endif
+
// GTA LOGO
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
@@ -2987,17 +3034,9 @@ CMenuManager::DrawFrontEndNormal()
void
CMenuManager::DrawPlayerSetupScreen()
{
- CFont::SetBackgroundOff();
- CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
- CFont::SetPropOn();
- CFont::SetCentreOff();
- CFont::SetJustifyOn();
- CFont::SetRightJustifyOff();
- CFont::SetBackGroundOnlyTextOn();
- CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
- CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+ RESET_FONT_FOR_NEW_PAGE
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS"));
@@ -3085,13 +3124,14 @@ CMenuManager::DrawPlayerSetupScreen()
m_bSkinsEnumerated = true;
}
CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(PLAYERSETUP_LIST_LEFT), MENU_Y(PLAYERSETUP_LIST_TOP),
- MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT), SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM)), CRGBA(200, 200, 50, FadeIn(50)));
+ MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT), SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM)),
+ CRGBA(LIST_BACKGROUND_COLOR.r, LIST_BACKGROUND_COLOR.g, LIST_BACKGROUND_COLOR.b, FadeIn(LIST_BACKGROUND_COLOR.a)));
// Header (Skin - Date)
if (m_nCurrExLayer == HOVEROPTION_LIST) {
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
} else {
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
@@ -3110,9 +3150,7 @@ CMenuManager::DrawPlayerSetupScreen()
CFont::PrintString(MENU_X_LEFT_ALIGNED(PLAYERSETUP_SKIN_COLUMN_LEFT), MENU_Y(PLAYERSETUP_LIST_TOP), TheText.Get("FES_SKN"));
// Skin list
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(PLAYERSETUP_ROW_TEXT_X_SCALE), MENU_Y(PLAYERSETUP_ROW_TEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
if (m_nSkinsTotal > 0) {
for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin->skinId != m_nFirstVisibleRowOnList;
m_pSelectedSkin = m_pSelectedSkin->nextSkin);
@@ -3161,7 +3199,7 @@ CMenuManager::DrawPlayerSetupScreen()
} else if (!strcmp(m_PrefsSkinFile, m_pSelectedSkin->skinNameOriginal)) {
CFont::SetColor(CRGBA(255, 255, 155, FadeIn(255)));
} else {
- CFont::SetColor(CRGBA(155, 155, 155, FadeIn(255)));
+ CFont::SetColor(CRGBA(LIST_OPTION_COLOR.r, LIST_OPTION_COLOR.g, LIST_OPTION_COLOR.b, FadeIn(LIST_OPTION_COLOR.a)));
}
wchar unicodeTemp[80];
AsciiToUnicode(m_pSelectedSkin->skinNameDisplayed, unicodeTemp);
@@ -3213,7 +3251,7 @@ CMenuManager::DrawPlayerSetupScreen()
// Scrollbar
CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT - 4), scrollbarTop,
MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT - PLAYERSETUP_SCROLLBAR_WIDTH), scrollbarBottom),
- CRGBA(235, 170, 50, FadeIn(255)));
+ CRGBA(SCROLLBAR_COLOR.r, SCROLLBAR_COLOR.g, SCROLLBAR_COLOR.b, FadeIn(255)));
// FIX: Scroll button dimensions are buggy, because:
// 1 - stretches the original image
@@ -3282,7 +3320,7 @@ CMenuManager::DrawPlayerSetupScreen()
CFont::SetScale(MENU_X(1.9f), MENU_Y(1.9f));
break;
}
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(120)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(120)));
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(20.0f), MENU_Y(220.0f), TheText.Get("FET_APL"));
}
@@ -3373,9 +3411,9 @@ CMenuManager::DrawPlayerSetupScreen()
for (int i = 0; i < 2; i++) {
CFont::PrintString(MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT - 3 - i), SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM - 5 - i), TheText.Get("FEDS_TB"));
if (m_nHoverOption == HOVEROPTION_BACK) {
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
} else {
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
}
CFont::SetRightJustifyOff();
@@ -3385,11 +3423,11 @@ CMenuManager::DrawPlayerSetupScreen()
for (int i = 0; i < 2; i++) {
CFont::PrintString(MENU_X_LEFT_ALIGNED(i + PLAYERSETUP_LIST_LEFT), SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM - 5 - i), TheText.Get("FES_SET"));
if (!strcmp(m_aSkinName, m_PrefsSkinFile)) {
- CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255)));
+ CFont::SetColor(CRGBA(DARKMENUOPTION_COLOR.r, DARKMENUOPTION_COLOR.g, DARKMENUOPTION_COLOR.b, FadeIn(255)));
} else if (m_nHoverOption == HOVEROPTION_USESKIN) {
- CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
} else {
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
}
}
@@ -3568,6 +3606,9 @@ CMenuManager::LoadAllTextures()
m_aMapSprites[i].SetTexture(MapFilenames[i][0], MapFilenames[i][1]);
m_aMapSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER);
}
+ fMapSize = SCREEN_HEIGHT * 2.0f;
+ fMapCenterX = 0.0f;
+ fMapCenterY = 0.0f;
#endif
#if GTA_VERSION >= GTA3_PC_11
CStreaming::IHaveUsedStreamingMemory();
@@ -3781,7 +3822,7 @@ CMenuManager::MessageScreen(const char *text)
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetCentreSize(SCREEN_SCALE_X(380.0f));
CFont::SetCentreOn();
- CFont::SetColor(CRGBA(255, 217, 106, 255));
+ CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, 255));
CFont::SetScale(SCREEN_SCALE_X(SMALLTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLTEXT_Y_SCALE));
CFont::PrintString(StretchX(320.0f), StretchY(170.0f), TheText.Get(text));
CFont::DrawFonts();
@@ -3807,7 +3848,7 @@ CMenuManager::PickNewPlayerColour()
void
CMenuManager::PrintBriefs()
{
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
@@ -3825,19 +3866,14 @@ CMenuManager::PrintBriefs()
CMessages::InsertPlayerControlKeysInString(gUString);
newColor = TEXT_COLOR;
FilterOutColorMarkersFromString(gUString, newColor);
-
-#ifdef PS2_LIKE_MENU
- // This PS2 code was always here, but unused
- bool rgSame = newColor.r == TEXT_COLOR.r && newColor.g == TEXT_COLOR.g;
- bool bSame = rgSame && newColor.b == TEXT_COLOR.b;
- bool colorNotChanged = bSame; /* && newColor.a == TEXT_COLOR.a; */
-
- if (!colorNotChanged) {
+ if (newColor != TEXT_COLOR) {
newColor.r /= 2;
newColor.g /= 2;
newColor.b /= 2;
}
- CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); // But this is from PS2
+
+#ifdef PS2_LIKE_MENU
+ CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255)));
CFont::SetDropShadowPosition(1);
#endif
@@ -3931,7 +3967,7 @@ CMenuManager::PrintStats()
} else
alphaMult = 1.0f;
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255.0f * alphaMult)));
+ CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255.0f * alphaMult)));
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(STATS_ROW_X_MARGIN), y - MENU_Y(STATS_BOTTOM_MARGIN - STATS_TOP_MARGIN), gUString);
CFont::SetRightJustifyOn();
@@ -3941,7 +3977,7 @@ CMenuManager::PrintStats()
// Game doesn't do that, but it's better
float nextX = MENU_X_LEFT_ALIGNED(STATS_RATING_X);
- CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
+ CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
CFont::SetRightJustifyOff();
CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA"));
#ifdef MORE_LANGUAGES
@@ -3964,7 +4000,7 @@ CMenuManager::PrintStats()
// ::Draw already does that.
/*
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
*/
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y));
@@ -4779,12 +4815,6 @@ CMenuManager::ProcessButtonPresses(void)
break;
#endif
} else {
-#ifdef MENU_MAP
- if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == MENUPAGE_MAP) {
- bMapLoaded = false;
- }
-
-#endif
ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true);
}
}
@@ -5135,7 +5165,7 @@ CMenuManager::ProcessButtonPresses(void)
increase = true;
} else if (
#ifdef SCROLLABLE_PAGES
- !(m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen)) &&
+ !SCREEN_HAS_AUTO_SCROLLBAR &&
#endif
CPad::GetPad(0)->GetMouseWheelUpJustDown() && m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) {
increase = true;
@@ -5148,7 +5178,7 @@ CMenuManager::ProcessButtonPresses(void)
decrease = true;
} else if (
#ifdef SCROLLABLE_PAGES
- !(m_nTotalListRow > MAX_VISIBLE_OPTION && !hasNativeList(m_nCurrScreen)) &&
+ !SCREEN_HAS_AUTO_SCROLLBAR &&
#endif
CPad::GetPad(0)->GetMouseWheelDownJustDown() && m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) {
decrease = true;
@@ -5855,26 +5885,14 @@ CMenuManager::PrintMap(void)
bMenuMapActive = true;
CRadar::InitFrontEndMap();
- // Just entered to map
- if (!bMapLoaded) {
- fMapSize = SCREEN_HEIGHT * 2.0f;
- fMapCenterX = 0.0f;
- fMapCenterY = 0.0f;
+ if (m_nMenuFadeAlpha < 255 && fMapCenterX == 0.f && fMapCenterY == 0.f) {
+ // Just entered. We need to do these transformations in here, because Radar knows whether map is active or not
CVector2D radarSpacePlayer;
CVector2D screenSpacePlayer;
CRadar::TransformRealWorldPointToRadarSpace(radarSpacePlayer, CVector2D(FindPlayerCoors()));
CRadar::TransformRadarPointToScreenSpace(screenSpacePlayer, radarSpacePlayer);
-
fMapCenterX = (-screenSpacePlayer.x) + SCREEN_WIDTH / 2;
fMapCenterY = (-screenSpacePlayer.y) + SCREEN_HEIGHT / 2;
- bMapMouseShownOnce = false;
- bMapLoaded = true;
-
- // Let's wait for a frame to not toggle the waypoint
- if (CPad::GetPad(0)->NewState.Cross) {
- bMenuMapActive = false;
- return;
- }
}
// Because fMapSize is half of the map length, and map consists of 3x3 tiles.
@@ -5933,34 +5951,35 @@ CMenuManager::PrintMap(void)
}
CRadar::DrawBlips();
+ static CVector2D mapCrosshair;
- CVector2D mapPoint;
- mapPoint.x = m_nMousePosX;
- mapPoint.y = m_nMousePosY;
-
- if (m_bShowMouse) {
- bMapMouseShownOnce = true;
- } else if (!bMapMouseShownOnce) {
- mapPoint.x = SCREEN_WIDTH / 2;
- mapPoint.y = SCREEN_HEIGHT / 2;
+ if (m_nMenuFadeAlpha != 255 && !m_bShowMouse) {
+ mapCrosshair.x = SCREEN_WIDTH / 2;
+ mapCrosshair.y = SCREEN_HEIGHT / 2;
+ } else if (m_bShowMouse) {
+ mapCrosshair.x = m_nMousePosX;
+ mapCrosshair.y = m_nMousePosY;
}
- CSprite2d::DrawRect(CRect(mapPoint.x - MENU_X(1.0f), 0.0f,
- mapPoint.x + MENU_X(1.0f), SCREEN_HEIGHT),
+ CSprite2d::DrawRect(CRect(mapCrosshair.x - MENU_X(1.0f), 0.0f,
+ mapCrosshair.x + MENU_X(1.0f), SCREEN_HEIGHT),
CRGBA(0, 0, 0, 150));
- CSprite2d::DrawRect(CRect(0.0f, mapPoint.y + MENU_X(1.0f),
- SCREEN_WIDTH, mapPoint.y - MENU_X(1.0f)),
+ CSprite2d::DrawRect(CRect(0.0f, mapCrosshair.y + MENU_X(1.0f),
+ SCREEN_WIDTH, mapCrosshair.y - MENU_X(1.0f)),
CRGBA(0, 0, 0, 150));
- if (CPad::GetPad(0)->GetRightMouseJustDown() || CPad::GetPad(0)->GetCrossJustDown()) {
- if (mapPoint.y > fMapCenterY - fMapSize && mapPoint.y < fMapCenterY + fMapSize &&
- mapPoint.x > fMapCenterX - fMapSize && mapPoint.x < fMapCenterX + fMapSize) {
+ // Adding marker
+ if (m_nMenuFadeAlpha >= 255) {
+ if (CPad::GetPad(0)->GetRightMouseJustDown() || CPad::GetPad(0)->GetCrossJustDown()) {
+ if (mapCrosshair.y > fMapCenterY - fMapSize && mapCrosshair.y < fMapCenterY + fMapSize &&
+ mapCrosshair.x > fMapCenterX - fMapSize && mapCrosshair.x < fMapCenterX + fMapSize) {
- float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize;
- float x = ((mapPoint.x - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f;
- float y = 2000.0f - ((mapPoint.y - diffY) / (fMapSize * 2)) * 4000.0f;
- CRadar::ToggleTargetMarker(x, y);
- DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
+ float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize;
+ float x = ((mapCrosshair.x - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f;
+ float y = 2000.0f - ((mapCrosshair.y - diffY) / (fMapSize * 2)) * 4000.0f;
+ CRadar::ToggleTargetMarker(x, y);
+ DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
+ }
}
}
@@ -5985,12 +6004,12 @@ CMenuManager::PrintMap(void)
if (CPad::GetPad(0)->GetMouseWheelDown() || CPad::GetPad(0)->GetPageDown() || CPad::GetPad(0)->GetRightShoulder2()) {
if (CPad::GetPad(0)->GetMouseWheelDown())
- ZOOM(mapPoint.x, mapPoint.y, false);
+ ZOOM(mapCrosshair.x, mapCrosshair.y, false);
else
ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, false);
} else if (CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetPageUp() || CPad::GetPad(0)->GetRightShoulder1()) {
if (CPad::GetPad(0)->GetMouseWheelUp())
- ZOOM(mapPoint.x, mapPoint.y, true);
+ ZOOM(mapCrosshair.x, mapCrosshair.y, true);
else
ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, true);
}
@@ -6008,16 +6027,13 @@ CMenuManager::PrintMap(void)
bMenuMapActive = false;
- // CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(5.0f)); // From VC
- // CFont::SetRightJustifyWrap(10.0f);
-
CSprite2d::DrawRect(CRect(MENU_X(14.0f), SCREEN_STRETCH_FROM_BOTTOM(95.0f),
SCREEN_STRETCH_FROM_RIGHT(11.0f), SCREEN_STRETCH_FROM_BOTTOM(59.0f)),
CRGBA(235, 170, 50, 255));
CFont::SetScale(MENU_X(0.4f), MENU_Y(0.7f));
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
- CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
+ CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, FadeIn(255)));
float nextX = MENU_X(30.0f), nextY = 95.0f;
wchar *text;
@@ -6062,108 +6078,157 @@ CMenuManager::PrintMap(void)
int
CMenuManager::ConstructStatLine(int rowIdx)
{
-#define STAT_LINE(str, left, isFloat, right) \
+#define int_STAT_IS_FLOAT false
+#define float_STAT_IS_FLOAT true
+#define STAT_LINE_1(varType, left, right1) \
do { \
if(counter == rowIdx){ \
- BuildStatLine(str, left, isFloat, right); \
+ varType a = right1; \
+ BuildStatLine(left, &a, varType##_STAT_IS_FLOAT, nil); \
return 0; \
} counter++; \
} while(0)
- int counter = 0, nTemp;
+#define STAT_LINE_2(varType, left, right1, right2) \
+ do { \
+ if(counter == rowIdx){ \
+ varType a = right1; \
+ varType b = right2; \
+ BuildStatLine(left, &a, varType##_STAT_IS_FLOAT, &b); \
+ return 0; \
+ } counter++; \
+ } while(0)
- STAT_LINE("PL_STAT", nil, false, nil);
+#define TEXT_ON_LEFT_GXT(name) \
+ do { \
+ if(counter == rowIdx){ \
+ BuildStatLine(name, nil, false, nil); \
+ return 0; \
+ } counter++; \
+ } while(0)
+
+#define TEXT_ON_RIGHT(text) \
+ do { \
+ if(counter == rowIdx){ \
+ gUString[0] = '\0'; \
+ UnicodeStrcpy(gUString2, text); \
+ return 0; \
+ } counter++; \
+ } while(0)
+
+ // Like TEXT_ON_LEFT_GXT, but counter wasn't initialized yet I think
+ if (rowIdx == 0) {
+ BuildStatLine("PL_STAT", nil, false, nil);
+ return 0;
+ }
int percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 :
CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1));
percentCompleted = Min(percentCompleted, 100);
- STAT_LINE("PER_COM", &percentCompleted, false, nil);
- STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil);
- STAT_LINE("FEST_MP", &CStats::MissionsPassed, false, &CStats::TotalNumberMissions);
- if (CGame::nastyGame) {
- STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, false, &CStats::TotalNumberKillFrenzies);
+ switch (rowIdx) {
+ // 0 is the heading text above
+ case 1: {
+ BuildStatLine("PER_COM", &percentCompleted, false, nil);
+ return 0;
+ }
+ case 2: {
+ BuildStatLine("NMISON", &CStats::MissionsGiven, false, nil);
+ return 0;
+ }
+ case 3: {
+ BuildStatLine("FEST_MP", &CStats::MissionsPassed, false, &CStats::TotalNumberMissions);
+ return 0;
+ }
}
+ int counter = 4;
+
+ if (CGame::nastyGame)
+ STAT_LINE_2(int, "FEST_RP", CStats::NumberKillFrenziesPassed, CStats::TotalNumberKillFrenzies);
CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus];
+
+ // Hidden packages shouldn't be shown with percent
+#ifdef FIX_BUGS
+ STAT_LINE_2(int, "PERPIC", player.m_nCollectedPackages, player.m_nTotalPackages);
+#else
float packagesPercent = 0.0f;
if (player.m_nTotalPackages != 0)
packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages;
- int nPackagesPercent = packagesPercent;
- STAT_LINE("PERPIC", &nPackagesPercent, false, &(nTemp = 100));
- STAT_LINE("NOUNIF", &CStats::NumberOfUniqueJumpsFound, false, &CStats::TotalNumberOfUniqueJumps);
- STAT_LINE("DAYSPS", &CStats::DaysPassed, false, nil);
+ STAT_LINE_2(int, "PERPIC", packagesPercent, 100);
+#endif
+ STAT_LINE_2(int, "NOUNIF", CStats::NumberOfUniqueJumpsFound, CStats::TotalNumberOfUniqueJumps);
+ STAT_LINE_1(int, "DAYSPS", CStats::DaysPassed);
if (CGame::nastyGame) {
- STAT_LINE("PE_WAST", &CStats::PeopleKilledByPlayer, false, nil);
- STAT_LINE("PE_WSOT", &CStats::PeopleKilledByOthers, false, nil);
+ STAT_LINE_1(int, "PE_WAST", CStats::PeopleKilledByPlayer);
+ STAT_LINE_1(int, "PE_WSOT", CStats::PeopleKilledByOthers);
}
- STAT_LINE("CAR_EXP", &CStats::CarsExploded, false, nil);
- STAT_LINE("TM_BUST", &CStats::TimesArrested, false, nil);
- STAT_LINE("TM_DED", &CStats::TimesDied, false, nil);
- STAT_LINE("GNG_WST", &(nTemp = CStats::PedsKilledOfThisType[PEDTYPE_GANG9] + CStats::PedsKilledOfThisType[PEDTYPE_GANG8]
+ STAT_LINE_1(int, "CAR_EXP", CStats::CarsExploded);
+ STAT_LINE_1(int, "TM_BUST", CStats::TimesArrested);
+ STAT_LINE_1(int, "TM_DED", CStats::TimesDied);
+ STAT_LINE_1(int, "GNG_WST", CStats::PedsKilledOfThisType[PEDTYPE_GANG9] + CStats::PedsKilledOfThisType[PEDTYPE_GANG8]
+ CStats::PedsKilledOfThisType[PEDTYPE_GANG7] + CStats::PedsKilledOfThisType[PEDTYPE_GANG6]
+ CStats::PedsKilledOfThisType[PEDTYPE_GANG5] + CStats::PedsKilledOfThisType[PEDTYPE_GANG4]
+ CStats::PedsKilledOfThisType[PEDTYPE_GANG3] + CStats::PedsKilledOfThisType[PEDTYPE_GANG2]
- + CStats::PedsKilledOfThisType[PEDTYPE_GANG1]), false, nil);
- STAT_LINE("DED_CRI", &(nTemp = CStats::PedsKilledOfThisType[PEDTYPE_CRIMINAL]), false, nil);
- STAT_LINE("HEL_DST", &CStats::HelisDestroyed, false, nil);
- STAT_LINE("KGS_EXP", &CStats::KgsOfExplosivesUsed, false, nil);
- STAT_LINE("ACCURA", &(nTemp = (CStats::InstantHitsFiredByPlayer == 0 ? 0 :
- CStats::InstantHitsHitByPlayer * 100.0f / CStats::InstantHitsFiredByPlayer)), false, nil);
+ + CStats::PedsKilledOfThisType[PEDTYPE_GANG1]);
+ STAT_LINE_1(int, "DED_CRI", CStats::PedsKilledOfThisType[PEDTYPE_CRIMINAL]);
+ STAT_LINE_1(int, "HEL_DST", CStats::HelisDestroyed);
+ STAT_LINE_1(int, "KGS_EXP", CStats::KgsOfExplosivesUsed);
+ STAT_LINE_1(int, "ACCURA", (CStats::InstantHitsFiredByPlayer == 0 ? 0 :
+ CStats::InstantHitsHitByPlayer * 100.0f / CStats::InstantHitsFiredByPlayer));
if (CStats::ElBurroTime > 0) {
- STAT_LINE("ELBURRO", &CStats::ElBurroTime, false, nil);
+ STAT_LINE_1(int, "ELBURRO", CStats::ElBurroTime);
}
if (CStats::Record4x4One > 0) {
- STAT_LINE("FEST_R1", &CStats::Record4x4One, false, nil);
+ STAT_LINE_1(int, "FEST_R1", CStats::Record4x4One);
}
if (CStats::Record4x4Two > 0) {
- STAT_LINE("FEST_R2", &CStats::Record4x4Two, false, nil);
+ STAT_LINE_1(int, "FEST_R2", CStats::Record4x4Two);
}
if (CStats::Record4x4Three > 0) {
- STAT_LINE("FEST_R3", &CStats::Record4x4Three, false, nil);
+ STAT_LINE_1(int, "FEST_R3", CStats::Record4x4Three);
}
if (CStats::Record4x4Mayhem > 0) {
- STAT_LINE("FEST_RM", &CStats::Record4x4Mayhem, false, nil);
+ STAT_LINE_1(int, "FEST_RM", CStats::Record4x4Mayhem);
}
if (CStats::LongestFlightInDodo > 0) {
- STAT_LINE("FEST_LF", &CStats::LongestFlightInDodo, false, nil);
+ STAT_LINE_1(int, "FEST_LF", CStats::LongestFlightInDodo);
}
if (CStats::TimeTakenDefuseMission > 0) {
- STAT_LINE("FEST_BD", &CStats::TimeTakenDefuseMission, false, nil);
+ STAT_LINE_1(int, "FEST_BD", CStats::TimeTakenDefuseMission);
}
- STAT_LINE("CAR_CRU", &CStats::CarsCrushed, false, nil);
+ STAT_LINE_1(int, "CAR_CRU", CStats::CarsCrushed);
if (CStats::HighestScores[0] > 0) {
- STAT_LINE("FEST_BB", nil, false, nil);
- STAT_LINE("FEST_H0", &CStats::HighestScores[0], false, nil);
+ TEXT_ON_LEFT_GXT("FEST_BB");
+ STAT_LINE_1(int, "FEST_H0", CStats::HighestScores[0]);
}
if (CStats::HighestScores[4] + CStats::HighestScores[3] + CStats::HighestScores[2] + CStats::HighestScores[1] > 0) {
- STAT_LINE("FEST_GC", nil, false, nil);
+ TEXT_ON_LEFT_GXT("FEST_GC");
}
if (CStats::HighestScores[1] > 0) {
- STAT_LINE("FEST_H1", &CStats::HighestScores[1], false, nil);
+ STAT_LINE_1(int, "FEST_H1", CStats::HighestScores[1]);
}
if (CStats::HighestScores[2] > 0) {
- STAT_LINE("FEST_H2", &CStats::HighestScores[2], false, nil);
+ STAT_LINE_1(int, "FEST_H2", CStats::HighestScores[2]);
}
if (CStats::HighestScores[3] > 0) {
- STAT_LINE("FEST_H3", &CStats::HighestScores[3], false, nil);
+ STAT_LINE_1(int, "FEST_H3", CStats::HighestScores[3]);
}
if (CStats::HighestScores[4] > 0) {
- STAT_LINE("FEST_H4", &CStats::HighestScores[4], false, nil);
+ STAT_LINE_1(int, "FEST_H4", CStats::HighestScores[4]);
}
switch (m_PrefsLanguage) {
case LANGUAGE_AMERICAN:
#ifndef USE_MEASUREMENTS_IN_METERS
- float fTemp;
- STAT_LINE("FEST_DF", &(fTemp = CStats::DistanceTravelledOnFoot * MILES_IN_METER), true, nil);
- STAT_LINE("FEST_DC", &(fTemp = CStats::DistanceTravelledInVehicle * MILES_IN_METER), true, nil);
- STAT_LINE("MMRAIN", &CStats::mmRain, false, nil);
- STAT_LINE("MXCARD", &(fTemp = CStats::MaximumJumpDistance * FEET_IN_METER), true, nil);
- STAT_LINE("MXCARJ", &(fTemp = CStats::MaximumJumpHeight * FEET_IN_METER), true, nil);
+ STAT_LINE_1(float, "FEST_DF", CStats::DistanceTravelledOnFoot * MILES_IN_METER);
+ STAT_LINE_1(float, "FEST_DC", CStats::DistanceTravelledInVehicle * MILES_IN_METER);
+ STAT_LINE_1(int, "MMRAIN", CStats::mmRain);
+ STAT_LINE_1(float, "MXCARD", CStats::MaximumJumpDistance * FEET_IN_METER);
+ STAT_LINE_1(float, "MXCARJ", CStats::MaximumJumpHeight * FEET_IN_METER);
break;
#endif
case LANGUAGE_FRENCH:
@@ -6175,63 +6240,65 @@ CMenuManager::ConstructStatLine(int rowIdx)
case LANGUAGE_RUSSIAN:
case LANGUAGE_JAPANESE:
#endif
- STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, true, nil);
- STAT_LINE("FESTDCM", &CStats::DistanceTravelledInVehicle, true, nil);
- STAT_LINE("MMRAIN", &CStats::mmRain, false, nil);
- STAT_LINE("MXCARDM", &CStats::MaximumJumpDistance, true, nil);
- STAT_LINE("MXCARJM", &CStats::MaximumJumpHeight, true, nil);
+ STAT_LINE_1(float, "FESTDFM", CStats::DistanceTravelledOnFoot);
+ STAT_LINE_1(float, "FESTDCM", CStats::DistanceTravelledInVehicle);
+ STAT_LINE_1(int, "MMRAIN", CStats::mmRain);
+ STAT_LINE_1(float, "MXCARDM", CStats::MaximumJumpDistance);
+ STAT_LINE_1(float, "MXCARJM", CStats::MaximumJumpHeight);
break;
default:
break;
}
- STAT_LINE("MXFLIP", &CStats::MaximumJumpFlips, false, nil);
- STAT_LINE("MXJUMP", &CStats::MaximumJumpSpins, false, nil);
- STAT_LINE("BSTSTU", nil, false, nil);
+ STAT_LINE_1(int, "MXFLIP", CStats::MaximumJumpFlips);
+ STAT_LINE_1(int, "MXJUMP", CStats::MaximumJumpSpins);
+ TEXT_ON_LEFT_GXT("BSTSTU");
- if (counter == rowIdx) {
- gUString[0] = '\0';
- switch (CStats::BestStuntJump) {
- case 1:
- UnicodeStrcpy(gUString2, TheText.Get("INSTUN"));
- return 0;
- case 2:
- UnicodeStrcpy(gUString2, TheText.Get("PRINST"));
- return 0;
- case 3:
- UnicodeStrcpy(gUString2, TheText.Get("DBINST"));
- return 0;
- case 4:
- UnicodeStrcpy(gUString2, TheText.Get("DBPINS"));
- return 0;
- case 5:
- UnicodeStrcpy(gUString2, TheText.Get("TRINST"));
- return 0;
- case 6:
- UnicodeStrcpy(gUString2, TheText.Get("PRTRST"));
- return 0;
- case 7:
- UnicodeStrcpy(gUString2, TheText.Get("QUINST"));
- return 0;
- case 8:
- UnicodeStrcpy(gUString2, TheText.Get("PQUINS"));
- return 0;
- default:
- UnicodeStrcpy(gUString2, TheText.Get("NOSTUC"));
- return 0;
- }
+ switch (CStats::BestStuntJump) {
+ case 1:
+ TEXT_ON_RIGHT(TheText.Get("INSTUN"));
+ break;
+ case 2:
+ TEXT_ON_RIGHT(TheText.Get("PRINST"));
+ break;
+ case 3:
+ TEXT_ON_RIGHT(TheText.Get("DBINST"));
+ break;
+ case 4:
+ TEXT_ON_RIGHT(TheText.Get("DBPINS"));
+ break;
+ case 5:
+ TEXT_ON_RIGHT(TheText.Get("TRINST"));
+ break;
+ case 6:
+ TEXT_ON_RIGHT(TheText.Get("PRTRST"));
+ break;
+ case 7:
+ TEXT_ON_RIGHT(TheText.Get("QUINST"));
+ break;
+ case 8:
+ TEXT_ON_RIGHT(TheText.Get("PQUINS"));
+ break;
+ default:
+ TEXT_ON_RIGHT(TheText.Get("NOSTUC"));
+ break;
}
- counter++;
- STAT_LINE("PASDRO", &CStats::PassengersDroppedOffWithTaxi, false, nil);
- STAT_LINE("MONTAX", &CStats::MoneyMadeWithTaxi, false, nil);
- STAT_LINE("FEST_LS", &CStats::LivesSavedWithAmbulance, false, nil);
- STAT_LINE("FEST_HA", &CStats::HighestLevelAmbulanceMission, false, nil);
- STAT_LINE("FEST_CC", &CStats::CriminalsCaught, false, nil);
- STAT_LINE("FEST_FE", &CStats::FiresExtinguished, false, nil);
- STAT_LINE("DAYPLC", &(nTemp = CTimer::GetTimeInMilliseconds() + 100), false, nil);
+
+ STAT_LINE_1(int, "PASDRO", CStats::PassengersDroppedOffWithTaxi);
+ STAT_LINE_1(int, "MONTAX", CStats::MoneyMadeWithTaxi);
+ STAT_LINE_1(int, "FEST_LS", CStats::LivesSavedWithAmbulance);
+ STAT_LINE_1(int, "FEST_HA", CStats::HighestLevelAmbulanceMission);
+ STAT_LINE_1(int, "FEST_CC", CStats::CriminalsCaught);
+ STAT_LINE_1(int, "FEST_FE", CStats::FiresExtinguished);
+ STAT_LINE_1(int, "DAYPLC", CTimer::GetTimeInMilliseconds() + 100);
return counter;
-#undef STAT_LINE
+#undef STAT_LINE_1
+#undef STAT_LINE_2
+#undef TEXT_ON_LEFT_GXT
+#undef TEXT_ON_RIGHT
+#undef int_STAT_IS_FLOAT
+#undef float_STAT_IS_FLOAT
}
#undef GetBackJustUp
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 21124fdb..8cf3dd28 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -25,15 +25,18 @@
#define MENUSLIDER_X 256.0f
#define MENUSLIDER_UNK 256.0f
-#define BIGTEXT_X_SCALE 0.75f
+#define BIGTEXT_X_SCALE 0.75f // For FONT_HEADING
#define BIGTEXT_Y_SCALE 0.9f
-#define MEDIUMTEXT_X_SCALE 0.55f
+#define MEDIUMTEXT_X_SCALE 0.55f // For FONT_HEADING
#define MEDIUMTEXT_Y_SCALE 0.8f
-#define SMALLTEXT_X_SCALE 0.45f
+#define SMALLTEXT_X_SCALE 0.45f // used for FONT_HEADING and FONT_BANK, but looks off for HEADING
#define SMALLTEXT_Y_SCALE 0.7f
-#define SMALLESTTEXT_X_SCALE 0.4f
+#define SMALLESTTEXT_X_SCALE 0.4f // used for both FONT_HEADING and FONT_BANK
#define SMALLESTTEXT_Y_SCALE 0.6f
+#define HELPER_TEXT_LEFT_MARGIN 320.0f
+#define HELPER_TEXT_BOTTOM_MARGIN 120.0f
+
#define PLAYERSETUP_LIST_TOP 28.0f
#define PLAYERSETUP_LIST_BOTTOM 125.0f
#define PLAYERSETUP_LIST_LEFT 200.0f
@@ -45,8 +48,6 @@
#endif
#define PLAYERSETUP_SCROLLBUTTON_HEIGHT 17.0f
#define PLAYERSETUP_SCROLLBUTTON_TXD_DIMENSION 64
-#define PLAYERSETUP_ROW_TEXT_X_SCALE 0.4f
-#define PLAYERSETUP_ROW_TEXT_Y_SCALE 0.6f
#define PLAYERSETUP_SKIN_COLUMN_LEFT 220.0f
#define PLAYERSETUP_DATE_COLUMN_RIGHT 56.0f
#define PLAYERSETUP_LIST_BODY_TOP 47
@@ -241,8 +242,6 @@ enum eMenuScreen
#ifdef GRAPHICS_MENU_OPTIONS
MENUPAGE_GRAPHICS_SETTINGS,
-#else
- MENUPAGE_ADVANCED_DISPLAY_SETTINGS,
#endif
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
MENUPAGE_DETECT_JOYSTICK,
@@ -697,8 +696,6 @@ public:
#ifdef MENU_MAP
static bool bMenuMapActive;
- static bool bMapMouseShownOnce;
- static bool bMapLoaded;
static float fMapSize;
static float fMapCenterY;
static float fMapCenterX;
diff --git a/src/core/Game.h b/src/core/Game.h
index 46e8fc68..b55793af 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -5,7 +5,8 @@ enum eLevelName {
LEVEL_GENERIC = 0,
LEVEL_INDUSTRIAL,
LEVEL_COMMERCIAL,
- LEVEL_SUBURBAN
+ LEVEL_SUBURBAN,
+ NUM_LEVELS
};
class CGame
diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp
index ae08f5f5..3a6d9c8b 100644
--- a/src/core/MenuScreensCustom.cpp
+++ b/src/core/MenuScreensCustom.cpp
@@ -399,7 +399,12 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
VIDEOMODE_SELECTOR
MULTISAMPLING_SELECTOR
- MENUACTION_CHANGEMENU, "FET_ADV", { nil, SAVESLOT_NONE, MENUPAGE_ADVANCED_DISPLAY_SETTINGS },
+ ISLAND_LOADING_SELECTOR
+ DUALPASS_SELECTOR
+ CUTSCENE_BORDERS_TOGGLE
+ FREE_CAM_TOGGLE
+ POSTFX_SELECTORS
+ PIPELINES_SELECTOR
MENUACTION_RESTOREDEF, "FET_DEF", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
@@ -829,31 +834,12 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
#else
MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#endif
-#ifdef EXTENDED_PIPELINES
PIPELINES_SELECTOR
-#endif
ISLAND_LOADING_SELECTOR
DUALPASS_SELECTOR
MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefGraphics) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
-#else
- // MENUPAGE_ADVANCED_DISPLAY_SETTINGS
- { "FET_ADV", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS,
- new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil,
-
- ISLAND_LOADING_SELECTOR
- DUALPASS_SELECTOR
- CUTSCENE_BORDERS_TOGGLE
- FREE_CAM_TOGGLE
-#ifdef EXTENDED_COLOURFILTER
- POSTFX_SELECTORS
-#endif
-#ifdef EXTENDED_PIPELINES
- PIPELINES_SELECTOR
-#endif
- MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
- },
#endif
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 09b3a499..07424736 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -3,6 +3,7 @@
#include "Automobile.h"
#include "Bridge.h"
#include "Camera.h"
+#include "CarCtrl.h"
#include "Cranes.h"
#include "Darkel.h"
#include "Explosion.h"
@@ -31,83 +32,6 @@
#include "ZoneCull.h"
#include "main.h"
-void
-CPlayerInfo::SetPlayerSkin(char *skin)
-{
- strncpy(m_aSkinName, skin, 32);
- LoadPlayerSkin();
-}
-
-const CVector &
-CPlayerInfo::GetPos()
-{
-#ifdef FIX_BUGS
- if (!m_pPed)
- return TheCamera.GetPosition();
-#endif
- if (m_pPed->InVehicle())
- return m_pPed->m_pMyVehicle->GetPosition();
- return m_pPed->GetPosition();
-}
-
-void
-CPlayerInfo::LoadPlayerSkin()
-{
- DeletePlayerSkin();
-
- m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
- if (!m_pSkinTexture)
- m_pSkinTexture = CPlayerSkin::GetSkinTexture(DEFAULT_SKIN_NAME);
-}
-
-void
-CPlayerInfo::DeletePlayerSkin()
-{
- if (m_pSkinTexture) {
- RwTextureDestroy(m_pSkinTexture);
- m_pSkinTexture = nil;
- }
-}
-
-void
-CPlayerInfo::KillPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
-
- m_WBState = WBSTATE_WASTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
- CStats::TimesDied++;
-}
-
-void
-CPlayerInfo::ArrestPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
-
- m_WBState = WBSTATE_BUSTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
- CStats::TimesArrested++;
-}
-
-bool
-CPlayerInfo::IsPlayerInRemoteMode()
-{
- return m_pRemoteVehicle || m_bInRemoteMode;
-}
-
-void
-CPlayerInfo::PlayerFailedCriticalMission()
-{
- if (m_WBState != WBSTATE_PLAYING)
- return;
- m_WBState = WBSTATE_FAILED_CRITICAL_MISSION;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
-}
void
CPlayerInfo::Clear(void)
@@ -147,197 +71,6 @@ CPlayerInfo::Clear(void)
}
void
-CPlayerInfo::BlowUpRCBuggy(void)
-{
- if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
- return;
-
- CRemote::TakeRemoteControlledCarFromPlayer();
- m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
-}
-
-void
-CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
-{
- if (!car || car == m_pPed->m_pMyVehicle) {
- if (m_pPed->EnteringCar())
- m_pPed->QuitEnteringCar();
- }
- if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
- m_pPed->ClearObjective();
-}
-
-void
-CPlayerInfo::MakePlayerSafe(bool toggle)
-{
- if (toggle) {
- CTheScripts::ResetCountdownToMakePlayerUnsafe();
- m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
- CWorld::StopAllLawEnforcersInTheirTracks();
- CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PLAYERINFO);
- CPad::StopPadsShaking();
- m_pPed->bBulletProof = true;
- m_pPed->bFireProof = true;
- m_pPed->bCollisionProof = true;
- m_pPed->bMeleeProof = true;
- m_pPed->bOnlyDamagedByPlayer = true;
- m_pPed->bExplosionProof = true;
- m_pPed->m_bCanBeDamaged = false;
- ((CPlayerPed*)m_pPed)->ClearAdrenaline();
- CancelPlayerEnteringCars(nil);
- gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
- CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
- CProjectileInfo::RemoveAllProjectiles();
- CWorld::SetAllCarsCanBeDamaged(false);
- CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
- CReplay::DisableReplays();
-
- } else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
- m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
- CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PLAYERINFO);
- m_pPed->bBulletProof = false;
- m_pPed->bFireProof = false;
- m_pPed->bCollisionProof = false;
- m_pPed->bMeleeProof = false;
- m_pPed->bOnlyDamagedByPlayer = false;
- m_pPed->bExplosionProof = false;
- m_pPed->m_bCanBeDamaged = true;
- CWorld::SetAllCarsCanBeDamaged(true);
- CReplay::EnableReplays();
- }
-}
-
-bool
-CPlayerInfo::IsRestartingAfterDeath()
-{
- return m_WBState == WBSTATE_WASTED;
-}
-
-bool
-CPlayerInfo::IsRestartingAfterArrest()
-{
- return m_WBState == WBSTATE_BUSTED;
-}
-
-// lastCloseness is passed to other calls of this function
-void
-CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
-{
- // This dist used for determining the angle to face
- CVector2D dist(carToTest->GetPosition() - player->GetPosition());
- float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
- while (neededTurn >= PI) {
- neededTurn -= 2 * PI;
- }
-
- while (neededTurn < -PI) {
- neededTurn += 2 * PI;
- }
-
- // This dist used for evaluating cars' distances, weird...
- // Accounts inverted needed turn (or needed turn in long way) and car dist.
- float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
- if (closeness > *lastCloseness) {
- *lastCloseness = closeness;
- *closestCarOutput = (CVehicle*)carToTest;
- }
-}
-
-// There is something unfinished in here... Sadly all IDBs we have have it unfinished.
-void
-CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
-{
- if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
- ++m_nExplosionsSinceLastReward;
- else
- m_nExplosionsSinceLastReward = 1;
-
- m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
- int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
- sprintf(gString, "$%d", award);
-#ifdef MONEY_MESSAGES
- // This line is a leftover from PS2, I don't know what it was meant to be.
- // CVector sth(TheCamera.GetPosition() * 4.0f);
-
- CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
-#endif
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
-
- for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
- CGeneral::GetRandomNumber();
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
- }
-}
-
-void
-CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
-{
- // Interesting
- *size = sizeof(CPlayerInfo);
-
-#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); buf += sizeof(data);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
-#undef CopyToBuf
-}
-
-void
-CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
-{
-#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); buf += sizeof(data);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName)
-#undef CopyFromBuf
-}
-
-void
-CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
-{
- for (CPtrNode* node = carList.first; node; node = node->next) {
- CVehicle *car = (CVehicle*)node->item;
- if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
- if (!car->bUsesCollision || !car->IsVehicle())
- continue;
-
- car->m_scanCode = CWorld::GetCurrentScanCode();
- if (car->GetStatus() != STATUS_WRECKED && car->GetStatus() != STATUS_TRAIN_MOVING
- && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
- CVector carCentre = car->GetBoundCentre();
-
- if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f) {
- float dist = (ped->GetPosition() - carCentre).Magnitude2D();
- if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
- EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
- }
- }
- }
- }
- }
-}
-
-void
CPlayerInfo::Process(void)
{
#ifdef FIX_BUGS
@@ -419,7 +152,7 @@ CPlayerInfo::Process(void)
if (found)
sth.z = 1.0f + groundZ;
- m_pPed->m_nPedState = PED_IDLE;
+ m_pPed->SetPedState(PED_IDLE);
m_pPed->SetMoveState(PEDMOVE_STILL);
CPed::PedSetOutCarCB(0, m_pPed);
CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
@@ -503,13 +236,13 @@ CPlayerInfo::Process(void)
uint32 timeWithoutRemoteCar = CTimer::GetTimeInMilliseconds() - m_nTimeLostRemoteCar;
if (CTimer::GetPreviousTimeInMilliseconds() - m_nTimeLostRemoteCar < 1000 && timeWithoutRemoteCar >= 1000 && m_WBState == WBSTATE_PLAYING) {
TheCamera.SetFadeColour(0, 0, 0);
- TheCamera.Fade(1.0f, 0);
+ TheCamera.Fade(1.0f, FADE_OUT);
}
if (timeWithoutRemoteCar > 2000) {
if (m_WBState == WBSTATE_PLAYING) {
TheCamera.RestoreWithJumpCut();
TheCamera.SetFadeColour(0, 0, 0);
- TheCamera.Fade(1.0f, 1);
+ TheCamera.Fade(1.0f, FADE_IN);
TheCamera.Process();
CTimer::Stop();
CCullZones::ForceCullZoneCoors(TheCamera.GetPosition());
@@ -560,3 +293,370 @@ CPlayerInfo::Process(void)
CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled;
}
}
+
+bool
+CPlayerInfo::IsPlayerInRemoteMode()
+{
+ return m_pRemoteVehicle || m_bInRemoteMode;
+}
+
+void
+CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
+{
+ // Interesting
+ *size = sizeof(CPlayerInfo);
+
+#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); buf += sizeof(data);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
+#undef CopyToBuf
+}
+
+void
+CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
+{
+#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); buf += sizeof(data);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName)
+#undef CopyFromBuf
+}
+
+void
+CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
+{
+ for (CPtrNode* node = carList.first; node; node = node->next) {
+ CVehicle *car = (CVehicle*)node->item;
+ if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
+ if (!car->bUsesCollision || !car->IsVehicle())
+ continue;
+
+ car->m_scanCode = CWorld::GetCurrentScanCode();
+ if (car->GetStatus() != STATUS_WRECKED && car->GetStatus() != STATUS_TRAIN_MOVING
+ && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
+ CVector carCentre = car->GetBoundCentre();
+
+ if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f) {
+ float dist = (ped->GetPosition() - carCentre).Magnitude2D();
+ if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
+ EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
+ }
+ }
+ }
+ }
+ }
+}
+
+// lastCloseness is passed to other calls of this function
+void
+CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
+{
+ // This dist used for determining the angle to face
+ CVector2D dist(carToTest->GetPosition() - player->GetPosition());
+ float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
+ while (neededTurn >= PI) {
+ neededTurn -= 2 * PI;
+ }
+
+ while (neededTurn < -PI) {
+ neededTurn += 2 * PI;
+ }
+
+ // This dist used for evaluating cars' distances, weird...
+ // Accounts inverted needed turn (or needed turn in long way) and car dist.
+ float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
+ if (closeness > *lastCloseness) {
+ *lastCloseness = closeness;
+ *closestCarOutput = (CVehicle*)carToTest;
+ }
+}
+
+const CVector &
+CPlayerInfo::GetPos()
+{
+#ifdef FIX_BUGS
+ if (!m_pPed)
+ return TheCamera.GetPosition();
+#endif
+ if (m_pPed->InVehicle())
+ return m_pPed->m_pMyVehicle->GetPosition();
+ return m_pPed->GetPosition();
+}
+
+CVector
+FindPlayerCoors(void)
+{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return TheCamera.GetPosition();
+#endif
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle->GetPosition();
+ else
+ return ped->GetPosition();
+}
+
+const CVector &
+FindPlayerSpeed(void)
+{
+#ifdef FIX_BUGS
+ static CVector vecTmpVector(0.0f, 0.0f, 0.0f);
+ if (CReplay::IsPlayingBack())
+ return vecTmpVector;
+#endif
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle->m_vecMoveSpeed;
+ else
+ return ped->m_vecMoveSpeed;
+}
+
+CVehicle *
+FindPlayerVehicle(void)
+{
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped && ped->InVehicle()) return ped->m_pMyVehicle;
+ return nil;
+}
+
+CEntity *
+FindPlayerEntity(void)
+{
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle;
+ else
+ return ped;
+}
+
+CVehicle *
+FindPlayerTrain(void)
+{
+ if(FindPlayerVehicle() && FindPlayerVehicle()->IsTrain())
+ return FindPlayerVehicle();
+ else
+ return nil;
+}
+
+CPlayerPed *
+FindPlayerPed(void)
+{
+ return CWorld::Players[CWorld::PlayerInFocus].m_pPed;
+}
+
+const CVector &
+FindPlayerCentreOfWorld(int32 player)
+{
+#ifdef FIX_BUGS
+ if(CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
+ if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
+ if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
+ return CWorld::Players[player].m_pPed->GetPosition();
+}
+
+const CVector &
+FindPlayerCentreOfWorld_NoSniperShift(void)
+{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
+ if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
+ if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
+ return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
+ return FindPlayerPed()->GetPosition();
+}
+
+float
+FindPlayerHeading(void)
+{
+ if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
+ return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetForward().Heading();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetForward().Heading();
+ return FindPlayerPed()->GetForward().Heading();
+}
+
+bool
+CPlayerInfo::IsRestartingAfterDeath()
+{
+ return m_WBState == WBSTATE_WASTED;
+}
+
+bool
+CPlayerInfo::IsRestartingAfterArrest()
+{
+ return m_WBState == WBSTATE_BUSTED;
+}
+
+void
+CPlayerInfo::KillPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_WASTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
+ CStats::TimesDied++;
+}
+
+void
+CPlayerInfo::ArrestPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_BUSTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
+ CStats::TimesArrested++;
+}
+
+void
+CPlayerInfo::PlayerFailedCriticalMission()
+{
+ if (m_WBState != WBSTATE_PLAYING)
+ return;
+ m_WBState = WBSTATE_FAILED_CRITICAL_MISSION;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+}
+
+void
+CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
+{
+ if (!car || car == m_pPed->m_pMyVehicle) {
+ if (m_pPed->EnteringCar())
+ m_pPed->QuitEnteringCar();
+ }
+ if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
+ m_pPed->ClearObjective();
+}
+
+void
+CPlayerInfo::MakePlayerSafe(bool toggle)
+{
+ if (toggle) {
+ CTheScripts::ResetCountdownToMakePlayerUnsafe();
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
+ CWorld::StopAllLawEnforcersInTheirTracks();
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PLAYERINFO);
+ CPad::StopPadsShaking();
+ m_pPed->bBulletProof = true;
+ m_pPed->bFireProof = true;
+ m_pPed->bCollisionProof = true;
+ m_pPed->bMeleeProof = true;
+ m_pPed->bOnlyDamagedByPlayer = true;
+ m_pPed->bExplosionProof = true;
+ m_pPed->m_bCanBeDamaged = false;
+ ((CPlayerPed*)m_pPed)->ClearAdrenaline();
+ CancelPlayerEnteringCars(nil);
+ gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
+ CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
+ CProjectileInfo::RemoveAllProjectiles();
+ CWorld::SetAllCarsCanBeDamaged(false);
+ CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
+ CReplay::DisableReplays();
+
+ } else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PLAYERINFO);
+ m_pPed->bBulletProof = false;
+ m_pPed->bFireProof = false;
+ m_pPed->bCollisionProof = false;
+ m_pPed->bMeleeProof = false;
+ m_pPed->bOnlyDamagedByPlayer = false;
+ m_pPed->bExplosionProof = false;
+ m_pPed->m_bCanBeDamaged = true;
+ CWorld::SetAllCarsCanBeDamaged(true);
+ CReplay::EnableReplays();
+ }
+}
+
+void
+CPlayerInfo::BlowUpRCBuggy(void)
+{
+ if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
+ return;
+
+ CRemote::TakeRemoteControlledCarFromPlayer();
+ m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
+}
+
+// There is something unfinished in here... Sadly all IDBs we have have it unfinished.
+void
+CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
+{
+ if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
+ ++m_nExplosionsSinceLastReward;
+ else
+ m_nExplosionsSinceLastReward = 1;
+
+ m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
+ int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
+ sprintf(gString, "$%d", award);
+#ifdef MONEY_MESSAGES
+ // This line is a leftover from PS2, I don't know what it was meant to be.
+ // CVector sth(TheCamera.GetPosition() * 4.0f);
+
+ CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
+#endif
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
+
+ for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
+ CGeneral::GetRandomNumber();
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
+ }
+}
+
+#ifdef GTA_PC
+void
+CPlayerInfo::SetPlayerSkin(const char *skin)
+{
+ strncpy(m_aSkinName, skin, 32);
+ LoadPlayerSkin();
+}
+
+void
+CPlayerInfo::LoadPlayerSkin()
+{
+ DeletePlayerSkin();
+
+ m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
+ if (!m_pSkinTexture)
+ m_pSkinTexture = CPlayerSkin::GetSkinTexture(DEFAULT_SKIN_NAME);
+}
+
+void
+CPlayerInfo::DeletePlayerSkin()
+{
+ if (m_pSkinTexture) {
+ RwTextureDestroy(m_pSkinTexture);
+ m_pSkinTexture = nil;
+ }
+}
+#endif \ No newline at end of file
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index 94410753..49424b8b 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -54,14 +54,13 @@ public:
bool m_bFastReload;
bool m_bGetOutOfJailFree;
bool m_bGetOutOfHospitalFree;
+#ifdef GTA_PC
char m_aSkinName[32];
RwTexture *m_pSkinTexture;
+#endif
void MakePlayerSafe(bool);
- void LoadPlayerSkin();
- void DeletePlayerSkin();
void AwardMoneyForExplosion(CVehicle *vehicle);
- void SetPlayerSkin(char* skin);
const CVector &GetPos();
void Process(void);
void KillPlayer(void);
@@ -78,7 +77,21 @@ public:
void SavePlayerInfo(uint8 *buf, uint32* size);
void FindClosestCarSectorList(CPtrList&, CPed*, float, float, float, float, float*, CVehicle**);
- ~CPlayerInfo() { };
+#ifdef GTA_PC
+ void LoadPlayerSkin();
+ void SetPlayerSkin(const char *skin);
+ void DeletePlayerSkin();
+#endif
};
+CPlayerPed *FindPlayerPed(void);
+CVehicle *FindPlayerVehicle(void);
+CVehicle *FindPlayerTrain(void);
+CEntity *FindPlayerEntity(void);
+CVector FindPlayerCoors(void);
+const CVector &FindPlayerSpeed(void);
+const CVector &FindPlayerCentreOfWorld(int32 player);
+const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
+float FindPlayerHeading(void);
+
VALIDATE_SIZE(CPlayerInfo, 0x13C);
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 0bc564ff..b2c1696c 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -33,7 +33,7 @@
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
-CPtrList CWorld::ms_bigBuildingsList[4];
+CPtrList CWorld::ms_bigBuildingsList[NUM_LEVELS];
CPtrList CWorld::ms_listMovingEntityPtrs;
CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
uint16 CWorld::ms_nCurrentScanCode;
@@ -1361,102 +1361,6 @@ CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList &list, const CVec
}
}
-CPlayerPed *
-FindPlayerPed(void)
-{
- return CWorld::Players[CWorld::PlayerInFocus].m_pPed;
-}
-
-CVehicle *
-FindPlayerVehicle(void)
-{
- CPlayerPed *ped = FindPlayerPed();
- if(ped && ped->InVehicle()) return ped->m_pMyVehicle;
- return nil;
-}
-
-CVehicle *
-FindPlayerTrain(void)
-{
- if(FindPlayerVehicle() && FindPlayerVehicle()->IsTrain())
- return FindPlayerVehicle();
- else
- return nil;
-}
-
-CEntity *
-FindPlayerEntity(void)
-{
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle;
- else
- return ped;
-}
-
-CVector
-FindPlayerCoors(void)
-{
-#ifdef FIX_BUGS
- if (CReplay::IsPlayingBack())
- return TheCamera.GetPosition();
-#endif
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle->GetPosition();
- else
- return ped->GetPosition();
-}
-
-CVector &
-FindPlayerSpeed(void)
-{
-#ifdef FIX_BUGS
- static CVector vecTmpVector(0.0f, 0.0f, 0.0f);
- if (CReplay::IsPlayingBack())
- return vecTmpVector;
-#endif
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle->m_vecMoveSpeed;
- else
- return ped->m_vecMoveSpeed;
-}
-
-const CVector &
-FindPlayerCentreOfWorld(int32 player)
-{
-#ifdef FIX_BUGS
- if(CReplay::IsPlayingBack()) return TheCamera.GetPosition();
-#endif
- if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
- if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
- return CWorld::Players[player].m_pPed->GetPosition();
-}
-
-const CVector &
-FindPlayerCentreOfWorld_NoSniperShift(void)
-{
-#ifdef FIX_BUGS
- if (CReplay::IsPlayingBack()) return TheCamera.GetPosition();
-#endif
- if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
- if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
- return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
- return FindPlayerPed()->GetPosition();
-}
-
-float
-FindPlayerHeading(void)
-{
- if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
- return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetForward().Heading();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetForward().Heading();
- return FindPlayerPed()->GetForward().Heading();
-}
-
void
CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2)
{
@@ -1537,7 +1441,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1
if(pVehicle->m_scanCode != GetCurrentScanCode()) {
pVehicle->m_scanCode = GetCurrentScanCode();
const CVector &vehiclePos = pVehicle->GetPosition();
- eCarMission carMission = pVehicle->AutoPilot.m_nCarMission;
+ uint8 carMission = pVehicle->AutoPilot.m_nCarMission;
if(pVehicle != FindPlayerVehicle() && vehiclePos.x > fStartX && vehiclePos.x < fEndX &&
vehiclePos.y > fStartY && vehiclePos.y < fEndY && pVehicle->bIsLawEnforcer &&
(carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE ||
@@ -1745,13 +1649,13 @@ CWorld::ShutDown(void)
pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush();
#endif
}
- for(int32 i = 0; i < 4; i++) {
- for(CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) {
+ for(int32 i = 0; i < NUM_LEVELS; i++) {
+ for(CPtrNode *pNode = ms_bigBuildingsList[i].first; pNode; pNode = pNode->next) {
CEntity *pEntity = (CEntity *)pNode->item;
// Maybe remove from world here?
delete pEntity;
}
- GetBigBuildingList((eLevelName)i).Flush();
+ ms_bigBuildingsList[i].Flush();
}
for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) {
CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y);
@@ -1955,12 +1859,11 @@ CWorld::Process(void)
} else {
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item;
-#ifdef SQUEEZE_PERFORMANCE
- if (movingEnt->bRemoveFromWorld) {
- RemoveEntityInsteadOfProcessingIt(movingEnt);
- } else
-#endif
+#ifdef FIX_BUGS // from VC
+ if(!movingEnt->bRemoveFromWorld && movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
+#else
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
+#endif
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),
0.02f * (movingEnt->IsObject()
diff --git a/src/core/World.h b/src/core/World.h
index 9465a914..9d62e79b 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -55,7 +55,7 @@ struct CStoredCollPoly;
class CWorld
{
- static CPtrList ms_bigBuildingsList[4];
+ static CPtrList ms_bigBuildingsList[NUM_LEVELS];
static CPtrList ms_listMovingEntityPtrs;
static CSector ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
static uint16 ms_nCurrentScanCode;
@@ -157,14 +157,3 @@ public:
extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
-class CPlayerPed;
-class CVehicle;
-CPlayerPed *FindPlayerPed(void);
-CVehicle *FindPlayerVehicle(void);
-CVehicle *FindPlayerTrain(void);
-CEntity *FindPlayerEntity(void);
-CVector FindPlayerCoors(void);
-CVector &FindPlayerSpeed(void);
-const CVector &FindPlayerCentreOfWorld(int32 player);
-const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
-float FindPlayerHeading(void);
diff --git a/src/core/common.h b/src/core/common.h
index 7029fdf1..ffae30bf 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -274,8 +274,14 @@ void re3_usererror(const char *format, ...);
#define DEBUGBREAK() __debugbreak();
-#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
+// Switch to enable development messages.
+#if 1
+#define DEV(f, ...)
+#else
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
+#endif
+
+#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)
diff --git a/src/core/config.h b/src/core/config.h
index d64cca40..96268138 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -300,7 +300,7 @@ enum Config {
# define CUSTOM_FRONTEND_OPTIONS
# ifdef CUSTOM_FRONTEND_OPTIONS
-# define GRAPHICS_MENU_OPTIONS // otherwise Advanced Options menu will appear if Display is full
+# define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable
# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
# define CUTSCENE_BORDERS_SWITCH
# define MULTISAMPLING // adds MSAA option
diff --git a/src/core/main.cpp b/src/core/main.cpp
index d02b8098..4b5d7004 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -415,6 +415,63 @@ PluginAttach(void)
return TRUE;
}
+#ifdef GTA_PS2
+#define NUM_PREALLOC_ATOMICS 3245
+#define NUM_PREALLOC_CLUMPS 101
+#define NUM_PREALLOC_FRAMES 2821
+#define NUM_PREALLOC_GEOMETRIES 1404
+#define NUM_PREALLOC_TEXDICTS 106
+#define NUM_PREALLOC_TEXTURES 1900
+#define NUM_PREALLOC_MATERIALS 3300
+bool preAlloc;
+
+void
+PreAllocateRwObjects(void)
+{
+ int i;
+ void **tmp = new void*[0x8000];
+ preAlloc = true;
+
+ for(i = 0; i < NUM_PREALLOC_ATOMICS; i++)
+ tmp[i] = RpAtomicCreate();
+ for(i = 0; i < NUM_PREALLOC_ATOMICS; i++)
+ RpAtomicDestroy((RpAtomic*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_CLUMPS; i++)
+ tmp[i] = RpClumpCreate();
+ for(i = 0; i < NUM_PREALLOC_CLUMPS; i++)
+ RpClumpDestroy((RpClump*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_FRAMES; i++)
+ tmp[i] = RwFrameCreate();
+ for(i = 0; i < NUM_PREALLOC_FRAMES; i++)
+ RwFrameDestroy((RwFrame*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_GEOMETRIES; i++)
+ tmp[i] = RpGeometryCreate(0, 0, 0);
+ for(i = 0; i < NUM_PREALLOC_GEOMETRIES; i++)
+ RpGeometryDestroy((RpGeometry*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
+ tmp[i] = RwTexDictionaryCreate();
+ for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
+ RwTexDictionaryDestroy((RwTexDictionary*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_TEXTURES; i++)
+ tmp[i] = RwTextureCreate(RwRasterCreate(0, 0, 0, 0));
+ for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
+ RwTextureDestroy((RwTexture*)tmp[i]);
+
+ for(i = 0; i < NUM_PREALLOC_MATERIALS; i++)
+ tmp[i] = RpMaterialCreate();
+ for(i = 0; i < NUM_PREALLOC_MATERIALS; i++)
+ RpMaterialDestroy((RpMaterial*)tmp[i]);
+
+ delete[] tmp;
+ preAlloc = false;
+}
+#endif
+
static RwBool
Initialise3D(void *param)
{
@@ -621,8 +678,10 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
AsciiToUnicode(str1, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
vpos += 22*yscale;
- AsciiToUnicode(str2, tmpstr);
- CFont::PrintString(hpos, vpos, tmpstr);
+ if (str2) {
+ AsciiToUnicode(str2, tmpstr);
+ CFont::PrintString(hpos, vpos, tmpstr);
+ }
#endif
}
@@ -1581,15 +1640,6 @@ AppEventHandler(RsEvent event, void *param)
return rsEVENTPROCESSED;
}
-#ifndef MASTER
- case rsANIMVIEWER:
- {
- TheModelViewer();
-
- return rsEVENTPROCESSED;
- }
-#endif
-
default:
{
return rsEVENTNOTPROCESSED;
@@ -1604,8 +1654,11 @@ TheModelViewer(void)
#if (defined(GTA_PS2) || defined(GTA_XBOX))
//TODO
#else
+ // This is III Mobile code. III Xbox code run it like main function, which is impossible to implement on PC's state machine implementation.
+ // Also we want 2D things initialized in here to print animation ids etc., our additions for that marked with X
+
#ifdef ASPECT_RATIO_SCALE
- CDraw::SetAspectRatio(CDraw::FindAspectRatio());
+ CDraw::SetAspectRatio(CDraw::FindAspectRatio()); // X
#endif
CAnimViewer::Update();
CTimer::Update();
@@ -1615,12 +1668,12 @@ TheModelViewer(void)
CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
255);
- CSprite2d::InitPerFrame();
- CFont::InitPerFrame();
+ CSprite2d::InitPerFrame(); // X
+ CFont::InitPerFrame(); // X
DefinedState();
CVisibilityPlugins::InitAlphaEntityList();
CAnimViewer::Render();
- Render2dStuff();
+ Render2dStuff(); // X
DoRWStuffEndOfFrame();
#endif
}
diff --git a/src/core/main.h b/src/core/main.h
index 77fac46a..149c0878 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -29,6 +29,7 @@ class CSprite2d;
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void);
+void PreAllocateRwObjects(void);
void InitialiseGame(void);
void LoadingScreen(const char *str1, const char *str2, const char *splashscreen);
void LoadingIslandScreen(const char *levelName);
diff --git a/src/core/templates.h b/src/core/templates.h
index 166f865c..3a5b314f 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -1,31 +1,31 @@
#pragma once
-template<typename T, int n>
+template<typename T, int32 n>
class CStore
{
public:
- int allocPtr;
+ int32 allocPtr;
T store[n];
- T *alloc(void){
- if(this->allocPtr >= n){
+ T *Alloc(void){
+ if(allocPtr >= n){
printf("Size of this thing:%d needs increasing\n", n);
assert(0);
}
- return &this->store[this->allocPtr++];
+ return &store[allocPtr++];
}
- void clear(void){
- this->allocPtr = 0;
+ void Clear(void){
+ allocPtr = 0;
}
- int getIndex(T *item){
- assert(item >= &this->store[0]);
- assert(item < &this->store[n]);
- return item - this->store;
+ int32 GetIndex(T *item){
+ assert(item >= &store[0]);
+ assert(item < &store[n]);
+ return item - store;
}
- T *getItem(int index){
+ T *GetItem(int32 index){
assert(index >= 0);
assert(index < n);
- return &this->store[index];
+ return &store[index];
}
};
@@ -40,12 +40,11 @@ class CPool
};
uint8 u;
} *m_flags;
- int m_size;
- int m_allocPtr;
+ int32 m_size;
+ int32 m_allocPtr;
public:
- CPool(int size){
- // TODO: use new here
+ CPool(int32 size){
m_entries = (U*)new uint8[sizeof(U)*size];
m_flags = (Flags*)new uint8[sizeof(Flags)*size];
m_size = size;
@@ -69,7 +68,7 @@ public:
m_allocPtr = 0;
}
}
- int GetSize(void) const { return m_size; }
+ int32 GetSize(void) const { return m_size; }
T *New(void){
bool wrapped = false;
do
@@ -93,12 +92,12 @@ public:
m_flags[m_allocPtr].id++;
return (T*)&m_entries[m_allocPtr];
}
- T *New(int handle){
+ T *New(int32 handle){
T *entry = (T*)&m_entries[handle>>8];
SetNotFreeAt(handle);
return entry;
}
- void SetNotFreeAt(int handle){
+ void SetNotFreeAt(int32 handle){
int idx = handle>>8;
m_flags[idx].free = 0;
m_flags[idx].id = handle & 0x7F;
@@ -123,21 +122,21 @@ public:
return m_flags[handle>>8].u == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
- int GetIndex(T *entry){
+ int32 GetIndex(T *entry){
int i = GetJustIndex_NoFreeAssert(entry);
return m_flags[i].u + (i<<8);
}
- int GetJustIndex(T *entry){
+ int32 GetJustIndex(T *entry){
int index = GetJustIndex_NoFreeAssert(entry);
assert(!IsFreeSlot(index));
return index;
}
- int GetJustIndex_NoFreeAssert(T* entry){
+ int32 GetJustIndex_NoFreeAssert(T* entry){
int index = ((U*)entry - m_entries);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
return index;
}
- int GetNoOfUsedSpaces(void) const{
+ int32 GetNoOfUsedSpaces(void) const{
int i;
int n = 0;
for(i = 0; i < m_size; i++)
@@ -241,7 +240,7 @@ public:
link->Remove(); // remove from list
freeHead.Insert(link); // insert into free list
}
- int Count(void){
+ int32 Count(void){
int n = 0;
CLink<T> *lnk;
for(lnk = head.next; lnk != &tail; lnk = lnk->next)
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index ba4f7ab0..9372c85d 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -6,7 +6,7 @@
struct CReference;
class CPtrList;
-enum eEntityType : uint8
+enum eEntityType
{
ENTITY_TYPE_NOTHING = 0,
ENTITY_TYPE_BUILDING,
@@ -16,7 +16,7 @@ enum eEntityType : uint8
ENTITY_TYPE_DUMMY,
};
-enum eEntityStatus : uint8
+enum eEntityStatus
{
STATUS_PLAYER,
STATUS_PLAYER_PLAYBACKFROMBUFFER,
@@ -92,10 +92,10 @@ public:
CReference *m_pFirstReference;
public:
- eEntityType GetType() const { return (eEntityType)m_type; }
- void SetType(eEntityType type) { m_type = type; }
- eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
- void SetStatus(eEntityStatus status) { m_status = status; }
+ uint8 GetType() const { return m_type; }
+ void SetType(uint8 type) { m_type = type; }
+ uint8 GetStatus() const { return m_status; }
+ void SetStatus(uint8 status) { m_status = status; }
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
bool GetIsStatic(void) const { return bIsStatic; }
void SetIsStatic(bool state) { bIsStatic = state; }
diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp
index 2d34cdcb..3f91a754 100644
--- a/src/extras/screendroplets.cpp
+++ b/src/extras/screendroplets.cpp
@@ -384,9 +384,9 @@ ScreenDroplets::ProcessCameraMovement(void)
ms_prevCamUp = camUp;
ms_prevCamPos = camPos;
- ms_screenMoveDelta.x = -RwV3dDotProduct(&camMat->right, (RwV3d*)&ms_camMoveDelta);
- ms_screenMoveDelta.y = RwV3dDotProduct(&camMat->up, (RwV3d*)&ms_camMoveDelta);
- ms_screenMoveDelta.z = RwV3dDotProduct(&camMat->at, (RwV3d*)&ms_camMoveDelta);
+ ms_screenMoveDelta.x = -RwV3dDotProduct(&camMat->right, &ms_camMoveDelta);
+ ms_screenMoveDelta.y = RwV3dDotProduct(&camMat->up, &ms_camMoveDelta);
+ ms_screenMoveDelta.z = RwV3dDotProduct(&camMat->at, &ms_camMoveDelta);
ms_screenMoveDelta *= 10.0f;
ms_screenMoveDist = ms_screenMoveDelta.Magnitude2D();
diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h
index a5a34626..47c94f7c 100644
--- a/src/math/Quaternion.h
+++ b/src/math/Quaternion.h
@@ -12,6 +12,11 @@ public:
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
void Normalise(void);
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
+ void Invert(void){ // Conjugate would have been a better name
+ x = -x;
+ y = -y;
+ z = -z;
+ }
const CQuaternion &operator+=(CQuaternion const &right) {
x += right.x;
diff --git a/src/math/Vector.h b/src/math/Vector.h
index 082b296f..776bfcfe 100644
--- a/src/math/Vector.h
+++ b/src/math/Vector.h
@@ -1,23 +1,22 @@
#pragma once
-class CVector
+class CVector : public RwV3d
{
public:
- float x, y, z;
CVector(void) {}
- CVector(float x, float y, float z) : x(x), y(y), z(z) {}
-#ifdef RWCORE_H
- CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {}
-
- operator RwV3d (void) const {
- RwV3d vecRw = { this->x, this->y, this->z };
- return vecRw;
+ CVector(float x, float y, float z)
+ {
+ this->x = x;
+ this->y = y;
+ this->z = z;
}
-
- operator RwV3d *(void) {
- return (RwV3d*)this;
+
+ CVector(const RwV3d &v)
+ {
+ x = v.x;
+ y = v.y;
+ z = v.z;
}
-#endif
// (0,1,0) means no rotation. So get right vector and its atan
float Heading(void) const { return Atan2(-x, y); }
float Magnitude(void) const { return Sqrt(x*x + y*y + z*z); }
diff --git a/src/math/VuVector.h b/src/math/VuVector.h
index f90818e0..30d62cfc 100644
--- a/src/math/VuVector.h
+++ b/src/math/VuVector.h
@@ -8,18 +8,7 @@ public:
CVuVector(float x, float y, float z) : CVector(x, y, z) {}
CVuVector(float x, float y, float z, float w) : CVector(x, y, z), w(w) {}
CVuVector(const CVector &v) : CVector(v.x, v.y, v.z) {}
-#ifdef RWCORE_H
- CVuVector(const RwV3d &v) : CVector(v.x, v.y, v.z) {}
-
- operator RwV3d (void) const {
- RwV3d vecRw = { this->x, this->y, this->z };
- return vecRw;
- }
-
- operator RwV3d *(void) {
- return (RwV3d*)this;
- }
-#endif
+ CVuVector(const RwV3d &v) : CVector(v) {}
/*
void Normalise(void) {
float sq = MagnitudeSqr();
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index 4c274aaf..ae2b6668 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -4,7 +4,7 @@
#define MAX_MODEL_NAME (24)
-enum ModelInfoType : uint8
+enum ModelInfoType
{
MITYPE_NA = 0,
MITYPE_SIMPLE = 1,
@@ -15,7 +15,6 @@ enum ModelInfoType : uint8
MITYPE_PED = 6,
MITYPE_XTRACOMPS = 7,
};
-VALIDATE_SIZE(ModelInfoType, 1);
class C2dEffect;
@@ -28,7 +27,7 @@ protected:
int16 m_objectId;
uint16 m_refCount;
int16 m_txdSlot;
- ModelInfoType m_type;
+ uint8 m_type;
uint8 m_num2dEffects;
bool m_bOwnsColModel;
#ifdef EXTRA_MODEL_FLAGS
@@ -50,7 +49,7 @@ public:
virtual RwObject *GetRwObject(void) = 0;
// one day it becomes virtual
- ModelInfoType GetModelType() const { return m_type; }
+ uint8 GetModelType() const { return m_type; }
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; }
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE ||
m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index 4ee8e72b..dcde0df3 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -26,15 +26,15 @@ CModelInfo::Initialise(void)
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
- ms_2dEffectStore.clear();
- ms_mloInstanceStore.clear();
- ms_xtraCompsModelStore.clear();
- ms_simpleModelStore.clear();
- ms_timeModelStore.clear();
- ms_mloModelStore.clear();
- ms_clumpModelStore.clear();
- ms_pedModelStore.clear();
- ms_vehicleModelStore.clear();
+ ms_2dEffectStore.Clear();
+ ms_mloInstanceStore.Clear();
+ ms_xtraCompsModelStore.Clear();
+ ms_simpleModelStore.Clear();
+ ms_timeModelStore.Clear();
+ ms_mloModelStore.Clear();
+ ms_clumpModelStore.Clear();
+ ms_pedModelStore.Clear();
+ ms_vehicleModelStore.Clear();
m = AddSimpleModel(MI_CAR_DOOR);
m->SetColModel(&CTempColModels::ms_colModelDoor1);
@@ -108,22 +108,22 @@ CModelInfo::ShutDown(void)
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
ms_2dEffectStore.store[i].Shutdown();
- ms_2dEffectStore.clear();
- ms_simpleModelStore.clear();
- ms_mloInstanceStore.clear();
- ms_mloModelStore.clear();
- ms_xtraCompsModelStore.clear();
- ms_timeModelStore.clear();
- ms_pedModelStore.clear();
- ms_clumpModelStore.clear();
- ms_vehicleModelStore.clear();
+ ms_2dEffectStore.Clear();
+ ms_simpleModelStore.Clear();
+ ms_mloInstanceStore.Clear();
+ ms_mloModelStore.Clear();
+ ms_xtraCompsModelStore.Clear();
+ ms_timeModelStore.Clear();
+ ms_pedModelStore.Clear();
+ ms_clumpModelStore.Clear();
+ ms_vehicleModelStore.Clear();
}
CSimpleModelInfo*
CModelInfo::AddSimpleModel(int id)
{
CSimpleModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_simpleModelStore.alloc();
+ modelinfo = CModelInfo::ms_simpleModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
@@ -133,7 +133,7 @@ CMloModelInfo *
CModelInfo::AddMloModel(int id)
{
CMloModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_mloModelStore.alloc();
+ modelinfo = CModelInfo::ms_mloModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->firstInstance = 0;
@@ -145,7 +145,7 @@ CTimeModelInfo*
CModelInfo::AddTimeModel(int id)
{
CTimeModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_timeModelStore.alloc();
+ modelinfo = CModelInfo::ms_timeModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
@@ -155,7 +155,7 @@ CClumpModelInfo*
CModelInfo::AddClumpModel(int id)
{
CClumpModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_clumpModelStore.alloc();
+ modelinfo = CModelInfo::ms_clumpModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
@@ -165,7 +165,7 @@ CPedModelInfo*
CModelInfo::AddPedModel(int id)
{
CPedModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_pedModelStore.alloc();
+ modelinfo = CModelInfo::ms_pedModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
@@ -175,7 +175,7 @@ CVehicleModelInfo*
CModelInfo::AddVehicleModel(int id)
{
CVehicleModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_vehicleModelStore.alloc();
+ modelinfo = CModelInfo::ms_vehicleModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->m_vehicleType = -1;
@@ -245,7 +245,7 @@ CModelInfo::ConstructMloClumps()
void
CModelInfo::ReInit2dEffects()
{
- ms_2dEffectStore.clear();
+ ms_2dEffectStore.Clear();
for (int i = 0; i < MODELINFOSIZE; i++) {
if (ms_modelInfoPtrs[i])
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index 17754211..cc2a7e34 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -471,7 +471,7 @@ CVehicleModelInfo::PreprocessHierarchy(void)
if(desc[i].flags & VEHICLE_FLAG_POS){
f = assoc.frame;
- rwvec = (RwV3d*)&m_positions[desc[i].hierId];
+ rwvec = &m_positions[desc[i].hierId];
*rwvec = *RwMatrixGetPos(RwFrameGetMatrix(f));
for(f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
RwV3dTransformPoints(rwvec, rwvec, 1, RwFrameGetMatrix(f));
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp
index d91a0f13..411e245a 100644
--- a/src/objects/Object.cpp
+++ b/src/objects/Object.cpp
@@ -209,15 +209,15 @@ CObject::ObjectDamage(float amount)
SetTurnSpeed(0.0f, 0.0f, 0.0f);
const RwRGBA color = { 96, 48, 0, 255 };
for (int32 i = 0; i < 25; i++) {
- CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ);
+ CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(0.1f, 0.25f) + fDirectionZ);
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f);
RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom) , color.blue, color.alpha };
- float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
- int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
+ float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.20f);
+ int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 40);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);
}
PlayOneShotScriptObject(SCRIPT_SOUND_BOX_DESTROYED_2, vecPos);
@@ -232,15 +232,15 @@ CObject::ObjectDamage(float amount)
SetTurnSpeed(0.0f, 0.0f, 0.0f);
const RwRGBA color = { 128, 128, 128, 255 };
for (int32 i = 0; i < 45; i++) {
- CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ);
+ CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(0.1f, 0.25f) + fDirectionZ);
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
- float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f);
+ float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 1.0f);
RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom), uint8(color.blue * fRandom), color.alpha };
- float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
- int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
+ float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.20f);
+ int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 40);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);
}
PlayOneShotScriptObject(SCRIPT_SOUND_BOX_DESTROYED_1, vecPos);
@@ -256,16 +256,16 @@ CObject::ObjectDamage(float amount)
const RwRGBA color1 = { 200, 0, 0, 255 };
const RwRGBA color2 = { 200, 200, 200, 255 };
for (int32 i = 0; i < 10; i++) {
- CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ);
+ CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(0.1f, 0.25f) + fDirectionZ);
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
RwRGBA color = color2;
if (nFrameGen & 1)
color = color1;
- float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
- int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
+ float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.20f);
+ int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 40);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0);
}
PlayOneShotScriptObject(SCRIPT_SOUND_TIRE_COLLISION, vecPos);
@@ -281,16 +281,16 @@ CObject::ObjectDamage(float amount)
const RwRGBA color1 = { 200, 0, 0, 255 };
const RwRGBA color2 = { 200, 200, 200, 255 };
for (int32 i = 0; i < 32; i++) {
- CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(-0.35f, 0.7f),
- CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ);
+ CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(-0.35f, 0.35f),
+ CGeneral::GetRandomNumberInRange(0.1f, 0.25f) + fDirectionZ);
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
RwRGBA color = color2;
if (nFrameGen & 1)
color = color1;
- float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
- int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
+ float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.20f);
+ int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 40);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0);
}
PlayOneShotScriptObject(SCRIPT_SOUND_METAL_COLLISION, vecPos);
@@ -389,7 +389,7 @@ CObject::DeleteAllTempObjectsInArea(CVector point, float fRadius)
CObjectPool *objectPool = CPools::GetObjectPool();
for (int32 i = 0; i < objectPool->GetSize(); i++) {
CObject *pObject = objectPool->GetSlot(i);
- if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT && fRadius * fRadius > pObject->GetPosition().MagnitudeSqr()) {
+ if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT && (point - pObject->GetPosition()).MagnitudeSqr() < SQR(fRadius)) {
CWorld::Remove(pObject);
delete pObject;
}
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index 401d2e67..a2f44357 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -274,7 +274,7 @@ CCivilianPed::ProcessControl(void)
} else {
crimeReporters[m_phoneId] = this;
m_facePhoneStart = true;
- m_nPedState = PED_FACE_PHONE;
+ SetPedState(PED_FACE_PHONE);
}
#else
} else if (bRunningToPhone) {
@@ -283,7 +283,7 @@ CCivilianPed::ProcessControl(void)
m_phoneId = -1;
} else {
gPhoneInfo.m_aPhones[m_phoneId].m_nState = PHONE_STATE_REPORTING_CRIME;
- m_nPedState = PED_FACE_PHONE;
+ SetPedState(PED_FACE_PHONE);
}
#endif
} else if (m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) {
@@ -305,7 +305,7 @@ CCivilianPed::ProcessControl(void)
break;
case PED_FACE_PHONE:
if (FacePhone())
- m_nPedState = PED_MAKE_CALL;
+ SetPedState(PED_MAKE_CALL);
break;
case PED_MAKE_CALL:
if (MakePhonecall())
@@ -331,7 +331,7 @@ CCivilianPed::ProcessControl(void)
for (int j = 0; j < m_numNearPeds; ++j) {
CPed *nearPed = m_nearPeds[j];
if (nearPed->m_nPedType == m_nPedType && nearPed->m_nPedState == PED_WANDER_PATH) {
- nearPed->m_nPedState = PED_UNKNOWN;
+ nearPed->SetPedState(PED_UNKNOWN);
}
}
}
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index d9f55559..e518fae4 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -69,7 +69,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
field_1364 = -1;
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
// VC also initializes in here, but as nil
#ifdef FIX_BUGS
@@ -114,14 +114,14 @@ CCopPed::SetArrestPlayer(CPed *player)
} else if (player->m_nPedState != PED_DIE && player->m_nPedState != PED_DEAD && player->m_nPedState != PED_ARRESTED) {
player->m_nLastPedState = player->m_nPedState;
- player->m_nPedState = PED_ARRESTED;
+ player->SetPedState(PED_ARRESTED);
FindPlayerPed()->m_bCanBeDamaged = false;
((CPlayerPed*)player)->m_pArrestingCop = this;
this->RegisterReference((CEntity**) &((CPlayerPed*)player)->m_pArrestingCop);
}
- m_nPedState = PED_ARREST_PLAYER;
+ SetPedState(PED_ARREST_PLAYER);
SetObjective(OBJECTIVE_NONE);
m_prevObjective = OBJECTIVE_NONE;
bIsPointingGunAt = false;
@@ -229,7 +229,7 @@ CCopPed::ArrestPlayer(void)
CPed *suspect = (CPed*)m_pSeekTarget;
if (suspect) {
if (suspect->CanSetPedState())
- suspect->m_nPedState = PED_ARRESTED;
+ suspect->SetPedState(PED_ARRESTED);
if (suspect->bInVehicle && m_pMyVehicle && suspect->m_pMyVehicle == m_pMyVehicle) {
@@ -244,7 +244,7 @@ CCopPed::ArrestPlayer(void)
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_ARREST_GUN, 4.0f);
CVector suspMidPos;
- suspect->m_pedIK.GetComponentPosition((RwV3d*)suspMidPos, PED_MID);
+ suspect->m_pedIK.GetComponentPosition(suspMidPos, PED_MID);
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(suspMidPos.x, suspMidPos.y,
GetPosition().x, GetPosition().y);
@@ -472,10 +472,7 @@ CCopPed::CopAI(void)
if (!CWorld::ProcessLineOfSight(gunPos, playerOrHisVeh->GetPosition(), foundCol, foundEnt,
false, true, false, false, true, false, false)
|| foundEnt && foundEnt == playerOrHisVeh) {
- m_pPointGunAt = playerOrHisVeh;
- if (playerOrHisVeh)
- playerOrHisVeh->RegisterReference((CEntity**) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(playerOrHisVeh);
SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
}
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index 8d6999c3..9f87c12b 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -100,7 +100,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_READY:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire) {
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN);
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
@@ -114,7 +114,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_DETERMINE_NEXT_STATE:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire && nearestFire != m_pAttendedFire) {
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN);
#ifdef FIX_BUGS
@@ -160,7 +160,7 @@ CEmergencyPed::FiremanAI(void)
#endif
--m_pAttendedFire->m_nFiremenPuttingOut;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetWanderPath(CGeneral::GetRandomNumber() & 7);
m_pAttendedFire = nil;
m_nEmergencyPedState = EMERGENCY_PED_READY;
@@ -234,8 +234,8 @@ CEmergencyPed::MedicAI(void)
if (nearestAccident) {
m_pRevivedPed = nearestAccident->m_pVictim;
m_pRevivedPed->RegisterReference((CEntity**)&m_pRevivedPed);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
SetSeek((headPos + midPos) * 0.5f, 1.0f);
SetObjective(OBJECTIVE_NONE);
bIsRunning = true;
@@ -274,8 +274,8 @@ CEmergencyPed::MedicAI(void)
m_nEmergencyPedState = EMERGENCY_PED_STOP;
break;
}
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
SetSeek((headPos + midPos) * 0.5f, nearestAccident->m_nMedicsPerformingCPR * 0.5f + 1.0f);
SetObjective(OBJECTIVE_NONE);
bIsRunning = true;
@@ -307,7 +307,7 @@ CEmergencyPed::MedicAI(void)
} else {
m_pRevivedPed->m_bloodyFootprintCountOrDeathTime = CTimer::GetTimeInMilliseconds();
SetMoveState(PEDMOVE_STILL);
- m_nPedState = PED_CPR;
+ SetPedState(PED_CPR);
m_nLastPedState = PED_CPR;
SetLookFlag(m_pRevivedPed, 0);
SetLookTimer(500);
@@ -329,8 +329,8 @@ CEmergencyPed::MedicAI(void)
if (!m_pRevivedPed || m_pRevivedPed->m_fHealth > 0.0f)
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
else {
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
midPos = (headPos + midPos) * 0.5f;
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(
midPos.x, midPos.y,
@@ -351,8 +351,8 @@ CEmergencyPed::MedicAI(void)
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
break;
}
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
midPos = (headPos + midPos) * 0.5f;
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(
midPos.x, midPos.y,
@@ -366,12 +366,12 @@ CEmergencyPed::MedicAI(void)
break;
}
m_nEmergencyPedState = EMERGENCY_PED_STOP_CPR;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetMoveState(PEDMOVE_WALK);
m_pVehicleAnim = nil;
if (!m_pRevivedPed->bBodyPartJustCameOff) {
m_pRevivedPed->m_fHealth = 100.0f;
- m_pRevivedPed->m_nPedState = PED_NONE;
+ m_pRevivedPed->SetPedState(PED_NONE);
m_pRevivedPed->m_nLastPedState = PED_WANDER_PATH;
m_pRevivedPed->SetGetUp();
m_pRevivedPed->bUsesCollision = true;
@@ -400,7 +400,7 @@ CEmergencyPed::MedicAI(void)
break;
case EMERGENCY_PED_STOP:
m_bStartedToCPR = false;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
if (m_pAttendedAccident) {
m_pAttendedAccident->m_pVictim = nil;
--m_pAttendedAccident->m_nMedicsAttending;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index c41c1f0c..df78902f 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -641,7 +641,7 @@ CPed::RestorePreviousState(void)
return;
if (InVehicle()) {
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
m_nLastPedState = PED_NONE;
} else {
if (m_nLastPedState == PED_NONE) {
@@ -658,7 +658,7 @@ CPed::RestorePreviousState(void)
SetIdle();
break;
case PED_WANDER_PATH:
- m_nPedState = PED_WANDER_PATH;
+ SetPedState(PED_WANDER_PATH);
bIsRunning = false;
if (bFindNewNodeAfterStateRestore) {
if (m_pNextPathNode) {
@@ -672,7 +672,7 @@ CPed::RestorePreviousState(void)
SetWanderPath(CGeneral::GetRandomNumber() & 7);
break;
default:
- m_nPedState = m_nLastPedState;
+ SetPedState(m_nLastPedState);
SetMoveState((eMoveState) m_nPrevMoveState);
break;
}
@@ -960,7 +960,7 @@ CPed::MoveHeadToLook(void)
}
if (m_pLookTarget->IsPed()) {
- ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition((RwV3d*) &lookPos, PED_MID);
+ ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition(lookPos, PED_MID);
} else {
lookPos = m_pLookTarget->GetPosition();
}
@@ -1511,8 +1511,8 @@ CPed::ClearAll(void)
if (!IsPedInControl() && m_nPedState != PED_DEAD)
return;
- m_nPedState = PED_NONE;
- m_nMoveState = PEDMOVE_NONE;
+ SetPedState(PED_NONE);
+ SetMoveState(PEDMOVE_NONE);
m_pSeekTarget = nil;
m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f);
m_fleeFromPosX = 0.0f;
@@ -1585,7 +1585,7 @@ CPed::ProcessBuoyancy(void)
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, CRGBA(0, 0, 0, 0), true);
#endif
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
return;
}
}
@@ -2692,36 +2692,6 @@ CPed::ProcessControl(void)
case PED_WANDER_PATH:
WanderPath();
break;
- case PED_SEEK_POS:
- case PED_SEEK_ENTITY:
- case PED_PURSUE:
- case PED_SNIPER_MODE:
- case PED_ROCKET_MODE:
- case PED_DUMMY:
- case PED_FACE_PHONE:
- case PED_MAKE_CALL:
- case PED_MUG:
- case PED_AI_CONTROL:
- case PED_FOLLOW_ROUTE:
- case PED_CPR:
- case PED_SOLICIT:
- case PED_BUY_ICECREAM:
- case PED_STEP_AWAY:
- case PED_UNKNOWN:
- case PED_STATES_NO_AI:
- case PED_JUMP:
- case PED_STAGGER:
- case PED_DIVE_AWAY:
- case PED_STATES_NO_ST:
- case PED_ARREST_PLAYER:
- case PED_PASSENGER:
- case PED_TAXI_PASSENGER:
- case PED_OPEN_DOOR:
- case PED_DEAD:
- case PED_DRAG_FROM_CAR:
- case PED_EXIT_CAR:
- case PED_STEAL_CAR:
- break;
case PED_ENTER_CAR:
case PED_CARJACK:
{
@@ -4467,7 +4437,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (!veh->bEngineOn)
veh->bEngineOn = true;
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->StopNonPartialAnims();
return;
}
@@ -4512,7 +4482,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
if (ped->m_nPedState == PED_CARJACK) {
veh->AddPassenger(ped, 0);
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective();
ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh);
} else if (veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) {
@@ -4552,7 +4522,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
veh->AutoPilot.m_nCruiseSpeed = 25;
}
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
@@ -4580,7 +4550,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
break;
}
}
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
ped->m_prevObjective = OBJECTIVE_NONE;
@@ -4967,7 +4937,7 @@ CPed::SetIdle(void)
m_nLastPedState = PED_NONE;
#endif
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL);
}
if (m_nWaitState == WAITSTATE_FALSE) {
@@ -5055,7 +5025,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
ClearLookFlag();
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_FALL;
+ SetPedState(PED_FALL);
CAnimBlendAssociation *fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), animId);
if (fallAssoc) {
@@ -5220,7 +5190,7 @@ CPed::SetGetUp(void)
}
if (m_nPedState != PED_GETUP) {
SetStoredState();
- m_nPedState = PED_GETUP;
+ SetPedState(PED_GETUP);
}
CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity;
@@ -5375,7 +5345,7 @@ CPed::SetSeek(CVector pos, float distanceToCountDone)
if (m_nPedState != PED_SEEK_POS)
SetStoredState();
- m_nPedState = PED_SEEK_POS;
+ SetPedState(PED_SEEK_POS);
m_distanceToCountSeekDone = distanceToCountDone;
m_vecSeekPos = pos;
}
@@ -5395,7 +5365,7 @@ CPed::SetSeek(CEntity *seeking, float distanceToCountDone)
if (m_nPedState != PED_SEEK_ENTITY)
SetStoredState();
- m_nPedState = PED_SEEK_ENTITY;
+ SetPedState(PED_SEEK_ENTITY);
m_distanceToCountSeekDone = distanceToCountDone;
m_pSeekTarget = seeking;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
@@ -5572,7 +5542,7 @@ CPed::SetFlee(CVector2D const &from, int time)
if (m_nPedState != PED_FLEE_ENTITY) {
SetStoredState();
- m_nPedState = PED_FLEE_POS;
+ SetPedState(PED_FLEE_POS);
SetMoveState(PEDMOVE_RUN);
m_fleeFromPosX = from.x;
m_fleeFromPosY = from.y;
@@ -5601,7 +5571,7 @@ CPed::SetFlee(CEntity *fleeFrom, int time)
return;
SetStoredState();
- m_nPedState = PED_FLEE_ENTITY;
+ SetPedState(PED_FLEE_ENTITY);
bUsePedNodeSeek = true;
SetMoveState(PEDMOVE_RUN);
m_fleeFrom = fleeFrom;
@@ -5862,7 +5832,7 @@ CPed::SetWanderPath(int8 pathStateDest)
// We did it, save next path state and return true
m_nPathDir = nextPathState;
- m_nPedState = PED_WANDER_PATH;
+ SetPedState(PED_WANDER_PATH);
SetMoveState(PEDMOVE_WALK);
bIsRunning = false;
return true;
@@ -6047,7 +6017,7 @@ CPed::SetFollowPath(CVector dest)
return false;
SetStoredState();
- m_nPedState = PED_FOLLOW_PATH;
+ SetPedState(PED_FOLLOW_PATH);
SetMoveState(PEDMOVE_WALK);
return true;
}
@@ -6150,7 +6120,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
m_fRotationCur = CGeneral::LimitRadianAngle(angleToFace);
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_STEP_AWAY;
+ SetPedState(PED_STEP_AWAY);
}
}
}
@@ -6247,13 +6217,13 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump)
animAssoc->flags &= ~ASSOC_DELETEFADEDOUT;
animAssoc->SetFinishCallback(PedEvadeCB, this);
SetStoredState();
- m_nPedState = PED_STEP_AWAY;
+ SetPedState(PED_STEP_AWAY);
} else {
m_fRotationCur = angleToFace;
ClearLookFlag();
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_DIVE_AWAY;
+ SetPedState(PED_DIVE_AWAY);
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_EV_DIVE, 8.0f);
animAssoc->SetFinishCallback(PedEvadeCB, this);
}
@@ -6291,7 +6261,7 @@ CPed::PedEvadeCB(CAnimBlendAssociation* animAssoc, void* arg)
if (ped->m_nPedState == PED_DIVE_AWAY)
{
ped->m_getUpTimer = CTimer::GetTimeInMilliseconds() + 1;
- ped->m_nPedState = PED_FALL;
+ ped->SetPedState(PED_FALL);
}
animAssoc->flags &= ~ASSOC_FADEOUTWHENDONE;
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
@@ -6342,7 +6312,7 @@ CPed::SetDie(AnimationId animId, float delta, float speed)
QuitEnteringCar();
}
- m_nPedState = PED_DIE;
+ SetPedState(PED_DIE);
if (animId == NUM_ANIMS) {
bIsPedDieAnimPlaying = false;
} else {
@@ -6384,7 +6354,7 @@ CPed::SetDead(void)
if (m_nPedState == PED_DRIVING)
bIsVisible = false;
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
m_pVehicleAnim = nil;
m_pCollidingEntity = nil;
@@ -6417,7 +6387,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time)
if(m_nPedState != PED_CHAT)
SetStoredState();
- m_nPedState = PED_CHAT;
+ SetPedState(PED_CHAT);
SetMoveState(PEDMOVE_STILL);
#if defined VC_PED_PORTS || defined FIX_BUGS
m_lookTimer = 0;
@@ -6658,7 +6628,7 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode)
// m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = doorNode;
m_distanceToCountSeekDone = 0.5f;
- m_nPedState = PED_SEEK_CAR;
+ SetPedState(PED_SEEK_CAR);
}
@@ -7683,10 +7653,11 @@ CPed::FlagToDestroyWhenNextProcessed(void)
}
bInVehicle = false;
m_pMyVehicle = nil;
+
if (CharCreatedBy == MISSION_CHAR)
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
else
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
m_pVehicleAnim = nil;
}
@@ -7710,7 +7681,7 @@ CPed::SetSolicit(uint32 time)
if(!m_carInObjective->bIsVan && !m_carInObjective->bIsBus)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_HOOKERTALK, 4.0f);
- m_nPedState = PED_SOLICIT;
+ SetPedState(PED_SOLICIT);
}
}
}
@@ -7769,7 +7740,7 @@ CPed::SetBuyIceCream(void)
// Simulating BuyIceCream
CPed* driver = m_carInObjective->pDriver;
if (driver) {
- m_nPedState = PED_BUY_ICECREAM;
+ SetPedState(PED_BUY_ICECREAM);
bFindNewNodeAfterStateRestore = true;
SetObjectiveTimer(8000);
SetChat(driver, 8000);
@@ -7783,7 +7754,7 @@ CPed::SetBuyIceCream(void)
if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) {
m_standardTimer = CTimer::GetTimeInMilliseconds() + 3000;
- m_nPedState = PED_BUY_ICECREAM;
+ SetPedState(PED_BUY_ICECREAM);
}
}
@@ -7985,7 +7956,7 @@ CPed::SetJump(void)
#endif
(m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) {
SetStoredState();
- m_nPedState = PED_JUMP;
+ SetPedState(PED_JUMP);
CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f);
jumpAssoc->SetFinishCallback(FinishLaunchCB, this);
m_fRotationDest = m_fRotationCur;
@@ -8287,7 +8258,7 @@ CPed::WarpPedIntoCar(CVehicle *car)
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_carInObjective = car;
m_carInObjective->RegisterReference((CEntity **) &m_carInObjective);
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
bUsesCollision = false;
bIsInTheAir = false;
bVehExitWillBeInstant = true;
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index a3d4997d..d27853d6 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -43,7 +43,7 @@ enum eFormation
FORMATION_FRONT
};
-enum FightState : int8 {
+enum FightState {
FIGHTSTATE_MOVE_FINISHED = -2,
FIGHTSTATE_JUST_ATTACKED,
FIGHTSTATE_NO_MOVE,
@@ -153,7 +153,7 @@ enum eWaitState {
WAITSTATE_FINISH_FLEE
};
-enum eObjective : uint32 {
+enum eObjective {
OBJECTIVE_NONE,
OBJECTIVE_WAIT_ON_FOOT,
OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE,
@@ -212,7 +212,7 @@ enum PedOnGroundState {
PED_DEAD_ON_THE_FLOOR
};
-enum PointBlankNecessity : uint8 {
+enum PointBlankNecessity {
NO_POINT_BLANK_PED,
POINT_BLANK_FOR_WANTED_PED,
POINT_BLANK_FOR_SOMEONE_ELSE
@@ -484,7 +484,7 @@ public:
CVector m_vecHitLastPos;
uint32 m_curFightMove;
uint8 m_fightButtonPressure;
- FightState m_fightState;
+ int8 m_fightState;
bool m_takeAStepAfterAttack;
CFire *m_pFire;
CEntity *m_pLookTarget;
@@ -598,7 +598,7 @@ public:
#endif
bool CheckForExplosions(CVector2D &area);
CPed *CheckForGunShots(void);
- PointBlankNecessity CheckForPointBlankPeds(CPed*);
+ uint8 CheckForPointBlankPeds(CPed*);
bool CheckIfInTheAir(void);
void ClearAll(void);
void SetPointGunAt(CEntity*);
@@ -863,6 +863,13 @@ public:
SetMoveState(PEDMOVE_WALK);
}
+ inline void SetWeaponLockOnTarget(CEntity *target)
+ {
+ m_pPointGunAt = (CPed *)target;
+ if(target)
+ ((CEntity *)target)->RegisterReference(&m_pPointGunAt);
+ }
+
// Using this to abstract nodes of skinned and non-skinned meshes
CVector GetNodePosition(int32 node)
{
@@ -891,13 +898,13 @@ public:
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
int32 idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
- RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, &mats[idx]);
+ RwV3dTransformPoints(&pos, &pos, 1, &mats[idx]);
}else
#endif
{
RwFrame *frame;
for (frame = m_pFrames[node]->frame; frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, RwFrameGetMatrix(frame));
+ RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(frame));
}
}
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index 38303473..a747c684 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -620,9 +620,7 @@ CPed::UpdateFromLeader(void)
m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget);
TurnBody();
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) {
- m_pPointGunAt = m_threatEntity;
- if (m_threatEntity)
- m_threatEntity->RegisterReference((CEntity **) &m_pPointGunAt);
+ SetWeaponLockOnTarget(m_threatEntity);
SetAttack(m_threatEntity);
}
}
@@ -811,10 +809,10 @@ CPed::ProcessObjective(void)
break;
}
case OBJECTIVE_WAIT_IN_CAR:
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
break;
case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT:
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
break;
case OBJECTIVE_KILL_CHAR_ANY_MEANS:
{
@@ -972,9 +970,9 @@ CPed::ProcessObjective(void)
}
CWeaponInfo *wepInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
float wepRange = wepInfo->m_fRange;
- float wepRangeAdjusted;
+ float maxDistToKeep;
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) {
- wepRangeAdjusted = wepRange / 3.0f;
+ maxDistToKeep = wepRange / 3.0f;
} else {
if (m_nPedState == PED_FIGHT) {
if (!IsPlayer() && !(m_pedStats->m_flags & STAT_CAN_KICK))
@@ -982,10 +980,10 @@ CPed::ProcessObjective(void)
} else {
wepRange = 1.3f;
}
- wepRangeAdjusted = wepRange;
+ maxDistToKeep = wepRange;
}
- if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && wepRangeAdjusted < 2.5f) {
- wepRangeAdjusted = 2.5f;
+ if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && maxDistToKeep < 2.5f) {
+ maxDistToKeep = 2.5f;
}
if (m_pedInObjective->IsPlayer() && m_nPedType != PEDTYPE_COP
&& CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops) {
@@ -1015,21 +1013,18 @@ CPed::ProcessObjective(void)
// I hope so
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
CVector maxShotPos = vehOfTarget->GetPosition() - ourHead;
- maxShotPos.Normalise();
- maxShotPos = maxShotPos * wepInfo->m_fRange + ourHead;
+ maxShotPos *= wepInfo->m_fRange / maxShotPos.Magnitude();
+ maxShotPos += ourHead;
- CWorld::bIncludeDeadPeds = true;
CColPoint foundCol;
CEntity *foundEnt;
- CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt,
- true, true, true, true, false, true, false);
+
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt, true, true, true, true, false, true, false);
CWorld::bIncludeDeadPeds = false;
if (foundEnt == vehOfTarget) {
SetAttack(vehOfTarget);
- m_pPointGunAt = vehOfTarget;
- if (vehOfTarget)
- vehOfTarget->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(vehOfTarget);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc <= m_distanceToCountSeekDone) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(200, 500));
@@ -1038,8 +1033,7 @@ CPed::ProcessObjective(void)
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
}
}
- }
- else if (m_nPedState != PED_ATTACK && !bKindaStayInSamePlace && !killPlayerInNoPoliceZone) {
+ } else if (m_nPedState != PED_ATTACK && !bKindaStayInSamePlace && !killPlayerInNoPoliceZone) {
if (vehOfTarget) {
if (m_nPedType == PEDTYPE_COP || vehOfTarget->bIsBus) {
GoToNearestDoor(vehOfTarget);
@@ -1086,7 +1080,7 @@ CPed::ProcessObjective(void)
|| distWithTargetSc > m_distanceToCountSeekDone && !CanSeeEntity(m_pedInObjective)) {
if (m_pedInObjective->EnteringCar())
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
if (bUsePedNodeSeek) {
CVector bestCoords(0.0f, 0.0f, 0.0f);
@@ -1100,7 +1094,7 @@ CPed::ProcessObjective(void)
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
}
bCrouchWhenShooting = false;
if (m_pedInObjective->m_pCurrentPhysSurface && distWithTargetSc < 5.0f) {
@@ -1147,32 +1141,27 @@ CPed::ProcessObjective(void)
CVector target;
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
if (m_pedInObjective->IsPed())
- m_pedInObjective->m_pedIK.GetComponentPosition((RwV3d*)&target, PED_MID);
+ m_pedInObjective->m_pedIK.GetComponentPosition(target, PED_MID);
else
target = m_pedInObjective->GetPosition();
target -= ourHead;
- target.Normalise();
- target = target * wepInfo->m_fRange + ourHead;
+ target *= wepInfo->m_fRange / target.Magnitude();
+ target += ourHead;
- CWorld::bIncludeDeadPeds = true;
- CEntity *foundEnt = nil;
CColPoint foundCol;
+ CEntity *foundEnt = nil;
- CWorld::ProcessLineOfSight(
- ourHead, target, foundCol, foundEnt,
- true, true, true, false, true, false);
- CWorld::bIncludeDeadPeds = 0;
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, target, foundCol, foundEnt, true, true, true, true, false, true, false);
+ CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_pedInObjective) {
SetAttack(m_pedInObjective);
- m_pPointGunAt = m_pedInObjective;
- if (m_pedInObjective)
- m_pedInObjective->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_pedInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500.0f, 2000.0f));
int time;
- if (distWithTargetSc <= wepRangeAdjusted)
+ if (distWithTargetSc <= maxDistToKeep)
time = CGeneral::GetRandomNumberInRange(100.0f, 500.0f);
else
time = CGeneral::GetRandomNumberInRange(1500.0f, 3000.0f);
@@ -1180,25 +1169,27 @@ CPed::ProcessObjective(void)
SetAttackTimer(time);
bObstacleShowedUpDuringKillObjective = false;
- } else if (foundEnt) {
- if (foundEnt->IsPed()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(500.0f, 1000.0f));
- bObstacleShowedUpDuringKillObjective = false;
- } else {
- if (foundEnt->IsObject()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(200.0f, 400.0f));
- bObstacleShowedUpDuringKillObjective = true;
- } else if (foundEnt->IsVehicle()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(400.0f, 600.0f));
- bObstacleShowedUpDuringKillObjective = true;
+ } else {
+ if (foundEnt) {
+ if (foundEnt->IsPed()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(500.0f, 1000.0f));
+ bObstacleShowedUpDuringKillObjective = false;
} else {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(700.0f, 1200.0f));
- bObstacleShowedUpDuringKillObjective = true;
+ if (foundEnt->IsObject()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(200.0f, 400.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ } else if (foundEnt->IsVehicle()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(400.0f, 600.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ } else {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(700.0f, 1200.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ }
}
- }
- m_fleeFrom = foundEnt;
- m_fleeFrom->RegisterReference((CEntity**) &m_fleeFrom);
+ m_fleeFrom = foundEnt;
+ m_fleeFrom->RegisterReference((CEntity**) &m_fleeFrom);
+ }
SetPointGunAt(m_pedInObjective);
}
}
@@ -1230,17 +1221,17 @@ CPed::ProcessObjective(void)
if (m_nPedType == PEDTYPE_COP) {
if (GetWeapon()->m_eWeaponType > WEAPONTYPE_COLT45
|| m_fleeFrom && m_fleeFrom->IsObject()) {
- wepRangeAdjusted = 6.0f;
+ maxDistToKeep = 6.0f;
} else if (m_fleeFrom && m_fleeFrom->IsVehicle()) {
- wepRangeAdjusted = 4.0f;
+ maxDistToKeep = 4.0f;
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
}
- if (distWithTargetSc <= wepRangeAdjusted) {
+ if (distWithTargetSc <= maxDistToKeep) {
SetMoveState(PEDMOVE_STILL);
bIsPointingGunAt = true;
if (m_nPedState != PED_AIM_GUN && !bDuckAndCover) {
@@ -1251,7 +1242,7 @@ CPed::ProcessObjective(void)
if (m_nPedState != PED_SEEK_ENTITY && m_nPedState != PED_SEEK_POS
&& !bStopAndShoot && !killPlayerInNoPoliceZone && !bKindaStayInSamePlace) {
Say(SOUND_PED_ATTACK);
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
bIsRunning = true;
}
}
@@ -1541,21 +1532,18 @@ CPed::ProcessObjective(void)
// I hope so
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
CVector maxShotPos = m_carInObjective->GetPosition() - ourHead;
- maxShotPos.Normalise();
- maxShotPos = maxShotPos * wepInfo->m_fRange + ourHead;
+ maxShotPos *= wepInfo->m_fRange / maxShotPos.Magnitude();
+ maxShotPos += ourHead;
- CWorld::bIncludeDeadPeds = true;
CColPoint foundCol;
CEntity *foundEnt;
- CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt,
- true, true, true, true, false, true, false);
+
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt, true, true, true, true, false, true, false);
CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_carInObjective) {
SetAttack(m_carInObjective);
- m_pPointGunAt = m_carInObjective;
- if (m_pPointGunAt)
- m_pPointGunAt->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_carInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
@@ -2629,7 +2617,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->IsPlayer() && ped->bGonnaKillTheCarJacker && ((CPlayerPed*)ped)->m_pArrestingCop) {
PedSetInCarCB(nil, ped);
ped->m_nLastPedState = ped->m_nPedState;
- ped->m_nPedState = PED_ARRESTED;
+ ped->SetPedState(PED_ARRESTED);
ped->bGonnaKillTheCarJacker = false;
if (veh) {
veh->m_nNumGettingIn = 0;
@@ -2990,9 +2978,15 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
}
if (ped->bFleeAfterExitingCar || ped->bGonnaKillTheCarJacker) {
- // POTENTIAL BUG? Why DOOR_FRONT_LEFT instead of door variable? or vice versa?
+#ifdef FIX_BUGS
+ if (!veh->IsDoorMissing(door))
+ ((CAutomobile*)veh)->Damage.SetDoorStatus(door, DOOR_STATUS_SWINGING);
+ PedSetOutCarCB(nil, ped);
+ return;
+#else
if (!veh->IsDoorMissing(door))
((CAutomobile*)veh)->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING);
+#endif
} else {
switch (door) {
case DOOR_FRONT_LEFT:
@@ -3346,7 +3340,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget);
- m_nPedState = PED_CARJACK;
+ SetPedState(PED_CARJACK);
car->bIsBeingCarJacked = true;
m_pMyVehicle = (CVehicle*)m_pSeekTarget;
m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle);
@@ -3393,7 +3387,7 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
SetMoveState(PEDMOVE_NONE);
LineUpPedWithCar(LINE_UP_TO_CAR_START);
m_pVehicleAnim = nil;
- m_nPedState = PED_DRAG_FROM_CAR;
+ SetPedState(PED_DRAG_FROM_CAR);
bChangedSeat = false;
bWillBeQuickJacked = quickJack;
@@ -3518,7 +3512,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
m_vehEnterType = doorNode;
- m_nPedState = PED_ENTER_CAR;
+ SetPedState(PED_ENTER_CAR);
if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
car->bIsBeingCarJacked = true;
}
@@ -3680,14 +3674,14 @@ void
CPed::SetExitBoat(CVehicle *boat)
{
#ifndef VC_PED_PORTS
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
CVector firstPos = GetPosition();
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f);
if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
m_vehEnterType = CAR_DOOR_RF;
- m_nPedState = PED_EXIT_CAR;
+ SetPedState(PED_EXIT_CAR);
} else {
m_vehEnterType = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
@@ -3700,7 +3694,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_vecMoveSpeed = boat->m_vecMoveSpeed;
bTryingToReachDryLand = true;
#else
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
CVector newPos = GetPosition();
RemoveInCarAnims();
CColModel* boatCol = boat->GetColModel();
@@ -3927,7 +3921,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
m_pSeekTarget = veh;
m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = optedDoorNode;
- m_nPedState = PED_EXIT_CAR;
+ SetPedState(PED_EXIT_CAR);
if (m_pVehicleAnim && m_pVehicleAnim->flags & ASSOC_PARTIAL)
m_pVehicleAnim->blendDelta = -1000.0f;
SetMoveState(PEDMOVE_NONE);
@@ -4475,7 +4469,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->bGonnaKillTheCarJacker = false;
if (!ped->m_pedInObjective || !(CGeneral::GetRandomNumber() & 1)) {
if (!driver || driver == ped || driver->IsPlayer() && CTheScripts::IsPlayerOnAMission()) {
- ped->m_nPedState = PED_NONE;
+ ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE;
ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 4000);
} else {
@@ -4504,7 +4498,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
else
#endif
{
- ped->m_nPedState = PED_NONE;
+ ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE;
ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
}
@@ -4597,7 +4591,7 @@ CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg)
return;
ped->bInVehicle = true;
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL);
veh->AddPassenger(ped);
@@ -4618,7 +4612,7 @@ CPed::SetEnterTrain(CVehicle *train, uint32 unused)
m_pMyVehicle = train;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
- m_nPedState = PED_ENTER_TRAIN;
+ SetPedState(PED_ENTER_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETIN, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetInTrainCB, this);
bUsesCollision = false;
@@ -4692,7 +4686,7 @@ CPed::SetExitTrain(CVehicle* train)
CVector exitPos;
GetNearestTrainPedPosition(train, exitPos);
*/
- m_nPedState = PED_EXIT_TRAIN;
+ SetPedState(PED_EXIT_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETOUT, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutTrainCB, this);
bUsesCollision = false;
@@ -4718,7 +4712,7 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->bUsesCollision = true;
ped->m_pVehicleAnim = nil;
ped->bInVehicle = false;
- ped->m_nPedState = PED_IDLE;
+ ped->SetPedState(PED_IDLE);
ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL);
@@ -5186,7 +5180,7 @@ CPed::SetSeekBoatPosition(CVehicle *boat)
m_pMyVehicle = boat;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_distanceToCountSeekDone = 0.5f;
- m_nPedState = PED_SEEK_IN_BOAT;
+ SetPedState(PED_SEEK_IN_BOAT);
}
void
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index 21310aaa..b57364d8 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -164,7 +164,7 @@ CPed::SetPointGunAt(CEntity *to)
if (m_nPedState != PED_ATTACK)
SetStoredState();
- m_nPedState = PED_AIM_GUN;
+ SetPedState(PED_AIM_GUN);
bIsPointingGunAt = true;
CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
SetMoveState(PEDMOVE_NONE);
@@ -222,7 +222,7 @@ CPed::ClearPointGunAt(void)
RestorePreviousState();
#else
if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) {
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
RestorePreviousState();
}
#endif
@@ -281,7 +281,7 @@ CPed::SetAttack(CEntity *victim)
(m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL && !(m_pedStats->m_flags & STAT_SHOPPING_BAGS))) {
if (m_nPedState != PED_ATTACK) {
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
bIsAttacking = false;
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, curWeapon->m_AnimToPlay, 8.0f);
animAssoc->SetRun();
@@ -329,7 +329,7 @@ CPed::SetAttack(CEntity *victim)
if (IsPlayer())
CPad::GetPad(0)->ResetAverageWeapon();
- PointBlankNecessity pointBlankStatus;
+ uint8 pointBlankStatus;
if ((curWeapon->m_eWeaponFire == WEAPON_FIRE_INSTANT_HIT || GetWeapon()->m_eWeaponType == WEAPONTYPE_FLAMETHROWER)
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON_RUNABOUT
@@ -348,7 +348,7 @@ CPed::SetAttack(CEntity *victim)
if (m_nPedState != PED_AIM_GUN)
SetStoredState();
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting) {
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f);
@@ -475,7 +475,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
ped->ClearAttack();
}
-PointBlankNecessity
+uint8
CPed::CheckForPointBlankPeds(CPed *pedToVerify)
{
float pbDistance = 1.1f;
@@ -786,7 +786,7 @@ CPed::StartFightAttack(uint8 buttonPressure)
RestoreHeadingRate();
}
- m_nPedState = PED_FIGHT;
+ SetPedState(PED_FIGHT);
m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@@ -1062,7 +1062,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
m_nWaitState = WAITSTATE_FALSE;
RestoreHeadingRate();
}
- m_nPedState = PED_FIGHT;
+ SetPedState(PED_FIGHT);
m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *walkStartAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@@ -1690,7 +1690,7 @@ CPed::FightStrike(CVector &touchedNodePos)
if (m_fightState == FIGHTSTATE_NO_MOVE)
m_fightState = FIGHTSTATE_1;
- m_vecHitLastPos = *touchedNodePos;
+ m_vecHitLastPos = touchedNodePos;
return false;
}
@@ -1796,7 +1796,7 @@ CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCount
SetStoredState();
bFindNewNodeAfterStateRestore = false;
- m_nPedState = PED_INVESTIGATE;
+ SetPedState(PED_INVESTIGATE);
m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
m_eventType = event;
m_eventOrThreat = pos;
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index ebd41296..8bace9a0 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -137,28 +137,28 @@ CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool change
}
void
-CPedIK::GetComponentPosition(RwV3d *pos, uint32 node)
+CPedIK::GetComponentPosition(RwV3d &pos, uint32 node)
{
RwFrame *f;
RwMatrix *mat;
#ifdef PED_SKIN
if(IsClumpSkinned(m_ped->GetClump())){
- pos->x = 0.0f;
- pos->y = 0.0f;
- pos->z = 0.0f;
+ pos.x = 0.0f;
+ pos.y = 0.0f;
+ pos.z = 0.0f;
mat = GetComponentMatrix(m_ped, node);
// could just copy the position out of the matrix...
- RwV3dTransformPoints(pos, pos, 1, mat);
+ RwV3dTransformPoints(&pos, &pos, 1, mat);
}else
#endif
{
f = m_ped->m_pFrames[node]->frame;
mat = RwFrameGetMatrix(f);
- *pos = mat->pos;
+ pos = mat->pos;
for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
- RwV3dTransformPoints(pos, pos, 1, RwFrameGetMatrix(f));
+ RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(f));
}
}
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index e91d7c06..4eeef6f0 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -51,7 +51,7 @@ public:
bool PointGunInDirection(float targetYaw, float targetPitch);
bool PointGunInDirectionUsingArm(float targetYaw, float targetPitch);
bool PointGunAtPosition(CVector const& position);
- void GetComponentPosition(RwV3d *pos, uint32 node);
+ void GetComponentPosition(RwV3d &pos, uint32 node);
static RwMatrix *GetWorldMatrix(RwFrame *source, RwMatrix *destination);
void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll);
void ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index fa865aec..8a6adbeb 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -47,8 +47,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = false;
- m_pPointGunAt = nil;
- m_nPedState = PED_IDLE;
+ SetWeaponLockOnTarget(nil);
+ SetPedState(PED_IDLE);
#ifndef FIX_BUGS
m_fCurrentStamina = m_fMaxStamina = 150.0f;
#endif
@@ -73,7 +73,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
void CPlayerPed::ClearWeaponTarget()
{
if (m_nPedType == PEDTYPE_PLAYER1) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrossHair();
}
@@ -113,14 +113,10 @@ CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{
if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++;
- } else {
- if (annoyedByPassingEntity) {
- if (m_pedStats->m_temper < 55) {
- m_pedStats->m_temper++;
- } else {
- m_pedStats->m_temper = 46;
- }
- }
+ } else if (annoyedByPassingEntity && m_pedStats->m_temper < 55) {
+ m_pedStats->m_temper++;
+ } else if (annoyedByPassingEntity) {
+ m_pedStats->m_temper = 46;
}
}
@@ -215,7 +211,7 @@ CPlayerPed::ReApplyMoveAnims(void)
for(int i = 0; i < ARRAY_SIZE(moveAnims); i++) {
CAnimBlendAssociation *curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), moveAnims[i]);
if (curMoveAssoc) {
- if (strcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) {
+ if (CGeneral::faststrcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name)) {
CAnimBlendAssociation *newMoveAssoc = CAnimManager::AddAnimation(GetClump(), m_animGroup, moveAnims[i]);
newMoveAssoc->blendDelta = curMoveAssoc->blendDelta;
newMoveAssoc->blendAmount = curMoveAssoc->blendAmount;
@@ -248,7 +244,7 @@ CPlayerPed::SetInitialState(void)
if (m_pFire)
m_pFire->Extinguish();
RpAnimBlendClumpRemoveAllAssociations(GetClump());
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL);
m_nLastPedState = PED_NONE;
m_animGroup = ASSOCGRP_PLAYER;
@@ -288,7 +284,7 @@ CPlayerPed::SetRealMoveAnim(void)
if (!curIdleAssoc)
curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
- if ((!curRunStopAssoc || !(curRunStopAssoc->IsRunning())) && (!curRunStopRAssoc || !(curRunStopRAssoc->IsRunning()))) {
+ if (!((curRunStopAssoc && curRunStopAssoc->IsRunning()) || (curRunStopRAssoc && curRunStopRAssoc->IsRunning()))) {
if (curRunStopAssoc && curRunStopAssoc->blendDelta >= 0.0f || curRunStopRAssoc && curRunStopRAssoc->blendDelta >= 0.0f) {
if (curRunStopAssoc) {
@@ -340,8 +336,8 @@ CPlayerPed::SetRealMoveAnim(void)
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f);
}
}
-
m_nMoveState = PEDMOVE_STILL;
+
} else {
if (curIdleAssoc) {
if (curWalkStartAssoc) {
@@ -394,6 +390,7 @@ CPlayerPed::SetRealMoveAnim(void)
}
if (curSprintAssoc && (m_nMoveState != PEDMOVE_SPRINT || m_fMoveSpeed < 0.4f)) {
+ // Stop sprinting in various conditions
if (curSprintAssoc->blendAmount == 0.0f) {
curSprintAssoc->blendDelta = -1000.0f;
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
@@ -417,8 +414,8 @@ CPlayerPed::SetRealMoveAnim(void)
curRunAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->blendAmount = 0.0f;
curRunAssoc->blendDelta = 0.0f;
- } else if (curSprintAssoc->blendDelta >= 0.0f) {
+ } else if (curSprintAssoc->blendDelta >= 0.0f) {
// Stop sprinting when tired
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
curSprintAssoc->blendDelta = -1.0f;
@@ -428,7 +425,9 @@ CPlayerPed::SetRealMoveAnim(void)
curSprintAssoc->blendDelta = -8.0f;
curRunAssoc->blendDelta = 8.0f;
}
+
} else if (curWalkStartAssoc) {
+ // Walk start and walk/run shouldn't run at the same time
curWalkAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->flags &= ~ASSOC_RUNNING;
curWalkAssoc->blendAmount = 0.0f;
@@ -436,11 +435,13 @@ CPlayerPed::SetRealMoveAnim(void)
} else if (m_nMoveState == PEDMOVE_SPRINT) {
if (curSprintAssoc) {
+ // We have anim, do it
if (curSprintAssoc->blendDelta < 0.0f) {
curSprintAssoc->blendDelta = 2.0f;
curRunAssoc->blendDelta = -2.0f;
}
} else {
+ // Transition between run-sprint
curWalkAssoc->blendAmount = 0.0f;
curRunAssoc->blendAmount = 1.0f;
curSprintAssoc = CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_SPRINT, 2.0f);
@@ -703,14 +704,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
float padMove = CVector2D(leftRight, upDown).Magnitude();
float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE;
if (padMoveInGameUnit > 0.0f) {
-#ifdef FREE_CAM
- if (!CCamera::bFreeCam)
- m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
- else
- m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
-#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
-#endif
m_fMoveSpeed = Min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
@@ -718,8 +712,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -730,8 +723,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
m_fMoveSpeed = 0.0f;
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -856,10 +848,9 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
{
CEntity *nextTarget = nil;
float weaponRange = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_fRange;
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
- // unused
- // CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
+ // CGeneral::GetATanOfXY(GetForward().x, GetForward().y); // unused
CVector distVec = previousTarget->GetPosition() - GetPosition();
float referenceBeta = CGeneral::GetATanOfXY(distVec.x, distVec.y);
@@ -884,9 +875,7 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}
@@ -900,14 +889,14 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (m_pPointGunAt) {
CVector distVec = m_pPointGunAt->GetPosition() - GetPosition();
if (distVec.Magnitude2D() > weaponRange) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
return false;
} else {
return true;
}
}
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
float referenceBeta = CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
for (int h = CPools::GetPedPool()->GetSize() - 1; h >= 0; h--) {
@@ -931,9 +920,7 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}
@@ -1002,7 +989,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed->TargetJustDown()) {
SetStoredState();
- m_nPedState = PED_SNIPER_MODE;
+ SetPedState(PED_SNIPER_MODE);
#ifdef FREE_CAM
if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
@@ -1105,7 +1092,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
}
}
- } else if (weaponInfo->m_bCanAimWithArm)
+ } else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK)
ClearPointGunAt();
}
}
@@ -1159,7 +1146,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#else
CVector markPos;
if (m_pPointGunAt->IsPed()) {
- ((CPed*)m_pPointGunAt)->m_pedIK.GetComponentPosition((RwV3d*)markPos, PED_MID);
+ ((CPed*)m_pPointGunAt)->m_pedIK.GetComponentPosition(markPos, PED_MID);
} else {
markPos = m_pPointGunAt->GetPosition();
}
@@ -1212,8 +1199,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -1225,8 +1211,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -1291,25 +1276,26 @@ CPlayerPed::ProcessControl(void)
if (m_nPedState == PED_DRIVING && m_objective != OBJECTIVE_LEAVE_CAR) {
if (m_pMyVehicle->IsCar() && ((CAutomobile*)m_pMyVehicle)->Damage.GetDoorStatus(DOOR_FRONT_LEFT) == DOOR_STATUS_SWINGING) {
CAnimBlendAssociation *rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR);
- if (!rollDoorAssoc) {
- rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW);
- }
-
- // These comparisons are wrong, they return uint16
- if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || padUsed
- && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f
- || padUsed->GetBrake() != 0.0f)) {
+ if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || (rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW))) {
if (rollDoorAssoc)
m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
+
} else {
- m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
- if (m_pMyVehicle->bLowVehicle)
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
- else
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
+ // These comparisons are wrong, they return uint16
+ if (padUsed && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f || padUsed->GetBrake() != 0.0f)) {
+ if (rollDoorAssoc)
+ m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
- rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ } else {
+ m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
+ if (m_pMyVehicle->bLowVehicle)
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
+ else
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
+
+ rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ }
}
}
return;
@@ -1338,12 +1324,18 @@ CPlayerPed::ProcessControl(void)
case PED_FIGHT:
case PED_AIM_GUN:
if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) {
- if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+ if (TheCamera.Cams[0].Using3rdPersonMouseCam()
+#ifdef FREE_CAM
+ && !CCamera::bFreeCam
+#endif
+ ) {
if (padUsed)
PlayerControl1stPersonRunAround(padUsed);
+
} else if (m_nPedState == PED_FIGHT) {
if (padUsed)
PlayerControlFighter(padUsed);
+
} else if (padUsed) {
PlayerControlZelda(padUsed);
}
@@ -1351,41 +1343,6 @@ CPlayerPed::ProcessControl(void)
if (IsPedInControl() && padUsed)
ProcessPlayerWeapon(padUsed);
break;
- case PED_LOOK_ENTITY:
- case PED_LOOK_HEADING:
- case PED_WANDER_RANGE:
- case PED_WANDER_PATH:
- case PED_PURSUE:
- case PED_FOLLOW_PATH:
- case PED_ROCKET_MODE:
- case PED_DUMMY:
- case PED_PAUSE:
- case PED_FACE_PHONE:
- case PED_MAKE_CALL:
- case PED_CHAT:
- case PED_MUG:
- case PED_AI_CONTROL:
- case PED_FOLLOW_ROUTE:
- case PED_CPR:
- case PED_SOLICIT:
- case PED_BUY_ICECREAM:
- case PED_INVESTIGATE:
- case PED_STEP_AWAY:
- case PED_ON_FIRE:
- case PED_UNKNOWN:
- case PED_STATES_NO_AI:
- case PED_STAGGER:
- case PED_DIVE_AWAY:
- case PED_STATES_NO_ST:
- case PED_ARREST_PLAYER:
- case PED_DRIVING:
- case PED_PASSENGER:
- case PED_TAXI_PASSENGER:
- case PED_OPEN_DOOR:
- case PED_DIE:
- case PED_DEAD:
- case PED_HANDS_UP:
- break;
case PED_SEEK_ENTITY:
m_vecSeekPos = m_pSeekTarget->GetPosition();
@@ -1415,6 +1372,7 @@ CPlayerPed::ProcessControl(void)
if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed)
PlayerControlM16(padUsed);
+
} else if (padUsed) {
PlayerControlSniper(padUsed);
}
@@ -1464,6 +1422,8 @@ CPlayerPed::ProcessControl(void)
if (m_nLastPedState == PED_DRAG_FROM_CAR && m_pVehicleAnim)
BeingDraggedFromCar();
break;
+ default:
+ break;
}
if (padUsed && IsPedShootable()) {
ProcessWeaponSwitch(padUsed);
@@ -1477,20 +1437,17 @@ CPlayerPed::ProcessControl(void)
m_lookTimer = 0;
float camAngle = CGeneral::LimitRadianAngle(TheCamera.Cams[TheCamera.ActiveCam].Front.Heading());
float angleBetweenPlayerAndCam = Abs(camAngle - m_fRotationCur);
- if (m_nPedState != PED_ATTACK
- && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
+ if (m_nPedState != PED_ATTACK && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
if (angleBetweenPlayerAndCam > DEGTORAD(150.0f) && angleBetweenPlayerAndCam < DEGTORAD(210.0f)) {
float rightTurnAngle = CGeneral::LimitRadianAngle(m_fRotationCur - DEGTORAD(150.0f));
float leftTurnAngle = CGeneral::LimitRadianAngle(DEGTORAD(150.0f) + m_fRotationCur);
- if (m_fLookDirection != 999999.0f) {
- if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
- camAngle = rightTurnAngle;
- else
- camAngle = leftTurnAngle;
- } else {
+ if (m_fLookDirection == 999999.0f)
camAngle = rightTurnAngle;
- }
+ else if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
+ camAngle = rightTurnAngle;
+ else
+ camAngle = leftTurnAngle;
}
SetLookFlag(camAngle, true);
SetLookTimer(CTimer::GetTimeStepInMilliseconds() * 5.0f);
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index b3eaf471..5dbde649 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -718,10 +718,10 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (i != 0) {
// Gang member
newPed->SetLeader(gangLeader);
-#ifndef FIX_BUGS
+#if !defined(FIX_BUGS) && GTA_VERSION >= GTA3_PC_10
// seems to be a miami leftover (this code is not on PS2) but gang peds end up just being frozen
- newPed->m_nPedState = PED_UNKNOWN;
- gangLeader->m_nPedState = PED_UNKNOWN;
+ newPed->SetPedState(PED_UNKNOWN);
+ gangLeader->SetPedState(PED_UNKNOWN);
newPed->m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints(
gangLeader->GetPosition().x, gangLeader->GetPosition().y,
newPed->GetPosition().x, newPed->GetPosition().y);
diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp
index 161418b9..b5af6619 100644
--- a/src/render/Clouds.cpp
+++ b/src/render/Clouds.cpp
@@ -133,7 +133,7 @@ CClouds::Render(void)
CSprite::InitSpriteBuffer();
int minute = CClock::GetHours()*60 + CClock::GetMinutes();
- RwV3d campos = *(RwV3d*)&TheCamera.GetPosition();
+ RwV3d campos = TheCamera.GetPosition();
// Moon
int moonfadeout = Abs(minute - 180); // fully visible at 3AM
diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp
index 33c3f4bf..48f0f6b9 100644
--- a/src/render/Coronas.cpp
+++ b/src/render/Coronas.cpp
@@ -255,7 +255,7 @@ CCoronas::Render(void)
CVector spriteCoors;
float spritew, spriteh;
- if(!CSprite::CalcScreenCoors(aCoronas[i].coors, spriteCoors, &spritew, &spriteh, true)){
+ if(!CSprite::CalcScreenCoors(aCoronas[i].coors, &spriteCoors, &spritew, &spriteh, true)){
aCoronas[i].offScreen = true;
aCoronas[i].sightClear = false;
}else{
@@ -464,7 +464,7 @@ CCoronas::RenderReflections(void)
CVector spriteCoors;
float spritew, spriteh;
- if(CSprite::CalcScreenCoors(coors, spriteCoors, &spritew, &spriteh, true)){
+ if(CSprite::CalcScreenCoors(coors, &spriteCoors, &spritew, &spriteh, true)){
float drawDist = 0.75f * aCoronas[i].drawDist;
drawDist = Min(drawDist, 55.0f);
if(spriteCoors.z < drawDist){
@@ -531,7 +531,7 @@ CCoronas::DoSunAndMoon(void)
CVector spriteCoors;
float spritew, spriteh;
- if(CSprite::CalcScreenCoors(sunCoors, spriteCoors, &spritew, &spriteh, true)){
+ if(CSprite::CalcScreenCoors(sunCoors, &spriteCoors, &spritew, &spriteh, true)){
SunScreenX = spriteCoors.x;
SunScreenY = spriteCoors.y;
}else{
diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp
index 690a1d3f..c76d6109 100644
--- a/src/render/Fluff.cpp
+++ b/src/render/Fluff.cpp
@@ -655,7 +655,7 @@ void CScrollBar::Render()
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
CVector coronaCoord, screenCoord;
- float screenW, screenH;
+ float screenW, screenH;
for (int i = 1; i < ARRAY_SIZE(m_MessageBar); ++i)
{
for (int j = 0; j < 5; ++j)
@@ -667,7 +667,7 @@ void CScrollBar::Render()
// Render main coronas
if (m_MessageBar[i] & (1 << j))
{
- if (CSprite::CalcScreenCoors(coronaCoord, screenCoord, &screenW, &screenH, true))
+ if (CSprite::CalcScreenCoors(coronaCoord, &screenCoord, &screenW, &screenH, true))
{
CSprite::RenderBufferedOneXLUSprite(
screenCoord.x, screenCoord.y, screenCoord.z,
@@ -679,7 +679,7 @@ void CScrollBar::Render()
// Render smaller and faded coronas for a trailing effect
else if (m_MessageBar[i - 1] & (1 << j))
{
- if (CSprite::CalcScreenCoors(coronaCoord, screenCoord, &screenW, &screenH, true))
+ if (CSprite::CalcScreenCoors(coronaCoord, &screenCoord, &screenW, &screenH, true))
{
CSprite::RenderBufferedOneXLUSprite(
screenCoord.x, screenCoord.y, screenCoord.z,
@@ -834,7 +834,7 @@ void CDigitalClock::Render()
const char* clockMessage = FindDigitalClockMessage();
CVector coronaCoord, screenCoord;
- float screenW, screenH;
+ float screenW, screenH;
for (int c = 0; c < 5; ++c) // for each char to be displayed
{
for (int i = 0; i < 5; ++i) // for each column of coronas
@@ -847,7 +847,7 @@ void CDigitalClock::Render()
coronaCoord.y = m_Position.y + (8 * c + i) * m_Size.y * m_fScale / 8.0f;
coronaCoord.z = m_Position.z + j * m_fScale / 8.0f;
- if (CSprite::CalcScreenCoors(coronaCoord, screenCoord, &screenW, &screenH, true))
+ if (CSprite::CalcScreenCoors(coronaCoord, &screenCoord, &screenW, &screenH, true))
{
CSprite::RenderBufferedOneXLUSprite(
screenCoord.x, screenCoord.y, screenCoord.z,
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index 2b19486e..f175c264 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -1570,7 +1570,7 @@ void CParticle::Render()
float w;
float h;
- if ( CSprite::CalcScreenCoors(particle->m_vecPosition, coors, &w, &h, true) )
+ if ( CSprite::CalcScreenCoors(particle->m_vecPosition, &coors, &w, &h, true) )
{
#ifdef PC_PARTICLE
if ( (!particleBanned || SCREEN_WIDTH * fParticleScaleLimit >= w)
@@ -1650,7 +1650,7 @@ void CParticle::Render()
float fRotation;
float fTrailLength;
- if ( CSprite::CalcScreenCoors(vecPrevPos, particle->m_vecScreenPosition, &fTrailLength, &fRotation, true) )
+ if ( CSprite::CalcScreenCoors(vecPrevPos, &particle->m_vecScreenPosition, &fTrailLength, &fRotation, true) )
{
CVector2D vecDist
(
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index 0713dc6d..6f0b4d46 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -218,7 +218,7 @@ CPointLights::RenderFogEffect(void)
// more intensity the closer to line
intensity *= 1.0f - sq(Sqrt(linedistsq) / FOG_AREA_WIDTH);
- if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){
+ if(CSprite::CalcScreenCoors(fogcoors, &spriteCoors, &spritew, &spriteh, true)){
float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x2000;
float size = FogSizes[r>>1];
CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z,
@@ -267,7 +267,7 @@ CPointLights::RenderFogEffect(void)
intensity *= 1.0f - sq(lightdist / FOG_AREA_RADIUS);
CVector fogcoors(xi, yi, point.point.z + 1.6f);
- if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){
+ if(CSprite::CalcScreenCoors(fogcoors, &spriteCoors, &spritew, &spriteh, true)){
float rotation = (CTimer::GetTimeInMilliseconds()&0x3FFF) * 2*3.14f / 0x4000;
float size = FogSizes[r>>1];
CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z,
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index a0f66819..d47cac31 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -741,7 +741,7 @@ CRenderer::ScanWorld(void)
vectors[CORNER_PRIO_RIGHT].x = vectors[CORNER_LOD_RIGHT].x * 0.2f;
vectors[CORNER_PRIO_RIGHT].y = vectors[CORNER_LOD_RIGHT].y * 0.2f;
vectors[CORNER_PRIO_RIGHT].z = vectors[CORNER_LOD_RIGHT].z;
- RwV3dTransformPoints((RwV3d*)vectors, (RwV3d*)vectors, 9, cammatrix);
+ RwV3dTransformPoints(vectors, vectors, 9, cammatrix);
m_loadingPriority = false;
if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN ||
@@ -881,7 +881,7 @@ CRenderer::RequestObjectsInFrustum(void)
vectors[CORNER_PRIO_RIGHT].x = vectors[CORNER_LOD_RIGHT].x * 0.2f;
vectors[CORNER_PRIO_RIGHT].y = vectors[CORNER_LOD_RIGHT].y * 0.2f;
vectors[CORNER_PRIO_RIGHT].z = vectors[CORNER_LOD_RIGHT].z;
- RwV3dTransformPoints((RwV3d*)vectors, (RwV3d*)vectors, 9, cammatrix);
+ RwV3dTransformPoints(vectors, vectors, 9, cammatrix);
if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN ||
#ifdef FIX_BUGS
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index ecfccc90..a0c7ae31 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "main.h"
#include "FileMgr.h"
+#include "FileLoader.h"
#include "TxdStore.h"
#include "Timer.h"
#include "Weather.h"
@@ -30,8 +31,8 @@ float TEXTURE_ADDV;
int32 CWaterLevel::ms_nNoOfWaterLevels;
float CWaterLevel::ms_aWaterZs[48];
CRect CWaterLevel::ms_aWaterRects[48];
-uint8 CWaterLevel::aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE];
-uint8 CWaterLevel::aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE];
+int8 CWaterLevel::aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
+int8 CWaterLevel::aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
bool CWaterLevel::WavesCalculatedThisFrame;
RpAtomic *CWaterLevel::ms_pWavyAtomic;
RpGeometry *CWaterLevel::apGeomArray[8];
@@ -53,41 +54,179 @@ const float fGreenMult = 1.0f;
const float fBlueMult = 1.4f;
-
void
CWaterLevel::Initialise(Const char *pWaterDat)
{
ms_nNoOfWaterLevels = 0;
-
+
+#ifdef MASTER
int32 hFile = -1;
-
+
do
{
hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
}
while ( hFile < 0 );
-
- if ( hFile > 0 )
+#else
+ int32 hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
+#endif
+
+ if (hFile > 0)
{
- if ( hFile >= 0 )
+ CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
+ CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
+ CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
+ CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
+ CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+
+ CFileMgr::CloseFile(hFile);
+ }
+#ifndef MASTER
+ else
+ {
+ printf("Init waterlevels\n");
+
+ CFileMgr::SetDir("");
+ hFile = CFileMgr::OpenFile(pWaterDat, "r");
+
+ char *line;
+
+ while ((line = CFileLoader::LoadLine(hFile)))
{
- CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
- CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
- CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
- CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
- CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+#ifdef FIX_BUGS
+ if (*line && *line != ';' && !strstr(line, "* ;end of file"))
+#else
+ if (*line && *line != ';')
+#endif
+ {
+ float z, l, b, r, t;
+ sscanf(line, "%f %f %f %f %f", &z, &l, &b, &r, &t);
+ AddWaterLevel(l, b, r, t, z);
+ }
}
-
+
CFileMgr::CloseFile(hFile);
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+
+ // rasterize water rects read from file
+ for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
+ {
+ int32 l = WATER_HUGE_X(ms_aWaterRects[i].left);
+ int32 r = WATER_HUGE_X(ms_aWaterRects[i].right) + 1.0f;
+ int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
+ int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
+
+#ifdef FIX_BUGS
+ // water.dat has rects that go out of bounds
+ // which causes memory corruption
+ l = clamp(l, 0, MAX_SMALL_SECTORS - 1);
+ r = clamp(r, 0, MAX_SMALL_SECTORS - 1);
+ t = clamp(t, 0, MAX_SMALL_SECTORS - 1);
+ b = clamp(b, 0, MAX_SMALL_SECTORS - 1);
+#endif
+
+ for (int32 x = l; x <= r; x++)
+ {
+ for (int32 y = t; y <= b; y++)
+ {
+ aWaterFineBlockList[x][y] = i;
+ }
+ }
+ }
+
+ // remove tiles that are obscured by land
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ float worldX = WATER_START_X + x * SMALL_SECTOR_SIZE;
+
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] >= 0)
+ {
+ float worldY = WATER_START_Y + y * SMALL_SECTOR_SIZE;
+
+ int32 i;
+ for (i = 0; i <= 8; i++)
+ {
+ for (int32 j = 0; j <= 8; j++)
+ {
+ CVector worldPos = CVector(worldX + i * (SMALL_SECTOR_SIZE / 8), worldY + j * (SMALL_SECTOR_SIZE / 8), ms_aWaterZs[aWaterFineBlockList[x][y]]);
+
+ if ((worldPos.x > WORLD_MIN_X && worldPos.x < WORLD_MAX_X) && (worldPos.y > WORLD_MIN_Y && worldPos.y < WORLD_MAX_Y) &&
+ (!WaterLevelAccordingToRectangles(worldPos.x, worldPos.y) || TestVisibilityForFineWaterBlocks(worldPos)))
+ continue;
+
+ // at least one point in the tile wasn't blocked, so don't remove water
+ i = 1000;
+ break;
+ }
+ }
+
+ if (i < 1000)
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ RemoveIsolatedWater();
+
+ // calculate coarse tiles from fine tiles
+ for (int32 x = 0; x < MAX_LARGE_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_LARGE_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x * 2][y * 2] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2];
+ }
+ else if (aWaterFineBlockList[x * 2 + 1][y * 2] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2];
+ }
+ else if (aWaterFineBlockList[x * 2][y * 2 + 1] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2 + 1];
+ }
+ else if (aWaterFineBlockList[x * 2 + 1][y * 2 + 1] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2 + 1];
+ }
+ else
+ {
+ aWaterBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ hFile = CFileMgr::OpenFileForWriting("data\\waterpro.dat");
+
+ if (hFile > 0)
+ {
+ CFileMgr::Write(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
+ CFileMgr::Write(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
+ CFileMgr::Write(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
+ CFileMgr::Write(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
+ CFileMgr::Write(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+
+ CFileMgr::CloseFile(hFile);
+ }
}
+#endif
CTxdStore::PushCurrentTxd();
int32 slot = CTxdStore::FindTxdSlot("particle");
CTxdStore::SetCurrentTxd(slot);
- if ( gpWaterTex == NULL )
- gpWaterTex = RwTextureRead("water_old", NULL);
+ if ( gpWaterTex == nil )
+ gpWaterTex = RwTextureRead("water_old", nil);
gpWaterRaster = RwTextureGetRaster(gpWaterTex);
CTxdStore::PopCurrentTxd();
@@ -104,10 +243,10 @@ CWaterLevel::Shutdown()
FreeBoatWakeArray();
DestroyWavyAtomic();
- if ( gpWaterTex != NULL )
+ if ( gpWaterTex != nil )
{
RwTextureDestroy(gpWaterTex);
- gpWaterTex = NULL;
+ gpWaterTex = nil;
}
}
@@ -129,15 +268,15 @@ CWaterLevel::CreateWavyAtomic()
|rpGEOMETRYPRELIT
|rpGEOMETRYMODULATEMATERIALCOLOR);
- ASSERT(wavyGeometry != NULL);
+ ASSERT(wavyGeometry != nil);
}
{
wavyMaterial = RpMaterialCreate();
- ASSERT(wavyMaterial != NULL);
- ASSERT(gpWaterTex != NULL);
+ ASSERT(wavyMaterial != nil);
+ ASSERT(gpWaterTex != nil);
RpMaterialSetTexture(wavyMaterial, gpWaterTex);
}
@@ -145,7 +284,7 @@ CWaterLevel::CreateWavyAtomic()
{
wavyTriangles = RpGeometryGetTriangles(wavyGeometry);
- ASSERT(wavyTriangles != NULL);
+ ASSERT(wavyTriangles != nil);
/*
[B] [C]
***********
@@ -176,9 +315,9 @@ CWaterLevel::CreateWavyAtomic()
{
wavyMorphTarget = RpGeometryGetMorphTarget(wavyGeometry, 0);
- ASSERT(wavyMorphTarget != NULL);
+ ASSERT(wavyMorphTarget != nil);
wavyVert = RpMorphTargetGetVertices(wavyMorphTarget);
- ASSERT(wavyVert != NULL);
+ ASSERT(wavyVert != nil);
for ( int32 i = 0; i < 9; i++ )
{
@@ -198,10 +337,10 @@ CWaterLevel::CreateWavyAtomic()
{
wavyFrame = RwFrameCreate();
- ASSERT( wavyFrame != NULL );
+ ASSERT( wavyFrame != nil );
ms_pWavyAtomic = RpAtomicCreate();
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RpAtomicSetGeometry(ms_pWavyAtomic, wavyGeometry, 0);
RpAtomicSetFrame(ms_pWavyAtomic, wavyFrame);
@@ -222,6 +361,170 @@ CWaterLevel::DestroyWavyAtomic()
RwFrameDestroy(frame);
}
+#ifndef MASTER
+void
+CWaterLevel::AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel)
+{
+ ms_aWaterRects[ms_nNoOfWaterLevels] = CRect(fXLeft, fYBottom, fXRight, fYTop);
+ ms_aWaterZs[ms_nNoOfWaterLevels] = fLevel;
+ ms_nNoOfWaterLevels++;
+}
+
+bool
+CWaterLevel::WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel)
+{
+ if (ms_nNoOfWaterLevels <= 0) return false;
+
+ for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
+ {
+ if (fX >= ms_aWaterRects[i].left && fX <= ms_aWaterRects[i].right
+ && fY >= ms_aWaterRects[i].top && fY <= ms_aWaterRects[i].bottom)
+ {
+ if (pfOutLevel) *pfOutLevel = ms_aWaterZs[i];
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos)
+{
+ static CVector2D tab[] =
+ {
+ { 50.0f, 50.0f },
+ { -50.0f, 50.0f },
+ { -50.0f, -50.0f },
+ { 50.0f, -50.0f },
+ { 50.0f, 0.0f },
+ { -50.0f, 0.0f },
+ { 0.0f, -50.0f },
+ { 0.0f, 50.0f },
+ };
+
+ CEntity *entity;
+ CColPoint col;
+ CVector lineStart, lineEnd;
+
+ lineStart = worldPos;
+
+ if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
+ {
+ lineStart.x += 0.4f;
+ lineStart.y += 0.4f;
+
+ if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
+ {
+ return false;
+ }
+ }
+
+ for (int32 i = 0; i < ARRAY_SIZE(tab); i++)
+ {
+ lineStart = worldPos;
+ lineEnd = worldPos;
+
+ lineEnd.x += tab[i].x;
+ lineEnd.y += tab[i].y;
+ lineEnd.z += 100.0f;
+
+ if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y))
+ {
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ {
+ lineStart.x += 0.4f;
+ lineStart.y += 0.4f;
+ lineEnd.x += 0.4f;
+ lineEnd.y += 0.4f;
+
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+void
+CWaterLevel::RemoveIsolatedWater()
+{
+ bool (*isConnected)[MAX_SMALL_SECTORS] = new bool[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ isConnected[x][y] = false;
+ }
+ }
+
+ isConnected[0][0] = true;
+ bool keepGoing;
+
+ do
+ {
+ keepGoing = false;
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] < 0 || isConnected[x][y])
+ continue;
+
+ if (x > 0 && isConnected[x - 1][y])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (y > 0 && isConnected[x][y - 1])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (x + 1 < MAX_SMALL_SECTORS && isConnected[x + 1][y])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (y + 1 < MAX_SMALL_SECTORS && isConnected[x][y + 1])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+ }
+ }
+ }
+ while (keepGoing);
+
+ int32 numRemoved = 0;
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] >= 0 && !isConnected[x][y] && ms_aWaterZs[aWaterFineBlockList[x][y]] == 0.0f)
+ {
+ numRemoved++;
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ printf("Removed %d isolated patches of water\n", numRemoved);
+
+ delete[] isConnected;
+}
+#endif
+
bool
CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ)
{
@@ -231,12 +534,12 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
- uint8 nBlock = aWaterFineBlockList[x][y];
+ int8 nBlock = aWaterFineBlockList[x][y];
- if ( nBlock == 128 )
+ if ( nBlock == NO_WATER )
return false;
- ASSERT( pfOutLevel != NULL );
+ ASSERT( pfOutLevel != nil );
*pfOutLevel = ms_aWaterZs[nBlock];
float fAngle = (CTimer::GetTimeInMilliseconds() & 4095) * (TWOPI / 4096.0f);
@@ -270,12 +573,12 @@ CWaterLevel::GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLeve
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
- uint8 nBlock = aWaterFineBlockList[x][y];
+ int8 nBlock = aWaterFineBlockList[x][y];
- if ( nBlock == 128 )
+ if ( nBlock == NO_WATER )
return false;
- ASSERT( pfOutLevel != NULL );
+ ASSERT( pfOutLevel != nil );
*pfOutLevel = ms_aWaterZs[nBlock];
return true;
@@ -418,10 +721,10 @@ CWaterLevel::RenderWater()
{
for ( int32 y = nStartY; y <= nEndY; y++ )
{
- if ( !(aWaterBlockList[2*x+0][2*y+0] & 128)
- || !(aWaterBlockList[2*x+1][2*y+0] & 128)
- || !(aWaterBlockList[2*x+0][2*y+1] & 128)
- || !(aWaterBlockList[2*x+1][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+0] >= 0
+ || aWaterBlockList[2*x+1][2*y+0] >= 0
+ || aWaterBlockList[2*x+0][2*y+1] >= 0
+ || aWaterBlockList[2*x+1][2*y+1] >= 0 )
{
float fX = WATER_FROM_HUGE_SECTOR_X(x);
float fY = WATER_FROM_HUGE_SECTOR_Y(y);
@@ -443,16 +746,16 @@ CWaterLevel::RenderWater()
{
float fZ;
- if ( !(aWaterBlockList[2*x+0][2*y+0] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+0] ];
- if ( !(aWaterBlockList[2*x+1][2*y+0] & 128) )
+ if ( aWaterBlockList[2*x+1][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+0] ];
- if ( !(aWaterBlockList[2*x+0][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+1] ];
- if ( !(aWaterBlockList[2*x+1][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+1][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+1] ];
RenderOneFlatHugeWaterPoly(fX, fY, fZ, color);
@@ -463,7 +766,7 @@ CWaterLevel::RenderWater()
{
for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
{
- if ( !(aWaterBlockList[x2][y2] & 128) )
+ if ( aWaterBlockList[x2][y2] >= 0 )
{
float fLargeX = WATER_FROM_LARGE_SECTOR_X(x2);
float fLargeY = WATER_FROM_LARGE_SECTOR_Y(y2);
@@ -498,7 +801,7 @@ CWaterLevel::RenderWater()
float fZ;
// WS
- if ( !(aWaterFineBlockList[2*x2+0][2*y2+0] & 128) )
+ if ( aWaterFineBlockList[2*x2+0][2*y2+0] >= 0 )
{
float fSmallX = fLargeX;
float fSmallY = fLargeY;
@@ -519,7 +822,7 @@ CWaterLevel::RenderWater()
}
// SE
- if ( !(aWaterFineBlockList[2*x2+1][2*y2+0] & 128) )
+ if ( aWaterFineBlockList[2*x2+1][2*y2+0] >= 0 )
{
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY;
@@ -540,7 +843,7 @@ CWaterLevel::RenderWater()
}
// WN
- if ( !(aWaterFineBlockList[2*x2+0][2*y2+1] & 128) )
+ if ( aWaterFineBlockList[2*x2+0][2*y2+1] >= 0 )
{
float fSmallX = fLargeX;
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@@ -561,7 +864,7 @@ CWaterLevel::RenderWater()
}
//NE
- if ( !(aWaterFineBlockList[2*x2+1][2*y2+1] & 128) )
+ if ( aWaterFineBlockList[2*x2+1][2*y2+1] >= 0 )
{
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@@ -591,7 +894,7 @@ CWaterLevel::RenderWater()
}
} // if ( TheCamera.IsSphereVisible
} // if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr )
- } // if ( !(aWaterBlockList[x2][y2] & 128) )
+ } // if ( aWaterBlockList[x2][y2] >= 0 )
} // for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
} // for ( int32 x2 = 2*x; x2 <= 2*x+1; x2++ )
//
@@ -948,19 +1251,19 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
CBoat::FillBoatList();
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RpGeometry *geometry = RpAtomicGetGeometry(ms_pWavyAtomic);
- ASSERT( geometry != NULL );
+ ASSERT( geometry != nil );
RwRGBA *wavyPreLights = RpGeometryGetPreLightColors(geometry);
RwTexCoords *wavyTexCoords = RpGeometryGetVertexTexCoords(geometry, rwTEXTURECOORDINATEINDEX0);
RwV3d *wavyVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geometry, 0));
- ASSERT( wavyPreLights != NULL );
- ASSERT( wavyTexCoords != NULL );
- ASSERT( wavyVertices != NULL );
+ ASSERT( wavyPreLights != nil );
+ ASSERT( wavyTexCoords != nil );
+ ASSERT( wavyVertices != nil );
RpGeometryLock(geometry, rpGEOMETRYLOCKVERTICES
| rpGEOMETRYLOCKPRELIGHT
@@ -983,7 +1286,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RpGeometryUnlock(geometry);
}
- static CBoat *apBoatList[4] = { NULL };
+ static CBoat *apBoatList[4] = { nil };
if ( apGeomArray[0]
&& nGeomUsed < MAX_BOAT_WAKES
@@ -997,16 +1300,16 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
RpGeometry *geom = apGeomArray[nGeomUsed++];
- ASSERT( wavyGeometry != NULL );
- ASSERT( geom != NULL );
+ ASSERT( wavyGeometry != nil );
+ ASSERT( geom != nil );
RpAtomic *atomic = RpAtomicCreate();
- ASSERT( atomic != NULL );
+ ASSERT( atomic != nil );
RpAtomicSetGeometry(atomic, geom, 0);
RwFrame *frame = RwFrameCreate();
- ASSERT( frame != NULL );
+ ASSERT( frame != nil );
RwMatrixCopy(RwFrameGetMatrix(frame), RwFrameGetMatrix(RpAtomicGetFrame(ms_pWavyAtomic)));
RpAtomicSetFrame(atomic, frame);
@@ -1017,11 +1320,11 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RwV3d *geomVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geom, 0));
RwV3d *wavyVertices = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(wavyGeometry, 0));
- ASSERT( geomTexCoords != NULL );
- ASSERT( wavyTexCoord != NULL );
- ASSERT( geomPreLights != NULL );
- ASSERT( geomVertices != NULL );
- ASSERT( wavyVertices != NULL );
+ ASSERT( geomTexCoords != nil );
+ ASSERT( wavyTexCoord != nil );
+ ASSERT( geomPreLights != nil );
+ ASSERT( geomVertices != nil );
+ ASSERT( wavyVertices != nil );
RpGeometryLock(geom, rpGEOMETRYLOCKVERTICES | rpGEOMETRYLOCKPRELIGHT | rpGEOMETRYLOCKTEXCOORDS);
@@ -1038,7 +1341,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
for ( int32 k = 0; k < 4; k++ )
{
- if ( apBoatList[k] != NULL )
+ if ( apBoatList[k] != nil )
fDistMult += CBoat::IsVertexAffectedByWake(CVector(fVertexX, fVertexY, 0.0f), apBoatList[k]);
}
@@ -1087,7 +1390,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
pos.y = fY;
pos.z = fZ;
- ASSERT( ms_pWavyAtomic != NULL );
+ ASSERT( ms_pWavyAtomic != nil );
RwFrameTranslate(RpAtomicGetFrame(ms_pWavyAtomic), &pos, rwCOMBINEREPLACE);
@@ -1116,7 +1419,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
{
for ( int32 y = nStartY; y <= nEndY; y++ )
{
- if ( !(aWaterFineBlockList[x][y] & 128) )
+ if ( aWaterFineBlockList[x][y] >= 0 )
{
float fSectorX = WATER_FROM_SMALL_SECTOR_X(x);
float fSectorY = WATER_FROM_SMALL_SECTOR_Y(y);
@@ -1142,7 +1445,7 @@ CWaterLevel::RenderAndEmptyRenderBuffer()
{
LittleTest();
- if ( RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, NULL, rwIM3D_VERTEXUV) )
+ if ( RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV) )
{
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
RwIm3DEnd();
@@ -1160,29 +1463,29 @@ CWaterLevel::AllocateBoatWakeArray()
PUSH_MEMID(MEMID_STREAM);
- ASSERT(ms_pWavyAtomic != NULL );
+ ASSERT(ms_pWavyAtomic != nil );
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
- ASSERT(wavyGeometry != NULL );
+ ASSERT(wavyGeometry != nil );
RpMorphTarget *wavyMorphTarget = RpGeometryGetMorphTarget(wavyGeometry, 0);
RpMaterial *wavyMaterial = RpGeometryGetMaterial(wavyGeometry, 0);
- ASSERT(wavyMorphTarget != NULL );
- ASSERT(wavyMaterial != NULL );
+ ASSERT(wavyMorphTarget != nil );
+ ASSERT(wavyMaterial != nil );
for ( int32 geom = 0; geom < MAX_BOAT_WAKES; geom++ )
{
- if ( apGeomArray[geom] == NULL )
+ if ( apGeomArray[geom] == nil )
{
apGeomArray[geom] = RpGeometryCreate(9*9, 8*8*2, rpGEOMETRYTRISTRIP
| rpGEOMETRYPRELIT
| rpGEOMETRYMODULATEMATERIALCOLOR
| rpGEOMETRYTEXTURED);
- ASSERT(apGeomArray[geom] != NULL);
+ ASSERT(apGeomArray[geom] != nil);
RpTriangle *geomTriangles = RpGeometryGetTriangles(apGeomArray[geom]);
- ASSERT( geomTriangles != NULL );
+ ASSERT( geomTriangles != nil );
for ( int32 i = 0; i < 8; i++ )
{
@@ -1216,8 +1519,8 @@ CWaterLevel::AllocateBoatWakeArray()
RpMorphTarget *geomMorphTarget = RpGeometryGetMorphTarget(apGeomArray[geom], 0);
RwV3d *geomVertices = RpMorphTargetGetVertices(geomMorphTarget);
- ASSERT( geomMorphTarget != NULL );
- ASSERT( geomVertices != NULL );
+ ASSERT( geomMorphTarget != nil );
+ ASSERT( geomVertices != nil );
for ( int32 i = 0; i < 9; i++ )
{
@@ -1242,10 +1545,10 @@ CWaterLevel::FreeBoatWakeArray()
{
for ( int32 i = 0; i < MAX_BOAT_WAKES; i++ )
{
- if ( apGeomArray[i] != NULL )
+ if ( apGeomArray[i] != nil )
{
RpGeometryDestroy(apGeomArray[i]);
- apGeomArray[i] = NULL;
+ apGeomArray[i] = nil;
}
}
diff --git a/src/render/WaterLevel.h b/src/render/WaterLevel.h
index 269d6091..cf3537ae 100644
--- a/src/render/WaterLevel.h
+++ b/src/render/WaterLevel.h
@@ -1,9 +1,9 @@
#pragma once
-#define WATER_BLOCK_SIZE LARGE_SECTOR_SIZE
-#define WATER_FINEBLOCK_SIZE HUGE_SECTOR_SIZE
#define WATER_Z_OFFSET (1.5f)
+#define NO_WATER -128
+
#define MAX_SMALL_SECTORS 128
#define MAX_LARGE_SECTORS 64
#define MAX_HUGE_SECTORS 32
@@ -23,7 +23,6 @@
#define WATER_WIDTH ((WATER_END_X - WATER_START_X))
#define WATER_HEIGHT ((WATER_END_Y - WATER_START_Y))
-
#define WATER_UNSIGN_X(x) ( (x) + (WATER_WIDTH /2) )
#define WATER_UNSIGN_Y(y) ( (y) + (WATER_HEIGHT/2) )
#define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) )
@@ -72,8 +71,8 @@ class CWaterLevel
static int32 ms_nNoOfWaterLevels;
static float ms_aWaterZs[48];
static CRect ms_aWaterRects[48];
- static uint8 aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE];
- static uint8 aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE];
+ static int8 aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
+ static int8 aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
static bool WavesCalculatedThisFrame;
static RpAtomic *ms_pWavyAtomic;
static RpGeometry *apGeomArray[MAX_BOAT_WAKES];
@@ -84,6 +83,10 @@ public:
static void Shutdown();
static void CreateWavyAtomic();
static void DestroyWavyAtomic();
+ static void AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel);
+ static bool WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel = nil);
+ static bool TestVisibilityForFineWaterBlocks(const CVector &worldPos);
+ static void RemoveIsolatedWater();
static bool GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ);
static bool GetWaterLevel(CVector coors, float *pfOutLevel, bool bDontCheckZ) { return GetWaterLevel(coors.x, coors.y, coors.z, pfOutLevel, bDontCheckZ); }
static bool GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel);
diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp
index f16467b6..e765f306 100644
--- a/src/render/Weather.cpp
+++ b/src/render/Weather.cpp
@@ -359,7 +359,7 @@ void CWeather::AddRain()
RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude();
splash_points[3] = 4.0f * CVector(RwCameraGetViewWindow(TheCamera.m_pRwCamera)->x, RwCameraGetViewWindow(TheCamera.m_pRwCamera)->y, 1.0f) *
RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude();
- RwV3dTransformPoints((RwV3d*)splash_points, (RwV3d*)splash_points, 4, RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
+ RwV3dTransformPoints(splash_points, splash_points, 4, RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
CVector fp = (splash_points[0] + splash_points[1] + splash_points[2] + splash_points[3]) / 4;
for (int i = 0; i < num_splash_attempts; i++) {
CColPoint point;
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index b27d96c8..21e00725 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -203,6 +203,10 @@ CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist)
return ret;
}
+// can't increase this yet unfortunately...
+// probably have to fix fading for this so material alpha isn't overwritten
+#define VEHICLE_LODDIST_MULTIPLIER (TheCamera.GenerationDistMultiplier)
+
void
CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera)
{
@@ -215,11 +219,11 @@ CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera)
else
ms_cullCompsDist = sq(TheCamera.LODDistMultiplier * 20.0f);
- ms_vehicleLod0Dist = sq(70.0f * TheCamera.GenerationDistMultiplier);
- ms_vehicleLod1Dist = sq(90.0f * TheCamera.GenerationDistMultiplier);
- ms_vehicleFadeDist = sq(100.0f * TheCamera.GenerationDistMultiplier);
- ms_bigVehicleLod0Dist = sq(60.0f * TheCamera.GenerationDistMultiplier);
- ms_bigVehicleLod1Dist = sq(150.0f * TheCamera.GenerationDistMultiplier);
+ ms_vehicleLod0Dist = sq(70.0f * VEHICLE_LODDIST_MULTIPLIER);
+ ms_vehicleLod1Dist = sq(90.0f * VEHICLE_LODDIST_MULTIPLIER);
+ ms_vehicleFadeDist = sq(100.0f * VEHICLE_LODDIST_MULTIPLIER);
+ ms_bigVehicleLod0Dist = sq(60.0f * VEHICLE_LODDIST_MULTIPLIER);
+ ms_bigVehicleLod1Dist = sq(150.0f * VEHICLE_LODDIST_MULTIPLIER);
ms_pedLod0Dist = sq(25.0f * TheCamera.LODDistMultiplier);
ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier);
ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier);
@@ -311,7 +315,12 @@ CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic)
m = RwFrameGetLTM(RpAtomicGetFrame(atomic));
RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn);
len = RwV3dLength(&view);
+#ifdef FIX_BUGS
+ // from VC
+ lodatm = mi->GetAtomicFromDistance(len * TheCamera.LODDistMultiplier / VEHICLE_LODDIST_MULTIPLIER);
+#else
lodatm = mi->GetAtomicFromDistance(len);
+#endif
if(lodatm){
if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic))
RpAtomicSetGeometry(atomic, RpAtomicGetGeometry(lodatm), rpATOMICSAMEBOUNDINGSPHERE);
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index 1635781b..d8807f2b 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -83,9 +83,6 @@ enum eGameState
GS_FRONTEND,
GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME,
-#ifndef MASTER
- GS_ANIMVIEWER,
-#endif
};
extern RwUInt32 gGameState;
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 7354c90a..93bfde5a 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -70,9 +70,6 @@ static psGlobalType PsGlobal;
#define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var)
-#undef MAKEPOINTS
-#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l)))
-
size_t _dwMemAvailPhys;
RwUInt32 gGameState;
@@ -870,6 +867,36 @@ void _InputInitialiseJoys()
PSGLOBAL(joy1id) = -1;
PSGLOBAL(joy2id) = -1;
+ // Load our gamepad mappings.
+#define SDL_GAMEPAD_DB_PATH "gamecontrollerdb.txt"
+ FILE *f = fopen(SDL_GAMEPAD_DB_PATH, "rb");
+ if (f) {
+ fseek(f, 0, SEEK_END);
+ size_t fsize = ftell(f);
+ fseek(f, 0, SEEK_SET);
+
+ char *db = (char*)malloc(fsize + 1);
+ if (fread(db, 1, fsize, f) == fsize) {
+ db[fsize] = '\0';
+
+ if (glfwUpdateGamepadMappings(db) == GLFW_FALSE)
+ Error("glfwUpdateGamepadMappings didn't succeed, check " SDL_GAMEPAD_DB_PATH ".\n");
+ } else
+ Error("fread on " SDL_GAMEPAD_DB_PATH " wasn't successful.\n");
+
+ free(db);
+ fclose(f);
+ } else
+ printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from re3/gamefiles to GTA3 directory. Some gamepads may not be recognized.\n");
+
+#undef SDL_GAMEPAD_DB_PATH
+
+ // But always overwrite it with the one in SDL_GAMECONTROLLERCONFIG.
+ char const* EnvControlConfig = getenv("SDL_GAMECONTROLLERCONFIG");
+ if (EnvControlConfig != nil) {
+ glfwUpdateGamepadMappings(EnvControlConfig);
+ }
+
for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
if (glfwJoystickPresent(i) && !IsThisJoystickBlacklisted(i)) {
if (PSGLOBAL(joy1id) == -1)
@@ -1175,15 +1202,15 @@ void InitialiseLanguage()
}
}
- TheText.Unload();
- TheText.Load();
-
#ifndef _WIN32
// TODO this is needed for strcasecmp to work correctly across all languages, but can these cause other problems??
setlocale(LC_CTYPE, "C");
setlocale(LC_COLLATE, "C");
setlocale(LC_NUMERIC, "C");
#endif
+
+ TheText.Unload();
+ TheText.Load();
}
/*
@@ -1230,17 +1257,11 @@ void resizeCB(GLFWwindow* window, int width, int height) {
* memory things don't work.
*/
/* redraw window */
-#ifndef MASTER
- if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
- {
- RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
- }
-#else
+
if (RwInitialised && gGameState == GS_PLAYING_GAME)
{
RsEventHandler(rsIDLE, (void *)TRUE);
}
-#endif
if (RwInitialised && height > 0 && width > 0) {
RwRect r;
@@ -1619,18 +1640,6 @@ main(int argc, char *argv[])
FrontEndMenuManager.DrawMemoryCardStartUpMenus();
}
#endif
-
- if (TurnOnAnimViewer)
- {
-#ifndef MASTER
- CAnimViewer::Initialise();
-#ifndef PS2_MENU
- FrontEndMenuManager.m_bGameNotLoaded = false;
-#endif
- gGameState = GS_ANIMVIEWER;
- TurnOnAnimViewer = false;
-#endif
- }
initkeymap();
@@ -1650,6 +1659,18 @@ main(int argc, char *argv[])
* Enter the message processing loop...
*/
+#ifndef MASTER
+ if (gbModelViewer) {
+ // This is TheModelViewer in LCS, but not compiled on III Mobile.
+ LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen());
+ CAnimViewer::Initialise();
+ CTimer::Update();
+#ifndef PS2_MENU
+ FrontEndMenuManager.m_bGameNotLoaded = false;
+#endif
+ }
+#endif
+
#ifdef PS2_MENU
if (TheMemoryCard.m_bWantToLoad)
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
@@ -1664,7 +1685,13 @@ main(int argc, char *argv[])
#endif
{
glfwPollEvents();
- if( ForegroundApp )
+#ifndef MASTER
+ if (gbModelViewer) {
+ // This is TheModelViewerCore in LCS, but TheModelViewer on other state-machine III-VCs.
+ TheModelViewer();
+ } else
+#endif
+ if ( ForegroundApp )
{
switch ( gGameState )
{
@@ -1867,18 +1894,6 @@ main(int argc, char *argv[])
}
break;
}
-#ifndef MASTER
- case GS_ANIMVIEWER:
- {
- float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
- if (RwInitialised)
- {
- if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
- RsEventHandler(rsANIMVIEWER, (void*)TRUE);
- }
- break;
- }
-#endif
}
}
else
@@ -1950,12 +1965,13 @@ main(int argc, char *argv[])
}
else
{
- if ( gGameState == GS_PLAYING_GAME )
- CGame::ShutDown();
#ifndef MASTER
- else if ( gGameState == GS_ANIMVIEWER )
+ if ( gbModelViewer )
CAnimViewer::Shutdown();
+ else
#endif
+ if ( gGameState == GS_PLAYING_GAME )
+ CGame::ShutDown();
CTimer::Stop();
@@ -1977,12 +1993,13 @@ main(int argc, char *argv[])
}
- if ( gGameState == GS_PLAYING_GAME )
- CGame::ShutDown();
#ifndef MASTER
- else if ( gGameState == GS_ANIMVIEWER )
+ if ( gbModelViewer )
CAnimViewer::Shutdown();
+ else
#endif
+ if ( gGameState == GS_PLAYING_GAME )
+ CGame::ShutDown();
DMAudio.Terminate();
diff --git a/src/skel/skeleton.cpp b/src/skel/skeleton.cpp
index 3166093e..98fc9843 100644
--- a/src/skel/skeleton.cpp
+++ b/src/skel/skeleton.cpp
@@ -10,14 +10,13 @@
#include "skeleton.h"
#include "platform.h"
+#include "main.h"
#include "MemoryHeap.h"
static RwBool DefaultVideoMode = TRUE;
-bool TurnOnAnimViewer = false;
-
RsGlobalType RsGlobal;
#ifdef _WIN32
@@ -162,7 +161,7 @@ rsPreInitCommandLine(RwChar *arg)
#ifndef MASTER
if (!strcmp(arg, RWSTRING("-animviewer")))
{
- TurnOnAnimViewer = TRUE;
+ gbModelViewer = TRUE;
return TRUE;
}
diff --git a/src/skel/skeleton.h b/src/skel/skeleton.h
index 1c468179..380b6c05 100644
--- a/src/skel/skeleton.h
+++ b/src/skel/skeleton.h
@@ -79,11 +79,8 @@ enum RsEvent
rsPADANALOGUERIGHTRESET,
rsPREINITCOMMANDLINE,
rsACTIVATE,
- rsANIMVIEWER,
};
-extern bool TurnOnAnimViewer;
-
typedef enum RsEvent RsEvent;
typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param);
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index c16ea2a1..388090fc 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1017,17 +1017,12 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
RECT rect;
/* redraw window */
-#ifndef MASTER
- if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
- {
- RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
- }
-#else
+
if (RwInitialised && gGameState == GS_PLAYING_GAME)
{
RsEventHandler(rsIDLE, (void *)TRUE);
}
-#endif
+
/* Manually resize window */
rect.left = rect.top = 0;
rect.bottom = newPos->bottom - newPos->top;
@@ -2183,17 +2178,17 @@ WinMain(HINSTANCE instance,
}
#endif
- if (TurnOnAnimViewer)
- {
#ifndef MASTER
+ if (gbModelViewer) {
+ // This is TheModelViewer in LCS, but not compiled on III Mobile.
+ LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen());
CAnimViewer::Initialise();
+ CTimer::Update();
#ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
- gGameState = GS_ANIMVIEWER;
- TurnOnAnimViewer = false;
-#endif
}
+#endif
while ( TRUE )
{
@@ -2238,6 +2233,12 @@ WinMain(HINSTANCE instance,
DispatchMessage(&message);
}
}
+#ifndef MASTER
+ else if (gbModelViewer) {
+ // This is TheModelViewerCore in LCS
+ TheModelViewer();
+ }
+#endif
else if( ForegroundApp )
{
switch ( gGameState )
@@ -2451,18 +2452,6 @@ WinMain(HINSTANCE instance,
}
break;
}
-#ifndef MASTER
- case GS_ANIMVIEWER:
- {
- float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
- if (RwInitialised)
- {
- if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
- RsEventHandler(rsANIMVIEWER, (void*)TRUE);
- }
- break;
- }
-#endif
}
}
else
@@ -2534,13 +2523,14 @@ WinMain(HINSTANCE instance,
}
else
{
- if ( gGameState == GS_PLAYING_GAME )
- CGame::ShutDown();
#ifndef MASTER
- else if ( gGameState == GS_ANIMVIEWER )
+ if ( gbModelViewer )
CAnimViewer::Shutdown();
+ else
#endif
-
+ if ( gGameState == GS_PLAYING_GAME )
+ CGame::ShutDown();
+
CTimer::Stop();
if ( FrontEndMenuManager.m_bFirstTime == true )
@@ -2561,12 +2551,13 @@ WinMain(HINSTANCE instance,
}
- if ( gGameState == GS_PLAYING_GAME )
- CGame::ShutDown();
#ifndef MASTER
- else if ( gGameState == GS_ANIMVIEWER )
+ if ( gbModelViewer )
CAnimViewer::Shutdown();
+ else
#endif
+ if ( gGameState == GS_PLAYING_GAME )
+ CGame::ShutDown();
DMAudio.Terminate();
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index ec71f690..79d3f6af 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -768,7 +768,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
m_nWheelsOnGround, fThrust,
@@ -802,7 +802,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
m_nWheelsOnGround, fThrust,
@@ -883,7 +883,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB);
WheelState[CARWHEEL_REAR_LEFT] = m_aWheelState[CARWHEEL_REAR_LEFT];
- if(Damage.GetWheelStatus(VEHWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_REAR_LEFT], contactPoints[CARWHEEL_REAR_LEFT],
m_nWheelsOnGround, fThrust,
@@ -917,7 +917,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB);
WheelState[CARWHEEL_REAR_RIGHT] = m_aWheelState[CARWHEEL_REAR_RIGHT];
- if(Damage.GetWheelStatus(VEHWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_REAR_RIGHT], contactPoints[CARWHEEL_REAR_RIGHT],
m_nWheelsOnGround, fThrust,
@@ -3946,10 +3946,10 @@ void
CAutomobile::BurstTyre(uint8 wheel)
{
switch(wheel){
- case CAR_PIECE_WHEEL_LF: wheel = VEHWHEEL_FRONT_LEFT; break;
- case CAR_PIECE_WHEEL_LR: wheel = VEHWHEEL_REAR_LEFT; break;
- case CAR_PIECE_WHEEL_RF: wheel = VEHWHEEL_FRONT_RIGHT; break;
- case CAR_PIECE_WHEEL_RR: wheel = VEHWHEEL_REAR_RIGHT; break;
+ case CAR_PIECE_WHEEL_LF: wheel = CARWHEEL_FRONT_LEFT; break;
+ case CAR_PIECE_WHEEL_RF: wheel = CARWHEEL_FRONT_RIGHT; break;
+ case CAR_PIECE_WHEEL_LR: wheel = CARWHEEL_REAR_LEFT; break;
+ case CAR_PIECE_WHEEL_RR: wheel = CARWHEEL_REAR_RIGHT; break;
}
int status = Damage.GetWheelStatus(wheel);
diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h
index 604bed17..a5bee226 100644
--- a/src/vehicles/Automobile.h
+++ b/src/vehicles/Automobile.h
@@ -30,8 +30,6 @@ enum eCarNodes
NUM_CAR_NODES,
};
-// These are used for all the wheel arrays
-// DON'T confuse with VEHWHEEL, which are vehicle components
enum {
CARWHEEL_FRONT_LEFT,
CARWHEEL_REAR_LEFT,
diff --git a/src/vehicles/Cranes.h b/src/vehicles/Cranes.h
index 6d877d82..0e134310 100644
--- a/src/vehicles/Cranes.h
+++ b/src/vehicles/Cranes.h
@@ -11,7 +11,7 @@ class CBuilding;
class CCrane
{
public:
- enum CraneState : uint8 {
+ enum CraneState {
IDLE = 0,
GOING_TOWARDS_TARGET = 1,
LIFTING_TARGET = 2,
@@ -19,7 +19,7 @@ public:
ROTATING_TARGET = 4,
DROPPING_TARGET = 5
};
- enum CraneStatus : uint8 {
+ enum CraneStatus {
NONE = 0,
ACTIVATED = 1,
DEACTIVATED = 2
@@ -47,8 +47,8 @@ public:
CVector2D m_vecHookVelocity;
CVehicle *m_pVehiclePickedUp;
uint32 m_nTimeForNextCheck;
- CraneStatus m_nCraneStatus;
- CraneState m_nCraneState;
+ uint8 m_nCraneStatus;
+ uint8 m_nCraneState;
uint8 m_nVehiclesCollected;
bool m_bIsCrusher;
bool m_bIsMilitaryCrane;
diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h
index 4d3b8389..23bd9681 100644
--- a/src/vehicles/HandlingMgr.h
+++ b/src/vehicles/HandlingMgr.h
@@ -65,7 +65,7 @@ enum tVehicleType
NUMHANDLINGS
};
-enum tField : uint32 // most likely a handling field enum, never used so :shrug:
+enum tField // most likely a handling field enum, never used so :shrug:
{
};
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 3933f1dd..7066a0ea 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -57,14 +57,6 @@ enum eLights
VEHLIGHT_REAR_RIGHT,
};
-enum eWheels
-{
- VEHWHEEL_FRONT_LEFT,
- VEHWHEEL_FRONT_RIGHT,
- VEHWHEEL_REAR_LEFT,
- VEHWHEEL_REAR_RIGHT,
-};
-
enum
{
CAR_PIECE_BONNET = 1,
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index dc15485e..a987a4c7 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -385,7 +385,7 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
if ( victimPed->bUsesCollision || victimPed->Dead() || victimPed->Driving() )
{
CVector victimPedPos = victimPed->GetPosition();
- if ( SQR(victimPedRadius) > (victimPedPos-(*fireSource)).MagnitudeSqr() )
+ if ( SQR(victimPedRadius) > (victimPedPos-fireSource).MagnitudeSqr() )
{
CVector collisionDist;
@@ -393,7 +393,7 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
while ( s < victimPedCol->numSpheres )
{
CColSphere *sphere = &victimPedCol->spheres[s];
- collisionDist = victimPedPos+sphere->center-(*fireSource);
+ collisionDist = victimPedPos+sphere->center-fireSource;
if ( SQR(sphere->radius + info->m_fRadius) > collisionDist.MagnitudeSqr() )
{