summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/Cam.cpp22
-rw-r--r--src/core/Camera.cpp53
-rw-r--r--src/core/Camera.h6
-rw-r--r--src/core/CdStream.cpp11
-rw-r--r--src/core/ControllerConfig.cpp104
-rw-r--r--src/core/ControllerConfig.h4
-rw-r--r--src/core/FileLoader.cpp116
-rw-r--r--src/core/FileMgr.cpp3
-rw-r--r--src/core/FileMgr.h2
-rw-r--r--src/core/Frontend.cpp107
-rw-r--r--src/core/Frontend.h7
-rw-r--r--src/core/Game.cpp5
-rw-r--r--src/core/General.h2
-rw-r--r--src/core/Lists.h2
-rw-r--r--src/core/MenuScreensCustom.cpp47
-rw-r--r--src/core/Pad.cpp35
-rw-r--r--src/core/Placeable.cpp4
-rw-r--r--src/core/Placeable.h2
-rw-r--r--src/core/PlayerInfo.cpp4
-rw-r--r--src/core/PlayerInfo.h2
-rw-r--r--src/core/Pools.cpp4
-rw-r--r--src/core/Radar.cpp13
-rw-r--r--src/core/Radar.h21
-rw-r--r--src/core/Stats.h2
-rw-r--r--src/core/Streaming.cpp26
-rw-r--r--src/core/Wanted.h1
-rw-r--r--src/core/World.cpp5
-rw-r--r--src/core/World.h6
-rw-r--r--src/core/Zones.cpp2
-rw-r--r--src/core/Zones.h4
-rw-r--r--src/core/common.h121
-rw-r--r--src/core/config.h133
-rw-r--r--src/core/main.cpp173
-rw-r--r--src/core/main.h9
-rw-r--r--src/core/re3.cpp476
-rw-r--r--src/core/templates.h71
36 files changed, 1263 insertions, 342 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 1d73a272..f43ff57a 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -193,7 +193,7 @@ CCam::Process(void)
break;
case MODE_CAM_ON_A_STRING:
#ifdef FREE_CAM
- if(CCamera::bFreeCam)
+ if(CCamera::bFreeCam && !CVehicle::bCheat5)
Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else
#endif
@@ -946,7 +946,7 @@ CVector
CCam::DoAverageOnVector(const CVector &vec)
{
int i;
- CVector Average = { 0.0f, 0.0f, 0.0f };
+ CVector Average(0.0f, 0.0f, 0.0f);
if(ResetStatics){
m_iRunningVectorArrayPos = 0;
@@ -3829,11 +3829,11 @@ CCam::Process_Debug(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -3900,11 +3900,11 @@ CCam::Process_Debug(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -3981,11 +3981,11 @@ CCam::Process_Editor(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -5039,11 +5039,15 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// Using GetCarGun(LR/UD) will give us same unprocessed RightStick value as SA
float stickX = -(pad->GetCarGunLeftRight());
- float stickY = pad->GetCarGunUpDown();
+ float stickY = -pad->GetCarGunUpDown();
// In SA this is for not let num2/num8 move camera when Keyboard & Mouse controls are used.
// if (CCamera::m_bUseMouse3rdPerson)
// stickY = 0.0f;
+#ifdef INVERT_LOOK_FOR_PAD
+ if (CPad::bInvertLook4Pad)
+ stickY = -stickY;
+#endif
float xMovement = Abs(stickX) * (FOV / 80.0f * 5.f / 70.f) * stickX * 0.007f * 0.007f;
float yMovement = Abs(stickY) * (FOV / 80.0f * 3.f / 70.f) * stickY * 0.007f * 0.007f;
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index b46bd2da..2ce4e754 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -2212,7 +2212,7 @@ CCamera::StartTransition(int16 newMode)
while(deltaBeta < -PI) deltaBeta += 2*PI;
deltaBeta = Abs(deltaBeta);
- door = FindPlayerPed()->m_vehEnterType;
+ door = FindPlayerPed()->m_vehDoor;
if(deltaBeta > HALFPI){
if(((CPed*)pTargetEntity)->m_carInObjective){
if(((CPed*)pTargetEntity)->m_carInObjective->IsUpsideDown()){
@@ -2293,7 +2293,7 @@ CCamera::StartTransition(int16 newMode)
}
#endif
- door = FindPlayerPed()->m_vehEnterType;
+ door = FindPlayerPed()->m_vehDoor;
if(deltaBeta > HALFPI){
if(((CVehicle*)pTargetEntity)->IsUpsideDown()){
if(door == CAR_DOOR_LF || door == CAR_DOOR_LR) // BUG: game checks LF twice
@@ -2783,7 +2783,7 @@ CCamera::TryToStartNewCamMode(int obbeMode)
if (CReplay::IsPlayingBack())
return false;
#endif
- if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
+ if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1)
return false;
if(FindPlayerVehicle() == nil)
return false;
@@ -2811,7 +2811,7 @@ CCamera::TryToStartNewCamMode(int obbeMode)
if (CReplay::IsPlayingBack())
return false;
#endif
- if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
+ if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1)
return false;
if(FindPlayerVehicle() == nil)
return false;
@@ -3629,9 +3629,17 @@ CCamera::CalculateDerivedValues(void)
bool
CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y < CDraw::GetNearClipZ()) return false;
if(c.y > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > 0.0f) return false;
@@ -3644,9 +3652,17 @@ CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y + radius < CDraw::GetNearClipZ()) return false;
if(c.y - radius > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > radius) return false;
@@ -3664,11 +3680,24 @@ CCamera::IsSphereVisible(const CVector &center, float radius)
}
bool
-CCamera::IsBoxVisible(RwV3d *box, const CMatrix *mat)
+#ifdef GTA_PS2
+CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat)
+#else
+CCamera::IsBoxVisible(CVector *box, const CMatrix *mat)
+#endif
{
int i;
int frustumTests[6] = { 0 };
- RwV3dTransformPoints(box, box, 8, &mat->m_matrix);
+#ifdef GTA_PS2
+ TransformPoints(box, 8, *mat, box);
+#else
+ #ifdef FIX_BUGS
+ for (i = 0; i < 8; i++)
+ box[i] = *mat * box[i];
+ #else
+ RwV3dTransformPoints(box, box, 8, (RwMatrix*)mat);
+ #endif
+#endif
for(i = 0; i < 8; i++){
if(box[i].y < CDraw::GetNearClipZ()) frustumTests[0]++;
diff --git a/src/core/Camera.h b/src/core/Camera.h
index ca1bd135..d7293e20 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -641,7 +641,11 @@ public:
bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius);
- bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
+#ifdef GTA_PS2
+ bool IsBoxVisible(CVuVector *box, const CMatrix *mat);
+#else
+ bool IsBoxVisible(CVector *box, const CMatrix *mat);
+#endif
};
VALIDATE_SIZE(CCamera, 0xE9D8);
diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp
index 4bb31ea4..da85a238 100644
--- a/src/core/CdStream.cpp
+++ b/src/core/CdStream.cpp
@@ -7,9 +7,6 @@
#include "RwHelper.h"
#include "MemoryMgr.h"
-#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-
struct CdReadInfo
{
uint32 nSectorOffset;
@@ -60,7 +57,7 @@ CdStreamInitThread(void)
if ( gpReadInfo[i].hSemaphore == nil )
{
- CDTRACE("failed to create sync semaphore");
+ printf("%s: failed to create sync semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -81,7 +78,7 @@ CdStreamInitThread(void)
if ( gCdStreamSema == nil )
{
- CDTRACE("failed to create stream semaphore");
+ printf("%s: failed to create stream semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -90,7 +87,7 @@ CdStreamInitThread(void)
if ( _gCdStreamThread == nil )
{
- CDTRACE("failed to create streaming thread");
+ printf("%s: failed to create streaming thread\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -138,7 +135,7 @@ CdStreamInit(int32 numChannels)
gpReadInfo = (CdReadInfo *)LocalAlloc(LMEM_ZEROINIT, sizeof(CdReadInfo) * numChannels);
ASSERT( gpReadInfo != nil );
- CDDEBUG("read info %p", gpReadInfo);
+ debug("%s: read info %p\n", "cdvd_stream", gpReadInfo);
CdStreamAddImage("MODELS\\GTA3.IMG");
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index bf4893ea..4115cd38 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -1,11 +1,7 @@
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-
+#define WITHDINPUT
#include "common.h"
#include "platform.h"
-#include "crossplatform.h" // for Windows version
+#include "crossplatform.h"
#include "ControllerConfig.h"
#include "Pad.h"
#include "FileMgr.h"
@@ -35,6 +31,9 @@ CControllerConfigManager::CControllerConfigManager()
void CControllerConfigManager::MakeControllerActionsBlank()
{
+#ifdef LOAD_INI_SETTINGS
+ ms_padButtonsInited = 0;
+#endif
for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++)
{
for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++)
@@ -349,6 +348,10 @@ void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerSta
}
}
+#ifdef LOAD_INI_SETTINGS
+uint32 CControllerConfigManager::ms_padButtonsInited = 0;
+#endif
+
void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
{
m_bFirstCapture = true;
@@ -357,6 +360,22 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
if (buttons > 16)
btn = 16;
+#ifdef LOAD_INI_SETTINGS
+ uint32 buttonMin = ms_padButtonsInited;
+ if (buttonMin >= btn)
+ return;
+
+ ms_padButtonsInited = btn;
+
+ #define IF_BTN_IN_RANGE(n) \
+ case n: \
+ if (n <= buttonMin) \
+ return;
+#else
+ #define IF_BTN_IN_RANGE(n) \
+ case n:
+#endif
+
// Now we use SDL Game Controller DB
#if defined RW_D3D9 || defined RWLIBS
if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427
@@ -369,49 +388,49 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
switch (btn)
{
- case 16:
+ IF_BTN_IN_RANGE(16)
SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK);
- case 15:
+ IF_BTN_IN_RANGE(15)
SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK);
- case 14:
+ IF_BTN_IN_RANGE(14)
SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK);
- case 13:
+ IF_BTN_IN_RANGE(13)
SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK);
- case 12:
- case 11:
+ IF_BTN_IN_RANGE(12)
+ IF_BTN_IN_RANGE(11)
SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK);
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
- case 10:
+ IF_BTN_IN_RANGE(10)
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
- case 9:
+ IF_BTN_IN_RANGE(9)
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
- case 8:
+ IF_BTN_IN_RANGE(8)
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
- case 7:
+ IF_BTN_IN_RANGE(7)
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
- case 6:
+ IF_BTN_IN_RANGE(6)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK);
- case 5:
+ IF_BTN_IN_RANGE(5)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK);
/*******************************************************************************************/
- case 4:
+ IF_BTN_IN_RANGE(4)
SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 4, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_JUMPING, 4, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 4, JOYSTICK);
- case 3:
+ IF_BTN_IN_RANGE(3)
SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SPRINT, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 3, JOYSTICK);
- case 2:
+ IF_BTN_IN_RANGE(2)
SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 2, JOYSTICK);
#ifdef BIND_VEHICLE_FIREWEAPON
SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 2, JOYSTICK);
#endif
- case 1:
+ IF_BTN_IN_RANGE(1)
SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 1, JOYSTICK);
/*******************************************************************************************/
}
@@ -420,46 +439,46 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
{
switch (btn)
{
- case 16:
+ IF_BTN_IN_RANGE(16)
SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK);
- case 15:
+ IF_BTN_IN_RANGE(15)
SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK);
- case 14:
+ IF_BTN_IN_RANGE(14)
SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK);
- case 13:
+ IF_BTN_IN_RANGE(13)
SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK);
- case 12:
- case 11:
+ IF_BTN_IN_RANGE(12)
+ IF_BTN_IN_RANGE(11)
SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK);
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
- case 10:
+ IF_BTN_IN_RANGE(10)
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
- case 9:
+ IF_BTN_IN_RANGE(9)
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
- case 8:
+ IF_BTN_IN_RANGE(8)
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
- case 7:
+ IF_BTN_IN_RANGE(7)
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
- case 6:
+ IF_BTN_IN_RANGE(6)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK);
- case 5:
+ IF_BTN_IN_RANGE(5)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK);
/*******************************************************************************************/
- case 4:
+ IF_BTN_IN_RANGE(4)
SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 4, JOYSTICK);
- case 3:
+ IF_BTN_IN_RANGE(3)
SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_JUMPING, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 3, JOYSTICK);
- case 2:
+ IF_BTN_IN_RANGE(2)
SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 2, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SPRINT, 2, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 2, JOYSTICK);
- case 1:
+ IF_BTN_IN_RANGE(1)
SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 1, JOYSTICK);
#ifdef BIND_VEHICLE_FIREWEAPON
SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 1, JOYSTICK);
@@ -2765,9 +2784,10 @@ wchar *CControllerConfigManager::GetButtonComboText(e_ControllerAction action)
void CControllerConfigManager::SetControllerKeyAssociatedWithAction(e_ControllerAction action, int32 key, eControllerType type)
{
ResetSettingOrder(action);
+ int numOfSettings = GetNumOfSettingsForAction(action);
m_aSettings[action][type].m_Key = key;
- m_aSettings[action][type].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][type].m_ContSetOrder = numOfSettings + 1;
}
int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerAction action)
@@ -2777,8 +2797,10 @@ int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerA
void CControllerConfigManager::SetMouseButtonAssociatedWithAction(e_ControllerAction action, int32 button)
{
+ int numOfSettings = GetNumOfSettingsForAction(action);
+
m_aSettings[action][MOUSE].m_Key = button;
- m_aSettings[action][MOUSE].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][MOUSE].m_ContSetOrder = numOfSettings + 1;
}
void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)
@@ -2801,7 +2823,7 @@ void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)
for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++)
{
int32 setorder = m_aSettings[action][k].m_ContSetOrder;
- if (setorder > i && setorder != KEYBOARD)
+ if (setorder > i && setorder != 0)
{
if (init)
{
diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h
index d3c2293d..295f03b9 100644
--- a/src/core/ControllerConfig.h
+++ b/src/core/ControllerConfig.h
@@ -141,6 +141,10 @@ public:
tControllerConfigBind m_aSettings[MAX_CONTROLLERACTIONS][MAX_CONTROLLERTYPES];
bool m_aSimCheckers[MAX_SIMS][MAX_CONTROLLERTYPES];
bool m_bMouseAssociated;
+
+#ifdef LOAD_INI_SETTINGS
+ static uint32 ms_padButtonsInited;
+#endif
CControllerConfigManager();
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index 926512b9..22e0159c 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -445,7 +445,7 @@ bool
CFileLoader::StartLoadClumpFile(RwStream *stream, uint32 id)
{
if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){
- printf("Start loading %s\n", CModelInfo::GetModelInfo(id)->GetName());
+ printf("Start loading %s\n", CModelInfo::GetModelInfo(id)->GetModelName());
return RpClumpGtaStreamRead1(stream);
}else{
printf("FAILED\n");
@@ -459,7 +459,7 @@ CFileLoader::FinishLoadClumpFile(RwStream *stream, uint32 id)
RpClump *clump;
CClumpModelInfo *mi;
- printf("Finish loading %s\n", CModelInfo::GetModelInfo(id)->GetName());
+ printf("Finish loading %s\n", CModelInfo::GetModelInfo(id)->GetModelName());
clump = RpClumpGtaStreamRead2(stream);
if(clump){
@@ -557,7 +557,6 @@ char *DoubleSidedNames[] = {
"overpass_comse",
"newdockbuilding",
"newdockbuilding2",
- "newdockbuilding",
"policeballhall",
"fuzballdoor",
"ind_land106",
@@ -581,7 +580,98 @@ char *DoubleSidedNames[] = {
"railtrax_2b",
"railtrax_straightss",
"railtrax_bentr",
+ "ind_land125",
+ "salvstrans",
+ "bridge_liftsec",
+ "subsign1",
+ "carparkfence",
+ "newairportwall4",
+ "apair_terminal",
+ "Helipad",
+ "bar_barrier10",
+ "damissionfence",
+ "sub_floodlite",
+ "suburbbridge1",
+ "damfencing",
+ "demfence08",
+ "damfence07",
+ "damfence06",
+ "damfence05",
+ "damfence04",
+ "damfence03",
+ "damfence02",
+ "damfence01",
+ "Dam_pod2",
+ "Dam_pod1",
+ "columansion_wall",
+ "wrckdhse020",
+ "wrckdhse01",
+ "arc_bridge",
+ "gRD_overpass19kbc",
+ "gRD_overpass19bkb",
+ "gRD_overpass19kb",
+ "gRD_overpass18kb",
+ "road_under",
+ "com_roadkb23",
+ "com_roadkb22",
+ "nbbridgerda",
+ "nbbridgerdb",
+ "policetenkb1",
+ "block3_scraper2",
+ "Clnm_cthdrlfcde",
+ "broadwaybuild",
+ "combillboard03",
+ "com_park3b",
+ "com_docksaa",
+ "newdockbuilding2",
+ "com_roadkb22",
+ "sidebarrier_gaz2",
+ "tunnelsupport1",
+ "skyscrpunbuilt2",
+ "cons_buid02",
+ "rail_platformw",
+ "railtrax_bent1",
+ "nrailstepswest",
+ "building_fucked",
+ "franksclb02",
+ "salvsdetail",
+ "crgoshp01",
+ "shp_wlkway",
+ "bar_barriergate1",
+ "plnt_pylon01",
+ "fishfctory",
+ "doc_crane_cab",
+ "nrailsteps",
+ "iten_club01",
+ "mak_Watertank",
+ "basketballcourt"
+ "carlift01",
+ "carlift02",
+ "iten_chinatown4",
+ "iten_details7",
+ "ind_customroad002"
+ "ind_brgrd1way",
+ "ind_customroad060",
+ "ind_customroad002",
+ "ind_land108",
+ "ind_customroad004",
+ "ind_customroad003",
+ "nbbridgcabls01",
+ "sbwy_tunl_bit",
+ "sbwy_tunl_bend",
+ "sbwy_tunl_cstm11",
+ "sbwy_tunl_cstm10",
+ "sbwy_tunl_cstm9",
+ "sbwy_tunl_cstm8",
+ "sbwy_tunl_cstm7",
+ "sbwy_tunl_cstm6",
+ "sbwy_tunl_cstm5",
+ "sbwy_tunl_cstm4",
+ "sbwy_tunl_cstm3",
+ "sbwy_tunl_cstm2",
+ "sbwy_tunl_cstm1",
""
+
};
char *TreeNames[] = {
"coast_treepatch",
@@ -985,9 +1075,9 @@ SetModelInfoFlags(CSimpleModelInfo *mi, uint32 flags)
#ifdef HARDCODED_MODEL_FLAGS
// mobile sets these flags in CFileLoader::SetRelatedModelInfoCB, but that's stupid
- if(MatchModelName(mi->GetName(), DoubleSidedNames)) mi->m_bIsDoubleSided = true;
- if(MatchModelName(mi->GetName(), TreeNames)) mi->m_bIsTree = true;
- if(MatchModelName(mi->GetName(), OptimizedNames)) mi->m_bCanBeIgnored = true;
+ if(MatchModelName(mi->GetModelName(), DoubleSidedNames)) mi->m_bIsDoubleSided = true;
+ if(MatchModelName(mi->GetModelName(), TreeNames)) mi->m_bIsTree = true;
+ if(MatchModelName(mi->GetModelName(), OptimizedNames)) mi->m_bCanBeIgnored = true;
#endif
#endif
@@ -1029,7 +1119,7 @@ CFileLoader::LoadObject(const char *line)
}
mi = CModelInfo::AddSimpleModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetNumAtomics(numObjs);
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
@@ -1048,7 +1138,7 @@ CFileLoader::LoadMLO(const char *line)
sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat);
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
- minfo->SetName(name);
+ minfo->SetModelName(name);
minfo->field_34 = someFloat;
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
minfo->firstInstance = instId;
@@ -1126,7 +1216,7 @@ CFileLoader::LoadTimeObject(const char *line)
}
mi = CModelInfo::AddTimeModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetNumAtomics(numObjs);
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
@@ -1148,7 +1238,7 @@ CFileLoader::LoadClumpObject(const char *line)
if(sscanf(line, "%d %s %s", &id, model, txd) == 3){
mi = CModelInfo::AddClumpModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
mi->SetColModel(&CTempColModels::ms_colModelBBox);
}
@@ -1172,7 +1262,7 @@ CFileLoader::LoadVehicleObject(const char *line)
&frequency, &level, &comprules, &misc, &wheelScale);
mi = CModelInfo::AddVehicleModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
for(p = gamename; *p; p++)
if(*p == '_') *p = ' ';
@@ -1251,7 +1341,7 @@ CFileLoader::LoadPedObject(const char *line)
return;
mi = CModelInfo::AddPedModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
mi->SetColModel(&CTempColModels::ms_colModelPed1);
mi->m_pedType = CPedType::FindPedType(pedType);
@@ -1725,7 +1815,7 @@ CFileLoader::ReloadObject(const char *line)
#ifdef FIX_BUGS
mi &&
#endif
- mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
+ mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetModelName(), model) && mi->m_numAtomics == numObjs) {
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
} else {
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index 99923ddf..32aa4041 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -241,7 +241,7 @@ CFileMgr::SetDirMyDocuments(void)
}
ssize_t
-CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
+CFileMgr::LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode)
{
int fd;
ssize_t n, len;
@@ -257,6 +257,7 @@ CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
return -1;
#endif
len += n;
+ assert(len < maxlen);
}while(n == 0x4000);
buf[len] = 0;
myfclose(fd);
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index 98a78360..f70451b7 100644
--- a/src/core/FileMgr.h
+++ b/src/core/FileMgr.h
@@ -9,7 +9,7 @@ public:
static void ChangeDir(const char *dir);
static void SetDir(const char *dir);
static void SetDirMyDocuments(void);
- static ssize_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
+ static ssize_t LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode);
static int OpenFile(const char *file, const char *mode);
static int OpenFile(const char *file) { return OpenFile(file, "rb"); }
static int OpenFileForWriting(const char *file);
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 2a87c7ad..bd72a15f 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -1,10 +1,6 @@
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-
#define FORCE_PC_SCALING
#define WITHWINDOWS
+#define WITHDINPUT
#include "common.h"
#ifndef PS2_MENU
#include "crossplatform.h"
@@ -145,14 +141,6 @@ int8 CMenuManager::m_nDisplayMSAALevel = 0;
int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW;
#endif
-#ifdef USE_PRECISE_MEASUREMENT_CONVERTION
-#define MILES_IN_METER 0.000621371192f
-#define FEET_IN_METER 3.28084f
-#else
-#define MILES_IN_METER (1 / 1670.f)
-#define FEET_IN_METER 3.33f
-#endif
-
int32 CMenuManager::OS_Language = LANG_ENGLISH;
int8 CMenuManager::m_PrefsUseVibration;
int8 CMenuManager::m_DisplayControllerOnFoot;
@@ -874,7 +862,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
m_bWaitingForNewKeyBind = false;
m_KeyPressedCode = -1;
m_bStartWaitingForKeyBind = false;
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#else
SaveSettings();
+#endif
}
if (escPressed) {
@@ -882,7 +874,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
m_bWaitingForNewKeyBind = false;
m_KeyPressedCode = -1;
m_bStartWaitingForKeyBind = false;
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#else
SaveSettings();
+#endif
}
}
@@ -1285,7 +1281,9 @@ CMenuManager::Draw()
float smallestSliderBar = lineHeight * 0.1f;
bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
+#ifdef ASPECT_RATIO_SCALE
char asciiTemp[32];
+#endif
#ifdef MENU_MAP
if (m_nCurrScreen == MENUPAGE_MAP) {
@@ -1459,18 +1457,34 @@ CMenuManager::Draw()
#else
switch (m_PrefsUseWideScreen) {
case AR_AUTO:
- sprintf(asciiTemp, "AUTO");
+ rightText = TheText.Get("FEM_AUT");
break;
case AR_4_3:
sprintf(asciiTemp, "4:3");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_5_4:
+ sprintf(asciiTemp, "5:4");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_16_10:
+ sprintf(asciiTemp, "16:10");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
break;
case AR_16_9:
sprintf(asciiTemp, "16:9");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_21_9:
+ sprintf(asciiTemp, "21:9");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
break;
}
-
- AsciiToUnicode(asciiTemp, unicodeTemp);
- rightText = unicodeTemp;
#endif
break;
case MENUACTION_RADIO:
@@ -3566,13 +3580,21 @@ CMenuManager::LoadAllTextures()
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0);
m_nCurrOption = 0;
+
+#ifdef FIX_BUGS
+ static bool firstTime = true;
+ if (firstTime) {
+ DMAudio.SetRadioInCar(m_PrefsRadioStation);
+ firstTime = false;
+ } else
+#endif
m_PrefsRadioStation = DMAudio.GetRadioInCar();
if (DMAudio.IsMP3RadioChannelAvailable()) {
if (m_PrefsRadioStation > USERTRACK)
- m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10;
+ m_PrefsRadioStation = CGeneral::GetRandomNumber() % (USERTRACK + 1);
} else if (m_PrefsRadioStation > CHATTERBOX)
- m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9;
+ m_PrefsRadioStation = CGeneral::GetRandomNumber() % (CHATTERBOX + 1);
CFileMgr::SetDir("");
//CFileMgr::SetDir("");
@@ -3707,6 +3729,16 @@ CMenuManager::LoadSettings()
CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");
+#ifdef LOAD_INI_SETTINGS
+ if (LoadINISettings()) {
+ LoadINIControllerSettings();
+ } else {
+ // no re3.ini, create it
+ SaveINISettings();
+ SaveINIControllerSettings();
+ }
+#endif
+
m_PrefsVsync = m_PrefsVsyncDisp;
CRenderer::ms_lodDistScale = m_PrefsLOD;
@@ -3745,15 +3777,12 @@ CMenuManager::LoadSettings()
strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME);
strcpy(m_aSkinName, DEFAULT_SKIN_NAME);
}
-
-#ifdef LOAD_INI_SETTINGS
- LoadINISettings(); // needs frontend options to be loaded
-#endif
}
void
CMenuManager::SaveSettings()
{
+#ifndef LOAD_INI_SETTINGS
static char RubbishString[48] = "stuffmorestuffevenmorestuff etc";
CFileMgr::SetDirMyDocuments();
@@ -3803,7 +3832,7 @@ CMenuManager::SaveSettings()
CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");
-#ifdef LOAD_INI_SETTINGS
+#else
SaveINISettings();
#endif
}
@@ -4113,19 +4142,19 @@ CMenuManager::Process(void)
MouseButtonJustClicked = false;
if (CPad::GetPad(0)->GetLeftMouseJustDown())
- MouseButtonJustClicked = 1;
+ MouseButtonJustClicked = rsMOUSELEFTBUTTON;
else if (CPad::GetPad(0)->GetRightMouseJustUp())
- MouseButtonJustClicked = 3;
+ MouseButtonJustClicked = rsMOUSERIGHTBUTTON;
else if (CPad::GetPad(0)->GetMiddleMouseJustUp())
- MouseButtonJustClicked = 2;
+ MouseButtonJustClicked = rsMOUSMIDDLEBUTTON;
else if (CPad::GetPad(0)->GetMouseWheelUpJustUp())
- MouseButtonJustClicked = 4;
+ MouseButtonJustClicked = rsMOUSEWHEELUPBUTTON;
else if (CPad::GetPad(0)->GetMouseWheelDownJustUp())
- MouseButtonJustClicked = 5;
+ MouseButtonJustClicked = rsMOUSEWHEELDOWNBUTTON;
else if (CPad::GetPad(0)->GetMouseX1JustUp())
- MouseButtonJustClicked = 6;
+ MouseButtonJustClicked = rsMOUSEX1BUTTON;
else if (CPad::GetPad(0)->GetMouseX2JustUp())
- MouseButtonJustClicked = 7;
+ MouseButtonJustClicked = rsMOUSEX2BUTTON;
JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown();
@@ -5043,6 +5072,9 @@ CMenuManager::ProcessButtonPresses(void)
CVehicle::m_bDisableMouseSteering = true;
TheCamera.m_bHeadBob = false;
SaveSettings();
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#endif
}
SetHelperText(2);
break;
@@ -5094,7 +5126,8 @@ CMenuManager::ProcessButtonPresses(void)
*option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
- if (option.m_CFOSelect->save)
+ // Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
+ // if (option.m_CFOSelect->save)
SaveSettings();
if (option.m_CFOSelect->displayedValue != oldValue && option.m_CFOSelect->changeFunc)
@@ -5252,12 +5285,12 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_WIDESCREEN:
if (changeValueBy > 0) {
m_PrefsUseWideScreen++;
- if (m_PrefsUseWideScreen > 2)
+ if (m_PrefsUseWideScreen > AR_MAX-1)
m_PrefsUseWideScreen = 0;
} else {
m_PrefsUseWideScreen--;
if (m_PrefsUseWideScreen < 0)
- m_PrefsUseWideScreen = 2;
+ m_PrefsUseWideScreen = AR_MAX-1;
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
SaveSettings();
@@ -5328,7 +5361,8 @@ CMenuManager::ProcessButtonPresses(void)
*option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
- if (option.m_CFOSelect->save)
+ // Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
+ // if (option.m_CFOSelect->save)
SaveSettings();
if (option.m_CFOSelect->displayedValue != oldValue && option.m_CFOSelect->changeFunc)
@@ -5570,6 +5604,9 @@ CMenuManager::SwitchMenuOnAndOff()
#endif
ShutdownJustMenu();
SaveSettings();
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#endif
m_bStartUpFrontEndRequested = false;
pControlEdit = nil;
m_bShutDownFrontEndRequested = false;
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 36647899..b0100fdc 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -494,6 +494,7 @@ struct CCustomScreenLayout {
struct CCFO
{
int8 *value;
+ const char *saveCat;
const char *save;
};
@@ -508,11 +509,12 @@ struct CCFOSelect : CCFO
bool disableIfGameLoaded;
CCFOSelect() {};
- CCFOSelect(int8* value, const char* save, const char** rightTexts, int8 numRightTexts, bool onlyApplyOnEnter, ChangeFunc changeFunc = nil, bool disableIfGameLoaded = false){
+ CCFOSelect(int8* value, const char* saveCat, const char* save, const char** rightTexts, int8 numRightTexts, bool onlyApplyOnEnter, ChangeFunc changeFunc = nil, bool disableIfGameLoaded = false){
this->value = value;
if (value)
this->lastSavedValue = this->displayedValue = *value;
+ this->saveCat = saveCat;
this->save = save;
this->rightTexts = (char**)rightTexts;
this->numRightTexts = numRightTexts;
@@ -528,8 +530,9 @@ struct CCFODynamic : CCFO
ButtonPressFunc buttonPressFunc;
CCFODynamic() {};
- CCFODynamic(int8* value, const char* save, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc){
+ CCFODynamic(int8* value, const char* saveCat, const char* save, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc){
this->value = value;
+ this->saveCat = saveCat;
this->save = save;
this->drawFunc = drawFunc;
this->buttonPressFunc = buttonPressFunc;
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 7961b981..4fd30b53 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -1,6 +1,3 @@
-#pragma warning( push )
-#pragma warning( disable : 4005)
-#pragma warning( pop )
#include "common.h"
#include "platform.h"
@@ -10,7 +7,6 @@
#include "Accident.h"
#include "Antennas.h"
#include "Bridge.h"
-#include "Camera.h"
#include "CarCtrl.h"
#include "CarGen.h"
#include "CdStream.h"
@@ -67,7 +63,6 @@
#include "Shadows.h"
#include "Skidmarks.h"
#include "SpecialFX.h"
-#include "Sprite2d.h"
#include "Stats.h"
#include "Streaming.h"
#include "SurfaceTable.h"
diff --git a/src/core/General.h b/src/core/General.h
index de803558..478ef027 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -133,7 +133,7 @@ public:
static bool faststricmp(const char *str1, const char *str2)
{
for (; *str1; str1++, str2++) {
-#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__
+#ifndef ASCII_STRCMP
if (toupper(*str1) != toupper(*str2))
#else
if (__ascii_toupper(*str1) != __ascii_toupper(*str2))
diff --git a/src/core/Lists.h b/src/core/Lists.h
index ecf24740..7572e882 100644
--- a/src/core/Lists.h
+++ b/src/core/Lists.h
@@ -1,7 +1,5 @@
#pragma once
-#include "common.h"
-
class CPtrNode
{
public:
diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp
index 4303e4b6..3eee8dd2 100644
--- a/src/core/MenuScreensCustom.cpp
+++ b/src/core/MenuScreensCustom.cpp
@@ -16,6 +16,7 @@
#include "Collision.h"
#include "ModelInfo.h"
#include "Pad.h"
+#include "ControllerConfig.h"
// Menu screens array is at the bottom of the file.
@@ -24,51 +25,51 @@
#ifdef CUSTOM_FRONTEND_OPTIONS
#ifdef IMPROVED_VIDEOMODE
- #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, nil, screenModes, 2, true, ScreenModeAfterChange, true) },
+ #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) },
#else
#define VIDEOMODE_SELECTOR
#endif
#ifdef MULTISAMPLING
- #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) },
+ #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "Graphics", "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) },
#else
#define MULTISAMPLING_SELECTOR
#endif
#ifdef CUTSCENE_BORDERS_SWITCH
- #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&CMenuManager::m_PrefsCutsceneBorders, "CutsceneBorders", off_on, 2, false) },
+ #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&CMenuManager::m_PrefsCutsceneBorders, "Display", "CutsceneBorders", off_on, 2, false) },
#else
#define CUTSCENE_BORDERS_TOGGLE
#endif
#ifdef FREE_CAM
- #define FREE_CAM_TOGGLE MENUACTION_CFO_SELECT, "FEC_FRC", { new CCFOSelect((int8*)&TheCamera.bFreeCam, "FreeCam", off_on, 2, false) },
+ #define FREE_CAM_TOGGLE MENUACTION_CFO_SELECT, "FEC_FRC", { new CCFOSelect((int8*)&TheCamera.bFreeCam, "Display", "FreeCam", off_on, 2, false) },
#else
#define FREE_CAM_TOGGLE
#endif
#ifdef PS2_ALPHA_TEST
- #define DUALPASS_SELECTOR MENUACTION_CFO_SELECT, "FEM_2PR", { new CCFOSelect((int8*)&gPS2alphaTest, "PS2AlphaTest", off_on, 2, false) },
+ #define DUALPASS_SELECTOR MENUACTION_CFO_SELECT, "FEM_2PR", { new CCFOSelect((int8*)&gPS2alphaTest, "Graphics", "PS2AlphaTest", off_on, 2, false) },
#else
#define DUALPASS_SELECTOR
#endif
#ifdef NO_ISLAND_LOADING
- #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsIslandLoading, "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) },
+ #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsIslandLoading, "Graphics", "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) },
#else
#define ISLAND_LOADING_SELECTOR
#endif
#ifdef EXTENDED_COLOURFILTER
#define POSTFX_SELECTORS \
- MENUACTION_CFO_SELECT, "FED_CLF", { new CCFOSelect((int8*)&CPostFX::EffectSwitch, "ColourFilter", filterNames, ARRAY_SIZE(filterNames), false) }, \
- MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "MotionBlur", off_on, 2, false) },
+ MENUACTION_CFO_SELECT, "FED_CLF", { new CCFOSelect((int8*)&CPostFX::EffectSwitch, "Graphics", "ColourFilter", filterNames, ARRAY_SIZE(filterNames), false) }, \
+ MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "Graphics", "MotionBlur", off_on, 2, false) },
#else
#define POSTFX_SELECTORS
#endif
#ifdef INVERT_LOOK_FOR_PAD
- #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_IVP", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "InvertPad", off_on, 2, false) },
+ #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_IVP", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "Controller", "InvertPad", off_on, 2, false) },
#else
#define INVERT_PAD_SELECTOR
#endif
@@ -292,6 +293,7 @@ void ScreenModeAfterChange(int8 before, int8 after)
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
wchar selectedJoystickUnicode[128];
+int cachedButtonNum = -1;
wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
int numButtons;
@@ -320,6 +322,7 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
strcpy(gSelectedJoystickName, joyname);
PSGLOBAL(joy1id) = found;
+ cachedButtonNum = numButtons;
}
}
if (PSGLOBAL(joy1id) == -1)
@@ -329,6 +332,18 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
return selectedJoystickUnicode;
}
+
+void DetectJoystickGoBack() {
+ if (cachedButtonNum != -1) {
+#ifdef LOAD_INI_SETTINGS
+ ControlsManager.InitDefaultControlConfigJoyPad(cachedButtonNum);
+ SaveINIControllerSettings();
+#else
+ // Otherwise no way to save gSelectedJoystickName or ms_padButtonsInited anyway :shrug: Why do you even use this config.??
+#endif
+ cachedButtonNum = -1;
+ }
+}
#endif
CMenuScreenCustom aScreens[MENUPAGES] = {
@@ -405,7 +420,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
CUTSCENE_BORDERS_TOGGLE
FREE_CAM_TOGGLE
MENUACTION_SUBTITLES, "FED_SUB", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
- MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefDisplay) },
+ MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefDisplay) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
@@ -418,9 +433,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_LANG_ITA, "FEL_ITA", { nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS },
MENUACTION_LANG_SPA, "FEL_SPA", { nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS },
#ifdef MORE_LANGUAGES
- MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, LangPolSelect) },
- MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, LangRusSelect) },
- MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, LangJapSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, nil, LangPolSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, nil, LangRusSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, nil, LangJapSelect) },
#endif
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
@@ -828,7 +843,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#endif
// re3.cpp inserts here pipeline selectors if neo/neo.txd exists and EXTENDED_PIPELINES defined
- MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefGraphics) },
+ MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefGraphics) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
@@ -836,10 +851,10 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
// MENUPAGE_DETECT_JOYSTICK
{ "FEC_JOD", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC,
- new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil,
+ new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), DetectJoystickGoBack,
MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
- MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, DetectJoystickDraw, nil) },
+ MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, nil, DetectJoystickDraw, nil) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index fd48ba97..95a107ee 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -1,11 +1,4 @@
-#pragma warning( push )
-#pragma warning( disable : 4005)
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-#pragma warning( pop )
-
+#define WITHDINPUT
#include "common.h"
#include "crossplatform.h"
#include "platform.h"
@@ -233,7 +226,7 @@ void ArmourCheat()
void WantedLevelUpCheat()
{
CHud::SetHelpMessage(TheText.Get("CHEAT5"), true);
- FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6));
+ FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->GetWantedLevel() + 2, 6));
}
void WantedLevelDownCheat()
@@ -872,6 +865,30 @@ void CPad::AddToCheatString(char c)
// "S1CD13TR1X" - SQUARE L1 CIRCLE DOWN L1 R1 TRIANGLE RIGHT L1 CROSS
else if ( !_CHEATCMP("X1RT31DC1S") )
NastyLimbsCheat();
+
+#ifdef KANGAROO_CHEAT
+ // "X1DUC3RLS3" - R1 SQUARE LEFT RIGHT R1 CIRCLE UP DOWN L1 CROSS
+ else if (!_CHEATCMP("X1DUC3RLS3"))
+ KangarooCheat();
+#endif
+
+#ifndef MASTER
+ // "31UD13XUD" - DOWN UP CROSS R1 L1 DOWN UP L1 R1
+ else if (!_CHEATCMP("31UD13XUD"))
+ CPed::SwitchDebugDisplay();
+#endif
+
+#ifdef ALLCARSHELI_CHEAT
+ // "UCCL3R1TT" - TRIANGLE TRIANGLE L1 RIGHT R1 LEFT CIRCLE CIRCLE UP
+ else if (!_CHEATCMP("UCCL3R1TT"))
+ AllCarsHeliCheat();
+#endif
+
+#ifdef ALT_DODO_CHEAT
+ // "DUU31XX13" - R1 L1 CROSS CROSS L1 R1 UP UP DOWN
+ else if (!_CHEATCMP("DUU31XX13"))
+ AltDodoCheat();
+#endif
#undef _CHEATCMP
}
#endif
diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp
index 69b3d3ea..162148f7 100644
--- a/src/core/Placeable.cpp
+++ b/src/core/Placeable.cpp
@@ -7,7 +7,9 @@ CPlaceable::CPlaceable(void)
m_matrix.SetScale(1.0f);
}
-CPlaceable::~CPlaceable(void) = default;
+CPlaceable::~CPlaceable(void)
+{
+}
void
CPlaceable::SetHeading(float angle)
diff --git a/src/core/Placeable.h b/src/core/Placeable.h
index 970c0d48..1d51f306 100644
--- a/src/core/Placeable.h
+++ b/src/core/Placeable.h
@@ -4,7 +4,7 @@ class CPlaceable
{
public:
// disable allocation
- static void *operator new(size_t) = delete;
+ static void *operator new(size_t);
CMatrix m_matrix;
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 07424736..1af8f924 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -222,8 +222,8 @@ CPlayerInfo::Process(void)
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
} else if (carBelow->IsBoat()) {
if (!carBelow->pDriver) {
- m_pPed->m_vehEnterType = 0;
- m_pPed->SetEnterCar(carBelow, m_pPed->m_vehEnterType);
+ m_pPed->m_vehDoor = 0;
+ m_pPed->SetEnterCar(carBelow, m_pPed->m_vehDoor);
}
} else {
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, carBelow);
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index 49424b8b..956756e4 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Collision.h"
+#include "ColModel.h"
enum eWastedBustedState
{
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 79841c14..39cfb1d4 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -102,7 +102,7 @@ CPools::CheckPoolsEmpty()
void
CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
{
- if (ms_pObjectPool->IsFreeSlot(slot)) return;
+ if (ms_pObjectPool->GetIsFree(slot)) return;
CObject *object = ms_pObjectPool->GetSlot(slot);
if (object->ObjectCreatedBy == TEMP_OBJECT) {
@@ -485,7 +485,7 @@ INITSAVEBUF
#endif
CopyToBuf(buf, CWanted::MaximumWantedLevel);
CopyToBuf(buf, CWanted::nMaximumWantedLevel);
- memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName(), MAX_MODEL_NAME);
+ memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetModelName(), MAX_MODEL_NAME);
SkipSaveBuf(buf, MAX_MODEL_NAME);
}
}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 816da6b9..116e9e94 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -1,3 +1,6 @@
+#if (!defined(GTA_PS2_STUFF) && defined(RWLIBS)) || defined(__MWERKS__)
+#define WITHD3D
+#endif
#include "config.h"
#include "common.h"
@@ -295,10 +298,10 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
{
CVector2D corners[4] = {
- { 1.0f, -1.0f }, // top right
- { 1.0f, 1.0f }, // bottom right
- { -1.0f, 1.0f }, // bottom left
- { -1.0f, -1.0f }, // top left
+ CVector2D( 1.0f, -1.0f ), // top right
+ CVector2D( 1.0f, 1.0f ), // bottom right
+ CVector2D( -1.0f, 1.0f ), // bottom left
+ CVector2D( -1.0f, -1.0f ), // top left
};
CVector2D tmp;
int i, j, n;
@@ -778,7 +781,7 @@ void CRadar::DrawRadarMask()
CVector2D(-1.0, -1.0f)
};
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)nil);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 5caf5bbb..5b38d350 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -1,5 +1,6 @@
#pragma once
#include "Sprite2d.h"
+#include "Draw.h"
enum eBlipType
{
@@ -91,8 +92,28 @@ VALIDATE_SIZE(sRadarTrace, 0x30);
#else
#define RADAR_BOTTOM (47.0f)
#endif
+
+#ifdef FIX_RADAR
+/*
+ The values are from an early screenshot taken before R* broke radar
+ #define RADAR_WIDTH (82.0f)
+ #define RADAR_HEIGHT (82.0f)
+*/
+#define RADAR_WIDTH ((CDraw::ms_bFixRadar) ? (82.0f) : (94.0f))
+#define RADAR_HEIGHT ((CDraw::ms_bFixRadar) ? (82.0f) : (76.0f))
+#else
+/*
+ broken since forever, someone tried to fix size for 640x512(PAL)
+ http://aap.rockstarvision.com/pics/gta3/ps2screens/gta3_interface.jpg
+ but failed:
+ http://aap.rockstarvision.com/pics/gta3/artwork/gta3_artwork_16.jpg
+ most likely the guy used something like this:
+ int y = 82 * (640.0/512.0)/(640.0/480.0);
+ int x = y * (640.0/512.0);
+*/
#define RADAR_WIDTH (94.0f)
#define RADAR_HEIGHT (76.0f)
+#endif
class CRadar
{
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 5dfcf803..6abcfb61 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -17,7 +17,7 @@ public:
static int32 NumberKillFrenziesPassed;
static int32 PeopleKilledByOthers;
static int32 HelisDestroyed;
- static int32 PedsKilledOfThisType[ePedType::NUM_PEDTYPES];
+ static int32 PedsKilledOfThisType[NUM_PEDTYPES];
static int32 TimesDied;
static int32 TimesArrested;
static int32 KillsSinceLastCheckpoint;
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index 03b49fd6..7b4218ba 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -509,10 +509,18 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
mi = CModelInfo::GetModelInfo(streamId);
// Txd has to be loaded
+#ifdef FIX_BUGS
+ if(!HasTxdLoaded(mi->GetTxdSlot())){
+#else
+ // texDict will exist even if only first part has loaded
if(CTxdStore::GetSlot(mi->GetTxdSlot())->texDict == nil){
- debug("failed to load %s because TXD %s is not in memory\n", mi->GetName(), CTxdStore::GetTxdName(mi->GetTxdSlot()));
+#endif
+ debug("failed to load %s because TXD %s is not in memory\n", mi->GetModelName(), CTxdStore::GetTxdName(mi->GetTxdSlot()));
RemoveModel(streamId);
+#ifndef FIX_BUGS
+ // if we're just waiting for it to load, don't remove this
RemoveTxd(mi->GetTxdSlot());
+#endif
ReRequestModel(streamId);
RwStreamClose(stream, &mem);
return false;
@@ -549,7 +557,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
if(!success){
- debug("Failed to load %s\n", CModelInfo::GetModelInfo(streamId)->GetName());
+ debug("Failed to load %s\n", CModelInfo::GetModelInfo(streamId)->GetModelName());
RemoveModel(streamId);
ReRequestModel(streamId);
RwStreamClose(stream, &mem);
@@ -590,7 +598,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(!success){
ReRequestModel(streamId);
if(streamId < STREAM_OFFSET_TXD)
- debug("Failed to load %s.dff\n", mi->GetName());
+ debug("Failed to load %s.dff\n", mi->GetModelName());
else
debug("Failed to load %s.txd\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD));
return false;
@@ -631,7 +639,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
timeDiff = endTime - startTime;
if(timeDiff > 5){
if(streamId < STREAM_OFFSET_TXD)
- debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff);
+ debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetModelName(), timeDiff);
else
debug("txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff);
}
@@ -705,7 +713,7 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
timeDiff = endTime - startTime;
if(timeDiff > 5){
if(streamId < STREAM_OFFSET_TXD)
- debug("finish model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff);
+ debug("finish model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetModelName(), timeDiff);
else
debug("finish txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff);
}
@@ -859,14 +867,14 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag
uint32 pos, size;
mi = CModelInfo::GetModelInfo(modelId);
- if(!CGeneral::faststrcmp(mi->GetName(), modelName)){
+ if(!CGeneral::faststrcmp(mi->GetModelName(), modelName)){
// Already have the correct name, just request it
RequestModel(modelId, flags);
return;
}
- strcpy(oldName, mi->GetName());
- mi->SetName(modelName);
+ strcpy(oldName, mi->GetModelName());
+ mi->SetModelName(modelName);
// What exactly is going on here?
if(CModelInfo::GetModelInfo(oldName, nil)){
@@ -2767,7 +2775,7 @@ CStreaming::PrintStreamingBufferState()
sprintf(str, "txd %s, refs %d, size %dK, flags 0x%x", CTxdStore::GetTxdName(modelIndex - STREAM_OFFSET_TXD),
CTxdStore::GetNumRefs(modelIndex - STREAM_OFFSET_TXD), 2 * size, streamingInfo->m_flags);
else
- sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetName(), modelInfo->GetNumRefs(), 2 * size,
+ sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetModelName(), modelInfo->GetNumRefs(), 2 * size,
streamingInfo->m_flags);
AsciiToUnicode(str, wstr);
CFont::PrintString(24.0f, y, wstr);
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index de36c442..9f08e752 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -37,6 +37,7 @@ public:
int32 NumOfHelisRequired();
void SetWantedLevel(int32);
void SetWantedLevelNoDrop(int32 level);
+ int32 GetWantedLevel() { return m_nWantedLevel; }
void RegisterCrime(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare);
void RegisterCrime_Immediately(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare);
void ClearQdCrimes();
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 67992035..6ecc294a 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -4,7 +4,6 @@
#include "CopPed.h"
#include "CutsceneMgr.h"
#include "DMAudio.h"
-#include "Entity.h"
#include "EventList.h"
#include "Explosion.h"
#include "Fire.h"
@@ -12,10 +11,7 @@
#include "Glass.h"
#include "Messages.h"
#include "ModelIndices.h"
-#include "Object.h"
#include "ParticleObject.h"
-#include "Ped.h"
-#include "PlayerPed.h"
#include "Population.h"
#include "ProjectileInfo.h"
#include "Record.h"
@@ -24,7 +20,6 @@
#include "RpAnimBlend.h"
#include "Shadows.h"
#include "TempColModels.h"
-#include "Vehicle.h"
#include "WaterLevel.h"
#include "World.h"
diff --git a/src/core/World.h b/src/core/World.h
index 9d62e79b..3d553752 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -3,6 +3,7 @@
#include "Game.h"
#include "Lists.h"
#include "PlayerInfo.h"
+#include "Collision.h"
/* Sectors span from -2000 to 2000 in x and y.
* With 100x100 sectors, each is 40x40 units. */
@@ -48,11 +49,6 @@ public:
VALIDATE_SIZE(CSector, 0x28);
-class CEntity;
-struct CColPoint;
-struct CColLine;
-struct CStoredCollPoly;
-
class CWorld
{
static CPtrList ms_bigBuildingsList[NUM_LEVELS];
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 2e3e0f6e..cdae85e1 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -649,7 +649,7 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
- WriteSaveBuf(buffer, GetIndexForZonePointer(m_pPlayersZone));
+ WriteSaveBuf(buffer, (int32)GetIndexForZonePointer(m_pPlayersZone));
WriteSaveBuf(buffer, m_CurrLevel);
WriteSaveBuf(buffer, FindIndex);
WriteSaveBuf(buffer, (int16)0); // padding
diff --git a/src/core/Zones.h b/src/core/Zones.h
index 6549dad5..aa0466e8 100644
--- a/src/core/Zones.h
+++ b/src/core/Zones.h
@@ -105,8 +105,8 @@ public:
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
static int16 FindAudioZone(CVector *pos);
static eLevelName FindZoneForPoint(const CVector &pos);
- static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &ZoneArray[i]; }
- static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; }
+ static CZone *GetPointerForZoneIndex(ssize_t i) { return i == -1 ? nil : &ZoneArray[i]; }
+ static ssize_t GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; }
static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void);
static void SaveAllZones(uint8 *buffer, uint32 *length);
diff --git a/src/core/common.h b/src/core/common.h
index 50002ab5..33d8910d 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -7,21 +7,47 @@
#pragma warning(disable: 4838) // narrowing conversion
#pragma warning(disable: 4996) // POSIX names
+#ifdef __MWERKS__
+#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc
+#endif
+
#include <stdint.h>
#include <string.h>
#include <math.h>
-#if defined _WIN32 && defined WITHWINDOWS
-#include <windows.h>
+#ifdef __MWERKS__
+#define AUDIO_MSS
+#define RWLIBS // codewarrior doesn't support project level defines - so not even this is enough, but still catches most ifdefs
+#endif
+
+#if !defined RW_D3D9 && defined LIBRW
+#undef WITHD3D
+#undef WITHDINPUT
#endif
-#if defined _WIN32 && defined WITHD3D
+#if (defined WITHD3D && !defined LIBRW)
+#define WITHWINDOWS
+#endif
+
+#if defined _WIN32 && defined WITHWINDOWS && !defined _INC_WINDOWS
#include <windows.h>
-#ifndef USE_D3D9
-#include <d3d8types.h>
-#else
-#include <d3d9types.h>
#endif
+
+#ifdef WITHD3D
+ #ifdef LIBRW
+ #define WITH_D3D // librw includes d3d9 itself via this right now
+ #else
+ #ifndef USE_D3D9
+ #include <d3d8.h>
+ #else
+ #include <d3d9.h>
+ #endif
+ #endif
+#endif
+
+#ifdef WITHDINPUT
+#define DIRECTINPUT_VERSION 0x0800
+#include <dinput.h>
#endif
#include <rwcore.h>
@@ -52,14 +78,6 @@
#define rwVENDORID_ROCKSTAR 0x0253F2
-// Get rid of bullshit windows definitions, we're not running on an 8086
-#ifdef far
-#undef far
-#endif
-#ifdef near
-#undef near
-#endif
-
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
@@ -70,8 +88,13 @@ typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
typedef int16_t int16;
+#ifndef __MWERKS__
typedef uint32_t uint32;
typedef int32_t int32;
+#else
+typedef unsigned int uint32;
+typedef int int32;
+#endif
typedef uintptr_t uintptr;
typedef intptr_t intptr;
typedef uint64_t uint64;
@@ -79,7 +102,11 @@ typedef int64_t int64;
// hardcode ucs-2
typedef uint16_t wchar;
-#if defined(_MSC_VER)
+typedef uint8 bool8;
+typedef uint16 bool16;
+typedef uint32 bool32;
+
+#if defined(_MSC_VER) || defined (__MWERKS__)
typedef ptrdiff_t ssize_t;
#endif
@@ -121,7 +148,7 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#include "skeleton.h"
#include "Draw.h"
-#if defined(USE_PROPER_SCALING)
+#if defined(PROPER_SCALING) || defined(PS2_HUD)
#ifdef FORCE_PC_SCALING
#define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (448)
@@ -155,8 +182,8 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
#endif
-#define SCREEN_HEIGHT_PAL (512)
-#define SCREEN_HEIGHT_NTSC (448)
+#define SCREEN_HEIGHT_PAL ((float)512)
+#define SCREEN_HEIGHT_NTSC ((float)448)
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f)))
@@ -175,8 +202,13 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#ifdef ASPECT_RATIO_SCALE
#define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO)
-extern float ScaleAndCenterX(float x);
-#define SCALE_AND_CENTER_X(x) ScaleAndCenterX(x)
+#define SCALE_AND_CENTER_X(x) ((SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) ? (x) : (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X((x)))
+#ifdef PROPER_SCALING
+ #ifndef FORCE_PC_SCALING
+ #undef SCREEN_SCALE_Y
+ #define SCREEN_SCALE_Y(a) CDraw::ScaleY(SCREEN_STRETCH_Y(a))
+ #endif
+#endif
#else
#define SCREEN_SCALE_AR(a) (a)
#define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x)
@@ -257,6 +289,22 @@ extern wchar *AllocUnicode(const char*src);
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
+#ifdef __MWERKS__
+#define M_E 2.71828182845904523536 // e
+#define M_LOG2E 1.44269504088896340736 // log2(e)
+#define M_LOG10E 0.434294481903251827651 // log10(e)
+#define M_LN2 0.693147180559945309417 // ln(2)
+#define M_LN10 2.30258509299404568402 // ln(10)
+#define M_PI 3.14159265358979323846 // pi
+#define M_PI_2 1.57079632679489661923 // pi/2
+#define M_PI_4 0.785398163397448309616 // pi/4
+#define M_1_PI 0.318309886183790671538 // 1/pi
+#define M_2_PI 0.636619772367581343076 // 2/pi
+#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
+#define M_SQRT2 1.41421356237309504880 // sqrt(2)
+#define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
+#endif
+
#define PI (float)M_PI
#define TWOPI (PI*2)
#define HALFPI (PI/2)
@@ -286,19 +334,42 @@ void re3_usererror(const char *format, ...);
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
#endif
+#ifdef __MWERKS__
+void debug(char *f, ...);
+void Error(char *f, ...);
+__inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function needs to be inline - this way no call actually gets placed
+// USERERROR only gets used in oal builds ... once
+#else
#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
-#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
+#ifndef MASTER
+#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)
+#else
+#define TRACE(f, ...)
+#define USERERROR(f, ...)
+#endif
+#endif
+#ifndef MASTER
#define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) )
+#else
+#define assert(_Expression)
+#endif
#define ASSERT assert
+#ifdef __MWERKS__
+#define static_assert(bool_constexpr, message)
+#endif
+
#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)
+#ifdef CHECK_STRUCT_SIZES
+template<int s, int t> struct check_size {
+ static_assert(s == t, "Invalid structure size");
+};
+#define VALIDATE_SIZE(struc, size) check_size<sizeof(struc), size> struc ## Check
#else
#define VALIDATE_SIZE(struc, size)
#endif
@@ -317,6 +388,7 @@ void re3_usererror(const char *format, ...);
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
+#ifdef DEBUGMENU
// Tweaking stuff for debugmenu
#define TWEAKPATH ___tw___TWEAKPATH
#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
@@ -430,6 +502,7 @@ _TWEEKCLASS(CTweakUInt32, uint32);
_TWEEKCLASS(CTweakFloat, float);
#undef _TWEEKCLASS
+#endif
#ifdef VALIDATE_SAVE_SIZE
extern int32 _saveBufCount;
diff --git a/src/core/config.h b/src/core/config.h
index 9f4ccd1f..b2c7135a 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -1,5 +1,8 @@
#pragma once
+// disables (most) stuff that wasn't in original gta3.exe - check section at the bottom of this file
+//#define VANILLA_DEFINES
+
enum Config {
NUMPLAYERS = 1, // 4 on PS2
@@ -8,8 +11,11 @@ enum Config {
MAX_CDCHANNELS = 5,
MODELINFOSIZE = 5500, // 3150 on PS2
-// TXDSTORESIZE = 850,
+#if defined __MWERKS__ || defined VANILLA_DEFINES
+ TXDSTORESIZE = 850,
+#else
TXDSTORESIZE = 1024, // for Xbox map
+#endif
EXTRADIRSIZE = 128,
CUTSCENEDIRSIZE = 512,
@@ -226,11 +232,21 @@ enum Config {
# define TIMEBARS // print debug timers
#endif
-#define FIX_BUGS // fixes bugs that we've came across during reversing
+#define FIX_BUGS // fixes bugs that we've came across during reversing. You can undefine this only on release builds.
#define MORE_LANGUAGES // Add more translations to the game
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS
+#if defined(__LP64__) || defined(_WIN64)
+#define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build
+#endif
+
+#define ASCII_STRCMP // use faster ascii str comparisons
+
+#if !defined _WIN32 || defined __MWERKS__ || defined __MINGW32__ || defined VANILLA_DEFINES
+#undef ASCII_STRCMP
+#endif
+
// Just debug menu entries
#ifdef DEBUGMENU
#define MISSION_SWITCHER // from debug menu
@@ -241,19 +257,24 @@ enum Config {
//# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names.
// NB: keep this enabled unless your map IDEs have these flags baked in
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
+#define PROPER_SCALING // use original DEFAULT_SCREEN_WIDTH/DEFAULT_SCREEN_HEIGHT from PS2 instead of PC(R* changed HEIGHT here to make radar look better, but broke other hud elements aspect ratio).
#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 PS2_ALPHA_TEST // emulate ps2 alpha test
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time
#define DISABLE_VSYNC_ON_TEXTURE_CONVERSION // make texture conversion work faster by disabling vsync
+#define ANISOTROPIC_FILTERING // set all textures to max anisotropic filtering
//#define USE_TEXTURE_POOL
#ifdef LIBRW
#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur)
#define EXTENDED_PIPELINES // custom render pipelines (includes Neo)
#define SCREEN_DROPLETS // neo water droplets
+#define NEW_RENDERER // leeds-like world rendering, needs librw
#endif
+#define FIX_SPRITES // fix sprites aspect ratio(moon, coronas, particle etc)
+
#ifndef EXTENDED_COLOURFILTER
#undef SCREEN_DROPLETS // we need the backbuffer for this effect
#endif
@@ -282,6 +303,7 @@ enum Config {
#define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better.
// #define BETA_SLIDING_TEXT
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
+#define FIX_RADAR // use radar size from early version before R* broke it
// #define XBOX_SUBTITLES // the infamous outlines
#define RADIO_OFF_TEXT
#define PC_MENU
@@ -322,6 +344,11 @@ enum Config {
#define USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif
+#ifdef MASTER
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
+#endif
+
// 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!)
@@ -350,8 +377,21 @@ enum Config {
// Audio
#define RADIO_SCROLL_TO_PREV_STATION
#define AUDIO_CACHE
-//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS
+//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
+//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
+#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
+
+#ifdef AUDIO_OPUS
+#define AUDIO_OAL_USE_OPUS // enable support of opus files
+#define OPUS_AUDIO_PATHS // changes audio paths to opus paths (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled)
+#define OPUS_SFX // enable if your sfx.raw is encoded with opus (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled)
+
+#ifndef AUDIO_OAL_USE_OPUS
+#undef OPUS_AUDIO_PATHS
+#undef OPUS_SFX
+#endif
+#endif
// IMG
#define BIG_IMG // allows to read larger img files
@@ -361,8 +401,91 @@ enum Config {
#undef NO_ISLAND_LOADING
#define PC_PARTICLE
#define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial
+ #define VC_RAIN_NERF // Reduces number of rain particles
#endif
-#ifdef LIBRW
-// these are not supported with librw yet
+#if defined __MWERKS__ || defined VANILLA_DEFINES
+#define FINAL
+#undef CHATTYSPLASH
+#undef TIMEBARS
+//#define USE_MY_DOCUMENTS
+
+#define MASTER
+#undef VALIDATE_SAVE_SIZE
+#undef NO_MOVIES
+#undef DEBUGMENU
+
+//#undef NASTY_GAME
+//#undef NO_CDCHECK
+
+#undef DRAW_GAME_VERSION_TEXT
+#undef DRAW_MENU_VERSION_TEXT
+
+#undef GTA_PS2_STUFF
+#undef USE_PS2_RAND
+#undef RANDOMSPLASH
+#undef PS2_MATFX
+
+#undef FIX_BUGS
+#define THIS_IS_STUPID
+#undef MORE_LANGUAGES
+#undef COMPATIBLE_SAVES
+#undef LOAD_INI_SETTINGS
+
+#undef ASPECT_RATIO_SCALE
+#undef PROPER_SCALING
+//#undef DEFAULT_NATIVE_RESOLUTION
+#undef PS2_ALPHA_TEST
+#undef IMPROVED_VIDEOMODE
+#undef DISABLE_LOADING_SCREEN
+#undef DISABLE_VSYNC_ON_TEXTURE_CONVERSION
+#undef ANISOTROPIC_FILTERING
+//#define USE_TEXTURE_POOL // not possible because R* used custom RW33
+
+#undef FIX_SPRITES
+
+#define PC_PARTICLE
+
+#undef XINPUT
+#undef DETECT_PAD_INPUT_SWITCH
+#undef KANGAROO_CHEAT
+#undef ALLCARSHELI_CHEAT
+#undef ALT_DODO_CHEAT
+#undef REGISTER_START_BUTTON
+#undef BIND_VEHICLE_FIREWEAPON
+#undef BUTTON_ICONS
+
+#undef HUD_ENHANCEMENTS
+#undef TRIANGULAR_BLIPS
+#undef FIX_RADAR
+#undef RADIO_OFF_TEXT
+
+#undef MENU_MAP
+#undef SCROLLABLE_STATS_PAGE
+#undef CUSTOM_FRONTEND_OPTIONS
+
+#undef GRAPHICS_MENU_OPTIONS
+#undef NO_ISLAND_LOADING
+#undef CUTSCENE_BORDERS_SWITCH
+#undef MULTISAMPLING
+#undef INVERT_LOOK_FOR_PAD
+
+#undef USE_DEBUG_SCRIPT_LOADER
+#undef USE_MEASUREMENTS_IN_METERS
+#undef USE_PRECISE_MEASUREMENT_CONVERTION
+#undef MISSION_REPLAY
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
+
+#define DONT_FIX_REPLAY_BUGS
+
+#undef EXPLODING_AIRTRAIN
+#undef CAMERA_PICKUP
+#undef PED_SKIN
+#undef ANIMATE_PED_COL_MODEL
+#undef CANCELLABLE_CAR_ENTER
+#undef IMPROVED_CAMERA
+#undef FREE_CAM
+#undef RADIO_SCROLL_TO_PREV_STATION
+#undef BIG_IMG
#endif
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 6e047b19..f1346fc0 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -3,6 +3,9 @@
#include "rphanim.h"
#include "rpskin.h"
#include "rtbmp.h"
+#ifdef ANISOTROPIC_FILTERING
+#include "rpanisot.h"
+#endif
#include "main.h"
#include "CdStream.h"
@@ -121,6 +124,31 @@ bool gbPrintMemoryUsage;
#define FOUND_GAME_TO_LOAD b_FoundRecentSavedGameWantToLoad
#endif
+#ifdef NEW_RENDERER
+bool gbNewRenderer;
+#define CLEARMODE (rwCAMERACLEARZ | rwCAMERACLEARSTENCIL)
+#else
+#define CLEARMODE (rwCAMERACLEARZ)
+#endif
+
+#ifdef __MWERKS__
+void
+debug(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+
+void
+Error(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+#endif
+
void
ValidateVersion()
{
@@ -168,7 +196,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &TopColor.rwRGBA, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &TopColor.rwRGBA, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return false;
@@ -190,7 +218,7 @@ DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return false;
@@ -407,6 +435,9 @@ PluginAttach(void)
return FALSE;
}
+#ifdef ANISOTROPIC_FILTERING
+ RpAnisotPluginAttach();
+#endif
#ifdef EXTENDED_PIPELINES
CustomPipes::CustomPipeRegister();
#endif
@@ -850,6 +881,7 @@ ProcessSlowMode(void)
float FramesPerSecondCounter;
int32 FrameSamples;
+#ifndef MASTER
struct tZonePrint
{
char name[12];
@@ -870,8 +902,6 @@ tZonePrint ZonePrint[] =
{ "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
};
-#ifndef MASTER
-
void
PrintMemoryUsage(void)
{
@@ -1160,9 +1190,126 @@ DisplayGameDebugText()
}
#endif
+#ifdef NEW_RENDERER
+bool gbRenderRoads = true;
+bool gbRenderEverythingBarRoads = true;
+//bool gbRenderFadingInUnderwaterEntities = true;
+bool gbRenderFadingInEntities = true;
+bool gbRenderWater = true;
+bool gbRenderBoats = true;
+bool gbRenderVehicles = true;
+bool gbRenderWorld0 = true;
+bool gbRenderWorld1 = true;
+bool gbRenderWorld2 = true;
+
+void
+MattRenderScene(void)
+{
+ // this calls CMattRenderer::Render
+ /// CWorld::AdvanceCurrentScanCode();
+ // CMattRenderer::ResetRenderStates
+ /// CRenderer::ClearForFrame(); // before ConstructRenderList
+ // CClock::CalcEnvMapTimeMultiplicator
+if(gbRenderWater)
+ CRenderer::RenderWater(); // actually CMattRenderer::RenderWater
+ // CClock::ms_EnvMapTimeMultiplicator = 1.0f;
+ // cWorldStream::ClearDynamics
+ /// CRenderer::ConstructRenderList(); // before PreRender
+if(gbRenderWorld0)
+ CRenderer::RenderWorld(0); // roads
+ // CMattRenderer::ResetRenderStates
+ /// CRenderer::PreRender(); // has to be called before BeginUpdate because of cutscene shadows
+ CCoronas::RenderReflections();
+if(gbRenderWorld1)
+ CRenderer::RenderWorld(1); // opaque
+if(gbRenderRoads)
+ CRenderer::RenderRoads();
+
+ CRenderer::RenderPeds();
+
+if(gbRenderBoats)
+ CRenderer::RenderBoats();
+//if(gbRenderFadingInUnderwaterEntities)
+// CRenderer::RenderFadingInUnderwaterEntities();
+
+if(gbRenderEverythingBarRoads)
+ CRenderer::RenderEverythingBarRoads();
+ // seam fixer
+ // moved this:
+ // CRenderer::RenderFadingInEntities();
+}
+
+void
+RenderScene_new(void)
+{
+ CClouds::Render();
+ DoRWRenderHorizon();
+
+ MattRenderScene();
+ DefinedState();
+ // CMattRenderer::ResetRenderStates
+ // moved CRenderer::RenderBoats to before transparent water
+}
+
+// TODO
+bool FredIsInFirstPersonCam(void) { return false; }
+void
+RenderEffects_new(void)
+{
+ CShadows::RenderStaticShadows();
+ // CRenderer::GenerateEnvironmentMap
+ CShadows::RenderStoredShadows();
+ CSkidmarks::Render();
+ CRubbish::Render();
+
+ // these aren't really effects
+ DefinedState();
+ if(FredIsInFirstPersonCam()){
+ DefinedState();
+ C3dMarkers::Render(); // normally rendered in CSpecialFX::Render()
+if(gbRenderWorld2)
+ CRenderer::RenderWorld(2); // transparent
+if(gbRenderVehicles)
+ CRenderer::RenderVehicles();
+ }else{
+ // flipped these two, seems to give the best result
+if(gbRenderWorld2)
+ CRenderer::RenderWorld(2); // transparent
+if(gbRenderVehicles)
+ CRenderer::RenderVehicles();
+ }
+ // better render these after transparent world
+if(gbRenderFadingInEntities)
+ CRenderer::RenderFadingInEntities();
+
+ // actual effects here
+ CGlass::Render();
+ // CMattRenderer::ResetRenderStates
+ DefinedState();
+ CWeather::RenderRainStreaks();
+ // CWeather::AddSnow
+ CWaterCannons::Render();
+ CAntennas::Render();
+ CSpecialFX::Render();
+ CCoronas::Render();
+ CParticle::Render();
+ CPacManPickups::Render();
+ CWeaponEffects::Render();
+ CPointLights::RenderFogEffect();
+ CMovingThings::Render();
+ CRenderer::RenderFirstPersonVehicle();
+}
+#endif
+
void
RenderScene(void)
{
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ RenderScene_new();
+ return;
+ }
+#endif
CClouds::Render();
DoRWRenderHorizon();
CRenderer::RenderRoads();
@@ -1195,6 +1342,12 @@ RenderDebugShit(void)
void
RenderEffects(void)
{
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ RenderEffects_new();
+ return;
+ }
+#endif
CGlass::Render();
CWaterCannons::Render();
CSpecialFX::Render();
@@ -1390,6 +1543,12 @@ Idle(void *arg)
PUSH_MEMID(MEMID_RENDERLIST);
tbStartTimer(0, "CnstrRenderList");
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ CWorld::AdvanceCurrentScanCode(); // don't think this is even necessary
+ CRenderer::ClearForFrame();
+ }
+#endif
CRenderer::ConstructRenderList();
tbEndTimer("CnstrRenderList");
@@ -1457,7 +1616,7 @@ Idle(void *arg)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
goto popret;
}
@@ -1523,7 +1682,7 @@ FrontendIdle(void)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return;
@@ -1780,7 +1939,7 @@ void TheGame(void)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
RsCameraBeginUpdate(Scene.camera);
}
diff --git a/src/core/main.h b/src/core/main.h
index 149c0878..9f181101 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -45,6 +45,13 @@ void TheModelViewer(void);
#endif
#ifdef LOAD_INI_SETTINGS
-void LoadINISettings();
+bool LoadINISettings();
void SaveINISettings();
+void LoadINIControllerSettings();
+void SaveINIControllerSettings();
+#endif
+
+#ifdef NEW_RENDERER
+extern bool gbNewRenderer;
+bool FredIsInFirstPersonCam(void);
#endif
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 87244e2a..7c780516 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -1,7 +1,6 @@
#include <csignal>
#define WITHWINDOWS
#include "common.h"
-#include "crossplatform.h"
#include "Renderer.h"
#include "Credits.h"
#include "Camera.h"
@@ -31,9 +30,12 @@
#include "custompipes.h"
#include "MemoryHeap.h"
#include "FileMgr.h"
+#include "Camera.h"
+#include "MBlur.h"
+#include "ControllerConfig.h"
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
-#include "ControllerConfig.h"
+#include "crossplatform.h"
#endif
#ifndef _WIN32
@@ -88,16 +90,16 @@ CustomFrontendOptionsPopulate(void)
if (fd) {
#ifdef GRAPHICS_MENU_OPTIONS
FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight");
- FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps");
- FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss");
+ FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight");
+ FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
+ FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#else
FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight");
- FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps");
- FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss");
+ FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight");
+ FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
+ FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#endif
CFileMgr::CloseFile(fd);
}
@@ -110,82 +112,303 @@ CustomFrontendOptionsPopulate(void)
#include "ini_parser.hpp"
linb::ini cfg;
-int CheckAndReadIniInt(const char *cat, const char *key, int original)
+bool ReadIniIfExists(const char *cat, const char *key, uint32 *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtoul(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
+
+bool ReadIniIfExists(const char *cat, const char *key, bool *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtoul(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
+
+bool ReadIniIfExists(const char *cat, const char *key, int32 *out)
{
- std::string strval = cfg.get(cat, key, "");
+ std::string strval = cfg.get(cat, key, "\xBA");
const char *value = strval.c_str();
- if (value && value[0] != '\0')
- return atoi(value);
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtol(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
- return original;
+bool ReadIniIfExists(const char *cat, const char *key, int8 *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtol(value, &endPtr, 0);
+ return true;
+ }
+ return false;
}
-float CheckAndReadIniFloat(const char *cat, const char *key, float original)
+bool ReadIniIfExists(const char *cat, const char *key, float *out)
{
- std::string strval = cfg.get(cat, key, "");
+ std::string strval = cfg.get(cat, key, "\xBA");
const char *value = strval.c_str();
- if (value && value[0] != '\0')
- return atof(value);
+ if (value && value[0] != '\xBA') {
+ *out = atof(value);
+ return true;
+ }
+ return false;
+}
- return original;
+bool ReadIniIfExists(const char *cat, const char *key, char *out, int size)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ if (value && value[0] != '\xBA') {
+ strncpy(out, value, size);
+ return true;
+ }
+ return false;
}
-void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed)
+void StoreIni(const char *cat, const char *key, uint32 val)
{
char temp[10];
- if (atoi(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it
- changed = true;
- sprintf(temp, "%u", val);
- cfg.set(cat, key, temp);
- }
+ sprintf(temp, "%u", val);
+ cfg.set(cat, key, temp);
}
-void CheckAndSaveIniFloat(const char *cat, const char *key, float val, bool &changed)
+void StoreIni(const char *cat, const char *key, uint8 val)
{
char temp[10];
- if (atof(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it
- changed = true;
- sprintf(temp, "%f", val);
- cfg.set(cat, key, temp);
- }
+ sprintf(temp, "%u", (uint32)val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, int32 val)
+{
+ char temp[10];
+ sprintf(temp, "%d", val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, int8 val)
+{
+ char temp[10];
+ sprintf(temp, "%d", (int32)val);
+ cfg.set(cat, key, temp);
}
-void LoadINISettings()
+void StoreIni(const char *cat, const char *key, float val)
{
- cfg.load_file("re3.ini");
+ char temp[10];
+ sprintf(temp, "%f", val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, char *val, int size)
+{
+ cfg.set(cat, key, val);
+}
+
+const char *iniControllerActions[] = { "PED_FIREWEAPON", "PED_CYCLE_WEAPON_RIGHT", "PED_CYCLE_WEAPON_LEFT", "GO_FORWARD", "GO_BACK", "GO_LEFT", "GO_RIGHT", "PED_SNIPER_ZOOM_IN",
+ "PED_SNIPER_ZOOM_OUT", "VEHICLE_ENTER_EXIT", "CAMERA_CHANGE_VIEW_ALL_SITUATIONS", "PED_JUMPING", "PED_SPRINT", "PED_LOOKBEHIND",
+#ifdef BIND_VEHICLE_FIREWEAPON
+ "VEHICLE_FIREWEAPON",
+#endif
+ "VEHICLE_ACCELERATE", "VEHICLE_BRAKE", "VEHICLE_CHANGE_RADIO_STATION", "VEHICLE_HORN", "TOGGLE_SUBMISSIONS", "VEHICLE_HANDBRAKE", "PED_1RST_PERSON_LOOK_LEFT",
+ "PED_1RST_PERSON_LOOK_RIGHT", "VEHICLE_LOOKLEFT", "VEHICLE_LOOKRIGHT", "VEHICLE_LOOKBEHIND", "VEHICLE_TURRETLEFT", "VEHICLE_TURRETRIGHT", "VEHICLE_TURRETUP", "VEHICLE_TURRETDOWN",
+ "PED_CYCLE_TARGET_LEFT", "PED_CYCLE_TARGET_RIGHT", "PED_CENTER_CAMERA_BEHIND_PLAYER", "PED_LOCK_TARGET", "NETWORK_TALK", "PED_1RST_PERSON_LOOK_UP", "PED_1RST_PERSON_LOOK_DOWN",
+ "_CONTROLLERACTION_36", "TOGGLE_DPAD", "SWITCH_DEBUG_CAM_ON", "TAKE_SCREEN_SHOT", "SHOW_MOUSE_POINTER_TOGGLE" };
+const char *iniControllerTypes[] = { "kbd:", "2ndKbd:", "mouse:", "joy:" };
+
+const char *iniMouseButtons[] = {"LEFT","MIDDLE","RIGHT","WHLUP","WHLDOWN","X1","X2"};
+
+const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12",
+ "INS","DEL","HOME","END","PGUP","PGDN","UP","DOWN","LEFT","RIGHT","DIVIDE","TIMES","PLUS","MINUS","PADDEL",
+ "PADEND","PADDOWN","PADPGDN","PADLEFT","PAD5","NUMLOCK","PADRIGHT","PADHOME","PADUP","PADPGUP","PADINS",
+ "PADENTER", "SCROLL","PAUSE","BACKSP","TAB","CAPSLK","ENTER","LSHIFT","RSHIFT","SHIFT","LCTRL","RCTRL","LALT",
+ "RALT", "LWIN", "RWIN", "APPS", "NULL"};
+
+void LoadINIControllerSettings()
+{
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
- // Written by assuming the codes below will run after _InputInitialiseJoys().
- strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str());
-
- if(gSelectedJoystickName[0] != '\0') {
- for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
- if (glfwJoystickPresent(i) && strncmp(gSelectedJoystickName, glfwGetJoystickName(i), strlen(gSelectedJoystickName)) == 0) {
- if (PSGLOBAL(joy1id) != -1) {
- PSGLOBAL(joy2id) = PSGLOBAL(joy1id);
+ ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128);
+#endif
+ // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that
+ if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) {
+ ControlsManager.ms_padButtonsInited = cfg.category_size("Bindings") != 0 ? 16 : 0;
+ }
+
+ for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) {
+ char value[128];
+ if (ReadIniIfExists("Bindings", iniControllerActions[i], value, 128)) {
+ for (int32 j = 0; j < MAX_CONTROLLERTYPES; j++){
+ ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)i, (eControllerType)j);
+ }
+
+ for (char *binding = strtok(value,", "); binding != nil; binding = strtok(nil, ", ")) {
+ int contType = -1;
+ for (int32 k = 0; k < ARRAY_SIZE(iniControllerTypes); k++) {
+ int len = strlen(iniControllerTypes[k]);
+ if (strncmp(binding, iniControllerTypes[k], len) == 0) {
+ contType = k;
+ binding += len;
+ break;
+ }
+ }
+ if (contType == -1)
+ continue;
+
+ int contKey;
+ if (contType == JOYSTICK) {
+ char *temp;
+ contKey = strtol(binding, &temp, 0);
+
+ } else if (contType == KEYBOARD || contType == OPTIONAL_EXTRA) {
+ if (strlen(binding) == 1) {
+ contKey = binding[0];
+ } else if(strcmp(binding, "SPC") == 0) {
+ contKey = ' ';
+ } else {
+ for (int32 k = 0; k < ARRAY_SIZE(iniKeyboardButtons); k++) {
+ if(strcmp(binding, iniKeyboardButtons[k]) == 0) {
+ contKey = 1000 + k;
+ break;
+ }
+ }
+ }
+ } else if (contType == MOUSE) {
+ for (int32 k = 0; k < ARRAY_SIZE(iniMouseButtons); k++) {
+ if(strcmp(binding, iniMouseButtons[k]) == 0) {
+ contKey = 1 + k;
+ break;
+ }
+ }
}
- PSGLOBAL(joy1id) = i;
- int count;
- glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
- // We need to init and reload bindings, because;
- // 1-joypad button number may differ with saved/prvly connected one
- // 2-bindings are not init'ed if there is no joypad at the start
- ControlsManager.InitDefaultControlConfigJoyPad(count);
- CFileMgr::SetDirMyDocuments();
- int32 gta3set = CFileMgr::OpenFile("gta3.set", "r");
- if (gta3set) {
- ControlsManager.LoadSettings(gta3set);
- CFileMgr::CloseFile(gta3set);
+ ControlsManager.SetControllerKeyAssociatedWithAction((e_ControllerAction)i, contKey, (eControllerType)contType);
+ }
+ }
+ }
+}
+
+void SaveINIControllerSettings()
+{
+ for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) {
+ char value[128] = { '\0' };
+
+ // upper limit should've been GetNumOfSettingsForAction(i), but sadly even R* doesn't use it's own system correctly, and there are gaps between orders.
+ for (int32 j = SETORDER_1; j < MAX_SETORDERS; j++){
+
+ // We respect the m_ContSetOrder, and join/implode/order the bindings according to that; using comma as seperator.
+ for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++){
+ if (ControlsManager.m_aSettings[i][k].m_ContSetOrder == j) {
+ char next[32];
+ if (k == JOYSTICK) {
+ snprintf(next, 32, "%s%d,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key);
+
+ } else if (k == KEYBOARD || k == OPTIONAL_EXTRA) {
+ if (ControlsManager.m_aSettings[i][k].m_Key == ' ')
+ snprintf(next, 32, "%sSPC,", iniControllerTypes[k]);
+ else if (ControlsManager.m_aSettings[i][k].m_Key < 256)
+ snprintf(next, 32, "%s%c,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key);
+ else
+ snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniKeyboardButtons[ControlsManager.m_aSettings[i][k].m_Key - 1000]);
+
+ } else if (k == MOUSE) {
+ snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniMouseButtons[ControlsManager.m_aSettings[i][k].m_Key - 1]);
+ }
+ strcat(value, next);
+ break;
}
- CFileMgr::SetDir("");
- break;
}
}
+ int len = strlen(value);
+ if (len > 0)
+ value[len - 1] = '\0'; // to remove comma
+
+ StoreIni("Bindings", iniControllerActions[i], value, 128);
}
+
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+ StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128);
+#endif
+ StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited);
+ cfg.write_file("re3.ini");
+}
+
+bool LoadINISettings()
+{
+ if (!cfg.load_file("re3.ini"))
+ return false;
+
+#ifdef IMPROVED_VIDEOMODE
+ ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth);
+ ReadIniIfExists("VideoMode", "Height", &FrontEndMenuManager.m_nPrefsHeight);
+ ReadIniIfExists("VideoMode", "Depth", &FrontEndMenuManager.m_nPrefsDepth);
+ ReadIniIfExists("VideoMode", "Subsystem", &FrontEndMenuManager.m_nPrefsSubsystem);
+ // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section
+#else
+ ReadIniIfExists("Graphics", "VideoMode", &FrontEndMenuManager.m_nDisplayVideoMode);
+#endif
+ ReadIniIfExists("Controller", "HeadBob1stPerson", &TheCamera.m_bHeadBob);
+ ReadIniIfExists("Controller", "VerticalMouseSens", &TheCamera.m_fMouseAccelVertical);
+ ReadIniIfExists("Controller", "HorizantalMouseSens", &TheCamera.m_fMouseAccelHorzntl);
+ ReadIniIfExists("Controller", "InvertMouseVertically", &MousePointerStateHelper.bInvertVertically);
+ ReadIniIfExists("Controller", "DisableMouseSteering", &CVehicle::m_bDisableMouseSteering);
+ ReadIniIfExists("Audio", "SfxVolume", &FrontEndMenuManager.m_PrefsSfxVolume);
+ ReadIniIfExists("Audio", "MusicVolume", &FrontEndMenuManager.m_PrefsMusicVolume);
+ ReadIniIfExists("Audio", "Radio", &FrontEndMenuManager.m_PrefsRadioStation);
+ ReadIniIfExists("Audio", "SpeakerType", &FrontEndMenuManager.m_PrefsSpeakers);
+ ReadIniIfExists("Audio", "Provider", &FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
+ ReadIniIfExists("Audio", "DynamicAcoustics", &FrontEndMenuManager.m_PrefsDMA);
+ ReadIniIfExists("Display", "Brightness", &FrontEndMenuManager.m_PrefsBrightness);
+ ReadIniIfExists("Display", "DrawDistance", &FrontEndMenuManager.m_PrefsLOD);
+ ReadIniIfExists("Display", "Subtitles", &FrontEndMenuManager.m_PrefsShowSubtitles);
+ ReadIniIfExists("Graphics", "AspectRatio", &FrontEndMenuManager.m_PrefsUseWideScreen);
+ ReadIniIfExists("Graphics", "VSync", &FrontEndMenuManager.m_PrefsVsyncDisp);
+ ReadIniIfExists("Graphics", "FrameLimiter", &FrontEndMenuManager.m_PrefsFrameLimiter);
+ ReadIniIfExists("Graphics", "Trails", &CMBlur::BlurOn);
+ ReadIniIfExists("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256);
+ ReadIniIfExists("Controller", "Method", &FrontEndMenuManager.m_ControlMethod);
+ ReadIniIfExists("General", "Language", &FrontEndMenuManager.m_PrefsLanguage);
+
+#ifdef EXTENDED_COLOURFILTER
+ ReadIniIfExists("CustomPipesValues", "PostFXIntensity", &CPostFX::Intensity);
+#endif
+#ifdef EXTENDED_PIPELINES
+ ReadIniIfExists("CustomPipesValues", "NeoVehicleShininess", &CustomPipes::VehicleShininess);
+ ReadIniIfExists("CustomPipesValues", "NeoVehicleSpecularity", &CustomPipes::VehicleSpecularity);
+ ReadIniIfExists("CustomPipesValues", "RimlightMult", &CustomPipes::RimlightMult);
+ ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult);
+ ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult);
+#endif
+
+#ifdef PROPER_SCALING
+ ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling);
+#endif
+#ifdef FIX_RADAR
+ ReadIniIfExists("Draw", "FixRadar", &CDraw::ms_bFixRadar);
+#endif
+#ifdef FIX_SPRITES
+ ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
+ bool migrate = cfg.category_size("FrontendOptions") != 0;
for (int i = 0; i < MENUPAGES; i++) {
for (int j = 0; j < NUM_MENUROWS; j++) {
CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j];
@@ -195,7 +418,13 @@ void LoadINISettings()
// CFO check
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
// CFO only supports saving uint8 right now
- *option.m_CFO->value = CheckAndReadIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value);
+
+ // Migrate from old .ini to new .ini
+ if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, option.m_CFO->value))
+ cfg.remove("FrontendOptions", option.m_CFO->save);
+ else
+ ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value);
+
if (option.m_Action == MENUACTION_CFO_SELECT) {
option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value;
}
@@ -204,28 +433,61 @@ void LoadINISettings()
}
#endif
-#ifdef EXTENDED_COLOURFILTER
- CPostFX::Intensity = CheckAndReadIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity);
-#endif
-#ifdef EXTENDED_PIPELINES
- CustomPipes::VehicleShininess = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess);
- CustomPipes::VehicleSpecularity = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity);
- CustomPipes::RimlightMult = CheckAndReadIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult);
- CustomPipes::LightmapMult = CheckAndReadIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
- CustomPipes::GlossMult = CheckAndReadIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
-#endif
+ return true;
}
void SaveINISettings()
{
- bool changed = false;
- char temp[4];
+#ifdef IMPROVED_VIDEOMODE
+ StoreIni("VideoMode", "Width", FrontEndMenuManager.m_nPrefsWidth);
+ StoreIni("VideoMode", "Height", FrontEndMenuManager.m_nPrefsHeight);
+ StoreIni("VideoMode", "Depth", FrontEndMenuManager.m_nPrefsDepth);
+ StoreIni("VideoMode", "Subsystem", FrontEndMenuManager.m_nPrefsSubsystem);
+ // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section
+#else
+ StoreIni("Graphics", "VideoMode", FrontEndMenuManager.m_nDisplayVideoMode);
+#endif
+ StoreIni("Controller", "HeadBob1stPerson", TheCamera.m_bHeadBob);
+ StoreIni("Controller", "VerticalMouseSens", TheCamera.m_fMouseAccelVertical);
+ StoreIni("Controller", "HorizantalMouseSens", TheCamera.m_fMouseAccelHorzntl);
+ StoreIni("Controller", "InvertMouseVertically", MousePointerStateHelper.bInvertVertically);
+ StoreIni("Controller", "DisableMouseSteering", CVehicle::m_bDisableMouseSteering);
+ StoreIni("Audio", "SfxVolume", FrontEndMenuManager.m_PrefsSfxVolume);
+ StoreIni("Audio", "MusicVolume", FrontEndMenuManager.m_PrefsMusicVolume);
+ StoreIni("Audio", "Radio", FrontEndMenuManager.m_PrefsRadioStation);
+ StoreIni("Audio", "SpeakerType", FrontEndMenuManager.m_PrefsSpeakers);
+ StoreIni("Audio", "Provider", FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
+ StoreIni("Audio", "DynamicAcoustics", FrontEndMenuManager.m_PrefsDMA);
+ StoreIni("Display", "Brightness", FrontEndMenuManager.m_PrefsBrightness);
+ StoreIni("Display", "DrawDistance", FrontEndMenuManager.m_PrefsLOD);
+ StoreIni("Display", "Subtitles", FrontEndMenuManager.m_PrefsShowSubtitles);
+ StoreIni("Graphics", "AspectRatio", FrontEndMenuManager.m_PrefsUseWideScreen);
+ StoreIni("Graphics", "VSync", FrontEndMenuManager.m_PrefsVsyncDisp);
+ StoreIni("Graphics", "FrameLimiter", FrontEndMenuManager.m_PrefsFrameLimiter);
+ StoreIni("Graphics", "Trails", CMBlur::BlurOn);
+ StoreIni("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256);
+ StoreIni("Controller", "Method", FrontEndMenuManager.m_ControlMethod);
+ StoreIni("General", "Language", FrontEndMenuManager.m_PrefsLanguage);
-#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
- if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) {
- changed = true;
- cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName);
- }
+#ifdef EXTENDED_COLOURFILTER
+ StoreIni("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity);
+#endif
+#ifdef EXTENDED_PIPELINES
+ StoreIni("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess);
+ StoreIni("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity);
+ StoreIni("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult);
+ StoreIni("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
+ StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
+#endif
+
+#ifdef PROPER_SCALING
+ StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling);
+#endif
+#ifdef FIX_RADAR
+ StoreIni("Draw", "FixRadar", CDraw::ms_bFixRadar);
+#endif
+#ifdef FIX_SPRITES
+ StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
for (int i = 0; i < MENUPAGES; i++) {
@@ -236,25 +498,13 @@ void SaveINISettings()
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
// Beware: CFO only supports saving uint8 right now
- CheckAndSaveIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value, changed);
+ StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value);
}
}
}
#endif
-#ifdef EXTENDED_COLOURFILTER
- CheckAndSaveIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity, changed);
-#endif
-#ifdef EXTENDED_PIPELINES
- CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult, changed);
-#endif
-
- if (changed)
- cfg.write_file("re3.ini");
+ cfg.write_file("re3.ini");
}
#endif
@@ -559,6 +809,30 @@ DebugMenuPopulate(void)
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);
+#ifdef NEW_RENDERER
+ DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil);
+extern bool gbRenderRoads;
+extern bool gbRenderEverythingBarRoads;
+//extern bool gbRenderFadingInUnderwaterEntities;
+extern bool gbRenderFadingInEntities;
+extern bool gbRenderWater;
+extern bool gbRenderBoats;
+extern bool gbRenderVehicles;
+extern bool gbRenderWorld0;
+extern bool gbRenderWorld1;
+extern bool gbRenderWorld2;
+ DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil);
+// DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil);
+#endif
+
#ifdef EXTENDED_COLOURFILTER
static const char *filternames[] = { "None", "Simple", "Normal", "Mobile" };
e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_MOBILE, filternames);
@@ -593,6 +867,18 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil);
+
+#ifdef PROPER_SCALING
+ DebugMenuAddVarBool8("Draw", "Proper Scaling", &CDraw::ms_bProperScaling, nil);
+#endif
+#ifdef FIX_RADAR
+ DebugMenuAddVarBool8("Draw", "Fix Radar", &CDraw::ms_bFixRadar, nil);
+#endif
+#ifdef FIX_SPRITES
+ DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil);
+#endif
+
+
#ifndef FINAL
DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil);
@@ -650,7 +936,7 @@ DebugMenuPopulate(void)
"Uzi Money", "Toyminator", "Rigged To Blow", "Bullion Run", "Rumble", "The Exchange"
};
- missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, 79, missions);
+ missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions);
DebugMenuEntrySetWrap(missionEntry, true);
DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission);
#endif
@@ -674,9 +960,13 @@ DebugMenuPopulate(void)
}
#endif
+#ifndef __MWERKS__
+#ifndef MASTER
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
+#endif
+#ifndef MASTER
void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func)
{
#ifdef _WIN32
@@ -730,9 +1020,11 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
assert(false);
#endif
}
+#endif
void re3_debug(const char *format, ...)
{
+#ifndef MASTER
va_list va;
va_start(va, format);
#ifdef _WIN32
@@ -744,8 +1036,10 @@ void re3_debug(const char *format, ...)
printf("%s", re3_buff);
CDebug::DebugAddText(re3_buff);
+#endif
}
+#ifndef MASTER
void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...)
{
char buff[re3_buffsize *2];
@@ -765,7 +1059,9 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons
OutputDebugString(buff);
}
+#endif
+#ifndef MASTER
void re3_usererror(const char *format, ...)
{
va_list va;
@@ -785,6 +1081,8 @@ void re3_usererror(const char *format, ...)
assert(false);
#endif
}
+#endif
+#endif
#ifdef VALIDATE_SAVE_SIZE
int32 _saveBufCount;
diff --git a/src/core/templates.h b/src/core/templates.h
index 3a5b314f..545dac39 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -29,39 +29,59 @@ public:
}
};
+#define POOLFLAG_ID 0x7f
+#define POOLFLAG_ISFREE 0x80
+
template<typename T, typename U = T>
class CPool
{
U *m_entries;
- union Flags {
- struct {
- uint8 id : 7;
- uint8 free : 1;
- };
- uint8 u;
- } *m_flags;
+ uint8 *m_flags;
int32 m_size;
int32 m_allocPtr;
public:
CPool(int32 size){
m_entries = (U*)new uint8[sizeof(U)*size];
- m_flags = (Flags*)new uint8[sizeof(Flags)*size];
+ m_flags = new uint8[size];
m_size = size;
m_allocPtr = 0;
for(int i = 0; i < size; i++){
- m_flags[i].id = 0;
- m_flags[i].free = 1;
+ SetId(i, 0);
+ SetIsFree(i, true);
}
}
+ int GetId(int i) const
+ {
+ return m_flags[i] & POOLFLAG_ID;
+ }
+
+ bool GetIsFree(int i) const
+ {
+ return !!(m_flags[i] & POOLFLAG_ISFREE);
+ }
+
+ void SetId(int i, int id)
+ {
+ m_flags[i] = (m_flags[i] & POOLFLAG_ISFREE) | (id & POOLFLAG_ID);
+ }
+
+ void SetIsFree(int i, bool isFree)
+ {
+ if (isFree)
+ m_flags[i] |= POOLFLAG_ISFREE;
+ else
+ m_flags[i] &= ~POOLFLAG_ISFREE;
+ }
+
~CPool() {
Flush();
}
void Flush() {
if (m_size > 0) {
delete[] (uint8*)m_entries;
- delete[] (uint8*)m_flags;
+ delete[] m_flags;
m_entries = nil;
m_flags = nil;
m_size = 0;
@@ -87,9 +107,9 @@ public:
m_allocPtr = 0;
}
#endif
- while(!m_flags[m_allocPtr].free);
- m_flags[m_allocPtr].free = 0;
- m_flags[m_allocPtr].id++;
+ while(!GetIsFree(m_allocPtr));
+ SetIsFree(m_allocPtr, false);
+ SetId(m_allocPtr, GetId(m_allocPtr)+1);
return (T*)&m_entries[m_allocPtr];
}
T *New(int32 handle){
@@ -99,36 +119,36 @@ public:
}
void SetNotFreeAt(int32 handle){
int idx = handle>>8;
- m_flags[idx].free = 0;
- m_flags[idx].id = handle & 0x7F;
+ SetIsFree(idx, false);
+ SetId(idx, handle & POOLFLAG_ID);
for(m_allocPtr = 0; m_allocPtr < m_size; m_allocPtr++)
- if(m_flags[m_allocPtr].free)
+ if(GetIsFree(m_allocPtr))
return;
}
void Delete(T *entry){
int i = GetJustIndex(entry);
- m_flags[i].free = 1;
+ SetIsFree(i, true);
if(i < m_allocPtr)
m_allocPtr = i;
}
T *GetSlot(int i){
- return m_flags[i].free ? nil : (T*)&m_entries[i];
+ return GetIsFree(i) ? nil : (T*)&m_entries[i];
}
T *GetAt(int handle){
#ifdef FIX_BUGS
if (handle == -1)
return nil;
#endif
- return m_flags[handle>>8].u == (handle & 0xFF) ?
+ return m_flags[handle>>8] == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
int32 GetIndex(T *entry){
int i = GetJustIndex_NoFreeAssert(entry);
- return m_flags[i].u + (i<<8);
+ return m_flags[i] + (i<<8);
}
int32 GetJustIndex(T *entry){
int index = GetJustIndex_NoFreeAssert(entry);
- assert(!IsFreeSlot(index));
+ assert(!GetIsFree(index));
return index;
}
int32 GetJustIndex_NoFreeAssert(T* entry){
@@ -140,13 +160,12 @@ public:
int i;
int n = 0;
for(i = 0; i < m_size; i++)
- if(!m_flags[i].free)
+ if(!GetIsFree(i))
n++;
return n;
}
- bool IsFreeSlot(int i) { return !!m_flags[i].free; }
void ClearStorage(uint8 *&flags, U *&entries){
- delete[] (uint8*)flags;
+ delete[] flags;
delete[] (uint8*)entries;
flags = nil;
entries = nil;
@@ -155,7 +174,7 @@ public:
void CopyBack(uint8 *&flags, U *&entries){
memcpy(m_flags, flags, sizeof(uint8)*m_size);
memcpy(m_entries, entries, sizeof(U)*m_size);
- debug("Size copied:%d (%d)\n", sizeof(U)*m_size, sizeof(Flags)*m_size);
+ debug("Size copied:%d (%d)\n", sizeof(U)*m_size, m_size);
m_allocPtr = 0;
ClearStorage(flags, entries);
debug("CopyBack:%d (/%d)\n", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */