From f85b5e99edfb2e1b9a4563cacc96892195eee379 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 16 Jan 2021 16:44:59 +0300 Subject: [PATCH 01/15] Includes overhaul, fix some compiler warnings --- src/audio/AudioLogic.cpp | 2 +- src/audio/PoliceRadio.cpp | 1 + src/audio/PoliceRadio.h | 2 +- src/audio/sampman.h | 1 - src/audio/sampman_miles.cpp | 6 ++--- src/audio/sampman_oal.cpp | 35 ++++++++++++------------- src/collision/TempColModels.cpp | 1 + src/collision/TempColModels.h | 2 +- src/control/Garages.h | 3 +-- src/control/Script.h | 4 +-- src/control/Script3.cpp | 1 + src/control/Script4.cpp | 1 + src/core/ControllerConfig.cpp | 8 ++---- src/core/Frontend.cpp | 6 +---- src/core/Game.cpp | 5 ---- src/core/Lists.h | 2 -- src/core/Pad.cpp | 9 +------ src/core/PlayerInfo.h | 2 +- src/core/World.cpp | 5 ---- src/core/World.h | 6 +---- src/core/Zones.h | 4 +-- src/core/common.h | 39 +++++++++++++++++----------- src/core/re3.cpp | 5 +++- src/extras/custompipes.cpp | 2 +- src/extras/custompipes_d3d9.cpp | 2 +- src/extras/postfx.cpp | 3 +-- src/extras/screendroplets.cpp | 2 +- src/fakerw/fake.cpp | 2 +- src/modelinfo/BaseModelInfo.cpp | 1 + src/modelinfo/BaseModelInfo.h | 2 +- src/modelinfo/ModelInfo.h | 3 +-- src/modelinfo/PedModelInfo.h | 1 + src/peds/Ped.cpp | 1 + src/peds/Ped.h | 2 +- src/render/MBlur.cpp | 1 - src/render/Renderer.cpp | 2 +- src/render/WaterCreatures.cpp | 2 +- src/rw/RwHelper.cpp | 2 -- src/save/MemoryCard.cpp | 1 + src/skel/glfw/glfw.cpp | 45 +++++++++++++-------------------- src/skel/win/win.cpp | 19 ++++++-------- src/vehicles/Automobile.cpp | 1 + src/vehicles/Bike.h | 1 + src/vehicles/Boat.cpp | 1 + src/vehicles/Vehicle.h | 6 ++--- 45 files changed, 110 insertions(+), 142 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 7d759279..c58daaaf 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -41,7 +41,7 @@ #include "WindModifiers.h" #include "Fluff.h" #include "Script.h" - +#include "Wanted.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index cf6f5bee..e174e587 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -13,6 +13,7 @@ #include "World.h" #include "Zones.h" #include "sampman.h" +#include "Wanted.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h index e9a0fde0..d7c928e2 100644 --- a/src/audio/PoliceRadio.h +++ b/src/audio/PoliceRadio.h @@ -1,6 +1,6 @@ #pragma once -#include "Wanted.h" +#include "Crime.h" struct cAMCrime { int32 type; diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 2db29244..5d7d39af 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #include "AudioSamples.h" #define MAX_VOLUME 127 diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index c360d64f..2d6a655e 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,8 +1,5 @@ -#include "common.h" - #ifdef AUDIO_MSS -#include -#include +#include #include #include @@ -11,6 +8,7 @@ #include "eax-util.h" #include "mss.h" +#include "common.h" #include "sampman.h" #include "AudioManager.h" #include "MusicManager.h" diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 5fe05d54..0d06098d 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1,17 +1,11 @@ //#define JUICY_OAL #ifdef AUDIO_OAL -#include "sampman.h" - #include #include "eax.h" #include "eax-util.h" -#define WITHWINDOWS -#include "common.h" -#include "crossplatform.h" - #ifdef _WIN32 #include #include @@ -19,8 +13,24 @@ #include #include #include + +// for user MP3s +#include +#include +#include +#else +#define _getcwd getcwd #endif +#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK +#pragma comment( lib, "OpenAL32.lib" ) +#endif + +#include "common.h" +#include "crossplatform.h" + +#include "sampman.h" + #include "oal/oal_utils.h" #include "oal/aldlist.h" #include "oal/channel.h" @@ -38,19 +48,6 @@ //TODO: max channels //TODO: loop count -#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK -#pragma comment( lib, "OpenAL32.lib" ) -#endif - -// for user MP3s -#ifdef _WIN32 -#include -#include -#include -#else -#define _getcwd getcwd -#endif - cSampleManager SampleManager; bool _bSampmanInitialised = false; diff --git a/src/collision/TempColModels.cpp b/src/collision/TempColModels.cpp index f8b26450..0c0d4376 100644 --- a/src/collision/TempColModels.cpp +++ b/src/collision/TempColModels.cpp @@ -1,6 +1,7 @@ #include "common.h" #include "TempColModels.h" +#include "Game.h" CColModel CTempColModels::ms_colModelPed1; CColModel CTempColModels::ms_colModelPed2; diff --git a/src/collision/TempColModels.h b/src/collision/TempColModels.h index 0c936d6f..1a888723 100644 --- a/src/collision/TempColModels.h +++ b/src/collision/TempColModels.h @@ -1,6 +1,6 @@ #pragma once -#include "Collision.h" +#include "ColModel.h" class CTempColModels { diff --git a/src/control/Garages.h b/src/control/Garages.h index 3d12d4a2..39327e4e 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -1,11 +1,10 @@ #pragma once -#include "Automobile.h" #include "audio_enums.h" #include "Camera.h" #include "config.h" +#include "Lists.h" class CVehicle; -class CCamera; enum eGarageState { diff --git a/src/control/Script.h b/src/control/Script.h index ae984c59..a45e11cf 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,7 +1,5 @@ #pragma once -#include "common.h" #include "Font.h" -#include "Ped.h" #include "PedType.h" #include "Text.h" #include "Sprite2d.h" @@ -38,9 +36,11 @@ void FlushLog(); #define SPHERE_MARKER_PULSE_FRACTION 0.1f #ifdef USE_PRECISE_MEASUREMENT_CONVERTION +#define MILES_IN_METER (0.000621371192f) #define METERS_IN_FOOT (0.3048f) #define FEET_IN_METER (3.28084f) #else +#define MILES_IN_METER (1 / 1670.f) #define METERS_IN_FOOT (0.3f) #define FEET_IN_METER (3.33f) #endif diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index aba06d03..1ac18fa8 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -34,6 +34,7 @@ #include "Zones.h" #include "GameLogic.h" #include "Bike.h" +#include "Wanted.h" int8 CRunningScript::ProcessCommands500To599(int32 command) { diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 51dc14d3..9830f0dc 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -39,6 +39,7 @@ #include "World.h" #include "Zones.h" #include "Bike.h" +#include "Wanted.h" #ifdef FIX_BUGS static bool IsSlideObjectUsedWrongByScript(const CVector& posTarget, const CVector& slideBy) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index eea1f6f0..585eac4e 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 -#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" diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index f8945d98..086a9887 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 -#endif - #define FORCE_PC_SCALING #define WITHWINDOWS +#define WITHDINPUT #include "common.h" #ifndef PS2_MENU #include "crossplatform.h" diff --git a/src/core/Game.cpp b/src/core/Game.cpp index c407bbe8..83d30bb4 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" @@ -69,7 +65,6 @@ #include "Skidmarks.h" #include "SetPieces.h" #include "SpecialFX.h" -#include "Sprite2d.h" #include "Stats.h" #include "Streaming.h" #include "SurfaceTable.h" 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/Pad.cpp b/src/core/Pad.cpp index 60ff3555..671a4552 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 -#endif -#pragma warning( pop ) - +#define WITHDINPUT #include "common.h" #include "crossplatform.h" #include "platform.h" diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index a3896ebb..a24185f0 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/World.cpp b/src/core/World.cpp index f7d2a28b..bc698c83 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,11 +11,8 @@ #include "Glass.h" #include "Messages.h" #include "ModelIndices.h" -#include "Object.h" #include "ParticleObject.h" -#include "Ped.h" #include "Pickups.h" -#include "PlayerPed.h" #include "Population.h" #include "ProjectileInfo.h" #include "Record.h" @@ -25,7 +21,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 59bf634c..81eb5d4c 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 -2400 to 1600 in x and -2000 to 2000 y. * With 80x80 sectors, each is 50x50 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.h b/src/core/Zones.h index 5306d9f1..b987f009 100644 --- a/src/core/Zones.h +++ b/src/core/Zones.h @@ -103,8 +103,8 @@ public: static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity); static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup); static int16 FindAudioZone(CVector *pos); - static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &NavigationZoneArray[i]; } - static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; } + static CZone *GetPointerForZoneIndex(ssize_t i) { return i == -1 ? nil : &NavigationZoneArray[i]; } + static ssize_t GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; } 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 2391f5fb..7fdbdf69 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,17 +11,34 @@ #include #include -#if defined _WIN32 && defined WITHWINDOWS +#if !defined RW_D3D9 && defined LIBRW +#undef WITHD3D +#undef WITHDINPUT +#endif + +#if (defined WITHD3D && !defined LIBRW) +#define WITHWINDOWS +#endif + +#if defined _WIN32 && defined WITHWINDOWS && !defined _INC_WINDOWS #include #endif -#if defined _WIN32 && defined WITHD3D -#include -#ifndef USE_D3D9 -#include -#else -#include +#ifdef WITHD3D + #ifdef LIBRW + #define WITH_D3D // librw includes d3d9 itself via this right now + #else + #ifndef USE_D3D9 + #include + #else + #include + #endif + #endif #endif + +#ifdef WITHDINPUT +#define DIRECTINPUT_VERSION 0x0800 +#include #endif #include @@ -52,14 +69,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)) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 80e8cb6b..7b3ab10c 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,7 +1,6 @@ #include #define WITHWINDOWS #include "common.h" -#include "crossplatform.h" #include "Renderer.h" #include "Occlusion.h" #include "Credits.h" @@ -39,6 +38,10 @@ #include "ControllerConfig.h" #endif +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#include "crossplatform.h" +#endif + #ifndef _WIN32 #include "assert.h" #include diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index 2cecf1c0..a485138e 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -1,4 +1,4 @@ -#define WITH_D3D +#define WITHD3D #include "common.h" #ifdef EXTENDED_PIPELINES diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index d0984ffe..d7634e99 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -1,4 +1,4 @@ -#define WITH_D3D +#define WITHD3D #include "common.h" #ifdef RW_D3D9 diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp index 2ea08141..03010267 100644 --- a/src/extras/postfx.cpp +++ b/src/extras/postfx.cpp @@ -1,5 +1,4 @@ -#define WITHWINDOWS -#define WITH_D3D +#define WITHD3D #include "common.h" #ifdef EXTENDED_COLOURFILTER diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index ac3a17b2..74c44da0 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -1,4 +1,4 @@ -#define WITH_D3D +#define WITHD3D #include "common.h" #ifdef SCREEN_DROPLETS diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp index 4a8a945d..18a27ec1 100644 --- a/src/fakerw/fake.cpp +++ b/src/fakerw/fake.cpp @@ -1,5 +1,5 @@ #define _CRT_SECURE_NO_WARNINGS -#define WITH_D3D +#define WITH_D3D // not WITHD3D, so it's librw define #include #include #include diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp index 966ffb38..d0f868fa 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -5,6 +5,7 @@ #include "2dEffect.h" #include "BaseModelInfo.h" #include "ModelInfo.h" +#include "ColModel.h" CBaseModelInfo::CBaseModelInfo(ModelInfoType type) { diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index 18e84c21..2d1dc8ac 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -1,6 +1,6 @@ #pragma once -#include "Collision.h" +struct CColModel; #define MAX_MODEL_NAME (21) diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index 1ac7b0bb..30f4c015 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -1,14 +1,13 @@ #pragma once #include "2dEffect.h" -#include "BaseModelInfo.h" #include "SimpleModelInfo.h" #include "TimeModelInfo.h" #include "WeaponModelInfo.h" #include "ClumpModelInfo.h" #include "PedModelInfo.h" #include "VehicleModelInfo.h" -#include "Instance.h" +#include "templates.h" class CModelInfo { diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index 86e6b74a..79bd7eaa 100644 --- a/src/modelinfo/PedModelInfo.h +++ b/src/modelinfo/PedModelInfo.h @@ -1,6 +1,7 @@ #pragma once #include "ClumpModelInfo.h" +#include "ColModel.h" #include "PedType.h" enum PedNode { diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 22b03cce..6a3df18b 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -38,6 +38,7 @@ #include "WindModifiers.h" #include "CutsceneShadow.h" #include "Clock.h" +#include "Wanted.h" CPed *gapTempPedList[50]; uint16 gnNumTempPedList; diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 05b8914e..8b091d15 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -9,8 +9,8 @@ #include "Physical.h" #include "Weapon.h" #include "WeaponInfo.h" -#include "AnimationId.h" #include "PathFind.h" +#include "Collision.h" #define FEET_OFFSET 1.04f #define CHECK_NEARBY_THINGS_MAX_DIST 15.0f diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 205f9d92..a94a5245 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -1,4 +1,3 @@ -#define WITHWINDOWS #ifndef LIBRW #define WITHD3D #endif diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 7522f832..8c4714fb 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1,4 +1,4 @@ -#define WITH_D3D +#define WITHD3D #include "common.h" #include "main.h" diff --git a/src/render/WaterCreatures.cpp b/src/render/WaterCreatures.cpp index d3bd2701..01f241b3 100644 --- a/src/render/WaterCreatures.cpp +++ b/src/render/WaterCreatures.cpp @@ -1,10 +1,10 @@ +#include "common.h" #include "WaterCreatures.h" #include "ModelIndices.h" #include "World.h" #include "WaterLevel.h" #include "Camera.h" #include "PlayerPed.h" -#include "config.h" #include "General.h" int CWaterCreatures::nNumActiveSeaLifeForms; diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index d3fbd1d0..609dd79b 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -1,6 +1,4 @@ -#if defined RW_D3D9 || defined RWLIBS #define WITHD3D -#endif #include "common.h" #include "Timecycle.h" diff --git a/src/save/MemoryCard.cpp b/src/save/MemoryCard.cpp index c8ebcd86..d6e95d33 100644 --- a/src/save/MemoryCard.cpp +++ b/src/save/MemoryCard.cpp @@ -1,6 +1,7 @@ #define WITHWINDOWS #include "common.h" #ifdef PS2_MENU +#include "crossplatform.h" #include "MemoryCard.h" #include "main.h" #include "DMAudio.h" diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 3154ad99..8c9289d2 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1,22 +1,30 @@ #if defined RW_GL3 && !defined LIBRW_SDL2 #ifdef _WIN32 -#include +#include +#include #include +#include #include #include -#include -#include -#include + +DWORD _dwOperatingSystemVersion; +#include "resource.h" +#else +long _dwOperatingSystemVersion; +#ifndef __APPLE__ +#include +#else +#include +#include +#endif +#include +#include +#include +#include #endif -#define WITHWINDOWS #include "common.h" - -#pragma warning( push ) -#pragma warning( disable : 4005) -#pragma warning( pop ) - #if (defined(_MSC_VER)) #include #endif /* (defined(_MSC_VER)) */ @@ -72,23 +80,6 @@ static psGlobalType PsGlobal; size_t _dwMemAvailPhys; RwUInt32 gGameState; -#ifdef _WIN32 -DWORD _dwOperatingSystemVersion; -#include "resource.h" -#else -long _dwOperatingSystemVersion; -#ifndef __APPLE__ -#include -#else -#include -#include -#endif -#include -#include -#include -#include -#endif - #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS char gSelectedJoystickName[128] = ""; #endif diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 84a010de..242a3fe2 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2,7 +2,6 @@ #define _WIN32_WINDOWS 0x0500 #define WINVER 0x0500 -#define DIRECTINPUT_VERSION 0x0800 #include #include @@ -20,13 +19,7 @@ #pragma warning( push ) #pragma warning( disable : 4005) -#ifdef USE_D3D9 -#include -#else -#include -#endif #include -#include #include #pragma warning( pop ) @@ -41,6 +34,9 @@ #pragma comment( lib, "strmiids.lib" ) #pragma comment( lib, "dinput8.lib" ) +#define WITHD3D +#define WITHDINPUT +#include "common.h" #if (defined(_MSC_VER)) #include #endif /* (defined(_MSC_VER)) */ @@ -81,7 +77,6 @@ static psGlobalType PsGlobal; #define JIF(x) if (FAILED(hr=(x))) \ {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} -#include "common.h" #include "main.h" #include "FileMgr.h" #include "Text.h" @@ -92,12 +87,14 @@ static psGlobalType PsGlobal; #include "Frontend.h" #include "Game.h" #include "PCSave.h" -#include "MemoryCard.h" -#include "Sprite2d.h" #include "AnimViewer.h" -#include "Font.h" #include "MemoryMgr.h" +#ifdef PS2_MENU +#include "MemoryCard.h" +#include "Font.h" +#endif + VALIDATE_SIZE(psGlobalType, 0x28); // DirectShow interfaces diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 8a5426ed..961b8108 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -49,6 +49,7 @@ #include "Object.h" #include "Automobile.h" #include "Bike.h" +#include "Wanted.h" bool bAllCarCheat; diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 3fcf66a2..219d8872 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -2,6 +2,7 @@ #include "Vehicle.h" #include "Skidmarks.h" +#include "AnimManager.h" enum eBikeNodes { BIKE_NODE_NONE, diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index adaab72c..5aed5814 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -27,6 +27,7 @@ #include "RpAnimBlend.h" #include "Record.h" #include "Shadows.h" +#include "Wanted.h" #define INVALID_ORIENTATION (-9999.99f) diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 7388bfab..4a361215 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -3,15 +3,15 @@ #include "Physical.h" #include "AutoPilot.h" #include "ModelIndices.h" -#include "AnimManager.h" -#include "Weapon.h" +#include "AnimationId.h" +#include "WeaponType.h" +#include "Collision.h" #include "HandlingMgr.h" class CPed; class CPlayerPed; class CCopPed; class CFire; -struct tHandlingData; enum { RANDOM_VEHICLE = 1, From 6b54d04bfc79141c4f751875641dec61da18f3f7 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 02:51:26 +0200 Subject: [PATCH 02/15] LCS model indices --- src/control/Garages.cpp | 83 ++-- src/core/World.cpp | 63 +-- src/modelinfo/ModelIndices.cpp | 16 +- src/modelinfo/ModelIndices.h | 869 +++++++++++++++++++++++++++++---- src/vehicles/Cranes.cpp | 14 +- 5 files changed, 862 insertions(+), 183 deletions(-) diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index de536918..db920fed 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1825,7 +1825,7 @@ void CGarage::FindDoorsEntities() } } if (m_pDoor1 && m_pDoor2) { - if (m_pDoor1->GetModelIndex() != MI_LCS_GARAGEDOOR39 && m_pDoor1->GetModelIndex() != MI_LCS_GARAGEDOOR40) { + if (m_pDoor1->GetModelIndex() != MI_CRUSHERBODY && m_pDoor1->GetModelIndex() != MI_CRUSHERLID) { CVector2D vecDoor1ToGarage(m_pDoor1->GetPosition().x - GetGarageCenterX(), m_pDoor1->GetPosition().y - GetGarageCenterY()); CVector2D vecDoor2ToGarage(m_pDoor2->GetPosition().x - GetGarageCenterX(), m_pDoor2->GetPosition().y - GetGarageCenterY()); if (DotProduct2D(vecDoor1ToGarage, vecDoor2ToGarage) > 0.0f) { @@ -2409,44 +2409,45 @@ void CGarages::Load(uint8* buf, uint32 size) bool CGarages::IsModelIndexADoor(uint32 id) { - return id == MI_LCS_GARAGEDOOR01 || - id == MI_LCS_GARAGEDOOR02 || - id == MI_LCS_GARAGEDOOR03 || - id == MI_LCS_GARAGEDOOR04 || - id == MI_LCS_GARAGEDOOR05 || - id == MI_LCS_GARAGEDOOR06 || - id == MI_LCS_GARAGEDOOR07 || - id == MI_LCS_GARAGEDOOR08 || - id == MI_LCS_GARAGEDOOR09 || - id == MI_LCS_GARAGEDOOR10 || - id == MI_LCS_GARAGEDOOR11 || - id == MI_LCS_GARAGEDOOR12 || - id == MI_LCS_GARAGEDOOR13 || - id == MI_LCS_GARAGEDOOR14 || - id == MI_LCS_GARAGEDOOR15 || - id == MI_LCS_GARAGEDOOR16 || - id == MI_LCS_GARAGEDOOR17 || - id == MI_LCS_GARAGEDOOR18 || - id == MI_LCS_GARAGEDOOR19 || - id == MI_LCS_GARAGEDOOR20 || - id == MI_LCS_GARAGEDOOR21 || - id == MI_LCS_GARAGEDOOR22 || - id == MI_LCS_GARAGEDOOR23 || - id == MI_LCS_GARAGEDOOR24 || - id == MI_LCS_GARAGEDOOR25 || - id == MI_LCS_GARAGEDOOR26 || - id == MI_LCS_GARAGEDOOR27 || - id == MI_LCS_GARAGEDOOR28 || - id == MI_LCS_GARAGEDOOR29 || - id == MI_LCS_GARAGEDOOR30 || - id == MI_LCS_GARAGEDOOR31 || - id == MI_LCS_GARAGEDOOR32 || - id == MI_LCS_GARAGEDOOR33 || - id == MI_LCS_GARAGEDOOR34 || - id == MI_LCS_GARAGEDOOR35 || - id == MI_LCS_GARAGEDOOR36 || - id == MI_LCS_GARAGEDOOR37 || - id == MI_LCS_GARAGEDOOR38 || - id == MI_LCS_GARAGEDOOR39 || - id == MI_LCS_GARAGEDOOR40; + return id == MI_GARAGEDOOR1 || + id == MI_GARAGEDOOR17 || + id == MI_GARAGEDOOR27 || + id == MI_GARAGEDOOR28 || + id == MI_GARAGEDOOR29 || + id == MI_GARAGEDOOR30 || + id == MI_GARAGEDOOR31 || + id == MI_GARAGEDOOR32 || + id == MI_GARAGEDOOR33 || + id == MI_GARAGEDOOR34 || + id == MI_GARAGEDOOR35 || + id == MI_GARAGEDOOR36 || + id == MI_GARAGEDOOR37 || + id == MI_GARAGEDOOR38 || + id == MI_GARAGEDOOR39 || + id == MI_CRUSHERBODY || + id == MI_CRUSHERLID || + id == MI_GARAGEDOOR2 || + id == MI_GARAGEDOOR3 || + id == MI_GARAGEDOOR4 || + id == MI_GARAGEDOOR5 || + id == MI_GARAGEDOOR6 || + id == MI_GARAGEDOOR7 || + id == MI_GARAGEDOOR9 || + id == MI_GARAGEDOOR10 || + id == MI_GARAGEDOOR11 || + id == MI_GARAGEDOOR12 || + id == MI_GARAGEDOOR13 || + id == MI_GARAGEDOOR14 || + id == MI_GARAGEDOOR15 || + id == MI_GARAGEDOOR16 || + id == MI_GARAGEDOOR18 || + id == MI_GARAGEDOOR19 || + id == MI_GARAGEDOOR20 || + id == MI_GARAGEDOOR21 || + id == MI_GARAGEDOOR22 || + id == MI_GARAGEDOOR23 || + id == MI_GARAGEDOOR24 || + id == MI_GARAGEDOOR25 || + id == MI_GARAGEDOOR26 || + id == MI_DOOR2_SJL; } diff --git a/src/core/World.cpp b/src/core/World.cpp index 14624f97..328b43c6 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1793,56 +1793,35 @@ void CWorld::RepositionOneObject(CEntity *pEntity) { int16 modelId = pEntity->GetModelIndex(); - if (modelId == MI_PARKINGMETER || modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || - modelId == MI_BIN || modelId == MI_POSTBOX1 || modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || - modelId == MI_DUMP1 || modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || - modelId == MI_PHONESIGN || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || - modelId == MI_PARKTABLE || modelId == MI_PARKINGMETER2 || modelId == MI_TELPOLE02 || - modelId == MI_PARKBENCH || modelId == MI_BARRIER1 || IsTreeModel(modelId) - ) { + if (IsLightThatNeedsRepositioning(modelId) || IsTreeModel(modelId) || modelId == MI_PARKINGMETER || + modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 || + modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 || + modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || + modelId == MI_PHONESIGN || modelId == MI_TAXISIGN || modelId == MI_FISHSTALL01 || + modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 || + modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || + modelId == MI_PARKTABLE) { CVector& position = pEntity->GetMatrix().GetPosition(); - CColModel* pColModel = pEntity->GetColModel(); - float fBoundingBoxMinZ = pColModel->boundingBox.min.z; - float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - if (fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z; + float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; position.z = FindGroundZFor3DCoord(position.x, position.y, - position.z + fHeight, nil) - - fBoundingBoxMinZ; + position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - + fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); pEntity->UpdateRwFrame(); - } else if(IsLightThatNeedsRepositioning(modelId)) { - CVector position = pEntity->GetMatrix().GetPosition(); - CColModel* pColModel = pEntity->GetColModel(); - float fBoundingBoxMinZ = pColModel->boundingBox.min.z; - float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - if (fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z; - if (pColModel->numBoxes == 1) - position = pEntity->GetMatrix() * CVector( - (pColModel->boxes[0].min.x + pColModel->boxes[0].max.x) / 2, - (pColModel->boxes[0].min.y + pColModel->boxes[0].max.y) / 2, - pColModel->boxes[0].min.z); - else if (pColModel->numSpheres > 0) { - position.z = 1000.0f; - for (int i = 0; i < pColModel->numSpheres; i++) { - if (pColModel->spheres[i].center.z < position.z) - position = pColModel->spheres[i].center; - } - if (position.z < 1000.0f) - position = pEntity->GetMatrix() * position; - } - pEntity->GetMatrix().GetPosition().z = FindGroundZFor3DCoord(position.x, position.y, pEntity->GetMatrix().GetPosition().z + fHeight, nil) - fBoundingBoxMinZ; - pEntity->GetMatrix().UpdateRW(); - pEntity->UpdateRwFrame(); - - } - if(modelId == MI_BUOY) { + } else if(modelId == MI_BUOY) { + float fWaterLevel = 0.0f; bool bFound = true; const CVector &position = pEntity->GetPosition(); float fGroundZ = FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); - CColModel *pColModel = pEntity->GetColModel(); - float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + 6.0f - 0.5f * fHeight; + if(CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, + &fWaterLevel)) { + if(!bFound || fWaterLevel > fGroundZ) { + CColModel *pColModel = pEntity->GetColModel(); + float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; + pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; + } + } } } diff --git a/src/modelinfo/ModelIndices.cpp b/src/modelinfo/ModelIndices.cpp index 98c7fb38..83539404 100644 --- a/src/modelinfo/ModelIndices.cpp +++ b/src/modelinfo/ModelIndices.cpp @@ -2,17 +2,25 @@ #include "General.h" #include "ModelIndices.h" +#include "main.h" -#define X(name, var) int16 var = -1; +CModelIndices *gpModelIndices; + +/*#define X(name, var) int16 var = -1; MODELINDICES -#undef X +#undef X*/ void InitModelIndices(void) { -#define X(name, var) var = -1; +/*#define X(name, var) var = -1; MODELINDICES -#undef X +#undef X*/ + if (gMakeResources) + { + gpModelIndices = new CModelIndices; + memset(gpModelIndices, -1, sizeof(CModelIndices)); + } } void diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index 476a2273..e5c7c1e5 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -2,8 +2,590 @@ #include "ModelInfo.h" +struct CModelIndices +{ + int16 TRAFFICLIGHTS; + int16 TLIGHT_POST; + int16 TLIGHT_WALK; + int16 TLIGHT_BOX1; + int16 TLIGHT_BOX2; + int16 TRAFFICLIGHTS_VERTICAL; + int16 TRAFFICLIGHTS_MIAMI; + int16 TRAFFICLIGHTS_TWOVERTICAL; + int16 SINGLESTREETLIGHTS1; + int16 SINGLESTREETLIGHTS2; + int16 SINGLESTREETLIGHTS3; + int16 DOUBLESTREETLIGHTS; + int16 STREETLAMP1; + int16 STREETLAMP2; + int16 ROADSFORROADBLOCKSSTART; + int16 ROADSFORROADBLOCKSEND; + int16 TREE2; + int16 TREE3; + int16 TREE6; + int16 TREE8; + int16 TREE1; + int16 TREE4; + int16 TREE5; + int16 TREE7; + int16 TREE9; + int16 TREE10; + int16 TREE11; + int16 TREE12; + int16 TREE13; + int16 TREE14; + int16 CRANE_1; + int16 CRANE_2; + int16 CRANE_3; + int16 CRANE_4; + int16 CRANE_5; + int16 CRANE_6; + int16 PARKINGMETER; + int16 PARKINGMETER2; + int16 MALLFAN; + int16 HOTELFAN_NIGHT; + int16 HOTELFAN_DAY; + int16 HOTROOMFAN; + int16 PHONEBOOTH1; + int16 WASTEBIN; + int16 BIN; + int16 POSTBOX1; + int16 NEWSSTAND; + int16 TRAFFICCONE; + int16 DUMP1; + int16 ROADWORKBARRIER1; + int16 BUSSIGN1; + int16 NOPARKINGSIGN1; + int16 PHONESIGN; + int16 TAXISIGN; + int16 FISHSTALL01; + int16 FISHSTALL02; + int16 FISHSTALL03; + int16 FISHSTALL04; + int16 BAGELSTAND2; + int16 FIRE_HYDRANT; + int16 COLLECTABLE1; + int16 MONEY; + int16 CARMINE; + int16 GARAGEDOOR1; + int16 GARAGEDOOR2; + int16 GARAGEDOOR3; + int16 GARAGEDOOR4; + int16 GARAGEDOOR5; + int16 GARAGEDOOR6; + int16 GARAGEDOOR7; + int16 GARAGEDOOR9; + int16 GARAGEDOOR10; + int16 GARAGEDOOR11; + int16 GARAGEDOOR12; + int16 GARAGEDOOR13; + int16 GARAGEDOOR14; + int16 GARAGEDOOR15; + int16 GARAGEDOOR16; + int16 GARAGEDOOR17; + int16 GARAGEDOOR18; + int16 GARAGEDOOR19; + int16 GARAGEDOOR20; + int16 GARAGEDOOR21; + int16 GARAGEDOOR22; + int16 GARAGEDOOR23; + int16 GARAGEDOOR24; + int16 GARAGEDOOR25; + int16 GARAGEDOOR26; + int16 GARAGEDOOR27; + int16 GARAGEDOOR28; + int16 GARAGEDOOR29; + int16 GARAGEDOOR30; + int16 GARAGEDOOR31; + int16 GARAGEDOOR32; + int16 GARAGEDOOR33; + int16 GARAGEDOOR34; + int16 GARAGEDOOR35; + int16 GARAGEDOOR36; + int16 GARAGEDOOR37; + int16 GARAGEDOOR38; + int16 GARAGEDOOR39; + int16 TESTRAMP1; // UNUSED + int16 TESTRAMP2; + int16 NAUTICALMINE; + int16 CRUSHERBODY; + int16 CRUSHERLID; + int16 DONKEYMAG; + int16 BULLION; + int16 FLOATPACKAGE1; + int16 BRIEFCASE; + int16 CHINABANNER1; + int16 CHINABANNER2; + int16 CHINABANNER3; + int16 CHINABANNER4; + int16 CHINABANNER5; + int16 CHINABANNER6; + int16 CHINABANNER7; + int16 CHINABANNER8; + int16 CHINABANNER9; + int16 CHINABANNER10; + int16 CHINABANNER11; + int16 CHINABANNER12; + int16 CHINALANTERN; + int16 GLASS1; + int16 GLASS2; + int16 GLASS3; + int16 GLASS4; + int16 GLASS5; + int16 GLASS6; + int16 GLASS7; + int16 GLASS8; + int16 BRIDGELIFT; + int16 BRIDGEWEIGHT; + int16 BRIDGEROADSEGMENT; + int16 EXPLODINGBARREL; + int16 ITALYBANNER1; + int16 MEGADAMAGE; + int16 REGENERATOR; + int16 INVISIBLE; + int16 GOOD_CAR; + int16 BAD_CAR; + int16 PICKUP_ADRENALINE; + int16 PICKUP_BODYARMOUR; + int16 PICKUP_INFO; + int16 PICKUP_HEALTH; + int16 PICKUP_BONUS; + int16 PICKUP_BRIBE; + int16 PICKUP_KILLFRENZY; + int16 PICKUP_CAMERA; + int16 PICKUP_REVENUE; + int16 PICKUP_SAVEGAME; + int16 PICKUP_PROPERTY; + int16 PICKUP_PROPERTY_FORSALE; + int16 PICKUP_CLOTHES; + int16 BOLLARDLIGHT; + int16 CA_SP1; + int16 CA_SP2; + int16 CA_SP3; + int16 CA_SP4; + int16 PACKAGE1IZZY; + int16 MAGNET; + int16 RAILTRACKS; + int16 FENCE; + int16 FENCE2; + int16 PETROLPUMP; + int16 PETROLPUMP2; + int16 BODYCAST; + int16 IZZY_CONFDOOR; + int16 SHIPDOOR; + int16 IZZY_JDDOOR; + int16 IZZY_JDDOOR_SLIDER; + int16 LITEHOUSE_GATE; + int16 COFFEE; + int16 BUOY; + int16 PARKTABLE; + int16 SUBWAY1; + int16 SUBWAY2; + int16 SUBWAY3; + int16 SUBWAY4; + int16 SUBWAY5; + int16 SUBWAY6; + int16 SUBWAY7; + int16 SUBWAY8; + int16 SUBWAY9; + int16 SUBWAY10; + int16 SUBWAY11; + int16 SUBWAY12; + int16 SUBWAY13; + int16 SUBWAY14; + int16 SUBWAY15; + int16 SUBWAY16; + int16 SUBWAY17; + int16 SUBWAY18; + int16 SUBPLATFORM_IND; + int16 SUBPLATFORM_COMS; + int16 SUBPLATFORM_COMS2; + int16 SUBPLATFORM_COMN; + int16 SUBPLATFORM_SUB; + int16 SUBPLATFORM_SUB2; + int16 FILES; + int16 LAMPPOST1; + int16 VEG_PALM01; + int16 VEG_PALM02; + int16 VEG_PALM03; + int16 VEG_PALM04; + int16 VEG_PALM05; + int16 VEG_PALM06; + int16 VEG_PALM07; + int16 VEG_PALM08; + int16 MLAMPPOST; + int16 BARRIER1; + int16 LITTLEHA_POLICE; + int16 TELPOLE02; + int16 TRAFFICLIGHT01; + int16 PARKBENCH; + int16 PLC_STINGER; + int16 LIGHTBEAM; + int16 AIRPORTRADAR; + int16 RCBOMB; + int16 JM_SALRADIO; + int16 BEACHBALL; + int16 SANDCASTLE1; + int16 SANDCASTLE2; + int16 JELLYFISH; + int16 JELLYFISH01; + int16 FISH1SINGLE; + int16 FISH1S; + int16 FISH2SINGLE; + int16 FISH2S; + int16 FISH3SINGLE; + int16 FISH3S; + int16 TURTLE; + int16 DOLPHIN; + int16 SHARK; + int16 SUBMARINE; + int16 ESCALATORSTEP; + int16 LOUNGE_WOOD_UP; + int16 LOUNGE_TOWEL_UP; + int16 LOUNGE_WOOD_DN; + int16 LOTION; + int16 BEACHTOWEL01; + int16 BEACHTOWEL02; + int16 BEACHTOWEL03; + int16 BEACHTOWEL04; + int16 BLIMP_NIGHT; + int16 BLIMP_DAY; + int16 YT_MAIN_BODY; + int16 YT_MAIN_BODY2; + int16 SMALL_HELIX; + int16 PT_BARRIER; + int16 SUBWAYGATE; + int16 IN_PMBRIDRAMP3; + int16 IN_PMBRIDG2_UPGS; + int16 IN_PMBRIDGE2; + int16 IN_PMBRIDG1_UPGS; + int16 PM_LIGHTRIG3; + int16 PM_LIGHTRIG1; + int16 IN_PMSCAFF_UPS; + int16 IN_PM_CONCBLOK2; + int16 IN_PMSCAFFH_NS; + int16 IN_PM_GRAVL_JMP; + int16 IN_PM_SCAFFCOVR; + int16 IN_PM_GIRDER2; + int16 IN_PM_SCAFFH_WE; + int16 IN_PM_SIXCONC2; + int16 IN_BMBRIDRAMP3; + int16 IN_BMBRIDG2_UPGS; + int16 IN_BMBRIDGE2; + int16 IN_BMBRIDG1_UPGS; + int16 BM_LIGHTRIG3; + int16 BM_LIGHTRIG1; + int16 IN_BMSCAFF_UPS; + int16 IN_BM_CONCBLOK2; + int16 IN_BMSCAFFH_NS; + int16 IN_BM_GRAVL_JMP; + int16 IN_BM_SCAFFCOVR; + int16 IN_BM_GIRDER2; + int16 IN_BM_SCAFFH_WE; + int16 IN_BM_SIXCONC2; + int16 CRATE_SJL; + int16 DOOR1_SJL; + int16 DOOR2_SJL; + int16 SJL_PORTACABIN; + int16 SJL_PORTACABINRED; +}; + +extern CModelIndices *gpModelIndices; + +#define MI_TRAFFICLIGHTS gpModelIndices->TRAFFICLIGHTS +#define MI_TLIGHT_POST gpModelIndices->TLIGHT_POST +#define MI_TLIGHT_WALK gpModelIndices->TLIGHT_WALK +#define MI_TLIGHT_BOX1 gpModelIndices->TLIGHT_BOX1 +#define MI_TLIGHT_BOX2 gpModelIndices->TLIGHT_BOX2 +#define MI_TRAFFICLIGHTS_VERTICAL gpModelIndices->TRAFFICLIGHTS_VERTICAL +#define MI_TRAFFICLIGHTS_MIAMI gpModelIndices->TRAFFICLIGHTS_MIAMI +#define MI_TRAFFICLIGHTS_TWOVERTICAL gpModelIndices->TRAFFICLIGHTS_TWOVERTICAL +#define MI_SINGLESTREETLIGHTS1 gpModelIndices->SINGLESTREETLIGHTS1 +#define MI_SINGLESTREETLIGHTS2 gpModelIndices->SINGLESTREETLIGHTS2 +#define MI_SINGLESTREETLIGHTS3 gpModelIndices->SINGLESTREETLIGHTS3 +#define MI_DOUBLESTREETLIGHTS gpModelIndices->DOUBLESTREETLIGHTS +#define MI_STREETLAMP1 gpModelIndices->STREETLAMP1 +#define MI_STREETLAMP2 gpModelIndices->STREETLAMP2 +#define MI_ROADSFORROADBLOCKSSTART gpModelIndices->ROADSFORROADBLOCKSSTART +#define MI_ROADSFORROADBLOCKSEND gpModelIndices->ROADSFORROADBLOCKSEND +#define MI_TREE2 gpModelIndices->TREE2 +#define MI_TREE3 gpModelIndices->TREE3 +#define MI_TREE6 gpModelIndices->TREE6 +#define MI_TREE8 gpModelIndices->TREE8 +#define MI_TREE1 gpModelIndices->TREE1 +#define MI_TREE4 gpModelIndices->TREE4 +#define MI_TREE5 gpModelIndices->TREE5 +#define MI_TREE7 gpModelIndices->TREE7 +#define MI_TREE9 gpModelIndices->TREE9 +#define MI_TREE10 gpModelIndices->TREE10 +#define MI_TREE11 gpModelIndices->TREE11 +#define MI_TREE12 gpModelIndices->TREE12 +#define MI_TREE13 gpModelIndices->TREE13 +#define MI_TREE14 gpModelIndices->TREE14 +#define MODELID_CRANE_1 gpModelIndices->CRANE_1 +#define MODELID_CRANE_2 gpModelIndices->CRANE_2 +#define MODELID_CRANE_3 gpModelIndices->CRANE_3 +#define MODELID_CRANE_4 gpModelIndices->CRANE_4 +#define MODELID_CRANE_5 gpModelIndices->CRANE_5 +#define MODELID_CRANE_6 gpModelIndices->CRANE_6 +#define MI_PARKINGMETER gpModelIndices->PARKINGMETER +#define MI_PARKINGMETER2 gpModelIndices->PARKINGMETER2 +#define MI_MALLFAN gpModelIndices->MALLFAN +#define MI_HOTELFAN_NIGHT gpModelIndices->HOTELFAN_NIGHT +#define MI_HOTELFAN_DAY gpModelIndices->HOTELFAN_DAY +#define MI_HOTROOMFAN gpModelIndices->HOTROOMFAN +#define MI_PHONEBOOTH1 gpModelIndices->PHONEBOOTH1 +#define MI_WASTEBIN gpModelIndices->WASTEBIN +#define MI_BIN gpModelIndices->BIN +#define MI_POSTBOX1 gpModelIndices->POSTBOX1 +#define MI_NEWSSTAND gpModelIndices->NEWSSTAND +#define MI_TRAFFICCONE gpModelIndices->TRAFFICCONE +#define MI_DUMP1 gpModelIndices->DUMP1 +#define MI_ROADWORKBARRIER1 gpModelIndices->ROADWORKBARRIER1 +#define MI_BUSSIGN1 gpModelIndices->BUSSIGN1 +#define MI_NOPARKINGSIGN1 gpModelIndices->NOPARKINGSIGN1 +#define MI_PHONESIGN gpModelIndices->PHONESIGN +#define MI_TAXISIGN gpModelIndices->TAXISIGN +#define MI_FISHSTALL01 gpModelIndices->FISHSTALL01 +#define MI_FISHSTALL02 gpModelIndices->FISHSTALL02 +#define MI_FISHSTALL03 gpModelIndices->FISHSTALL03 +#define MI_FISHSTALL04 gpModelIndices->FISHSTALL04 +#define MI_BAGELSTAND2 gpModelIndices->BAGELSTAND2 +#define MI_FIRE_HYDRANT gpModelIndices->FIRE_HYDRANT +#define MI_COLLECTABLE1 gpModelIndices->COLLECTABLE1 +#define MI_MONEY gpModelIndices->MONEY +#define MI_CARMINE gpModelIndices->CARMINE +#define MI_GARAGEDOOR1 gpModelIndices->GARAGEDOOR1 +#define MI_GARAGEDOOR2 gpModelIndices->GARAGEDOOR2 +#define MI_GARAGEDOOR3 gpModelIndices->GARAGEDOOR3 +#define MI_GARAGEDOOR4 gpModelIndices->GARAGEDOOR4 +#define MI_GARAGEDOOR5 gpModelIndices->GARAGEDOOR5 +#define MI_GARAGEDOOR6 gpModelIndices->GARAGEDOOR6 +#define MI_GARAGEDOOR7 gpModelIndices->GARAGEDOOR7 +#define MI_GARAGEDOOR9 gpModelIndices->GARAGEDOOR9 +#define MI_GARAGEDOOR10 gpModelIndices->GARAGEDOOR10 +#define MI_GARAGEDOOR11 gpModelIndices->GARAGEDOOR11 +#define MI_GARAGEDOOR12 gpModelIndices->GARAGEDOOR12 +#define MI_GARAGEDOOR13 gpModelIndices->GARAGEDOOR13 +#define MI_GARAGEDOOR14 gpModelIndices->GARAGEDOOR14 +#define MI_GARAGEDOOR15 gpModelIndices->GARAGEDOOR15 +#define MI_GARAGEDOOR16 gpModelIndices->GARAGEDOOR16 +#define MI_GARAGEDOOR17 gpModelIndices->GARAGEDOOR17 +#define MI_GARAGEDOOR18 gpModelIndices->GARAGEDOOR18 +#define MI_GARAGEDOOR19 gpModelIndices->GARAGEDOOR19 +#define MI_GARAGEDOOR20 gpModelIndices->GARAGEDOOR20 +#define MI_GARAGEDOOR21 gpModelIndices->GARAGEDOOR21 +#define MI_GARAGEDOOR22 gpModelIndices->GARAGEDOOR22 +#define MI_GARAGEDOOR23 gpModelIndices->GARAGEDOOR23 +#define MI_GARAGEDOOR24 gpModelIndices->GARAGEDOOR24 +#define MI_GARAGEDOOR25 gpModelIndices->GARAGEDOOR25 +#define MI_GARAGEDOOR26 gpModelIndices->GARAGEDOOR26 +#define MI_GARAGEDOOR27 gpModelIndices->GARAGEDOOR27 +#define MI_GARAGEDOOR28 gpModelIndices->GARAGEDOOR28 +#define MI_GARAGEDOOR29 gpModelIndices->GARAGEDOOR29 +#define MI_GARAGEDOOR30 gpModelIndices->GARAGEDOOR30 +#define MI_GARAGEDOOR31 gpModelIndices->GARAGEDOOR31 +#define MI_GARAGEDOOR32 gpModelIndices->GARAGEDOOR32 +#define MI_GARAGEDOOR33 gpModelIndices->GARAGEDOOR33 +#define MI_GARAGEDOOR34 gpModelIndices->GARAGEDOOR34 +#define MI_GARAGEDOOR35 gpModelIndices->GARAGEDOOR35 +#define MI_GARAGEDOOR36 gpModelIndices->GARAGEDOOR36 +#define MI_GARAGEDOOR37 gpModelIndices->GARAGEDOOR37 +#define MI_GARAGEDOOR38 gpModelIndices->GARAGEDOOR38 +#define MI_GARAGEDOOR39 gpModelIndices->GARAGEDOOR39 +#define MI_TESTRAMP1 gpModelIndices->TESTRAMP1 // UNUSED +#define MI_TESTRAMP2 gpModelIndices->TESTRAMP2 +#define MI_NAUTICALMINE gpModelIndices->NAUTICALMINE +#define MI_CRUSHERBODY gpModelIndices->CRUSHERBODY +#define MI_CRUSHERLID gpModelIndices->CRUSHERLID +#define MI_DONKEYMAG gpModelIndices->DONKEYMAG +#define MI_BULLION gpModelIndices->BULLION +#define MI_FLOATPACKAGE1 gpModelIndices->FLOATPACKAGE1 +#define MI_BRIEFCASE gpModelIndices->BRIEFCASE +#define MI_CHINABANNER1 gpModelIndices->CHINABANNER1 +#define MI_CHINABANNER2 gpModelIndices->CHINABANNER2 +#define MI_CHINABANNER3 gpModelIndices->CHINABANNER3 +#define MI_CHINABANNER4 gpModelIndices->CHINABANNER4 +#define MI_CHINABANNER5 gpModelIndices->CHINABANNER5 +#define MI_CHINABANNER6 gpModelIndices->CHINABANNER6 +#define MI_CHINABANNER7 gpModelIndices->CHINABANNER7 +#define MI_CHINABANNER8 gpModelIndices->CHINABANNER8 +#define MI_CHINABANNER9 gpModelIndices->CHINABANNER9 +#define MI_CHINABANNER10 gpModelIndices->CHINABANNER10 +#define MI_CHINABANNER11 gpModelIndices->CHINABANNER11 +#define MI_CHINABANNER12 gpModelIndices->CHINABANNER12 +#define MI_CHINALANTERN gpModelIndices->CHINALANTERN +#define MI_GLASS1 gpModelIndices->GLASS1 +#define MI_GLASS2 gpModelIndices->GLASS2 +#define MI_GLASS3 gpModelIndices->GLASS3 +#define MI_GLASS4 gpModelIndices->GLASS4 +#define MI_GLASS5 gpModelIndices->GLASS5 +#define MI_GLASS6 gpModelIndices->GLASS6 +#define MI_GLASS7 gpModelIndices->GLASS7 +#define MI_GLASS8 gpModelIndices->GLASS8 +#define MI_BRIDGELIFT gpModelIndices->BRIDGELIFT +#define MI_BRIDGEWEIGHT gpModelIndices->BRIDGEWEIGHT +#define MI_BRIDGEROADSEGMENT gpModelIndices->BRIDGEROADSEGMENT +#define MI_EXPLODINGBARREL gpModelIndices->EXPLODINGBARREL +#define MI_ITALYBANNER1 gpModelIndices->ITALYBANNER1 +#define MI_MEGADAMAGE gpModelIndices->MEGADAMAGE +#define MI_REGENERATOR gpModelIndices->REGENERATOR +#define MI_INVISIBLE gpModelIndices->INVISIBLE +#define MI_GOOD_CAR gpModelIndices->GOOD_CAR +#define MI_BAD_CAR gpModelIndices->BAD_CAR +#define MI_PICKUP_ADRENALINE gpModelIndices->PICKUP_ADRENALINE +#define MI_PICKUP_BODYARMOUR gpModelIndices->PICKUP_BODYARMOUR +#define MI_PICKUP_INFO gpModelIndices->PICKUP_INFO +#define MI_PICKUP_HEALTH gpModelIndices->PICKUP_HEALTH +#define MI_PICKUP_BONUS gpModelIndices->PICKUP_BONUS +#define MI_PICKUP_BRIBE gpModelIndices->PICKUP_BRIBE +#define MI_PICKUP_KILLFRENZY gpModelIndices->PICKUP_KILLFRENZY +#define MI_PICKUP_CAMERA gpModelIndices->PICKUP_CAMERA +#define MI_PICKUP_REVENUE gpModelIndices->PICKUP_REVENUE +#define MI_PICKUP_SAVEGAME gpModelIndices->PICKUP_SAVEGAME +#define MI_PICKUP_PROPERTY gpModelIndices->PICKUP_PROPERTY +#define MI_PICKUP_PROPERTY_FORSALE gpModelIndices->PICKUP_PROPERTY_FORSALE +#define MI_PICKUP_CLOTHES gpModelIndices->PICKUP_CLOTHES +#define MI_BOLLARDLIGHT gpModelIndices->BOLLARDLIGHT +#define MI_CA_SP1 gpModelIndices->CA_SP1 +#define MI_CA_SP2 gpModelIndices->CA_SP2 +#define MI_CA_SP3 gpModelIndices->CA_SP3 +#define MI_CA_SP4 gpModelIndices->CA_SP4 +#define MI_PACKAGE1IZZY gpModelIndices->PACKAGE1IZZY +#define MI_MAGNET gpModelIndices->MAGNET +#define MI_RAILTRACKS gpModelIndices->RAILTRACKS +#define MI_FENCE gpModelIndices->FENCE +#define MI_FENCE2 gpModelIndices->FENCE2 +#define MI_PETROLPUMP gpModelIndices->PETROLPUMP +#define MI_PETROLPUMP2 gpModelIndices->PETROLPUMP2 +#define MI_BODYCAST gpModelIndices->BODYCAST +#define MI_IZZY_CONFDOOR gpModelIndices->IZZY_CONFDOOR +#define MI_SHIPDOOR gpModelIndices->SHIPDOOR +#define MI_IZZY_JDDOOR gpModelIndices->IZZY_JDDOOR +#define MI_IZZY_JDDOOR_SLIDER gpModelIndices->IZZY_JDDOOR_SLIDER +#define MI_LITEHOUSE_GATE gpModelIndices->LITEHOUSE_GATE +#define MI_COFFEE gpModelIndices->COFFEE +#define MI_BUOY gpModelIndices->BUOY +#define MI_PARKTABLE gpModelIndices->PARKTABLE +#define MI_SUBWAY1 gpModelIndices->SUBWAY1 +#define MI_SUBWAY2 gpModelIndices->SUBWAY2 +#define MI_SUBWAY3 gpModelIndices->SUBWAY3 +#define MI_SUBWAY4 gpModelIndices->SUBWAY4 +#define MI_SUBWAY5 gpModelIndices->SUBWAY5 +#define MI_SUBWAY6 gpModelIndices->SUBWAY6 +#define MI_SUBWAY7 gpModelIndices->SUBWAY7 +#define MI_SUBWAY8 gpModelIndices->SUBWAY8 +#define MI_SUBWAY9 gpModelIndices->SUBWAY9 +#define MI_SUBWAY10 gpModelIndices->SUBWAY10 +#define MI_SUBWAY11 gpModelIndices->SUBWAY11 +#define MI_SUBWAY12 gpModelIndices->SUBWAY12 +#define MI_SUBWAY13 gpModelIndices->SUBWAY13 +#define MI_SUBWAY14 gpModelIndices->SUBWAY14 +#define MI_SUBWAY15 gpModelIndices->SUBWAY15 +#define MI_SUBWAY16 gpModelIndices->SUBWAY16 +#define MI_SUBWAY17 gpModelIndices->SUBWAY17 +#define MI_SUBWAY18 gpModelIndices->SUBWAY18 +#define MI_SUBPLATFORM_IND gpModelIndices->SUBPLATFORM_IND +#define MI_SUBPLATFORM_COMS gpModelIndices->SUBPLATFORM_COMS +#define MI_SUBPLATFORM_COMS2 gpModelIndices->SUBPLATFORM_COMS2 +#define MI_SUBPLATFORM_COMN gpModelIndices->SUBPLATFORM_COMN +#define MI_SUBPLATFORM_SUB gpModelIndices->SUBPLATFORM_SUB +#define MI_SUBPLATFORM_SUB2 gpModelIndices->SUBPLATFORM_SUB2 +#define MI_FILES gpModelIndices->FILES +#define MI_LAMPPOST1 gpModelIndices->LAMPPOST1 +#define MI_VEG_PALM01 gpModelIndices->VEG_PALM01 +#define MI_VEG_PALM02 gpModelIndices->VEG_PALM02 +#define MI_VEG_PALM03 gpModelIndices->VEG_PALM03 +#define MI_VEG_PALM04 gpModelIndices->VEG_PALM04 +#define MI_VEG_PALM05 gpModelIndices->VEG_PALM05 +#define MI_VEG_PALM06 gpModelIndices->VEG_PALM06 +#define MI_VEG_PALM07 gpModelIndices->VEG_PALM07 +#define MI_VEG_PALM08 gpModelIndices->VEG_PALM08 +#define MI_MLAMPPOST gpModelIndices->MLAMPPOST +#define MI_BARRIER1 gpModelIndices->BARRIER1 +#define MI_LITTLEHA_POLICE gpModelIndices->LITTLEHA_POLICE +#define MI_TELPOLE02 gpModelIndices->TELPOLE02 +#define MI_TRAFFICLIGHT01 gpModelIndices->TRAFFICLIGHT01 +#define MI_PARKBENCH gpModelIndices->PARKBENCH +#define MI_PLC_STINGER gpModelIndices->PLC_STINGER +#define MI_LIGHTBEAM gpModelIndices->LIGHTBEAM +#define MI_AIRPORTRADAR gpModelIndices->AIRPORTRADAR +#define MI_RCBOMB gpModelIndices->RCBOMB +#define MI_JM_SALRADIO gpModelIndices->JM_SALRADIO +#define MI_BEACHBALL gpModelIndices->BEACHBALL +#define MI_SANDCASTLE1 gpModelIndices->SANDCASTLE1 +#define MI_SANDCASTLE2 gpModelIndices->SANDCASTLE2 +#define MI_JELLYFISH gpModelIndices->JELLYFISH +#define MI_JELLYFISH01 gpModelIndices->JELLYFISH01 +#define MI_FISH1SINGLE gpModelIndices->FISH1SINGLE +#define MI_FISH1S gpModelIndices->FISH1S +#define MI_FISH2SINGLE gpModelIndices->FISH2SINGLE +#define MI_FISH2S gpModelIndices->FISH2S +#define MI_FISH3SINGLE gpModelIndices->FISH3SINGLE +#define MI_FISH3S gpModelIndices->FISH3S +#define MI_TURTLE gpModelIndices->TURTLE +#define MI_DOLPHIN gpModelIndices->DOLPHIN +#define MI_SHARK gpModelIndices->SHARK +#define MI_SUBMARINE gpModelIndices->SUBMARINE +#define MI_ESCALATORSTEP gpModelIndices->ESCALATORSTEP +#define MI_LOUNGE_WOOD_UP gpModelIndices->LOUNGE_WOOD_UP +#define MI_LOUNGE_TOWEL_UP gpModelIndices->LOUNGE_TOWEL_UP +#define MI_LOUNGE_WOOD_DN gpModelIndices->LOUNGE_WOOD_DN +#define MI_LOTION gpModelIndices->LOTION +#define MI_BEACHTOWEL01 gpModelIndices->BEACHTOWEL01 +#define MI_BEACHTOWEL02 gpModelIndices->BEACHTOWEL02 +#define MI_BEACHTOWEL03 gpModelIndices->BEACHTOWEL03 +#define MI_BEACHTOWEL04 gpModelIndices->BEACHTOWEL04 +#define MI_BLIMP_NIGHT gpModelIndices->BLIMP_NIGHT +#define MI_BLIMP_DAY gpModelIndices->BLIMP_DAY +#define MI_YT_MAIN_BODY gpModelIndices->YT_MAIN_BODY +#define MI_YT_MAIN_BODY2 gpModelIndices->YT_MAIN_BODY2 +#define MI_SMALL_HELIX gpModelIndices->SMALL_HELIX +#define MI_PT_BARRIER gpModelIndices->PT_BARRIER +#define MI_SUBWAYGATE gpModelIndices->SUBWAYGATE +#define MI_IN_PMBRIDRAMP3 gpModelIndices->IN_PMBRIDRAMP3 +#define MI_IN_PMBRIDG2_UPGS gpModelIndices->IN_PMBRIDG2_UPGS +#define MI_IN_PMBRIDGE2 gpModelIndices->IN_PMBRIDGE2 +#define MI_IN_PMBRIDG1_UPGS gpModelIndices->IN_PMBRIDG1_UPGS +#define MI_PM_LIGHTRIG3 gpModelIndices->PM_LIGHTRIG3 +#define MI_PM_LIGHTRIG1 gpModelIndices->PM_LIGHTRIG1 +#define MI_IN_PMSCAFF_UPS gpModelIndices->IN_PMSCAFF_UPS +#define MI_IN_PM_CONCBLOK2 gpModelIndices->IN_PM_CONCBLOK2 +#define MI_IN_PMSCAFFH_NS gpModelIndices->IN_PMSCAFFH_NS +#define MI_IN_PM_GRAVL_JMP gpModelIndices->IN_PM_GRAVL_JMP +#define MI_IN_PM_SCAFFCOVR gpModelIndices->IN_PM_SCAFFCOVR +#define MI_IN_PM_GIRDER2 gpModelIndices->IN_PM_GIRDER2 +#define MI_IN_PM_SCAFFH_WE gpModelIndices->IN_PM_SCAFFH_WE +#define MI_IN_PM_SIXCONC2 gpModelIndices->IN_PM_SIXCONC2 +#define MI_IN_BMBRIDRAMP3 gpModelIndices->IN_BMBRIDRAMP3 +#define MI_IN_BMBRIDG2_UPGS gpModelIndices->IN_BMBRIDG2_UPGS +#define MI_IN_BMBRIDGE2 gpModelIndices->IN_BMBRIDGE2 +#define MI_IN_BMBRIDG1_UPGS gpModelIndices->IN_BMBRIDG1_UPGS +#define MI_BM_LIGHTRIG3 gpModelIndices->BM_LIGHTRIG3 +#define MI_BM_LIGHTRIG1 gpModelIndices->BM_LIGHTRIG1 +#define MI_IN_BMSCAFF_UPS gpModelIndices->IN_BMSCAFF_UPS +#define MI_IN_BM_CONCBLOK2 gpModelIndices->IN_BM_CONCBLOK2 +#define MI_IN_BMSCAFFH_NS gpModelIndices->IN_BMSCAFFH_NS +#define MI_IN_BM_GRAVL_JMP gpModelIndices->IN_BM_GRAVL_JMP +#define MI_IN_BM_SCAFFCOVR gpModelIndices->IN_BM_SCAFFCOVR +#define MI_IN_BM_GIRDER2 gpModelIndices->IN_BM_GIRDER2 +#define MI_IN_BM_SCAFFH_WE gpModelIndices->IN_BM_SCAFFH_WE +#define MI_IN_BM_SIXCONC2 gpModelIndices->IN_BM_SIXCONC2 +#define MI_CRATE_SJL gpModelIndices->CRATE_SJL +#define MI_DOOR1_SJL gpModelIndices->DOOR1_SJL +#define MI_DOOR2_SJL gpModelIndices->DOOR2_SJL +#define MI_SJL_PORTACABIN gpModelIndices->SJL_PORTACABIN +#define MI_SJL_PORTACABINRED gpModelIndices->SJL_PORTACABINRED + #define MODELINDICES \ X("fire_hydrant", MI_FIRE_HYDRANT) \ + X("fire_hydrant", MI_FIRE_HYDRANT) /* BUG: second time */ \ + X("bagelstnd02", MI_BAGELSTAND2) \ + X("fish01", MI_FISHSTALL01) \ + X("fishstall02", MI_FISHSTALL02) \ + X("fishstall03", MI_FISHSTALL03) \ + X("fishstall04", MI_FISHSTALL04) \ + X("taxisign", MI_TAXISIGN) \ X("phonesign", MI_PHONESIGN) \ X("noparkingsign1", MI_NOPARKINGSIGN1) \ X("bussign1", MI_BUSSIGN1) \ @@ -16,12 +598,17 @@ X("wastebin", MI_WASTEBIN) \ X("phonebooth1", MI_PHONEBOOTH1) \ X("parkingmeter", MI_PARKINGMETER) \ + X("trafficlight1", MI_TRAFFICLIGHTS) \ + X("tlight_post", MI_TLIGHT_POST) \ + X("tlight_walk", MI_TLIGHT_WALK) \ + X("tlight_box1", MI_TLIGHT_BOX1) \ + X("tlight_box2", MI_TLIGHT_BOX2) \ X("parkingmeterg", MI_PARKINGMETER2) \ X("mall_fans", MI_MALLFAN) \ X("htl_fan_rotate_nt", MI_HOTELFAN_NIGHT) \ X("htl_fan_rotate_dy", MI_HOTELFAN_DAY) \ X("hotroomfan", MI_HOTROOMFAN) \ - X("trafficlight1", MI_TRAFFICLIGHTS) \ + X("trafficlight1", MI_TRAFFICLIGHTS) /* BUG: second time */ \ X("MTraffic4", MI_TRAFFICLIGHTS_VERTICAL) \ X("MTraffic1", MI_TRAFFICLIGHTS_MIAMI) \ X("MTraffic2", MI_TRAFFICLIGHTS_TWOVERTICAL) \ @@ -31,47 +618,110 @@ X("doublestreetlght1", MI_DOUBLESTREETLIGHTS) \ X("Streetlamp1", MI_STREETLAMP1) \ X("Streetlamp2", MI_STREETLAMP2) \ + X("rd_Road2A10", MI_ROADSFORROADBLOCKSSTART) \ + X("rd_Road1A30", MI_ROADSFORROADBLOCKSEND) \ + X("veg_tree1", MI_TREE1) \ X("veg_tree3", MI_TREE2) \ X("veg_treea1", MI_TREE3) \ + X("veg_treenew01", MI_TREE4) \ + X("veg_treenew05", MI_TREE5) \ X("veg_treeb1", MI_TREE6) \ + X("veg_treenew10", MI_TREE7) \ X("veg_treea3", MI_TREE8) \ - X("doc_crane_cab0", MODELID_CRANE_1) \ - X("doc_crane_cab01", MODELID_CRANE_2) \ - X("doc_crane_cab02", MODELID_CRANE_3) \ - X("doc_crane_cab03", MODELID_CRANE_4) \ - X("boatcranelg0", MODELID_CRANE_5) \ - X("LODnetopa0", MODELID_CRANE_6) \ + X("veg_treenew09", MI_TREE9) \ + X("veg_treenew08", MI_TREE10) \ + X("veg_treenew03", MI_TREE11) \ + X("veg_treenew16", MI_TREE12) \ + X("veg_treenew17", MI_TREE13) \ + X("veg_treenew06", MI_TREE14) \ + X("crusher_crane", MODELID_CRANE_1) \ X("package1", MI_COLLECTABLE1) \ X("Money", MI_MONEY) \ X("barrel1", MI_CARMINE) \ - X("dk_paynspraydoor", MI_GARAGEDOOR2) \ - X("dk_waretankdoor1", MI_GARAGEDOOR3) \ - X("hav_garagedoor1", MI_GARAGEDOOR4) \ - X("hav_garagedoor02", MI_GARAGEDOOR5) \ - X("hav_garagedoor03", MI_GARAGEDOOR6) \ - X("hav_garagedoor04", MI_GARAGEDOOR7) \ - X("lh_showdoor03", MI_GARAGEDOOR9) \ - X("lh_showdoor1", MI_GARAGEDOOR10) \ - X("lhtankdoor", MI_GARAGEDOOR11) \ - X("nbtgardoor", MI_GARAGEDOOR12) \ - X("dk_camjonesdoor", MI_GARAGEDOOR13) \ - X("nbtgardoor02", MI_GARAGEDOOR14) \ - X("dt_savedra", MI_GARAGEDOOR15) \ - X("dt_savedrb", MI_GARAGEDOOR16) \ - X("dk_bombdoor", MI_GARAGEDOOR18) \ - X("haiwshpnsdoor", MI_GARAGEDOOR19) \ - X("wshpnsdoor", MI_GARAGEDOOR20) \ - X("nbecpnsdoor", MI_GARAGEDOOR21) \ - X("nbtgardoor03", MI_GARAGEDOOR22) \ - X("dt_savedrc", MI_GARAGEDOOR23) \ - X("dt_savedrd", MI_GARAGEDOOR24) \ - X("man_frntstepGD", MI_GARAGEDOOR25) \ - X("svegrgedoor", MI_GARAGEDOOR26) \ + X("oddjgaragdoor", MI_GARAGEDOOR1) \ + X("bombdoor", MI_GARAGEDOOR2) \ + X("door_bombshop", MI_GARAGEDOOR3) \ + X("vheistlocdoor", MI_GARAGEDOOR4) \ + X("door2_garage", MI_GARAGEDOOR5) \ + X("ind_slidedoor", MI_GARAGEDOOR6) \ + X("bankjobdoor", MI_GARAGEDOOR7) \ + X("door_jmsgrage", MI_GARAGEDOOR9) \ + X("jamesgrge_kb", MI_GARAGEDOOR10) \ + X("door_sfehousegrge", MI_GARAGEDOOR11) \ + X("shedgaragedoor", MI_GARAGEDOOR12) \ + X("door4_garage", MI_GARAGEDOOR13) \ + X("door_col_compnd_01", MI_GARAGEDOOR14) \ + X("door_col_compnd_02", MI_GARAGEDOOR15) \ + X("door_col_compnd_03", MI_GARAGEDOOR16) \ + X("door_col_compnd_04", MI_GARAGEDOOR17) \ + X("door_col_compnd_05", MI_GARAGEDOOR18) \ + X("impex_door", MI_GARAGEDOOR19) \ + X("SalvGarage", MI_GARAGEDOOR20) \ + X("door3_garage", MI_GARAGEDOOR21) \ + X("leveldoor2", MI_GARAGEDOOR22) \ + X("double_garage_dr", MI_GARAGEDOOR23) \ + X("amcogaragedoor", MI_GARAGEDOOR24) \ + X("towergaragedoor1", MI_GARAGEDOOR25) \ + X("towergaragedoor2", MI_GARAGEDOOR26) \ + X("towergaragedoor3", MI_GARAGEDOOR27) \ + X("plysve_gragedoor", MI_GARAGEDOOR28) \ + X("impexpsubgrgdoor", MI_GARAGEDOOR29) \ + X("Sub_sprayshopdoor", MI_GARAGEDOOR30) \ + X("ind_plyrwoor", MI_GARAGEDOOR31) \ + X("8ballsuburbandoor", MI_GARAGEDOOR32) \ + X("door_nthgrage", MI_GARAGEDOOR33) \ + X("hangardoor1", MI_GARAGEDOOR34) \ + X("hangardoor2", MI_GARAGEDOOR35) \ + X("neds_door", MI_GARAGEDOOR36) \ + X("fs_wrhsedoor", MI_GARAGEDOOR37) \ + X("jm_ContraGarage", MI_GARAGEDOOR38) \ + X("jm_imp_SalvGarage", MI_GARAGEDOOR39) \ + X("Testramp1", MI_TESTRAMP1) /* BUG: LCS used MI_TESTRAMP2 here */ \ + X("Testramp2", MI_TESTRAMP2) \ X("barrel2", MI_NAUTICALMINE) \ + X("crushercrush", MI_CRUSHERBODY) \ + X("crushertop", MI_CRUSHERLID) \ + X("donkeymag", MI_DONKEYMAG) \ + X("bullion", MI_BULLION) \ + X("floatpackge1", MI_FLOATPACKAGE1) \ X("briefcase", MI_BRIEFCASE) \ - X("wglasssmash", MI_GLASS1) \ + X("chinabanner1", MI_CHINABANNER1) \ + X("chinabanner2", MI_CHINABANNER2) \ + X("chinabanner3", MI_CHINABANNER3) \ + X("chinabanner4", MI_CHINABANNER4) \ + X("iten_chinatown5", MI_CHINABANNER5) \ + X("iten_chinatown7", MI_CHINABANNER6) \ + X("iten_chinatown3", MI_CHINABANNER7) \ + X("iten_chinatown2", MI_CHINABANNER8) \ + X("iten_chinatown4", MI_CHINABANNER9) \ + X("iten_washline01", MI_CHINABANNER10) \ + X("iten_washline02", MI_CHINABANNER11) \ + X("iten_washline03", MI_CHINABANNER12) \ + X("chinalanterns", MI_CHINALANTERN) \ + X("glassfx1", MI_GLASS1) \ + X("glassfx2", MI_GLASS2) \ + X("glassfx3", MI_GLASS3) \ + X("glassfx4", MI_GLASS4) \ + X("glassfx55", MI_GLASS5) \ + X("glassfxsub1", MI_GLASS6) \ + X("glassfxsub2", MI_GLASS7) \ X("glassfx_composh", MI_GLASS8) \ + X("bridge_liftsec", MI_BRIDGELIFT) \ + X("bridge_liftweight", MI_BRIDGEWEIGHT) \ + X("subbridge_lift", MI_BRIDGEROADSEGMENT) \ + X("flagsitaly", MI_ITALYBANNER1) \ + X("small_helix", MI_SMALL_HELIX) \ X("barrel4", MI_EXPLODINGBARREL) \ + X("Crate_sjl", MI_CRATE_SJL) \ + X("Door1_sjl", MI_DOOR1_SJL) \ + X("Door2_sjl", MI_DOOR2_SJL) \ + X("SJL_PortaCabin", MI_SJL_PORTACABIN) \ + X("SJL_PortaCabinred", MI_SJL_PORTACABINRED) \ + X("megaDamage", MI_MEGADAMAGE) \ + X("regenerator", MI_REGENERATOR) \ + X("invisible", MI_INVISIBLE) \ + X("good_car", MI_GOOD_CAR) \ + X("bad_car", MI_BAD_CAR) \ X("adrenaline", MI_PICKUP_ADRENALINE) \ X("bodyarmour", MI_PICKUP_BODYARMOUR) \ X("info", MI_PICKUP_INFO) \ @@ -82,16 +732,57 @@ X("camerapickup", MI_PICKUP_CAMERA) \ X("bigdollar", MI_PICKUP_REVENUE) \ X("pickupsave", MI_PICKUP_SAVEGAME) \ + X("clothesp", MI_PICKUP_CLOTHES) \ X("property_locked", MI_PICKUP_PROPERTY) \ X("property_fsale", MI_PICKUP_PROPERTY_FORSALE) \ - X("clothesp", MI_PICKUP_CLOTHES) \ X("bollardlight", MI_BOLLARDLIGHT) \ + X("ca_sp1", MI_CA_SP1) \ + X("ca_sp2", MI_CA_SP2) \ + X("ca_sp3", MI_CA_SP3) \ + X("ca_sp4", MI_CA_SP4) \ + X("package1izzy", MI_PACKAGE1IZZY) \ + X("magnet", MI_MAGNET) \ + X("streetlamp1", MI_STREETLAMP1) \ + X("streetlamp2", MI_STREETLAMP2) \ + X("railtrax_lo4b", MI_RAILTRACKS) \ X("bar_barrier10", MI_FENCE) \ X("bar_barrier12", MI_FENCE2) \ X("petrolpump", MI_PETROLPUMP) \ X("washgaspump", MI_PETROLPUMP2) \ + X("bodycast", MI_BODYCAST) \ + X("izzy_confDoor", MI_IZZY_CONFDOOR) \ + X("shipdoor", MI_SHIPDOOR) \ + X("izzy_jdDoor", MI_IZZY_JDDOOR) \ + X("izzy_jdDoor_slider", MI_IZZY_JDDOOR_SLIDER) \ + X("litehouse_gate", MI_LITEHOUSE_GATE) \ + X("coffee", MI_COFFEE) \ X("bouy", MI_BUOY) \ X("parktable1", MI_PARKTABLE) \ + X("sbwy_tunl_start", MI_SUBWAY1) \ + X("sbwy_tunl_bit", MI_SUBWAY2) \ + X("sbwy_tunl_bend", MI_SUBWAY3) \ + X("sbwy_tunl_cstm6", MI_SUBWAY4) \ + X("sbwy_tunl_cstm7", MI_SUBWAY5) \ + X("sbwy_tunl_cstm8", MI_SUBWAY6) \ + X("sbwy_tunl_cstm10", MI_SUBWAY7) \ + X("sbwy_tunl_cstm9", MI_SUBWAY8) \ + X("sbwy_tunl_cstm11", MI_SUBWAY9) \ + X("sbwy_tunl_cstm1", MI_SUBWAY10) \ + X("sbwy_tunl_cstm2", MI_SUBWAY11) \ + X("sbwy_tunl_cstm4", MI_SUBWAY12) \ + X("sbwy_tunl_cstm3", MI_SUBWAY13) \ + X("sbwy_tunl_cstm5", MI_SUBWAY14) \ + X("subplatform_n2", MI_SUBWAY15) \ + X("suby_tunl_start", MI_SUBWAY16) \ + X("sbwy_tunl_start2", MI_SUBWAY17) \ + X("indy_tunl_start", MI_SUBWAY18) \ + X("indsubway03", MI_SUBPLATFORM_IND) \ + X("comerside_subway", MI_SUBPLATFORM_COMS) \ + X("subplatform", MI_SUBPLATFORM_COMS2) \ + X("subplatform_n", MI_SUBPLATFORM_COMN) \ + X("Otherside_subway", MI_SUBPLATFORM_SUB) \ + X("subplatform_sub", MI_SUBPLATFORM_SUB2) \ + X("files", MI_FILES) \ X("lamppost1", MI_LAMPPOST1) \ X("veg_palm04", MI_VEG_PALM01) \ X("veg_palwee02", MI_VEG_PALM02) \ @@ -107,10 +798,12 @@ X("telgrphpole02", MI_TELPOLE02) \ X("trafficlight1", MI_TRAFFICLIGHT01) \ X("parkbench1", MI_PARKBENCH) \ + X("Money", MI_MONEY) \ X("plc_stinger", MI_PLC_STINGER) \ X("od_lightbeam", MI_LIGHTBEAM) \ X("ap_radar1_01", MI_AIRPORTRADAR) \ X("rcbomb", MI_RCBOMB) \ + X("jm_salradio", MI_JM_SALRADIO) \ X("beachball", MI_BEACHBALL) \ X("sandcastle1", MI_SANDCASTLE1) \ X("sandcastle2", MI_SANDCASTLE2) \ @@ -138,54 +831,42 @@ X("blimp_night", MI_BLIMP_NIGHT) \ X("blimp_day", MI_BLIMP_DAY) \ X("yt_main_body", MI_YT_MAIN_BODY) \ - X("yt_main_body2", MI_YT_MAIN_BODY2) \ - X("oddjgaragdoor", MI_LCS_GARAGEDOOR01) \ - X("bombdoor", MI_LCS_GARAGEDOOR02) \ - X("door_bombshop", MI_LCS_GARAGEDOOR03) \ - X("vheistlocdoor", MI_LCS_GARAGEDOOR04) \ - X("door2_garage", MI_LCS_GARAGEDOOR05) \ - X("ind_slidedoor", MI_LCS_GARAGEDOOR06) \ - X("bankjobdoor", MI_LCS_GARAGEDOOR07) \ - X("door_jmsgrage", MI_LCS_GARAGEDOOR08) \ - X("ind_safeh_gdoor", MI_LCS_GARAGEDOOR09) \ - X("door_sfehousegrge", MI_LCS_GARAGEDOOR10) \ - X("shedgaragedoor", MI_LCS_GARAGEDOOR11) \ - X("door4_garage", MI_LCS_GARAGEDOOR12) \ - X("door_col_compnd_01", MI_LCS_GARAGEDOOR13) \ - X("door_col_compnd_02", MI_LCS_GARAGEDOOR14) \ - X("door_col_compnd_03", MI_LCS_GARAGEDOOR15) \ - X("door_col_compnd_04", MI_LCS_GARAGEDOOR16) \ - X("door_col_compnd_05", MI_LCS_GARAGEDOOR17) \ - X("impex_door", MI_LCS_GARAGEDOOR18) \ - X("SalvGarage", MI_LCS_GARAGEDOOR19) \ - X("door3_garage", MI_LCS_GARAGEDOOR20) \ - X("leveldoor2", MI_LCS_GARAGEDOOR21) \ - X("double_garage_dr", MI_LCS_GARAGEDOOR22) \ - X("amcogaragedoor", MI_LCS_GARAGEDOOR23) \ - X("towergaragedoor1", MI_LCS_GARAGEDOOR24) \ - X("towergaragedoor2", MI_LCS_GARAGEDOOR25) \ - X("towergaragedoor3", MI_LCS_GARAGEDOOR26) \ - X("plysve_gragedoor", MI_LCS_GARAGEDOOR27) \ - X("impexpsubgrgdoor", MI_LCS_GARAGEDOOR28) \ - X("Sub_sprayshopdoor", MI_LCS_GARAGEDOOR29) \ - X("ind_plyrwoor", MI_LCS_GARAGEDOOR30) \ - X("8ballsuburbandoor", MI_LCS_GARAGEDOOR31) \ - X("door_nthgrage", MI_LCS_GARAGEDOOR32) \ - X("hangardoor1", MI_LCS_GARAGEDOOR33) \ - X("hangardoor2", MI_LCS_GARAGEDOOR34) \ - X("neds_door", MI_LCS_GARAGEDOOR35) \ - X("fs_wrhsedoor", MI_LCS_GARAGEDOOR36) \ - X("jm_ContraGarage", MI_LCS_GARAGEDOOR37) \ - X("jm_imp_SalvGarage", MI_LCS_GARAGEDOOR38) \ - X("crushercrush", MI_LCS_GARAGEDOOR39) \ - X("crushertop", MI_LCS_GARAGEDOOR40) \ - X("crusher_crane", MI_LCS_CRANE01) \ + X("pt_barrier", MI_PT_BARRIER) \ + X("subwaygate", MI_SUBWAYGATE) \ + X("in_PMbridramp3", MI_IN_PMBRIDRAMP3) \ + X("in_PMbridg2_upgs", MI_IN_PMBRIDG2_UPGS) \ + X("in_PMbridge2", MI_IN_PMBRIDGE2) \ + X("in_PMbridg1_upgs", MI_IN_PMBRIDG1_UPGS) \ + X("pm_lightrig3", MI_PM_LIGHTRIG3) \ + X("pm_lightrig1", MI_PM_LIGHTRIG1) \ + X("in_pmSCAFF_UPS", MI_IN_PMSCAFF_UPS) \ + X("in_pm_concblok2", MI_IN_PM_CONCBLOK2) \ + X("in_pmSCAFFH_ns", MI_IN_PMSCAFFH_NS) \ + X("in_pm_gravl_jmp", MI_IN_PM_GRAVL_JMP) \ + X("in_pm_scaffcovr", MI_IN_PM_SCAFFCOVR) \ + X("in_pm_girder2", MI_IN_PM_GIRDER2) \ + X("in_pm_scaffH_we", MI_IN_PM_SCAFFH_WE) \ + X("in_pm_sixconc2", MI_IN_PM_SIXCONC2) \ + X("in_BMbridramp3", MI_IN_BMBRIDRAMP3) \ + X("in_BMbridg2_upgs", MI_IN_BMBRIDG2_UPGS) \ + X("in_BMbridge2", MI_IN_BMBRIDGE2) \ + X("in_BMbridg1_upgs", MI_IN_BMBRIDG1_UPGS) \ + X("Bm_lightrig3", MI_BM_LIGHTRIG3) \ + X("bm_lightrig1", MI_BM_LIGHTRIG1) \ + X("in_BmSCAFF_UPS", MI_IN_BMSCAFF_UPS) \ + X("in_Bm_concblok2", MI_IN_BM_CONCBLOK2) \ + X("in_BmSCAFFH_ns", MI_IN_BMSCAFFH_NS) \ + X("in_Bm_gravl_jmp", MI_IN_BM_GRAVL_JMP) \ + X("in_Bm_scaffcovr", MI_IN_BM_SCAFFCOVR) \ + X("in_Bm_girder2", MI_IN_BM_GIRDER2) \ + X("in_Bm_scaffH_we", MI_IN_BM_SCAFFH_WE) \ + X("in_Bm_sixconc2", MI_IN_BM_SIXCONC2) -// NB: MI_LCS_ <- temporary stuff so that garages started somewhat working + /*X("yt_main_body2", MI_YT_MAIN_BODY2) \*/ -#define X(name, var) extern int16 var; - MODELINDICES -#undef X +//#define X(name, var) extern int16 var; +// MODELINDICES +//#undef X // and some hardcoded ones // expand as needed @@ -576,11 +1257,7 @@ IsLightThatNeedsRepositioning(int16 id) return id == MI_SINGLESTREETLIGHTS1 || id == MI_SINGLESTREETLIGHTS2 || id == MI_SINGLESTREETLIGHTS3 || - id == MI_TRAFFICLIGHTS_MIAMI || - id == MI_TRAFFICLIGHTS_TWOVERTICAL || - id == MI_MLAMPPOST || - id == MI_STREETLAMP1 || - id == MI_STREETLAMP2; + id == MI_DOUBLESTREETLIGHTS; } inline bool @@ -592,7 +1269,9 @@ IsLightObject(int16 id) id == MI_SINGLESTREETLIGHTS2 || id == MI_SINGLESTREETLIGHTS3 || id == MI_DOUBLESTREETLIGHTS || - id == MI_TRAFFICLIGHTS_TWOVERTICAL; + id == MI_TRAFFICLIGHTS_TWOVERTICAL || + id == MI_TRAFFICLIGHTS || + id == MI_FENCE; } inline bool @@ -624,24 +1303,26 @@ IsPedModel(int16 id) inline bool IsPalmTreeModel(int16 id) { - return id == MI_VEG_PALM01 || - id == MI_VEG_PALM02 || - id == MI_VEG_PALM03 || - id == MI_VEG_PALM04 || - id == MI_VEG_PALM05 || - id == MI_VEG_PALM06 || - id == MI_VEG_PALM07 || - id == MI_VEG_PALM08; + return false; } inline bool IsTreeModel(int16 id) { - return id == MI_TREE2 || + return id == MI_TREE1 || + id == MI_TREE2 || id == MI_TREE3 || + id == MI_TREE4 || + id == MI_TREE5 || id == MI_TREE6 || + id == MI_TREE7 || id == MI_TREE8 || - IsPalmTreeModel(id); + id == MI_TREE9 || + id == MI_TREE10 || + id == MI_TREE11 || + id == MI_TREE12 || + id == MI_TREE13 || + id == MI_TREE14; } inline bool diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index c84b6732..a675fe4e 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -50,7 +50,12 @@ void CCranes::InitCranes(void) for (int j = 0; j < NUMSECTORS_Y; j++) { for (CPtrNode* pNode = CWorld::GetSector(i, j)->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (MI_LCS_CRANE01 == pEntity->GetModelIndex()) + if (MODELID_CRANE_1 == pEntity->GetModelIndex() || + MODELID_CRANE_2 == pEntity->GetModelIndex() || + MODELID_CRANE_3 == pEntity->GetModelIndex() || + MODELID_CRANE_4 == pEntity->GetModelIndex() || + MODELID_CRANE_5 == pEntity->GetModelIndex() || + MODELID_CRANE_6 == pEntity->GetModelIndex()) AddThisOneCrane(pEntity); } } @@ -58,7 +63,12 @@ void CCranes::InitCranes(void) // TODO(LCS) for (CPtrNode* pNode = CWorld::GetBigBuildingList(LEVEL_INDUSTRIAL).first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (MI_LCS_CRANE01 == pEntity->GetModelIndex()) + if (MODELID_CRANE_1 == pEntity->GetModelIndex() || + MODELID_CRANE_2 == pEntity->GetModelIndex() || + MODELID_CRANE_3 == pEntity->GetModelIndex() || + MODELID_CRANE_4 == pEntity->GetModelIndex() || + MODELID_CRANE_5 == pEntity->GetModelIndex() || + MODELID_CRANE_6 == pEntity->GetModelIndex()) AddThisOneCrane(pEntity); } From b35b0c598d183e2ba73c73ad82a03f833556dc27 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 03:09:15 +0200 Subject: [PATCH 03/15] Enable GTA_BRIDGE --- src/audio/AudioLogic.cpp | 5 +++-- src/control/Bridge.cpp | 20 ++++++++++++++++++++ src/control/Bridge.h | 1 + src/core/config.h | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index c2050f59..a06df0d0 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -9311,7 +9311,8 @@ cAudioManager::ProcessBridge() void cAudioManager::ProcessBridgeWarning() { - if (CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { + // TODO: LCS +/* if (CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { m_sQueueSample.m_nVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; @@ -9332,7 +9333,7 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } - } + }*/ } void diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp index 1e63cf30..e7c76a9c 100644 --- a/src/control/Bridge.cpp +++ b/src/control/Bridge.cpp @@ -161,3 +161,23 @@ bool CBridge::ThisIsABridgeObjectMovingUp(int index) return false; #endif } + +void CBridge::ForceBridgeState(uint8 state) +{ +#ifdef GTA_BRIDGE + State = state; + switch (state) + { + case STATE_BRIDGE_LOCKED: + case STATE_LIFT_PART_MOVING_DOWN: + case STATE_LIFT_PART_ABOUT_TO_MOVE_UP: + ThePaths.SetLinksBridgeLights(-330.0f, -230.0f, -700.0f, -588.0f, true); + break; + case STATE_BRIDGE_ALWAYS_UNLOCKED: + ThePaths.SetLinksBridgeLights(-330.0f, -230.0f, -700.0f, -588.0f, false); + break; + default: + break; + } +#endif +} \ No newline at end of file diff --git a/src/control/Bridge.h b/src/control/Bridge.h index dd781a9a..e639d4c1 100644 --- a/src/control/Bridge.h +++ b/src/control/Bridge.h @@ -26,4 +26,5 @@ public: static bool ShouldLightsBeFlashing(); static void FindBridgeEntities(); static bool ThisIsABridgeObjectMovingUp(int); + static void ForceBridgeState(uint8 state); }; diff --git a/src/core/config.h b/src/core/config.h index 07773543..2685c687 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -198,7 +198,7 @@ enum Config { //#define ANIM_COMPRESSION // only keep most recently used anims uncompressed #define GTA_TRAIN -//#define GTA_BRIDGE +#define GTA_BRIDGE #if defined GTA_PS2 # define GTA_PS2_STUFF From 3565f179af95e4b0c62831fb6189bb4ff671d1e6 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 03:12:01 +0200 Subject: [PATCH 04/15] Add TXD mid field --- src/modelinfo/ModelIndices.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index e5c7c1e5..cbc4ede8 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -288,6 +288,7 @@ struct CModelIndices int16 DOOR2_SJL; int16 SJL_PORTACABIN; int16 SJL_PORTACABINRED; + int16 advert_test; // txd }; extern CModelIndices *gpModelIndices; From 0aad73f4a1fdc4e900eeafb6bd89f462f1f121af Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 03:39:24 +0200 Subject: [PATCH 05/15] Remove size assert --- src/audio/AudioManager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index b5e9b499..f715fb45 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -544,8 +544,8 @@ public: #endif }; -#ifdef AUDIO_MSS -static_assert(sizeof(cAudioManager) == 0x5558, "cAudioManager: error"); -#endif +//#ifdef AUDIO_MSS +//static_assert(sizeof(cAudioManager) == 0x5558, "cAudioManager: error"); +//#endif extern cAudioManager AudioManager; From 2814f2e8cf4491adf4bfccb4371ada95243ce5fa Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 23 Jan 2021 12:49:54 +0100 Subject: [PATCH 06/15] wrong path node array --- src/control/PathFind.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index cbc29db4..2d3972f6 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -338,17 +338,17 @@ CPathFind::StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, InfoForTileCars[i].x = x/16.0f; InfoForTileCars[i].y = y/16.0f; InfoForTileCars[i].z = z/16.0f; - InfoForTilePeds[i].width = 8.0f*Min(width, 15.0f); + InfoForTileCars[i].width = 8.0f*Min(width, 15.0f); InfoForTileCars[i].numLeftLanes = numLeft; InfoForTileCars[i].numRightLanes = numRight; - InfoForTilePeds[i].crossing = false; - InfoForTilePeds[i].speedLimit = 0; - InfoForTilePeds[i].roadBlock = false; - InfoForTilePeds[i].disabled = false; - InfoForTilePeds[i].waterPath = false; - InfoForTilePeds[i].onlySmallBoats = false; - InfoForTilePeds[i].betweenLevels = false; - InfoForTilePeds[i].spawnRate = Min(spawnRate, 15); + InfoForTileCars[i].crossing = false; + InfoForTileCars[i].speedLimit = 0; + InfoForTileCars[i].roadBlock = false; + InfoForTileCars[i].disabled = false; + InfoForTileCars[i].waterPath = false; + InfoForTileCars[i].onlySmallBoats = false; + InfoForTileCars[i].betweenLevels = false; + InfoForTileCars[i].spawnRate = Min(spawnRate, 15); if(node == 11) InfoForTileCars[id*12].SwapConnectionsToBeRightWayRound(); From f6fb473cf97b5175263c1b1cc63bc512dc567ac7 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 23 Jan 2021 12:59:52 +0100 Subject: [PATCH 07/15] revert accident --- src/save/GenericGameStorage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index ee946480..d177aa17 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -345,7 +345,7 @@ GenericLoad() #endif ReadDataFromBufferPointer(buf, CGame::currArea); ReadDataFromBufferPointer(buf, CVehicle::bAllTaxisHaveNitro); - buf += align4bytes(sizeof(CPad::bInvertLook4Pad)); + ReadDataFromBufferPointer(buf, CPad::bInvertLook4Pad); ReadDataFromBufferPointer(buf, CTimeCycle::m_ExtraColour); ReadDataFromBufferPointer(buf, CTimeCycle::m_bExtraColourOn); ReadDataFromBufferPointer(buf, CTimeCycle::m_ExtraColourInter); From b5c4866964a281ad9ab18dfd7218e1ef168f15f4 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 23 Jan 2021 15:29:00 +0300 Subject: [PATCH 08/15] added some missing functions --- src/control/Garages.cpp | 40 +++++++++++++++++++++++++++++++++++++++- src/control/Garages.h | 5 +++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 39fa5c94..e3b5aa8c 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -106,7 +106,7 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLL { MI_VOODOO, MI_CUBAN, MI_CADDY, MI_BAGGAGE, MI_MRWHOOP, MI_PIZZABOY } }; -const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; // what is this? +const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; int32 CGarages::BankVansCollected; bool CGarages::BombsAreFree; @@ -2357,3 +2357,41 @@ CGarages::IsModelIndexADoor(uint32 id) id == MI_GARAGEDOOR25 || id == MI_GARAGEDOOR26; } + +void CGarages::StopCarFromBlowingUp(CAutomobile* pCar) +{ + pCar->m_fFireBlowUpTimer = 0.0f; + pCar->m_fHealth = Max(pCar->m_fHealth, 300.0f); + pCar->Damage.SetEngineStatus(Max(pCar->Damage.GetEngineStatus(), 275)); +} + +bool CGarage::Does60SecondsNeedThisCarAtAll(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return true; + } + return false; +} + +bool CGarage::Does60SecondsNeedThisCar(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return m_bCollectedCarsState & BIT(i); + } + return false; +} + +void CGarage::MarkThisCarAsCollectedFor60Seconds(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + m_bCollectedCarsState |= BIT(i); + } +} + +bool CGarage::IsPlayerEntirelyInsideGarage() +{ + return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f); +} diff --git a/src/control/Garages.h b/src/control/Garages.h index 39327e4e..07d5f712 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -182,6 +182,10 @@ public: void FindDoorsEntities(); void FindDoorsEntitiesSectorList(CPtrList&, bool); void PlayerArrestedOrDied(); + bool Does60SecondsNeedThisCarAtAll(int mi); + bool Does60SecondsNeedThisCar(int mi); + void MarkThisCarAsCollectedFor60Seconds(int mi); + bool IsPlayerEntirelyInsideGarage(); bool IsPointInsideGarage(CVector); bool IsPointInsideGarage(CVector, float); @@ -254,6 +258,7 @@ public: static bool IsModelIndexADoor(uint32 id); static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; } static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; } + static void StopCarFromBlowingUp(CAutomobile*); static void SetMaxNumStoredCarsForGarage(int16 garage, uint8 num) { aGarages[garage].m_nMaxStoredCars = num; } static bool IsCarSprayable(CVehicle*); From 73f1340afb80f8749cb309b4ac89b9f13f4dff31 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 23 Jan 2021 15:59:38 +0300 Subject: [PATCH 09/15] Store all settings in .INI --- src/core/ControllerConfig.cpp | 2 +- src/core/Frontend.cpp | 58 +++-- src/core/Frontend.h | 9 +- src/core/MenuScreensCustom.cpp | 30 +-- src/core/Pad.cpp | 2 +- src/core/main.h | 2 + src/core/re3.cpp | 429 +++++++++++++++++++++++++------- src/extras/frontendoption.cpp | 6 +- src/extras/frontendoption.h | 6 +- src/render/WaterCreatures.cpp | 1 + src/render/WaterCreatures.h | 3 +- src/save/GenericGameStorage.cpp | 4 + src/skel/glfw/glfw.cpp | 5 + src/skel/win/win.cpp | 5 + 14 files changed, 432 insertions(+), 130 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 585eac4e..9bb459f9 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2768,7 +2768,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/Frontend.cpp b/src/core/Frontend.cpp index 086a9887..12e4b16a 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -563,13 +563,21 @@ CMenuManager::Initialise(void) DMAudio.Service(); DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); +#ifdef FIX_BUGS + static bool firstTime = true; + if (firstTime) { + DMAudio.SetRadioInCar(m_PrefsRadioStation); + firstTime = false; + } else +#endif m_PrefsRadioStation = DMAudio.GetRadioInCar(); + DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); if (DMAudio.IsMP3RadioChannelAvailable()) { if (m_PrefsRadioStation < WILDSTYLE || m_PrefsRadioStation > USERTRACK) - m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10; + m_PrefsRadioStation = CGeneral::GetRandomNumber() % (USERTRACK + 1); } else if (m_PrefsRadioStation < WILDSTYLE || m_PrefsRadioStation > WAVE) - m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9; + m_PrefsRadioStation = CGeneral::GetRandomNumber() % (WAVE + 1); CFileMgr::SetDir(""); //CFileMgr::SetDir(""); @@ -653,7 +661,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl) m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; m_bStartWaitingForKeyBind = false; +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#else SaveSettings(); +#endif } } @@ -3032,6 +3044,11 @@ CMenuManager::LoadSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); +#ifdef LOAD_INI_SETTINGS + LoadINISettings(); + LoadINIControllerSettings(); // Calling that after LoadINISettings is important because of gSelectedJoystickName loading +#endif + #ifdef FIX_BUGS TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; #endif @@ -3077,15 +3094,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"; static int SomeVersion = 3; @@ -3144,7 +3158,14 @@ CMenuManager::SaveSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); -#ifdef LOAD_INI_SETTINGS +#else + m_lastWorking3DAudioProvider = m_nPrefsAudio3DProviderIndex; + static bool firstTime = true; + // In other conditions we already call SaveINIControllerSettings explicitly. + if (firstTime) { + SaveINIControllerSettings(); + firstTime = false; + } SaveINISettings(); #endif } @@ -4424,19 +4445,19 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u 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(); @@ -4796,6 +4817,9 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u TheCamera.m_bUseMouse3rdPerson = false; #endif SaveSettings(); +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#endif } SetHelperText(2); break; @@ -4826,7 +4850,8 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u *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) @@ -4982,7 +5007,8 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u *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) diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 4a812b05..c1c3983e 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -392,6 +392,7 @@ struct CCustomScreenLayout { struct CCFO { int8 *value; + const char *saveCat; const char *save; }; @@ -406,11 +407,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; @@ -426,8 +428,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; @@ -581,7 +584,7 @@ public: int8 m_bLanguageLoaded; uint8 m_PrefsAllowNastyGame; int8 m_PrefsMP3BoostVolume; - uint8 m_ControlMethod; + int8 m_ControlMethod; int32 m_nPrefsVideoMode; int32 m_nDisplayVideoMode; int32 m_nMouseTempPosX; diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 70c92ce8..d34ff8b9 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -24,51 +24,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) }, 0, 0, MENUALIGN_LEFT, + #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) }, 0, 0, MENUALIGN_LEFT, #else #define VIDEOMODE_SELECTOR #endif #ifdef MULTISAMPLING - #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) }, 0, 0, MENUALIGN_LEFT, + #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "Graphics", "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) }, 0, 0, MENUALIGN_LEFT, #else #define MULTISAMPLING_SELECTOR #endif #ifdef CUTSCENE_BORDERS_SWITCH - #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&FrontEndMenuManager.m_PrefsCutsceneBorders, "CutsceneBorders", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, + #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&FrontEndMenuManager.m_PrefsCutsceneBorders, "Display", "CutsceneBorders", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, #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) }, 0, 0, MENUALIGN_LEFT, + #define FREE_CAM_TOGGLE MENUACTION_CFO_SELECT, "FEC_FRC", { new CCFOSelect((int8*)&TheCamera.bFreeCam, "Display", "FreeCam", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, #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) }, 0, 0, MENUALIGN_LEFT, + #define DUALPASS_SELECTOR MENUACTION_CFO_SELECT, "FEM_2PR", { new CCFOSelect((int8*)&gPS2alphaTest, "Graphics", "PS2AlphaTest", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, #else #define DUALPASS_SELECTOR #endif #ifdef NO_ISLAND_LOADING - #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&FrontEndMenuManager.m_PrefsIslandLoading, "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) }, 0, 0, MENUALIGN_LEFT, + #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&FrontEndMenuManager.m_PrefsIslandLoading, "Graphics", "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) }, 0, 0, MENUALIGN_LEFT, #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) }, 0, 0, MENUALIGN_LEFT, \ - MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "MotionBlur", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, + MENUACTION_CFO_SELECT, "FED_CLF", { new CCFOSelect((int8*)&CPostFX::EffectSwitch, "Graphics", "ColourFilter", filterNames, ARRAY_SIZE(filterNames), false) }, 0, 0, MENUALIGN_LEFT, \ + MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "Graphics", "MotionBlur", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, #else #define POSTFX_SELECTORS #endif #ifdef INVERT_LOOK_FOR_PAD - #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_ILU", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, nil, off_on, 2, false) }, 150, 0, MENUALIGN_LEFT, + #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_ILU", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "Controller", "InvertPad", off_on, 2, false) }, 150, 0, MENUALIGN_LEFT, #else #define INVERT_PAD_SELECTOR #endif @@ -388,7 +388,7 @@ CMenuScreenCustom aScreens[] = { MENUACTION_RADARMODE, "FED_RDR", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, 0, 0, MENUALIGN_LEFT, MENUACTION_HUD, "FED_HUD", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, 0, 0, MENUALIGN_LEFT, MENUACTION_SUBTITLES, "FED_SUB", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, 0, 0, MENUALIGN_LEFT, - MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefDisplay) }, 320, 0, MENUALIGN_CENTER, + MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefDisplay) }, 320, 0, MENUALIGN_CENTER, MENUACTION_GOBACK, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE}, 320, 0, MENUALIGN_CENTER, }, #endif @@ -401,9 +401,9 @@ CMenuScreenCustom aScreens[] = { MENUACTION_LANG_ITA, "FEL_ITA", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, MENUACTION_LANG_SPA, "FEL_SPA", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, #ifdef MORE_LANGUAGES - MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, LangPolSelect) }, 0, 0, MENUALIGN_CENTER, - MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, LangRusSelect) }, 0, 0, MENUALIGN_CENTER - MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, LangJapSelect) }, 0, 0, MENUALIGN_CENTER, + MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, nil, LangPolSelect) }, 0, 0, MENUALIGN_CENTER, + MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, nil, LangRusSelect) }, 0, 0, MENUALIGN_CENTER + MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, nil, LangJapSelect) }, 0, 0, MENUALIGN_CENTER, #endif MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 0, 0, MENUALIGN_CENTER, }, @@ -695,7 +695,7 @@ CMenuScreenCustom aScreens[] = { MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, 0, 0, MENUALIGN_LEFT, #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) }, 320, 0, MENUALIGN_CENTER, + MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefGraphics) }, 320, 0, MENUALIGN_CENTER, MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 320, 0, MENUALIGN_CENTER, }, #endif @@ -705,7 +705,7 @@ CMenuScreenCustom aScreens[] = { { "FEC_JOD", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({0, 0, 0, false, false, 30}), nil, MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, 0, - MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, DetectJoystickDraw, nil) }, 80, 200, MENUALIGN_LEFT, + MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, nil, DetectJoystickDraw, nil) }, 80, 200, MENUALIGN_LEFT, MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 320, 225, MENUALIGN_CENTER, }, #endif diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 671a4552..5c79c0d3 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -61,7 +61,7 @@ bool CPad::bOldDisplayNoControllerMessage; bool CPad::m_bMapPadOneToPadTwo; bool CPad::m_bDebugCamPCOn; bool CPad::bHasPlayerCheated; -bool CPad::bInvertLook4Pad = true; +bool CPad::bInvertLook4Pad; #ifdef GTA_PS2 unsigned char act_direct[6]; unsigned char act_align[6]; diff --git a/src/core/main.h b/src/core/main.h index 37a82fb2..eacfd8e1 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -47,6 +47,8 @@ void TheModelViewer(void); #ifdef LOAD_INI_SETTINGS void LoadINISettings(); void SaveINISettings(); +void LoadINIControllerSettings(); +void SaveINIControllerSettings(); #endif #ifdef NEW_RENDERER diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 7b3ab10c..8ec1bd01 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -33,10 +33,9 @@ #include "custompipes.h" #include "MemoryHeap.h" #include "FileMgr.h" - -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#include "Camera.h" +#include "MBlur.h" #include "ControllerConfig.h" -#endif #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS #include "crossplatform.h" @@ -96,16 +95,16 @@ CustomFrontendOptionsPopulate(void) if (fd) { #ifdef GRAPHICS_MENU_OPTIONS FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); - FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); - FrontendOptionAddSelect("FED_PRM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); - FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); - FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); + FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss"); #else FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false); - FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); - FrontendOptionAddSelect("FED_PRM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); - FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); - FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); + FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss"); #endif CFileMgr::CloseFile(fd); } @@ -118,53 +117,298 @@ 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, ""); + std::string strval = cfg.get(cat, key, "\xBA"); const char *value = strval.c_str(); - if (value && value[0] != '\0') - return atoi(value); - - return original; + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(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, bool *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); - - return original; + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(value, &endPtr, 0); + return true; + } + return false; } -void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed) +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); + return true; + } + return false; +} + +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; +} + +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); + return true; + } + return false; +} + +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 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 StoreIni(const char *cat, const char *key, uint8 val) +{ + char temp[10]; + 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 StoreIni(const char *cat, const char *key, float val) +{ + 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", "PED_DUCK", "PED_ANSWER_PHONE", +#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", "UNKNOWN_ACTION" }; + +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() +{ + 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; + } + } + } + + ControlsManager.SetControllerKeyAssociatedWithAction((e_ControllerAction)i, contKey, (eControllerType)contType); + } + } } } -void CheckAndSaveIniFloat(const char *cat, const char *key, float val, bool &changed) +void SaveINIControllerSettings() { - 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); + 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; + } + } + } + int len = strlen(value); + if (len > 0) + value[len - 1] = '\0'; // to remove comma + + StoreIni("Bindings", iniControllerActions[i], value, 128); } + + cfg.write_file("re3.ini"); } void LoadINISettings() { cfg.load_file("reVC.ini"); +#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", "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", "MP3BoostVolume", &FrontEndMenuManager.m_PrefsMP3BoostVolume); + 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", "FrameLimiter", &FrontEndMenuManager.m_PrefsFrameLimiter); +#ifdef LEGACY_MENU_OPTIONS + ReadIniIfExists("Graphics", "VSync", &FrontEndMenuManager.m_PrefsVsyncDisp); + ReadIniIfExists("Graphics", "Trails", &CMBlur::BlurOn); +#endif + ReadIniIfExists("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256); + ReadIniIfExists("Controller", "Method", &FrontEndMenuManager.m_ControlMethod); + ReadIniIfExists("General", "Language", &FrontEndMenuManager.m_PrefsLanguage); + ReadIniIfExists("Display", "ShowHud", &FrontEndMenuManager.m_PrefsShowHud); + ReadIniIfExists("Display", "RadarMode", &FrontEndMenuManager.m_PrefsRadarMode); + ReadIniIfExists("Display", "ShowLegends", &FrontEndMenuManager.m_PrefsShowLegends); + +#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 DONT_TRUST_RECOGNIZED_JOYSTICKS // Written by assuming the codes below will run after _InputInitialiseJoys(). - strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str()); + std::string strval = cfg.get("Controller", "JoystickName", ""); + const char *value = strval.c_str(); + strcpy(gSelectedJoystickName, value); if(gSelectedJoystickName[0] != '\0') { for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { @@ -187,6 +431,7 @@ void LoadINISettings() CFileMgr::CloseFile(gta3set); } CFileMgr::SetDir(""); + // We call LoadINIControllerSettings after this func., so calling here isn't needed break; } } @@ -203,7 +448,7 @@ 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); + 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; } @@ -211,39 +456,70 @@ 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 - gBackfaceCulling = CheckAndReadIniInt("Rendering", "BackfaceCulling", gBackfaceCulling); - -#ifdef PROPER_SCALING - CDraw::ms_bProperScaling = CheckAndReadIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling); -#endif -#ifdef FIX_RADAR - CDraw::ms_bFixRadar = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar); -#endif -#ifdef FIX_SPRITES - CDraw::ms_bFixSprites = CheckAndReadIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites); -#endif } void SaveINISettings() { - bool changed = false; +#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", "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", "MP3BoostVolume", FrontEndMenuManager.m_PrefsMP3BoostVolume); + 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); +#ifdef LEGACY_MENU_OPTIONS + StoreIni("Graphics", "VSync", FrontEndMenuManager.m_PrefsVsyncDisp); + StoreIni("Graphics", "Trails", CMBlur::BlurOn); +#endif + StoreIni("Graphics", "FrameLimiter", FrontEndMenuManager.m_PrefsFrameLimiter); + StoreIni("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256); + StoreIni("Controller", "Method", FrontEndMenuManager.m_ControlMethod); + StoreIni("General", "Language", FrontEndMenuManager.m_PrefsLanguage); + StoreIni("Display", "ShowHud", FrontEndMenuManager.m_PrefsShowHud); + StoreIni("Display", "RadarMode", FrontEndMenuManager.m_PrefsRadarMode); + StoreIni("Display", "ShowLegends", FrontEndMenuManager.m_PrefsShowLegends); + +#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 + StoreIni("Rendering", "BackfaceCulling", gBackfaceCulling); + +#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 DONT_TRUST_RECOGNIZED_JOYSTICKS - if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) { - changed = true; - cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName); - } + StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); #endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { @@ -254,36 +530,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 - CheckAndSaveIniInt("Rendering", "BackfaceCulling", gBackfaceCulling, changed); - -#ifdef PROPER_SCALING - CheckAndSaveIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling, changed); -#endif -#ifdef FIX_RADAR - CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed); -#endif -#ifdef FIX_SPRITES - CheckAndSaveIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites, changed); -#endif - - if (changed) - cfg.write_file("reVC.ini"); + cfg.write_file("reVC.ini"); } #endif diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index 8a95a49a..2660e75e 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -111,7 +111,7 @@ void FrontendOptionAddBuiltinAction(const char* gxtKey, uint16 x, uint16 y, uint option.m_TargetMenu = targetMenu; } -void FrontendOptionAddSelect(const char* gxtKey, uint16 x, uint16 y, uint8 align, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveName, bool disableIfGameLoaded) +void FrontendOptionAddSelect(const char* gxtKey, uint16 x, uint16 y, uint8 align, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveCat, const char* saveName, bool disableIfGameLoaded) { int8 screenOptionOrder = RegisterNewOption(); @@ -130,13 +130,14 @@ void FrontendOptionAddSelect(const char* gxtKey, uint16 x, uint16 y, uint8 align option.m_CFOSelect->displayedValue = *var; option.m_CFOSelect->lastSavedValue = *var; } + option.m_CFOSelect->saveCat = saveCat; option.m_CFOSelect->save = saveName; option.m_CFOSelect->onlyApplyOnEnter = onlyApplyOnEnter; option.m_CFOSelect->changeFunc = changeFunc; option.m_CFOSelect->disableIfGameLoaded = disableIfGameLoaded; } -void FrontendOptionAddDynamic(const char* gxtKey, uint16 x, uint16 y, uint8 align, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveName) +void FrontendOptionAddDynamic(const char* gxtKey, uint16 x, uint16 y, uint8 align, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveCat, const char* saveName) { int8 screenOptionOrder = RegisterNewOption(); @@ -150,6 +151,7 @@ void FrontendOptionAddDynamic(const char* gxtKey, uint16 x, uint16 y, uint8 alig option.m_CFODynamic->drawFunc = drawFunc; option.m_CFODynamic->buttonPressFunc = buttonPressFunc; option.m_CFODynamic->value = var; + option.m_CFODynamic->saveCat = saveCat; option.m_CFODynamic->save = saveName; } diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h index 2719f076..05cd5fa0 100644 --- a/src/extras/frontendoption.h +++ b/src/extras/frontendoption.h @@ -76,10 +76,10 @@ uint8 GetNumberOfMenuOptions(int screen); void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false); -// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to saveName param. obv), otherwise pass nil/0 +// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to saveCat and saveKey param. obv), otherwise pass nil/0 void FrontendOptionAddBuiltinAction(const char* gxtKey, uint16 x, uint16 y, uint8 align, int action, int targetMenu = MENUPAGE_NONE, int saveSlot = SAVESLOT_NONE); -void FrontendOptionAddSelect(const char* gxtKey, uint16 x, uint16 y, uint8 align, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveName = nil, bool disableIfGameLoaded = false); -void FrontendOptionAddDynamic(const char* gxtKey, uint16 x, uint16 y, uint8 align, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveName = nil); +void FrontendOptionAddSelect(const char* gxtKey, uint16 x, uint16 y, uint8 align, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveCat = nil, const char* saveKey = nil, bool disableIfGameLoaded = false); +void FrontendOptionAddDynamic(const char* gxtKey, uint16 x, uint16 y, uint8 align, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveCat = nil, const char* saveKey = nil); // lineHeight = 0 means game will use MENU_DEFAULT_LINE_HEIGHT uint8 FrontendScreenAdd(const char* gxtKey, int prevPage, int lineHeight, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil); diff --git a/src/render/WaterCreatures.cpp b/src/render/WaterCreatures.cpp index 01f241b3..92fb74ee 100644 --- a/src/render/WaterCreatures.cpp +++ b/src/render/WaterCreatures.cpp @@ -6,6 +6,7 @@ #include "Camera.h" #include "PlayerPed.h" #include "General.h" +#include "Object.h" int CWaterCreatures::nNumActiveSeaLifeForms; CWaterCreature CWaterCreatures::aWaterCreatures[NUM_WATER_CREATURES]; diff --git a/src/render/WaterCreatures.h b/src/render/WaterCreatures.h index 9ef8198c..32754a10 100644 --- a/src/render/WaterCreatures.h +++ b/src/render/WaterCreatures.h @@ -1,5 +1,6 @@ #pragma once -#include "Object.h" + +class CObject; enum eFishSlotState { WATER_CREATURE_INIT = 0, diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index ee946480..54685b66 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -345,7 +345,11 @@ GenericLoad() #endif ReadDataFromBufferPointer(buf, CGame::currArea); ReadDataFromBufferPointer(buf, CVehicle::bAllTaxisHaveNitro); +#ifdef LOAD_INI_SETTINGS buf += align4bytes(sizeof(CPad::bInvertLook4Pad)); +#else + ReadDataFromBufferPointer(buf, CPad::bInvertLook4Pad); +#endif ReadDataFromBufferPointer(buf, CTimeCycle::m_ExtraColour); ReadDataFromBufferPointer(buf, CTimeCycle::m_bExtraColourOn); ReadDataFromBufferPointer(buf, CTimeCycle::m_ExtraColourInter); diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 8c9289d2..a86ccaf8 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1634,6 +1634,7 @@ main(int argc, char *argv[]) SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &NewStickyKeys, SPIF_SENDCHANGE); #endif + // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); @@ -1646,6 +1647,10 @@ main(int argc, char *argv[]) } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); +#endif } #ifdef _WIN32 diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 242a3fe2..02b3f917 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2142,6 +2142,7 @@ WinMain(HINSTANCE instance, ShowWindow(PSGLOBAL(window), cmdShow); UpdateWindow(PSGLOBAL(window)); + // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); @@ -2154,6 +2155,10 @@ WinMain(HINSTANCE instance, } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); +#endif } SetErrorMode(SEM_FAILCRITICALERRORS); From 45c2488e367dad03726df94cf885c5655d6e47ab Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 23 Jan 2021 16:04:19 +0300 Subject: [PATCH 10/15] Migrate from old .ini to new .ini --- src/core/re3.cpp | 9 ++++++++- src/extras/ini_parser.hpp | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 8ec1bd01..3d94cafd 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -439,6 +439,7 @@ void LoadINISettings() #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]; @@ -448,7 +449,13 @@ void LoadINISettings() // CFO check if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { // CFO only supports saving uint8 right now - ReadIniIfExists(option.m_CFO->saveCat, 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; } diff --git a/src/extras/ini_parser.hpp b/src/extras/ini_parser.hpp index 8e88bc29..7bea024c 100644 --- a/src/extras/ini_parser.hpp +++ b/src/extras/ini_parser.hpp @@ -158,6 +158,25 @@ namespace linb /* Too lazy to continue this container... If you need more methods, just add it */ + // re3 + void remove(const string_type& sect, const key_type& key) + { + auto it = this->find(sect); + if(it != this->end()) + { + it->second.erase(key); + } + } + + int category_size(const string_type& sect) + { + auto it = this->find(sect); + if(it != this->end()) + { + return it->second.size(); + } + return 0; + } #if 1 bool read_file(const char_type* filename) From cfac29b0ef89fce769a007bad113681170f5794c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 15:09:34 +0200 Subject: [PATCH 11/15] Remove restrictions in CGame::Process --- src/core/Game.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 3f34617f..b18ab4e1 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -856,9 +856,9 @@ void CGame::Process(void) gameProcessPirateCheck = 2; } #endif - uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); + //uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); CStreaming::Update(); - uint32 processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime; + //uint32 processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime; CWindModifiers::Number = 0; if (!CTimer::GetIsPaused()) { @@ -897,13 +897,13 @@ void CGame::Process(void) CEventList::Update(); CParticle::Update(); gFireManager.Update(); - if (processTime >= 2) { - CPopulation::Update(false); - } else { - uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); + //if (processTime >= 2) { + // CPopulation::Update(false); + //} else { + // uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); CPopulation::Update(true); - processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime; - } + // processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime; + //} CWeapon::UpdateWeapons(); if (!CCutsceneMgr::IsRunning()) CTheCarGenerators::Process(); @@ -941,7 +941,7 @@ void CGame::Process(void) if (!CReplay::IsPlayingBack()) { PUSH_MEMID(MEMID_CARS); - if (processTime < 2) + //if (processTime < 2) CCarCtrl::GenerateRandomCars(); CRoadBlocks::GenerateRoadBlocks(); CCarCtrl::RemoveDistantCars(); From 1b3284042446551f6ff5a2c723957056131f5f31 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 22 Jan 2021 23:40:28 +0300 Subject: [PATCH 12/15] No more resetting bindings for joypad, create .ini at the first start, joystick hotplug for Linux --- src/core/ControllerConfig.cpp | 87 +++++++++++++++++++++------------- src/core/ControllerConfig.h | 4 ++ src/core/Frontend.cpp | 18 +++---- src/core/MenuScreensCustom.cpp | 18 ++++++- src/core/main.h | 2 +- src/core/re3.cpp | 59 +++++++---------------- src/skel/glfw/glfw.cpp | 18 ++++++- src/skel/win/win.cpp | 14 +++++- 8 files changed, 133 insertions(+), 87 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 9bb459f9..fcc4503a 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -31,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++) @@ -317,6 +320,10 @@ void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerSta } } +#ifdef LOAD_INI_SETTINGS +uint32 CControllerConfigManager::ms_padButtonsInited = 0; +#endif + void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { m_bFirstCapture = true; @@ -325,6 +332,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 @@ -337,50 +360,50 @@ 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); SetControllerKeyAssociatedWithAction(PED_DUCK, 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_ANSWER_PHONE, 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); /*******************************************************************************************/ } @@ -389,47 +412,47 @@ 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); SetControllerKeyAssociatedWithAction(PED_DUCK, 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_ANSWER_PHONE, 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); diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index eb66937a..604fb5cc 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -144,6 +144,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/Frontend.cpp b/src/core/Frontend.cpp index 12e4b16a..0a9db5a4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3045,8 +3045,13 @@ CMenuManager::LoadSettings() CFileMgr::SetDir(""); #ifdef LOAD_INI_SETTINGS - LoadINISettings(); - LoadINIControllerSettings(); // Calling that after LoadINISettings is important because of gSelectedJoystickName loading + if (LoadINISettings()) { + LoadINIControllerSettings(); + } else { + // no re3.ini, create it + SaveINISettings(); + SaveINIControllerSettings(); + } #endif #ifdef FIX_BUGS @@ -3160,12 +3165,6 @@ CMenuManager::SaveSettings() #else m_lastWorking3DAudioProvider = m_nPrefsAudio3DProviderIndex; - static bool firstTime = true; - // In other conditions we already call SaveINIControllerSettings explicitly. - if (firstTime) { - SaveINIControllerSettings(); - firstTime = false; - } SaveINISettings(); #endif } @@ -5450,6 +5449,9 @@ CMenuManager::SwitchMenuOnAndOff() ThingsToDoBeforeLeavingPage(); #endif SaveSettings(); +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#endif pControlEdit = nil; pEditString = nil; DisplayComboButtonErrMsg = false; diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index d34ff8b9..770e8ec1 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. @@ -278,6 +279,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; @@ -306,6 +308,7 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { strcpy(gSelectedJoystickName, joyname); PSGLOBAL(joy1id) = found; + cachedButtonNum = numButtons; } } if (PSGLOBAL(joy1id) == -1) @@ -315,6 +318,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[] = { @@ -702,8 +717,7 @@ CMenuScreenCustom aScreens[] = { #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS // MENUPAGE_DETECT_JOYSTICK - { "FEC_JOD", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({0, 0, 0, false, false, 30}), nil, - + { "FEC_JOD", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({0, 0, 0, false, false, 30}), DetectJoystickGoBack, MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, 0, MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, nil, DetectJoystickDraw, nil) }, 80, 200, MENUALIGN_LEFT, MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 320, 225, MENUALIGN_CENTER, diff --git a/src/core/main.h b/src/core/main.h index eacfd8e1..9f181101 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -45,7 +45,7 @@ void TheModelViewer(void); #endif #ifdef LOAD_INI_SETTINGS -void LoadINISettings(); +bool LoadINISettings(); void SaveINISettings(); void LoadINIControllerSettings(); void SaveINIControllerSettings(); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 3d94cafd..19697c37 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -249,6 +249,14 @@ const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8 void LoadINIControllerSettings() { +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + 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)) { @@ -340,12 +348,17 @@ void SaveINIControllerSettings() StoreIni("Bindings", iniControllerActions[i], value, 128); } - cfg.write_file("re3.ini"); +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif + StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); + cfg.write_file("reVC.ini"); } -void LoadINISettings() +bool LoadINISettings() { - cfg.load_file("reVC.ini"); + if (!cfg.load_file("reVC.ini")) + return false; #ifdef IMPROVED_VIDEOMODE ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth); @@ -404,40 +417,6 @@ void LoadINISettings() ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - // Written by assuming the codes below will run after _InputInitialiseJoys(). - std::string strval = cfg.get("Controller", "JoystickName", ""); - const char *value = strval.c_str(); - strcpy(gSelectedJoystickName, value); - - 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); - } - 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); - } - CFileMgr::SetDir(""); - // We call LoadINIControllerSettings after this func., so calling here isn't needed - break; - } - } - } -#endif - #ifdef CUSTOM_FRONTEND_OPTIONS bool migrate = cfg.category_size("FrontendOptions") != 0; for (int i = 0; i < MENUPAGES; i++) { @@ -463,6 +442,8 @@ void LoadINISettings() } } #endif + + return true; } void SaveINISettings() @@ -524,10 +505,6 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif - -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); -#endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index a86ccaf8..055712f3 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1634,10 +1634,16 @@ main(int argc, char *argv[]) SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &NewStickyKeys, SPIF_SENDCHANGE); #endif - // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta_vc.set", "r"); if ( gta3set ) @@ -1650,6 +1656,10 @@ main(int argc, char *argv[]) #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } #endif } @@ -2163,6 +2173,12 @@ void joysChangeCB(int jid, int event) PSGLOBAL(joy1id) = jid; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS strcpy(gSelectedJoystickName, glfwGetJoystickName(jid)); +#endif + // This is behind LOAD_INI_SETTINGS, because otherwise the Init call below will destroy/overwrite your bindings. +#ifdef LOAD_INI_SETTINGS + int count; + glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + ControlsManager.InitDefaultControlConfigJoyPad(count); #endif } else if (PSGLOBAL(joy2id) == -1) PSGLOBAL(joy2id) = jid; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 02b3f917..4963450a 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2142,12 +2142,18 @@ WinMain(HINSTANCE instance, ShowWindow(PSGLOBAL(window), cmdShow); UpdateWindow(PSGLOBAL(window)); - // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta_vc.set", "r"); - + if ( gta3set ) { ControlsManager.LoadSettings(gta3set); @@ -2158,6 +2164,10 @@ WinMain(HINSTANCE instance, #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } #endif } From de44a17e6479afc95469fd4676b71e7d3e217a27 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 18:16:47 +0200 Subject: [PATCH 13/15] Fix ini name --- src/core/re3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 81ba03b1..67cfd6a9 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -352,12 +352,12 @@ void SaveINIControllerSettings() StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); #endif StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); - cfg.write_file("reVC.ini"); + cfg.write_file("reLCS.ini"); } bool LoadINISettings() { - if (!cfg.load_file("reVC.ini")) + if (!cfg.load_file("reLCS.ini")) return false; #ifdef IMPROVED_VIDEOMODE From 13507d422ba9cf9a17d0ae9cc0f7ec0052e1d6b6 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 23 Jan 2021 18:56:27 +0200 Subject: [PATCH 14/15] Add PSP scaling macros --- src/core/common.h | 7 +++++++ src/render/Hud.cpp | 33 +++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/core/common.h b/src/core/common.h index 349392f4..fbc28225 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -200,6 +200,13 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x) #endif +#define PSP_DEFAULT_SCREEN_WIDTH (480) +#define PSP_DEFAULT_SCREEN_HEIGHT (272) +#define PSP_SCREEN_SCALE_X(a) SCREEN_SCALE_AR(SCREEN_STRETCH_X(a * ((float)DEFAULT_SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH))) +#define PSP_SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(a* ((float)DEFAULT_SCREEN_HEIGHT / PSP_DEFAULT_SCREEN_HEIGHT)) +#define PSP_SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - PSP_SCREEN_SCALE_X(a)) +#define PSP_SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - PSP_SCREEN_SCALE_Y(a)) + #include "maths.h" #include "Vector.h" #include "Vector2D.h" diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 38c09e33..69e340e3 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -45,8 +45,8 @@ CRGBA ARMOUR_COLOR(185, 185, 185, 255); CRGBA NOTWANTED_COLOR(27, 89, 130, 255); CRGBA WANTED_COLOR_FLASH(62, 141, 181, 255); CRGBA WANTED_COLOR(97, 194, 247, 255); -CRGBA ZONE_COLOR(45, 155, 90, 255); -CRGBA VEHICLE_COLOR(97, 194, 247, 255); +CRGBA ZONE_COLOR(255, 255, 255, 255); +CRGBA VEHICLE_COLOR(255, 255, 255, 255); CRGBA CLOCK_COLOR(97, 194, 247, 255); CRGBA TIMER_COLOR(97, 194, 247, 255); CRGBA COUNTER_COLOR(97, 194, 247, 255); @@ -785,14 +785,14 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetBackgroundOff(); - if (FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_SPANISH) - CFont::SetScale(SCREEN_SCALE_X(1.7f * 0.8f), SCREEN_SCALE_Y(1.8f)); + if (FrontEndMenuManager.m_PrefsUseWideScreen) + CFont::SetScale(PSP_SCREEN_SCALE_X(0.42768f), PSP_SCREEN_SCALE_Y(0.88f)); else - CFont::SetScale(SCREEN_SCALE_X(1.7f), SCREEN_SCALE_Y(1.8f)); - - CFont::SetSlantRefPoint(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f)); - CFont::SetSlant(0.15f); + CFont::SetScale(PSP_SCREEN_SCALE_X(0.4752f), PSP_SCREEN_SCALE_Y(0.88f)); + //CFont::SetSlantRefPoint(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f)); + //CFont::SetSlant(0.15f); + CFont::SetWrapx(SCREEN_WIDTH); CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); CFont::SetBackGroundOnlyTextOff(); @@ -802,9 +802,9 @@ void CHud::Draw() CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha)); if (!CTheScripts::bPlayerIsInTheStatium) - CFont::PrintStringFromBottom(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f), m_ZoneToPrint); + CFont::PrintStringFromBottom(PSP_SCREEN_SCALE_FROM_RIGHT(24.0f), PSP_SCREEN_SCALE_FROM_BOTTOM(16.0f), m_ZoneToPrint); - CFont::SetSlant(0.f); + //CFont::SetSlant(0.f); } else { m_ZoneState = 3; } @@ -885,13 +885,14 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetBackgroundOff(); - if (FrontEndMenuManager.m_PrefsLanguage != CMenuManager::LANGUAGE_ITALIAN && FrontEndMenuManager.m_PrefsLanguage != CMenuManager::LANGUAGE_SPANISH) - CFont::SetScale(SCREEN_SCALE_X(1.7f), SCREEN_SCALE_Y(1.8f)); + if (FrontEndMenuManager.m_PrefsUseWideScreen) + CFont::SetScale(PSP_SCREEN_SCALE_X(0.42768f), PSP_SCREEN_SCALE_Y(0.88f)); else - CFont::SetScale(SCREEN_SCALE_X(1.7f * 0.85f), SCREEN_SCALE_Y(1.8f)); + CFont::SetScale(PSP_SCREEN_SCALE_X(0.4752f), PSP_SCREEN_SCALE_Y(0.88f)); - CFont::SetSlantRefPoint(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f)); - CFont::SetSlant(0.15f); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::SetSlantRefPoint(PSP_SCREEN_SCALE_FROM_RIGHT(24.0f), PSP_SCREEN_SCALE_FROM_BOTTOM(35.6f)); + CFont::SetSlant(0.f); CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); @@ -901,7 +902,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha)); CFont::SetDropColor(CRGBA(0, 0, 0, fVehicleAlpha)); - CFont::PrintStringFromBottom(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f), m_pVehicleNameToPrint); + CFont::PrintStringFromBottom(PSP_SCREEN_SCALE_FROM_RIGHT(24.0f), PSP_SCREEN_SCALE_FROM_BOTTOM(35.6f), m_pVehicleNameToPrint); CFont::SetSlant(0.f); } From a1d6833bac35bff1a095612216a970e5e9fc25f0 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 23 Jan 2021 19:23:26 +0100 Subject: [PATCH 15/15] txd store --- src/rw/TxdStore.cpp | 93 +++++++++++++++++++++++++++++++++++++++++---- src/rw/TxdStore.h | 11 +++++- 2 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/rw/TxdStore.cpp b/src/rw/TxdStore.cpp index 0bd29718..b7936bcf 100644 --- a/src/rw/TxdStore.cpp +++ b/src/rw/TxdStore.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "main.h" +#include "smallHeap.h" #include "templates.h" #include "General.h" #include "Streaming.h" @@ -9,13 +11,19 @@ CPool *CTxdStore::ms_pTxdPool; RwTexDictionary *CTxdStore::ms_pStoredTxd; +// LCS: file done except unused: +// CTexListStore::RemoveTexListChunk(int) +// CTexListStore::validateRefs(void) +// CTexListStore::Write(base::cRelocatableChunkWriter &) + void CTxdStore::Initialise(void) { - if(ms_pTxdPool == nil) + if(gMakeResources && ms_pTxdPool == nil) ms_pTxdPool = new CPool(TXDSTORESIZE, "TexDictionary"); } +// removed in LCS but we should probably keep it void CTxdStore::Shutdown(void) { @@ -23,6 +31,7 @@ CTxdStore::Shutdown(void) delete ms_pTxdPool; } +// removed in LCS but we should probably keep it void CTxdStore::GameShutdown(void) { @@ -42,6 +51,7 @@ CTxdStore::AddTxdSlot(const char *name) assert(def); def->texDict = nil; def->refCount = 0; + def->refCountGu = 0; strcpy(def->name, name); return ms_pTxdPool->GetJustIndex(def); } @@ -95,7 +105,11 @@ CTxdStore::SetCurrentTxd(int slot) void CTxdStore::Create(int slot) { - GetSlot(slot)->texDict = RwTexDictionaryCreate(); + TxdDef *def = GetSlot(slot); + def->texDict = RwTexDictionaryCreate(); + // LCS: mobile sets the txd name here, but txds don't really have names + def->refCount = 0; + def->refCountGu = 0; } int @@ -110,6 +124,20 @@ CTxdStore::AddRef(int slot) GetSlot(slot)->refCount++; } +void +CTxdStore::AddRefEvenIfNotInMemory(int slot) +{ + GetSlot(slot)->refCount++; +} + +void +CTxdStore::AddRefGu(int slot) +{ + TxdDef *def = GetSlot(slot); + def->refCount++; + def->refCountGu++; +} + void CTxdStore::RemoveRef(int slot) { @@ -117,6 +145,15 @@ CTxdStore::RemoveRef(int slot) CStreaming::RemoveTxd(slot); } +void +CTxdStore::RemoveRefGu(int slot) +{ + TxdDef *def = GetSlot(slot); + def->refCount--; + if(gUseChunkFiles) + def->refCountGu--; +} + void CTxdStore::RemoveRefWithoutDelete(int slot) { @@ -128,14 +165,31 @@ CTxdStore::LoadTxd(int slot, RwStream *stream) { TxdDef *def = GetSlot(slot); - if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ - def->texDict = RwTexDictionaryGtaStreamRead(stream); - return def->texDict != nil; + if(stream){ + if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ + def->texDict = RwTexDictionaryGtaStreamRead(stream); + return def->texDict != nil; + } + }else{ + // TODO(LCS)? fall back reading from file } printf("Failed to load TXD\n"); return false; } +bool +CTxdStore::LoadTxd(int slot, void *data, void *chunk) +{ + TxdDef *def = GetSlot(slot); + def->texDict = (RwTexDictionary*)data; + if(strncasecmp(def->name, "radar", 5) == 0){ + def->refCount = 0; + def->refCountGu = 0; + } + CStreaming::RegisterPointer(&def->texDict, 3, true); + return def->texDict != nil; +} + bool CTxdStore::LoadTxd(int slot, const char *filename) { @@ -152,6 +206,7 @@ CTxdStore::LoadTxd(int slot, const char *filename) return ret; } +// removed in LCS but we should probably keep it bool CTxdStore::StartLoadTxd(int slot, RwStream *stream) { @@ -165,6 +220,7 @@ CTxdStore::StartLoadTxd(int slot, RwStream *stream) } } +// removed in LCS but we should probably keep it bool CTxdStore::FinishLoadTxd(int slot, RwStream *stream) { @@ -174,10 +230,31 @@ CTxdStore::FinishLoadTxd(int slot, RwStream *stream) } void -CTxdStore::RemoveTxd(int slot) +CTxdStore::RemoveTxd(int slot, bool notChunk) { TxdDef *def = GetSlot(slot); - if(def->texDict) - RwTexDictionaryDestroy(def->texDict); + if(def->texDict){ + if(!gUseChunkFiles || notChunk) + RwTexDictionaryDestroy(def->texDict); + else{ + // TODO? Rsl3D specific: RslTextureDestroyDispList for all textures + CStreaming::UnregisterPointer(&def->texDict, 3); + cSmallHeap::msInstance.Free(def->texDict); + } + } def->texDict = nil; + def->refCount = 0; + def->refCountGu = 0; +} + +void +CTxdStore::Load(RwTexDictionary *stored, CPool *pool) +{ + ms_pTxdPool = pool; + ms_pStoredTxd = stored; + for(int i = 0; i < TXDSTORESIZE; i++){ + TxdDef *def = GetSlot(i); + if(def) + def->refCount = def->texDict != nil; + } } diff --git a/src/rw/TxdStore.h b/src/rw/TxdStore.h index 937fd1b7..31fcf87f 100644 --- a/src/rw/TxdStore.h +++ b/src/rw/TxdStore.h @@ -4,7 +4,8 @@ struct TxdDef { RwTexDictionary *texDict; - int refCount; + int16 refCount; + int16 refCountGu; char name[20]; }; @@ -26,13 +27,19 @@ public: static void Create(int slot); static int GetNumRefs(int slot); static void AddRef(int slot); + static void AddRefEvenIfNotInMemory(int slot); + static void AddRefGu(int slot); static void RemoveRef(int slot); + static void RemoveRefGu(int slot); static void RemoveRefWithoutDelete(int slot); static bool LoadTxd(int slot, RwStream *stream); + static bool LoadTxd(int slot, void *data, void *chunk); static bool LoadTxd(int slot, const char *filename); static bool StartLoadTxd(int slot, RwStream *stream); static bool FinishLoadTxd(int slot, RwStream *stream); - static void RemoveTxd(int slot); + static void RemoveTxd(int slot, bool notChunk = false); + + static void Load(RwTexDictionary *stored, CPool *pool); static TxdDef *GetSlot(int slot) { assert(slot >= 0);