summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Fire.cpp2
-rw-r--r--src/core/Frontend.cpp98
-rw-r--r--src/core/Frontend.h29
-rw-r--r--src/core/Game.cpp6
-rw-r--r--src/core/IniFile.cpp4
-rw-r--r--src/core/IniFile.h3
-rw-r--r--src/core/MenuScreensCustom.cpp27
-rw-r--r--src/core/Pools.cpp10
-rw-r--r--src/core/Zones.cpp78
-rw-r--r--src/core/config.h191
-rw-r--r--src/core/re3.cpp135
11 files changed, 352 insertions, 231 deletions
diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp
index 984b21bb..8b184622 100644
--- a/src/core/Fire.cpp
+++ b/src/core/Fire.cpp
@@ -396,7 +396,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt
if (target) {
if (target->IsPed()) {
ped->m_pFire = fire;
- if (target != (CVehicle *)FindPlayerPed()) {
+ if (target != FindPlayerPed()) {
CVector2D pos = target->GetPosition();
ped->SetFlee(pos, 10000);
ped->SetMoveAnim();
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 7ff80697..ecb893b4 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -336,6 +336,7 @@ const char* MenuFilenames[][2] = {
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); \
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+// value must be between 0.0-1.0
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \
lastActiveBarX = DisplaySlider(MENU_X_RIGHT_ALIGNED(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \
@@ -489,7 +490,7 @@ CMenuManager::ThingsToDoBeforeGoingBack()
option.m_CFODynamic->buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS);
if (option.m_Action == MENUACTION_CFO_SELECT && option.m_CFOSelect->onlyApplyOnEnter && option.m_CFOSelect->lastSavedValue != option.m_CFOSelect->displayedValue)
- option.m_CFOSelect->displayedValue = *option.m_CFO->value = option.m_CFOSelect->lastSavedValue;
+ option.m_CFOSelect->displayedValue = *(int8*)option.m_CFO->value = option.m_CFOSelect->lastSavedValue;
if (aScreens[m_nCurrScreen].returnPrevPageFunc) {
aScreens[m_nCurrScreen].returnPrevPageFunc();
@@ -898,29 +899,29 @@ CMenuManager::CheckSliderMovement(int value)
{
switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) {
case MENUACTION_BRIGHTNESS:
- m_PrefsBrightness += value * (512/16);
+ m_PrefsBrightness += value * (512/MENUSLIDER_LOGICAL_BARS);
m_PrefsBrightness = Clamp(m_PrefsBrightness, 0, 511);
break;
case MENUACTION_DRAWDIST:
if(value > 0)
- m_PrefsLOD += ((1.8f - 0.8f) / 16.0f);
+ m_PrefsLOD += ((1.8f - 0.8f) / MENUSLIDER_LOGICAL_BARS);
else
- m_PrefsLOD -= ((1.8f - 0.8f) / 16.0f);
+ m_PrefsLOD -= ((1.8f - 0.8f) / MENUSLIDER_LOGICAL_BARS);
m_PrefsLOD = Clamp(m_PrefsLOD, 0.8f, 1.8f);
CRenderer::ms_lodDistScale = m_PrefsLOD;
break;
case MENUACTION_MUSICVOLUME:
- m_PrefsMusicVolume += value * (128/16);
+ m_PrefsMusicVolume += value * (128/MENUSLIDER_LOGICAL_BARS);
m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 127);
DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume);
break;
case MENUACTION_SFXVOLUME:
- m_PrefsSfxVolume += value * (128/16);
+ m_PrefsSfxVolume += value * (128/MENUSLIDER_LOGICAL_BARS);
m_PrefsSfxVolume = Clamp(m_PrefsSfxVolume, 0, 127);
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
break;
case MENUACTION_MOUSESENS:
- TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ???
+ TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // probably because diving it to 15 instead of 16(MENUSLIDER_LOGICAL_BARS) had more accurate steps
TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
@@ -928,6 +929,20 @@ CMenuManager::CheckSliderMovement(int value)
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl;
#endif
break;
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ case MENUACTION_CFO_SLIDER:
+ {
+ CMenuScreenCustom::CMenuEntry &option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption];
+ float oldValue = *(float*)option.m_CFOSlider->value;
+ *(float*)option.m_CFOSlider->value += value * ((option.m_CFOSlider->max - option.m_CFOSlider->min) / MENUSLIDER_LOGICAL_BARS);
+ *(float*)option.m_CFOSlider->value = Clamp(*(float*)option.m_CFOSlider->value, option.m_CFOSlider->min, option.m_CFOSlider->max);
+
+ if (*(float*)option.m_CFOSlider->value != oldValue && option.m_CFOSlider->changeFunc)
+ option.m_CFOSlider->changeFunc(oldValue, *(float*)option.m_CFOSlider->value);
+
+ break;
+ }
+#endif
default:
return;
}
@@ -1001,10 +1016,10 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR
int lastActiveBarX = 0;
float curBarX = 0.0f;
float spacing = SCREEN_SCALE_X(10.0f);
- for (int i = 0; i < 16; i++) {
- curBarX = i * rectSize/16.0f + x;
+ for (int i = 0; i < MENUSLIDER_BARS; i++) {
+ curBarX = i * rectSize/MENUSLIDER_BARS + x;
- if (i / 16.0f + 1 / 32.0f < progress) {
+ if (i / (float)MENUSLIDER_BARS + 1 / (MENUSLIDER_BARS * 2.f) < progress) {
color = CRGBA(SLIDERON_COLOR.r, SLIDERON_COLOR.g, SLIDERON_COLOR.b, FadeIn(255));
lastActiveBarX = curBarX;
} else
@@ -1012,7 +1027,7 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR
maxBarHeight = Max(mostLeftBarSize, mostRightBarSize);
- float curBarFreeSpace = ((16 - i) * mostLeftBarSize + i * mostRightBarSize) / 16.0f;
+ float curBarFreeSpace = ((MENUSLIDER_BARS - i) * mostLeftBarSize + i * mostRightBarSize) / (float)MENUSLIDER_BARS;
float left = curBarX;
float top = y + maxBarHeight - curBarFreeSpace;
float right = spacing + curBarX;
@@ -1595,10 +1610,10 @@ CMenuManager::Draw()
// If that was previously selected option, restore it to default value.
// if (m_nCurrOption != lastSelectedOpt && lastSelectedOpt == i)
- option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *option.m_CFO->value;
+ option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *(int8*)option.m_CFO->value;
} else {
- if (option.m_CFOSelect->displayedValue != *option.m_CFO->value)
+ if (option.m_CFOSelect->displayedValue != *(int8*)option.m_CFO->value)
SetHelperText(1); // Enter to apply
else if (m_nHelperTextMsgId == 1)
ResetHelperText(); // Applied
@@ -1606,8 +1621,8 @@ CMenuManager::Draw()
}
// To whom manipulate option.m_CFO->value of select options externally (like RestoreDef functions)
- if (*option.m_CFO->value != option.m_CFOSelect->lastSavedValue)
- option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *option.m_CFO->value;
+ if (*(int8*)option.m_CFO->value != option.m_CFOSelect->lastSavedValue)
+ option.m_CFOSelect->displayedValue = option.m_CFOSelect->lastSavedValue = *(int8*)option.m_CFO->value;
if (option.m_CFOSelect->displayedValue >= option.m_CFOSelect->numRightTexts || option.m_CFOSelect->displayedValue < 0)
option.m_CFOSelect->displayedValue = 0;
@@ -1799,6 +1814,12 @@ CMenuManager::Draw()
case MENUACTION_MOUSESENS:
ProcessSlider(TheCamera.m_fMouseAccelHorzntl * 200.0f, HOVEROPTION_INCREASE_MOUSESENS, HOVEROPTION_DECREASE_MOUSESENS, MENU_X_LEFT_ALIGNED(200.0f), SCREEN_WIDTH);
break;
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ case MENUACTION_CFO_SLIDER:
+ CMenuScreenCustom::CMenuEntry &option = aScreens[m_nCurrScreen].m_aEntries[i];
+ ProcessSlider((*(float*)option.m_CFOSlider->value - option.m_CFOSlider->min) / (option.m_CFOSlider->max - option.m_CFOSlider->min), HOVEROPTION_INCREASE_CFO_SLIDER, HOVEROPTION_DECREASE_CFO_SLIDER, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH);
+ break;
+#endif
}
// Needed after the bug fix in Font.cpp
@@ -4477,7 +4498,7 @@ CMenuManager::ProcessButtonPresses(void)
#ifndef TIDY_UP_PBP
switch (m_nHoverOption) {
case HOVEROPTION_INCREASE_BRIGHTNESS:
- m_PrefsBrightness = m_PrefsBrightness + 32;
+ m_PrefsBrightness = m_PrefsBrightness + (512 / MENUSLIDER_LOGICAL_BARS);
if (m_PrefsBrightness < 0) {
m_PrefsBrightness = 0;
}
@@ -4487,7 +4508,7 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_DECREASE_BRIGHTNESS:
- m_PrefsBrightness = m_PrefsBrightness - 32;
+ m_PrefsBrightness = m_PrefsBrightness - (512 / MENUSLIDER_LOGICAL_BARS);
if (m_PrefsBrightness < 0) {
m_PrefsBrightness = 0;
}
@@ -4497,25 +4518,25 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_INCREASE_DRAWDIST:
- m_PrefsLOD = m_PrefsLOD + (1.0f / 16);
+ m_PrefsLOD = m_PrefsLOD + (1.0f / MENUSLIDER_LOGICAL_BARS);
m_PrefsLOD = min(1.8f, m_PrefsLOD);
CRenderer::ms_lodDistScale = m_PrefsLOD;
SaveSettings();
break;
case HOVEROPTION_DECREASE_DRAWDIST:
- m_PrefsLOD = m_PrefsLOD - (1.0f / 16);
+ m_PrefsLOD = m_PrefsLOD - (1.0f / MENUSLIDER_LOGICAL_BARS);
m_PrefsLOD = max(0.8f, m_PrefsLOD);
CRenderer::ms_lodDistScale = m_PrefsLOD;
SaveSettings();
break;
case HOVEROPTION_INCREASE_MUSICVOLUME:
- m_PrefsMusicVolume = m_PrefsMusicVolume + 8;
+ m_PrefsMusicVolume = m_PrefsMusicVolume + (128 / MENUSLIDER_LOGICAL_BARS);
m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 127);
DMAudio.SetMusicMasterVolume(uchar)(m_PrefsMusicVolume);
SaveSettings();
break;
case HOVEROPTION_DECREASE_MUSICVOLUME:
- m_PrefsMusicVolume = m_PrefsMusicVolume - 8;
+ m_PrefsMusicVolume = m_PrefsMusicVolume - (128 / MENUSLIDER_LOGICAL_BARS);
if (m_PrefsMusicVolume < 0) {
m_PrefsMusicVolume = 0;
}
@@ -4526,7 +4547,7 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_INCREASE_SFXVOLUME:
- m_PrefsSFXVolume = m_PrefsSFXVolume + 8;
+ m_PrefsSFXVolume = m_PrefsSFXVolume + (128 / MENUSLIDER_LOGICAL_BARS);
if (m_PrefsSFXVolume < 0) {
m_PrefsSFXVolume = 0;
}
@@ -4537,7 +4558,7 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_DECREASE_SFXVOLUME:
- m_PrefsSFXVolume = m_PrefsSFXVolume - 8;
+ m_PrefsSFXVolume = m_PrefsSFXVolume - (128 / MENUSLIDER_LOGICAL_BARS);
if (m_PrefsSFXVolume < 0) {
m_PrefsSFXVolume = 0;
}
@@ -4548,7 +4569,7 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_INCREASE_MOUSESENS:
- TheCamera.m_fMouseAccelHorzntl += (1.0f / 3000);
+ TheCamera.m_fMouseAccelHorzntl += 1.0f/200.0f/15.0f; // probably because diving it to 15 instead of 16(MENUSLIDER_LOGICAL_BARS) had more accurate steps
TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
@@ -4558,7 +4579,7 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
break;
case HOVEROPTION_DECREASE_MOUSESENS:
- TheCamera.m_fMouseAccelHorzntl -= (1.0f / 3000);
+ TheCamera.m_fMouseAccelHorzntl -= 1.0f/200.0f/15.0f; // probably because diving it to 15 instead of 16(MENUSLIDER_LOGICAL_BARS) had more accurate steps
TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
@@ -4575,6 +4596,9 @@ CMenuManager::ProcessButtonPresses(void)
case HOVEROPTION_INCREASE_MUSICVOLUME:
case HOVEROPTION_INCREASE_SFXVOLUME:
case HOVEROPTION_INCREASE_MOUSESENS:
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ case HOVEROPTION_INCREASE_CFO_SLIDER:
+#endif
CheckSliderMovement(1);
break;
case HOVEROPTION_DECREASE_BRIGHTNESS:
@@ -4582,6 +4606,9 @@ CMenuManager::ProcessButtonPresses(void)
case HOVEROPTION_DECREASE_MUSICVOLUME:
case HOVEROPTION_DECREASE_SFXVOLUME:
case HOVEROPTION_DECREASE_MOUSESENS:
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ case HOVEROPTION_DECREASE_CFO_SLIDER:
+#endif
CheckSliderMovement(-1);
break;
}
@@ -4612,7 +4639,11 @@ CMenuManager::ProcessButtonPresses(void)
|| CPad::GetPad(0)->GetAnaloguePadLeftJustUp() || CPad::GetPad(0)->GetAnaloguePadRightJustUp()
|| CPad::GetPad(0)->GetMouseWheelUpJustDown() || CPad::GetPad(0)->GetMouseWheelDownJustDown()) {
int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action;
- if (option == MENUACTION_BRIGHTNESS || option == MENUACTION_DRAWDIST)
+ if (option == MENUACTION_BRIGHTNESS || option == MENUACTION_DRAWDIST
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ || option == MENUACTION_CFO_SLIDER
+#endif
+ )
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
else if (option == MENUACTION_SFXVOLUME)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_AUDIO_TEST, 0);
@@ -4775,7 +4806,12 @@ CMenuManager::ProcessButtonPresses(void)
} else if (option != MENUACTION_CHANGEMENU && option != MENUACTION_BRIGHTNESS && option != MENUACTION_DRAWDIST
&& option != MENUACTION_MUSICVOLUME && option != MENUACTION_SFXVOLUME
&& option != MENUACTION_CHECKSAVE && option != MENUACTION_UNK24
- && option != MENUACTION_MOUSESENS && option != MENUACTION_SCREENRES) {
+ && option != MENUACTION_MOUSESENS && option != MENUACTION_SCREENRES
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ && option != MENUACTION_CFO_SLIDER
+#endif
+ )
+ {
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
}
@@ -5166,9 +5202,9 @@ CMenuManager::ProcessButtonPresses(void)
if (option.m_CFOSelect->displayedValue >= option.m_CFOSelect->numRightTexts || option.m_CFOSelect->displayedValue < 0)
option.m_CFOSelect->displayedValue = 0;
}
- int8 oldValue = *option.m_CFO->value;
+ int8 oldValue = *(int8*)option.m_CFO->value;
- *option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
+ *(int8*)option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
// Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
// if (option.m_CFOSelect->save)
@@ -5412,9 +5448,9 @@ CMenuManager::ProcessButtonPresses(void)
option.m_CFOSelect->displayedValue = option.m_CFOSelect->numRightTexts - 1;
}
if (!option.m_CFOSelect->onlyApplyOnEnter) {
- int8 oldValue = *option.m_CFO->value;
+ int8 oldValue = *(int8*)option.m_CFO->value;
- *option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
+ *(int8*)option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
// Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
// if (option.m_CFOSelect->save)
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 5c3523ab..32e5ef9d 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -25,6 +25,9 @@
#define MENUSLIDER_X 256.0f
#define MENUSLIDER_UNK 256.0f
+#define MENUSLIDER_BARS 16
+#define MENUSLIDER_LOGICAL_BARS MENUSLIDER_BARS
+
#define BIGTEXT_X_SCALE 0.75f // For FONT_HEADING
#define BIGTEXT_Y_SCALE 0.9f
#define MEDIUMTEXT_X_SCALE 0.55f // For FONT_HEADING
@@ -256,6 +259,7 @@ enum eMenuScreen
enum eMenuAction
{
#ifdef CUSTOM_FRONTEND_OPTIONS
+ MENUACTION_CFO_SLIDER = -3,
MENUACTION_CFO_SELECT = -2,
MENUACTION_CFO_DYNAMIC = -1,
#endif
@@ -424,6 +428,10 @@ enum eCheckHover
HOVEROPTION_DECREASE_SFXVOLUME,
HOVEROPTION_INCREASE_MOUSESENS,
HOVEROPTION_DECREASE_MOUSESENS,
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ HOVEROPTION_INCREASE_CFO_SLIDER,
+ HOVEROPTION_DECREASE_CFO_SLIDER,
+#endif
HOVEROPTION_NOT_HOVERING,
};
@@ -493,7 +501,7 @@ struct CCustomScreenLayout {
struct CCFO
{
- int8 *value;
+ void *value;
const char *saveCat;
const char *save;
};
@@ -524,6 +532,24 @@ struct CCFOSelect : CCFO
}
};
+// Value is float in here
+struct CCFOSlider : CCFO
+{
+ ChangeFuncFloat changeFunc;
+ float min;
+ float max;
+
+ CCFOSlider() {};
+ CCFOSlider(float* value, const char* saveCat, const char* save, float min, float max, ChangeFuncFloat changeFunc = nil){
+ this->value = value;
+ this->saveCat = saveCat;
+ this->save = save;
+ this->changeFunc = changeFunc;
+ this->min = min;
+ this->max = max;
+ }
+};
+
struct CCFODynamic : CCFO
{
DrawFunc drawFunc;
@@ -555,6 +581,7 @@ struct CMenuScreenCustom
CCFO *m_CFO; // for initializing
CCFOSelect *m_CFOSelect;
CCFODynamic *m_CFODynamic;
+ CCFOSlider *m_CFOSlider;
};
int32 m_SaveSlot; // eSaveSlot
int32 m_TargetMenu; // eMenuScreen
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index f6156a4c..b3dd1eda 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -409,7 +409,11 @@ bool CGame::Initialise(const char* datFile)
#endif
#ifndef GTA_PS2
- CIniFile::LoadIniFile();
+#ifdef PED_CAR_DENSITY_SLIDERS
+ // Load density values from gta3.ini only if our re3.ini have them 1.f
+ if (CIniFile::PedNumberMultiplier == 1.f && CIniFile::CarNumberMultiplier == 1.f)
+#endif
+ CIniFile::LoadIniFile();
#endif
currLevel = LEVEL_INDUSTRIAL;
diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp
index df01b440..524632fe 100644
--- a/src/core/IniFile.cpp
+++ b/src/core/IniFile.cpp
@@ -23,6 +23,6 @@ void CIniFile::LoadIniFile()
CarNumberMultiplier = Min(3.0f, Max(0.5f, CarNumberMultiplier));
CFileMgr::CloseFile(f);
}
- CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier;
- CCarCtrl::MaxNumberOfCarsInUse = 12.0f * CarNumberMultiplier;
+ CPopulation::MaxNumberOfPedsInUse = DEFAULT_MAX_NUMBER_OF_PEDS * PedNumberMultiplier;
+ CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS * CarNumberMultiplier;
} \ No newline at end of file
diff --git a/src/core/IniFile.h b/src/core/IniFile.h
index 1e30c4de..30dc8c21 100644
--- a/src/core/IniFile.h
+++ b/src/core/IniFile.h
@@ -1,5 +1,8 @@
#pragma once
+#define DEFAULT_MAX_NUMBER_OF_PEDS 25.0f
+#define DEFAULT_MAX_NUMBER_OF_CARS 12.0f
+
class CIniFile
{
public:
diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp
index 6e23f76a..033ed9b9 100644
--- a/src/core/MenuScreensCustom.cpp
+++ b/src/core/MenuScreensCustom.cpp
@@ -26,6 +26,9 @@
#include "ModelInfo.h"
#include "Pad.h"
#include "ControllerConfig.h"
+#include "IniFile.h"
+#include "CarCtrl.h"
+#include "Population.h"
// Menu screens array is at the bottom of the file.
@@ -63,6 +66,15 @@
#define DUALPASS_SELECTOR
#endif
+#ifdef PED_CAR_DENSITY_SLIDERS
+ // 0.2f - 3.4f makes it possible to have 1.0f somewhere inbetween
+ #define DENSITY_SLIDERS \
+ MENUACTION_CFO_SLIDER, "FEM_PED", { new CCFOSlider(&CIniFile::PedNumberMultiplier, "Display", "PedDensity", 0.2f, 3.4f, PedDensityChange) }, \
+ MENUACTION_CFO_SLIDER, "FEM_CAR", { new CCFOSlider(&CIniFile::CarNumberMultiplier, "Display", "CarDensity", 0.2f, 3.4f, CarDensityChange) },
+#else
+ #define DENSITY_SLIDERS
+#endif
+
#ifdef NO_ISLAND_LOADING
#define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsIslandLoading, "Graphics", "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) },
#else
@@ -145,6 +157,9 @@ void RestoreDefDisplay(int8 action) {
#ifdef FREE_CAM
TheCamera.bFreeCam = false;
#endif
+ #ifdef PED_CAR_DENSITY_SLIDERS
+ CIniFile::LoadIniFile();
+ #endif
#ifdef GRAPHICS_MENU_OPTIONS // otherwise Frontend will handle those
CMenuManager::m_PrefsBrightness = 256;
CMenuManager::m_PrefsLOD = 1.2f;
@@ -195,6 +210,16 @@ void IslandLoadingAfterChange(int8 before, int8 after) {
}
#endif
+#ifdef PED_CAR_DENSITY_SLIDERS
+void PedDensityChange(float before, float after) {
+ CPopulation::MaxNumberOfPedsInUse = DEFAULT_MAX_NUMBER_OF_PEDS * after;
+}
+
+void CarDensityChange(float before, float after) {
+ CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS * after;
+}
+#endif
+
#ifndef MULTISAMPLING
void GraphicsGoBack() {
}
@@ -423,6 +448,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
{ "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil,
MENUACTION_BRIGHTNESS, "FED_BRI", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_DRAWDIST, "FEM_LOD", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
+ DENSITY_SLIDERS
MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_FRAMELIMIT, "FEM_FRM", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#ifndef EXTENDED_COLOURFILTER
@@ -447,6 +473,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
{ "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil,
MENUACTION_BRIGHTNESS, "FED_BRI", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_DRAWDIST, "FEM_LOD", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
+ DENSITY_SLIDERS
CUTSCENE_BORDERS_TOGGLE
FREE_CAM_TOGGLE
MENUACTION_SUBTITLES, "FED_SUB", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 5cffe9e4..b0248664 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -281,9 +281,9 @@ INITSAVEBUF
#else
if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
#endif
- WriteSaveBuf<uint32>(buf, pVehicle->m_vehType);
- WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex());
- WriteSaveBuf<int32>(buf, GetVehicleRef(pVehicle));
+ WriteSaveBuf(buf, pVehicle->m_vehType);
+ WriteSaveBuf(buf, pVehicle->GetModelIndex());
+ WriteSaveBuf(buf, GetVehicleRef(pVehicle));
pVehicle->Save(buf);
}
#else
@@ -292,7 +292,7 @@ INITSAVEBUF
#else
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
#endif
- WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
+ WriteSaveBuf(buf, pVehicle->m_vehType);
WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CAutomobile));
@@ -303,7 +303,7 @@ INITSAVEBUF
#else
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
#endif
- WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
+ WriteSaveBuf(buf, pVehicle->m_vehType);
WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CBoat));
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 107b1db8..82fbc047 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -10,6 +10,14 @@
#include "Timer.h"
#include "SaveBuf.h"
+#ifdef COMPATIBLE_SAVES
+#define ZONEARRAY_SAVE_SIZE 0xAF0
+#define MAPZONEARRAY_SAVE_SIZE 0x578
+#else
+#define ZONEARRAY_SAVE_SIZE sizeof(ZoneArray)
+#define MAPZONEARRAY_SAVE_SIZE sizeof(MapZoneArray)
+#endif
+
eLevelName CTheZones::m_CurrLevel;
CZone *CTheZones::m_pPlayersZone;
int16 CTheZones::FindIndex;
@@ -633,6 +641,28 @@ CTheZones::InitialiseAudioZoneArray(void)
}
}
+#ifdef COMPATIBLE_SAVES
+static inline void
+SaveOneZone(CZone &zone, uint8 *&buffer)
+{
+ memcpy(buffer, zone.name, sizeof(zone.name));
+ SkipSaveBuf(buffer, sizeof(zone.name));
+ WriteSaveBuf(buffer, zone.minx);
+ WriteSaveBuf(buffer, zone.miny);
+ WriteSaveBuf(buffer, zone.minz);
+ WriteSaveBuf(buffer, zone.maxx);
+ WriteSaveBuf(buffer, zone.maxy);
+ WriteSaveBuf(buffer, zone.maxz);
+ WriteSaveBuf(buffer, zone.type);
+ WriteSaveBuf(buffer, zone.level);
+ WriteSaveBuf(buffer, zone.zoneinfoDay);
+ WriteSaveBuf(buffer, zone.zoneinfoNight);
+ WriteSaveBuf(buffer, (int32)CTheZones::GetIndexForZonePointer(zone.child));
+ WriteSaveBuf(buffer, (int32)CTheZones::GetIndexForZonePointer(zone.parent));
+ WriteSaveBuf(buffer, (int32)CTheZones::GetIndexForZonePointer(zone.next));
+}
+#endif
+
void
CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
{
@@ -643,9 +673,9 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
+ sizeof(int32) // GetIndexForZonePointer
+ sizeof(m_CurrLevel) + sizeof(FindIndex)
+ sizeof(int16) // padding
- + sizeof(ZoneArray) + sizeof(ZoneInfoArray)
+ + ZONEARRAY_SAVE_SIZE + sizeof(ZoneInfoArray)
+ sizeof(TotalNumberOfZones) + sizeof(TotalNumberOfZoneInfos)
- + sizeof(MapZoneArray) + sizeof(AudioZoneArray)
+ + MAPZONEARRAY_SAVE_SIZE + sizeof(AudioZoneArray)
+ sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones);
WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
@@ -656,10 +686,14 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
WriteSaveBuf(buffer, (int16)0); // padding
for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){
+#ifdef COMPATIBLE_SAVES
+ SaveOneZone(ZoneArray[i], buffer);
+#else
CZone *zone = WriteSaveBuf(buffer, ZoneArray[i]);
zone->child = (CZone*)GetIndexForZonePointer(ZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(ZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(ZoneArray[i].next);
+#endif
}
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
@@ -669,7 +703,9 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
WriteSaveBuf(buffer, TotalNumberOfZoneInfos);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) {
+#ifndef COMPATIBLE_SAVES
CZone* zone = WriteSaveBuf(buffer, MapZoneArray[i]);
+#endif
/*
The call of GetIndexForZonePointer is wrong, as it is
@@ -679,9 +715,13 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
assert(MapZoneArray[i].child == nil);
assert(MapZoneArray[i].parent == nil);
assert(MapZoneArray[i].next == nil);
+#ifndef COMPATIBLE_SAVES
zone->child = (CZone*)GetIndexForZonePointer(MapZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(MapZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(MapZoneArray[i].next);
+#else
+ SaveOneZone(MapZoneArray[i], buffer);
+#endif
}
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
@@ -693,6 +733,32 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
VALIDATESAVEBUF(*size)
}
+#ifdef COMPATIBLE_SAVES
+static inline void
+LoadOneZone(CZone &zone, uint8 *&buffer)
+{
+ memcpy(zone.name, buffer, sizeof(zone.name));
+ SkipSaveBuf(buffer, sizeof(zone.name));
+ ReadSaveBuf(&zone.minx, buffer);
+ ReadSaveBuf(&zone.miny, buffer);
+ ReadSaveBuf(&zone.minz, buffer);
+ ReadSaveBuf(&zone.maxx, buffer);
+ ReadSaveBuf(&zone.maxy, buffer);
+ ReadSaveBuf(&zone.maxz, buffer);
+ ReadSaveBuf(&zone.type, buffer);
+ ReadSaveBuf(&zone.level, buffer);
+ ReadSaveBuf(&zone.zoneinfoDay, buffer);
+ ReadSaveBuf(&zone.zoneinfoNight, buffer);
+ int32 tmp;
+ ReadSaveBuf(&tmp, buffer);
+ zone.child = CTheZones::GetPointerForZoneIndex(tmp);
+ ReadSaveBuf(&tmp, buffer);
+ zone.parent = CTheZones::GetPointerForZoneIndex(tmp);
+ ReadSaveBuf(&tmp, buffer);
+ zone.next = CTheZones::GetPointerForZoneIndex(tmp);
+}
+#endif
+
void
CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
{
@@ -708,11 +774,15 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){
+#ifdef COMPATIBLE_SAVES
+ LoadOneZone(ZoneArray[i], buffer);
+#else
ReadSaveBuf(&ZoneArray[i], buffer);
ZoneArray[i].child = GetPointerForZoneIndex((uintptr)ZoneArray[i].child);
ZoneArray[i].parent = GetPointerForZoneIndex((uintptr)ZoneArray[i].parent);
ZoneArray[i].next = GetPointerForZoneIndex((uintptr)ZoneArray[i].next);
+#endif
}
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
@@ -722,6 +792,9 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
ReadSaveBuf(&TotalNumberOfZoneInfos, buffer);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){
+#ifdef COMPATIBLE_SAVES
+ LoadOneZone(MapZoneArray[i], buffer);
+#else
ReadSaveBuf(&MapZoneArray[i], buffer);
/*
@@ -732,6 +805,7 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
MapZoneArray[i].child = GetPointerForZoneIndex((uintptr)MapZoneArray[i].child);
MapZoneArray[i].parent = GetPointerForZoneIndex((uintptr)MapZoneArray[i].parent);
MapZoneArray[i].next = GetPointerForZoneIndex((uintptr)MapZoneArray[i].next);
+#endif
assert(MapZoneArray[i].child == nil);
assert(MapZoneArray[i].parent == nil);
assert(MapZoneArray[i].next == nil);
diff --git a/src/core/config.h b/src/core/config.h
index 298b2a1a..2abaec13 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -1,7 +1,9 @@
#pragma once
-// disables (most) stuff that wasn't in original gta3.exe - check section at the bottom of this file
-//#define VANILLA_DEFINES
+// disables (most) stuff that wasn't in original gta3.exe
+#ifdef __MWERKS__
+#define VANILLA_DEFINES
+#endif
enum Config {
NUMPLAYERS = 1, // 4 on PS2
@@ -11,7 +13,7 @@ enum Config {
MAX_CDCHANNELS = 5,
MODELINFOSIZE = 5500, // 3150 on PS2
-#if defined __MWERKS__ || defined VANILLA_DEFINES
+#ifdef VANILLA_DEFINES
TXDSTORESIZE = 850,
#else
TXDSTORESIZE = 1024, // for Xbox map
@@ -146,8 +148,30 @@ enum Config {
//#define GTA_PS2
//#define GTA_XBOX
-// This enables things from the PS2 version on PC
-#define GTA_PS2_STUFF
+// Version defines
+#define GTA3_PS2_140 300
+#define GTA3_PS2_160 301
+#define GTA3_PC_10 310
+#define GTA3_PC_11 311
+#define GTA3_PC_STEAM 312
+// TODO? maybe something for xbox or android?
+
+#define GTA_VERSION GTA3_PC_11
+
+#if defined GTA_PS2
+# define GTA_PS2_STUFF
+# define RANDOMSPLASH
+# define USE_CUSTOM_ALLOCATOR
+# define VU_COLLISION
+# define ANIM_COMPRESSION
+# define PS2_MENU
+#elif defined GTA_PC
+# define PC_PLAYER_CONTROLS // mouse player/cam mode
+# define GTA_REPLAY
+# define GTA_SCENE_EDIT
+# define PC_MENU
+#elif defined GTA_XBOX
+#endif
// This is enabled for all released games.
// any debug stuff that isn't left in any game is not in FINAL
@@ -166,19 +190,29 @@ enum Config {
#define FINAL
#endif
-// Version defines
-#define GTA3_PS2_140 300
-#define GTA3_PS2_160 301
-#define GTA3_PC_10 310
-#define GTA3_PC_11 311
-#define GTA3_PC_STEAM 312
-// TODO? maybe something for xbox or android?
+// these are placed here to work with VANILLA_DEFINES for compatibility
+#define NO_CDCHECK // skip audio CD check
+#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
-#define GTA_VERSION GTA3_PC_11
+#ifdef VANILLA_DEFINES
+#if !defined(_WIN32) || defined(__LP64__) || defined(_WIN64)
+#error Vanilla can only be built for win-x86
+#endif
+
+#define FINAL
+#define MASTER
+//#define USE_MY_DOCUMENTS
+#define THIS_IS_STUPID
+#define PC_PARTICLE
+#define DONT_FIX_REPLAY_BUGS
+#define USE_TXD_CDIMAGE // generate and load textures from txd.img
+//#define USE_TEXTURE_POOL // not possible because R* used custom RW33
+#else
+// This enables things from the PS2 version on PC
+#define GTA_PS2_STUFF
// quality of life fixes that should also be in FINAL
#define NASTY_GAME // nasty game for all languages
-#define NO_CDCHECK
// those infamous texts
#define DRAW_GAME_VERSION_TEXT
@@ -194,22 +228,10 @@ enum Config {
//#define COMPRESSED_COL_VECTORS // use compressed vectors for collision vertices
//#define ANIM_COMPRESSION // only keep most recently used anims uncompressed
-#if defined GTA_PS2
-# define GTA_PS2_STUFF
-# define RANDOMSPLASH
-# define USE_CUSTOM_ALLOCATOR
-# define VU_COLLISION
-# define ANIM_COMPRESSION
-#elif defined GTA_PC
-# ifdef GTA_PS2_STUFF
-# define USE_PS2_RAND
-# define RANDOMSPLASH // use random splash as on PS2
-# define PS2_MATFX
-# endif
-# define PC_PLAYER_CONTROLS // mouse player/cam mode
-# define GTA_REPLAY
-# define GTA_SCENE_EDIT
-#elif defined GTA_XBOX
+#if defined GTA_PC && defined GTA_PS2_STUFF
+# define USE_PS2_RAND
+# define RANDOMSPLASH // use random splash as on PS2
+# define PS2_MATFX
#endif
#ifdef VU_COLLISION
@@ -237,7 +259,8 @@ enum Config {
#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 COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible, and keeps saves compatible between platforms, needs to be enabled on 64bit builds!
+#define FIX_INCOMPATIBLE_SAVES // try to fix incompatible saves, requires COMPATIBLE_SAVES
#define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS
#define NO_MOVIES // add option to disable intro videos
@@ -248,7 +271,7 @@ enum Config {
#define ASCII_STRCMP // use faster ascii str comparisons
-#if !defined _WIN32 || defined __MWERKS__ || defined __MINGW32__ || defined VANILLA_DEFINES
+#if !defined _WIN32 || defined __MINGW32__
#undef ASCII_STRCMP
#endif
@@ -340,6 +363,7 @@ enum Config {
# define CUTSCENE_BORDERS_SWITCH
# define MULTISAMPLING // adds MSAA option
# define INVERT_LOOK_FOR_PAD // add bInvertLook4Pad from VC
+# define PED_CAR_DENSITY_SLIDERS
# endif
#endif
@@ -385,7 +409,7 @@ enum Config {
// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
-//#define PEDS_REPORT_CRIMES_ON_PHONE, requires COMPATIBLE_SAVES
+//#define PEDS_REPORT_CRIMES_ON_PHONE // requires COMPATIBLE_SAVES
// Camera
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
@@ -396,7 +420,7 @@ enum Config {
#define RADIO_SCROLL_TO_PREV_STATION
#define AUDIO_CACHE
#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 44 (PC has 28 originally)
-//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
+#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
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
@@ -437,101 +461,4 @@ enum Config {
#undef PEDS_REPORT_CRIMES_ON_PHONE
#endif
-// -------
-
-#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 EXTENDED_COLOURFILTER
-#undef EXTENDED_PIPELINES
-#undef SCREEN_DROPLETS
-#undef NEW_RENDERER
-
-#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 GAMEPAD_MENU
-#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 AUDIO_CACHE
-#undef PS2_AUDIO_CHANNELS
-#undef PAUSE_RADIO_IN_FRONTEND
-#undef MULTITHREADED_AUDIO
-#undef BIG_IMG
-#endif
+#endif // VANILLA_DEFINES
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index fe0347d9..b7d89363 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -41,6 +41,9 @@
#include "Camera.h"
#include "MBlur.h"
#include "ControllerConfig.h"
+#include "CarCtrl.h"
+#include "Population.h"
+#include "IniFile.h"
#ifdef DETECT_JOYSTICK_MENU
#include "crossplatform.h"
@@ -179,16 +182,29 @@ CustomFrontendOptionsPopulate(void)
#endif
#ifdef LOAD_INI_SETTINGS
-#include "ini_parser.hpp"
+#define MINI_CASE_SENSITIVE
+#include "ini.h"
+
+mINI::INIFile ini("re3.ini");
+mINI::INIStructure cfg;
-linb::ini cfg;
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);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtoul(section.get(key).c_str(), &endPtr, 0);
+ return true;
+ }
+ return false;
+}
+
+bool ReadIniIfExists(const char *cat, const char *key, uint8 *out)
+{
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtoul(section.get(key).c_str(), &endPtr, 0);
return true;
}
return false;
@@ -196,11 +212,10 @@ bool ReadIniIfExists(const char *cat, const char *key, uint32 *out)
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);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtoul(section.get(key).c_str(), &endPtr, 0);
return true;
}
return false;
@@ -208,11 +223,10 @@ bool ReadIniIfExists(const char *cat, const char *key, bool *out)
bool ReadIniIfExists(const char *cat, const char *key, int32 *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);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtol(section.get(key).c_str(), &endPtr, 0);
return true;
}
return false;
@@ -220,11 +234,10 @@ bool ReadIniIfExists(const char *cat, const char *key, int32 *out)
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);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtol(section.get(key).c_str(), &endPtr, 0);
return true;
}
return false;
@@ -232,10 +245,10 @@ bool ReadIniIfExists(const char *cat, const char *key, int8 *out)
bool ReadIniIfExists(const char *cat, const char *key, float *out)
{
- std::string strval = cfg.get(cat, key, "\xBA");
- const char *value = strval.c_str();
- if (value && value[0] != '\xBA') {
- *out = atof(value);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ char *endPtr;
+ *out = strtof(section.get(key).c_str(), &endPtr);
return true;
}
return false;
@@ -243,10 +256,10 @@ bool ReadIniIfExists(const char *cat, const char *key, float *out)
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);
+ mINI::INIMap<std::string> section = cfg.get(cat);
+ if (section.has(key)) {
+ strncpy(out, section.get(key).c_str(), size - 1);
+ out[size - 1] = '\0';
return true;
}
return false;
@@ -254,42 +267,42 @@ bool ReadIniIfExists(const char *cat, const char *key, char *out, int size)
void StoreIni(const char *cat, const char *key, uint32 val)
{
- char temp[10];
+ char temp[11];
sprintf(temp, "%u", val);
- cfg.set(cat, key, temp);
+ cfg[cat][key] = temp;
}
void StoreIni(const char *cat, const char *key, uint8 val)
{
- char temp[10];
- sprintf(temp, "%u", (uint32)val);
- cfg.set(cat, key, temp);
+ char temp[11];
+ sprintf(temp, "%u", val);
+ cfg[cat][key] = temp;
}
void StoreIni(const char *cat, const char *key, int32 val)
{
- char temp[10];
+ char temp[11];
sprintf(temp, "%d", val);
- cfg.set(cat, key, temp);
+ cfg[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);
+ char temp[11];
+ sprintf(temp, "%d", val);
+ cfg[cat][key] = temp;
}
void StoreIni(const char *cat, const char *key, float val)
{
- char temp[10];
+ char temp[50];
sprintf(temp, "%f", val);
- cfg.set(cat, key, temp);
+ cfg[cat][key] = temp;
}
void StoreIni(const char *cat, const char *key, char *val, int size)
{
- cfg.set(cat, key, val);
+ cfg[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",
@@ -351,7 +364,7 @@ void LoadINIControllerSettings()
#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;
+ ControlsManager.ms_padButtonsInited = cfg.get("Bindings").size() != 0 ? 16 : 0;
}
for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) {
@@ -453,12 +466,13 @@ void SaveINIControllerSettings()
#endif
#endif
StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited);
- cfg.write_file("re3.ini");
+
+ ini.write(cfg);
}
bool LoadINISettings()
{
- if (!cfg.load_file("re3.ini"))
+ if (!ini.read(cfg))
return false;
#ifdef IMPROVED_VIDEOMODE
@@ -524,7 +538,7 @@ bool LoadINISettings()
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
- bool migrate = cfg.category_size("FrontendOptions") != 0;
+ bool migrate = cfg.get("FrontendOptions").size() != 0;
for (int i = 0; i < MENUPAGES; i++) {
for (int j = 0; j < NUM_MENUROWS; j++) {
CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j];
@@ -533,22 +547,29 @@ bool LoadINISettings()
// CFO check
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
- // CFO only supports saving uint8 right now
-
// 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);
+ // Old values can only be int8, new ones can contain float if it is slider
+ if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, (int8*)option.m_CFO->value))
+ cfg["FrontendOptions"].remove(option.m_CFO->save);
+ else if (option.m_Action == MENUACTION_CFO_SLIDER)
+ ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, (float*)option.m_CFO->value);
else
- ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value);
+ ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, (int8*)option.m_CFO->value);
if (option.m_Action == MENUACTION_CFO_SELECT) {
- option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value;
+ option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *(int8*)option.m_CFO->value;
}
}
}
}
#endif
+ // Fetched in above block, but needs evaluation
+#ifdef PED_CAR_DENSITY_SLIDERS
+ CPopulation::MaxNumberOfPedsInUse = DEFAULT_MAX_NUMBER_OF_PEDS * CIniFile::PedNumberMultiplier;
+ CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS * CIniFile::CarNumberMultiplier;
+#endif
+
return true;
}
@@ -623,14 +644,16 @@ void SaveINISettings()
break;
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
- // Beware: CFO only supports saving uint8 right now
- StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value);
+ if (option.m_Action == MENUACTION_CFO_SLIDER)
+ StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *(float*)option.m_CFO->value);
+ else
+ StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *(int8*)option.m_CFO->value);
}
}
}
#endif
- cfg.write_file("re3.ini");
+ ini.write(cfg);
}
#endif