From ee89c485fcce7f3b9a189f7a80b3a1b2933f79bd Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 24 Jan 2021 13:42:45 +0300 Subject: sync --- src/audio/AudioLogic.cpp | 7 +- src/audio/AudioManager.h | 6 +- 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/ColStore.cpp | 176 +++++++- src/collision/ColStore.h | 17 +- src/collision/TempColModels.cpp | 1 + src/collision/TempColModels.h | 2 +- src/control/Bridge.cpp | 20 + src/control/Bridge.h | 1 + src/control/Garages.h | 10 +- src/control/PathFind.cpp | 24 +- src/control/Remote.cpp | 3 +- src/control/Remote.h | 2 +- src/control/Script.cpp | 40 +- src/control/Script.h | 27 +- src/control/Script10.cpp | 5 +- src/control/Script3.cpp | 1 + src/control/Script4.cpp | 4 +- src/control/Script7.cpp | 3 +- src/control/Script8.cpp | 31 +- src/control/Script9.cpp | 8 +- src/control/TrafficLights.cpp | 26 ++ src/core/ControllerConfig.cpp | 97 +++-- src/core/ControllerConfig.h | 4 + src/core/Frontend.cpp | 66 ++- src/core/Frontend.h | 9 +- src/core/Game.cpp | 23 +- src/core/Lists.h | 2 - src/core/MenuScreensCustom.cpp | 48 ++- src/core/Pad.cpp | 11 +- src/core/PlayerInfo.h | 2 +- src/core/Streaming.cpp | 40 ++ src/core/Streaming.h | 12 + src/core/World.cpp | 68 +--- src/core/World.h | 6 +- src/core/Zones.h | 4 +- src/core/common.h | 51 ++- src/core/config.h | 2 +- src/core/main.h | 4 +- src/core/re3.cpp | 450 ++++++++++++++++----- src/extras/custompipes.cpp | 2 +- src/extras/custompipes_d3d9.cpp | 2 +- src/extras/frontendoption.cpp | 6 +- src/extras/frontendoption.h | 6 +- src/extras/ini_parser.hpp | 19 + src/extras/postfx.cpp | 3 +- src/extras/screendroplets.cpp | 2 +- src/fakerw/fake.cpp | 2 +- src/leeds/base/sList.h | 35 ++ src/leeds/smallHeap.cpp | 20 + src/leeds/smallHeap.h | 17 + src/modelinfo/BaseModelInfo.h | 4 +- src/modelinfo/ModelIndices.cpp | 16 +- src/modelinfo/ModelIndices.h | 874 +++++++++++++++++++++++++++++++++++----- src/modelinfo/ModelInfo.h | 3 +- src/modelinfo/PedModelInfo.h | 1 + src/peds/Ped.cpp | 1 + src/peds/Ped.h | 2 +- src/render/Hud.cpp | 33 +- src/render/MBlur.cpp | 1 - src/render/Renderer.cpp | 2 +- src/render/SpecialFX.cpp | 4 +- src/render/WaterCreatures.cpp | 3 +- src/render/WaterCreatures.h | 3 +- src/rw/RwHelper.cpp | 2 - src/rw/TxdStore.cpp | 93 ++++- src/rw/TxdStore.h | 11 +- src/save/GenericGameStorage.cpp | 4 + src/save/MemoryCard.cpp | 1 + src/skel/glfw/glfw.cpp | 66 +-- src/skel/win/win.cpp | 36 +- src/vehicles/Automobile.cpp | 1 + src/vehicles/Bike.cpp | 1 + src/vehicles/Bike.h | 1 + src/vehicles/Boat.cpp | 1 + src/vehicles/Cranes.cpp | 14 +- src/vehicles/Vehicle.h | 6 +- 81 files changed, 2083 insertions(+), 573 deletions(-) create mode 100644 src/leeds/base/sList.h create mode 100644 src/leeds/smallHeap.cpp create mode 100644 src/leeds/smallHeap.h (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index c2050f59..36b9eb11 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; @@ -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/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; diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index a2a765ed..edfb8a7c 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 7597eafb..697a7aa8 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 44be3b1c..d78c6d84 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 ec85fc43..7da871a5 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/ColStore.cpp b/src/collision/ColStore.cpp index f1e695fe..90a29bc2 100644 --- a/src/collision/ColStore.cpp +++ b/src/collision/ColStore.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "main.h" +#include "smallHeap.h" #include "templates.h" #include "General.h" #include "ModelInfo.h" @@ -8,6 +10,9 @@ #include "Script.h" #include "Timer.h" #include "Camera.h" +#include "World.h" +#include "Zones.h" +#include "Garages.h" #include "Frontend.h" #include "Physical.h" #include "ColStore.h" @@ -15,16 +20,55 @@ #include "Pools.h" CPool *CColStore::ms_pColPool; +bool CColStore::m_onlyBB; #ifndef MASTER bool bDispColInMem; #endif +// LCS: file done except unused: +// CColStore::LoadCol(int,char const*) +// CColStore::LoadAllBoundingBoxes(void) +// CColStore::Write(base::cRelocatableChunkWriter &) + +const CVector& +LevelPos(eLevelName level) +{ + static CVector pos[4] = { + CVector(1060.0f, -800.0f, 0.0f), + CVector(1060.0f, -800.0f, 0.0f), + CVector(350.0f, -624.0f, 0.0f), + CVector(-670.0f, -511.0f, 0.0f) + }; + return pos[level]; +}; + +static eLevelName +PosLevel(const CVector &pos) +{ + static eLevelName lastPlayerLevel = LEVEL_INDUSTRIAL; + static eLevelName lastOtherLevel = LEVEL_INDUSTRIAL; + + if(Abs(FindPlayerCoors().x - pos.x) < 5.0f && + Abs(FindPlayerCoors().y - pos.y) < 5.0f && + Abs(FindPlayerCoors().z - pos.z) < 5.0f){ + if(CGame::currLevel != LEVEL_GENERIC) + lastPlayerLevel = CGame::currLevel; + return lastPlayerLevel; + }else{ + eLevelName lvl = CTheZones::GetLevelFromPosition(&pos); + if(lvl != LEVEL_GENERIC) + lastOtherLevel = lvl; + return lastOtherLevel; + } +} + void CColStore::Initialise(void) { - if(ms_pColPool == nil) + if(ms_pColPool == nil){ ms_pColPool = new CPool(COLSTORESIZE, "CollisionFiles"); - AddColSlot("generic"); // slot 0. not streamed + AddColSlot("generic"); // slot 0. not streamed + } #ifndef MASTER VarConsole.Add("Display collision in memory", &bDispColInMem, true); #endif @@ -38,7 +82,9 @@ CColStore::Shutdown(void) RemoveColSlot(i); if(ms_pColPool) delete ms_pColPool; +#ifdef FIX_BUGS ms_pColPool = nil; +#endif } int @@ -119,11 +165,34 @@ CColStore::LoadCol(int32 slot, uint8 *buffer, int32 bufsize) return success; } +struct ColChunkEntry +{ + int32 modelId; // -1 marks end + CColModel *colModel; +}; + +void +CColStore::LoadColCHK(int32 slot, void *data, void *chunk) +{ + ColDef *def = GetSlot(slot); + def->chunk = chunk; + CStreaming::RegisterPointer(&def->chunk, 1, true); + for(ColChunkEntry *entry = (ColChunkEntry*)data; entry->modelId != -1; entry++){ + CBaseModelInfo *mi = CModelInfo::GetModelInfo(entry->modelId); + mi->SetColModel(entry->colModel, true); // we own this? can that work? + CStreaming::RegisterPointer(&mi->m_colModel, 1, true); + } + def->isLoaded = true; +} + +CColModel nullCollision; + void CColStore::RemoveCol(int32 slot) { int id; - GetSlot(slot)->isLoaded = false; + ColDef *def = GetSlot(slot); + def->isLoaded = false; for(id = 0; id < MODELINFOSIZE; id++){ CBaseModelInfo *mi = CModelInfo::GetModelInfo(id); if(mi){ @@ -132,6 +201,23 @@ CColStore::RemoveCol(int32 slot) col->RemoveCollisionVolumes(); } } + if(gUseChunkFiles){ + for(id = 0; id < MODELINFOSIZE; id++){ + CBaseModelInfo *mi = CModelInfo::GetModelInfo(id); + if(mi){ + CColModel *col = mi->GetColModel(); + if(col && col->level == slot){ + mi->SetColModel(&nullCollision); + CStreaming::UnregisterPointer(&mi->m_colModel, 1); + } + } + } + if(def->chunk){ + CStreaming::UnregisterPointer(&def->chunk, 1); + cSmallHeap::msInstance.Free(def->chunk); + def->chunk = nil; + } + } } void @@ -156,29 +242,49 @@ CColStore::RemoveAllCollision(void) } static bool bLoadAtSecondPosition; -static CVector2D secondPosition; +static CVector secondPosition; void -CColStore::AddCollisionNeededAtPosn(const CVector2D &pos) +CColStore::AddCollisionNeededAtPosn(const CVector &pos) { bLoadAtSecondPosition = true; secondPosition = pos; } void -CColStore::LoadCollision(const CVector2D &pos) +CColStore::LoadCollision(const CVector &pos, eLevelName level) { int i; if(CStreaming::ms_disableStreaming) return; + if(level == LEVEL_GENERIC) + level = PosLevel(pos); + + eLevelName allowedLevel = (eLevelName)CTheScripts::AllowedCollision[0]; + if(allowedLevel == LEVEL_GENERIC) + allowedLevel = (eLevelName)CTheScripts::AllowedCollision[1]; + + bool requestedSomething = false; + for(i = 1; i < COLSTORESIZE; i++){ - if(GetSlot(i) == nil) + if(GetSlot(i) == nil || !DoScriptsWantThisIn(i)) continue; bool wantThisOne = false; + if(strcmp(GetColName(i), "indust") == 0){ + if(allowedLevel != LEVEL_GENERIC && level != LEVEL_INDUSTRIAL) + wantThisOne = allowedLevel == LEVEL_INDUSTRIAL; + else + wantThisOne = level == LEVEL_INDUSTRIAL; + }else if(GetBoundingBox(i).IsPointInside(LevelPos(level))) + wantThisOne = true; + else if(allowedLevel != LEVEL_GENERIC && GetBoundingBox(i).IsPointInside(LevelPos(allowedLevel))) + wantThisOne = true; + +/* // LCS: removed if(GetBoundingBox(i).IsPointInside(pos) || bLoadAtSecondPosition && GetBoundingBox(i).IsPointInside(secondPosition, -119.0f) || strcmp(GetColName(i), "yacht") == 0){ @@ -203,28 +309,38 @@ CColStore::LoadCollision(const CVector2D &pos) } } } +*/ - if(wantThisOne) + if(wantThisOne){ CStreaming::RequestCol(i, STREAMFLAGS_PRIORITY); - else + requestedSomething = true; + }else CStreaming::RemoveCol(i); } + if(requestedSomething){ + CTimer::Suspend(); + // BUG? request was done with priority but now loading non-priority? + CStreaming::LoadAllRequestedModels(false); + CGarages::SetupAnyGaragesForThisIsland(); + CTimer::Resume(); + } bLoadAtSecondPosition = false; } void -CColStore::RequestCollision(const CVector2D &pos) +CColStore::RequestCollision(const CVector &pos) { int i; for(i = 1; i < COLSTORESIZE; i++) - if(GetSlot(i) && GetBoundingBox(i).IsPointInside(pos, -115.0f)) + if(GetSlot(i) && DoScriptsWantThisIn(i) && GetBoundingBox(i).IsPointInside(LevelPos(PosLevel(pos)), -115.0f)) CStreaming::RequestCol(i, STREAMFLAGS_PRIORITY); } void -CColStore::EnsureCollisionIsInMemory(const CVector2D &pos) +CColStore::EnsureCollisionIsInMemory(const CVector &pos) { +/* // LCS: removed int i; if(CStreaming::ms_disableStreaming) @@ -240,16 +356,48 @@ CColStore::EnsureCollisionIsInMemory(const CVector2D &pos) CStreaming::LoadAllRequestedModels(false); CTimer::Resume(); } +*/ } bool -CColStore::HasCollisionLoaded(const CVector2D &pos) +CColStore::DoScriptsWantThisIn(int32 slot) +{ + if(slot == 0) + return false; + ColDef *coldef = GetSlot(slot); + if(coldef == nil) + return false; + if(strcmp(coldef->name, "fortstaunton") == 0) + return !CTheScripts::IsFortStauntonDestroyed(); + if(strcmp(coldef->name, "fortdestroyed") == 0) + return CTheScripts::IsFortStauntonDestroyed(); + return true; +} + +bool +CColStore::HasCollisionLoaded(eLevelName level) { int i; + const CVector &pos = LevelPos(level); for(i = 1; i < COLSTORESIZE; i++) - if(GetSlot(i) && GetBoundingBox(i).IsPointInside(pos, -115.0f) && + if(GetSlot(i) && DoScriptsWantThisIn(i) && + (!CGeneral::faststricmp(GetColName(i), "indust") && level == LEVEL_INDUSTRIAL || + GetBoundingBox(i).IsPointInside(pos)) && !GetSlot(i)->isLoaded) return false; return true; } + +bool +CColStore::HasCollisionLoaded(const CVector &pos) +{ + return HasCollisionLoaded(PosLevel(pos)); +} + +void +CColStore::Load(bool onlyBB, CPool *pool) +{ + ms_pColPool = pool; + m_onlyBB = onlyBB; +} diff --git a/src/collision/ColStore.h b/src/collision/ColStore.h index e0da92ca..d09bbf8f 100644 --- a/src/collision/ColStore.h +++ b/src/collision/ColStore.h @@ -9,11 +9,13 @@ struct ColDef { // made up name char name[20]; int16 minIndex; int16 maxIndex; + void *chunk; }; class CColStore { static CPool *ms_pColPool; + static bool m_onlyBB; public: static void Initialise(void); @@ -25,15 +27,18 @@ public: static CRect &GetBoundingBox(int32 slot); static void IncludeModelIndex(int32 slot, int32 modelIndex); static bool LoadCol(int32 storeID, uint8 *buffer, int32 bufsize); + static void LoadColCHK(int32 slot, void *data, void *chunk); static void RemoveCol(int32 slot); - static void AddCollisionNeededAtPosn(const CVector2D &pos); + static void AddCollisionNeededAtPosn(const CVector &pos); static void LoadAllCollision(void); static void RemoveAllCollision(void); - static void LoadCollision(const CVector2D &pos); - static void RequestCollision(const CVector2D &pos); - static void EnsureCollisionIsInMemory(const CVector2D &pos); - static bool HasCollisionLoaded(const CVector2D &pos); - static bool HasCollisionLoaded(eLevelName level) { return true; }; // TODO + static void LoadCollision(const CVector &pos, eLevelName level = LEVEL_GENERIC); + static void RequestCollision(const CVector &pos); + static void EnsureCollisionIsInMemory(const CVector &pos); + static bool DoScriptsWantThisIn(int32 slot); + static bool HasCollisionLoaded(eLevelName level); + static bool HasCollisionLoaded(const CVector &pos); + static void Load(bool, CPool *pool); static ColDef *GetSlot(int slot) { assert(slot >= 0); diff --git a/src/collision/TempColModels.cpp b/src/collision/TempColModels.cpp index 55058bde..32f2285c 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 457315b6..e8a39695 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/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/control/Garages.h b/src/control/Garages.h index 3d12d4a2..c3542d27 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 { @@ -183,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); @@ -255,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*); @@ -293,4 +297,6 @@ public: } static bool IsThisGarageTypeSafehouse(uint8 type) { return FindSafeHouseIndexForGarageType(type) >= 0; } + static void SetupAnyGaragesForThisIsland(void) {} // TODO(LCS) + }; diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index cbc29db4..bc9af2e9 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(); @@ -1763,18 +1763,18 @@ CPathFind::TestCoorsCloseness(CVector target, uint8 type, CVector start) float dist; if(type == PATH_CAR) - DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 999999.88f, -1); + DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 170.0f, -1); else DoPathSearch(type, start, -1, target, nil, &DummyResult2, 0, nil, &dist, 50.0f, -1); #ifdef FIX_BUGS // dist has GenerationDistMultiplier as a factor, so our reference dist should have it too if(type == PATH_CAR) - return dist < 150.0f*TheCamera.GenerationDistMultiplier; + return dist < 180.0f*TheCamera.GenerationDistMultiplier; else return dist < 100.0f*TheCamera.GenerationDistMultiplier; #else if(type == PATH_CAR) - return dist < 150.0f; + return dist < 180.0f; else return dist < 100.0f; #endif diff --git a/src/control/Remote.cpp b/src/control/Remote.cpp index 047b19f3..dc025549 100644 --- a/src/control/Remote.cpp +++ b/src/control/Remote.cpp @@ -9,7 +9,7 @@ #include "PlayerInfo.h" #include "Vehicle.h" -void +CVehicle* CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model) { CAutomobile *car = new CAutomobile(model, MISSION_VEHICLE); @@ -40,6 +40,7 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin TheCamera.SetZoomValueCamStringScript(0); } else TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT); + return car; } void diff --git a/src/control/Remote.h b/src/control/Remote.h index 72cabb7c..4c40dd96 100644 --- a/src/control/Remote.h +++ b/src/control/Remote.h @@ -3,6 +3,6 @@ class CRemote { public: - static void GivePlayerRemoteControlledCar(float, float, float, float, uint16); + static CVehicle* GivePlayerRemoteControlledCar(float, float, float, float, uint16); static void TakeRemoteControlledCarFromPlayer(bool blowUp = true); }; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a9df5799..1b1b9045 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -11,6 +11,7 @@ #include "CivilianPed.h" #include "Clock.h" #include "CopPed.h" +#include "Coronas.h" #include "Debug.h" #include "DMAudio.h" #include "EmergencyPed.h" @@ -49,7 +50,7 @@ #include "Timecycle.h" #include "TxdStore.h" #include "Bike.h" -#include "memoryManager.h" +#include "smallHeap.h" #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #include #endif @@ -98,7 +99,7 @@ uint16 CTheScripts::NumberOfExclusiveMissionScripts; bool CTheScripts::bPlayerHasMetDebbieHarry; bool CTheScripts::bPlayerIsInTheStatium; int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS]; -bool CTheScripts::FSDestroyedFlag; +int CTheScripts::FSDestroyedFlag; short* CTheScripts::SavedVarIndices; int CTheScripts::NumSaveVars; int gScriptsFile = -1; @@ -107,6 +108,9 @@ bool CTheScripts::InTheScripts; CRunningScript* pCurrent; uint16 CTheScripts::NumTrueGlobals; uint16 CTheScripts::MostGlobals; +CVector gVectorSetInLua; +int CTheScripts::NextScriptCoronaID; +base::cSList CTheScripts::mCoronas; #ifdef MISSION_REPLAY @@ -422,7 +426,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_ADD_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_SCORE_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_STORE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""), REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL_NO_DROP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_WANTED_LEVEL_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""), @@ -2136,9 +2140,7 @@ void CMissionCleanup::Process() default: break; } - m_sEntities[i].id = 0; - m_sEntities[i].type = CLEANUP_UNUSED; - m_nCount--; + RemoveEntityFromList(m_sEntities[i].id, m_sEntities[i].type); } for (int i = 1; i < NUMSTREAMINFO; i++) { if (CStreaming::IsScriptOwnedModel(i)) @@ -2513,7 +2515,7 @@ int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp) return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; } script_assert(false && "wrong type for variable"); - return nil; + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; } int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type) @@ -2620,6 +2622,14 @@ bool CTheScripts::Init(bool loaddata) memset(&UsedObjectArray[i].name, 0, sizeof(UsedObjectArray[i].name)); UsedObjectArray[i].index = 0; } +#if defined FIX_BUGS || (!defined GTA_PS2 && !defined GTA_PSP) + for (base::cSList::tSItem* i = CTheScripts::mCoronas.first; i;) { + base::cSList::tSItem* next = i->next; + delete i; + i = next; + } + CTheScripts::mCoronas.first = nil; +#endif NumberOfUsedObjects = 0; if (ScriptSpace) Shutdown(); @@ -2632,7 +2642,8 @@ bool CTheScripts::Init(bool loaddata) CFileMgr::Read(mainf, (char*)&MainScriptSize, sizeof(MainScriptSize)); int nLargestMissionSize = 0; CFileMgr::Read(mainf, (char*)&nLargestMissionSize, sizeof(nLargestMissionSize)); - // some cSmallHeap shit - TODO + if (!cSmallHeap::msInstance.IsLocked()) + cSmallHeap::msInstance.Lock(); ScriptSpace = (uint8*)base::cMainMemoryManager::Instance()->Allocate(MainScriptSize + nLargestMissionSize); memset(ScriptSpace, 0, MainScriptSize + nLargestMissionSize); CFileMgr::Read(mainf, (char*)ScriptSpace, MainScriptSize); @@ -2772,8 +2783,6 @@ void CTheScripts::Process() UseTextCommands = 0; } - // TODO: mCoronas - #ifdef MISSION_REPLAY static uint32 TimeToWaitTill; switch (AllowMissionReplay) { @@ -2833,6 +2842,11 @@ void CTheScripts::Process() if (script && !script->m_bIsActive) script = nil; } + InTheScripts = false; + for (base::cSList::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + CCoronas::RegisterCorona((uint32)(uintptr)i, i->item.r, i->item.g, i->item.b, 255, CVector(i->item.x, i->item.y, i->item.z), + -i->item.size, 450.0f, i->item.type, i->item.flareType, 1, 0, 0, 0.0f); + } DbgFlag = false; #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT PrintToLog("Script processing done, ScriptsUpdated: %d, CommandsExecuted: %d\n", ScriptsUpdated, CommandsExecuted); @@ -2896,7 +2910,9 @@ int8 CRunningScript::ProcessOneCommand() uint8 nLocalsOffset; if (command < ARRAY_SIZE(commands)) { script_assert(commands[command].id == command); + m_nIp -= 2; sprintf(commandInfo, m_nIp >= CTheScripts::MainScriptSize ? "M<%5d> " : "<%6d> ", m_nIp >= CTheScripts::MainScriptSize ? m_nIp - CTheScripts::MainScriptSize : m_nIp); + m_nIp += 2; if (m_bNotFlag) strcat(commandInfo, "NOT "); if (commands[command].position == -1) @@ -4918,7 +4934,9 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), MI_RCBANDIT); + CVehicle* pVehicle = CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), MI_RCBANDIT); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); + StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ALTER_WANTED_LEVEL: diff --git a/src/control/Script.h b/src/control/Script.h index 780440dd..11c1b185 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,9 +1,9 @@ #pragma once -#include "common.h" -#include "Font.h" +#include "Font.h" #include "Ped.h" #include "PedType.h" #include "Text.h" +#include "sList.h" #include "Sprite2d.h" class CEntity; @@ -38,9 +38,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 @@ -273,6 +275,20 @@ struct tBuildingSwap int32 m_nOldModel; }; +struct script_corona +{ + int id; + float x; + float y; + float z; + float size; + uint8 r; + uint8 g; + uint8 b; + int type; + int flareType; +}; + enum { VAR_LOCAL = 1, @@ -343,12 +359,14 @@ public: static int AllowedCollision[MAX_ALLOWED_COLLISIONS]; static short* SavedVarIndices; static int NumSaveVars; - static bool FSDestroyedFlag; + static int FSDestroyedFlag; static int NextProcessId; static bool InTheScripts; static CRunningScript* pCurrent; static uint16 NumTrueGlobals; static uint16 MostGlobals; + static base::cSList mCoronas; + static int NextScriptCoronaID; static bool Init(bool loaddata = false); static void Process(); @@ -468,6 +486,8 @@ public: static void SetObjectiveForAllPedsInCollective(int, eObjective); #endif + static bool IsFortStauntonDestroyed() { return FSDestroyedFlag && *(int32*)&ScriptSpace[FSDestroyedFlag] == 1; } + }; extern int ScriptParams[32]; @@ -665,4 +685,5 @@ extern int scriptToLoad; #endif extern int gScriptsFile; +extern CVector gVectorSetInLua; diff --git a/src/control/Script10.cpp b/src/control/Script10.cpp index 536701b3..fef33848 100644 --- a/src/control/Script10.cpp +++ b/src/control/Script10.cpp @@ -74,7 +74,7 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) case COMMAND_ADD_ARROW_3D_MARKER: { uint32 ip = m_nIp; - uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&m_nIp, 0); + uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0); CollectParameters(&m_nIp, 10); CVector pos = GET_VECTOR_PARAM(0); CVector dir = GET_VECTOR_PARAM(3); @@ -213,7 +213,7 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) case COMMAND_PRINT_WITH_2_NUMBERS_NOW_NO_BRIEF: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CollectParameters(&m_nIp, 3); + CollectParameters(&m_nIp, 4); CMessages::AddMessageJumpQWithNumber(key, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); // 0 return 0; } @@ -321,6 +321,7 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) strncpy(onscreen_str2, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(1), onscreen_str1, 0); // TODO - second set of data + return 0; } case COMMAND_GET_PLAYER_STORED_WEAPON: { diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index 1e4d5b6f..7acfdfc8 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -35,6 +35,7 @@ #include "Zones.h" #include "GameLogic.h" #include "Bike.h" +#include "Wanted.h" // LCS: file done except TODOs diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 20e041da..d1dba350 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" // LCS: file done except TODOs @@ -477,7 +478,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) float fx = pObject->GetForward().x; float fy = pObject->GetForward().y; float heading = LimitAngleOnCircle( - RADTODEG(CGeneral::GetATanOfXY(pObject->GetForward().x, pObject->GetForward().y))); + RADTODEG(Atan2(-pObject->GetForward().x, pObject->GetForward().y))); float headingTarget = GET_FLOAT_PARAM(1); #ifdef FIX_BUGS float rotateBy = GET_FLOAT_PARAM(2) * CTimer::GetTimeStepFix(); @@ -935,6 +936,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) script_assert(pVehicle); pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); pPed->WarpPedIntoCar(pVehicle); + pPed->RestorePreviousObjective(); return 0; } case COMMAND_WARP_CHAR_INTO_CAR: diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index 601a979d..c50f0dea 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -423,9 +423,10 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_REQUEST_COLLISION: { CollectParameters(&m_nIp, 2); - CVector2D pos; + CVector pos; pos.x = GET_FLOAT_PARAM(0); pos.y = GET_FLOAT_PARAM(1); + pos.z = 0.0f; CColStore::RequestCollision(pos); return 0; } diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 55a56b2f..53e39b68 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -601,19 +601,36 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_SCRIPT_CORONA: { CollectParameters(&m_nIp, 9); - static bool bShowed = false; - if (!bShowed) { - debug("CREATE_SCRIPT_CORONA not implemented"); - bShowed = true; - } - SET_INTEGER_PARAM(0, -1); + base::cSList::tSItem* pCorona = new base::cSList::tSItem(); + pCorona->item.x = GET_FLOAT_PARAM(0); + pCorona->item.y = GET_FLOAT_PARAM(1); + pCorona->item.z = GET_FLOAT_PARAM(2); + pCorona->item.id = CTheScripts::NextScriptCoronaID++; + if (pCorona->item.z <= MAP_Z_LOW_LIMIT) + pCorona->item.z = CWorld::FindGroundZForCoord(pCorona->item.x, pCorona->item.y); + pCorona->item.size = GET_FLOAT_PARAM(3); + pCorona->item.r = GET_INTEGER_PARAM(6); + pCorona->item.g = GET_INTEGER_PARAM(7); + pCorona->item.b = GET_INTEGER_PARAM(8); + pCorona->item.type = GET_INTEGER_PARAM(4); + pCorona->item.flareType = GET_INTEGER_PARAM(5); + SET_INTEGER_PARAM(0, pCorona->item.id); + CTheScripts::mCoronas.Insert(pCorona); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REMOVE_SCRIPT_CORONA: + { CollectParameters(&m_nIp, 1); - // TODO + for (base::cSList::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + if (i->item.id == GET_INTEGER_PARAM(0)) { + CTheScripts::mCoronas.Remove(i); + delete i; + break; + } + } return 0; + } case COMMAND_IS_BOAT_IN_WATER: { CollectParameters(&m_nIp, 1); diff --git a/src/control/Script9.cpp b/src/control/Script9.cpp index c936e68f..020221c4 100644 --- a/src/control/Script9.cpp +++ b/src/control/Script9.cpp @@ -636,7 +636,7 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) case COMMAND_ADD_POINT_3D_MARKER: { uint32 ip = m_nIp; - uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&m_nIp, 0); + uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0); static CVector vPreviousLocation; CollectParameters(&m_nIp, 7); CVector pos = GET_VECTOR_PARAM(0); @@ -651,7 +651,7 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) return 0; } case COMMAND_GET_VECTOR_FROM_MULTIPLAYER: - // SET_VECTOR_PARAM(0, gVectorSetInLua); + SET_VECTOR_PARAM(0, gVectorSetInLua); StoreParameters(&m_nIp, 3); return 0; case COMMAND_PRINT_HELP_ALWAYS: @@ -737,10 +737,10 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) } case COMMAND_SET_CHAR_ATTACKS_PLAYER_WITH_COPS: { - CollectParameters(&m_nIp, 1); + CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bAttacksPlayerWithCops = (GET_INTEGER_PARAM(0) != 0); + pPed->bAttacksPlayerWithCops = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_REGISTER_FACE_PLANT_DISTANCE: diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp index df0761ab..d8f211d0 100644 --- a/src/control/TrafficLights.cpp +++ b/src/control/TrafficLights.cpp @@ -114,6 +114,32 @@ CTrafficLights::DisplayActualLight(CEntity *ent) CBrightLights::RegisterOne(pos1, ent->GetUp(), ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); CBrightLights::RegisterOne(pos2, ent->GetUp(), -ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); + + // TODO(LCS): check coordinates + static const float top = -0.127f; + static const float bot = -0.539f; + static const float mid = bot + (top - bot) / 3.0f; + static const float left = 1.256f; + static const float right = 0.706f; + phase = CTrafficLights::LightForPeds(); + if (phase == PED_LIGHTS_DONT_WALK) { + CVector p0(2.7f, right, top); + CVector p1(2.7f, left, top); + CVector p2(2.7f, right, mid); + CVector p3(2.7f, left, mid); + CShinyTexts::RegisterOne(ent->GetMatrix() * p0, ent->GetMatrix() * p1, ent->GetMatrix() * p2, ent->GetMatrix() * p3, + 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, + SHINYTEXT_WALK, 255, 0, 0, 60.0f); + } + else if (phase == PED_LIGHTS_WALK || CTimer::GetTimeInMilliseconds() & 0x100) { + CVector p0(2.7f, right, mid); + CVector p1(2.7f, left, mid); + CVector p2(2.7f, right, bot); + CVector p3(2.7f, left, bot); + CShinyTexts::RegisterOne(ent->GetMatrix() * p0, ent->GetMatrix() * p1, ent->GetMatrix() * p2, ent->GetMatrix() * p3, + 1.0f, 0.5f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f, + SHINYTEXT_WALK, 255, 255, 255, 60.0f); + } } else if (MI_TRAFFICLIGHTS_VERTICAL == m) { CBaseModelInfo* mi = CModelInfo::GetModelInfo(ent->GetModelIndex()); diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index eea1f6f0..fcc4503a 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" @@ -35,6 +31,9 @@ CControllerConfigManager::CControllerConfigManager() void CControllerConfigManager::MakeControllerActionsBlank() { +#ifdef LOAD_INI_SETTINGS + ms_padButtonsInited = 0; +#endif for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++) { for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++) @@ -321,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; @@ -329,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 @@ -341,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); /*******************************************************************************************/ } @@ -393,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); @@ -2772,7 +2791,7 @@ void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action) for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++) { int32 setorder = m_aSettings[action][k].m_ContSetOrder; - if (setorder > i && setorder != KEYBOARD) + if (setorder > i && setorder != 0) { if (init) { diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 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 36db8107..3a2d3b59 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" @@ -581,13 +577,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(""); @@ -671,7 +675,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl) m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; m_bStartWaitingForKeyBind = false; +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#else SaveSettings(); +#endif } } @@ -3053,6 +3061,16 @@ CMenuManager::LoadSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); +#ifdef LOAD_INI_SETTINGS + if (LoadINISettings()) { + LoadINIControllerSettings(); + } else { + // no re3.ini, create it + SaveINISettings(); + SaveINIControllerSettings(); + } +#endif + #ifdef FIX_BUGS TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; #endif @@ -3098,15 +3116,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; @@ -3165,7 +3180,8 @@ CMenuManager::SaveSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); -#ifdef LOAD_INI_SETTINGS +#else + m_lastWorking3DAudioProvider = m_nPrefsAudio3DProviderIndex; SaveINISettings(); #endif } @@ -4445,19 +4461,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(); @@ -4818,6 +4834,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; @@ -4848,7 +4867,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) @@ -5004,7 +5024,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) @@ -5446,6 +5467,9 @@ CMenuManager::SwitchMenuOnAndOff() ThingsToDoBeforeLeavingPage(); #endif SaveSettings(); +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#endif pControlEdit = nil; pEditString = nil; DisplayComboButtonErrMsg = false; 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/Game.cpp b/src/core/Game.cpp index 3f34617f..e0becc43 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" @@ -856,9 +851,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 +892,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 +936,7 @@ void CGame::Process(void) if (!CReplay::IsPlayingBack()) { PUSH_MEMID(MEMID_CARS); - if (processTime < 2) + //if (processTime < 2) CCarCtrl::GenerateRandomCars(); CRoadBlocks::GenerateRoadBlocks(); CCarCtrl::RemoveDistantCars(); diff --git a/src/core/Lists.h b/src/core/Lists.h index ecf24740..7572e882 100644 --- a/src/core/Lists.h +++ b/src/core/Lists.h @@ -1,7 +1,5 @@ #pragma once -#include "common.h" - class CPtrNode { public: diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 70c92ce8..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. @@ -24,51 +25,51 @@ #ifdef CUSTOM_FRONTEND_OPTIONS #ifdef IMPROVED_VIDEOMODE - #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, nil, screenModes, 2, true, ScreenModeAfterChange, true) }, 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 @@ -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[] = { @@ -388,7 +403,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 +416,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,17 +710,16 @@ 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 #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, 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 d099a9d3..5c4ffbf8 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" @@ -68,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/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/Streaming.cpp b/src/core/Streaming.cpp index 19339fb6..8cdc3a66 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -3150,6 +3150,46 @@ CStreaming::LoadSceneCollision(const CVector &pos) CStreaming::LoadAllRequestedModels(false); } +//--LCS: TODO PSP and PS2 +// some things commented out that might be Rsl3D dependent +void CStreaming::RegisterPointer(void *ptr, int, bool) {} +RpAtomic *CStreaming::RegisterAtomic(RpAtomic *atomic, void *) +{ + return atomic; +} +void CStreaming::RegisterClump(RpClump *clump) +{ + RpClumpForAllAtomics(clump, RegisterAtomic, nil); +} +RpAtomic *CStreaming::RegisterInstance(RpAtomic *atomic, void *) +{ +// RegisterPointer(&atomic->geometry, 2, true); + return atomic; +} +void CStreaming::RegisterInstance(RpClump *clump) +{ + RpClumpForAllAtomics(clump, RegisterInstance, nil); +} + +void CStreaming::UnregisterPointer(void *ptr, int) {} +RpAtomic *CStreaming::UnregisterAtomic(RpAtomic *atomic, void *) +{ + return atomic; +} +void CStreaming::UnregisterClump(RpClump *clump) +{ + RpClumpForAllAtomics(clump, UnregisterAtomic, nil); +} +RpAtomic *CStreaming::UnregisterInstance(RpAtomic *atomic, void *) +{ +// UnregisterPointer(&atomic->geometry, 2); + return atomic; +} +void CStreaming::UnregisterInstance(RpClump *clump) +{ + RpClumpForAllAtomics(clump, UnregisterInstance, nil); +} + void CStreaming::MemoryCardSave(uint8 *buf, uint32 *size) { diff --git a/src/core/Streaming.h b/src/core/Streaming.h index 66262721..4b9502e9 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -20,6 +20,7 @@ enum StreamFlags STREAMFLAGS_40 = 0x40, // TODO(LCS): what's this STREAMFLAGS_AMBIENT_SCRIPT_OWNED = 0x80, + // TODO(LCS): STREAMFLAGS_AMBIENT_SCRIPT_OWNED in STREAMFLAGS_CANT_REMOVE? check CColStore STREAMFLAGS_CANT_REMOVE = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED, STREAMFLAGS_KEEP_IN_MEMORY = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED|STREAMFLAGS_DEPENDENCY, }; @@ -209,6 +210,17 @@ public: static void LoadScene(const CVector &pos); static void LoadSceneCollision(const CVector &pos); + static void RegisterPointer(void *ptr, int, bool); + static RpAtomic *RegisterAtomic(RpAtomic *atomic, void *); + static void RegisterClump(RpClump *clump); + static RpAtomic *RegisterInstance(RpAtomic *atomic, void *); + static void RegisterInstance(RpClump *clump); + static void UnregisterPointer(void *ptr, int); + static RpAtomic *UnregisterAtomic(RpAtomic *atomic, void *); + static void UnregisterClump(RpClump *clump); + static RpAtomic *UnregisterInstance(RpAtomic *atomic, void *); + static void UnregisterInstance(RpClump *clump); + static void MemoryCardSave(uint8 *buffer, uint32 *length); static void MemoryCardLoad(uint8 *buffer, uint32 length); diff --git a/src/core/World.cpp b/src/core/World.cpp index 14624f97..eccbcd89 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" @@ -1793,56 +1788,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/core/World.h b/src/core/World.h index 4cc9398e..b75b6a6c 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -3,6 +3,7 @@ #include "Game.h" #include "Lists.h" #include "PlayerInfo.h" +#include "Collision.h" /* Sectors span from -2000 to 2000 in x and y. * With 100x100 sectors, each is 40x40 units. */ @@ -48,11 +49,6 @@ public: VALIDATE_SIZE(CSector, 0x28); -class CEntity; -struct CColPoint; -struct CColLine; -struct CStoredCollPoly; - class CWorld { static CPtrList ms_bigBuildingsList[NUM_LEVELS]; diff --git a/src/core/Zones.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 ace15ee1..e1d64523 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,17 +11,34 @@ #include #include -#if defined _WIN32 && defined WITHWINDOWS -#include +#if !defined RW_D3D9 && defined LIBRW +#undef WITHD3D +#undef WITHDINPUT +#endif + +#if (defined WITHD3D && !defined LIBRW) +#define WITHWINDOWS #endif -#if defined _WIN32 && defined WITHD3D +#if defined _WIN32 && defined WITHWINDOWS && !defined _INC_WINDOWS #include -#ifndef USE_D3D9 -#include -#else -#include #endif + +#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)) @@ -191,6 +200,18 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x) #endif +// these are temp marcos while we don't implement all PSP UI coordinates +#define PSP_DEFAULT_SCREEN_WIDTH (480) +#define PSP_DEFAULT_SCREEN_HEIGHT (272) + +#define PSP_SCALE_TO_PS2_X(a) (a * ((float)DEFAULT_SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH)) +#define PSP_SCALE_TO_PS2_Y(a) (a * ((float)DEFAULT_SCREEN_HEIGHT / PSP_DEFAULT_SCREEN_HEIGHT)) + +#define PSP_SCREEN_SCALE_X(a) SCREEN_STRETCH_X(PSP_SCALE_TO_PS2_X(a)) +#define PSP_SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(PSP_SCALE_TO_PS2_Y(a)) +#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/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 diff --git a/src/core/main.h b/src/core/main.h index 0f9ceb08..38dce115 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -49,8 +49,10 @@ void TheModelViewer(void); #endif #ifdef LOAD_INI_SETTINGS -void LoadINISettings(); +bool LoadINISettings(); void SaveINISettings(); +void LoadINIControllerSettings(); +void SaveINIControllerSettings(); #endif #ifdef NEW_RENDERER diff --git a/src/core/re3.cpp b/src/core/re3.cpp index cc3e93cb..ace15502 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" @@ -34,9 +33,12 @@ #include "custompipes.h" #include "MemoryHeap.h" #include "FileMgr.h" +#include "Camera.h" +#include "MBlur.h" +#include "ControllerConfig.h" #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS -#include "ControllerConfig.h" +#include "crossplatform.h" #endif #ifndef _WIN32 @@ -95,16 +97,14 @@ CustomFrontendOptionsPopulate(void) FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "WorldPipeline"); - 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_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, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "WorldPipeline"); - 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_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); } @@ -117,172 +117,410 @@ CustomFrontendOptionsPopulate(void) #include "ini_parser.hpp" linb::ini cfg; -int CheckAndReadIniInt(const char *cat, const char *key, int original) +bool ReadIniIfExists(const char *cat, const char *key, uint32 *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(value, &endPtr, 0); + return true; + } + return false; +} + +bool ReadIniIfExists(const char *cat, const char *key, bool *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(value, &endPtr, 0); + return true; + } + return false; +} + +bool ReadIniIfExists(const char *cat, const char *key, int32 *out) { - std::string strval = cfg.get(cat, key, ""); + std::string strval = cfg.get(cat, key, "\xBA"); const char *value = strval.c_str(); - if (value && value[0] != '\0') - return atoi(value); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtol(value, &endPtr, 0); + return true; + } + return false; +} - return original; +bool ReadIniIfExists(const char *cat, const char *key, int8 *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtol(value, &endPtr, 0); + return true; + } + return false; } -float CheckAndReadIniFloat(const char *cat, const char *key, float original) +bool ReadIniIfExists(const char *cat, const char *key, float *out) { - std::string strval = cfg.get(cat, key, ""); + std::string strval = cfg.get(cat, key, "\xBA"); const char *value = strval.c_str(); - if (value && value[0] != '\0') - return atof(value); + if (value && value[0] != '\xBA') { + *out = atof(value); + return true; + } + return false; +} - return original; +bool ReadIniIfExists(const char *cat, const char *key, char *out, int size) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + if (value && value[0] != '\xBA') { + strncpy(out, value, size); + return true; + } + return false; } -void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed) +void StoreIni(const char *cat, const char *key, uint32 val) { char temp[10]; - if (atoi(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it - changed = true; - sprintf(temp, "%u", val); - cfg.set(cat, key, temp); - } +sprintf(temp, "%u", val); + cfg.set(cat, key, temp); } -void CheckAndSaveIniFloat(const char *cat, const char *key, float val, bool &changed) +void StoreIni(const char *cat, const char *key, uint8 val) { char temp[10]; - if (atof(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it - changed = true; - sprintf(temp, "%f", val); - cfg.set(cat, key, temp); - } + sprintf(temp, "%u", (uint32)val); + cfg.set(cat, key, temp); } -void LoadINISettings() +void StoreIni(const char *cat, const char *key, int32 val) { - cfg.load_file("reLCS.ini"); + 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() +{ #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - // Written by assuming the codes below will run after _InputInitialiseJoys(). - strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str()); - - if(gSelectedJoystickName[0] != '\0') { - for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { - if (glfwJoystickPresent(i) && strncmp(gSelectedJoystickName, glfwGetJoystickName(i), strlen(gSelectedJoystickName)) == 0) { - if (PSGLOBAL(joy1id) != -1) { - PSGLOBAL(joy2id) = PSGLOBAL(joy1id); + ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif + // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that + if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) { + ControlsManager.ms_padButtonsInited = cfg.category_size("Bindings") != 0 ? 16 : 0; + } + + for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { + char value[128]; + if (ReadIniIfExists("Bindings", iniControllerActions[i], value, 128)) { + for (int32 j = 0; j < MAX_CONTROLLERTYPES; j++){ + ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)i, (eControllerType)j); + } + + for (char *binding = strtok(value,", "); binding != nil; binding = strtok(nil, ", ")) { + int contType = -1; + for (int32 k = 0; k < ARRAY_SIZE(iniControllerTypes); k++) { + int len = strlen(iniControllerTypes[k]); + if (strncmp(binding, iniControllerTypes[k], len) == 0) { + contType = k; + binding += len; + break; + } } - 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); + 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; + } + } } - CFileMgr::SetDir(""); - break; + + ControlsManager.SetControllerKeyAssociatedWithAction((e_ControllerAction)i, contKey, (eControllerType)contType); } } } -#endif +} -#ifdef CUSTOM_FRONTEND_OPTIONS - for (int i = 0; i < MENUPAGES; i++) { - for (int j = 0; j < NUM_MENUROWS; j++) { - CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j]; - if (option.m_Action == MENUACTION_NOTHING) - break; - - // 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); - if (option.m_Action == MENUACTION_CFO_SELECT) { - option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value; +void SaveINIControllerSettings() +{ + for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { + char value[128] = { '\0' }; + + // upper limit should've been GetNumOfSettingsForAction(i), but sadly even R* doesn't use it's own system correctly, and there are gaps between orders. + for (int32 j = SETORDER_1; j < MAX_SETORDERS; j++){ + + // We respect the m_ContSetOrder, and join/implode/order the bindings according to that; using comma as seperator. + for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++){ + if (ControlsManager.m_aSettings[i][k].m_ContSetOrder == j) { + char next[32]; + if (k == JOYSTICK) { + snprintf(next, 32, "%s%d,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key); + + } else if (k == KEYBOARD || k == OPTIONAL_EXTRA) { + if (ControlsManager.m_aSettings[i][k].m_Key == ' ') + snprintf(next, 32, "%sSPC,", iniControllerTypes[k]); + else if (ControlsManager.m_aSettings[i][k].m_Key < 256) + snprintf(next, 32, "%s%c,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key); + else + snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniKeyboardButtons[ControlsManager.m_aSettings[i][k].m_Key - 1000]); + + } else if (k == MOUSE) { + snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniMouseButtons[ControlsManager.m_aSettings[i][k].m_Key - 1]); + } + strcat(value, next); + break; } } } + int len = strlen(value); + if (len > 0) + value[len - 1] = '\0'; // to remove comma + + StoreIni("Bindings", iniControllerActions[i], value, 128); } + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); #endif + StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); + cfg.write_file("reLCS.ini"); +} + +bool LoadINISettings() +{ + if (!cfg.load_file("reLCS.ini")) + return false; + +#ifdef IMPROVED_VIDEOMODE + ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth); + ReadIniIfExists("VideoMode", "Height", &FrontEndMenuManager.m_nPrefsHeight); + ReadIniIfExists("VideoMode", "Depth", &FrontEndMenuManager.m_nPrefsDepth); + ReadIniIfExists("VideoMode", "Subsystem", &FrontEndMenuManager.m_nPrefsSubsystem); + // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section +#else + ReadIniIfExists("Graphics", "VideoMode", &FrontEndMenuManager.m_nDisplayVideoMode); +#endif + ReadIniIfExists("Controller", "HeadBob1stPerson", &TheCamera.m_bHeadBob); + ReadIniIfExists("Controller", "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 - CPostFX::Intensity = CheckAndReadIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity); + ReadIniIfExists("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); + 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 - gBackfaceCulling = CheckAndReadIniInt("Rendering", "BackfaceCulling", gBackfaceCulling); - + #ifdef PROPER_SCALING - CDraw::ms_bProperScaling = CheckAndReadIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling); + ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling); #endif #ifdef FIX_RADAR - CDraw::ms_bFixRadar = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar); + ReadIniIfExists("Draw", "FixRadar", &CDraw::ms_bFixRadar); #endif #ifdef FIX_SPRITES - CDraw::ms_bFixSprites = CheckAndReadIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites); + ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif -} - -void SaveINISettings() -{ - bool changed = false; -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) { - changed = true; - cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName); - } -#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]; if (option.m_Action == MENUACTION_NOTHING) break; + // CFO check 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); + // CFO only supports saving uint8 right now + + // Migrate from old .ini to new .ini + if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, option.m_CFO->value)) + cfg.remove("FrontendOptions", option.m_CFO->save); + 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; + } } } } #endif + return true; +} + +void SaveINISettings() +{ +#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 - CheckAndSaveIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity, changed); + StoreIni("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity); #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); + 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 - CheckAndSaveIniInt("Rendering", "BackfaceCulling", gBackfaceCulling, changed); + StoreIni("Rendering", "BackfaceCulling", gBackfaceCulling); #ifdef PROPER_SCALING - CheckAndSaveIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling, changed); + StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling); #endif #ifdef FIX_RADAR - CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed); + StoreIni("Draw", "FixRadar", CDraw::ms_bFixRadar); #endif #ifdef FIX_SPRITES - CheckAndSaveIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites, changed); + StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); +#endif +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < MENUPAGES; i++) { + for (int j = 0; j < NUM_MENUROWS; j++) { + CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j]; + if (option.m_Action == MENUACTION_NOTHING) + break; + + if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { + // Beware: CFO only supports saving uint8 right now + StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value); + } + } + } #endif - if (changed) - cfg.write_file("reLCS.ini"); + cfg.write_file("reLCS.ini"); } #endif @@ -767,7 +1005,7 @@ extern bool gbRenderDebugEnvMap; "A Date with Death (Toshiko Kasen)", "Cash in Kazuki's Chips (Toshiko Kasen)" }; - missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, 96, missions); + missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); DebugMenuEntrySetWrap(missionEntry, true); DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission); #endif diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index 247aa4b1..390ec475 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 551d1a74..68337fb6 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/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/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) diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp index a9e0604b..1ccd8ac5 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 963b7624..1412141e 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 768c11f4..3d513bbd 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/leeds/base/sList.h b/src/leeds/base/sList.h new file mode 100644 index 00000000..378d8e31 --- /dev/null +++ b/src/leeds/base/sList.h @@ -0,0 +1,35 @@ +#pragma once + +namespace base +{ + +template +class cSList +{ +public: + struct tSItem + { + tSItem* next; + T item; + }; + // extra field on PS2 + tSItem* first; + + cSList() { first = nil; } + void Insert(tSItem* item) { tSItem* n = first; first = item; item->next = n; } + void Remove(tSItem* item) { + if (first == item) { + first = item->next; + return; + } + tSItem* i = first; + while (i && i->next != item) + i = i->next; + assert(i); + i->next = item->next; + + } + +}; + +} \ No newline at end of file diff --git a/src/leeds/smallHeap.cpp b/src/leeds/smallHeap.cpp new file mode 100644 index 00000000..262113af --- /dev/null +++ b/src/leeds/smallHeap.cpp @@ -0,0 +1,20 @@ +#include "common.h" +#include "smallHeap.h" + +cSmallHeap cSmallHeap::msInstance; + +cSmallHeap::cSmallHeap() +{ + bLocked = false; + bUnk = false; +} + +void cSmallHeap::Lock() +{ + // TODO: PS2 code +} + +void cSmallHeap::Unlock() +{ + // TODO: PS2 code +} \ No newline at end of file diff --git a/src/leeds/smallHeap.h b/src/leeds/smallHeap.h new file mode 100644 index 00000000..f2897688 --- /dev/null +++ b/src/leeds/smallHeap.h @@ -0,0 +1,17 @@ +#pragma once + +#include "memoryManager.h" + +class cSmallHeap : public base::cMemoryManager +{ + bool bLocked; + bool bUnk; +public: + cSmallHeap(); + void Lock(); + void Unlock(); + + bool IsLocked() const { return bLocked; } + + static cSmallHeap msInstance; +}; \ No newline at end of file diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index a93040b1..f3fddf20 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) @@ -29,7 +29,9 @@ protected: uint8 m_type; uint8 m_num2dEffects; bool m_bOwnsColModel; +public: // need this in colstore CColModel *m_colModel; +protected: int16 m_2dEffectsID; int16 m_objectId; uint16 m_refCount; 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..cbc4ede8 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -2,8 +2,591 @@ #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; + int16 advert_test; // txd +}; + +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 +599,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 +619,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 +733,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 +799,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 +832,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) \ - -// NB: MI_LCS_ <- temporary stuff so that garages started somewhat working - -#define X(name, var) extern int16 var; - MODELINDICES -#undef X + 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) + + /*X("yt_main_body2", MI_YT_MAIN_BODY2) \*/ + +//#define X(name, var) extern int16 var; +// MODELINDICES +//#undef X // and some hardcoded ones // expand as needed @@ -576,11 +1258,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 +1270,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 +1304,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/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 354bda88..1009a9b4 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 1acd571b..f3271861 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/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); } diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 5abc94b9..ab77bf9b 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 bada38b7..90b54ab7 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/SpecialFX.cpp b/src/render/SpecialFX.cpp index 35b0b2fc..3387cb2e 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -877,7 +877,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size pMarker->m_Matrix.GetPosition() = pos; if (pMarker->m_bFindZOnNextPlacement) { - if ((playerPos - pos).MagnitudeSqr() < sq(100.f) && CColStore::HasCollisionLoaded(CVector2D(pos))) { + if ((playerPos - pos).MagnitudeSqr() < sq(100.f) && CColStore::HasCollisionLoaded(pos)) { float z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z + 1.0f, nil); if (z != 0.0f) pMarker->m_Matrix.GetPosition().z = z - 0.05f * size; @@ -893,7 +893,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size pMarker->AddMarker(identifier, type, size, r, g, b, a, pulsePeriod, pulseFraction, rotateRate); if (type == MARKERTYPE_CYLINDER || type == MARKERTYPE_0 || type == MARKERTYPE_2) { - if ((playerPos - pos).MagnitudeSqr() < sq(100.f) && CColStore::HasCollisionLoaded(CVector2D(pos))) { + if ((playerPos - pos).MagnitudeSqr() < sq(100.f) && CColStore::HasCollisionLoaded(pos)) { float z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z + 1.0f, nil); if (z != 0.0f) pos.z = z - 0.05f * size; diff --git a/src/render/WaterCreatures.cpp b/src/render/WaterCreatures.cpp index b44f987c..4c6c92a6 100644 --- a/src/render/WaterCreatures.cpp +++ b/src/render/WaterCreatures.cpp @@ -1,11 +1,12 @@ +#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" +#include "Object.h" /* int CWaterCreatures::nNumActiveSeaLifeForms; diff --git a/src/render/WaterCreatures.h b/src/render/WaterCreatures.h index 0b8d2376..099cc1a4 100644 --- a/src/render/WaterCreatures.h +++ b/src/render/WaterCreatures.h @@ -1,5 +1,6 @@ #pragma once -#include "Object.h" + +class CObject; /* enum eFishSlotState { diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index d80a3904..186ed870 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/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); diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 44aace43..e0a989de 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/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 d0818d6d..3e7ba0ab 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 @@ -1646,6 +1637,13 @@ main(int argc, char *argv[]) { 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 ) @@ -1655,6 +1653,14 @@ main(int argc, char *argv[]) } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } +#endif } #ifdef _WIN32 @@ -2167,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 db6215f0..87c3846a 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 @@ -2148,8 +2145,15 @@ WinMain(HINSTANCE instance, { 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); @@ -2157,6 +2161,14 @@ WinMain(HINSTANCE instance, } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } +#endif } SetErrorMode(SEM_FAILCRITICALERRORS); diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 13291d33..a4d9e5c3 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.cpp b/src/vehicles/Bike.cpp index 7b6787c7..6ad59769 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -79,6 +79,7 @@ CBike::CBike(int32 id, uint8 CreatedBy) m_bikeAnimType = ASSOCGRP_BIKE_STANDARD; break; case MI_SANCHEZ: + case MI_SANCHEZ2: m_bikeAnimType = ASSOCGRP_BIKE_DIRT; break; default: m_bikeAnimType = ASSOCGRP_BIKE_STANDARD; //assert(0 && "invalid bike model ID"); // TODO 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 6a15d53d..381d13d8 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/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); } diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index e5cd3f62..cebafd77 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, -- cgit v1.2.3 From d7bd0be53eed87b5c86de99888ffce0fece393c5 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 26 Jan 2021 02:23:55 +0300 Subject: garage stuff --- src/control/Garages.cpp | 199 +++++++++++++++++++++++++++++++++++------------ src/control/Garages.h | 12 ++- src/control/Script10.cpp | 3 +- src/control/Script3.cpp | 4 + src/vehicles/Bike.cpp | 2 + src/vehicles/Bike.h | 1 + src/vehicles/Vehicle.cpp | 1 + src/vehicles/Vehicle.h | 1 + 8 files changed, 173 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 9238f51d..951bd6b2 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -16,6 +16,7 @@ #include "Particle.h" #include "PlayerPed.h" #include "Replay.h" +#include "Script.h" #include "Stats.h" #include "Streaming.h" #include "Text.h" @@ -43,7 +44,7 @@ #define RESPRAY_PRICE (100) // Distances -#define DISTANCE_TO_CALL_OFF_CHASE (10.0f) +#define DISTANCE_TO_CALL_OFF_CHASE (50.0f) #define DISTANCE_FOR_MRWHOOP_HACK (0.5f) #define DISTANCE_TO_ACTIVATE_GARAGE (8.0f) #define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE (17.0f) @@ -127,6 +128,7 @@ CStoredCar CGarages::aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_ int32 hGarages = AEHANDLE_NONE; CGarage CGarages::aGarages[NUM_GARAGES]; bool CGarages::bCamShouldBeOutisde; +uint8 CGarages::CrusherRewardMultiplier; #ifndef MASTER bool bPrintNearestObject; @@ -137,6 +139,7 @@ void CGarages::Init(void) #ifndef MASTER VarConsole.Add("Print nearest object", &bPrintNearestObject, true); #endif + CrusherRewardMultiplier = 1; CrushedCarId = -1; NumGarages = 0; MessageEndTime = 0; @@ -217,7 +220,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_fSupX = Max(Max(X1, X2), X3); pGarage->m_fInfY = Min(Min(Min(Y1, Y2), Y3), Y2 + Y3 - Y1); pGarage->m_fSupY = Max(Max(Y1, Y2), Y3); - pGarage->m_vecCorner1 = CVector(X1, Y1, Z1); + pGarage->m_vecCorner1 = CVector2D(X1, Y1); pGarage->m_fInfZ = Z1; pGarage->m_vDir1 = CVector2D(X2 - X1, Y2 - Y1); pGarage->m_vDir2 = CVector2D(X3 - X1, Y3 - Y1); @@ -235,6 +238,22 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_bRecreateDoorOnNextRefresh = false; pGarage->m_bRotatedDoor = false; pGarage->m_bCameraFollowsPlayer = false; + pGarage->m_nTimeToStartAction = 0; + pGarage->field_2 = false; + pGarage->m_nTargetModelIndex = targetId; + pGarage->m_bCollectedCarsState = 0; + pGarage->m_bDeactivated = false; + pGarage->m_bResprayHappened = false; + pGarage->m_bInitialized = false; + pGarage->field_F0 = 0; + pGarage->field_FC = 0; + pGarage->m_bInitialized = InitDoorGubbins(NumGarages, type); + return NumGarages++; +} + +bool CGarages::InitDoorGubbins(uint32 id, uint8 type) +{ + CGarage* pGarage = &aGarages[id]; pGarage->RefreshDoorPointers(true); if (pGarage->m_pDoor1) { pGarage->m_fDoor1Z = pGarage->m_pDoor1->GetPosition().z; @@ -249,12 +268,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_fDoorHeight = pGarage->m_pDoor1 ? FindDoorHeightForMI(pGarage->m_pDoor1->GetModelIndex()) : 4.0f; pGarage->m_fDoorPos = 0.0f; pGarage->m_eGarageState = GS_FULLYCLOSED; - pGarage->m_nTimeToStartAction = 0; - pGarage->field_2 = false; - pGarage->m_nTargetModelIndex = targetId; - pGarage->m_bCollectedCarsState = 0; - pGarage->m_bDeactivated = false; - pGarage->m_bResprayHappened = false; switch (type) { case GARAGE_MISSION: case GARAGE_COLLECTORSITEMS: @@ -263,7 +276,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X case GARAGE_COLLECTCARS_2: case GARAGE_COLLECTCARS_3: case GARAGE_FORCARTOCOMEOUTOF: - case GARAGE_60SECONDS: case GARAGE_MISSION_KEEPCAR: case GARAGE_FOR_SCRIPT_TO_OPEN: case GARAGE_HIDEOUT_ONE: @@ -290,6 +302,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: case GARAGE_RESPRAY: + case GARAGE_60SECONDS: pGarage->m_eGarageState = GS_OPENED; pGarage->m_fDoorPos = pGarage->m_fDoorHeight; break; @@ -304,7 +317,16 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->UpdateCrusherAngle(); else pGarage->UpdateDoorsHeight(); - return NumGarages++; + return pGarage->m_fDoorHeight > 0.0f; +} + +void CGarages::SetupAnyGaragesForThisIsland(void) +{ + for (int i = 0; i < NumGarages; i++) { + CGarage* pGarage = &aGarages[i]; + if (!pGarage->m_bInitialized) + pGarage->m_bInitialized = InitDoorGubbins(i, pGarage->m_eGarageType); + } } void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi) @@ -315,6 +337,21 @@ void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi) pGarage->m_eGarageState = GS_FULLYCLOSED; } +void CGarages::LockGarage(int16 garage, bool state) +{ + CGarage* pGarage = &aGarages[garage]; + pGarage->m_bLocked = state; + if (pGarage->m_bLocked) { + pGarage->m_fDoorPos = 0.0f; + pGarage->m_eGarageState = GS_FULLYCLOSED; + pGarage->m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + 2000; + pGarage->UpdateDoorsHeight(); + } + else { + pGarage->m_eGarageState = GS_OPENING; + } +} + void CGarage::Update() { if (m_eGarageType != GARAGE_CRUSHER) { @@ -354,7 +391,7 @@ void CGarage::Update() if (m_bDeactivated && m_eGarageState == GS_FULLYCLOSED) return; if (m_bRotatedDoor) { -#ifdef GTA_PS2 +#if defined GTA_PS2 || defined GTA_PSP if (m_eGarageState == GS_OPENING) { if (m_pDoor1) { if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor1) @@ -438,7 +475,10 @@ void CGarage::Update() #else if (FindPlayerVehicle()) #endif + { ((CAutomobile*)(FindPlayerVehicle()))->m_fFireBlowUpTimer = 0.0f; + FindPlayerVehicle()->m_bGarageTurnedLightsOff = true; + } CWorld::CallOffChaseForArea( m_fInfX - DISTANCE_TO_CALL_OFF_CHASE, m_fInfY - DISTANCE_TO_CALL_OFF_CHASE, @@ -446,6 +486,7 @@ void CGarage::Update() m_fSupY + DISTANCE_TO_CALL_OFF_CHASE); break; case GS_FULLYCLOSED: + m_fDoorPos = 0.0f; if (CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) { m_eGarageState = GS_OPENING; DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1); @@ -480,11 +521,8 @@ void CGarage::Update() FindPlayerVehicle()->GetRight() = -FindPlayerVehicle()->GetRight(); } bChangedColour = false; -#ifdef FIX_BUGS - if (!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) { -#else - if (!((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) { -#endif + if ((!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) && + (!FindPlayerVehicle()->IsBike() || !((CBike*)(FindPlayerVehicle()))->bFixedColour)) { uint8 colour1, colour2; uint16 attempt; FindPlayerVehicle()->GetModelInfo()->ChooseVehicleColour(colour1, colour2); @@ -497,12 +535,36 @@ void CGarage::Update() FindPlayerVehicle()->m_currentColour1 = colour1; FindPlayerVehicle()->m_currentColour2 = colour2; if (bChangedColour) { + CVector vCorners[] = { + CVector(m_fInfX, m_fInfY, 0.0f), CVector(m_fInfX, m_fSupY, 0.0f), + CVector(m_fSupX, m_fInfY, 0.0f), CVector(m_fSupX, m_fSupY, 0.0f) + }; + CVector vMiddles[] = { + CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fInfY, 0.0f), CVector(m_fInfX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f), + CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fSupY, 0.0f), CVector(m_fSupX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f), + }; + int nClosestCornerToCamera = 0; + int nClosestMiddleToCamera = 0; + for (int i = 1; i < 4; i++) { + if ((vCorners[nClosestCornerToCamera] - TheCamera.GetPosition()).Magnitude() > + (vCorners[i] - TheCamera.GetPosition()).Magnitude()) + nClosestCornerToCamera = i; + if ((vMiddles[nClosestMiddleToCamera] - TheCamera.GetPosition()).Magnitude() > + (vMiddles[i] - TheCamera.GetPosition()).Magnitude()) + nClosestMiddleToCamera = i; + } + CVector vDirectionCenterToMiddle = vMiddles[nClosestMiddleToCamera] - CVector(GetGarageCenterX(), GetGarageCenterY(), 0.0f); + vDirectionCenterToMiddle.Normalise(); + for (int i = 0; i < NUM_PARTICLES_IN_RESPRAY; i++) { - CVector pos; - pos.x = CGeneral::GetRandomNumberInRange(m_fInfX + 0.5f, m_fSupX - 0.5f); - pos.y = CGeneral::GetRandomNumberInRange(m_fInfY + 0.5f, m_fSupY - 0.5f); - pos.z = CGeneral::GetRandomNumberInRange(m_fDoor1Z - 3.0f, m_fDoor1Z + 1.0f); - CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]); + CVector pos(vMiddles[nClosestMiddleToCamera] - vDirectionCenterToMiddle * 0.5f); + CVector dir(CrossProduct(vDirectionCenterToMiddle, CVector(0.0f, 0.0f, 1.0f))); + float fDirMultiplier = (vCorners[nClosestCornerToCamera] - vMiddles[nClosestMiddleToCamera]).Magnitude(); + pos += dir * CGeneral::GetRandomNumberInRange(-1.0f, 1.0f) * fDirMultiplier; // TODO: base::RandomReal? + pos += vDirectionCenterToMiddle * CGeneral::GetRandomNumberInRange(-6.0f, 0.4f); + dir = vDirectionCenterToMiddle * 0.04f; + pos.z = m_fInfZ + CGeneral::GetRandomNumberInRange(-0.4f, 0.0f); + CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, dir, nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]); // TODO: mspInfo } } } @@ -512,8 +574,11 @@ void CGarage::Update() if (!CGarages::RespraysAreFree) { CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE); CStats::AutoPaintingBudget += RESPRAY_PRICE; + CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you! + } + else { + CGarages::TriggerMessage("GA_17", -1, 4000, -1); } - CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you! } else if (bChangedColour) { if (CGeneral::GetRandomTrueFalse()) @@ -538,6 +603,8 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_OPENEDCONTAINSCAR: + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = false; if (IsPlayerOutsideGarage()) m_eGarageState = GS_OPENED; break; @@ -550,9 +617,18 @@ void CGarage::Update() case GARAGE_BOMBSHOP1: case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: + if (m_bLocked) + break; switch (m_eGarageState) { case GS_OPENED: + UpdateDoorsHeight(); if (IsStaticPlayerCarEntirelyInside()) { + if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) { + CGarages::TriggerMessage("GA_22", -1, 4000, -1); + m_eGarageState = GS_OPENEDCONTAINSCAR; + DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1); + break; + } if (!FindPlayerVehicle() || FindPlayerVehicle()->m_bombType) { CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb" m_eGarageState = GS_OPENEDCONTAINSCAR; @@ -579,6 +655,8 @@ void CGarage::Update() m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB; DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); } + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = true; UpdateDoorsHeight(); if (m_eGarageType == GARAGE_BOMBSHOP3) CStreaming::RequestModel(MI_BOMB, STREAMFLAGS_DONT_REMOVE); @@ -595,13 +673,25 @@ void CGarage::Update() if (!CGarages::BombsAreFree) CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE); if (FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike())) { -#if (!defined GTA_PS2 || defined FIX_BUGS) +#if (!defined GTA_PS2 || defined FIX_BUGS) // <- this remained in CAutomobile in LCS FindPlayerVehicle()->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); FindPlayerVehicle()->m_pBombRigger = FindPlayerPed(); #else // PS2 version contained a bug: CBike was casted to CAutomobile, but due to coincidence it didn't corrupt memory ((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); ((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed(); #endif + // what is this + uint32 i = CPools::GetVehiclePool()->GetSize(); + while (i--) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (pVehicle) { + if (pVehicle->IsCar() && pVehicle->GetStatus() == STATUS_WRECKED) { + CAutomobile* pCar = (CAutomobile*)pVehicle; + pCar->m_pBombRigger = nil; + pCar->m_pBlowUpEntity = nil; + } + } + } if (m_eGarageType == GARAGE_BOMBSHOP3) CGarages::GivePlayerDetonator(); CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB; @@ -640,6 +730,7 @@ void CGarage::Update() CHud::SetHelpMessage(TheText.Get("GA_8"), false); // Use the detonator to activate the bomb. break; } + CGarages::TriggerMessage(CGarages::BombsAreFree ? "GA_24" : "GA_23", -1, 4000, -1); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE); FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false; } @@ -657,6 +748,8 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_OPENEDCONTAINSCAR: + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = false; if (IsPlayerOutsideGarage()) m_eGarageState = GS_OPENED; break; @@ -670,16 +763,12 @@ void CGarage::Update() switch (m_eGarageState) { case GS_OPENED: if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) { - if ((CTimer::GetFrameCounter() & 0x1F) == 0 -#ifndef GTA_PS2 - && (!m_pTarget || IsEntityTouching3D(m_pTarget)) -#endif - ) { + if ((CTimer::GetFrameCounter() & 0x1F) == 0 && !IsAnyOtherCarTouchingGarage(nil)) { m_eGarageState = GS_CLOSING; m_bClosingWithoutTargetCar = true; } } - else if (!FindPlayerVehicle() && m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) && + else if (m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) && IsEntityEntirelyOutside(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 2.0f)) { CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE); FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true; @@ -691,7 +780,11 @@ void CGarage::Update() if (m_pTarget) ThrowCarsNearDoorOutOfGarage(m_pTarget); m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep()); - if (m_fDoorPos == 0.0f) { + if (!IsEntityEntirelyOutside(FindPlayerPed(), 1.0f)) { + printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); + m_eGarageState = GS_OPENING; + } + else if (m_fDoorPos == 0.0f) { DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); if (m_bClosingWithoutTargetCar) m_eGarageState = GS_FULLYCLOSED; @@ -787,22 +880,21 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_FULLYCLOSED: + if (CTheScripts::IsPlayerOnAMission()) { + m_pTarget = nil; + break; + } + if (IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) { + printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); + m_eGarageState = GS_OPENING; + } if (FindPlayerVehicle() && CalcSmallestDistToGarageDoorSquared( FindPlayerVehicle()->GetPosition().x, FindPlayerVehicle()->GetPosition().y ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE)) { if (DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) { - if (FindPlayerVehicle()->VehicleCreatedBy == MISSION_VEHICLE) - CGarages::TriggerMessage("GA_1A", -1, 5000, -1); // Come back when you're not so busy... - else - m_eGarageState = GS_OPENING; - } - else { - if (HasCraigCollectedThisCar(FindPlayerVehicle()->GetModelIndex())) - CGarages::TriggerMessage("GA_20", -1, 5000, -1); // We got more of these than we can shift. Sorry man, no deal. - else if (FindPlayerSpeed().Magnitude() < MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE) - CGarages::TriggerMessage("GA_19", -1, 5000, -1); // We're not interested in that model. + m_eGarageState = GS_OPENING; } } m_pTarget = nil; @@ -838,6 +930,7 @@ void CGarage::Update() m_eGarageState = GS_FULLYCLOSED; DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); } + UpdateDoorsHeight(); if (!IsGarageEmpty()) m_eGarageState = GS_OPENING; break; @@ -858,6 +951,7 @@ void CGarage::Update() break; } break; + case GARAGE_60SECONDS: case GARAGE_CRUSHER: { // for now version from III @@ -870,9 +964,10 @@ void CGarage::Update() CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) continue; - if (pVehicle->IsCar() && IsEntityEntirelyInside3D(pVehicle, 0.0f)) { - m_eGarageState = GS_CLOSING; + if ((pVehicle->IsCar() || pVehicle->IsBike()) && IsEntityEntirelyInside3D(pVehicle, 0.0f)) { + m_eGarageState = GS_WAITINGFORCAR; m_pTarget = pVehicle; + m_nTimeCrusherCraneActivated = CTimer::GetTimeInMilliseconds(); m_pTarget->RegisterReference((CEntity**)&m_pTarget); } } @@ -892,9 +987,10 @@ void CGarage::Update() if (m_fDoorPos == 0.0f) { CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget); float reward = Min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT); - CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward; + CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward * CGarages::CrusherRewardMultiplier; + CMessages::AddMessageWithNumber(TheText.Get("CRUSHED"), 5000, 1, reward* CGarages::CrusherRewardMultiplier, -1, -1, -1, -1, -1); DestroyVehicleAndDriverAndPassengers(m_pTarget); - //++CStats::CarsCrushed; + //++CStats::CarsCrushed; // TODO m_pTarget = nil; m_eGarageState = GS_AFTERDROPOFF; m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_CRUSH_CAR; @@ -922,9 +1018,12 @@ void CGarage::Update() } UpdateCrusherAngle(); break; - //case GS_FULLYCLOSED: - //case GS_CLOSEDCONTAINSCAR: - //case GS_OPENEDCONTAINSCAR: + case GS_WAITINGFORCAR: + if (m_pTarget) { + if (CTimer::GetTimeInMilliseconds() - m_nTimeCrusherCraneActivated > 3000) + m_eGarageState = GS_CLOSING; + } + break; default: break; } @@ -1089,7 +1188,10 @@ void CGarage::Update() break; case GS_FULLYCLOSED: { - float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y); + float distance = INFINITY; + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed) { + distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y); + } if (distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT) || distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR) && FindPlayerVehicle()) { if (FindPlayerVehicle() && CGarages::CountCarsInHideoutGarage(m_eGarageType) >= FindMaxNumStoredCarsForGarage()) { @@ -1273,6 +1375,7 @@ bool CGarage::IsPointInsideGarage(CVector pos, float m_fMargin) bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin) { + // TODO: hack for GARAGE_60SECONDS if (pEntity->GetPosition().x < m_fInfX - fMargin || pEntity->GetPosition().x > m_fSupX + fMargin || pEntity->GetPosition().y < m_fInfY - fMargin || pEntity->GetPosition().y > m_fSupY + fMargin || pEntity->GetPosition().z < m_fInfZ - fMargin || pEntity->GetPosition().z > m_fSupZ + fMargin) diff --git a/src/control/Garages.h b/src/control/Garages.h index c3542d27..83e040c5 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -15,6 +15,7 @@ enum eGarageState GS_OPENEDCONTAINSCAR, GS_CLOSEDCONTAINSCAR, GS_AFTERDROPOFF, + GS_WAITINGFORCAR }; enum eGarageType @@ -121,6 +122,7 @@ public: float m_fSupX; float m_fInfY; float m_fSupY; + uint32 m_nTimeCrusherCraneActivated; float m_fDoorPos; float m_fDoorHeight; float m_fDoor1X; @@ -133,6 +135,11 @@ public: uint8 m_bCollectedCarsState; CVehicle *m_pTarget; CStoredCar m_sStoredCar; // not needed + bool m_bInitialized; + uint32 field_F0; + bool m_bLocked; + uint32 field_F8; + uint32 field_FC; void OpenThisGarage(); void CloseThisGarage(); @@ -219,6 +226,7 @@ public: static CGarage aGarages[NUM_GARAGES]; static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_CARS]; static bool bCamShouldBeOutisde; + static uint8 CrusherRewardMultiplier; static void Init(void); #ifndef PS2 @@ -297,6 +305,8 @@ public: } static bool IsThisGarageTypeSafehouse(uint8 type) { return FindSafeHouseIndexForGarageType(type) >= 0; } - static void SetupAnyGaragesForThisIsland(void) {} // TODO(LCS) + static bool InitDoorGubbins(uint32, uint8); + static void SetupAnyGaragesForThisIsland(void); + static void LockGarage(int16, bool); }; diff --git a/src/control/Script10.cpp b/src/control/Script10.cpp index fef33848..ba46fcc3 100644 --- a/src/control/Script10.cpp +++ b/src/control/Script10.cpp @@ -7,6 +7,7 @@ #include "DMAudio.h" #include "Frontend.h" #include "GameLogic.h" +#include "Garages.h" #include "General.h" #include "Hud.h" #include "Messages.h" @@ -286,7 +287,7 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) return 0; case COMMAND_LOCK_GARAGE: CollectParameters(&m_nIp, 2); - // CGarages::LockGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + CGarages::LockGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_IS_FINAL_GAME: #ifdef FINAL diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index 7acfdfc8..a903d023 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -1225,6 +1225,10 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) #endif ((CAutomobile*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0); +#ifdef FIX_BUGS + else if (pVehicle->m_vehType == VEHICLE_TYPE_BIKE) + ((CBike*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0); +#endif return 0; } diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 6ad59769..f8ef4746 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -134,6 +134,8 @@ CBike::CBike(int32 id, uint8 CreatedBy) bIsOnFire = false; bWheelieCam = false; + bFixedColour = false; // <- figure out actual place (TODO) + m_fTireTemperature = 1.0f; m_fBrakeDestabilization = 0.0f; m_fVelocityChangeForAudio = 0; diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 219d8872..611cd11d 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -75,6 +75,7 @@ public: uint8 bExtraSpeed : 1; // leaning forward uint8 bIsOnFire : 1; uint8 bWheelieCam : 1; + uint8 bFixedColour : 1; // <- figure out its actual place (TODO) int16 m_doingBurnout; float m_fTireTemperature; float m_fBrakeDestabilization; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 02852cee..54c2260b 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -133,6 +133,7 @@ CVehicle::CVehicle(uint8 CreatedBy) bCreatedAsPoliceVehicle = false; bRestingOnPhysical = false; bParking = false; + m_bGarageTurnedLightsOff = false; bCanPark = CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < 0.0f; // never true. probably doesn't work very well bIsVan = false; bIsBus = false; diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index cebafd77..cd16171b 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -251,6 +251,7 @@ public: uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default) int8 m_nPacManPickupsCarried; uint8 m_nRoadblockType; + bool m_bGarageTurnedLightsOff; float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode float m_fEngineEnergy; // TODO(LCS): better name. it adds up acceleration force, so possibly kinetic energy?? uint8 m_nCurrentGear; -- cgit v1.2.3 From 42d9d6abc880beade72c17ce4f490de5636ae56c Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 26 Jan 2021 02:27:32 +0300 Subject: syncd --- src/control/Garages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 951bd6b2..5f3fc1ff 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -564,7 +564,7 @@ void CGarage::Update() pos += vDirectionCenterToMiddle * CGeneral::GetRandomNumberInRange(-6.0f, 0.4f); dir = vDirectionCenterToMiddle * 0.04f; pos.z = m_fInfZ + CGeneral::GetRandomNumberInRange(-0.4f, 0.0f); - CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, dir, nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]); // TODO: mspInfo + CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, dir, nil, 0.0f, CVehicleModelInfo::mspInfo->ms_vehicleColourTable[colour1]); } } } -- cgit v1.2.3 From 2fea28f194c81ca17a4401cb8cd4f8fbc82c7ab8 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 26 Jan 2021 02:27:57 +0300 Subject: fix --- src/control/Garages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 5f3fc1ff..59619f8e 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -322,7 +322,7 @@ bool CGarages::InitDoorGubbins(uint32 id, uint8 type) void CGarages::SetupAnyGaragesForThisIsland(void) { - for (int i = 0; i < NumGarages; i++) { + for (uint32 i = 0; i < NumGarages; i++) { CGarage* pGarage = &aGarages[i]; if (!pGarage->m_bInitialized) pGarage->m_bInitialized = InitDoorGubbins(i, pGarage->m_eGarageType); -- cgit v1.2.3 From edb50b66a04a06aa1f5ed97e7b5b95b528cffc43 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 26 Jan 2021 20:46:42 +0300 Subject: enum change --- src/control/Garages.cpp | 6 +++--- src/control/Garages.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 59619f8e..1bf15424 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -302,7 +302,7 @@ bool CGarages::InitDoorGubbins(uint32 id, uint8 type) case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: case GARAGE_RESPRAY: - case GARAGE_60SECONDS: + case GARAGE_CRATE_GARAGE: pGarage->m_eGarageState = GS_OPENED; pGarage->m_fDoorPos = pGarage->m_fDoorHeight; break; @@ -951,7 +951,7 @@ void CGarage::Update() break; } break; - case GARAGE_60SECONDS: + case GARAGE_CRATE_GARAGE: case GARAGE_CRUSHER: { // for now version from III @@ -2243,7 +2243,7 @@ void CGarage::PlayerArrestedOrDied() case GARAGE_COLLECTCARS_2: case GARAGE_COLLECTCARS_3: case GARAGE_FORCARTOCOMEOUTOF: - case GARAGE_60SECONDS: + case GARAGE_CRATE_GARAGE: case GARAGE_MISSION_KEEPCAR: case GARAGE_FOR_SCRIPT_TO_OPEN: case GARAGE_HIDEOUT_ONE: diff --git a/src/control/Garages.h b/src/control/Garages.h index 83e040c5..99426040 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -32,7 +32,7 @@ enum eGarageType GARAGE_COLLECTCARS_2, GARAGE_COLLECTCARS_3, GARAGE_FORCARTOCOMEOUTOF, - GARAGE_60SECONDS, + GARAGE_CRATE_GARAGE, GARAGE_CRUSHER, GARAGE_MISSION_KEEPCAR, GARAGE_FOR_SCRIPT_TO_OPEN, -- cgit v1.2.3 From c3c2a4269d5562ca6059eb87fbfc5b59d22894ca Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 28 Jan 2021 01:07:40 +0300 Subject: stuff --- src/control/Garages.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++++--- src/control/Garages.h | 11 +++++ 2 files changed, 120 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 1bf15424..7d7d3922 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -354,6 +354,10 @@ void CGarages::LockGarage(int16 garage, bool state) void CGarage::Update() { +#ifdef GTA_NETWORK + if (/* gIsMultiplayerGame && */m_eGarageType != GARAGE_CRATE_GARAGE) // TODO(multiplayer) + return; +#endif if (m_eGarageType != GARAGE_CRUSHER) { switch (m_eGarageState) { case GS_FULLYCLOSED: @@ -617,8 +621,10 @@ void CGarage::Update() case GARAGE_BOMBSHOP1: case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: - if (m_bLocked) + if (m_bLocked) { + UpdateDoorsHeight(); break; + } switch (m_eGarageState) { case GS_OPENED: UpdateDoorsHeight(); @@ -952,9 +958,92 @@ void CGarage::Update() } break; case GARAGE_CRATE_GARAGE: +#ifdef GTA_NETWORK + { + switch (m_eGarageState) { + case GS_OPENED: + if (m_pSSVehicle) { + // if (m_pSSVehicle->GetVehiclePointer() && IsEntityEntirelyInside3D(m_pSSVehicle->GetVehiclePointer()) + { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + // m_pSSTargetCar = m_pSSVehicle->GetVehiclePointer(); + m_pSSTargetCar->RegisterReference((CEntity**)&m_pSSTargetCar); + } + // else + { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + m_pSSTargetCar = nil; + } + if (m_pSSTargetCar) { + if (!FindPlayerVehicle()/* && m_pSSTargetCar == m_pSSVehicle->GetVehiclePointer() */) + { + if (IsEntityEntirelyOutside(FindPlayerPed(), 6.0f)) { + if (FindPlayerPed()->m_fHealth > 0.0f) { + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE); + m_eGarageState = GS_CLOSING; + m_bSSGarageStateChanging = true; + } + } + } + } + } + break; + case GS_CLOSING: + m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep()); + if (m_fDoorPos == 0.0f) { + // if (? == m_nSSGarageState) + { + if (m_pSSTargetCar) { + // if (m_pSSVehicle->GetVehiclePointer()) + { + if (IsEntityEntirelyInside3D(/* m_pSSVehicle->GetVehiclePointer() */nil, 0.0f)) { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + CWorld::Remove(m_pSSTargetCar); + delete m_pSSTargetCar; + m_pSSTargetCar = nil; + m_pSSVehicle = nil; + m_bSSGarageAcceptedVehicle = true; + printf("Destroying Car Inside Crate....\n"); + } + } + } + } + // TODO: some loop :( + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE); + m_eGarageState = GS_FULLYCLOSED; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); + } + UpdateDoorsHeight(); + if (!IsGarageEmpty()) + m_eGarageState = GS_OPENING; + break; + case GS_FULLYCLOSED: + { + // if (? == m_nSSGarageState) + { + if (CalcDistToGarageRectangleSquared(FindPlayerPed()->GetPosition().x, FindPlayerPed()->GetPosition().y) > SQR(10.0f)) + m_eGarageState = GS_OPENING; + } + break; + } + case GS_OPENING: + m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep()); + if (m_fDoorPos == m_fDoorHeight) { + m_bSSGarageStateChanging = false; + m_eGarageState = GS_OPENED; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f); + } + UpdateDoorsHeight(); + break; + } + break; + } +#endif case GARAGE_CRUSHER: { - // for now version from III switch (m_eGarageState) { case GS_OPENED: { @@ -1375,7 +1464,6 @@ bool CGarage::IsPointInsideGarage(CVector pos, float m_fMargin) bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin) { - // TODO: hack for GARAGE_60SECONDS if (pEntity->GetPosition().x < m_fInfX - fMargin || pEntity->GetPosition().x > m_fSupX + fMargin || pEntity->GetPosition().y < m_fInfY - fMargin || pEntity->GetPosition().y > m_fSupY + fMargin || pEntity->GetPosition().z < m_fInfZ - fMargin || pEntity->GetPosition().z > m_fSupZ + fMargin) @@ -1384,8 +1472,15 @@ bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin) for (int i = 0; i < pColModel->numSpheres; i++) { CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; float radius = pColModel->spheres[i].radius; - if (!IsPointInsideGarage(pos, fMargin - radius)) - return false; + if (m_eGarageType == GARAGE_CRATE_GARAGE) { + if (pos.x + radius < m_fInfX - fMargin || pos.x - radius > m_fSupX + fMargin || + pos.y + radius < m_fInfY - fMargin || pos.y - radius > m_fSupX + fMargin) + return false; + } + else { + if (!IsPointInsideGarage(pos, fMargin - radius)) + return false; + } } return true; } @@ -1399,8 +1494,15 @@ bool CGarage::IsEntityEntirelyOutside(CEntity * pEntity, float fMargin) for (int i = 0; i < pColModel->numSpheres; i++) { CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; float radius = pColModel->spheres[i].radius; - if (IsPointInsideGarage(pos, fMargin + radius)) - return false; + if (m_eGarageType == GARAGE_CRATE_GARAGE) { + if (pos.x + radius > m_fInfX - fMargin && pos.x - radius < m_fSupX + fMargin && + pos.y + radius > m_fInfY - fMargin && pos.y - radius < m_fSupX + fMargin) + return false; + } + else { + if (IsPointInsideGarage(pos, fMargin + radius)) + return false; + } } return true; } diff --git a/src/control/Garages.h b/src/control/Garages.h index 99426040..5235275e 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -6,6 +6,8 @@ class CVehicle; +#define GTA_NETWORK + enum eGarageState { GS_FULLYCLOSED, @@ -123,6 +125,7 @@ public: float m_fInfY; float m_fSupY; uint32 m_nTimeCrusherCraneActivated; + CVehicle* m_pSSTargetCar; float m_fDoorPos; float m_fDoorHeight; float m_fDoor1X; @@ -135,7 +138,15 @@ public: uint8 m_bCollectedCarsState; CVehicle *m_pTarget; CStoredCar m_sStoredCar; // not needed +#ifdef GTA_NETWORK + void* m_pSSVehicle; // some multiplayer vehicle structure, +104 == GetVehiclePointer + bool m_bSSGarageAcceptedVehicle; +#endif bool m_bInitialized; +#ifdef GTA_NETWORK + uint8 m_nSSGarageState; + bool m_bSSGarageStateChanging; +#endif uint32 field_F0; bool m_bLocked; uint32 field_F8; -- cgit v1.2.3 From 07a5cc654474ffe09ae5ce45b3ec1a7f0e004379 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 31 Jan 2021 01:38:00 +0300 Subject: garages --- src/control/Garages.cpp | 202 ++++++++++++++++++++++++++++--------------- src/control/Garages.h | 34 +++++--- src/control/Script.cpp | 2 +- src/control/Script10.cpp | 4 +- src/control/ScriptCommands.h | 2 +- src/modelinfo/ModelIndices.h | 2 +- src/vehicles/Vehicle.h | 5 +- 7 files changed, 162 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index d5b41c6c..d3e0295a 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -8,6 +8,7 @@ #include "DMAudio.h" #include "General.h" #include "Font.h" +#include "Frontend.h" #include "HandlingMgr.h" #include "Hud.h" #include "Messages.h" @@ -15,6 +16,7 @@ #include "Pad.h" #include "Particle.h" #include "PlayerPed.h" +#include "Radar.h" #include "Replay.h" #include "Script.h" #include "Stats.h" @@ -101,10 +103,10 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLLECTCARS_CARS] = { - { MI_LANDSTAL, MI_IDAHO, MI_ESPERANT, MI_STALLION, MI_RANCHER, MI_BLISTAC }, - { MI_SABRE, MI_VIRGO, MI_SENTINEL, MI_STRETCH, MI_WASHING, MI_ADMIRAL }, - { MI_CHEETAH, MI_INFERNUS, MI_BANSHEE, MI_PHEONIX, MI_COMET, MI_STINGER }, - { MI_VOODOO, MI_CUBAN, MI_CADDY, MI_BAGGAGE, MI_MRWHOOP, MI_PIZZABOY } + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, }; const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; @@ -890,7 +892,7 @@ void CGarage::Update() m_pTarget = nil; break; } - if (IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) { + if (!IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) { printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); m_eGarageState = GS_OPENING; } @@ -1677,23 +1679,20 @@ void CGarage::RemoveCarsBlockingDoorNotInside() void CGarages::PrintMessages() { if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) { + // CRadar::m_FadeDownRadar = true; // TODO CFont::DrawFonts(); - CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); + float x_scale = FrontEndMenuManager.m_PrefsUseWideScreen ? 0.34506f : 0.3834f; + CFont::SetScale(PSP_SCREEN_SCALE_X(x_scale), PSP_SCREEN_SCALE_Y(0.71f)); CFont::SetPropOn(); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); -#ifdef FIX_BUGS - CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 50)); -#else - CFont::SetCentreSize(SCREEN_WIDTH - 50); -#endif CFont::SetCentreOn(); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetColor(CRGBA(27, 89, 130, 255)); CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); - - float y_offset = SCREEN_SCALE_Y(140.0f); + CFont::SetCentreSize(PSP_SCREEN_SCALE_X(454.0f)); + float y_offset = PSP_SCREEN_SCALE_Y(170.0f); if (MessageNumberInString2 >= 0) { CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString); @@ -1714,6 +1713,7 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle) switch (pVehicle->GetModelIndex()) { case MI_FIRETRUCK: case MI_AMBULAN: + case MI_FBICAR: case MI_POLICE: case MI_ENFORCER: case MI_BUS: @@ -1721,9 +1721,6 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle) case MI_BARRACKS: case MI_DODO: case MI_COACH: -#ifndef GTA_PS2 - case MI_FBIRANCH: -#endif return false; default: break; @@ -1773,9 +1770,9 @@ void CGarage::BuildRotatedDoorMatrix(CEntity * pDoor, float fPosition) void CGarage::UpdateCrusherAngle() { RefreshDoorPointers(false); - m_pDoor1->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos); - m_pDoor1->GetMatrix().UpdateRW(); - m_pDoor1->UpdateRwFrame(); + m_pDoor2->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos); + m_pDoor2->GetMatrix().UpdateRW(); + m_pDoor2->UpdateRwFrame(); } void CGarage::UpdateCrusherShake(float X, float Y) @@ -1860,6 +1857,7 @@ void CGarages::TriggerMessage(const char* text, int16 num1, uint16 time, int16 n MessageEndTime = CTimer::GetTimeInMilliseconds() - 500 + time; } else { + CMessages::AddToPreviousBriefArray(TheText.Get(text), -1, -1, -1, -1, -1, -1, nil); strcpy(MessageIDString, text); MessageStartTime = CTimer::GetTimeInMilliseconds(); MessageEndTime = CTimer::GetTimeInMilliseconds() + time; @@ -1926,6 +1924,8 @@ bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) bool CGarage::DoesCraigNeedThisCar(int32 mi) { int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); + if (ct != 0) + return false; for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0; @@ -1936,8 +1936,10 @@ bool CGarage::DoesCraigNeedThisCar(int32 mi) bool CGarage::HasCraigCollectedThisCar(int32 mi) { int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); + if (ct != 0) + return 0; for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { - if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) + if (mi == gaCarsToCollectInCraigsGarages[ct][i]) return CGarages::CarTypesCollected[ct] & BIT(i); } return false; @@ -1946,23 +1948,21 @@ bool CGarage::HasCraigCollectedThisCar(int32 mi) bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi) { int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); + if (ct != 0) + return 0; int index; for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) { - if (mi == gaCarsToCollectInCraigsGarages[ct][index] || (gaCarsToCollectInCraigsGarages[ct][index] == MI_CHEETAH && mi == MI_VICECHEE)) + if (mi == gaCarsToCollectInCraigsGarages[ct][index]) break; } if (index >= TOTAL_COLLECTCARS_CARS) return false; CGarages::CarTypesCollected[ct] |= BIT(index); - CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_REWARD; for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) { - CGarages::TriggerMessage("GA_13", -1, 5000, -1); // Delivered like a pro. Complete the list and there'll be a bonus for you. return false; } } - CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_ALLCARS_REWARD; - CGarages::TriggerMessage("GA_14", -1, 5000, -1); // All the cars. NICE! Here's a little something. return true; } @@ -2059,8 +2059,27 @@ void CGarage::FindDoorsEntitiesSectorList(CPtrList& list, bool dummy) pEntity->m_scanCode = CWorld::GetCurrentScanCode(); if (!pEntity || !CGarages::IsModelIndexADoor(pEntity->GetModelIndex())) continue; - if (!IsPointInsideGarage(pEntity->GetPosition(), 2.0f)) + if (Abs(pEntity->GetPosition().x - GetGarageCenterX()) >= 20.0f || + Abs(pEntity->GetPosition().y - GetGarageCenterY()) >= 20.0f) + continue; + if (pEntity->GetModelIndex() == MI_CRUSHERBODY) { + m_pDoor1 = pEntity; + m_bDoor1IsDummy = dummy; + if (dummy) + m_bDoor1PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F; + else + m_bDoor1PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F; + continue; + } + if (pEntity->GetModelIndex() == MI_CRUSHERLID) { + m_pDoor2 = pEntity; + m_bDoor2IsDummy = dummy; + if (dummy) + m_bDoor2PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F; + else + m_bDoor2PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F; continue; + } if (!m_pDoor1) { m_pDoor1 = pEntity; m_bDoor1IsDummy = dummy; @@ -2117,25 +2136,48 @@ bool CGarages::HasCarBeenCrushed(int32 handle) void CStoredCar::StoreCar(CVehicle* pVehicle) { m_nModelIndex = pVehicle->GetModelIndex(); - m_vecPos = pVehicle->GetPosition(); - m_vecAngle = pVehicle->GetForward(); + m_fPosX = pVehicle->GetPosition().x; + m_fPosY = pVehicle->GetPosition().y; + m_fPosY = pVehicle->GetPosition().z; + m_fForwardX = pVehicle->GetForward().x; + m_fForwardY = pVehicle->GetForward().y; + m_fForwardZ = pVehicle->GetForward().z; + m_fTractionMultiplier = 1.0f; m_nPrimaryColor = pVehicle->m_currentColour1; m_nSecondaryColor = pVehicle->m_currentColour2; m_nRadioStation = pVehicle->m_nRadioStation; m_nVariationA = pVehicle->m_aExtras[0]; m_nVariationB = pVehicle->m_aExtras[1]; - m_bBulletproof = pVehicle->bBulletProof; - m_bFireproof = pVehicle->bFireProof; - m_bExplosionproof = pVehicle->bExplosionProof; - m_bCollisionproof = pVehicle->bCollisionProof; - m_bMeleeproof = pVehicle->bMeleeProof; - if (pVehicle->IsCar() || pVehicle->IsBike()) - m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType; // NB: cast to CAutomobile is original behaviour + m_nFlags = 0; + if (pVehicle->bRewardVehicle) m_nFlags |= FLAG_REWARD_VEHICLE; + if (pVehicle->bBulletProof) m_nFlags |= FLAG_BULLETPROOF; + if (pVehicle->bFireProof) m_nFlags |= FLAG_FIREPROOF; + if (pVehicle->bExplosionProof) m_nFlags |= FLAG_EXPLOSIONPROOF; + if (pVehicle->bCollisionProof) m_nFlags |= FLAG_COLLISIONPROOF; + if (pVehicle->bMeleeProof) m_nFlags |= FLAG_MELEEPROOF; + if (pVehicle->bTyresDontBurst) m_nFlags |= FLAG_TIRES_INVULNERABLE; + if (pVehicle->bTakeLessDamage) m_nFlags |= FLAG_STRONG; + if (pVehicle->bIsHeavy) m_nFlags |= FLAG_HEAVY; + if (pVehicle->IsCar()) { + CAutomobile* pAutomobile = (CAutomobile*)pVehicle; + if (pAutomobile->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR; + if (pAutomobile->m_bombType) m_nFlags |= FLAG_BOMB; + if (pAutomobile->bNotDamagedUpsideDown) m_nFlags |= FLAG_NOT_DAMAGED_UPSIDEDOWN; + m_fTractionMultiplier = pAutomobile->m_fTraction; + } + else if (pVehicle->IsBike()) { + CBike* pBike = (CBike*)pVehicle; + if (pBike->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR; + m_fTractionMultiplier = pBike->m_fTraction; + } } CVehicle* CStoredCar::RestoreCar() { CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY); + uint8 owner = RANDOM_VEHICLE; + if (m_nFlags & FLAG_REWARD_VEHICLE) + owner = MISSION_VEHICLE; if (!CStreaming::HasModelLoaded(m_nModelIndex)) return nil; #ifdef FIX_BUGS @@ -2148,19 +2190,19 @@ CVehicle* CStoredCar::RestoreCar() } CVehicle* pVehicle; if (CModelInfo::IsBoatModel(m_nModelIndex)) - pVehicle = new CBoat(m_nModelIndex, RANDOM_VEHICLE); + pVehicle = new CBoat(m_nModelIndex, owner); else if (CModelInfo::IsBikeModel(m_nModelIndex)) { - CBike* pBike = new CBike(m_nModelIndex, RANDOM_VEHICLE); + CBike* pBike = new CBike(m_nModelIndex, owner); pBike->bIsStanding = true; pVehicle = pBike; } else - pVehicle = new CAutomobile(m_nModelIndex, RANDOM_VEHICLE); - pVehicle->SetPosition(m_vecPos); + pVehicle = new CAutomobile(m_nModelIndex, owner); + pVehicle->SetPosition(m_fPosX, m_fPosY, m_fPosZ); pVehicle->SetStatus(STATUS_ABANDONED); - pVehicle->GetForward() = m_vecAngle; - pVehicle->GetRight() = CVector(m_vecAngle.y, -m_vecAngle.x, 0.0f); + pVehicle->GetForward() = CVector(m_fForwardX, m_fForwardY, m_fForwardZ); + pVehicle->GetRight() = CVector(m_fForwardY, -m_fForwardX, 0.0f); pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f); pVehicle->pDriver = nil; pVehicle->m_currentColour1 = m_nPrimaryColor; @@ -2177,11 +2219,36 @@ CVehicle* CStoredCar::RestoreCar() } pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; - pVehicle->bBulletProof = m_bBulletproof; - pVehicle->bFireProof = m_bFireproof; - pVehicle->bExplosionProof = m_bExplosionproof; - pVehicle->bCollisionProof = m_bCollisionproof; - pVehicle->bMeleeProof = m_bMeleeproof; + if (m_nFlags & FLAG_REWARD_VEHICLE) pVehicle->bRewardVehicle = true; + if (m_nFlags & FLAG_BULLETPROOF) pVehicle->bBulletProof = true; + if (m_nFlags & FLAG_FIREPROOF) pVehicle->bFireProof = true; + if (m_nFlags & FLAG_EXPLOSIONPROOF) pVehicle->bExplosionProof = true; + if (m_nFlags & FLAG_COLLISIONPROOF) pVehicle->bCollisionProof = true; + if (m_nFlags & FLAG_MELEEPROOF) pVehicle->bMeleeProof = true; + if (m_nFlags & FLAG_TIRES_INVULNERABLE) pVehicle->bTyresDontBurst = true; + if (m_nFlags & FLAG_STRONG) pVehicle->bTakeLessDamage = true; + if (m_nFlags & FLAG_HEAVY) { + pVehicle->bIsHeavy = true; + pVehicle->m_fMass = pVehicle->pHandling->GetMass(); + pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass(); + } + else { + pVehicle->bIsHeavy = false; + pVehicle->m_fMass = pVehicle->pHandling->GetMass() * 3.0f; + pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass() * 5.0f; + } + if (pVehicle->IsCar()) { + CAutomobile* pAutomobile = (CAutomobile*)pVehicle; + if (m_nFlags & FLAG_PERMANENT_COLOUR) pAutomobile->bFixedColour = true; + if (m_nFlags & FLAG_BOMB) pAutomobile->m_bombType = CARBOMB_TIMED; + if (m_nFlags & FLAG_NOT_DAMAGED_UPSIDEDOWN) pAutomobile->bNotDamagedUpsideDown = true; + m_fTractionMultiplier = pAutomobile->m_fTraction; + } + else if (pVehicle->IsBike()) { + CBike* pBike = (CBike*)pVehicle; + if (m_nFlags & FLAG_PERMANENT_COLOUR) pBike->bFixedColour = true; + m_fTractionMultiplier = pBike->m_fTraction; + } return pVehicle; } @@ -2196,13 +2263,23 @@ void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar* aCars, int32 nMax) if (!pVehicle) continue; if (IsPointInsideGarage(pVehicle->GetPosition())) { - if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE) { - if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f)) - aCars[index++].StoreCar(pVehicle); +#if defined GTA_PS2 || defined GTA_MOBILE + if (pVehicle->GetStatus() == STATUS_WRECKED) { CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle); CWorld::Remove(pVehicle); delete pVehicle; } + else if (pVehicle->m_bombType == CARBOMB_NONE || pVehicle->bRewardVehicle) // <- probably condition looked different +#endif + { + if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE || pVehicle->bRewardVehicle) { + if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f)) + aCars[index++].StoreCar(pVehicle); + CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle); + CWorld::Remove(pVehicle); + delete pVehicle; + } + } } } // why? @@ -2507,6 +2584,8 @@ void CGarages::SetAllDoorsBackToOriginalHeight() default: aGarages[i].RefreshDoorPointers(true); if (aGarages[i].m_pDoor1) { + aGarages[i].m_pDoor1->GetMatrix().GetPosition().x = aGarages[i].m_fDoor1X; + aGarages[i].m_pDoor1->GetMatrix().GetPosition().y = aGarages[i].m_fDoor1Y; aGarages[i].m_pDoor1->GetMatrix().GetPosition().z = aGarages[i].m_fDoor1Z; if (aGarages[i].m_pDoor1->IsObject()) ((CObject*)aGarages[i].m_pDoor1)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor1Z; @@ -2516,6 +2595,8 @@ void CGarages::SetAllDoorsBackToOriginalHeight() aGarages[i].m_pDoor1->UpdateRwFrame(); } if (aGarages[i].m_pDoor2) { + aGarages[i].m_pDoor2->GetMatrix().GetPosition().x = aGarages[i].m_fDoor2X; + aGarages[i].m_pDoor2->GetMatrix().GetPosition().y = aGarages[i].m_fDoor2Y; aGarages[i].m_pDoor2->GetMatrix().GetPosition().z = aGarages[i].m_fDoor2Z; if (aGarages[i].m_pDoor2->IsObject()) ((CObject*)aGarages[i].m_pDoor2)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor2Z; @@ -2531,7 +2612,7 @@ void CGarages::SetAllDoorsBackToOriginalHeight() void CGarages::Save(uint8 * buf, uint32 * size) { //INITSAVEBUF - *size = 7876; // for some reason it's not actual size again + *size = 10692; // for some reason it's not actual size again //*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)); CloseHideOutGaragesBeforeSave(); WriteSaveBuf(buf, NumGarages); @@ -2553,29 +2634,10 @@ void CGarages::Save(uint8 * buf, uint32 * size) //VALIDATESAVEBUF(*size); } -const CStoredCar &CStoredCar::operator=(const CStoredCar & other) -{ - m_nModelIndex = other.m_nModelIndex; - m_vecPos = other.m_vecPos; - m_vecAngle = other.m_vecAngle; - m_bBulletproof = other.m_bBulletproof; - m_bFireproof = other.m_bFireproof; - m_bExplosionproof = other.m_bExplosionproof; - m_bCollisionproof = other.m_bCollisionproof; - m_bMeleeproof = other.m_bMeleeproof; - m_nPrimaryColor = other.m_nPrimaryColor; - m_nSecondaryColor = other.m_nSecondaryColor; - m_nRadioStation = other.m_nRadioStation; - m_nVariationA = other.m_nVariationA; - m_nVariationB = other.m_nVariationB; - m_nCarBombType = other.m_nCarBombType; - return *this; -} - void CGarages::Load(uint8* buf, uint32 size) { //INITSAVEBUF - assert(size = 7876); + assert(size == 10692); //assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage))); CloseHideOutGaragesBeforeSave(); NumGarages = ReadSaveBuf(buf); diff --git a/src/control/Garages.h b/src/control/Garages.h index 5235275e..eb2c3e18 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -6,8 +6,6 @@ class CVehicle; -#define GTA_NETWORK - enum eGarageState { GS_FULLYCLOSED, @@ -61,19 +59,34 @@ enum { TOTAL_COLLECTCARS_GARAGES = 4, TOTAL_HIDEOUT_GARAGES = 12, - TOTAL_COLLECTCARS_CARS = 6 + TOTAL_COLLECTCARS_CARS = 16 }; class CStoredCar { + enum { + FLAG_BULLETPROOF = 0x1, + FLAG_FIREPROOF = 0x2, + FLAG_EXPLOSIONPROOF = 0x4, + FLAG_COLLISIONPROOF = 0x8, + FLAG_MELEEPROOF = 0x10, + FLAG_TIRES_INVULNERABLE = 0x20, + FLAG_STRONG = 0x40, + FLAG_HEAVY = 0x80, + FLAG_PERMANENT_COLOUR = 0x100, + FLAG_BOMB = 0x200, + FLAG_NOT_DAMAGED_UPSIDEDOWN = 0x400, + FLAG_REWARD_VEHICLE = 0x8000 + }; int32 m_nModelIndex; - CVector m_vecPos; - CVector m_vecAngle; - int32 m_bBulletproof : 1; - int32 m_bFireproof : 1; - int32 m_bExplosionproof : 1; - int32 m_bCollisionproof : 1; - int32 m_bMeleeproof : 1; + float m_fPosX; + float m_fPosY; + float m_fPosZ; + float m_fForwardX; + float m_fForwardY; + float m_fForwardZ; + float m_fTractionMultiplier; + int32 m_nFlags; int8 m_nPrimaryColor; int8 m_nSecondaryColor; int8 m_nRadioStation; @@ -84,7 +97,6 @@ public: void Init() { m_nModelIndex = 0; } void Clear() { m_nModelIndex = 0; } bool HasCar() { return m_nModelIndex != 0; } - const CStoredCar &operator=(const CStoredCar& other); void StoreCar(CVehicle*); CVehicle* RestoreCar(); }; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index d12bbb40..8ce2d84d 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1808,7 +1808,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_IS_REWARD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), }; #undef REGISTER_COMMAND diff --git a/src/control/Script10.cpp b/src/control/Script10.cpp index 46013887..ac3961a7 100644 --- a/src/control/Script10.cpp +++ b/src/control/Script10.cpp @@ -392,12 +392,12 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) CHud::SetHelpMessage(text, false, true); // + false return 0; } - case COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE: + case COMMAND_SET_CAR_IS_REWARD: { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bAllowGarageToStore = (GET_INTEGER_PARAM(1) != 0); + pVehicle->bRewardVehicle = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS: diff --git a/src/control/ScriptCommands.h b/src/control/ScriptCommands.h index 76bc4aa3..000f561c 100644 --- a/src/control/ScriptCommands.h +++ b/src/control/ScriptCommands.h @@ -1656,7 +1656,7 @@ enum { COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, - COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE, + COMMAND_SET_CAR_IS_REWARD, COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT LAST_SCRIPT_COMMAND diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index cbc4ede8..3a6b8252 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -647,7 +647,7 @@ extern CModelIndices *gpModelIndices; X("ind_slidedoor", MI_GARAGEDOOR6) \ X("bankjobdoor", MI_GARAGEDOOR7) \ X("door_jmsgrage", MI_GARAGEDOOR9) \ - X("jamesgrge_kb", MI_GARAGEDOOR10) \ + X("ind_safeh_gdoor", MI_GARAGEDOOR10) \ X("door_sfehousegrge", MI_GARAGEDOOR11) \ X("shedgaragedoor", MI_GARAGEDOOR12) \ X("door4_garage", MI_GARAGEDOOR13) \ diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index cd16171b..450f1c3b 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -240,12 +240,11 @@ public: uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed uint8 bParking : 1; uint8 bCanPark : 1; -#if (!defined GTA_PS2 || defined FIX_BUGS) +#if (!defined GTA_PS2 || defined FIX_BUGS) // <- I think this can be moved back to CAutomobile? uint8 m_bombType : 3; #endif uint8 bDriverLastFrame : 1; - - uint8 bAllowGarageToStore : 1; // <- many LCS flags before + uint8 bRewardVehicle : 1; // 25B_40 int8 m_numPedsUseItAsCover; uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default) -- cgit v1.2.3 From 48926fcadeaf4a7ea0c893988955dd1e850e3db8 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 31 Jan 2021 23:34:19 +0300 Subject: multiplayer stuff --- src/control/Garages.cpp | 142 ++++++++++++++++++++++++++++++++++++++++++------ src/control/Garages.h | 32 ++++++----- src/control/Script7.cpp | 3 +- 3 files changed, 144 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index d3e0295a..a3e91f85 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -247,8 +247,8 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_bDeactivated = false; pGarage->m_bResprayHappened = false; pGarage->m_bInitialized = false; - pGarage->field_F0 = 0; - pGarage->field_FC = 0; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_bSSGarageStateChanging = false; pGarage->m_bInitialized = InitDoorGubbins(NumGarages, type); return NumGarages++; } @@ -1509,6 +1509,10 @@ bool CGarage::IsEntityEntirelyOutside(CEntity * pEntity, float fMargin) return true; } +#ifdef GTA_NETWORK +// some CGarage method (0x134E7C) +#endif + bool CGarage::IsGarageEmpty() { int16 num; @@ -1903,7 +1907,8 @@ int32 CGarages::QueryCarsCollected(int16 garage) bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car) { - return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (BIT(car)); + uint32 total; + return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType, total)] & (BIT(car)); } bool CGarages::IsGarageOpen(int16 garage) @@ -1923,10 +1928,9 @@ bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) bool CGarage::DoesCraigNeedThisCar(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); - if (ct != 0) - return false; - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); + for (int i = 0; i < total; i++) { if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0; } @@ -1935,10 +1939,9 @@ bool CGarage::DoesCraigNeedThisCar(int32 mi) bool CGarage::HasCraigCollectedThisCar(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); - if (ct != 0) - return 0; - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); + for (int i = 0; i < total; i++) { if (mi == gaCarsToCollectInCraigsGarages[ct][i]) return CGarages::CarTypesCollected[ct] & BIT(i); } @@ -1947,18 +1950,17 @@ bool CGarage::HasCraigCollectedThisCar(int32 mi) bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); - if (ct != 0) - return 0; + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); int index; - for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) { + for (index = 0; index < total; index++) { if (mi == gaCarsToCollectInCraigsGarages[ct][index]) break; } - if (index >= TOTAL_COLLECTCARS_CARS) + if (index >= total) return false; CGarages::CarTypesCollected[ct] |= BIT(index); - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { + for (int i = 0; i < total; i++) { if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) { return false; } @@ -2756,3 +2758,109 @@ bool CGarage::IsPlayerEntirelyInsideGarage() { return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f); } + +int16 CGarages::AddCrateGarage(CVector pos, float angle) +{ + CMatrix matrix; + matrix.SetUnity(); + matrix.SetRotateZOnly(DEGTORAD(angle)); + CStreaming::RequestModel(MI_CRATE_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pCrate = new CObject(MI_CRATE_SJL, false); + pCrate->ObjectCreatedBy = MISSION_OBJECT; + pCrate->SetPosition(pos); + pCrate->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pCrate->GetMatrix().UpdateRW(); + pCrate->UpdateRwFrame(); + pCrate->bAffectedByGravity = false; + pCrate->m_phy_flagA08 = true; + pCrate->bExplosionProof = true; + pCrate->bIsStatic = false; + + CStreaming::RequestModel(MI_DOOR1_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pDoor1 = new CObject(MI_DOOR1_SJL, false); + pDoor1->ObjectCreatedBy = MISSION_OBJECT; + CVector vDoor1Pos = matrix * CVector(0.0f, 5.64f, 5.168f); + pDoor1->SetPosition(vDoor1Pos); + pDoor1->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pDoor1->GetMatrix().UpdateRW(); + pDoor1->UpdateRwFrame(); + pDoor1->bAffectedByGravity = false; + pDoor1->m_phy_flagA08 = true; + pDoor1->bExplosionProof = true; + pDoor1->bIsStatic = false; + + CStreaming::RequestModel(MI_DOOR2_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pDoor2 = new CObject(MI_DOOR2_SJL, false); + pDoor2->ObjectCreatedBy = MISSION_OBJECT; + CVector vDoor2Pos = matrix * CVector(0.0f, -5.64f, 5.168f); + pDoor2->SetPosition(vDoor2Pos); + pDoor2->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pDoor2->GetMatrix().UpdateRW(); + pDoor2->UpdateRwFrame(); + pDoor2->bAffectedByGravity = false; + pDoor2->m_phy_flagA08 = true; + pDoor2->bExplosionProof = true; + pDoor2->bIsStatic = false; + + CWorld::Add(pCrate); + CWorld::Add(pDoor1); + CWorld::Add(pDoor2); + + CVector corner = matrix * CVector(-3.0f, -3.5f, -0.5f) + pos; + CVector xplane = matrix * CVector(0.0f, 2.0f, 0.0f) + pos; + CVector yplane = matrix * CVector(0.0f, 0.0f, 0.0f) + pos; + + printf("Posttrans Corner[%f][%f][%f] XPlane[%f][%f][%f] YPlane[%f][%f][%f]", + corner.x, corner.y, corner.z, xplane.x, xplane.y, xplane.z, yplane.x, yplane.y, yplane.z); + int16 index = AddOne(corner.x, corner.y, corner.z, xplane.x, xplane.y, yplane.x, yplane.y, pos.z + 4.0f, GARAGE_CRATE_GARAGE, 0); + SetLeaveCameraForThisGarage(index); + CGarage* pGarage = &aGarages[index]; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_bSSGarageStateChanging = false; + pGarage->m_vecSSGaragePos = pos; + pGarage->m_fSSGarageAngle = angle; + return index; +} + +#ifdef GTA_NETWORK +void CGarages::RemoveAllCrateGarages() +{ + for (uint32 i = 0; i < NUM_GARAGES; i++) { + CGarage* pGarage = &aGarages[i]; + if (pGarage->m_eGarageType == GARAGE_CRATE_GARAGE) { + pGarage->m_eGarageType = GARAGE_NONE; + pGarage->m_bSSGarageStateChanging = false; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_pSSVehicle = nil; + --NumGarages; + } + } +} + +bool CGarages::HasSSGarageAcceptedVehicle(int16 garage) +{ + return aGarages[garage].m_bSSGarageAcceptedVehicle; +} + +void CGarages::SetVehicleForSSGarage(bool state, int16 garage, void* pVehicle) +{ + CGarage* pGarage = &aGarages[garage]; + pGarage->m_pSSVehicle = pVehicle; + pGarage->m_nSSGarageState = state; + pGarage->m_bSSGarageAcceptedVehicle = false; + if (!pVehicle) { + if (pGarage->m_pSSTargetCar) + pGarage->m_pSSTargetCar->CleanUpOldReference((CEntity**)pGarage->m_pSSTargetCar); + pGarage->m_pSSTargetCar = nil; + } +} +#endif diff --git a/src/control/Garages.h b/src/control/Garages.h index eb2c3e18..2ab74606 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -130,6 +130,8 @@ public: CVector2D m_vDir1; CVector2D m_vDir2; float m_fSupZ; + CVector m_vecSSGaragePos; + float m_fSSGarageAngle; float m_fDir1Len; float m_fDir2Len; float m_fInfX; @@ -150,19 +152,14 @@ public: uint8 m_bCollectedCarsState; CVehicle *m_pTarget; CStoredCar m_sStoredCar; // not needed -#ifdef GTA_NETWORK - void* m_pSSVehicle; // some multiplayer vehicle structure, +104 == GetVehiclePointer - bool m_bSSGarageAcceptedVehicle; -#endif bool m_bInitialized; #ifdef GTA_NETWORK - uint8 m_nSSGarageState; - bool m_bSSGarageStateChanging; + void* m_pSSVehicle; // some multiplayer vehicle structure, +104 == GetVehiclePointer #endif - uint32 field_F0; + bool m_bSSGarageAcceptedVehicle; bool m_bLocked; - uint32 field_F8; - uint32 field_FC; + bool m_nSSGarageState; + bool m_bSSGarageStateChanging; void OpenThisGarage(); void CloseThisGarage(); @@ -297,13 +294,13 @@ public: static void CloseHideOutGaragesBeforeSave(void); static int32 CountCarsInHideoutGarage(uint8); static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; } - static int32 GetCarsCollectedIndexForGarageType(uint8 type) + static int32 GetCarsCollectedIndexForGarageType(uint8 type, uint32& total) { switch (type) { - case GARAGE_COLLECTCARS_1: return 0; - case GARAGE_COLLECTCARS_2: return 1; - case GARAGE_COLLECTCARS_3: return 2; - case GARAGE_COLLECTCARS_4: return 3; + case GARAGE_COLLECTCARS_1: total = TOTAL_COLLECTCARS_CARS; return 0; + case GARAGE_COLLECTCARS_2: total = 0; return 1; + case GARAGE_COLLECTCARS_3: total = 0; return 2; + case GARAGE_COLLECTCARS_4: total = 0; return 3; default: assert(0); } return 0; @@ -331,5 +328,12 @@ public: static bool InitDoorGubbins(uint32, uint8); static void SetupAnyGaragesForThisIsland(void); static void LockGarage(int16, bool); + static int16 AddCrateGarage(CVector, float); + +#ifdef GTA_NETWORK + static void RemoveAllCrateGarages(); + static bool HasSSGarageAcceptedVehicle(int16 garage); + static void SetVehicleForSSGarage(bool state, int16 garage, void* pVehicle); // void* -> ? +#endif }; diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index c50f0dea..6dd6e281 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -438,8 +438,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); - script_assert(pObject); - UpdateCompareFlag(pObject->bIsInWater); + UpdateCompareFlag(pObject && pObject->bIsInWater); return 0; } //case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR_EVEN_MISSION_CAR: -- cgit v1.2.3 From 3584dac5c00db5ded4405b08ddf2a79c9d670423 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Wed, 3 Feb 2021 15:35:06 +0300 Subject: fix --- src/control/AutoPilot.cpp | 8 ++++---- src/control/AutoPilot.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index c956a6f1..d3de6ac2 100644 --- a/src/control/AutoPilot.cpp +++ b/src/control/AutoPilot.cpp @@ -52,8 +52,8 @@ void CAutoPilot::Save(uint8*& buf) WriteSaveBuf(buf, m_nCurrentRouteNode); WriteSaveBuf(buf, m_nNextRouteNode); WriteSaveBuf(buf, m_nPrevRouteNode); - WriteSaveBuf(buf, m_nTimeEnteredCurve); - WriteSaveBuf(buf, m_nTimeToSpendOnCurrentCurve); + WriteSaveBuf(buf, m_nTimeEnteredCurve); + WriteSaveBuf(buf, m_nTimeToSpendOnCurrentCurve); WriteSaveBuf(buf, m_nCurrentPathNodeInfo); WriteSaveBuf(buf, m_nNextPathNodeInfo); WriteSaveBuf(buf, m_nPreviousPathNodeInfo); @@ -95,8 +95,8 @@ void CAutoPilot::Load(uint8*& buf) m_nCurrentRouteNode = ReadSaveBuf(buf); m_nNextRouteNode = ReadSaveBuf(buf); m_nPrevRouteNode = ReadSaveBuf(buf); - m_nTimeEnteredCurve = ReadSaveBuf(buf); - m_nTimeToSpendOnCurrentCurve = ReadSaveBuf(buf); + m_nTimeEnteredCurve = ReadSaveBuf(buf); + m_nTimeToSpendOnCurrentCurve = ReadSaveBuf(buf); m_nCurrentPathNodeInfo = ReadSaveBuf(buf); m_nNextPathNodeInfo = ReadSaveBuf(buf); m_nPreviousPathNodeInfo = ReadSaveBuf(buf); diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h index aa14ccdd..ec3bb8d8 100644 --- a/src/control/AutoPilot.h +++ b/src/control/AutoPilot.h @@ -64,8 +64,8 @@ public: int32 m_nCurrentRouteNode; int32 m_nNextRouteNode; int32 m_nPrevRouteNode; - uint32 m_nTimeEnteredCurve; - uint32 m_nTimeToSpendOnCurrentCurve; + int32 m_nTimeEnteredCurve; + int32 m_nTimeToSpendOnCurrentCurve; uint32 m_nCurrentPathNodeInfo; uint32 m_nNextPathNodeInfo; uint32 m_nPreviousPathNodeInfo; -- cgit v1.2.3