summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/AnimViewer.cpp32
-rw-r--r--src/core/Cam.cpp34
-rw-r--r--src/core/Camera.cpp40
-rw-r--r--src/core/Camera.h29
-rw-r--r--src/core/CdStream.cpp1
-rw-r--r--src/core/CdStream.h1
-rw-r--r--src/core/Collision.cpp2
-rw-r--r--src/core/Collision.h10
-rw-r--r--src/core/ControllerConfig.cpp10
-rw-r--r--src/core/FileLoader.cpp50
-rw-r--r--src/core/Frontend.cpp245
-rw-r--r--src/core/Frontend.h18
-rw-r--r--src/core/Game.cpp22
-rw-r--r--src/core/Game.h2
-rw-r--r--src/core/MenuScreens.h6
-rw-r--r--src/core/Pad.cpp169
-rw-r--r--src/core/Pad.h9
-rw-r--r--src/core/Placeable.cpp4
-rw-r--r--src/core/Placeable.h11
-rw-r--r--src/core/PlayerInfo.cpp20
-rw-r--r--src/core/PlayerInfo.h4
-rw-r--r--src/core/Pools.cpp92
-rw-r--r--src/core/Radar.cpp47
-rw-r--r--src/core/Radar.h2
-rw-r--r--src/core/Streaming.cpp131
-rw-r--r--src/core/Streaming.h10
-rw-r--r--src/core/Timer.h5
-rw-r--r--src/core/User.cpp12
-rw-r--r--src/core/Wanted.cpp2
-rw-r--r--src/core/Wanted.h2
-rw-r--r--src/core/World.cpp75
-rw-r--r--src/core/World.h11
-rw-r--r--src/core/ZoneCull.cpp11
-rw-r--r--src/core/Zones.cpp97
-rw-r--r--src/core/Zones.h15
-rw-r--r--src/core/common.h7
-rw-r--r--src/core/config.h8
-rw-r--r--src/core/main.cpp12
-rw-r--r--src/core/re3.cpp40
-rw-r--r--src/core/templates.h14
40 files changed, 832 insertions, 480 deletions
diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp
index 36ea20b7..40a8b09e 100644
--- a/src/core/AnimViewer.cpp
+++ b/src/core/AnimViewer.cpp
@@ -108,7 +108,7 @@ CAnimViewer::Initialise(void) {
CTimeCycle::Initialise();
CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed();
- player->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
+ player->SetPosition(0.0f, 0.0f, 0.0f);
CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
@@ -148,7 +148,7 @@ LastPedModelId(int modelId)
CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
- if (model->m_type == MITYPE_PED)
+ if (model->GetModelType() == MITYPE_PED)
return i;
}
return modelId;
@@ -160,7 +160,7 @@ LastVehicleModelId(int modelId)
CBaseModelInfo* model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
- if (model->m_type == MITYPE_VEHICLE)
+ if (model->GetModelType() == MITYPE_VEHICLE)
return i;
}
return modelId;
@@ -222,7 +222,7 @@ CAnimViewer::Update(void)
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *newEntity = nil;
- if (modelInfo->m_type == MITYPE_PED) {
+ if (modelInfo->GetModelType() == MITYPE_PED) {
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
if (animId > ANIM_IDLE_STANCE)
@@ -248,8 +248,9 @@ CAnimViewer::Update(void)
}
CPad::UpdatePads();
CPad* pad = CPad::GetPad(0);
-
+#ifdef DEBUGMENU
DebugMenuProcess();
+#endif
CStreaming::UpdateForAnimViewer();
CStreaming::RequestModel(modelId, 0);
@@ -257,7 +258,7 @@ CAnimViewer::Update(void)
if (!pTarget) {
- if (modelInfo->m_type == MITYPE_VEHICLE) {
+ if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR) {
@@ -278,10 +279,10 @@ CAnimViewer::Update(void)
// }
} else {
newEntity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
- newEntity->m_status = STATUS_ABANDONED;
+ newEntity->SetStatus(STATUS_ABANDONED);
}
newEntity->bIsStuck = true;
- } else if (modelInfo->m_type == MITYPE_PED) {
+ } else if (modelInfo->GetModelType() == MITYPE_PED) {
pTarget = newEntity = new CPed(PEDTYPE_CIVMALE);
newEntity->SetModelIndex(modelId);
} else {
@@ -292,18 +293,18 @@ CAnimViewer::Update(void)
}
newEntity->bIsStuck = true;
}
- newEntity->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
+ newEntity->SetPosition(0.0f, 0.0f, 0.0f);
CWorld::Add(newEntity);
TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT);
}
- if (pTarget->m_type == ENTITY_TYPE_VEHICLE || pTarget->m_type == ENTITY_TYPE_PED || pTarget->m_type == ENTITY_TYPE_OBJECT) {
+ if (pTarget->IsVehicle() || pTarget->IsPed() || pTarget->IsObject()) {
((CPhysical*)pTarget)->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
}
- pTarget->GetPosition().z = 0.0f;
+ pTarget->GetMatrix().GetPosition().z = 0.0f;
- if (modelInfo->m_type != MITYPE_PED) {
+ if (modelInfo->GetModelType() != MITYPE_PED) {
- if (modelInfo->m_type == MITYPE_VEHICLE) {
+ if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
nextModelId = LastPedModelId(modelId);
@@ -369,10 +370,11 @@ CAnimViewer::Update(void)
if (pad->NewState.Triangle) {
#ifdef PED_SKIN
if(IsClumpSkinned(pTarget->GetClump()))
- ((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->AnimatePedColModelSkinned(pTarget->GetClump());
+ ((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump());
else
#endif
- CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->GetHitColModel(), RpClumpGetFrame(pTarget->GetClump()));
+ CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->GetHitColModel(),
+ RpClumpGetFrame(pTarget->GetClump()));
AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString);
CMessages::AddMessage(gUString, 100, 0);
}
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 801652cb..20b262c8 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -25,13 +25,11 @@
#include "Camera.h"
#include "DMAudio.h"
-const float DefaultFOV = 70.0f; // beta: 80.0f
-
bool PrintDebugCode = false;
int16 DebugCamMode;
#ifdef FREE_CAM
-bool CCamera::bFreeCam = false;
+bool CCamera::bFreeCam = true;
int nPreviousMode = -1;
#endif
@@ -3794,7 +3792,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
if(FindPlayerVehicle())
FindPlayerVehicle()->Teleport(Source);
else
- CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition() = Source;
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source);
}
// stay inside sectors
@@ -3941,7 +3939,7 @@ CCam::Process_Editor(const CVector&, float, float, float)
if(FindPlayerVehicle())
FindPlayerVehicle()->Teleport(Source);
else
- CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition() = Source;
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source);
}
@@ -4489,7 +4487,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
*/
{
LookLeftRight = -CPad::GetPad(0)->LookAroundLeftRight();
- LookUpDown = CPad::GetPad(0)->LookAroundUpDown();
+ LookUpDown = -CPad::GetPad(0)->LookAroundUpDown();
}
float AlphaOffset, BetaOffset;
if(UseMouse){
@@ -4639,7 +4637,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 camSetArrPos = 0;
// We may need those later
- bool isPlane = car->m_modelIndex == MI_DODO;
+ bool isPlane = car->GetModelIndex() == MI_DODO;
bool isHeli = false;
bool isBike = false;
bool isCar = car->IsCar() && !isPlane && !isHeli && !isBike;
@@ -4650,9 +4648,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 nextDirectionIsForward = !(pad->GetLookBehindForCar() || pad->GetLookBehindForPed() || pad->GetLookLeft() || pad->GetLookRight()) &&
DirectionWasLooking == LOOKING_FORWARD;
- if (car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_FIRETRUCK) {
camSetArrPos = 7;
- } else if (car->m_modelIndex == MI_RCBANDIT) {
+ } else if (car->GetModelIndex() == MI_RCBANDIT) {
camSetArrPos = 5;
} else if (car->IsBoat()) {
camSetArrPos = 4;
@@ -4683,7 +4681,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
static float ZmTwoAlphaOffsetLCS[] = { 0.1f, 0.08f, 0.3f, 0.08f, 0.08f };
static float ZmThreeAlphaOffsetLCS[] = { 0.065f, 0.05f, 0.15f, 0.06f, 0.08f };
- if (isHeli && car->m_status == STATUS_PLAYER_REMOTE)
+ if (isHeli && car->GetStatus() == STATUS_PLAYER_REMOTE)
zoomModeAlphaOffset = ZmTwoAlphaOffsetLCS[alphaArrPos];
else {
switch ((int)TheCamera.CarZoomIndicator) {
@@ -4712,7 +4710,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float minDistForThisCar = approxCarLength * CARCAM_SET[camSetArrPos][3];
- if (!isHeli || car->m_status == STATUS_PLAYER_REMOTE) {
+ if (!isHeli || car->GetStatus() == STATUS_PLAYER_REMOTE) {
float radiusToStayOutside = colMaxZ * CARCAM_SET[camSetArrPos][0] - CARCAM_SET[camSetArrPos][2];
if (radiusToStayOutside > 0.0f) {
TargetCoors.z += radiusToStayOutside;
@@ -4851,7 +4849,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// This is also original LCS and SA bug, or some attempt to fix lag. We'll never know
// if (car->m_vecMoveSpeed.MagnitudeSqr() < sq(0.2f))
- if (car->m_modelIndex != MI_FIRETRUCK) {
+ if (car->GetModelIndex() != MI_FIRETRUCK) {
// if (!isBike || GetMysteriousWheelRelatedThingBike(car) > 3)
// if (!isHeli && (!isPlane || car->GetWheelsOnGround())) {
@@ -4907,7 +4905,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
bool correctAlpha = true;
// if (SA checks if we aren't in work car, why?) {
- if (!isCar || car->m_modelIndex != MI_YARDIE) {
+ if (!isCar || car->GetModelIndex() != MI_YARDIE) {
correctAlpha = false;
}
else {
@@ -5186,13 +5184,13 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// gTargetCoordsForLookingBehind = TargetCoors;
// SA code from CAutomobile::TankControl/FireTruckControl.
- if (car->m_modelIndex == MI_RHINO || car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_RHINO || car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunLR = ((CAutomobile*)car)->m_fCarGunLR;
CVector hi = Multiply3x3(Front, car->GetMatrix());
// III/VC's firetruck turret angle is reversed
- float angleToFace = (car->m_modelIndex == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
+ float angleToFace = (car->GetModelIndex() == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
if (angleToFace <= carGunLR + PI) {
if (angleToFace < carGunLR - PI)
@@ -5202,7 +5200,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
float neededTurn = angleToFace - carGunLR;
- float turnPerFrame = CTimer::GetTimeStep() * (car->m_modelIndex == MI_FIRETRUCK ? 0.05f : 0.015f);
+ float turnPerFrame = CTimer::GetTimeStep() * (car->GetModelIndex() == MI_FIRETRUCK ? 0.05f : 0.015f);
if (neededTurn <= turnPerFrame) {
if (neededTurn < -turnPerFrame)
angleToFace = carGunLR - turnPerFrame;
@@ -5210,7 +5208,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
angleToFace = turnPerFrame + carGunLR;
}
- if (car->m_modelIndex == MI_RHINO && carGunLR != angleToFace) {
+ if (car->GetModelIndex() == MI_RHINO && carGunLR != angleToFace) {
DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_CAR_TANK_TURRET_ROTATE, Abs(angleToFace - carGunLR));
}
carGunLR = angleToFace;
@@ -5222,7 +5220,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
// Because firetruk turret also has Y movement
- if (car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunUD = ((CAutomobile*)car)->m_fCarGunUD;
float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f);
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 9a053056..9b178f35 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -470,19 +470,19 @@ CCamera::Process(void)
}
}
- GetRight() = CrossProduct(CamUp, CamFront); // actually Left
- GetForward() = CamFront;
- GetUp() = CamUp;
- GetPosition() = CamSource;
+ GetMatrix().GetRight() = CrossProduct(CamUp, CamFront); // actually Left
+ GetMatrix().GetForward() = CamFront;
+ GetMatrix().GetUp() = CamUp;
+ GetMatrix().GetPosition() = CamSource;
// Process Shake
float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f;
shakeStrength = clamp(shakeStrength, 0.0f, 2.0f);
int shakeRand = CGeneral::GetRandomNumber();
float shakeOffset = shakeStrength*0.1f;
- GetPosition().x += shakeOffset*((shakeRand&0xF)-7);
- GetPosition().y += shakeOffset*(((shakeRand&0xF0)>>4)-7);
- GetPosition().z += shakeOffset*(((shakeRand&0xF00)>>8)-7);
+ GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
+ GetMatrix().GetPosition().y += shakeOffset * (((shakeRand & 0xF0) >> 4) - 7);
+ GetMatrix().GetPosition().z += shakeOffset * (((shakeRand & 0xF00) >> 8) - 7);
if(shakeOffset > 0.0f && m_BlurType != MBLUR_SNIPER)
SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150));
@@ -499,27 +499,27 @@ CCamera::Process(void)
CVector Front = Cams[2].Front;
CVector Up = Cams[2].Up;
- GetRight() = CrossProduct(Up, Front);
- GetForward() = Front;
- GetUp() = Up;
- GetPosition() = Source;
+ GetMatrix().GetRight() = CrossProduct(Up, Front);
+ GetMatrix().GetForward() = Front;
+ GetMatrix().GetUp() = Up;
+ GetMatrix().GetPosition() = Source;
CDraw::SetFOV(Cams[2].FOV);
m_vecGameCamPos = Cams[ActiveCam].Source;
- *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
- *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
- *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
- *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
+ *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition();
+ *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward();
+ *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp();
+ *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}else{
RwFrame *frame = RwCameraGetFrame(m_pRwCamera);
m_vecGameCamPos = GetPosition();
- *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
- *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
- *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
- *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
+ *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition();
+ *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward();
+ *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp();
+ *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}
@@ -2707,7 +2707,6 @@ CCamera::DontProcessObbeCinemaCamera(void)
bDidWeProcessAnyCinemaCam = false;
}
-
void
CCamera::LoadTrainCamNodes(char const *name)
{
@@ -2887,7 +2886,6 @@ CCamera::Process_Train_Camera_Control(void)
}
-
void
CCamera::LoadPathSplines(int file)
{
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 6d53f417..94bcbd23 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -40,6 +40,8 @@ enum
#define DEFAULT_CAR_ZOOM_VALUE_2 (1.9f)
#define DEFAULT_CAR_ZOOM_VALUE_3 (3.9f)
+const float DefaultFOV = 70.0f; // beta: 80.0f
+
class CCam
{
public:
@@ -258,9 +260,8 @@ public:
void Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float);
void Process_FollowCar_SA(const CVector &CameraTarget, float TargetOrientation, float, float);
};
-static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
-static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
-static_assert(offsetof(CCam, Front) == 0x140, "CCam: error");
+
+VALIDATE_SIZE(CCam, 0x1A4);
class CCamPathSplines
{
@@ -298,11 +299,12 @@ enum
enum
{
- // TODO: figure out
- FADE_0,
+ // TODO: find better names
+ FADE_0, // faded in
FADE_1, // mid fade
- FADE_2,
+ FADE_2, // faded out
+ // Direction
FADE_OUT = 0,
FADE_IN,
FADE_NONE
@@ -634,19 +636,8 @@ uint32 unknown; // some counter having to do with music
bool IsSphereVisible(const CVector &center, float radius);
bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
};
-static_assert(offsetof(CCamera, DistanceToWater) == 0xe4, "CCamera: error");
-static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error");
-static_assert(offsetof(CCamera, WorldViewerBeingUsed) == 0x75, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiNumberOfTrainCamNodes) == 0x84, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiTransitionState) == 0x89, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiTimeTransitionStart) == 0x94, "CCamera: error");
-static_assert(offsetof(CCamera, m_BlurBlue) == 0x9C, "CCamera: error");
-static_assert(offsetof(CCamera, Cams) == 0x1A4, "CCamera: error");
-static_assert(offsetof(CCamera, pToGarageWeAreIn) == 0x690, "CCamera: error");
-static_assert(offsetof(CCamera, m_PreviousCameraPosition) == 0x6B0, "CCamera: error");
-static_assert(offsetof(CCamera, m_vecCutSceneOffset) == 0x6F8, "CCamera: error");
-static_assert(offsetof(CCamera, m_arrPathArray) == 0x7a8, "CCamera: error");
-static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size");
+
+VALIDATE_SIZE(CCamera, 0xE9D8);
extern CCamera TheCamera;
diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp
index ea79fb9a..666041e1 100644
--- a/src/core/CdStream.cpp
+++ b/src/core/CdStream.cpp
@@ -22,6 +22,7 @@ struct CdReadInfo
HANDLE hFile;
OVERLAPPED Overlapped;
};
+
VALIDATE_SIZE(CdReadInfo, 0x30);
char gCdImageNames[MAX_CDIMAGES+1][64];
diff --git a/src/core/CdStream.h b/src/core/CdStream.h
index 9ef71b65..ba6c63a3 100644
--- a/src/core/CdStream.h
+++ b/src/core/CdStream.h
@@ -27,7 +27,6 @@ struct Queue
VALIDATE_SIZE(Queue, 0x10);
-
void CdStreamInitThread(void);
void CdStreamInit(int32 numChannels);
uint32 GetGTA3ImgSize(void);
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index 7dfe3651..0cdacfdb 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -184,6 +184,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CPad::StopPadsShaking();
LoadCollisionScreen(CGame::currLevel);
DMAudio.Service();
+
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
@@ -204,6 +205,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
+
CGame::TidyUpMemory(true, true);
CTimer::Update();
DMAudio.SetEffectsFadeVol(127);
diff --git a/src/core/Collision.h b/src/core/Collision.h
index bdf51eb8..895f012a 100644
--- a/src/core/Collision.h
+++ b/src/core/Collision.h
@@ -89,11 +89,11 @@ struct CColModel
{
CColSphere boundingSphere;
CColBox boundingBox;
- short numSpheres;
- short numLines;
- short numBoxes;
- short numTriangles;
- int level;
+ int16 numSpheres;
+ int16 numLines;
+ int16 numBoxes;
+ int16 numTriangles;
+ int32 level;
bool ownsCollisionVolumes;
CColSphere *spheres;
CColLine *lines;
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index f55568be..cba8186f 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -685,7 +685,15 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving(int32
}
bool isDodo = false;
- if (FindPlayerVehicle() && (FindPlayerVehicle()->IsVehicle() && FindPlayerVehicle()->GetModelIndex() == MI_DODO))
+ if (FindPlayerVehicle() && (FindPlayerVehicle()->IsVehicle() && (
+ FindPlayerVehicle()->GetModelIndex() == MI_DODO
+#ifdef FIX_BUGS
+ || CVehicle::bAllDodosCheat
+#ifdef ALLCARSHELI_CHEAT
+ || bAllCarCheat
+#endif
+#endif
+ )))
{
isDodo = true;
}
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index b7d82089..88afb40c 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -172,16 +172,19 @@ CFileLoader::LoadTexDictionary(const char *filename)
return txd;
}
+struct ColHeader
+{
+ char ident[4];
+ uint32 size;
+};
+
void
CFileLoader::LoadCollisionFile(const char *filename)
{
int fd;
char modelname[24];
CBaseModelInfo *mi;
- struct {
- char ident[4];
- uint32 size;
- } header;
+ ColHeader header;
debug("Loading collision file %s\n", filename);
fd = CFileMgr::OpenFile(filename, "rb");
@@ -384,7 +387,7 @@ CFileLoader::LoadClumpFile(RwStream *stream, uint32 id)
return false;
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id);
mi->SetClump(clump);
- if(mi->m_type == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){
+ if (mi->GetModelType() == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)) {
// Read LOD ped
clump = RpClumpStreamRead(stream);
if(clump){
@@ -780,7 +783,7 @@ CFileLoader::LoadVehicleObject(const char *line)
mi->SetTexDictionary(txd);
for(p = gamename; *p; p++)
if(*p == '_') *p = ' ';
- strncpy(mi->m_gameName, gamename, 32);
+ strcpy(mi->m_gameName, gamename);
mi->m_level = level;
mi->m_compRules = comprules;
@@ -809,33 +812,33 @@ CFileLoader::LoadVehicleObject(const char *line)
// Well this is kinda dumb....
if(strncmp(vehclass, "poorfamily", 11) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_POOR;
+ mi->m_vehicleClass = CCarCtrl::POOR;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_POOR);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::POOR);
}else if(strncmp(vehclass, "richfamily", 11) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_RICH;
+ mi->m_vehicleClass = CCarCtrl::RICH;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_RICH);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::RICH);
}else if(strncmp(vehclass, "executive", 10) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_EXECUTIVE;
+ mi->m_vehicleClass = CCarCtrl::EXEC;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_EXECUTIVE);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::EXEC);
}else if(strncmp(vehclass, "worker", 7) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_WORKER;
+ mi->m_vehicleClass = CCarCtrl::WORKER;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_WORKER);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::WORKER);
}else if(strncmp(vehclass, "special", 8) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_SPECIAL;
+ mi->m_vehicleClass = CCarCtrl::SPECIAL;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_SPECIAL);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::SPECIAL);
}else if(strncmp(vehclass, "big", 4) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_BIG;
+ mi->m_vehicleClass = CCarCtrl::BIG;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_BIG);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::BIG);
}else if(strncmp(vehclass, "taxi", 5) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_TAXI;
+ mi->m_vehicleClass = CCarCtrl::TAXI;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_TAXI);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::TAXI);
}
}
@@ -1060,7 +1063,6 @@ CFileLoader::LoadObjectInstance(const char *line)
CSimpleModelInfo *mi;
RwMatrix *xform;
CEntity *entity;
-
if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f",
&id, name,
&trans.x, &trans.y, &trans.z,
@@ -1086,7 +1088,7 @@ CFileLoader::LoadObjectInstance(const char *line)
entity = new CBuilding;
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
- entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
+ entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
if(mi->IsSimple()){
if(mi->m_isBigBuilding)
entity->SetupBigBuilding();
@@ -1103,7 +1105,7 @@ CFileLoader::LoadObjectInstance(const char *line)
CWorld::Add(entity);
if(IsGlass(entity->GetModelIndex()))
entity->bIsVisible = false;
- entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
+ entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
}
RwMatrixDestroy(xform);
@@ -1325,7 +1327,7 @@ CFileLoader::ReloadObject(const char *line)
#ifdef FIX_BUGS
mi &&
#endif
- mi->m_type == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
+ mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
} else {
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index b0766cff..827e2ca7 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -110,7 +110,7 @@ int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt;
int32 CMenuManager::m_PrefsMusicVolume = 102;
int32 CMenuManager::m_PrefsSfxVolume = 102;
-char CMenuManager::m_PrefsSkinFile[256] = "$$\"\"";
+char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME;
int32 CMenuManager::m_KeyPressedCode = -1;
@@ -286,7 +286,7 @@ ScaleAndCenterX(float x)
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \
@@ -394,6 +394,9 @@ CMenuManager::ThingsToDoBeforeLeavingPage()
#endif
} else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
m_nDisplayVideoMode = m_nPrefsVideoMode;
+#ifdef IMPROVED_VIDEOMODE
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+#endif
}
if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) {
@@ -413,6 +416,14 @@ CMenuManager::BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2)
if (!text)
return;
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese() && stat2)
+ if (itsFloat)
+ sprintf(gString2, " %.2f/%.2f", *(float*)stat, *(float*)stat2);
+ else
+ sprintf(gString2, " %d/%d", *(int*)stat, *(int*)stat2);
+ else
+#endif
if (stat2) {
if (itsFloat)
sprintf(gString2, " %.2f %s %.2f", *(float*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(float*)stat2);
@@ -596,7 +607,7 @@ CMenuManager::DisplayHelperText()
CFont::SetCentreOn();
CFont::SetScale(SCREEN_SCALE_X(SMALLESTTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
// TODO: name this cases?
switch (m_nHelperTextMsgId) {
@@ -732,7 +743,7 @@ CMenuManager::Draw()
nextYToUse += 24.0f + 10.0f;
}
- CFont::SetFontStyle(FONT_BANK);
+ 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)));
@@ -788,7 +799,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 240;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -805,7 +816,7 @@ CMenuManager::Draw()
columnWidth = 50;
headerHeight = 0;
lineHeight = 20;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = MEDIUMTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = MEDIUMTEXT_Y_SCALE));
CFont::SetRightJustifyOff();
break;
@@ -815,7 +826,7 @@ CMenuManager::Draw()
columnWidth = 120;
headerHeight = 38;
lineHeight = 20;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE));
CFont::SetRightJustifyOff();
break;
@@ -827,7 +838,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 60;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -835,7 +846,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 140;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -843,7 +854,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 117;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -852,7 +863,7 @@ CMenuManager::Draw()
columnWidth = 180;
headerHeight = 60;
lineHeight = 24;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
break;
#endif
@@ -860,14 +871,14 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 40;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
}
#ifdef PS2_LIKE_MENU
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#endif
switch (m_nCurrScreen) {
@@ -890,6 +901,25 @@ CMenuManager::Draw()
bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
+#ifdef MENU_MAP
+ if (m_nCurrScreen == MENUPAGE_MAP) {
+ // Back button
+ wchar *backTx = TheText.Get("FEDS_TB");
+ CFont::SetDropShadowPosition(1);
+ CFont::SetDropColor(CRGBA(0, 0, 0, 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))) {
+ m_nHoverOption = HOVEROPTION_NOT_HOVERING;
+ m_nCurrOption = m_nPrevOption = 0;
+ } else {
+ m_nHoverOption = HOVEROPTION_RANDOM_ITEM;
+ m_nCurrOption = m_nPrevOption = 1;
+ }
+ return;
+ }
+#endif
+
for (int i = 0; i < NUM_MENUROWS; ++i) {
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') {
wchar *rightText = nil;
@@ -1070,6 +1100,18 @@ CMenuManager::Draw()
AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp);
rightText = unicodeTemp;
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ char mode[32];
+ if (m_nSelectedScreenMode == 0)
+ sprintf(mode, "FULLSCREEN");
+ else
+ sprintf(mode, "WINDOWED");
+
+ AsciiToUnicode(mode, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+#endif
case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex == -1)
rightText = TheText.Get("FEA_NAH");
@@ -1241,6 +1283,14 @@ CMenuManager::Draw()
SetHelperText(3);
}
}
+#ifdef IMPROVED_VIDEOMODE
+ if (m_nSelectedScreenMode != m_nPrefsWindowed) {
+ if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "SCRFOR") != 0
+ && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+ }
+ }
+#endif
// Sliders
int lastActiveBarX;
@@ -1580,7 +1630,12 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
nextX += CFont::GetStringWidth(seperator, true) + bindingMargin;
}
CFont::PrintString(nextX, nextY, settingText);
- nextX += CFont::GetStringWidth(settingText, true) + bindingMargin;
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += CFont::GetStringWidth_Jap(settingText) + bindingMargin;
+ else
+#endif
+ nextX += CFont::GetStringWidth(settingText, true) + bindingMargin;
}
}
if (controllerAction == -1) {
@@ -1629,7 +1684,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
}
CFont::SetCentreOn();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
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
@@ -1639,7 +1694,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(0);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
if (!m_bKeyIsOK)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
@@ -1647,24 +1702,24 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
} else {
CFont::SetCentreOn();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
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_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
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_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
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_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
}
}
}
@@ -1819,7 +1874,7 @@ CMenuManager::DrawControllerSetupScreen()
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
// List header
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CAC"));
@@ -1827,7 +1882,7 @@ CMenuManager::DrawControllerSetupScreen()
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_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
int yStart;
if (m_ControlMethod == CONTROL_CLASSIC)
yStart = CONTSETUP_LIST_HEADER_HEIGHT + 29;
@@ -1916,7 +1971,7 @@ CMenuManager::DrawControllerSetupScreen()
}
// Back button and it's shadow
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y));
CFont::SetRightJustifyOn();
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90)));
@@ -2174,7 +2229,7 @@ CMenuManager::DrawFrontEndNormal()
if (CheckHover(xStart, xStart + optionWidth, optionTop, optionBottom))
hoveredBottomBarOption = i;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(0.35f), MENU_Y(0.7f));
CFont::SetRightJustifyOff();
if (hoveredBottomBarOption == i && hoveredBottomBarOption != curBottomBarOption)
@@ -2442,7 +2497,7 @@ CMenuManager::DrawPlayerSetupScreen()
m_pSelectedSkin->nextSkin = new tSkinInfo;
m_pSelectedSkin = m_pSelectedSkin->nextSkin;
m_pSelectedSkin->skinId = 0;
- strcpy(m_pSelectedSkin->skinNameOriginal, "$$\"\"");
+ strcpy(m_pSelectedSkin->skinNameOriginal, DEFAULT_SKIN_NAME);
strcpy(m_pSelectedSkin->skinNameDisplayed, UnicodeToAscii(TheText.Get("FET_DSN")));
int nextSkinId = 1;
m_pSelectedSkin->nextSkin = nil;
@@ -2451,7 +2506,7 @@ CMenuManager::DrawPlayerSetupScreen()
SYSTEMTIME SystemTime;
HANDLE handle = FindFirstFile("skins\\*.bmp", &FindFileData);
for (int i = 1; handle != INVALID_HANDLE_VALUE && i; i = FindNextFile(handle, &FindFileData)) {
- if (strncmp(FindFileData.cFileName, "$$\"\"", 5) != 0) {
+ if (strncmp(FindFileData.cFileName, DEFAULT_SKIN_NAME, 5) != 0) {
m_pSelectedSkin->nextSkin = new tSkinInfo;
m_pSelectedSkin = m_pSelectedSkin->nextSkin;
m_pSelectedSkin->skinId = nextSkinId;
@@ -2525,7 +2580,7 @@ CMenuManager::DrawPlayerSetupScreen()
} else {
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
CFont::SetRightJustifyOn();
CFont::PrintString(MENU_X_RIGHT_ALIGNED(PLAYERSETUP_DATE_COLUMN_RIGHT), MENU_Y(PLAYERSETUP_LIST_TOP), TheText.Get("FES_DAT"));
@@ -2544,7 +2599,7 @@ CMenuManager::DrawPlayerSetupScreen()
// Skin list
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(PLAYERSETUP_ROW_TEXT_X_SCALE), MENU_Y(PLAYERSETUP_ROW_TEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
if (m_nSkinsTotal > 0) {
for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin->skinId != m_nFirstVisibleRowOnList;
m_pSelectedSkin = m_pSelectedSkin->nextSkin);
@@ -2698,7 +2753,7 @@ CMenuManager::DrawPlayerSetupScreen()
// Big apply button
if (strcmp(m_aSkinName, m_PrefsSkinFile) != 0) {
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
switch (m_PrefsLanguage) {
case LANGUAGE_FRENCH:
CFont::SetScale(MENU_X(1.1f), MENU_Y(1.9f));
@@ -2718,7 +2773,7 @@ CMenuManager::DrawPlayerSetupScreen()
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(20.0f), MENU_Y(220.0f), TheText.Get("FET_APL"));
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(SMALLTEXT_X_SCALE), MENU_Y(SMALLTEXT_Y_SCALE));
@@ -2796,7 +2851,7 @@ CMenuManager::DrawPlayerSetupScreen()
m_nHoverOption = HOVEROPTION_NOT_HOVERING;
}
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(SMALLTEXT_X_SCALE), MENU_Y(SMALLTEXT_Y_SCALE));
CFont::SetRightJustifyOn();
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90)));
@@ -2898,6 +2953,8 @@ CMenuManager::InitialiseChangedLanguageSettings()
CGame::frenchGame = false;
CGame::germanGame = false;
#ifdef MORE_LANGUAGES
+ CGame::russianGame = false;
+ CGame::japaneseGame = false;
switch (m_PrefsLanguage) {
case LANGUAGE_POLISH:
CFont::ReloadFonts(FONT_LANGSET_POLISH);
@@ -2905,6 +2962,9 @@ CMenuManager::InitialiseChangedLanguageSettings()
case LANGUAGE_RUSSIAN:
CFont::ReloadFonts(FONT_LANGSET_RUSSIAN);
break;
+ case LANGUAGE_JAPANESE:
+ CFont::ReloadFonts(FONT_LANGSET_JAPANESE);
+ break;
default:
CFont::ReloadFonts(FONT_LANGSET_EFIGS);
break;
@@ -2919,12 +2979,12 @@ CMenuManager::InitialiseChangedLanguageSettings()
CGame::germanGame = true;
break;
#ifdef MORE_LANGUAGES
- case LANGUAGE_POLISH:
- CGame::polishGame = true;
- break;
case LANGUAGE_RUSSIAN:
CGame::russianGame = true;
break;
+ case LANGUAGE_JAPANESE:
+ CGame::japaneseGame = true;
+ break;
#endif
default:
break;
@@ -3027,7 +3087,25 @@ CMenuManager::LoadSettings()
if (strncmp(Ver, TopLineEmptyFile, sizeof(TopLineEmptyFile) - 1)) {
CFileMgr::Seek(fileHandle, 0, 0);
ControlsManager.LoadSettings(fileHandle);
+#ifdef IMPROVED_VIDEOMODE
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
+ if(m_nPrefsWindowed != 0 && m_nPrefsWindowed != 1){
+ // garbage data from vanilla settings file
+ // let skeleton find something
+ m_nPrefsWidth = 0;
+ m_nPrefsHeight = 0;
+ m_nPrefsDepth = 0;
+ m_nPrefsWindowed = 0;
+ m_nPrefsSubsystem = 0;
+ }
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+#else
CFileMgr::Read(fileHandle, gString, 20);
+#endif
CFileMgr::Read(fileHandle, gString, 20);
CFileMgr::Read(fileHandle, gString, 4);
CFileMgr::Read(fileHandle, gString, 4);
@@ -3094,8 +3172,8 @@ CMenuManager::LoadSettings()
if (!SkinFound) {
OutputDebugString("Default skin set as no other skins are available OR saved skin not found!");
- strcpy(m_PrefsSkinFile, "$$\"\"");
- strcpy(m_aSkinName, "$$\"\"");
+ strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME);
+ strcpy(m_aSkinName, DEFAULT_SKIN_NAME);
}
}
@@ -3109,7 +3187,15 @@ CMenuManager::SaveSettings()
int fileHandle = CFileMgr::OpenFile("gta3.set", "w+");
if (fileHandle) {
ControlsManager.SaveSettings(fileHandle);
+#ifdef IMPROVED_VIDEOMODE
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
+#else
CFileMgr::Write(fileHandle, RubbishString, 20);
+#endif
CFileMgr::Write(fileHandle, RubbishString, 20);
CFileMgr::Write(fileHandle, RubbishString, 4);
CFileMgr::Write(fileHandle, RubbishString, 4);
@@ -3169,7 +3255,7 @@ CMenuManager::MessageScreen(const char *text)
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f));
CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(170.0f));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_SCALE_FROM_BOTTOM(220.0f)), CRGBA(50, 50, 50, 210));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetCentreSize(SCREEN_SCALE_X(380.0f));
CFont::SetCentreOn();
CFont::SetColor(CRGBA(255, 217, 106, 255));
@@ -3199,7 +3285,7 @@ void
CMenuManager::PrintBriefs()
{
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
- CFont::SetFontStyle(FONT_BANK);
+ 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
@@ -3254,7 +3340,7 @@ CMenuManager::PrintErrorMessage()
return;
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(140.0f), SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f)), CRGBA(64, 16, 16, 224));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetBackgroundOff();
CFont::SetPropOn();
CFont::SetCentreOff();
@@ -3275,7 +3361,7 @@ CMenuManager::PrintStats()
{
int rowNum = ConstructStatLine(99999);
#ifdef GTA3_1_1_PATCH
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#endif
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
float nextYChange, y, alphaMult;
@@ -3334,9 +3420,21 @@ CMenuManager::PrintStats()
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::SetRightJustifyOff();
- CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA")); nextX += MENU_X(10.0f) + CFont::GetStringWidth(TheText.Get("CRIMRA"), true);
+ CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA"));
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += MENU_X(10.0f) + CFont::GetStringWidth_Jap(TheText.Get("CRIMRA"));
+ else
+#endif
+ nextX += MENU_X(10.0f) + CFont::GetStringWidth(TheText.Get("CRIMRA"), true);
UnicodeStrcpy(gUString, CStats::FindCriminalRatingString());
- CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString); nextX += MENU_X(6.0f) + CFont::GetStringWidth(gUString, true);
+ CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString);
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += MENU_X(6.0f) + CFont::GetStringWidth_Jap(gUString);
+ else
+#endif
+ nextX += MENU_X(6.0f) + CFont::GetStringWidth(gUString, true);
sprintf(gString, "%d", CStats::FindCriminalRatingNumber());
AsciiToUnicode(gString, gUString);
CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString);
@@ -4285,6 +4383,12 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_LANG_RUS:
m_PrefsLanguage = LANGUAGE_RUSSIAN;
m_bFrontEnd_ReloadObrTxtGxt = true;
+ CMenuManager::InitialiseChangedLanguageSettings();
+ SaveSettings();
+ break;
+ case MENUACTION_LANG_JAP:
+ m_PrefsLanguage = LANGUAGE_JAPANESE;
+ m_bFrontEnd_ReloadObrTxtGxt = true;
InitialiseChangedLanguageSettings();
SaveSettings();
break;
@@ -4428,6 +4532,16 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
}
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ if (m_nSelectedScreenMode != m_nPrefsWindowed) {
+ m_nPrefsWindowed = m_nSelectedScreenMode;
+ _psSelectScreenVM(m_nPrefsVideoMode); // apply same resolution
+ SetHelperText(0);
+ SaveSettings();
+ }
+ break;
+#endif
case MENUACTION_AUDIOHW:
{
int selectedProvider = m_nPrefsAudio3DProviderIndex;
@@ -4701,6 +4815,12 @@ CMenuManager::ProcessButtonPresses(void)
}
}
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
+ m_nSelectedScreenMode = !m_nSelectedScreenMode;
+ break;
+#endif
case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex != -1) {
m_nPrefsAudio3DProviderIndex += changeValueBy;
@@ -5075,7 +5195,7 @@ CMenuManager::PrintController(void)
m_aFrontEndSprites[FE_ARROWS4].Draw(MENU_X_LEFT_ALIGNED(160.0f), MENU_Y(160.0f), MENU_X(235.2f), MENU_Y(175.2f), CRGBA(255, 255, 255, 255));
}
- CFont::SetFontStyle(FONT_BANK); // X
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); // X
// CFont::SetScale(0.4f, 0.4f);
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); // X
@@ -5280,13 +5400,13 @@ CMenuManager::PrintController(void)
#define ZOOM(x, y, in) \
do { \
- if(fMapSize > SCREEN_WIDTH * 2 && in) \
+ if(fMapSize > SCREEN_HEIGHT * 3.0f && in) \
break; \
float z2 = in? 1.1f : 1.f/1.1f; \
fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \
fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \
\
- if (fMapSize < SCREEN_WIDTH / 3 && !in) \
+ if (fMapSize < SCREEN_HEIGHT / 2 && !in) \
break; \
\
fMapSize *= z2; \
@@ -5299,10 +5419,18 @@ CMenuManager::PrintMap(void)
bMenuMapActive = true;
CRadar::InitFrontEndMap();
+ // Just entered to map
if (!bMapLoaded) {
- fMapCenterX = SCREEN_WIDTH / 2;
- fMapCenterY = SCREEN_HEIGHT / 3;
- fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio();
+ fMapSize = SCREEN_HEIGHT * 2.0f;
+ fMapCenterX = 0.0f;
+ fMapCenterY = 0.0f;
+ 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;
@@ -5452,13 +5580,23 @@ CMenuManager::PrintMap(void)
CRGBA(235, 170, 50, 255));
CFont::SetScale(MENU_X(0.4f), MENU_Y(0.7f));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
float nextX = MENU_X(30.0f), nextY = 95.0f;
wchar *text;
+#ifdef MORE_LANGUAGES
+#define TEXT_PIECE(key,extraSpace) \
+ text = TheText.Get(key);\
+ CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text);\
+ if (CFont::IsJapanese())\
+ nextX += CFont::GetStringWidth_Jap(text) + MENU_X(extraSpace);\
+ else\
+ nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace);
+#else
#define TEXT_PIECE(key,extraSpace) \
text = TheText.Get(key); CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text); nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace);
+#endif
TEXT_PIECE("FEC_MWF", 3.0f);
TEXT_PIECE("FEC_PGU", 1.0f);
@@ -5506,9 +5644,9 @@ CMenuManager::ConstructStatLine(int rowIdx)
STAT_LINE("PER_COM", &percentCompleted, false, nil);
STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil);
- STAT_LINE("FEST_MP", &CStats::MissionsPassed, 0, &CStats::TotalNumberMissions);
+ STAT_LINE("FEST_MP", &CStats::MissionsPassed, false, &CStats::TotalNumberMissions);
if (CGame::nastyGame) {
- STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, 0, &CStats::TotalNumberKillFrenzies);
+ STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, false, &CStats::TotalNumberKillFrenzies);
}
CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus];
@@ -5517,8 +5655,8 @@ CMenuManager::ConstructStatLine(int rowIdx)
packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages;
int nPackagesPercent = packagesPercent;
- STAT_LINE("PERPIC", &nPackagesPercent, 0, &(nTemp = 100));
- STAT_LINE("NOUNIF", &CStats::TotalNumberOfUniqueJumps, 0, &CStats::NumberOfUniqueJumpsFound);
+ STAT_LINE("PERPIC", &nPackagesPercent, false, &(nTemp = 100));
+ STAT_LINE("NOUNIF", &CStats::NumberOfUniqueJumpsFound, false, &CStats::TotalNumberOfUniqueJumps);
STAT_LINE("DAYSPS", &CStats::DaysPassed, false, nil);
if (CGame::nastyGame) {
STAT_LINE("PE_WAST", &CStats::PeopleKilledByPlayer, false, nil);
@@ -5599,6 +5737,7 @@ CMenuManager::ConstructStatLine(int rowIdx)
#ifdef MORE_LANGUAGES
case LANGUAGE_POLISH:
case LANGUAGE_RUSSIAN:
+ case LANGUAGE_JAPANESE:
#endif
STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, true, nil);
STAT_LINE("FESTDCM", &CStats::DistanceTravelledInVehicle, true, nil);
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index ef5279aa..e496f9c0 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -91,6 +91,7 @@ enum eLanguages
#ifdef MORE_LANGUAGES
LANGUAGE_POLISH,
LANGUAGE_RUSSIAN,
+ LANGUAGE_JAPANESE,
#endif
};
@@ -368,6 +369,10 @@ enum eMenuAction
#ifdef MORE_LANGUAGES
MENUACTION_LANG_PL,
MENUACTION_LANG_RUS,
+ MENUACTION_LANG_JAP,
+#endif
+#ifdef IMPROVED_VIDEOMODE
+ MENUACTION_SCREENMODE
#endif
};
@@ -531,6 +536,15 @@ public:
int32 m_nCurrSaveSlot;
int32 m_nScreenChangeDelayTimer;
+#ifdef IMPROVED_VIDEOMODE
+ int32 m_nPrefsWidth;
+ int32 m_nPrefsHeight;
+ int32 m_nPrefsDepth;
+ int32 m_nPrefsWindowed;
+ int32 m_nPrefsSubsystem;
+ int32 m_nSelectedScreenMode;
+#endif
+
public:
bool GetIsMenuActive() {return !!m_bMenuActive;}
@@ -643,7 +657,9 @@ public:
// uint8 GetNumberOfMenuOptions();
};
-static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");
+#ifndef IMPROVED_VIDEOMODE
+VALIDATE_SIZE(CMenuManager, 0x564);
+#endif
extern CMenuManager FrontEndMenuManager;
extern unsigned long _dwOperatingSystemVersion; \ No newline at end of file
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 8ab12e3f..c50471f1 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -97,8 +97,8 @@ bool CGame::noProstitutes;
bool CGame::playingIntro;
char CGame::aDatFile[32];
#ifdef MORE_LANGUAGES
-bool CGame::polishGame = false;
bool CGame::russianGame = false;
+bool CGame::japaneseGame = false;
#endif
int gameTxdSlot;
@@ -306,24 +306,7 @@ bool CGame::Initialise(const char* datFile)
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
LoadingScreen("Loading the Game", "Setup streaming", nil);
-#ifdef USE_TXD_CDIMAGE
- int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
- if (txdHandle)
- CFileMgr::CloseFile(txdHandle);
- if (!CheckVideoCardCaps() && txdHandle) {
- CdStreamAddImage("MODELS\\TXD.IMG");
- CStreaming::Init();
- } else {
- CStreaming::Init();
- if (CreateTxdImageForVideoCard()) {
- CStreaming::Shutdown();
- CdStreamAddImage("MODELS\\TXD.IMG");
- CStreaming::Init();
- }
- }
-#else
CStreaming::Init();
-#endif
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
CStreaming::RequestBigBuildings(LEVEL_NONE);
@@ -615,8 +598,9 @@ void CGame::Process(void)
TheCamera.SetMotionBlurAlpha(0);
if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
-
+#ifdef DEBUGMENU
DebugMenuProcess();
+#endif
CCutsceneMgr::Update();
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
FrontEndMenuManager.Process();
diff --git a/src/core/Game.h b/src/core/Game.h
index 01f5f0e9..48f31abc 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -17,8 +17,8 @@ public:
static bool frenchGame;
static bool germanGame;
#ifdef MORE_LANGUAGES
- static bool polishGame;
static bool russianGame;
+ static bool japaneseGame;
#endif
static bool noProstitutes;
static bool playingIntro;
diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h
index e55ec49f..6c2ebdb8 100644
--- a/src/core/MenuScreens.h
+++ b/src/core/MenuScreens.h
@@ -62,6 +62,9 @@ const CMenuScreen aScreens[] = {
MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
+#ifdef IMPROVED_VIDEOMODE
+ MENUACTION_SCREENMODE, "SCRFOR", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
+#endif
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
@@ -76,6 +79,7 @@ const CMenuScreen aScreens[] = {
#ifdef MORE_LANGUAGES
MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE,
+ MENUACTION_LANG_JAP, "FEL_JAP", SAVESLOT_NONE, MENUPAGE_NONE,
#endif
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
@@ -455,6 +459,8 @@ const CMenuScreen aScreens[] = {
#ifdef MENU_MAP
// MENUPAGE_MAP = 59
{ "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2,
+ MENUACTION_UNK110, "", SAVESLOT_NONE, MENUPAGE_NONE, // to prevent cross/enter to go back
+ MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
#endif
};
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 0a626570..da86d15e 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -55,6 +55,10 @@ CMouseControllerState CPad::OldMouseControllerState;
CMouseControllerState CPad::NewMouseControllerState;
CMouseControllerState CPad::PCTempMouseControllerState;
+#ifdef DETECT_PAD_INPUT_SWITCH
+bool CPad::IsAffectedByController = false;
+#endif
+
_TODO("gbFastTime");
extern bool gbFastTime;
@@ -102,12 +106,12 @@ void TankCheat()
CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE);
#endif
if (tank != nil) {
- CVector pos = ThePaths.m_pathNodes[node].pos;
+ CVector pos = ThePaths.m_pathNodes[node].GetPosition();
pos.z += 4.0f;
- tank->GetPosition() = pos;
+ tank->SetPosition(pos);
tank->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f));
- tank->m_status = STATUS_ABANDONED;
+ tank->SetStatus(STATUS_ABANDONED);
tank->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(tank);
}
@@ -325,6 +329,16 @@ void AltDodoCheat(void)
}
#endif
+#ifdef DETECT_PAD_INPUT_SWITCH
+bool
+CControllerState::IsAnyButtonPressed(void)
+{
+ return !!LeftStickX || !!LeftStickY || !!RightStickX || !!RightStickY || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 ||
+ !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight || !!Start || !!Select || !!Square || !!Triangle || !!Cross || !!Circle || !!LeftShock ||
+ !!RightShock || !!NetworkTalk;
+}
+#endif
+
void
CControllerState::Clear(void)
{
@@ -575,14 +589,15 @@ void CPad::UpdateMouse()
PCTempMouseControllerState.MXB1 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_4);
PCTempMouseControllerState.MXB2 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_5);
- PSGLOBAL(lastMousePos.x) = xpos;
- PSGLOBAL(lastMousePos.y) = ypos;
-
if (PSGLOBAL(mouseWheel) > 0)
PCTempMouseControllerState.WHEELUP = 1;
else if (PSGLOBAL(mouseWheel) < 0)
PCTempMouseControllerState.WHEELDN = 1;
+ PSGLOBAL(lastMousePos.x) = xpos;
+ PSGLOBAL(lastMousePos.y) = ypos;
+ PSGLOBAL(mouseWheel) = 0.0f;
+
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
#endif
@@ -1001,7 +1016,7 @@ void CPad::AffectFromXinput(uint32 pad)
if (Abs(rx) > 0.3f || Abs(ry) > 0.3f) {
PCTempJoyState.RightStickX = (int32)(rx * 128.0f);
- PCTempJoyState.RightStickY = (int32)(ry * 128.0f);
+ PCTempJoyState.RightStickY = (int32)(-ry * 128.0f);
}
XINPUT_VIBRATION VibrationState;
@@ -1036,11 +1051,20 @@ void CPad::UpdatePads(void)
#else
CapturePad(0);
#endif
-
+#ifdef DETECT_PAD_INPUT_SWITCH
+ if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed())
+ IsAffectedByController = true;
+ else {
+#endif
+ ControlsManager.ClearSimButtonPressCheckers();
+ ControlsManager.AffectPadFromKeyBoard();
+ ControlsManager.AffectPadFromMouse();
- ControlsManager.ClearSimButtonPressCheckers();
- ControlsManager.AffectPadFromKeyBoard();
- ControlsManager.AffectPadFromMouse();
+#ifdef DETECT_PAD_INPUT_SWITCH
+ }
+ if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed()))
+ IsAffectedByController = false;
+#endif
if ( CReplay::IsPlayingBackFromFile() )
bUpdate = false;
@@ -1095,7 +1119,10 @@ void CPad::Update(int16 unk)
void CPad::DoCheats(void)
{
- GetPad(0)->DoCheats(0);
+#ifdef DETECT_PAD_INPUT_SWITCH
+ if (IsAffectedByController)
+#endif
+ GetPad(0)->DoCheats(0);
}
void CPad::DoCheats(int16 unk)
@@ -1153,13 +1180,19 @@ CPad *CPad::GetPad(int32 pad)
{
return &Pads[pad];
}
+#ifdef DETECT_PAD_INPUT_SWITCH
+#define CURMODE (IsAffectedByController ? Mode : 0)
+#else
+#define CURMODE (Mode)
+#endif
+
int16 CPad::GetSteeringLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1191,8 +1224,8 @@ int16 CPad::GetSteeringUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1224,8 +1257,8 @@ int16 CPad::GetCarGunUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1251,8 +1284,8 @@ int16 CPad::GetCarGunLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1278,8 +1311,8 @@ int16 CPad::GetPedWalkLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1312,8 +1345,8 @@ int16 CPad::GetPedWalkUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1343,7 +1376,7 @@ int16 CPad::GetPedWalkUpDown(void)
int16 CPad::GetAnalogueUpDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1408,8 +1441,8 @@ bool CPad::GetHorn(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1447,8 +1480,8 @@ bool CPad::HornJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1487,8 +1520,8 @@ bool CPad::GetCarGunFired(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1514,8 +1547,8 @@ bool CPad::CarGunJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1541,8 +1574,8 @@ int16 CPad::GetHandBrake(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1574,8 +1607,8 @@ int16 CPad::GetBrake(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1612,8 +1645,8 @@ bool CPad::GetExitVehicle(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1639,8 +1672,8 @@ bool CPad::ExitVehicleJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1666,8 +1699,8 @@ int32 CPad::GetWeapon(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1699,8 +1732,8 @@ bool CPad::WeaponJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1732,8 +1765,8 @@ int16 CPad::GetAccelerate(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1768,7 +1801,7 @@ int16 CPad::GetAccelerate(void)
bool CPad::CycleCameraModeUpJustDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1792,7 +1825,7 @@ bool CPad::CycleCameraModeUpJustDown(void)
bool CPad::CycleCameraModeDownJustDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1818,8 +1851,8 @@ bool CPad::ChangeStationJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1874,8 +1907,8 @@ bool CPad::GetTarget(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1901,8 +1934,8 @@ bool CPad::TargetJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1936,8 +1969,8 @@ bool CPad::GetSprint(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2091,8 +2124,8 @@ bool CPad::ForceCameraBehindPlayer(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2124,8 +2157,8 @@ bool CPad::SniperZoomIn(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2151,8 +2184,8 @@ bool CPad::SniperZoomOut(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2174,6 +2207,7 @@ bool CPad::SniperZoomOut(void)
return false;
}
+#undef CURMODE
int16 CPad::SniperModeLookLeftRight(void)
{
@@ -2189,6 +2223,9 @@ int16 CPad::SniperModeLookLeftRight(void)
int16 CPad::SniperModeLookUpDown(void)
{
int16 axis = NewState.LeftStickY;
+#ifdef FIX_BUGS
+ axis = -axis;
+#endif
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
if ( Abs(axis) > Abs(dpad) )
@@ -2215,7 +2252,11 @@ int16 CPad::LookAroundLeftRight(void)
int16 CPad::LookAroundUpDown(void)
{
int16 axis = GetPad(0)->NewState.RightStickY;
-
+
+#ifdef FIX_BUGS
+ axis = -axis;
+#endif
+
if ( Abs(axis) > 85 && !GetLookBehindForPed() )
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
* (127.0f / 32.0f) ); // 3.96875f
diff --git a/src/core/Pad.h b/src/core/Pad.h
index b8228444..ea771f81 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -29,6 +29,9 @@ public:
float GetRightStickX(void) { return RightStickX/32767.0f; };
float GetRightStickY(void) { return RightStickY/32767.0f; };
+#ifdef DETECT_PAD_INPUT_SWITCH
+ bool IsAnyButtonPressed();
+#endif
void Clear(void);
};
VALIDATE_SIZE(CControllerState, 0x2A);
@@ -158,7 +161,10 @@ public:
int32 LastTimeTouched;
int32 AverageWeapon;
int32 AverageEntries;
-
+
+#ifdef DETECT_PAD_INPUT_SWITCH
+ static bool IsAffectedByController;
+#endif
CPad() { }
~CPad() { }
@@ -418,6 +424,7 @@ public:
bool GetLeftStickYJustDown() { return !!(NewState.LeftStickY && !OldState.LeftStickY); }
bool GetTriangleJustUp() { return !!(!NewState.Triangle && OldState.Triangle); }
+ bool GetCircleJustUp() { return !!(!NewState.Circle && OldState.Circle); }
bool GetCrossJustUp() { return !!(!NewState.Cross && OldState.Cross); }
bool GetSquareJustUp() { return !!(!NewState.Square && OldState.Square); }
bool GetDPadUpJustUp() { return !!(!NewState.DPadUp && OldState.DPadUp); }
diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp
index 99ca5659..69b3d3ea 100644
--- a/src/core/Placeable.cpp
+++ b/src/core/Placeable.cpp
@@ -12,9 +12,9 @@ CPlaceable::~CPlaceable(void) = default;
void
CPlaceable::SetHeading(float angle)
{
- CVector pos = GetPosition();
+ CVector pos = GetMatrix().GetPosition();
m_matrix.SetRotateZ(angle);
- GetPosition() += pos;
+ GetMatrix().Translate(pos);
}
bool
diff --git a/src/core/Placeable.h b/src/core/Placeable.h
index 2df26a7c..970c0d48 100644
--- a/src/core/Placeable.h
+++ b/src/core/Placeable.h
@@ -10,7 +10,13 @@ public:
CPlaceable(void);
virtual ~CPlaceable(void);
- CVector &GetPosition(void) { return m_matrix.GetPosition(); }
+ const CVector &GetPosition(void) { return m_matrix.GetPosition(); }
+ void SetPosition(float x, float y, float z) {
+ m_matrix.GetPosition().x = x;
+ m_matrix.GetPosition().y = y;
+ m_matrix.GetPosition().z = z;
+ }
+ void SetPosition(const CVector &pos) { m_matrix.GetPosition() = pos; }
CVector &GetRight(void) { return m_matrix.GetRight(); }
CVector &GetForward(void) { return m_matrix.GetForward(); }
CVector &GetUp(void) { return m_matrix.GetUp(); }
@@ -25,4 +31,5 @@ public:
bool IsWithinArea(float x1, float y1, float x2, float y2);
bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2);
};
-static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error"); \ No newline at end of file
+
+VALIDATE_SIZE(CPlaceable, 0x4C);
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index e92f7568..ec6d3023 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -38,7 +38,7 @@ CPlayerInfo::SetPlayerSkin(char *skin)
LoadPlayerSkin();
}
-CVector&
+const CVector &
CPlayerInfo::GetPos()
{
#ifdef FIX_BUGS
@@ -328,7 +328,7 @@ CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1,
continue;
car->m_scanCode = CWorld::GetCurrentScanCode();
- if (car->m_status != STATUS_WRECKED && car->m_status != STATUS_TRAIN_MOVING
+ 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();
@@ -354,7 +354,7 @@ CPlayerInfo::Process(void)
bool startTaxiTimer = true;
if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
CVehicle *veh = m_pPed->m_pMyVehicle;
- if ((veh->m_modelIndex == MI_TAXI || veh->m_modelIndex == MI_CABBIE || veh->m_modelIndex == MI_BORGNINE)
+ if ((veh->GetModelIndex() == MI_TAXI || veh->GetModelIndex() == MI_CABBIE || veh->GetModelIndex() == MI_BORGNINE)
&& veh->pDriver == m_pPed && veh->m_nNumPassengers != 0) {
for (uint32 timePassed = CTimer::GetTimeInMilliseconds() - m_nUnusedTaxiTimer; timePassed >= 1000; m_nUnusedTaxiTimer += 1000) {
timePassed -= 1000;
@@ -407,13 +407,13 @@ CPlayerInfo::Process(void)
if (m_pPed->bInVehicle) {
if (!m_pRemoteVehicle) {
CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity;
- if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->m_modelIndex)) {
+ if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->GetModelIndex())) {
CVehicle *veh = m_pPed->m_pMyVehicle;
if (!veh->IsBoat() || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
// This condition will always return true, else block was probably WIP Miami code.
if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
- if (veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
+ if (veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) {
m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
}
@@ -430,7 +430,7 @@ CPlayerInfo::Process(void)
CPed::PedSetOutCarCB(0, m_pPed);
CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
CAnimManager::BlendAnimation(m_pPed->GetClump(), ASSOCGRP_STD, ANIM_FALL_LAND, 100.0f);
- m_pPed->GetPosition() = sth;
+ m_pPed->SetPosition(sth);
m_pPed->SetMoveState(PEDMOVE_STILL);
m_pPed->m_vecMoveSpeed = veh->m_vecMoveSpeed;
}
@@ -454,9 +454,9 @@ CPlayerInfo::Process(void)
weAreOnBoat = true;
m_pPed->bOnBoat = true;
#ifdef VC_PED_PORTS
- if (carBelow->m_status != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
+ if (carBelow->GetStatus() != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
#else
- if (carBelow->m_status != STATUS_WRECKED)
+ if (carBelow->GetStatus() != STATUS_WRECKED)
#endif
m_pPed->SetSeekBoatPosition(carBelow);
}
@@ -491,7 +491,7 @@ CPlayerInfo::Process(void)
}
// carBelow is now closest vehicle
if (carBelow && !weAreOnBoat) {
- if (carBelow->m_status == STATUS_TRAIN_NOT_MOVING) {
+ if (carBelow->GetStatus() == STATUS_TRAIN_NOT_MOVING) {
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
} else if (carBelow->IsBoat()) {
if (!carBelow->pDriver) {
@@ -526,7 +526,7 @@ CPlayerInfo::Process(void)
m_bInRemoteMode = false;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = nil;
if (FindPlayerVehicle()) {
- FindPlayerVehicle()->m_status = STATUS_PLAYER;
+ FindPlayerVehicle()->SetStatus(STATUS_PLAYER);
}
}
}
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index ff31418c..94410753 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -62,7 +62,7 @@ public:
void DeletePlayerSkin();
void AwardMoneyForExplosion(CVehicle *vehicle);
void SetPlayerSkin(char* skin);
- CVector& GetPos();
+ const CVector &GetPos();
void Process(void);
void KillPlayer(void);
void ArrestPlayer(void);
@@ -81,4 +81,4 @@ public:
~CPlayerInfo() { };
};
-static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");
+VALIDATE_SIZE(CPlayerInfo, 0x13C);
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 4f4588da..bc65f6b6 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -88,7 +88,7 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
delete object;
} else if (!CProjectileInfo::RemoveIfThisIsAProjectile(object)) {
// relocate to another slot??
- CObject *newObject = new CObject();
+ CObject *newObject = new CObject(object->GetModelIndex(), false);
CWorld::Remove(object);
memcpy(newObject, object, ms_pObjectPool->GetMaxEntrySize());
CWorld::Add(newObject);
@@ -110,13 +110,24 @@ INITSAVEBUF
CStreaming::LoadAllRequestedModels(false);
int32 slot = ReadSaveBuf<int32>(buf);
CVehicle* pVehicle;
- char* vbuf = new char[Max(sizeof(CAutomobile), sizeof(CBoat))];
+#ifdef COMPATIBLE_SAVES
+ if (type == VEHICLE_TYPE_BOAT)
+ pVehicle = new(slot) CBoat(model, RANDOM_VEHICLE);
+ else if (type == VEHICLE_TYPE_CAR)
+ pVehicle = new(slot) CAutomobile(model, RANDOM_VEHICLE);
+ else
+ assert(0);
+ --CCarCtrl::NumRandomCars;
+ pVehicle->Load(buf);
+ CWorld::Add(pVehicle);
+#else
+ char* vbuf = new char[Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize)];
if (type == VEHICLE_TYPE_BOAT) {
memcpy(vbuf, buf, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
CBoat* pBoat = new(slot) CBoat(model, RANDOM_VEHICLE);
pVehicle = pBoat;
- --CCarCtrl::NumRandomCars; // why?
+ --CCarCtrl::NumRandomCars;
}
else if (type == VEHICLE_TYPE_CAR) {
memcpy(vbuf, buf, sizeof(CAutomobile));
@@ -161,13 +172,14 @@ INITSAVEBUF
pVehicle->m_nTimeOfDeath = pBufferVehicle->m_nTimeOfDeath;
#endif
pVehicle->m_nDoorLock = pBufferVehicle->m_nDoorLock;
- pVehicle->m_status = pBufferVehicle->m_status;
- pVehicle->m_type = pBufferVehicle->m_type;
+ pVehicle->SetStatus(pBufferVehicle->GetStatus());
+ pVehicle->SetType(pBufferVehicle->GetType());
(pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0];
(pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1];
pVehicle->AutoPilot = pBufferVehicle->AutoPilot;
CWorld::Add(pVehicle);
delete[] vbuf;
+#endif
}
VALIDATESAVEBUF(size)
}
@@ -184,7 +196,7 @@ INITSAVEBUF
continue;
bool bHasPassenger = false;
for (int j = 0; j < ARRAY_SIZE(pVehicle->pPassengers); j++) {
- if (pVehicle->pPassengers[i])
+ if (pVehicle->pPassengers[j])
bHasPassenger = true;
}
if (!pVehicle->pDriver && !bHasPassenger) {
@@ -194,8 +206,8 @@ INITSAVEBUF
++nNumBoats;
}
}
- *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CAutomobile)) + sizeof(int) +
- nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CBoat)) + sizeof(int);
+ *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) +
+ nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int);
WriteSaveBuf(buf, nNumCars);
WriteSaveBuf(buf, nNumBoats);
for (int i = 0; i < nPoolSize; i++) {
@@ -208,20 +220,29 @@ INITSAVEBUF
bHasPassenger = true;
}
if (!pVehicle->pDriver && !bHasPassenger) {
+#ifdef COMPATIBLE_SAVES
+ if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
+ WriteSaveBuf<uint32>(buf, pVehicle->m_vehType);
+ WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex());
+ WriteSaveBuf<int32>(buf, GetVehicleRef(pVehicle));
+ pVehicle->Save(buf);
+ }
+#else
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
- WriteSaveBuf(buf, pVehicle->m_modelIndex);
+ WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CAutomobile));
SkipSaveBuf(buf, sizeof(CAutomobile));
}
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
- WriteSaveBuf(buf, pVehicle->m_modelIndex);
+ WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
}
+#endif
}
}
VALIDATESAVEBUF(*size)
@@ -258,7 +279,7 @@ INITSAVEBUF
bool bHasBeenDamaged = pObject->bHasBeenDamaged;
bool bUseVehicleColours = pObject->bUseVehicleColours;
CCompressedMatrixNotAligned tmp;
- WriteSaveBuf(buf, pObject->m_modelIndex);
+ WriteSaveBuf(buf, pObject->GetModelIndex());
WriteSaveBuf(buf, GetObjectRef(pObject));
tmp.CompressFromFullMatrix(pObject->GetMatrix());
WriteSaveBuf(buf, tmp);
@@ -279,8 +300,12 @@ INITSAVEBUF
WriteSaveBuf(buf, pObject->m_nCollisionDamageEffect);
WriteSaveBuf(buf, pObject->m_nSpecialCollisionResponseCases);
WriteSaveBuf(buf, pObject->m_nEndOfLifeTime);
+#ifdef COMPATIBLE_SAVES
+ pObject->SaveEntityFlags(buf);
+#else
WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[0]);
WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[1]);
+#endif
}
}
VALIDATESAVEBUF(*size)
@@ -315,12 +340,17 @@ INITSAVEBUF
pBufferObject->m_nCollisionDamageEffect = ReadSaveBuf<uint8>(buf);
pBufferObject->m_nSpecialCollisionResponseCases = ReadSaveBuf<uint8>(buf);
pBufferObject->m_nEndOfLifeTime = ReadSaveBuf<uint32>(buf);
+#ifndef COMPATIBLE_SAVES
(pBufferObject->GetAddressOfEntityProperties())[0] = ReadSaveBuf<uint32>(buf);
(pBufferObject->GetAddressOfEntityProperties())[1] = ReadSaveBuf<uint32>(buf);
+#endif
if (GetObjectPool()->GetSlot(ref >> 8))
CPopulation::ConvertToDummyObject(GetObjectPool()->GetSlot(ref >> 8));
CObject* pObject = new(ref) CObject(mi, false);
pObject->GetMatrix() = pBufferObject->GetMatrix();
+#ifdef COMPATIBLE_SAVES
+ pObject->LoadEntityFlags(buf);
+#endif
pObject->m_fUprootLimit = pBufferObject->m_fUprootLimit;
pObject->m_objectMatrix = pBufferObject->m_objectMatrix;
pObject->ObjectCreatedBy = pBufferObject->ObjectCreatedBy;
@@ -335,8 +365,10 @@ INITSAVEBUF
pObject->m_nCollisionDamageEffect = pBufferObject->m_nCollisionDamageEffect;
pObject->m_nSpecialCollisionResponseCases = pBufferObject->m_nSpecialCollisionResponseCases;
pObject->m_nEndOfLifeTime = pBufferObject->m_nEndOfLifeTime;
+#ifndef COMPATIBLE_SAVES
(pObject->GetAddressOfEntityProperties())[0] = (pBufferObject->GetAddressOfEntityProperties())[0];
(pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1];
+#endif
pObject->bHasCollided = false;
CWorld::Add(pObject);
delete[] obuf;
@@ -356,7 +388,7 @@ INITSAVEBUF
if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1)
nNumPeds++;
}
- *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + sizeof(CPlayerPed) +
+ *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + CPlayerPed::nSaveStructSize +
sizeof(CWanted::MaximumWantedLevel) + sizeof(CWanted::nMaximumWantedLevel) + MAX_MODEL_NAME);
WriteSaveBuf(buf, nNumPeds);
for (int i = 0; i < nPoolSize; i++) {
@@ -365,10 +397,14 @@ INITSAVEBUF
continue;
if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) {
WriteSaveBuf(buf, pPed->m_nPedType);
- WriteSaveBuf(buf, pPed->m_modelIndex);
+ WriteSaveBuf(buf, pPed->GetModelIndex());
WriteSaveBuf(buf, GetPedRef(pPed));
+#ifdef COMPATIBLE_SAVES
+ pPed->Save(buf);
+#else
memcpy(buf, pPed, sizeof(CPlayerPed));
SkipSaveBuf(buf, sizeof(CPlayerPed));
+#endif
WriteSaveBuf(buf, CWanted::MaximumWantedLevel);
WriteSaveBuf(buf, CWanted::nMaximumWantedLevel);
memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName(), MAX_MODEL_NAME);
@@ -386,6 +422,34 @@ INITSAVEBUF
uint32 pedtype = ReadSaveBuf<uint32>(buf);
int16 model = ReadSaveBuf<int16>(buf);
int ref = ReadSaveBuf<int>(buf);
+#ifdef COMPATIBLE_SAVES
+ CPed* pPed;
+
+ char name[MAX_MODEL_NAME];
+ // Unfortunate hack: player model is stored after ped structure.
+ // It could be avoided by just using "player" because in practice it is always true.
+ memcpy(name, buf + CPlayerPed::nSaveStructSize + 2 * sizeof(int32), MAX_MODEL_NAME);
+ CStreaming::RequestSpecialModel(model, name, STREAMFLAGS_DONT_REMOVE);
+ CStreaming::LoadAllRequestedModels(false);
+
+ if (pedtype == PEDTYPE_PLAYER1)
+ pPed = new(ref) CPlayerPed();
+ else
+ assert(0);
+
+ pPed->Load(buf);
+ if (pedtype == PEDTYPE_PLAYER1) {
+ CWanted::MaximumWantedLevel = ReadSaveBuf<int32>(buf);
+ CWanted::nMaximumWantedLevel = ReadSaveBuf<int32>(buf);
+ SkipSaveBuf(buf, MAX_MODEL_NAME);
+ }
+
+ if (pedtype == PEDTYPE_PLAYER1) {
+ pPed->m_wepAccuracy = 100;
+ CWorld::Players[0].m_pPed = (CPlayerPed*)pPed;
+ }
+ CWorld::Add(pPed);
+#else
char* pbuf = new char[sizeof(CPlayerPed)];
CPlayerPed* pBufferPlayer = (CPlayerPed*)pbuf;
CPed* pPed;
@@ -416,12 +480,14 @@ INITSAVEBUF
pPed->m_maxWeaponTypeAllowed = pBufferPlayer->m_maxWeaponTypeAllowed;
for (int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++)
pPed->m_weapons[i] = pBufferPlayer->m_weapons[i];
+
if (pedtype == PEDTYPE_PLAYER1) {
pPed->m_wepAccuracy = 100;
CWorld::Players[0].m_pPed = (CPlayerPed*)pPed;
}
CWorld::Add(pPed);
delete[] pbuf;
+#endif
}
VALIDATESAVEBUF(size)
}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 2b3e6f1e..9406f1bd 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -66,9 +66,17 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
&WeaponSprite
};
+// Why this doesn't coincide with world coordinates i don't know
+#define RADAR_MIN_X (-2000.0f)
+#define RADAR_MIN_Y (-2000.0f)
+#define RADAR_MAX_X (2000.0f)
+#define RADAR_MAX_Y (2000.0f)
+#define RADAR_SIZE_X (RADAR_MAX_X - RADAR_MIN_X)
+#define RADAR_SIZE_Y (RADAR_MAX_Y - RADAR_MIN_Y)
+
#define RADAR_NUM_TILES (8)
-#define RADAR_TILE_SIZE (WORLD_SIZE_X / RADAR_NUM_TILES)
-static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
+#define RADAR_TILE_SIZE (RADAR_SIZE_X / RADAR_NUM_TILES)
+static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
#define RADAR_MIN_RANGE (120.0f)
#define RADAR_MAX_RANGE (350.0f)
@@ -523,8 +531,8 @@ void CRadar::DrawBlips()
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = blipEntity->GetPosition();
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = blipEntity->GetPosition();
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -562,8 +570,8 @@ void CRadar::DrawBlips()
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -629,8 +637,8 @@ void CRadar::DrawBlips()
else
#ifdef TRIANGULAR_BLIPS
{
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = blipEntity->GetPosition();
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = blipEntity->GetPosition();
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -678,8 +686,8 @@ void CRadar::DrawBlips()
else
#ifdef TRIANGULAR_BLIPS
{
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -738,8 +746,8 @@ void CRadar::DrawRadarMap()
DrawRadarMask();
// top left ist (0, 0)
- int x = floorf((vec2DRadarOrigin.x - WORLD_MIN_X) / RADAR_TILE_SIZE);
- int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - WORLD_MIN_Y) / RADAR_TILE_SIZE);
+ int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE);
+ int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE);
StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -1064,6 +1072,13 @@ void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
INITSAVEBUF
WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
+#ifdef MENU_MAP
+ if (TargetMarkerId != -1) {
+ ClearBlip(TargetMarkerId);
+ TargetMarkerId = -1;
+ }
+#endif
+
for (int i = 0; i < NUMRADARBLIPS; i++)
WriteSaveBuf(buf, ms_RadarTrace[i]);
@@ -1253,8 +1268,8 @@ void CRadar::StreamRadarSections(int32 x, int32 y)
void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y)
{
- out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X);
- out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + WORLD_MIN_Y));
+ out.x = in.x - (x * RADAR_TILE_SIZE + RADAR_MIN_X);
+ out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + RADAR_MIN_Y));
out.x /= RADAR_TILE_SIZE;
out.y /= RADAR_TILE_SIZE;
}
@@ -1420,9 +1435,9 @@ CRadar::DrawYouAreHereSprite(float x, float y)
if (show) {
float left = x - SCREEN_SCALE_X(12.0f);
- float top = y - SCREEN_SCALE_Y(2.0f);
+ float top = y;
float right = SCREEN_SCALE_X(12.0) + x;
- float bottom = y - SCREEN_SCALE_Y(26.0f);
+ float bottom = y - SCREEN_SCALE_Y(24.0f);
CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255));
}
MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
diff --git a/src/core/Radar.h b/src/core/Radar.h
index e39a17f0..7d07671d 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -71,7 +71,7 @@ struct sRadarTrace
uint16 m_eBlipDisplay; // eBlipDisplay
uint16 m_eRadarSprite; // eRadarSprite
};
-static_assert(sizeof(sRadarTrace) == 0x30, "sRadarTrace: error");
+VALIDATE_SIZE(sRadarTrace, 0x30);
// Values for screen space
#define RADAR_LEFT (40.0f)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index a76e9038..f24192ef 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -114,7 +114,7 @@ CStreamingInfo::RemoveFromList(void)
}
void
-CStreaming::Init(void)
+CStreaming::Init2(void)
{
int i;
@@ -244,6 +244,29 @@ CStreaming::Init(void)
}
void
+CStreaming::Init(void)
+{
+#ifdef USE_TXD_CDIMAGE
+ int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
+ if (txdHandle)
+ CFileMgr::CloseFile(txdHandle);
+ if (!CheckVideoCardCaps() && txdHandle) {
+ CdStreamAddImage("MODELS\\TXD.IMG");
+ CStreaming::Init2();
+ } else {
+ CStreaming::Init2();
+ if (CreateTxdImageForVideoCard()) {
+ CStreaming::Shutdown();
+ CdStreamAddImage("MODELS\\TXD.IMG");
+ CStreaming::Init2();
+ }
+ }
+#else
+ CStreaming::Init();
+#endif
+}
+
+void
CStreaming::Shutdown(void)
{
RwFreeAlign(ms_pStreamingBuffer[0]);
@@ -294,6 +317,7 @@ CStreaming::Update(void)
LoadRequestedModels();
+
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
prev = si->m_prev;
if((si->m_flags & (STREAMFLAGS_KEEP_IN_MEMORY|STREAMFLAGS_PRIORITY)) == 0)
@@ -435,7 +459,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(mi->IsSimple()){
success = CFileLoader::LoadAtomicFile(stream, streamId);
- }else if(mi->m_type == MITYPE_VEHICLE){
+ } else if (mi->GetModelType() == MITYPE_VEHICLE) {
// load vehicles in two parts
CModelInfo::GetModelInfo(streamId)->AddRef();
success = CFileLoader::StartLoadClumpFile(stream, streamId);
@@ -499,7 +523,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(streamId < STREAM_OFFSET_TXD){
// Model
// Vehicles and Peds not in loaded list
- if(mi->m_type != MITYPE_VEHICLE && mi->m_type != MITYPE_PED){
+ if (mi->GetModelType() != MITYPE_VEHICLE && mi->GetModelType() != MITYPE_PED) {
CSimpleModelInfo *smi = (CSimpleModelInfo*)mi;
// Set fading for some objects
@@ -510,12 +534,12 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
smi->m_alpha = 0;
}
- if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
}
}else{
// Txd
- if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
}
@@ -628,7 +652,7 @@ CStreaming::RequestModel(int32 id, int32 flags)
// reinsert into list
if(ms_aInfoForModel[id].m_next){
ms_aInfoForModel[id].RemoveFromList();
- if((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[id].AddToList(&ms_startLoadedList);
}
}else if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_NOTLOADED ||
@@ -689,6 +713,8 @@ CStreaming::RequestSubway(void)
}
}
+#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY
+
void
CStreaming::RequestBigBuildings(eLevelName level)
{
@@ -699,7 +725,7 @@ CStreaming::RequestBigBuildings(eLevelName level)
for(i = n; i >= 0; i--){
b = CPools::GetBuildingPool()->GetSlot(i);
if(b && b->bIsBIGBuilding && b->m_level == level)
- RequestModel(b->GetModelIndex(), STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
}
RequestIslands(level);
ms_hasLoadedLODs = false;
@@ -710,16 +736,16 @@ CStreaming::RequestIslands(eLevelName level)
{
switch(level){
case LEVEL_INDUSTRIAL:
- RequestModel(islandLODcomInd, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODsubInd, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODcomInd, BIGBUILDINGFLAGS);
+ RequestModel(islandLODsubInd, BIGBUILDINGFLAGS);
break;
case LEVEL_COMMERCIAL:
- RequestModel(islandLODindust, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODsubCom, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODindust, BIGBUILDINGFLAGS);
+ RequestModel(islandLODsubCom, BIGBUILDINGFLAGS);
break;
case LEVEL_SUBURBAN:
- RequestModel(islandLODindust, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODcomSub, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODindust, BIGBUILDINGFLAGS);
+ RequestModel(islandLODcomSub, BIGBUILDINGFLAGS);
break;
}
}
@@ -858,7 +884,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -871,7 +897,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -884,7 +910,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered && ((CObject*)e)->ObjectCreatedBy == GAME_OBJECT){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -897,7 +923,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -972,7 +998,7 @@ CStreaming::RemoveBigBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -990,8 +1016,7 @@ CStreaming::RemoveLoadedVehicle(void)
ms_lastVehicleDeleted = 0;
id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 &&
- (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 &&
- CModelInfo::GetModelInfo(id)->m_refCount == 0 &&
+ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0 &&
ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED)
goto found;
}
@@ -1012,7 +1037,7 @@ CStreaming::RemoveLeastUsedModel(void)
for(si = ms_endLoadedList.m_prev; si != &ms_startLoadedList; si = si->m_prev){
streamId = si - ms_aInfoForModel;
if(streamId < STREAM_OFFSET_TXD){
- if(CModelInfo::GetModelInfo(streamId)->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(streamId)->GetNumRefs() == 0) {
RemoveModel(streamId);
return true;
}
@@ -1038,7 +1063,7 @@ CStreaming::RemoveAllUnusedModels(void)
for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED &&
ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE &&
- CModelInfo::GetModelInfo(i)->m_refCount == 0){
+ CModelInfo::GetModelInfo(i)->GetNumRefs() == 0) {
RemoveModel(i);
ms_aInfoForModel[i].m_loadState = STREAMSTATE_NOTLOADED;
}
@@ -1129,8 +1154,7 @@ CStreaming::AddToLoadedVehiclesList(int32 modelId)
for(i = 0; i < MAXVEHICLESLOADED; i++){
id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 &&
- (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 &&
- CModelInfo::GetModelInfo(id)->m_refCount == 0)
+ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0)
goto found;
ms_lastVehicleDeleted++;
if(ms_lastVehicleDeleted == MAXVEHICLESLOADED)
@@ -1202,7 +1226,7 @@ void
CStreaming::SetModelIsDeletable(int32 id)
{
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_DONT_REMOVE;
- if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) &&
+ if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id);
@@ -1221,7 +1245,7 @@ void
CStreaming::SetMissionDoesntRequireModel(int32 id)
{
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_SCRIPTOWNED;
- if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) &&
+ if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_DONT_REMOVE) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id);
@@ -1307,7 +1331,7 @@ CStreaming::StreamVehiclesAndPeds(void)
for(i = 1; i <= 10; i++){
model = CCarCtrl::ChooseCarModel(modelQualityClass);
modelQualityClass++;
- if(modelQualityClass >= NUM_VEHICLE_CLASSES)
+ if(modelQualityClass >= CCarCtrl::TOTAL_CUSTOM_CLASSES)
modelQualityClass = 0;
// check if we want to load this model
@@ -1336,7 +1360,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
// unload pevious group
if(ms_currentPedGrp != -1)
- for(i = 0; i < 8; i++){
+ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break;
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
@@ -1345,7 +1369,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
ms_currentPedGrp = info.pedGroup;
- for(i = 0; i < 8; i++){
+ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break;
RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE);
@@ -1431,7 +1455,6 @@ CStreaming::RemoveCurrentZonesModels(void)
}
-
// Find starting offset of the cdimage we next want to read
// Not useful at all on PC...
int32
@@ -1470,12 +1493,14 @@ CStreaming::GetCdImageOffset(int32 lastPosn)
}
inline bool
-TxdAvailable(int32 txdId)
+ModelNotLoaded(int32 modelId)
{
- CStreamingInfo *si = &CStreaming::ms_aInfoForModel[txdId + STREAM_OFFSET_TXD];
- return si->m_loadState == STREAMSTATE_LOADED || si->m_loadState == STREAMSTATE_READING;
+ CStreamingInfo *si = &CStreaming::ms_aInfoForModel[modelId];
+ return si->m_loadState != STREAMSTATE_LOADED && si->m_loadState != STREAMSTATE_READING;
}
+inline bool TxdNotLoaded(int32 txdId) { return ModelNotLoaded(txdId + STREAM_OFFSET_TXD); }
+
// Find stream id of next requested file in cdimage
int32
CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
@@ -1500,10 +1525,15 @@ CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
continue;
// request Txd if necessary
- if(streamId < STREAM_OFFSET_TXD &&
- !TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot())){
- ReRequestTxd(CModelInfo::GetModelInfo(streamId)->GetTxdSlot());
- }else if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){
+ if(streamId < STREAM_OFFSET_TXD){
+ int txdId = CModelInfo::GetModelInfo(streamId)->GetTxdSlot();
+ if(TxdNotLoaded(txdId)){
+ ReRequestTxd(txdId);
+ continue;
+ }
+ }
+
+ if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){
if(posn < posnFirst){
// find first requested file in image
streamIdFirst = streamId;
@@ -1599,9 +1629,9 @@ CStreaming::RequestModelStream(int32 ch)
// Can't load certain combinations of files together
if(streamId < STREAM_OFFSET_TXD){
- if(havePed && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED ||
- haveBigFile && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE ||
- !TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot()))
+ if (havePed && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED ||
+ haveBigFile && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE ||
+ TxdNotLoaded(CModelInfo::GetModelInfo(streamId)->GetTxdSlot()))
break;
}else{
if(haveBigFile && size > 200)
@@ -1619,9 +1649,9 @@ CStreaming::RequestModelStream(int32 ch)
break;
}
if(streamId < STREAM_OFFSET_TXD){
- if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED)
+ if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED)
havePed = 1;
- if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE)
+ if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE)
haveBigFile = 1;
}else{
if(size > 200)
@@ -1679,14 +1709,13 @@ CStreaming::ProcessLoadingChannel(int32 ch)
continue;
cdsize = ms_aInfoForModel[id].GetCdSize();
- if(id < STREAM_OFFSET_TXD &&
- CModelInfo::GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
+ if(id < STREAM_OFFSET_TXD && CModelInfo::GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
ms_numVehiclesLoaded >= desiredNumVehiclesLoaded &&
!RemoveLoadedVehicle() &&
- ((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 || GetAvailableVehicleSlot() == -1)){
+ ((ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 || GetAvailableVehicleSlot() == -1)){
// can't load vehicle
RemoveModel(id);
- if(ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST)
+ if(ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE)
ReRequestModel(id);
else if(CTxdStore::GetNumRefs(CModelInfo::GetModelInfo(id)->GetTxdSlot()) == 0)
RemoveTxd(CModelInfo::GetModelInfo(id)->GetTxdSlot());
@@ -1953,7 +1982,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
- if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){
+ if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) {
lodDistSq = sq(mi->GetLargestLodDistance());
lodDistSq = Min(lodDistSq, sq(STREAM_DIST));
pos = CVector2D(e->GetPosition());
@@ -1983,7 +2012,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list)
if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
- if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
+ if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
if(CRenderer::IsEntityCullZoneVisible(e))
RequestModel(e->GetModelIndex(), 0);
}
@@ -2349,7 +2378,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject();
- if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem)
return true;
@@ -2370,7 +2399,7 @@ CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && !e->IsVisible() && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject();
- if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem)
return true;
@@ -2400,7 +2429,7 @@ CStreaming::LoadScene(const CVector &pos)
CStreamingInfo *si, *prev;
eLevelName level;
- level = CTheZones::GetLevelFromPosition(pos);
+ level = CTheZones::GetLevelFromPosition(&pos);
debug("Start load scene\n");
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
prev = si->m_prev;
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index cf8790e9..84434769 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -3,8 +3,7 @@
#include "Game.h"
enum {
- STREAM_OFFSET_MODEL = 0,
- STREAM_OFFSET_TXD = STREAM_OFFSET_MODEL+MODELINFOSIZE,
+ STREAM_OFFSET_TXD = MODELINFOSIZE,
NUMSTREAMINFO = STREAM_OFFSET_TXD+TXDSTORESIZE
};
@@ -16,8 +15,7 @@ enum StreamFlags
STREAMFLAGS_PRIORITY = 0x08,
STREAMFLAGS_NOFADE = 0x10,
- // TODO: this isn't named well, maybe CANT_REMOVE?
- STREAMFLAGS_NOT_IN_LIST = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED,
+ STREAMFLAGS_CANT_REMOVE = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED,
STREAMFLAGS_KEEP_IN_MEMORY = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED|STREAMFLAGS_DEPENDENCY,
};
@@ -108,6 +106,7 @@ public:
static uint32 ms_memoryAvailable;
static void Init(void);
+ static void Init2(void);
static void Shutdown(void);
static void Update(void);
static void LoadCdDirectory(void);
@@ -115,6 +114,9 @@ public:
static bool ConvertBufferToObject(int8 *buf, int32 streamId);
static bool FinishLoadingLargeFile(int8 *buf, int32 streamId);
static bool HasModelLoaded(int32 id) { return ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED; }
+ static bool HasTxdLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_TXD); }
+ static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; }
+ static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); }
static void RequestModel(int32 model, int32 flags);
static void ReRequestModel(int32 model) { RequestModel(model, ms_aInfoForModel[model].m_flags); }
static void RequestTxd(int32 txd, int32 flags) { RequestModel(txd + STREAM_OFFSET_TXD, flags); }
diff --git a/src/core/Timer.h b/src/core/Timer.h
index 00a11409..004cda4d 100644
--- a/src/core/Timer.h
+++ b/src/core/Timer.h
@@ -56,6 +56,11 @@ public:
friend bool GenericLoad(void);
friend bool GenericSave(int file);
+
+#ifdef FIX_BUGS
+ static float GetDefaultTimeStep(void) { return 5.0f / 3.0f; }
+ static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
+#endif
};
#ifdef FIX_BUGS
diff --git a/src/core/User.cpp b/src/core/User.cpp
index 50eb7d9d..f906ae44 100644
--- a/src/core/User.cpp
+++ b/src/core/User.cpp
@@ -32,15 +32,15 @@ void
CPlaceName::Process()
{
CVector pos = CWorld::Players[CWorld::PlayerInFocus].GetPos();
- CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_TYPE1);
- CZone *audioZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_AUDIO);
+ CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_NAVIG);
+ CZone *defaultZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_DEFAULT);
if (navigZone == nil) m_pZone = nil;
- if (audioZone == nil) m_pZone2 = nil;
+ if (defaultZone == nil) m_pZone2 = nil;
if (navigZone == m_pZone) {
- if (audioZone == m_pZone2 || m_pZone != nil) {
- if (navigZone != nil || audioZone != nil) {
+ if (defaultZone == m_pZone2 || m_pZone != nil) {
+ if (navigZone != nil || defaultZone != nil) {
if (m_nAdditionalTimer != 0)
m_nAdditionalTimer--;
} else {
@@ -49,7 +49,7 @@ CPlaceName::Process()
m_pZone2 = nil;
}
} else {
- m_pZone2 = audioZone;
+ m_pZone2 = defaultZone;
m_nAdditionalTimer = 250;
}
} else {
diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp
index 6f5fdf06..7508c9f4 100644
--- a/src/core/Wanted.cpp
+++ b/src/core/Wanted.cpp
@@ -352,7 +352,7 @@ CWanted::WorkOutPolicePresence(CVector posn, float radius)
vehicle->bIsLawEnforcer &&
IsPoliceVehicleModel(vehicle->GetModelIndex()) &&
vehicle != FindPlayerVehicle() &&
- vehicle->m_status != STATUS_ABANDONED && vehicle->m_status != STATUS_WRECKED &&
+ vehicle->GetStatus() != STATUS_ABANDONED && vehicle->GetStatus() != STATUS_WRECKED &&
(posn - vehicle->GetPosition()).Magnitude() < radius)
numPolice++;
}
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index e3e407b0..de36c442 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -54,4 +54,4 @@ public:
static void SetMaximumWantedLevel(int32 level);
};
-static_assert(sizeof(CWanted) == 0x204, "CWanted: error");
+VALIDATE_SIZE(CWanted, 0x204);
diff --git a/src/core/World.cpp b/src/core/World.cpp
index b2a01b80..c884f1ed 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1,4 +1,4 @@
-#include "World.h"
+#include "common.h"
#include "Camera.h"
#include "CarCtrl.h"
#include "CopPed.h"
@@ -26,7 +26,7 @@
#include "TempColModels.h"
#include "Vehicle.h"
#include "WaterLevel.h"
-#include "common.h"
+#include "World.h"
#define OBJECT_REPOSITION_OFFSET_Z 2.0f
@@ -75,7 +75,7 @@ CWorld::Add(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return;
- if(!ent->bIsStatic) ((CPhysical *)ent)->AddToMovingList();
+ if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList();
}
void
@@ -90,7 +90,7 @@ CWorld::Remove(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return;
- if(!ent->bIsStatic) ((CPhysical *)ent)->RemoveFromMovingList();
+ if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList();
}
void
@@ -382,7 +382,7 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
{
AdvanceCurrentScanCode();
CVector point2(point1.x, point1.y, z2);
- return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexX(point1.y)),
+ return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexY(point1.y)),
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
}
@@ -659,7 +659,7 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo
}
void
-CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector &centre, float radius, bool ignoreZ, short *nextObject,
+CWorld::FindObjectsInRangeSectorList(CPtrList &list, Const CVector &centre, float radius, bool ignoreZ, short *nextObject,
short lastObject, CEntity **objects)
{
float radiusSqr = radius * radius;
@@ -685,7 +685,7 @@ CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector &centre, float radi
}
void
-CWorld::FindObjectsInRange(CVector &centre, float radius, bool ignoreZ, short *nextObject, short lastObject,
+CWorld::FindObjectsInRange(Const CVector &centre, float radius, bool ignoreZ, short *nextObject, short lastObject,
CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds,
bool checkObjects, bool checkDummies)
{
@@ -758,7 +758,7 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList &list, const
CEntity *pEntity = (CEntity *)pNode->item;
if(pEntity->m_scanCode != GetCurrentScanCode()) {
pEntity->m_scanCode = GetCurrentScanCode();
- if(modelId == pEntity->m_modelIndex) {
+ if (modelId == pEntity->GetModelIndex()) {
float fMagnitude = 0.0f;
if(bCheck2DOnly)
fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D();
@@ -953,14 +953,13 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad
float distance = diff.Magnitude();
if(e->GetBoundRadius() + radius > distance) {
- CColModel *eCol = CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel();
+ CColModel *eCol = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
int collidedSpheres =
CCollision::ProcessColModels(sphereMat, sphereCol, e->GetMatrix(), *eCol,
gaTempSphereColPoints, nil, nil);
if(collidedSpheres != 0 ||
- (e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR &&
- e->m_modelIndex != MI_DODO &&
+ (e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR && e->GetModelIndex() != MI_DODO &&
radius + eCol->boundingBox.max.x > distance)) {
return e;
}
@@ -1417,7 +1416,7 @@ FindPlayerSpeed(void)
return ped->m_vecMoveSpeed;
}
-CVector &
+const CVector &
FindPlayerCentreOfWorld(int32 player)
{
#ifdef FIX_BUGS
@@ -1429,7 +1428,7 @@ FindPlayerCentreOfWorld(int32 player)
return CWorld::Players[player].m_pPed->GetPosition();
}
-CVector &
+const CVector &
FindPlayerCentreOfWorld_NoSniperShift(void)
{
#ifdef FIX_BUGS
@@ -1618,7 +1617,7 @@ CWorld::RemoveFallenPeds(void)
if(ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) {
int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED,
999999.9f, false, false);
- CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
+ CVector newPos = ThePaths.m_pathNodes[closestNode].GetPosition();
newPos.z += 2.0f;
ped->Teleport(newPos);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
@@ -1642,7 +1641,7 @@ CWorld::RemoveFallenCars(void)
(veh->pDriver && veh->pDriver->IsPlayer())) {
int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR,
999999.9f, false, false);
- CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
+ CVector newPos = ThePaths.m_pathNodes[closestNode].GetPosition();
newPos.z += 3.0f;
veh->Teleport(newPos);
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
@@ -1823,13 +1822,8 @@ CWorld::RepositionCertainDynamicObjects()
void
CWorld::RepositionOneObject(CEntity *pEntity)
{
- int16 modelId = pEntity->m_modelIndex;
- if(modelId == MI_SINGLESTREETLIGHTS1 || modelId == MI_SINGLESTREETLIGHTS2 ||
- modelId == MI_SINGLESTREETLIGHTS3 || modelId == MI_DOUBLESTREETLIGHTS || modelId == MI_TREE1 ||
- modelId == MI_TREE2 || modelId == MI_TREE3 || modelId == MI_TREE4 || modelId == MI_TREE5 ||
- modelId == MI_TREE6 || modelId == MI_TREE7 || modelId == MI_TREE8 || modelId == MI_TREE9 ||
- modelId == MI_TREE10 || modelId == MI_TREE11 || modelId == MI_TREE12 || modelId == MI_TREE13 ||
- modelId == MI_TREE14 || modelId == MI_TRAFFICLIGHTS || modelId == MI_PARKINGMETER ||
+ int16 modelId = pEntity->GetModelIndex();
+ if (IsTrafficLight(modelId) || IsTreeModel(modelId) || modelId == MI_PARKINGMETER ||
modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 ||
modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 ||
modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 ||
@@ -1837,7 +1831,7 @@ CWorld::RepositionOneObject(CEntity *pEntity)
modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 ||
modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT ||
modelId == MI_PARKTABLE) {
- CVector &position = pEntity->GetPosition();
+ CVector &position = pEntity->GetMatrix().GetPosition();
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z;
position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y,
position.z + OBJECT_REPOSITION_OFFSET_Z, nil) -
@@ -1855,7 +1849,7 @@ CWorld::RepositionOneObject(CEntity *pEntity)
if(!bFound || fWaterLevel > fGroundZ) {
CColModel *pColModel = pEntity->GetColModel();
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
- pEntity->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
+ pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
}
}
}
@@ -1867,7 +1861,7 @@ CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason)
int poolSize = CPools::GetVehiclePool()->GetSize();
for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
- if(veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
+ if(veh && veh->GetStatus() != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
if(Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius &&
Abs(veh->GetPosition().y - y) < radius)
gFireManager.StartFire(veh, reason, 0.8f, true);
@@ -1928,7 +1922,7 @@ CWorld::Process(void)
if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) {
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(),
- 0.02f * (csObj->m_type == ENTITY_TYPE_OBJECT
+ 0.02f * (csObj->IsObject()
? CTimer::GetTimeStepNonClipped()
: CTimer::GetTimeStep()));
}
@@ -1946,7 +1940,7 @@ CWorld::Process(void)
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),
- 0.02f * (movingEnt->m_type == ENTITY_TYPE_OBJECT
+ 0.02f * (movingEnt->IsObject()
? CTimer::GetTimeStepNonClipped()
: CTimer::GetTimeStep()));
}
@@ -1957,7 +1951,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
- if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); }
+ if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
}
}
bForceProcessControl = true;
@@ -1968,7 +1962,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
- if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); }
+ if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
}
}
}
@@ -2030,9 +2024,8 @@ CWorld::Process(void)
movingEnt->UpdateRwFrame();
if(!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
- if(movingEnt->m_status == STATUS_PLAYER) {
- printf("STUCK: Final Step: Player Entity %d Is Stuck\n",
- movingEnt->m_modelIndex);
+ if(movingEnt->GetStatus() == STATUS_PLAYER) {
+ printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->GetModelIndex());
movingEnt->m_vecMoveSpeed *= 0.3f;
movingEnt->ApplyMoveSpeed();
movingEnt->ApplyTurnSpeed();
@@ -2122,15 +2115,15 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
CObject *pObject = (CObject *)pEntity;
CVehicle *pVehicle = (CVehicle *)pEntity;
if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) {
- if(pEntity->bIsStatic) {
+ if(pEntity->IsStatic()) {
if(pEntity->IsObject()) {
- if(fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) {
- if(IsGlass(pObject->m_modelIndex)) {
+ if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) {
+ if (IsGlass(pObject->GetModelIndex())) {
CGlass::WindowRespondsToExplosion(pObject, position);
} else {
pObject->bIsStatic = false;
pObject->AddToMovingList();
- int16 modelId = pEntity->m_modelIndex;
+ int16 modelId = pEntity->GetModelIndex();
if(modelId != MI_FIRE_HYDRANT ||
pObject->bHasBeenDamaged) {
if(pEntity->IsObject() &&
@@ -2146,7 +2139,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
}
}
}
- if(pEntity->bIsStatic) {
+ if(pEntity->IsStatic()) {
float fDamageMultiplier =
(fRadius - fMagnitude) * 2.0f / fRadius;
float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f);
@@ -2157,7 +2150,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
pEntity->AddToMovingList();
}
}
- if(!pEntity->bIsStatic) {
+ if(!pEntity->IsStatic()) {
float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
CVector vecForceDir =
vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier /
@@ -2178,10 +2171,10 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
pEntity->ApplyTurnForce(vecForceDir.x, vecForceDir.y, vecForceDir.z,
0.0f, 0.0f, fPointZ);
}
- switch(pEntity->m_type) {
+ switch(pEntity->GetType()) {
case ENTITY_TYPE_VEHICLE:
- if(pEntity->m_status == STATUS_SIMPLE) {
- pEntity->m_status = STATUS_PHYSICS;
+ if(pEntity->GetStatus() == STATUS_SIMPLE) {
+ pEntity->SetStatus(STATUS_PHYSICS);
CCarCtrl::SwitchVehicleToRealPhysics(pVehicle);
}
pVehicle->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION,
diff --git a/src/core/World.h b/src/core/World.h
index 25c76531..2bcc4e43 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -45,7 +45,8 @@ class CSector
public:
CPtrList m_lists[NUMSECTORENTITYLISTS];
};
-static_assert(sizeof(CSector) == 0x28, "CSector: error");
+
+VALIDATE_SIZE(CSector, 0x28);
class CEntity;
struct CColPoint;
@@ -101,8 +102,8 @@ public:
static CEntity *TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects);
static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool);
- static void FindObjectsInRangeSectorList(CPtrList&, CVector&, float, bool, short*, short, CEntity**);
- static void FindObjectsInRange(CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
+ static void FindObjectsInRangeSectorList(CPtrList&, Const CVector&, float, bool, short*, short, CEntity**);
+ static void FindObjectsInRange(Const CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
static void FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities);
static void FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies);
static float FindGroundZForCoord(float x, float y);
@@ -164,6 +165,6 @@ CVehicle *FindPlayerTrain(void);
CEntity *FindPlayerEntity(void);
CVector FindPlayerCoors(void);
CVector &FindPlayerSpeed(void);
-CVector &FindPlayerCentreOfWorld(int32 player);
-CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
+const CVector &FindPlayerCentreOfWorld(int32 player);
+const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
float FindPlayerHeading(void);
diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp
index 7a221f39..6dcd0f18 100644
--- a/src/core/ZoneCull.cpp
+++ b/src/core/ZoneCull.cpp
@@ -34,13 +34,13 @@ CCullZones::Init(void)
int i;
NumAttributeZones = 0;
- NumCullZones = 0;
CurrentWantedLevelDrop_Player = 0;
CurrentFlags_Camera = 0;
CurrentFlags_Player = 0;
+ bCurrentSubwayIsInvisible = false;
+ NumCullZones = 0;
OldCullZone = -1;
EntityIndicesUsed = 0;
- bCurrentSubwayIsInvisible = false;
for(i = 0; i < NUMBUILDINGS; i++)
aPointersToBigBuildingsForBuildings[i] = -1;
@@ -386,7 +386,6 @@ CCullZones::AddCullZone(CVector const &position,
}
-
void
CCullZone::DoStuffLeavingZone(void)
{
@@ -522,7 +521,7 @@ CCullZone::CalcDistToCullZoneSquared(float x, float y)
bool
CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
{
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(entity->GetModelIndex());
float distToZone = CalcDistToCullZone(pos.x, pos.y);
@@ -534,7 +533,7 @@ CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
if (lodDist > distToZone) return true;
if (!checkLevel) return false;
- return CTheZones::GetLevelFromPosition(pos) == CTheZones::GetLevelFromPosition(CVector(minx, miny, minz));
+ return CTheZones::GetLevelFromPosition(&pos) == CTheZones::GetLevelFromPosition(&CVector(minx, miny, minz));
}
bool
@@ -561,4 +560,4 @@ CCullZones::DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set)
}
}
return false;
-}
+} \ No newline at end of file
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 804708b4..22c0735a 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -23,6 +23,8 @@ CZoneInfo CTheZones::ZoneInfoArray[2*NUMZONES];
#define SWAPF(a, b) { float t; t = a; a = b; b = t; }
+inline bool IsNormalZone(int type) { return type == ZONE_DEFAULT || type == ZONE_NAVIG || type == ZONE_INFO; }
+
static void
CheckZoneInfo(CZoneInfo *info)
{
@@ -58,6 +60,9 @@ CTheZones::Init(void)
AudioZoneArray[i] = -1;
NumberOfAudioZones = 0;
+ for(i = 0; i < NUMZONES; i++)
+ memset(&ZoneArray[i], 0, sizeof(CZone));
+
CZoneInfo *zonei;
int x = 1000/6;
for(i = 0; i < 2*NUMZONES; i++){
@@ -81,10 +86,13 @@ CTheZones::Init(void)
zonei->gangThreshold[8] = zonei->gangThreshold[7];
CheckZoneInfo(zonei);
}
+
TotalNumberOfZoneInfos = 1; // why 1?
+ TotalNumberOfZones = 1;
+
+ m_CurrLevel = LEVEL_NONE;
+ m_pPlayersZone = &ZoneArray[0];
- for(i = 0; i < NUMZONES; i++)
- memset(&ZoneArray[i], 0, sizeof(CZone));
strcpy(ZoneArray[0].name, "CITYZON");
ZoneArray[0].minx = -4000.0f;
ZoneArray[0].miny = -4000.0f;
@@ -93,15 +101,14 @@ CTheZones::Init(void)
ZoneArray[0].maxy = 4000.0f;
ZoneArray[0].maxz = 500.0f;
ZoneArray[0].level = LEVEL_NONE;
- TotalNumberOfZones = 1;
-
- m_CurrLevel = LEVEL_NONE;
- m_pPlayersZone = &ZoneArray[0];
for(i = 0; i < NUMMAPZONES; i++){
memset(&MapZoneArray[i], 0, sizeof(CZone));
MapZoneArray[i].type = ZONE_MAPZONE;
}
+
+ TotalNumberOfMapZones = 1;
+
strcpy(MapZoneArray[0].name, "THEMAP");
MapZoneArray[0].minx = -4000.0f;
MapZoneArray[0].miny = -4000.0f;
@@ -110,7 +117,6 @@ CTheZones::Init(void)
MapZoneArray[0].maxy = 4000.0f;
MapZoneArray[0].maxz = 500.0f;
MapZoneArray[0].level = LEVEL_NONE;
- TotalNumberOfMapZones = 1;
}
void
@@ -119,7 +125,7 @@ CTheZones::Update(void)
CVector pos;
pos = FindPlayerCoors();
m_pPlayersZone = FindSmallestZonePosition(&pos);
- m_CurrLevel = GetLevelFromPosition(pos);
+ m_CurrLevel = GetLevelFromPosition(&pos);
}
void
@@ -128,8 +134,8 @@ CTheZones::CreateZone(char *name, eZoneType type,
float maxx, float maxy, float maxz,
eLevelName level)
{
- CZone *zone;
char *p;
+ char tmpname[8];
if(minx > maxx) SWAPF(minx, maxx);
if(miny > maxy) SWAPF(miny, maxy);
@@ -139,21 +145,22 @@ CTheZones::CreateZone(char *name, eZoneType type,
for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p);
// add zone
- zone = &ZoneArray[TotalNumberOfZones++];
- strncpy(zone->name, name, 7);
- zone->name[7] = '\0';
- zone->type = type;
- zone->minx = minx;
- zone->miny = miny;
- zone->minz = minz;
- zone->maxx = maxx;
- zone->maxy = maxy;
- zone->maxz = maxz;
- zone->level = level;
- if(type == ZONE_AUDIO || type == ZONE_TYPE1 || type == ZONE_TYPE2){
- zone->zoneinfoDay = TotalNumberOfZoneInfos++;
- zone->zoneinfoNight = TotalNumberOfZoneInfos++;
+ strncpy(tmpname, name, 7);
+ tmpname[7] = '\0';
+ strcpy(ZoneArray[TotalNumberOfZones].name, tmpname);
+ ZoneArray[TotalNumberOfZones].type = type;
+ ZoneArray[TotalNumberOfZones].minx = minx;
+ ZoneArray[TotalNumberOfZones].miny = miny;
+ ZoneArray[TotalNumberOfZones].minz = minz;
+ ZoneArray[TotalNumberOfZones].maxx = maxx;
+ ZoneArray[TotalNumberOfZones].maxy = maxy;
+ ZoneArray[TotalNumberOfZones].maxz = maxz;
+ ZoneArray[TotalNumberOfZones].level = level;
+ if(IsNormalZone(type)){
+ ZoneArray[TotalNumberOfZones].zoneinfoDay = TotalNumberOfZoneInfos++;
+ ZoneArray[TotalNumberOfZones].zoneinfoNight = TotalNumberOfZoneInfos++;
}
+ TotalNumberOfZones++;
}
void
@@ -259,11 +266,11 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
inner->minz < outer->minz ||
inner->maxz > outer->maxz){
CVector vmin(inner->minx, inner->miny, inner->minz);
- if(PointLiesWithinZone(vmin, outer))
+ if(PointLiesWithinZone(&vmin, outer))
sprintf(tmp, "Overlapping zones %s and %s\n",
inner->name, outer->name);
CVector vmax(inner->maxx, inner->maxy, inner->maxz);
- if(PointLiesWithinZone(vmax, outer))
+ if(PointLiesWithinZone(&vmax, outer))
sprintf(tmp, "Overlapping zones %s and %s\n",
inner->name, outer->name);
return false;
@@ -272,15 +279,15 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
}
bool
-CTheZones::PointLiesWithinZone(const CVector &v, CZone *zone)
+CTheZones::PointLiesWithinZone(const CVector *v, CZone *zone)
{
- return zone->minx <= v.x && v.x <= zone->maxx &&
- zone->miny <= v.y && v.y <= zone->maxy &&
- zone->minz <= v.z && v.z <= zone->maxz;
+ return zone->minx <= v->x && v->x <= zone->maxx &&
+ zone->miny <= v->y && v->y <= zone->maxy &&
+ zone->minz <= v->z && v->z <= zone->maxz;
}
eLevelName
-CTheZones::GetLevelFromPosition(CVector const &v)
+CTheZones::GetLevelFromPosition(CVector const *v)
{
int i;
// char tmp[116];
@@ -300,7 +307,7 @@ CTheZones::FindSmallestZonePosition(const CVector *v)
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
+ if(PointLiesWithinZone(v, zone)){
best = zone;
zone = zone->child;
// otherwise try next zone
@@ -319,7 +326,7 @@ CTheZones::FindSmallestZonePositionType(const CVector *v, eZoneType type)
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
+ if(PointLiesWithinZone(v, zone)){
if(zone->type == type)
best = zone;
zone = zone->child;
@@ -333,18 +340,14 @@ CZone*
CTheZones::FindSmallestZonePositionILN(const CVector *v)
{
CZone *best = nil;
- if(ZoneArray[0].type == ZONE_AUDIO ||
- ZoneArray[0].type == ZONE_TYPE1 ||
- ZoneArray[0].type == ZONE_TYPE2)
+ if(IsNormalZone(ZoneArray[0].type))
best = &ZoneArray[0];
// zone to test next
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
- if(zone->type == ZONE_AUDIO ||
- zone->type == ZONE_TYPE1 ||
- zone->type == ZONE_TYPE2)
+ if(PointLiesWithinZone(v, zone)){
+ if(IsNormalZone(zone->type))
best = zone;
zone = zone->child;
// otherwise try next zone
@@ -532,7 +535,7 @@ CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity;
}
@@ -541,7 +544,7 @@ CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity;
}
@@ -550,7 +553,7 @@ CTheZones::SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup;
}
@@ -560,7 +563,7 @@ CTheZones::FindAudioZone(CVector *pos)
int i;
for(i = 0; i < NumberOfAudioZones; i++)
- if(PointLiesWithinZone(*pos, GetZone(AudioZoneArray[i])))
+ if(PointLiesWithinZone(pos, GetAudioZone(i)))
return i;
return -1;
}
@@ -568,11 +571,11 @@ CTheZones::FindAudioZone(CVector *pos)
eLevelName
CTheZones::FindZoneForPoint(const CVector &pos)
{
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
return LEVEL_INDUSTRIAL;
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
return LEVEL_COMMERCIAL;
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
return LEVEL_SUBURBAN;
return LEVEL_NONE;
}
@@ -582,7 +585,7 @@ CTheZones::AddZoneToAudioZoneArray(CZone *zone)
{
int i, z;
- if(zone->type != ZONE_AUDIO)
+ if(zone->type != ZONE_DEFAULT)
return;
/* This is a bit stupid */
diff --git a/src/core/Zones.h b/src/core/Zones.h
index bb1585dc..67800569 100644
--- a/src/core/Zones.h
+++ b/src/core/Zones.h
@@ -5,9 +5,9 @@
enum eZoneType
{
- ZONE_AUDIO,
- ZONE_TYPE1, // this should be NAVIG
- ZONE_TYPE2, // this should be INFO...but all except MAPINFO get zoneinfo??
+ ZONE_DEFAULT,
+ ZONE_NAVIG,
+ ZONE_INFO,
ZONE_MAPZONE,
};
@@ -51,8 +51,6 @@ public:
class CTheZones
{
-public:
- static eLevelName m_CurrLevel;
static CZone *m_pPlayersZone;
static int16 FindIndex;
@@ -64,6 +62,8 @@ public:
static CZone MapZoneArray[NUMMAPZONES];
static uint16 TotalNumberOfZoneInfos;
static CZoneInfo ZoneInfoArray[2*NUMZONES];
+public:
+ static eLevelName m_CurrLevel;
static void Init(void);
static void Update(void);
@@ -76,12 +76,13 @@ public:
float maxx, float maxy, float maxz,
eLevelName level);
static CZone *GetZone(uint16 i) { return &ZoneArray[i]; }
+ static CZone *GetAudioZone(uint16 i) { return &ZoneArray[AudioZoneArray[i]]; }
static void PostZoneCreation(void);
static void InsertZoneIntoZoneHierarchy(CZone *zone);
static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
- static bool PointLiesWithinZone(const CVector &v, CZone *zone);
- static eLevelName GetLevelFromPosition(CVector const &v);
+ static bool PointLiesWithinZone(const CVector *v, CZone *zone);
+ static eLevelName GetLevelFromPosition(const CVector *v);
static CZone *FindSmallestZonePosition(const CVector *v);
static CZone *FindSmallestZonePositionType(const CVector *v, eZoneType type);
static CZone *FindSmallestZonePositionILN(const CVector *v);
diff --git a/src/core/common.h b/src/core/common.h
index 66a3ad81..f79b199b 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -58,6 +58,9 @@
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
+// Use this to add const that wasn't there in the original code
+#define Const const
+
typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
@@ -225,7 +228,11 @@ void re3_usererror(const char *format, ...);
#define _TODO(x)
#define _TODOCONST(x) (x)
+#ifdef CHECK_STRUCT_SIZES
#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc)
+#else
+#define VALIDATE_SIZE(struc, size)
+#endif
#define VALIDATE_OFFSET(struc, member, offset) static_assert(offsetof(struc, member) == offset, "The offset of " #member " in " #struc " is not " #offset "...")
#define PERCENT(x, p) ((float(x) * (float(p) / 100.0f)))
diff --git a/src/core/config.h b/src/core/config.h
index 6896a7ba..ae30b539 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -38,6 +38,9 @@ enum Config {
NUMAUDIOSCRIPTOBJECTS = 256,
NUMCUTSCENEOBJECTS = 50,
+ NUMANIMBLOCKS = 2,
+ NUMANIMATIONS = 250,
+
NUMTEMPOBJECTS = 30,
// Path data
@@ -184,6 +187,7 @@ enum Config {
# define NO_MOVIES // disable intro videos
# define NO_CDCHECK
# define CHATTYSPLASH // print what the game is loading
+# define DEBUGMENU
//# define TIMEBARS // print debug timers
#endif
@@ -192,6 +196,7 @@ enum Config {
#define MORE_LANGUAGES // Add more translations to the game
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
#define USE_TXD_CDIMAGE // generate and load textures from txd.img
+#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
//#define USE_TEXTURE_POOL
//#define AUDIO_OAL
#define AUDIO_MSS
@@ -204,6 +209,7 @@ enum Config {
#ifndef RW_GL3
#define XINPUT
#endif
+#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
#define KANGAROO_CHEAT
#define ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT
@@ -226,6 +232,8 @@ enum Config {
#define USE_MEASUREMENTS_IN_METERS // makes game use meters instead of feet in script
#define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely
+#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
+
// Replay
//#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool!
//#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!)
diff --git a/src/core/main.cpp b/src/core/main.cpp
index ec37fa28..37a5673f 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -91,7 +91,9 @@ void GameInit(void);
void SystemInit(void);
void TheGame(void);
+#ifdef DEBUGMENU
void DebugMenuPopulate(void);
+#endif
void
@@ -328,11 +330,10 @@ Initialise3D(void *param)
{
if (RsRwInitialise(param))
{
- //
+#ifdef DEBUGMENU
DebugMenuInit();
DebugMenuPopulate();
- //
-
+#endif // !DEBUGMENU
return CGame::InitialiseRenderWare();
}
@@ -343,8 +344,9 @@ static void
Terminate3D(void)
{
CGame::ShutdownRenderWare();
-
+#ifdef DEBUGMENU
DebugMenuShutdown();
+#endif // !DEBUGMENU
RsRwTerminate();
@@ -878,7 +880,9 @@ Render2dStuff(void)
CPad::PrintErrorMessage();
CFont::DrawFonts();
+#ifdef DEBUGMENU
DebugMenuRender();
+#endif
}
void
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index b7eb6480..0ab32999 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -26,6 +26,7 @@
#include "PlayerPed.h"
#include "Radar.h"
#include "debugmenu.h"
+#include "Frontend.h"
#include <list>
@@ -60,6 +61,7 @@ mysrand(unsigned int seed)
myrand_seed = seed;
}
+#ifdef DEBUGMENU
void WeaponCheat();
void HealthCheat();
void TankCheat();
@@ -115,13 +117,13 @@ SpawnCar(int id)
DebugMenuEntrySetAddress(carCol2, &v->m_currentColour2);
if(CModelInfo::IsBoatModel(id))
- v->GetPosition() = TheCamera.GetPosition() + TheCamera.GetForward()*15.0f;
+ v->SetPosition(TheCamera.GetPosition() + TheCamera.GetForward()*15.0f);
else
- v->GetPosition() = ThePaths.m_pathNodes[node].pos;
+ v->SetPosition(ThePaths.m_pathNodes[node].GetPosition());
- v->GetPosition().z += 4.0f;
+ v->GetMatrix().GetPosition().z += 4.0f;
v->SetOrientation(0.0f, 0.0f, 3.49f);
- v->m_status = STATUS_ABANDONED;
+ v->SetStatus(STATUS_ABANDONED);
v->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(v);
}
@@ -322,11 +324,26 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); });
DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); });
+ DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
#ifdef LIBRW
DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil);
#endif
+ DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil);
+ DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil);
+ DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil);
+ DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil);
+ DebugMenuAddVarBool8("Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil);
+ DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil);
+ DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Peds", &gbDontRenderPeds, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
- DebugMenuAddVarBool8("Debug", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil);
#ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
@@ -343,18 +360,6 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway);
DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil);
- DebugMenuAddVarBool8("Debug", "Show Ped Paths", &gbShowPedPaths, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Paths", &gbShowCarPaths, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Path Links", &gbShowCarPathsLinks, nil);
- DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", &gbShowPedRoadGroups, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Road Groups", &gbShowCarRoadGroups, nil);
- DebugMenuAddVarBool8("Debug", "Show Collision Lines", &gbShowCollisionLines, nil);
- DebugMenuAddVarBool8("Debug", "Show Collision Polys", &gbShowCollisionPolys, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Buildings", &gbDontRenderBuildings, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Peds", &gbDontRenderPeds, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Vehicles", &gbDontRenderVehicles, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Objects", &gbDontRenderObjects, nil);
#ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil);
DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", &CPed::bMakePedsRunToPhonesToReportCrimes, nil);
@@ -380,6 +385,7 @@ DebugMenuPopulate(void)
CTweakVars::AddDBG("Debug");
}
}
+#endif
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
diff --git a/src/core/templates.h b/src/core/templates.h
index 51a24e4c..4f7b8490 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -17,6 +17,16 @@ public:
void clear(void){
this->allocPtr = 0;
}
+ int getIndex(T *item){
+ assert(item >= &this->store[0]);
+ assert(item < &this->store[n]);
+ return item - this->store;
+ }
+ T *getItem(int index){
+ assert(index >= 0);
+ assert(index < n);
+ return &this->store[index];
+ }
};
template<typename T, typename U = T>
@@ -35,6 +45,7 @@ class CPool
public:
CPool(int size){
+ // TODO: use new here
m_entries = (U*)malloc(sizeof(U)*size);
m_flags = (Flags*)malloc(sizeof(Flags)*size);
m_size = size;
@@ -44,6 +55,7 @@ public:
m_flags[i].free = 1;
}
}
+
~CPool() {
Flush();
}
@@ -119,7 +131,7 @@ public:
// TODO: the cast is unsafe
return (int)((U*)entry - m_entries);
}
- int GetNoOfUsedSpaces(void){
+ int GetNoOfUsedSpaces(void) const{
int i;
int n = 0;
for(i = 0; i < m_size; i++)