diff options
Diffstat (limited to 'src')
222 files changed, 4616 insertions, 2002 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad72eb56..f3d51b06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,6 +79,21 @@ endif() target_compile_definitions(${EXECUTABLE} PRIVATE ) +option(${PROJECT}_WITH_SANITIZERS "Use UB sanitizers (better crash log)" OFF) +option(${PROJECT}_WITH_ASAN "Use Address sanitizer (better crash log)" OFF) + +if(${PROJECT}_WITH_SANITIZERS) + target_compile_options(${EXECUTABLE} PUBLIC + -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability + -g3 -fno-omit-frame-pointer) + target_link_options(${EXECUTABLE} PUBLIC -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability) +endif() + +if(${PROJECT}_WITH_ASAN) + target_compile_options(${EXECUTABLE} PUBLIC -fsanitize=address -g3 -fno-omit-frame-pointer) + target_link_options(${EXECUTABLE} PUBLIC -fsanitize=address) +endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") target_compile_options(${EXECUTABLE} PRIVATE diff --git a/src/animation/AnimBlendAssocGroup.cpp b/src/animation/AnimBlendAssocGroup.cpp index ea6dea3e..7c0a10d4 100644 --- a/src/animation/AnimBlendAssocGroup.cpp +++ b/src/animation/AnimBlendAssocGroup.cpp @@ -1,7 +1,11 @@ #include "common.h" #if defined _WIN32 && !defined __MINGW32__ +#if defined __MWERKS__ +#include <wctype.h> +#else #include "ctype.h" +#endif #else #include <cwctype> #endif @@ -16,8 +20,6 @@ #include "AnimBlendAssocGroup.h" #include "KeyGen.h" -//--MIAMI: file done - CAnimBlendAssocGroup::CAnimBlendAssocGroup(void) { animBlock = nil; @@ -91,18 +93,18 @@ strcmpIgnoringDigits(const char *s1, const char *s2) if(c1) s1++; if(c2) s2++; if(c1 == '\0' && c2 == '\0') return true; -#if defined _WIN32 && !defined __MINGW32__ - if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2)) -#else +#ifndef ASCII_STRCMP if(iswdigit(c1) && iswdigit(c2)) +#else + if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2)) #endif continue; -#if defined _WIN32 && !defined __MINGW32__ - c1 = __ascii_toupper(c1); - c2 = __ascii_toupper(c2); -#else +#ifndef ASCII_STRCMP c1 = toupper(c1); c2 = toupper(c2); +#else + c1 = __ascii_toupper(c1); + c2 = __ascii_toupper(c2); #endif if(c1 && c2 && c1 != c2) diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp index b91b35ee..bb4e7bf4 100644 --- a/src/animation/AnimBlendAssociation.cpp +++ b/src/animation/AnimBlendAssociation.cpp @@ -7,8 +7,6 @@ #include "AnimBlendAssociation.h" #include "MemoryMgr.h" -//--MIAMI: file done - CAnimBlendAssociation::CAnimBlendAssociation(void) { groupId = -1; diff --git a/src/animation/AnimBlendClumpData.cpp b/src/animation/AnimBlendClumpData.cpp index 620c2229..b333a449 100644 --- a/src/animation/AnimBlendClumpData.cpp +++ b/src/animation/AnimBlendClumpData.cpp @@ -3,8 +3,6 @@ #include "AnimBlendClumpData.h" #include "MemoryMgr.h" -//--MIAMI: file done - CAnimBlendClumpData::CAnimBlendClumpData(void) { numFrames = 0; diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp index cc7c7de8..bfa39ef9 100644 --- a/src/animation/AnimBlendHierarchy.cpp +++ b/src/animation/AnimBlendHierarchy.cpp @@ -4,8 +4,6 @@ #include "AnimBlendHierarchy.h" #include "AnimManager.h" -//--MIAMI: file done - CAnimBlendHierarchy::CAnimBlendHierarchy(void) { sequences = nil; diff --git a/src/animation/AnimBlendNode.cpp b/src/animation/AnimBlendNode.cpp index d2a8dd41..6352c11b 100644 --- a/src/animation/AnimBlendNode.cpp +++ b/src/animation/AnimBlendNode.cpp @@ -3,8 +3,6 @@ #include "AnimBlendAssociation.h" #include "AnimBlendNode.h" -//--MIAMI: file done - void CAnimBlendNode::Init(void) { diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp index 93cce91d..36ac9495 100644 --- a/src/animation/AnimBlendSequence.cpp +++ b/src/animation/AnimBlendSequence.cpp @@ -3,8 +3,6 @@ #include "AnimBlendSequence.h" #include "MemoryHeap.h" -//--MIAMI: file done - CAnimBlendSequence::CAnimBlendSequence(void) { type = 0; diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index d0c8b4cb..34a0673b 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -12,8 +12,6 @@ #include "AnimManager.h" #include "Streaming.h" -//--MIAMI: file done - CAnimBlock CAnimManager::ms_aAnimBlocks[NUMANIMBLOCKS]; CAnimBlendHierarchy CAnimManager::ms_aAnimations[NUMANIMATIONS]; int32 CAnimManager::ms_numAnimBlocks; @@ -1477,7 +1475,6 @@ CAnimManager::LoadAnimFile(const char *filename) RwStreamClose(stream, nil); } -//--MIAMI: done void CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedAnims)[32]) { diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp index bbbd9aa3..088cb413 100644 --- a/src/animation/CutsceneMgr.cpp +++ b/src/animation/CutsceneMgr.cpp @@ -24,8 +24,6 @@ #include "Pools.h" #include "crossplatform.h" -//--MIAMI: file done - static bool bModelsRemovedForCutscene; static int32 NumberOfSavedWeapons; static eWeaponType SavedWeaponIDs[TOTAL_WEAPON_SLOTS]; diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp index e35bd4c8..d3094bb0 100644 --- a/src/animation/FrameUpdate.cpp +++ b/src/animation/FrameUpdate.cpp @@ -6,8 +6,6 @@ #include "AnimBlendAssociation.h" #include "RpAnimBlend.h" -//--MIAMI: file done - CAnimBlendClumpData *gpAnimBlendClump; // PS2 names without "NonSkinned" diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp index 9223d198..9a11d8bb 100644 --- a/src/animation/RpAnimBlend.cpp +++ b/src/animation/RpAnimBlend.cpp @@ -12,8 +12,6 @@ #include "RpAnimBlend.h" #include "PedModelInfo.h" -//--MIAMI: file done - RwInt32 ClumpOffset; enum diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 1f32890c..457e09c0 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "AudioManager.h" #include "audio_enums.h" @@ -41,9 +41,9 @@ #include "WindModifiers.h" #include "Fluff.h" #include "Script.h" +#include "Wanted.h" - -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; @@ -305,11 +305,11 @@ cAudioManager::ProcessPlayerMood() playerPed = FindPlayerPed(); if (playerPed != nil) { - if (playerPed->m_pWanted->m_nWantedLevel > 3) { + if (playerPed->m_pWanted->GetWantedLevel() > 3) { m_nPlayerMood = PLAYER_MOOD_ANGRY; return; } - if (playerPed->m_pWanted->m_nWantedLevel > 1) { + if (playerPed->m_pWanted->GetWantedLevel() > 1) { m_nPlayerMood = PLAYER_MOOD_PISSED_OFF; return; } @@ -5684,7 +5684,7 @@ cAudioManager::GetCopTalkSfx(CPed *ped, int16 sound) case SOUND_PED_ATTACK: GetPhrase(sfx, ped->m_lastComment, 8494, 4); break; case SOUND_PED_EVADE: GetPhrase(sfx, ped->m_lastComment, 8491, 3); break; case SOUND_PED_PED_COLLISION: - if(FindPlayerPed()->m_pWanted->m_nWantedLevel <= 0) return NO_SAMPLE; + if(FindPlayerPed()->m_pWanted->GetWantedLevel() <= 0) return NO_SAMPLE; GetPhrase(sfx, ped->m_lastComment, 8476, 5); break; default: return GetGenericMaleTalkSfx(ped, sound); @@ -8115,7 +8115,7 @@ cAudioManager::ProcessWaterCannon(int32) } //positon of arcade machines -CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.794f, 11.324f}, {-1004.476f, 181.697f, 11.324f} }; +CVector aVecExtraSoundPosition[] = { CVector(-1042.546f, 88.794f, 11.324f), CVector(-1004.476f, 181.697f, 11.324f) }; void cAudioManager::ProcessExtraSounds() @@ -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.cpp b/src/audio/AudioManager.cpp index 721a7acc..2304b4c4 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -14,7 +14,7 @@ cAudioManager AudioManager; -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index b5e9b499..2eb2220b 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "audio_enums.h" #include "AudioCollision.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/AudioSamples.h b/src/audio/AudioSamples.h index 159809d0..403ef684 100644 --- a/src/audio/AudioSamples.h +++ b/src/audio/AudioSamples.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "common.h" diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 2a16dc14..0a28421d 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -1237,11 +1237,12 @@ cMusicManager::DisplayRadioStationName() case RADIO_ESPANTOSO: string = TheText.Get("FEA_FM6"); break; case EMOTION: string = TheText.Get("FEA_FM7"); break; case WAVE: string = TheText.Get("FEA_FM8"); break; - case USERTRACK: + case 9: string = TheText.Get("FEA_FM9"); break; + case 10: if (!SampleManager.IsMP3RadioChannelAvailable()) return; string = TheText.Get("FEA_MP3"); break; - default: return; + default: string = TheText.Get("FEA_NON"); break; }; if (pCurrentStation != string) { @@ -1255,21 +1256,22 @@ cMusicManager::DisplayRadioStationName() CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetDropShadowPosition(2); + CFont::SetScale(PSP_SCREEN_SCALE_X(0.5f), PSP_SCREEN_SCALE_Y(0.88f)); CFont::SetPropOn(); - CFont::SetFontStyle(FONT_STANDARD); + CFont::SetFontStyle(FONT_BANK); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation); + CFont::SetCentreSize(PSP_SCREEN_SCALE_X(260.0f)); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); if (gNumRetunePresses) - CFont::SetColor(CRGBA(102, 133, 143, 255)); + CFont::SetColor(CRGBA(77, 155, 210, 255)); else - CFont::SetColor(CRGBA(147, 196, 211, 255)); + CFont::SetColor(CRGBA(77, 155, 210, 255)); - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_Y(22.0f), pCurrentStation); + CFont::PrintString(SCREEN_WIDTH / 2, PSP_SCREEN_SCALE_Y(7.0f), pCurrentStation); CFont::DrawFonts(); + CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); } } } diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 07dfb890..b8f44f60 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -13,8 +13,9 @@ #include "World.h" #include "Zones.h" #include "sampman.h" +#include "Wanted.h" -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; struct tPoliceRadioZone { @@ -136,7 +137,7 @@ cAudioManager::ServicePoliceRadio() #endif CPlayerPed *playerPed = FindPlayerPed(); if (playerPed) { - wantedLevel = playerPed->m_pWanted->m_nWantedLevel; + wantedLevel = playerPed->m_pWanted->GetWantedLevel(); if (!crimeReport) { if (wantedLevel != 0) { if (nLastSeen != 0) @@ -652,7 +653,7 @@ void cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) { int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); - if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && + if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { 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 78de4e6b..bf91a874 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,8 +1,7 @@ #include "common.h" #ifdef AUDIO_MSS -#include <windows.h> -#include <shobjidl.h> +#include <shlobj.h> #include <shlguid.h> #include <time.h> @@ -20,8 +19,6 @@ #pragma comment( lib, "mss32.lib" ) -// --MIAMI: file done - cSampleManager SampleManager; uint32 BankStartOffset[MAX_SFX_BANKS]; /////////////////////////////////////////////////////////////// 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 <time.h> #include "eax.h" #include "eax-util.h" -#define WITHWINDOWS -#include "common.h" -#include "crossplatform.h" - #ifdef _WIN32 #include <io.h> #include <AL/al.h> @@ -19,8 +13,24 @@ #include <AL/alext.h> #include <AL/efx.h> #include <AL/efx-presets.h> + +// for user MP3s +#include <direct.h> +#include <shlobj.h> +#include <shlguid.h> +#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 <direct.h> -#include <shobjidl.h> -#include <shlguid.h> -#else -#define _getcwd getcwd -#endif - cSampleManager SampleManager; bool _bSampmanInitialised = false; diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h index 98982f61..4d88590e 100644 --- a/src/audio/soundlist.h +++ b/src/audio/soundlist.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once enum eSound { diff --git a/src/collision/ColModel.cpp b/src/collision/ColModel.cpp index 49847dbd..2de7f736 100644 --- a/src/collision/ColModel.cpp +++ b/src/collision/ColModel.cpp @@ -7,6 +7,8 @@ CColModel::CColModel(void) { + boundingSphere.Set(0.0001f, CVector(0.0f, 0.0f, 0.0f)); + boundingBox.Set(CVector(0.0f, 0.0f, 0.0f), CVector(0.0f, 0.0f, 0.0f)); numSpheres = 0; spheres = nil; numLines = 0; @@ -18,7 +20,7 @@ CColModel::CColModel(void) triangles = nil; trianglePlanes = nil; level = LEVEL_GENERIC; // generic col slot - ownsCollisionVolumes = true; +// ownsCollisionVolumes = true; } CColModel::~CColModel(void) @@ -204,3 +206,10 @@ CColModel::operator=(const CColModel &other) } return *this; } + +bool +CColModel::Write(base::cRelocatableChunkWriter &writer, bool allocSpace) +{ + assert(0 && "TODO(LCS)"); + return 1; +} diff --git a/src/collision/ColModel.h b/src/collision/ColModel.h index cd5ae651..c58a4d9b 100644 --- a/src/collision/ColModel.h +++ b/src/collision/ColModel.h @@ -36,4 +36,6 @@ struct CColModel void *operator new(size_t); void operator delete(void *p, size_t); CColModel& operator=(const CColModel& other); + + bool Write(base::cRelocatableChunkWriter &writer, bool allocSpace); };
\ No newline at end of file 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<ColDef,ColDef> *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<ColDef,ColDef>(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<ColDef> *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<ColDef,ColDef> *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<ColDef> *pool); static ColDef *GetSlot(int slot) { assert(slot >= 0); diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp index 703804d9..bead5183 100644 --- a/src/collision/Collision.cpp +++ b/src/collision/Collision.cpp @@ -24,8 +24,6 @@ #include "Camera.h" #include "ColStore.h" -//--MIAMI: file done - #ifdef VU_COLLISION #include "VuCollision.h" @@ -93,7 +91,7 @@ CCollision::Update(void) { } -//--MIAMI: unused +// unused eLevelName GetCollisionInSectorList(CPtrList &list) { @@ -110,7 +108,7 @@ GetCollisionInSectorList(CPtrList &list) return LEVEL_GENERIC; } -//--MIAMI: unused +// unused // Get a level this sector is in based on collision models eLevelName GetCollisionInSector(CSector §) @@ -880,7 +878,7 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC return true; } -//--MIAMI: unused +// unused bool CCollision::ProcessVerticalLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, @@ -2101,12 +2099,12 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin float dot = DotProduct(*point - *l0, *l1 - *l0); // Between 0 and len we're above the line. // if not, calculate distance to endpoint - if(dot <= 0.0f) - return (*point - *l0).Magnitude(); - if(dot >= lensq) - return (*point - *l1).Magnitude(); + if(dot <= 0.0f) return (*point - *l0).Magnitude(); + if(dot >= lensq) return (*point - *l1).Magnitude(); // distance to line - return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq); + float distSqr = (*point - *l0).MagnitudeSqr() - dot * dot / lensq; + if(distSqr <= 0.f) return 0.f; + return Sqrt(distSqr); } // same as above but also return the point on the line @@ -2573,4 +2571,4 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel, RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); -}
\ No newline at end of file +} diff --git a/src/collision/TempColModels.cpp b/src/collision/TempColModels.cpp index 55058bde..148b86fe 100644 --- a/src/collision/TempColModels.cpp +++ b/src/collision/TempColModels.cpp @@ -1,10 +1,12 @@ #include "common.h" +#include "main.h" #include "TempColModels.h" +#include "Game.h" + +// LCS: haven't yet checked the numbers but they probably haven't changed -CColModel CTempColModels::ms_colModelPed1; CColModel CTempColModels::ms_colModelPed2; -CColModel CTempColModels::ms_colModelBBox; CColModel CTempColModels::ms_colModelBumper1; CColModel CTempColModels::ms_colModelWheel1; CColModel CTempColModels::ms_colModelPanel1; @@ -15,7 +17,9 @@ CColModel CTempColModels::ms_colModelPedGroundHit; CColModel CTempColModels::ms_colModelBoot1; CColModel CTempColModels::ms_colModelDoor1; CColModel CTempColModels::ms_colModelBonnet1; -CColModel CTempColModels::ms_colModelWeapon; +CColModel CTempColModels::ms_colModelFerryDocked; + +CTempColModels *gpTempColModels; CColSphere s_aPedSpheres[3]; @@ -33,6 +37,7 @@ CColSphere s_aBootSpheres[4]; CColSphere s_aWheelSpheres[2]; CColSphere s_aBodyPartSpheres1[2]; CColSphere s_aBodyPartSpheres2[2]; +CColBox S_aFerryDockedBoxes[1]; void CTempColModels::Initialise(void) @@ -43,11 +48,26 @@ CTempColModels::Initialise(void) colmodel.level = LEVEL_GENERIC;\ colmodel.ownsCollisionVolumes = false; - int i; + if(gMakeResources){ + if(gpTempColModels == nil){ + gpTempColModels = new CTempColModels; + gpTempColModels->Initialise(); + return; + } + + ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f)); + ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f)); + ms_colModelBBox.level = LEVEL_GENERIC; - ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f)); - ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f)); - ms_colModelBBox.level = LEVEL_GENERIC; + ms_colModelPed1.boundingSphere.Set(1.25f, CVector(0.0f, 0.0f, 0.0f)); + ms_colModelPed1.boundingBox.Set(CVector(-0.35f, -0.35f, -1.0f), CVector(0.35f, 0.35f, 0.9f)); + SET_COLMODEL_SPHERES(ms_colModelPed1, s_aPedSpheres); + + ms_colModelWeapon.boundingSphere.Set(0.25f, CVector(0.0f, 0.0f, 0.0f)); + ms_colModelWeapon.boundingBox.Set(CVector(-0.25f, -0.25f, -0.25f), CVector(0.25f, 0.25f, 0.25f)); + } + + int i; for (i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) { ms_colModelCutObj[i].boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f)); @@ -73,10 +93,6 @@ CTempColModels::Initialise(void) s_aPedSpheres[i].piece = 0; } - ms_colModelPed1.boundingSphere.Set(1.25f, CVector(0.0f, 0.0f, 0.0f)); - ms_colModelPed1.boundingBox.Set(CVector(-0.35f, -0.35f, -1.0f), CVector(0.35f, 0.35f, 0.9f)); - SET_COLMODEL_SPHERES(ms_colModelPed1, s_aPedSpheres); - // Ped 2 Spheres s_aPed2Spheres[0].radius = 0.3f; @@ -293,13 +309,47 @@ CTempColModels::Initialise(void) SET_COLMODEL_SPHERES(ms_colModelBodyPart2, s_aBodyPartSpheres2); - ms_colModelWeapon.boundingSphere.radius = 0.25f; - ms_colModelWeapon.boundingBox.min.x = -0.25f; - ms_colModelWeapon.boundingBox.min.y = -0.25f; - ms_colModelWeapon.boundingBox.min.z = -0.25f; - ms_colModelWeapon.boundingBox.max.x = 0.25f; - ms_colModelWeapon.boundingBox.max.y = 0.25f; - ms_colModelWeapon.boundingBox.max.z = 0.25f; + // Ferry Docked + + S_aFerryDockedBoxes[0].Set(CVector(-6.3f, -22.78f, -2.0f), CVector(6.3f, 22.78f, 2.8f), SURFACE_THICK_METAL_PLATE, SURFACE_DEFAULT); + + ms_colModelFerryDocked.boundingSphere.Set(35.0f, CVector(0.0f, -0.0f, 0.0f)); + ms_colModelFerryDocked.boundingBox.Set(S_aFerryDockedBoxes[0].min, S_aFerryDockedBoxes[0].max); + ms_colModelFerryDocked.spheres = nil; + ms_colModelFerryDocked.numSpheres = 0; + ms_colModelFerryDocked.boxes = S_aFerryDockedBoxes; + ms_colModelFerryDocked.numBoxes = ARRAY_SIZE(S_aFerryDockedBoxes); + ms_colModelFerryDocked.level = LEVEL_GENERIC; + #undef SET_COLMODEL_SPHERES } + +void +CTempColModels::Write(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), 0x10, false, true); + + ms_colModelBBox.Write(writer, false); + writer.AddPatch(&ms_colModelBBox); + + ms_colModelPed1.Write(writer, false); + writer.AddPatch(&ms_colModelPed1); + + ms_colModelWeapon.Write(writer, false); + writer.AddPatch(&ms_colModelWeapon); + + for(int i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) + ms_colModelCutObj[i].Write(writer, true); + ms_colModelPed2.Write(writer, true); + ms_colModelPedGroundHit.Write(writer, true); + ms_colModelDoor1.Write(writer, true); + ms_colModelBumper1.Write(writer, true); + ms_colModelPanel1.Write(writer, true); + ms_colModelBonnet1.Write(writer, true); + ms_colModelBoot1.Write(writer, true); + ms_colModelWheel1.Write(writer, true); + ms_colModelBodyPart1.Write(writer, true); + ms_colModelBodyPart2.Write(writer, true); + ms_colModelFerryDocked.Write(writer, true); +} diff --git a/src/collision/TempColModels.h b/src/collision/TempColModels.h index 457315b6..0f1f06c3 100644 --- a/src/collision/TempColModels.h +++ b/src/collision/TempColModels.h @@ -1,13 +1,15 @@ #pragma once -#include "Collision.h" +#include "ColModel.h" class CTempColModels { public: - static CColModel ms_colModelPed1; + CColModel ms_colModelPed1; + CColModel ms_colModelBBox; + CColModel ms_colModelWeapon; + static CColModel ms_colModelPed2; - static CColModel ms_colModelBBox; static CColModel ms_colModelBumper1; static CColModel ms_colModelWheel1; static CColModel ms_colModelPanel1; @@ -18,7 +20,10 @@ public: static CColModel ms_colModelBoot1; static CColModel ms_colModelDoor1; static CColModel ms_colModelBonnet1; - static CColModel ms_colModelWeapon; + static CColModel ms_colModelFerryDocked; - static void Initialise(void); + void Initialise(void); + void Write(base::cRelocatableChunkWriter &writer); }; + +extern CTempColModels *gpTempColModels; diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index a899518b..c956a6f1 100644 --- a/src/control/AutoPilot.cpp +++ b/src/control/AutoPilot.cpp @@ -6,8 +6,6 @@ #include "Curves.h" #include "PathFind.h" -//--MIAMI: file done - void CAutoPilot::ModifySpeed(float speed) { m_fMaxTrafficSpeed = Max(0.01f, speed); diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp index 1a1c03bd..e7c76a9c 100644 --- a/src/control/Bridge.cpp +++ b/src/control/Bridge.cpp @@ -6,8 +6,6 @@ #include "PathFind.h" #include "Stats.h" -//--MIAMI: file done - CEntity *CBridge::pLiftRoad; CEntity *CBridge::pLiftPart; CEntity *CBridge::pWeight; @@ -163,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/CarAI.cpp b/src/control/CarAI.cpp index 06438e0a..45652b23 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -23,8 +23,6 @@ #define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f -//--MIAMI: file done - float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle) { return pVehicle->AutoPilot.m_nSwitchDistance; @@ -45,7 +43,7 @@ float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle) void CCarAI::BackToCruisingIfNoWantedLevel(CVehicle* pVehicle) { if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer && - (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) { + (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) { CCarCtrl::JoinCarWithRoadSystem(pVehicle); pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; @@ -131,7 +129,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) TellOccupantsToLeaveCar(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = 0; pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1) pVehicle->m_bSirenOrAlarm = false; } } @@ -173,7 +171,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) TellOccupantsToLeaveCar(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = 0; pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1) pVehicle->m_bSirenOrAlarm = false; } } @@ -346,7 +344,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) pVehicle->AutoPilot.m_nCarMission = MISSION_STOP_FOREVER; } if (distance > 70.0f || FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || - (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) { + (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) { TellOccupantsToLeaveCar(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = 0; pVehicle->AutoPilot.m_nCarMission = MISSION_STOP_FOREVER; @@ -363,7 +361,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) break; } default: - if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && !CCullZones::NoPolice()){ + if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && !CCullZones::NoPolice()){ if (ABS(FindPlayerCoors().x - pVehicle->GetPosition().x) > 10.0f || ABS(FindPlayerCoors().y - pVehicle->GetPosition().y) > 10.0f){ pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle); @@ -377,7 +375,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) TellOccupantsToLeaveCar(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = 0; pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1) pVehicle->m_bSirenOrAlarm = false; } } @@ -390,7 +388,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) pVehicle->AutoPilot.m_nCruiseSpeed = 0; break; } - if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel >= 1 && CCullZones::PoliceAbandonCars()) { + if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->GetWantedLevel() >= 1 && CCullZones::PoliceAbandonCars()) { TellOccupantsToLeaveCar(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = 0; pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; @@ -498,7 +496,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) else pVehicle->AutoPilot.m_fCruiseSpeedMultiplier += change; - if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0) { + if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0) { if (!FindPlayerVehicle() || FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR || FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) { @@ -563,7 +561,7 @@ void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle) case MI_RHINO: case MI_BARRACKS: pVehicle->SetUpDriver(); - if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 1) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() > 1) pVehicle->SetupPassenger(0); return; case MI_PREDATOR: @@ -649,7 +647,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget) uint8 CCarAI::FindPoliceCarMissionForWantedLevel() { - switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){ + switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel()){ case 0: case 1: return MISSION_BLOCKPLAYER_FARAWAY; case 2: return (CGeneral::GetRandomNumber() & 3) >= 3 ? MISSION_RAMPLAYER_FARAWAY : MISSION_BLOCKPLAYER_FARAWAY; @@ -663,7 +661,7 @@ uint8 CCarAI::FindPoliceCarMissionForWantedLevel() uint8 CCarAI::FindPoliceBoatMissionForWantedLevel() { - switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { + switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel()) { case 0: case 1: return MISSION_BLOCKPLAYER_FARAWAY; case 2: @@ -677,7 +675,7 @@ uint8 CCarAI::FindPoliceBoatMissionForWantedLevel() int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle) { - switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { + switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel()) { case 0: return CGeneral::GetRandomNumberInRange(12, 16); case 1: return 25; case 2: return 34; @@ -691,7 +689,7 @@ int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle) void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle) { - if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 1){ + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel() == 1){ float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude(); if (FindPlayerVehicle()){ if (distanceToPlayer < 10.0f) @@ -708,7 +706,7 @@ void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle) else pVehicle->AutoPilot.m_nCruiseSpeed = 25; } - }else if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 2){ + }else if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel() == 2){ float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude(); if (FindPlayerVehicle()) { if (distanceToPlayer < 10.0f) @@ -735,7 +733,7 @@ void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle) void CCarAI::MellowOutChaseSpeedBoat(CVehicle* pVehicle) { - switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { + switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel()) { case 0: pVehicle->AutoPilot.m_nCruiseSpeed = 8; break; case 1: pVehicle->AutoPilot.m_nCruiseSpeed = 10; break; case 2: pVehicle->AutoPilot.m_nCruiseSpeed = 15; break; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 6abeae64..e92f26c9 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -85,8 +85,6 @@ #define MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN (40.0f) #define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f) -//--MIAMI: file done - bool CCarCtrl::bMadDriversCheat; int CCarCtrl::NumLawEnforcerCars; int CCarCtrl::NumAmbulancesOnDuty; @@ -115,8 +113,6 @@ uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP]; bool gbEmergencyVehiclesEnabled = true; -//--MIAMI: done except heli/plane functions - void CCarCtrl::GenerateRandomCars() { @@ -156,12 +152,12 @@ CCarCtrl::GenerateOneRandomCar() CWanted* pWanted = pPlayer->m_pPed->m_pWanted; int carClass; int carModel; - if (pWanted->m_nWantedLevel > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && + if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && pWanted->m_CurrentCops < pWanted->m_MaxCops && !CGame::IsInInterior() && ( - pWanted->m_nWantedLevel > 3 || - pWanted->m_nWantedLevel > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || - pWanted->m_nWantedLevel > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { - /* Last pWanted->m_nWantedLevel > 1 is unnecessary but I added it for better readability. */ + pWanted->GetWantedLevel() > 3 || + pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || + pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { + /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */ /* Wouldn't be surprised it was there originally but was optimized out. */ carClass = COPS; carModel = ChoosePoliceCarModel(); @@ -170,7 +166,7 @@ CCarCtrl::GenerateOneRandomCar() carModel = ChooseModel(&zone, &carClass); if (carModel == -1) return; - if (!(carClass == COPS && pWanted->m_nWantedLevel >= 1)) + if (!(carClass == COPS && pWanted->GetWantedLevel() >= 1)) /* All cop spawns with wanted level are handled by condition above. */ /* In particular it means that cop cars never spawn if player has wanted level of 1. */ break; @@ -318,7 +314,7 @@ CCarCtrl::GenerateOneRandomCar() } if (!ThePaths.GenerateCarCreationCoors(vecTargetPos.x, vecTargetPos.y, frontX, frontY, preferredDistance, angleLimit, invertAngleLimitTest, &spawnPosition, &curNodeId, &nextNodeId, - &positionBetweenNodes, carClass == COPS && pWanted->m_nWantedLevel >= 1)) + &positionBetweenNodes, carClass == COPS && pWanted->GetWantedLevel() >= 1)) return; CPathNode* pCurNode = &ThePaths.m_pathNodes[curNodeId]; CPathNode* pNextNode = &ThePaths.m_pathNodes[nextNodeId]; @@ -384,7 +380,7 @@ CCarCtrl::GenerateOneRandomCar() switch (carClass) { case COPS: pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; - if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel != 0){ + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel() != 0){ pVehicle->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pVehicle); pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed / 2; pVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); @@ -3199,7 +3195,7 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle) void CCarCtrl::GenerateEmergencyServicesCar(void) { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 3) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() > 3) return; if (CGame::IsInInterior()) return; diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp index 29471608..31a2767a 100644 --- a/src/control/Curves.cpp +++ b/src/control/Curves.cpp @@ -2,8 +2,6 @@ #include "Curves.h" -//--MIAMI: file done - float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) { CVector2D dir1(dir1X, dir1Y); diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index f1400de8..a6aca57e 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -16,8 +16,6 @@ #include "Vehicle.h" #include "GameLogic.h" -//--MIAMI: file done - #define FRENZY_ANY_PED -1 #define FRENZY_ANY_CAR -2 diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index d17c5b04..e238a8b3 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -47,8 +47,6 @@ float CGameLogic::ShortCutDropOffOrientationForMission; bool CGameLogic::MissionDropOffReadyToBeUsed; char CGameLogic::mStoredPlayerOutfit[8] = "plr3"; -//--MIAMI: file done - #define SHORTCUT_TAXI_COST (9) #define TOTAL_BUSTED_AUDIO (28) @@ -223,7 +221,7 @@ CGameLogic::Update() pPlayerInfo.m_WBState = WBSTATE_PLAYING; int takeMoney; - switch (pPlayerInfo.m_pPed->m_pWanted->m_nWantedLevel) { + switch (pPlayerInfo.m_pPed->m_pWanted->GetWantedLevel()) { case 0: case 1: takeMoney = 100; diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 8e5f5abc..0b1f8e19 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -25,8 +25,6 @@ #include "World.h" #include "VarConsole.h" -//--MIAMI: file done - #define CRUSHER_GARAGE_X1 (1135.5f) #define CRUSHER_GARAGE_Y1 (57.0f) #define CRUSHER_GARAGE_Z1 (-1.0f) @@ -108,7 +106,7 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLL { MI_VOODOO, MI_CUBAN, MI_CADDY, MI_BAGGAGE, MI_MRWHOOP, MI_PIZZABOY } }; -const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; // what is this? +const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; int32 CGarages::BankVansCollected; bool CGarages::BombsAreFree; @@ -452,7 +450,7 @@ void CGarage::Update() m_eGarageState = GS_OPENING; DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1); bool bTakeMoney = false; - if (FindPlayerPed()->m_pWanted->m_nWantedLevel != 0) { + if (FindPlayerPed()->m_pWanted->GetWantedLevel() != 0) { bTakeMoney = true; FindPlayerPed()->m_pWanted->Suspend(); } @@ -504,7 +502,7 @@ void CGarage::Update() 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]); + CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, CVehicleModelInfo::mspInfo->ms_vehicleColourTable[colour1]); } } } @@ -1827,7 +1825,7 @@ void CGarage::FindDoorsEntities() } } if (m_pDoor1 && m_pDoor2) { - if (m_pDoor1->GetModelIndex() != MI_LCS_GARAGEDOOR39 && m_pDoor1->GetModelIndex() != MI_LCS_GARAGEDOOR40) { + if (m_pDoor1->GetModelIndex() != MI_CRUSHERBODY && m_pDoor1->GetModelIndex() != MI_CRUSHERLID) { CVector2D vecDoor1ToGarage(m_pDoor1->GetPosition().x - GetGarageCenterX(), m_pDoor1->GetPosition().y - GetGarageCenterY()); CVector2D vecDoor2ToGarage(m_pDoor2->GetPosition().x - GetGarageCenterX(), m_pDoor2->GetPosition().y - GetGarageCenterY()); if (DotProduct2D(vecDoor1ToGarage, vecDoor2ToGarage) > 0.0f) { @@ -2411,44 +2409,83 @@ void CGarages::Load(uint8* buf, uint32 size) bool CGarages::IsModelIndexADoor(uint32 id) { - return id == MI_LCS_GARAGEDOOR01 || - id == MI_LCS_GARAGEDOOR02 || - id == MI_LCS_GARAGEDOOR03 || - id == MI_LCS_GARAGEDOOR04 || - id == MI_LCS_GARAGEDOOR05 || - id == MI_LCS_GARAGEDOOR06 || - id == MI_LCS_GARAGEDOOR07 || - id == MI_LCS_GARAGEDOOR08 || - id == MI_LCS_GARAGEDOOR09 || - id == MI_LCS_GARAGEDOOR10 || - id == MI_LCS_GARAGEDOOR11 || - id == MI_LCS_GARAGEDOOR12 || - id == MI_LCS_GARAGEDOOR13 || - id == MI_LCS_GARAGEDOOR14 || - id == MI_LCS_GARAGEDOOR15 || - id == MI_LCS_GARAGEDOOR16 || - id == MI_LCS_GARAGEDOOR17 || - id == MI_LCS_GARAGEDOOR18 || - id == MI_LCS_GARAGEDOOR19 || - id == MI_LCS_GARAGEDOOR20 || - id == MI_LCS_GARAGEDOOR21 || - id == MI_LCS_GARAGEDOOR22 || - id == MI_LCS_GARAGEDOOR23 || - id == MI_LCS_GARAGEDOOR24 || - id == MI_LCS_GARAGEDOOR25 || - id == MI_LCS_GARAGEDOOR26 || - id == MI_LCS_GARAGEDOOR27 || - id == MI_LCS_GARAGEDOOR28 || - id == MI_LCS_GARAGEDOOR29 || - id == MI_LCS_GARAGEDOOR30 || - id == MI_LCS_GARAGEDOOR31 || - id == MI_LCS_GARAGEDOOR32 || - id == MI_LCS_GARAGEDOOR33 || - id == MI_LCS_GARAGEDOOR34 || - id == MI_LCS_GARAGEDOOR35 || - id == MI_LCS_GARAGEDOOR36 || - id == MI_LCS_GARAGEDOOR37 || - id == MI_LCS_GARAGEDOOR38 || - id == MI_LCS_GARAGEDOOR39 || - id == MI_LCS_GARAGEDOOR40; + return id == MI_GARAGEDOOR1 || + id == MI_GARAGEDOOR17 || + id == MI_GARAGEDOOR27 || + id == MI_GARAGEDOOR28 || + id == MI_GARAGEDOOR29 || + id == MI_GARAGEDOOR30 || + id == MI_GARAGEDOOR31 || + id == MI_GARAGEDOOR32 || + id == MI_GARAGEDOOR33 || + id == MI_GARAGEDOOR34 || + id == MI_GARAGEDOOR35 || + id == MI_GARAGEDOOR36 || + id == MI_GARAGEDOOR37 || + id == MI_GARAGEDOOR38 || + id == MI_GARAGEDOOR39 || + id == MI_CRUSHERBODY || + id == MI_CRUSHERLID || + id == MI_GARAGEDOOR2 || + id == MI_GARAGEDOOR3 || + id == MI_GARAGEDOOR4 || + id == MI_GARAGEDOOR5 || + id == MI_GARAGEDOOR6 || + id == MI_GARAGEDOOR7 || + id == MI_GARAGEDOOR9 || + id == MI_GARAGEDOOR10 || + id == MI_GARAGEDOOR11 || + id == MI_GARAGEDOOR12 || + id == MI_GARAGEDOOR13 || + id == MI_GARAGEDOOR14 || + id == MI_GARAGEDOOR15 || + id == MI_GARAGEDOOR16 || + id == MI_GARAGEDOOR18 || + id == MI_GARAGEDOOR19 || + id == MI_GARAGEDOOR20 || + id == MI_GARAGEDOOR21 || + id == MI_GARAGEDOOR22 || + id == MI_GARAGEDOOR23 || + id == MI_GARAGEDOOR24 || + id == MI_GARAGEDOOR25 || + id == MI_GARAGEDOOR26 || + id == MI_DOOR2_SJL; +} + +void CGarages::StopCarFromBlowingUp(CAutomobile* pCar) +{ + pCar->m_fFireBlowUpTimer = 0.0f; + pCar->m_fHealth = Max(pCar->m_fHealth, 300.0f); + pCar->Damage.SetEngineStatus(Max(pCar->Damage.GetEngineStatus(), 275)); +} + +bool CGarage::Does60SecondsNeedThisCarAtAll(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return true; + } + return false; +} + +bool CGarage::Does60SecondsNeedThisCar(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return m_bCollectedCarsState & BIT(i); + } + return false; +} + +void CGarage::MarkThisCarAsCollectedFor60Seconds(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + m_bCollectedCarsState |= BIT(i); + } +} + +bool CGarage::IsPlayerEntirelyInsideGarage() +{ + return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f); } diff --git a/src/control/Garages.h b/src/control/Garages.h index 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/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp index 52d00f43..53ed14c7 100644 --- a/src/control/OnscreenTimer.cpp +++ b/src/control/OnscreenTimer.cpp @@ -9,14 +9,12 @@ #include "OnscreenTimer.h" #include "Camera.h" -// --MIAMI: file done - void COnscreenTimer::Init() { m_bDisabled = false; for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { m_sCounters[i].m_nCounterOffset = 0; - for(uint32 j = 0; j < ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText); j++) { + for(uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText); j++) { m_sCounters[i].m_aCounterText[j] = 0; } @@ -26,7 +24,7 @@ void COnscreenTimer::Init() { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { m_sClocks[i].m_nClockOffset = 0; - for(uint32 j = 0; j < ARRAY_SIZE(COnscreenTimerEntry::m_aClockText); j++) { + for(uint32 j = 0; j < ARRAY_SIZE(m_sClocks[0].m_aClockText); j++) { m_sClocks[i].m_aClockText[j] = 0; } @@ -94,7 +92,7 @@ void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 p m_sCounters[pos].m_nCounterOffset = offset; if(text) { - strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText)); + strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(m_sCounters[0].m_aCounterText)); } else { m_sCounters[pos].m_aCounterText[0] = 0; } @@ -116,7 +114,7 @@ void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) { m_sClocks[i].m_nClockOffset = offset; m_sClocks[i].m_bClockGoingDown = bGoingDown; if(text) { - strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(COnscreenTimerEntry::m_aClockText)); + strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(m_sClocks[0].m_aClockText)); } else { m_sClocks[i].m_aClockText[0] = 0; } diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 0f135029..bc9af2e9 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -8,8 +8,6 @@ #include "Lines.h" // for debug #include "PathFind.h" -//--MIAMI: file done except mobile unused function - bool gbShowPedPaths; bool gbShowCarPaths; bool gbShowCarPathsLinks; @@ -340,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(); @@ -1765,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/Phones.cpp b/src/control/Phones.cpp index d25f146f..411dc8c3 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -17,8 +17,6 @@ #include "Replay.h" #endif -// --MIAMI: file done - CPhoneInfo gPhoneInfo; bool CPhoneInfo::bDisplayingPhoneMessage; // is phone picked up diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 8f589ad3..9dff91dd 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -34,8 +34,6 @@ #include "Messages.h" #include "Streaming.h" -// --MIAMI: file done - CPickup CPickups::aPickUps[NUMPICKUPS]; int16 CPickups::NumMessages; int32 CPickups::aPickUpsCollected[NUMCOLLECTEDPICKUPS]; @@ -278,7 +276,7 @@ CPickup::CanBePickedUp(CPlayerPed *player, int playerId) bool cannotBePickedUp = (m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > CWorld::Players[playerId].m_nMaxArmour - 0.5f) || (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > CWorld::Players[playerId].m_nMaxHealth - 0.5f) - || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0) + || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->GetWantedLevel() == 0) || (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame)); return !cannotBePickedUp; } @@ -784,7 +782,7 @@ CPickups::GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex) DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0); return true; } else if (modelIndex == MI_PICKUP_BRIBE) { - int32 level = Max(FindPlayerPed()->m_pWanted->m_nWantedLevel - 1, 0); + int32 level = Max(FindPlayerPed()->m_pWanted->GetWantedLevel() - 1, 0); player->SetWantedLevel(level); DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0); return true; @@ -1578,7 +1576,6 @@ CPacManPickups::ResetPowerPillsCarriedByPlayer() { } -// --MIAMI: Done void CPed::CreateDeadPedMoney(void) { @@ -1599,7 +1596,6 @@ CPed::CreateDeadPedMoney(void) m_nPedMoney = 0; } -// --MIAMI: Done void CPed::CreateDeadPedWeaponPickups(void) { @@ -1625,7 +1621,6 @@ CPed::CreateDeadPedWeaponPickups(void) ClearWeapons(); } -// --MIAMI: Done void CPed::CreateDeadPedPickupCoors(float *x, float *y, float *z) { diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 08fb2bc8..fd8b15cd 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -147,7 +147,7 @@ public: class CPacManPickups { - friend CPacManPickup; + friend class CPacManPickup; static CPacManPickup aPMPickUps[NUMPACMANPICKUPS]; static CVector LastPickUpCoors; diff --git a/src/control/Record.cpp b/src/control/Record.cpp index 9b4a21fc..5e6c7cdb 100644 --- a/src/control/Record.cpp +++ b/src/control/Record.cpp @@ -10,8 +10,6 @@ #include "VehicleModelInfo.h" #include "World.h" -//--MIAMI: file done - uint16 CRecordDataForGame::RecordingState; void CRecordDataForGame::Init(void) diff --git a/src/control/Remote.cpp b/src/control/Remote.cpp index 164a2f4c..dc025549 100644 --- a/src/control/Remote.cpp +++ b/src/control/Remote.cpp @@ -9,9 +9,7 @@ #include "PlayerInfo.h" #include "Vehicle.h" -//--MIAMI: file done - -void +CVehicle* CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model) { CAutomobile *car = new CAutomobile(model, MISSION_VEHICLE); @@ -42,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/Replay.cpp b/src/control/Replay.cpp index 5d109c6f..1fb4b9b0 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -53,8 +53,6 @@ #include "Fluff.h" #include "WaterCreatures.h" -//--MIAMI: file done - uint8 CReplay::Mode; CAddressInReplayBuffer CReplay::Record; CAddressInReplayBuffer CReplay::Playback; diff --git a/src/control/Restart.cpp b/src/control/Restart.cpp index f63d2c07..e1950a29 100644 --- a/src/control/Restart.cpp +++ b/src/control/Restart.cpp @@ -4,8 +4,6 @@ #include "Zones.h" #include "PathFind.h" -//--MIAMI: file done - uint8 CRestart::OverrideHospitalLevel; uint8 CRestart::OverridePoliceStationLevel; bool CRestart::bFadeInAfterNextArrest; diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index bcb7e059..4f714e80 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -16,8 +16,6 @@ #include "General.h" #include "Object.h" -//--MIAMI: file done - #define ROADBLOCKDIST (90.0f) #define ROADBLOCK_OBJECT_WIDTH (4.0f) @@ -57,8 +55,8 @@ CRoadBlocks::Init(void) void CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType) { - static const CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f}, - {1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} }; + static const CVector vecRoadBlockOffets[6] = { CVector(-1.5, 1.8f, 0.0f), CVector(-1.5f, -1.8f, 0.0f), CVector(1.5f, 1.8f, 0.0f), + CVector(1.5f, -1.8f, 0.0f), CVector(-1.5f, 0.0f, 0.0f), CVector(1.5, 0.0, 0.0) }; CEntity* pEntityToAttack = (CEntity*)FindPlayerVehicle(); if (!pEntityToAttack) pEntityToAttack = (CEntity*)FindPlayerPed(); diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp index c793e027..74d81327 100644 --- a/src/control/SceneEdit.cpp +++ b/src/control/SceneEdit.cpp @@ -20,8 +20,6 @@ #include "WeaponInfo.h" #include "World.h" -//--MIAMI: file done - bool CSceneEdit::m_bEditOn; int32 CSceneEdit::m_bCameraFollowActor; bool CSceneEdit::m_bRecording; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 6e97d383..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,13 +50,12 @@ #include "Timecycle.h" #include "TxdStore.h" #include "Bike.h" -#include "memoryManager.h" +#include "smallHeap.h" #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #include <stdarg.h> #endif //--LCS: file done except TODOs and command table - uint8* CTheScripts::ScriptSpace; CRunningScript CTheScripts::ScriptsArray[MAX_NUM_SCRIPTS]; intro_text_line CTheScripts::IntroTextLines[MAX_NUM_INTRO_TEXT_LINES]; @@ -99,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; @@ -108,6 +108,9 @@ bool CTheScripts::InTheScripts; CRunningScript* pCurrent; uint16 CTheScripts::NumTrueGlobals; uint16 CTheScripts::MostGlobals; +CVector gVectorSetInLua; +int CTheScripts::NextScriptCoronaID; +base::cSList<script_corona> CTheScripts::mCoronas; #ifdef MISSION_REPLAY @@ -423,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, ""), @@ -2137,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)) @@ -2514,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) @@ -2621,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<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i;) { + base::cSList<script_corona>::tSItem* next = i->next; + delete i; + i = next; + } + CTheScripts::mCoronas.first = nil; +#endif NumberOfUsedObjects = 0; if (ScriptSpace) Shutdown(); @@ -2633,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); @@ -2773,8 +2783,6 @@ void CTheScripts::Process() UseTextCommands = 0; } - // TODO: mCoronas - #ifdef MISSION_REPLAY static uint32 TimeToWaitTill; switch (AllowMissionReplay) { @@ -2834,6 +2842,11 @@ void CTheScripts::Process() if (script && !script->m_bIsActive) script = nil; } + InTheScripts = false; + for (base::cSList<script_corona>::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); @@ -2897,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) @@ -4919,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: @@ -4932,7 +4949,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) return 0; case COMMAND_IS_WANTED_LEVEL_GREATER: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pWanted->m_nWantedLevel > GET_INTEGER_PARAM(1)); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pWanted->GetWantedLevel() > GET_INTEGER_PARAM(1)); return 0; case COMMAND_CLEAR_WANTED_LEVEL: CollectParameters(&m_nIp, 1); diff --git a/src/control/Script.h b/src/control/Script.h index 780440dd..8b54f28f 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,187 @@ 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; +}; + +class CRunningScript +{ + enum { + ANDOR_NONE = 0, + ANDS_1 = 1, + ANDS_2, + ANDS_3, + ANDS_4, + ANDS_5, + ANDS_6, + ANDS_7, + ANDS_8, + ORS_1 = 21, + ORS_2, + ORS_3, + ORS_4, + ORS_5, + ORS_6, + ORS_7, + ORS_8 + }; + + enum { + STACKVALUE_IP_BITS = 22, + STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS, + STACKVALUE_IS_FUNCTION_CALL_BIT, + STACKVALUE_IP_PARAMS_OFFSET, + + STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1) + }; + +public: + CRunningScript* next; + CRunningScript* prev; + int32 m_nId; + char m_abScriptName[8]; + uint32 m_nIp; + uint32 m_anStack[MAX_STACK_DEPTH]; + uint16 m_nStackPointer; + int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106 + int32 m_nLocalsPointer; + bool m_bIsActive; + bool m_bCondResult; + bool m_bIsMissionScript; + bool m_bSkipWakeTime; + uint32 m_nWakeTime; + uint16 m_nAndOrState; + bool m_bNotFlag; + bool m_bDeatharrestEnabled; + bool m_bDeatharrestExecuted; + bool m_bMissionFlag; + +public: + void SetIP(uint32 ip) { m_nIp = ip; } + CRunningScript* GetNext() const { return next; } + + void Save(uint8*& buf); + void Load(uint8*& buf); + + void UpdateTimers(float timeStep) { + for (int i = 0; i < NUM_TIMERS; i++) + m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep; + } + + void Init(); + void Process(); + + void RemoveScriptFromList(CRunningScript**); + void AddScriptToList(CRunningScript**); + + static const uint32 nSaveStructSize; + + void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams); + int32 CollectNextParameterWithoutIncreasingPC(uint32); + int32* GetPointerToScriptVariable(uint32*, int16); + void StoreParameters(uint32*, int16); + + int8 ProcessOneCommand(); + void DoDeatharrestCheck(); + void UpdateCompareFlag(bool flag) + { + if (m_bNotFlag) + flag = !flag; + if (m_nAndOrState == ANDOR_NONE) { + m_bCondResult = flag; + return; + } + if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { + m_bCondResult &= flag; + if (m_nAndOrState == ANDS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + else { + m_bCondResult |= flag; + if (m_nAndOrState <= ORS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + m_nAndOrState--; + } + int16 GetPadState(uint16, uint16); + + int8 ProcessCommands0To99(int32); + int8 ProcessCommands100To199(int32); + int8 ProcessCommands200To299(int32); + int8 ProcessCommands300To399(int32); + int8 ProcessCommands400To499(int32); + int8 ProcessCommands500To599(int32); + int8 ProcessCommands600To699(int32); + int8 ProcessCommands700To799(int32); + int8 ProcessCommands800To899(int32); + int8 ProcessCommands900To999(int32); + int8 ProcessCommands1000To1099(int32); + int8 ProcessCommands1100To1199(int32); + int8 ProcessCommands1200To1299(int32); + int8 ProcessCommands1300To1399(int32); + int8 ProcessCommands1400To1499(int32); + int8 ProcessCommands1500To1599(int32); + int8 ProcessCommands1600To1699(int32); + + uint32 CollectLocateParameters(uint32*, bool); + void LocatePlayerCommand(int32, uint32*); + void LocatePlayerCharCommand(int32, uint32*); + void LocatePlayerCarCommand(int32, uint32*); + void LocateCharCommand(int32, uint32*); + void LocateCharCharCommand(int32, uint32*); + void LocateCharCarCommand(int32, uint32*); + void LocateCharObjectCommand(int32, uint32*); + void LocateCarCommand(int32, uint32*); + void LocateSniperBulletCommand(int32, uint32*); + void PlayerInAreaCheckCommand(int32, uint32*); + void PlayerInAngledAreaCheckCommand(int32, uint32*); + void CharInAreaCheckCommand(int32, uint32*); + void CarInAreaCheckCommand(int32, uint32*); + void LocateObjectCommand(int32, uint32*); + void ObjectInAreaCheckCommand(int32, uint32*); + +#ifdef GTA_SCRIPT_COLLECTIVE + void LocateCollectiveCommand(int32, uint32*); + void LocateCollectiveCharCommand(int32, uint32*); + void LocateCollectiveCarCommand(int32, uint32*); + void LocateCollectivePlayerCommand(int32, uint32*); + void CollectiveInAreaCheckCommand(int32, uint32*); +#endif + +#ifdef MISSION_REPLAY + bool CanAllowMissionReplay(); +#endif + +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + int CollectParameterForDebug(char* buf, bool& var); + void GetStoredParameterForDebug(char* buf); +#endif + + float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } + + bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami); + bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal); + bool CheckDamagedWeaponType(int32 actual, int32 type); + + void ReturnFromGosubOrFunction(); + +}; + enum { VAR_LOCAL = 1, @@ -343,12 +526,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<script_corona> mCoronas; + static int NextScriptCoronaID; static bool Init(bool loaddata = false); static void Process(); @@ -468,179 +653,14 @@ public: static void SetObjectiveForAllPedsInCollective(int, eObjective); #endif + static bool IsFortStauntonDestroyed() { return FSDestroyedFlag && *(int32*)&ScriptSpace[FSDestroyedFlag] == 1; } + }; extern int ScriptParams[32]; VALIDATE_SIZE(uStackReturnValue, 4); -class CRunningScript -{ - enum { - ANDOR_NONE = 0, - ANDS_1 = 1, - ANDS_2, - ANDS_3, - ANDS_4, - ANDS_5, - ANDS_6, - ANDS_7, - ANDS_8, - ORS_1 = 21, - ORS_2, - ORS_3, - ORS_4, - ORS_5, - ORS_6, - ORS_7, - ORS_8 - }; - - enum { - STACKVALUE_IP_BITS = 22, - STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS, - STACKVALUE_IS_FUNCTION_CALL_BIT, - STACKVALUE_IP_PARAMS_OFFSET, - - STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1) - }; - -public: - CRunningScript* next; - CRunningScript* prev; - int32 m_nId; - char m_abScriptName[8]; - uint32 m_nIp; - uint32 m_anStack[MAX_STACK_DEPTH]; - uint16 m_nStackPointer; - int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106 - int32 m_nLocalsPointer; - bool m_bIsActive; - bool m_bCondResult; - bool m_bIsMissionScript; - bool m_bSkipWakeTime; - uint32 m_nWakeTime; - uint16 m_nAndOrState; - bool m_bNotFlag; - bool m_bDeatharrestEnabled; - bool m_bDeatharrestExecuted; - bool m_bMissionFlag; - -public: - void SetIP(uint32 ip) { m_nIp = ip; } - CRunningScript* GetNext() const { return next; } - - void Save(uint8*& buf); - void Load(uint8*& buf); - - void UpdateTimers(float timeStep) { - for (int i = 0; i < NUM_TIMERS; i++) - m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep; - } - - void Init(); - void Process(); - - void RemoveScriptFromList(CRunningScript**); - void AddScriptToList(CRunningScript**); - - static const uint32 nSaveStructSize; - - void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams); - int32 CollectNextParameterWithoutIncreasingPC(uint32); - int32* GetPointerToScriptVariable(uint32*, int16); - void StoreParameters(uint32*, int16); - - int8 ProcessOneCommand(); - void DoDeatharrestCheck(); - void UpdateCompareFlag(bool flag) - { - if (m_bNotFlag) - flag = !flag; - if (m_nAndOrState == ANDOR_NONE) { - m_bCondResult = flag; - return; - } - if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { - m_bCondResult &= flag; - if (m_nAndOrState == ANDS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - else { - m_bCondResult |= flag; - if (m_nAndOrState <= ORS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - m_nAndOrState--; - } - int16 GetPadState(uint16, uint16); - - int8 ProcessCommands0To99(int32); - int8 ProcessCommands100To199(int32); - int8 ProcessCommands200To299(int32); - int8 ProcessCommands300To399(int32); - int8 ProcessCommands400To499(int32); - int8 ProcessCommands500To599(int32); - int8 ProcessCommands600To699(int32); - int8 ProcessCommands700To799(int32); - int8 ProcessCommands800To899(int32); - int8 ProcessCommands900To999(int32); - int8 ProcessCommands1000To1099(int32); - int8 ProcessCommands1100To1199(int32); - int8 ProcessCommands1200To1299(int32); - int8 ProcessCommands1300To1399(int32); - int8 ProcessCommands1400To1499(int32); - int8 ProcessCommands1500To1599(int32); - int8 ProcessCommands1600To1699(int32); - - uint32 CollectLocateParameters(uint32*, bool); - void LocatePlayerCommand(int32, uint32*); - void LocatePlayerCharCommand(int32, uint32*); - void LocatePlayerCarCommand(int32, uint32*); - void LocateCharCommand(int32, uint32*); - void LocateCharCharCommand(int32, uint32*); - void LocateCharCarCommand(int32, uint32*); - void LocateCharObjectCommand(int32, uint32*); - void LocateCarCommand(int32, uint32*); - void LocateSniperBulletCommand(int32, uint32*); - void PlayerInAreaCheckCommand(int32, uint32*); - void PlayerInAngledAreaCheckCommand(int32, uint32*); - void CharInAreaCheckCommand(int32, uint32*); - void CarInAreaCheckCommand(int32, uint32*); - void LocateObjectCommand(int32, uint32*); - void ObjectInAreaCheckCommand(int32, uint32*); - -#ifdef GTA_SCRIPT_COLLECTIVE - void LocateCollectiveCommand(int32, uint32*); - void LocateCollectiveCharCommand(int32, uint32*); - void LocateCollectiveCarCommand(int32, uint32*); - void LocateCollectivePlayerCommand(int32, uint32*); - void CollectiveInAreaCheckCommand(int32, uint32*); -#endif - -#ifdef MISSION_REPLAY - bool CanAllowMissionReplay(); -#endif - -#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT - int CollectParameterForDebug(char* buf, bool& var); - void GetStoredParameterForDebug(char* buf); -#endif - - float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } - - bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami); - bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal); - bool CheckDamagedWeaponType(int32 actual, int32 type); - - void ReturnFromGosubOrFunction(); - -}; - #ifdef USE_DEBUG_SCRIPT_LOADER extern int scriptToLoad; #endif @@ -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/Script2.cpp b/src/control/Script2.cpp index b31484ab..e4c71403 100644 --- a/src/control/Script2.cpp +++ b/src/control/Script2.cpp @@ -1080,7 +1080,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - SET_INTEGER_PARAM(0, pPed->m_pWanted->m_nWantedLevel); + SET_INTEGER_PARAM(0, pPed->m_pWanted->GetWantedLevel()); StoreParameters(&m_nIp, 1); return 0; } 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/Script5.cpp b/src/control/Script5.cpp index 74d187ca..502bc005 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -2665,7 +2665,7 @@ bool CTheScripts::IsPedStopped(CPed* pPed) { if (pPed->InVehicle()) return IsVehicleStopped(pPed->m_pMyVehicle); - return (pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL) && + return (pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL) && !pPed->bIsInTheAir && !pPed->bIsLanding && pPed->bIsStanding && pPed->m_vecAnimMoveDelta.x == 0.0f && pPed->m_vecAnimMoveDelta.y == 0.0f; } @@ -2679,7 +2679,7 @@ bool CTheScripts::IsPlayerStopped(CPlayerInfo* pPlayer) RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_LAUNCH) || RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_GLIDE)) return false; - return (pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL) && + return (pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL) && !pPed->bIsInTheAir && !pPed->bIsLanding && pPed->bIsStanding && pPed->m_vecAnimMoveDelta.x == 0.0f && pPed->m_vecAnimMoveDelta.y == 0.0f; } 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 e58bf3ea..53e39b68 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -65,7 +65,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_WANTED_STARS_ARE_FLASHING: { CWanted* pWanted = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted; - UpdateCompareFlag(pWanted->m_nMinWantedLevel - pWanted->m_nWantedLevel > 0); + UpdateCompareFlag(pWanted->m_nMinWantedLevel - pWanted->GetWantedLevel() > 0); return 0; } case COMMAND_SET_ALLOW_HURRICANES: @@ -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<script_corona>::tSItem* pCorona = new base::cSList<script_corona>::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<script_corona>::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 3ad8e180..020221c4 100644 --- a/src/control/Script9.cpp +++ b/src/control/Script9.cpp @@ -359,6 +359,7 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) return 0; case COMMAND_HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON: { + CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); bool result = false; if (!pObject) { @@ -635,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); @@ -650,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: @@ -736,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/SetPieces.cpp b/src/control/SetPieces.cpp index bbcfa1ea..143115b8 100644 --- a/src/control/SetPieces.cpp +++ b/src/control/SetPieces.cpp @@ -14,8 +14,6 @@ #define TIME_BETWEEN_SETPIECE_SPAWNS 20000 -//--MIAMI: file done - bool CSetPieces::bDebug; uint32 CSetPieces::NumSetPieces; CSetPiece CSetPieces::aSetPieces[NUM_SETPIECES]; @@ -86,7 +84,7 @@ void CSetPiece::Update(void) switch (m_nType) { case SETPIECE_TWOCOPCARSINALLEY: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle()) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 1 || FindPlayerVehicle()) return; CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1); if (!pVehicle1) @@ -120,7 +118,7 @@ void CSetPiece::Update(void) } case SETPIECE_CARBLOCKINGPLAYERFROMSIDE: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 2) return; if (!FindPlayerVehicle()) return; @@ -143,7 +141,7 @@ void CSetPiece::Update(void) } case SETPIECE_CARRAMMINGPLAYERFROMSIDE: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 2) return; if (!FindPlayerVehicle()) return; @@ -166,7 +164,7 @@ void CSetPiece::Update(void) } case SETPIECE_CREATECOPPERONFOOT: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle()) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 1 || FindPlayerVehicle()) return; CCopPed* pCop = TryToGenerateCopPed(m_vSpawn1); if (!pCop) @@ -180,7 +178,7 @@ void CSetPiece::Update(void) } case SETPIECE_CREATETWOCOPPERSONFOOT: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle()) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 1 || FindPlayerVehicle()) return; CCopPed* pCop = TryToGenerateCopPed(m_vSpawn1); if (!pCop) @@ -204,7 +202,7 @@ void CSetPiece::Update(void) } case SETPIECE_TWOCARSBLOCKINGPLAYERFROMSIDE: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 2) return; if (!FindPlayerVehicle()) return; @@ -242,7 +240,7 @@ void CSetPiece::Update(void) } case SETPIECE_TWOCARSRAMMINGPLAYERFROMSIDE: { - if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2) + if (FindPlayerPed()->m_pWanted->GetWantedLevel() < 2) return; if (!FindPlayerVehicle()) return; diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp index ecfc7207..d8f211d0 100644 --- a/src/control/TrafficLights.cpp +++ b/src/control/TrafficLights.cpp @@ -15,8 +15,6 @@ #include "Weather.h" #include "World.h" -//--MIAMI: file done - bool CTrafficLights::bGreenLightsCheat; void @@ -116,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/Accident.cpp b/src/core/Accident.cpp index cb46e181..c8611323 100644 --- a/src/core/Accident.cpp +++ b/src/core/Accident.cpp @@ -6,8 +6,6 @@ #include "Pools.h" #include "World.h" -// --MIAMI: File done - CAccidentManager gAccidentManager; CAccident* diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index 854ec7d4..1a7facc1 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -81,7 +81,7 @@ CAnimViewer::Initialise(void) { CCollision::Init(); CWorld::Initialise(); mod_HandlingManager.Initialise(); - CTempColModels::Initialise(); + gpTempColModels->Initialise(); CAnimManager::Initialise(); CModelInfo::Initialise(); CParticle::Initialise(); diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 63d8b30b..4895ef6e 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -30,8 +30,6 @@ #include "Bike.h" #include "Pickups.h" -//--MIAMI: file done - bool PrintDebugCode = false; int16 DebugCamMode; @@ -953,7 +951,7 @@ CVector CCam::DoAverageOnVector(const CVector &vec) { int i; - CVector Average = { 0.0f, 0.0f, 0.0f }; + CVector Average = CVector(0.0f, 0.0f, 0.0f); if(ResetStatics){ m_iRunningVectorArrayPos = 0; @@ -4035,7 +4033,7 @@ CCam::Process_Debug(const CVector&, float, float, float) if(CPad::GetPad(1)->GetLeftShockJustDown() && gbBigWhiteDebugLightSwitchedOn) CShadows::StoreShadowToBeRendered(SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &Source, 12.0f, 0.0f, 0.0f, -12.0f, - 128, 128, 128, 128, 1000.0f, false, 1.0f); + 128, 128, 128, 128, 1000.0f, false, 1.0f, nil, 1.0f); if(CHud::m_Wants_To_Draw_Hud){ char str[256]; diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 4bb782f2..f9f4a88f 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -2955,7 +2955,7 @@ CCamera::TryToStartNewCamMode(int obbeMode) if (CReplay::IsPlayingBack()) return false; #endif - if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1) + if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1) return false; if(FindPlayerVehicle() == nil) return false; @@ -2983,7 +2983,7 @@ CCamera::TryToStartNewCamMode(int obbeMode) if (CReplay::IsPlayingBack()) return false; #endif - if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1) + if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1) return false; if(FindPlayerVehicle() == nil) return false; diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index 4bb31ea4..da85a238 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -7,9 +7,6 @@ #include "RwHelper.h" #include "MemoryMgr.h" -#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__) -#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__) - struct CdReadInfo { uint32 nSectorOffset; @@ -60,7 +57,7 @@ CdStreamInitThread(void) if ( gpReadInfo[i].hSemaphore == nil ) { - CDTRACE("failed to create sync semaphore"); + printf("%s: failed to create sync semaphore\n", "cdvd_stream"); ASSERT(0); return; } @@ -81,7 +78,7 @@ CdStreamInitThread(void) if ( gCdStreamSema == nil ) { - CDTRACE("failed to create stream semaphore"); + printf("%s: failed to create stream semaphore\n", "cdvd_stream"); ASSERT(0); return; } @@ -90,7 +87,7 @@ CdStreamInitThread(void) if ( _gCdStreamThread == nil ) { - CDTRACE("failed to create streaming thread"); + printf("%s: failed to create streaming thread\n", "cdvd_stream"); ASSERT(0); return; } @@ -138,7 +135,7 @@ CdStreamInit(int32 numChannels) gpReadInfo = (CdReadInfo *)LocalAlloc(LMEM_ZEROINIT, sizeof(CdReadInfo) * numChannels); ASSERT( gpReadInfo != nil ); - CDDEBUG("read info %p", gpReadInfo); + debug("%s: read info %p\n", "cdvd_stream", gpReadInfo); CdStreamAddImage("MODELS\\GTA3.IMG"); diff --git a/src/core/Clock.cpp b/src/core/Clock.cpp index b0f0b34f..0aa841ae 100644 --- a/src/core/Clock.cpp +++ b/src/core/Clock.cpp @@ -6,8 +6,6 @@ #include "Stats.h" #include "VarConsole.h" -// --MIAMI: File done - _TODO("gbFastTime"); bool gbFastTime; diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index b2dad358..23e86a79 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -1,11 +1,7 @@ -#if defined RW_D3D9 || defined RWLIBS -#define DIRECTINPUT_VERSION 0x0800 -#include <dinput.h> -#endif - +#define WITHDINPUT #include "common.h" #include "platform.h" -#include "crossplatform.h" // for Windows version +#include "crossplatform.h" #include "ControllerConfig.h" #include "Pad.h" #include "FileMgr.h" @@ -21,8 +17,6 @@ #include "Camera.h" #include "GenericGameStorage.h" -// --MIAMI: file done - CControllerConfigManager ControlsManager; CControllerConfigManager::CControllerConfigManager() @@ -37,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++) @@ -323,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; @@ -331,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 @@ -343,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); /*******************************************************************************************/ } @@ -395,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); @@ -524,7 +541,7 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int32 button, i break; case 12: #ifndef REGISTER_START_BUTTON - if (padNumber == 1) + if (padnumber == 1) #endif pad->PCTempJoyState.Start = 255; break; @@ -2738,9 +2755,10 @@ wchar *CControllerConfigManager::GetButtonComboText(e_ControllerAction action) void CControllerConfigManager::SetControllerKeyAssociatedWithAction(e_ControllerAction action, int32 key, eControllerType type) { ResetSettingOrder(action); + int numOfSettings = GetNumOfSettingsForAction(action); m_aSettings[action][type].m_Key = key; - m_aSettings[action][type].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1; + m_aSettings[action][type].m_ContSetOrder = numOfSettings + 1; } int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerAction action) @@ -2750,8 +2768,10 @@ int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerA void CControllerConfigManager::SetMouseButtonAssociatedWithAction(e_ControllerAction action, int32 button) { + int numOfSettings = GetNumOfSettingsForAction(action); + m_aSettings[action][MOUSE].m_Key = button; - m_aSettings[action][MOUSE].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1; + m_aSettings[action][MOUSE].m_ContSetOrder = numOfSettings + 1; } void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action) @@ -2774,7 +2794,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/EventList.cpp b/src/core/EventList.cpp index 8e639656..b7f139b4 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -10,8 +10,6 @@ #include "main.h" #include "Accident.h" -// --MIAMI: file done - int32 CEventList::ms_nFirstFreeSlotIndex; CEvent gaEvent[NUMEVENTS]; @@ -220,7 +218,7 @@ CEventList::ReportCrimeForEvent(eEventType type, intptr crimeId, bool copsDontCa default: crime = CRIME_NONE; break; } - if (crime == CRIME_HIT_PED && IsPedPointerValid((CPed*)crimeId) && FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 && ((CPed*)crimeId)->bBeingChasedByPolice) { + if (crime == CRIME_HIT_PED && IsPedPointerValid((CPed*)crimeId) && FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 && ((CPed*)crimeId)->bBeingChasedByPolice) { if (!((CPed*)crimeId)->DyingOrDead()) { CMessages::AddBigMessage(TheText.Get("GOODBOY"), 5000, 0); CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 50; diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 3ea73233..2818007b 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -30,8 +30,6 @@ #include "ColStore.h" #include "Occlusion.h" -//--MIAMI: file done - char CFileLoader::ms_line[256]; const char* @@ -609,11 +607,14 @@ CFileLoader::LoadObjectTypes(const char *filename) int section; int pathIndex; int id, pathType; - int minID, maxID; + //int minID, maxID; + + for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++) + m_sTempIdeData[i].id = -1; section = NONE; - minID = INT32_MAX; - maxID = -1; + //minID = INT32_MAX; + //maxID = -1; pathIndex = -1; debug("Loading object types from %s...\n", filename); @@ -637,13 +638,13 @@ CFileLoader::LoadObjectTypes(const char *filename) }else switch(section){ case OBJS: id = LoadObject(line); - if(id > maxID) maxID = id; - if(id < minID) minID = id; + //if(id > maxID) maxID = id; + //if(id < minID) minID = id; break; case TOBJ: id = LoadTimeObject(line); - if(id > maxID) maxID = id; - if(id < minID) minID = id; + //if(id > maxID) maxID = id; + //if(id < minID) minID = id; break; case WEAP: LoadWeaponObject(line); @@ -680,10 +681,10 @@ CFileLoader::LoadObjectTypes(const char *filename) } CFileMgr::CloseFile(fd); - for(id = minID; id <= maxID; id++){ + for(id = 0; id < MODELINFOSIZE; id++){ CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id); if(mi && mi->IsBuilding()) - mi->SetupBigBuilding(minID, maxID); + mi->SetupBigBuilding(); } } @@ -716,6 +717,13 @@ CFileLoader::LoadObject(const char *line) if(sscanf(line, "%d %s %s %d", &id, model, txd, &numObjs) != 4) return 0; // game returns return value + for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++) + if(m_sTempIdeData[i].id == -1){ + m_sTempIdeData[i].id = id; + strcpy(m_sTempIdeData[i].name, model); + break; + } + switch(numObjs){ case 1: sscanf(line, "%d %s %s %d %f %d", @@ -764,6 +772,13 @@ CFileLoader::LoadTimeObject(const char *line) if(sscanf(line, "%d %s %s %d", &id, model, txd, &numObjs) != 4) return 0; // game returns return value + for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++) + if(m_sTempIdeData[i].id < 0){ + m_sTempIdeData[i].id = id; + strcpy(m_sTempIdeData[i].name, model); + break; + } + switch(numObjs){ case 1: sscanf(line, "%d %s %s %d %f %d %d %d", @@ -794,7 +809,7 @@ CFileLoader::LoadTimeObject(const char *line) mi->m_firstDamaged = damaged; mi->SetTimes(timeOn, timeOff); mi->SetTexDictionary(txd); - other = mi->FindOtherTimeModel(); + other = mi->FindOtherTimeModel(model); if(other) other->SetOtherTimeModel(id); MatchModelString(model, id); @@ -818,7 +833,7 @@ CFileLoader::LoadWeaponObject(const char *line) mi->m_lodDistances[0] = dist; mi->SetTexDictionary(txd); mi->SetAnimFile(animFile); - mi->SetColModel(&CTempColModels::ms_colModelWeapon); + mi->SetColModel(&gpTempColModels->ms_colModelWeapon); MatchModelString(model, id); return id; } @@ -834,7 +849,7 @@ CFileLoader::LoadClumpObject(const char *line) mi = CModelInfo::AddClumpModel(id); mi->SetModelName(model); mi->SetTexDictionary(txd); - mi->SetColModel(&CTempColModels::ms_colModelBBox); + mi->SetColModel(&gpTempColModels->ms_colModelBBox); } } @@ -941,7 +956,7 @@ CFileLoader::LoadPedObject(const char *line) mi->SetModelName(model); mi->SetTexDictionary(txd); mi->SetAnimFile(animFile); - mi->SetColModel(&CTempColModels::ms_colModelPed1); + mi->SetColModel(&gpTempColModels->ms_colModelPed1); mi->m_pedType = CPedType::FindPedType(pedType); mi->m_pedStatType = CPedStats::GetPedStatType(pedStats); for(animGroupId = 0; animGroupId < NUM_ANIM_ASSOC_GROUPS; animGroupId++) @@ -1312,7 +1327,7 @@ CFileLoader::LoadOcclusionVolume(const char *line) } -//--MIAMI: unused +// unused void CFileLoader::ReloadPaths(const char *filename) { diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index c4c39b1f..8a6db0da 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -18,8 +18,6 @@ #include "GameLogic.h" #include "CarAI.h" -// --MIAMI: file done - CFireManager gFireManager; CFire::CFire() diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index d8d6af8a..df00efde 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1,10 +1,6 @@ -#if defined RW_D3D9 || defined RWLIBS -#define DIRECTINPUT_VERSION 0x0800 -#include <dinput.h> -#endif - #define FORCE_PC_SCALING #define WITHWINDOWS +#define WITHDINPUT #include "common.h" #ifndef PS2_MENU #include "crossplatform.h" @@ -41,7 +37,6 @@ #include "sampman.h" // --LCS: changed a bit to have lcs feel, needs more work - // Similar story to Hud.cpp: // Game has colors inlined in code. // For easier modification we collect them here: @@ -50,7 +45,7 @@ const CRGBA SELECTIONBORDER_COLOR(25, 130, 70, 255); const CRGBA MENUOPTION_COLOR = LABEL_COLOR; const CRGBA SELECTEDMENUOPTION_COLOR(255, 255, 255, 255); const CRGBA HEADER_COLOR(197, 0, 0, 255); -const CRGBA DARKMENUOPTION_COLOR(195, 90, 165, 255); +const CRGBA DARKMENUOPTION_COLOR(115/2, 173/2, 216 / 2, 255); const CRGBA SLIDERON_COLOR(97, 194, 247, 255); const CRGBA SLIDEROFF_COLOR(27, 89, 130, 255); const CRGBA LIST_BACKGROUND_COLOR(49, 101, 148, 130); @@ -582,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(""); @@ -672,7 +675,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl) m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; m_bStartWaitingForKeyBind = false; +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#else SaveSettings(); +#endif } } @@ -909,14 +916,14 @@ CMenuManager::DrawStandardMenus(bool activeScreen) #endif switch (m_nCurrScreen) { - case MENUPAGE_CHOOSE_LOAD_SLOT: + /*case MENUPAGE_CHOOSE_LOAD_SLOT: case MENUPAGE_CHOOSE_DELETE_SLOT: case MENUPAGE_CHOOSE_SAVE_SLOT: CSprite2d::Draw2DPolygon(MENU_X_LEFT_ALIGNED(38.0f), MENU_Y(85.0f), MENU_X_LEFT_ALIGNED(615.0f), MENU_Y(75.0f), MENU_X_LEFT_ALIGNED(30.0f), MENU_Y(320.0f), MENU_X_LEFT_ALIGNED(605.0f), MENU_Y(330.0f), CRGBA(LIST_BACKGROUND_COLOR.r, LIST_BACKGROUND_COLOR.g, LIST_BACKGROUND_COLOR.b, FadeIn(LIST_BACKGROUND_COLOR.a))); - break; + break;*/ case MENUPAGE_SOUND_SETTINGS: PrintRadioSelector(); break; @@ -993,7 +1000,9 @@ CMenuManager::DrawStandardMenus(bool activeScreen) } wchar unicodeTemp[64]; +#ifdef ASPECT_RATIO_SCALE char asciiTemp[32]; +#endif bool weHaveLabel = aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL; uint8 section = 0; // 0: highlight trapezoid 1: texts @@ -1010,12 +1019,12 @@ CMenuManager::DrawStandardMenus(bool activeScreen) #endif wchar* rightText = nil; wchar* leftText; - if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { + /*if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetScale(MENU_X(MEDIUMTEXT_X_SCALE), MENU_Y(MEDIUMTEXT_Y_SCALE)); CFont::SetDropShadowPosition(0); - } else { + } else {*/ CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetScale(MENU_X(BIGTEXT_X_SCALE), MENU_Y(BIGTEXT_Y_SCALE)); CFont::SetDropShadowPosition(2); @@ -1024,7 +1033,7 @@ CMenuManager::DrawStandardMenus(bool activeScreen) CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255))); else CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255))); - } + //} if (aScreens[m_nCurrScreen].m_aEntries[i].m_Align == MENUALIGN_LEFT) { CFont::SetCentreOff(); CFont::SetRightJustifyOff(); @@ -3054,6 +3063,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 @@ -3099,15 +3118,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; @@ -3166,7 +3182,8 @@ CMenuManager::SaveSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); -#ifdef LOAD_INI_SETTINGS +#else + m_lastWorking3DAudioProvider = m_nPrefsAudio3DProviderIndex; SaveINISettings(); #endif } @@ -3222,7 +3239,7 @@ CMenuManager::SmallMessageScreen(const char* text) void CMenuManager::PrintBriefs() { - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255))); CFont::SetRightJustifyOff(); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetScale(MENU_X(MEDIUMTEXT_X_SCALE), MENU_Y(MEDIUMTEXT_Y_SCALE)); @@ -4446,19 +4463,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(); @@ -4687,7 +4704,8 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u break; case MENUACTION_CANCELGAME: DMAudio.Service(); - SwitchToNewScreen(MENUPAGE_OUTRO); + RsEventHandler(rsQUITAPP, nil); + //SwitchToNewScreen(MENUPAGE_OUTRO); break; case MENUACTION_RESUME: #ifdef LEGACY_MENU_OPTIONS @@ -4818,6 +4836,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 +4869,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 +5026,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 +5469,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 b8a5bd7a..b5b4b90d 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" @@ -125,8 +120,6 @@ int gameTxdSlot; uint8 gameProcessPirateCheck = 0; #endif -// --MIAMI: File done - bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); void DoRWStuffEndOfFrame(void); #ifdef PS2_MENU @@ -323,7 +316,7 @@ bool CGame::InitialiseOnceAfterRW(void) { TheText.Load(); CTimer::Initialise(); - CTempColModels::Initialise(); + gpTempColModels->Initialise(); mod_HandlingManager.Initialise(); CSurfaceTable::Initialise("DATA\\SURFACE.DAT"); CPedStats::Initialise(); @@ -373,6 +366,9 @@ bool CGame::Initialise(const char* datFile) CPools::Initialise(); + if(gMakeResources) + CVehicleModelInfo::Load(nil); + #ifndef GTA_PS2 CIniFile::LoadIniFile(); #endif @@ -858,9 +854,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()) { @@ -899,13 +895,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(); @@ -943,7 +939,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/General.h b/src/core/General.h index 69492fb8..2f205c39 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -2,8 +2,6 @@ #include <ctype.h> -// --MIAMI: file done - class CGeneral { public: @@ -135,7 +133,7 @@ public: static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { -#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__ +#ifndef ASCII_STRCMP if (toupper(*str1) != toupper(*str2)) #else if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 870e9a71..3dd98865 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -7,8 +7,6 @@ #include "main.h" #include "Population.h" -// --MIAMI: file done - float CIniFile::PedNumberMultiplier = 0.6f; float CIniFile::CarNumberMultiplier = 0.8f; diff --git a/src/core/Leeds.cpp b/src/core/Leeds.cpp new file mode 100644 index 00000000..cda50605 --- /dev/null +++ b/src/core/Leeds.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "Leeds.h" + +void LoadResource(RpAtomic *atomic) {} +void LoadResource(RpClump *clump) {} + + +void SaveResource(RwTexture *tex, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RwTexDictionary *txd, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RpMaterial *mat, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RpMaterialList *matlist, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RpGeometry *geo, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RpAtomic *atomic, base::cRelocatableChunkWriter &writer) {} +void SaveResource(RpClump *clump, base::cRelocatableChunkWriter &writer) {} diff --git a/src/core/Leeds.h b/src/core/Leeds.h new file mode 100644 index 00000000..bf71d7e0 --- /dev/null +++ b/src/core/Leeds.h @@ -0,0 +1,36 @@ +#pragma once + +/* +PatchElementModelInfo(RslElement *,void *) +ChunkName(char const*) +DestroyAndFreeResourceImage(void) +WriteOrder(char const*) +UnpatchTextures(void) +IsChunked(int) +SaveResourceImage(void) +LoadResourceImage(void) +SaveResource(RslNode *,base::cRelocatableChunkWriter &) +SaveResource(RslTAnimTree *,base::cRelocatableChunkWriter &) +SaveResource(RslSkin *,base::cRelocatableChunkWriter &) +SaveResource(CAnimBlendTree *,base::cRelocatableChunkWriter &) +PatchElementTextures(RslElement *) +PatchElementGroupTextures(RslElementGroup *) +*/ + +void LoadResource(RpAtomic *atomic); +void LoadResource(RpClump *clump); + +/* +cRelocatableChunkWriterGTA::Save(char const*,uint,uint,bool) +cRelocatableChunkGTA::cRelocatableChunkGTA(char const*,uint,uint,bool) +SaveAnimBlock(int) +SaveModel(int,bool) +*/ + +void SaveResource(RwTexture *tex, base::cRelocatableChunkWriter &writer); +void SaveResource(RwTexDictionary *txd, base::cRelocatableChunkWriter &writer); +void SaveResource(RpMaterial *mat, base::cRelocatableChunkWriter &writer); +void SaveResource(RpMaterialList *matlist, base::cRelocatableChunkWriter &writer); +void SaveResource(RpGeometry *geo, base::cRelocatableChunkWriter &writer); +void SaveResource(RpAtomic *atomic, base::cRelocatableChunkWriter &writer); +void SaveResource(RpClump *clump, base::cRelocatableChunkWriter &writer); 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 2548e70d..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 <dinput.h> -#endif -#pragma warning( pop ) - +#define WITHDINPUT #include "common.h" #include "crossplatform.h" #include "platform.h" @@ -54,8 +47,6 @@ #include "libpad.h" #endif -// --MIAMI: file done except Mobile(see TODOs) and PS2 stuff - CPad Pads[MAX_PADS]; #ifdef GTA_PS2 u_long128 pad_dma_buf[scePadDmaBufferMax] __attribute__((aligned(64))); @@ -459,7 +450,7 @@ void ArmourCheat() void WantedLevelUpCheat() { CHud::SetHelpMessage(TheText.Get("CHEAT5"), true); - FindPlayerPed()->m_pWanted->CheatWantedLevel(Min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6)); + FindPlayerPed()->m_pWanted->CheatWantedLevel(Min(FindPlayerPed()->m_pWanted->GetWantedLevel() + 2, 6)); } void WantedLevelDownCheat() diff --git a/src/core/Placeable.h b/src/core/Placeable.h index 22f7583c..b0f9a15a 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -4,7 +4,7 @@ class CPlaceable { public: // disable allocation - static void *operator new(size_t) = delete; + static void *operator new(size_t); CMatrix m_matrix; diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 64f3b9d0..337d631c 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -35,8 +35,6 @@ #include "Automobile.h" #include "GameLogic.h" -// --MIAMI: File done - CVector lastPlayerPos; void @@ -483,7 +481,7 @@ CPlayerInfo::Process(void) CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled; } - if (m_pPed->m_pWanted->m_nWantedLevel && !CTheScripts::IsPlayerOnAMission()) { + if (m_pPed->m_pWanted->GetWantedLevel() && !CTheScripts::IsPlayerOnAMission()) { float maxDelta = 0.0f; static bool movedSignificantly = true; static bool thereIsACarPathNear = true; @@ -495,7 +493,7 @@ CPlayerInfo::Process(void) lastPlayerPos = FindPlayerCoors(); thereIsACarPathNear = ThePaths.FindNodeClosestToCoors(FindPlayerCoors(), PATH_CAR, 60.0f, true, false, false, false) != 0; } - switch (m_pPed->m_pWanted->m_nWantedLevel) { + switch (m_pPed->m_pWanted->GetWantedLevel()) { case 1: maxDelta = 31.f; break; 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/Pools.cpp b/src/core/Pools.cpp index bd246b71..bf35f8ef 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -15,8 +15,6 @@ #include "World.h" #include "MemoryHeap.h" -//--MIAMI: file done - CCPtrNodePool *CPools::ms_pPtrNodePool; CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool; CPedPool *CPools::ms_pPedPool; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index c93876b3..f1bc1655 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1,3 +1,6 @@ +#if (!defined(GTA_PS2_STUFF) && defined(RWLIBS)) || defined(__MWERKS__) +#define WITHD3D +#endif #include "config.h" #include "common.h" @@ -17,8 +20,6 @@ #include "SpecialFX.h" #include "Font.h" -// --MIAMI: file done - float CRadar::m_radarRange; sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS]; CVector2D vec2DRadarOrigin; @@ -54,7 +55,7 @@ CSprite2d CRadar::SpraySprite; CSprite2d CRadar::TShirtSprite; CSprite2d CRadar::TommySprite; CSprite2d CRadar::PhoneSprite; -CSprite2d CRadar::RadioWildstyleSprite; +/*CSprite2d CRadar::RadioWildstyleSprite; CSprite2d CRadar::RadioFlashSprite; CSprite2d CRadar::RadioKChatSprite; CSprite2d CRadar::RadioFeverSprite; @@ -62,7 +63,39 @@ CSprite2d CRadar::RadioVRockSprite; CSprite2d CRadar::RadioVCPRSprite; CSprite2d CRadar::RadioEspantosoSprite; CSprite2d CRadar::RadioEmotionSprite; -CSprite2d CRadar::RadioWaveSprite; +CSprite2d CRadar::RadioWaveSprite;*/ +CSprite2d CRadar::EightBallSprite; +CSprite2d CRadar::BurnerSprite; +CSprite2d CRadar::CiprianiSprite; +CSprite2d CRadar::DonaldSprite; +CSprite2d CRadar::JosephSprite; +CSprite2d CRadar::LeoneSprite; +CSprite2d CRadar::MariaSprite; +CSprite2d CRadar::McraySprite; +CSprite2d CRadar::ToshikoSprite; +CSprite2d CRadar::VincenzoSprite; +CSprite2d CRadar::BombSprite; +CSprite2d CRadar::ClothesShopSprite; +CSprite2d CRadar::PropertyRedSprite; +CSprite2d CRadar::PhilCassidySprite; +CSprite2d CRadar::PowerupSprite; +CSprite2d CRadar::MPBase; +CSprite2d CRadar::MPCheckPoint; +CSprite2d CRadar::MPPlayer; +CSprite2d CRadar::MPObjective; +CSprite2d CRadar::MPCar; +CSprite2d CRadar::MPTank; +CSprite2d CRadar::MPCarLockup; +CSprite2d CRadar::MPTargetPlayer; +CSprite2d CRadar::MapHereSprite0; +CSprite2d CRadar::MapHereSprite1; +CSprite2d CRadar::MapHereSprite2; +CSprite2d CRadar::MapHereSprite3; +CSprite2d CRadar::MapHereSprite4; +CSprite2d CRadar::MapHereSprite5; +CSprite2d CRadar::MapHereSprite6; +CSprite2d CRadar::MapHereSprite7; +CSprite2d CRadar::MapWayPoint; CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { nil, @@ -96,20 +129,38 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { &TShirtSprite, &TommySprite, &PhoneSprite, - &RadioWildstyleSprite, - &RadioFlashSprite, - &RadioKChatSprite, - &RadioFeverSprite, - &RadioVRockSprite, - &RadioVCPRSprite, - &RadioEspantosoSprite, - &RadioEmotionSprite, - &RadioWaveSprite, // tmp hack - &RadioWaveSprite, - &RadioWaveSprite, - &RadioWaveSprite, - &RadioWaveSprite, - &RadioWaveSprite + &EightBallSprite, + &BurnerSprite, + &CiprianiSprite, + &DonaldSprite, + &JosephSprite, + &LeoneSprite, + &MariaSprite, + &McraySprite, + &ToshikoSprite, + &VincenzoSprite, + &BombSprite, + &ClothesShopSprite, + &PropertyRedSprite, + &PhilCassidySprite, + &PowerupSprite, + &MPBase, + &MPCheckPoint, + &MPPlayer, + &MPObjective, + &MPCar, + &MPTank, + &MPCarLockup, + &MPTargetPlayer, + &MapHereSprite0, + &MapHereSprite1, + &MapHereSprite2, + &MapHereSprite3, + &MapHereSprite4, + &MapHereSprite5, + &MapHereSprite6, + &MapHereSprite7, + &MapWayPoint, }; // Why this doesn't coincide with world coordinates i don't know @@ -339,10 +390,10 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id) int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) { CVector2D corners[4] = { - { 1.0f, -1.0f }, // top right - { 1.0f, 1.0f }, // bottom right - { -1.0f, 1.0f }, // bottom left - { -1.0f, -1.0f }, // top left + CVector2D( 1.0f, -1.0f ), // top right + CVector2D( 1.0f, 1.0f ), // bottom right + CVector2D( -1.0f, 1.0f ), // bottom left + CVector2D( -1.0f, -1.0f ), // top left }; CVector2D tmp; int i, j, n; @@ -1025,7 +1076,7 @@ CRadar::LoadTextures() TShirtSprite.SetTexture("tshirt"); TommySprite.SetTexture("tommy"); PhoneSprite.SetTexture("phone"); - RadioWildstyleSprite.SetTexture("RWildstyle"); + /*RadioWildstyleSprite.SetTexture("RWildstyle"); RadioFlashSprite.SetTexture("RFlash"); RadioKChatSprite.SetTexture("RKchat"); RadioFeverSprite.SetTexture("RFever"); @@ -1033,7 +1084,39 @@ CRadar::LoadTextures() RadioVCPRSprite.SetTexture("RVCPR"); RadioEspantosoSprite.SetTexture("REspantoso"); RadioEmotionSprite.SetTexture("REmotion"); - RadioWaveSprite.SetTexture("RWave"); + RadioWaveSprite.SetTexture("RWave");*/ + EightBallSprite.SetTexture("radar_8Ball"); + BurnerSprite.SetTexture("radar_Burner"); + CiprianiSprite.SetTexture("radar_Cipriani"); + DonaldSprite.SetTexture("radar_Donald"); + JosephSprite.SetTexture("radar_Joseph"); + LeoneSprite.SetTexture("radar_Leone"); + MariaSprite.SetTexture("radar_Maria"); + McraySprite.SetTexture("radar_McRay"); + ToshikoSprite.SetTexture("radar_Toshiko"); + VincenzoSprite.SetTexture("radar_Vincenzo"); + BombSprite.SetTexture("radar_Bomb"); + ClothesShopSprite.SetTexture("radar_cShop"); + PropertyRedSprite.SetTexture("radar_propertyR"); + PhilCassidySprite.SetTexture("radar_flag"); + PowerupSprite.SetTexture("radar_powerup"); + MPBase.SetTexture("mp_base"); + MPCheckPoint.SetTexture("radar_mp_checkpoint"); + MPPlayer.SetTexture("mp_player"); + MPObjective.SetTexture("mp_objective"); + MPCar.SetTexture("mp_car"); + MPTank.SetTexture("mp_tank"); + MPCarLockup.SetTexture("mp_carlockup"); + MPTargetPlayer.SetTexture("mp_targetplayer"); + MapHereSprite0.SetTexture("radar_arrow"); + MapHereSprite1.SetTexture("radar_arrow_01"); + MapHereSprite2.SetTexture("radar_arrow_02"); + MapHereSprite3.SetTexture("radar_arrow_03"); + MapHereSprite4.SetTexture("radar_arrow_04"); + MapHereSprite5.SetTexture("radar_arrow_05"); + MapHereSprite6.SetTexture("radar_arrow_06"); + MapHereSprite7.SetTexture("radar_arrow_07"); + MapWayPoint.SetTexture("radar_player_target"); CTxdStore::PopCurrentTxd(); } @@ -1221,7 +1304,39 @@ void CRadar::Shutdown() TShirtSprite.Delete(); TommySprite.Delete(); PhoneSprite.Delete(); - RadioWildstyleSprite.Delete(); + EightBallSprite.Delete(); + BurnerSprite.Delete(); + CiprianiSprite.Delete(); + DonaldSprite.Delete(); + JosephSprite.Delete(); + LeoneSprite.Delete(); + MariaSprite.Delete(); + McraySprite.Delete(); + ToshikoSprite.Delete(); + VincenzoSprite.Delete(); + BombSprite.Delete(); + ClothesShopSprite.Delete(); + PropertyRedSprite.Delete(); + PhilCassidySprite.Delete(); + PowerupSprite.Delete(); + MPBase.Delete(); + MPCheckPoint.Delete(); + MPPlayer.Delete(); + MPObjective.Delete(); + MPCar.Delete(); + MPTank.Delete(); + MPCarLockup.Delete(); + MPTargetPlayer.Delete(); + MapHereSprite0.Delete(); + MapHereSprite1.Delete(); + MapHereSprite2.Delete(); + MapHereSprite3.Delete(); + MapHereSprite4.Delete(); + MapHereSprite5.Delete(); + MapHereSprite6.Delete(); + MapHereSprite7.Delete(); + MapWayPoint.Delete(); + /*RadioWildstyleSprite.Delete(); RadioFlashSprite.Delete(); RadioKChatSprite.Delete(); RadioFeverSprite.Delete(); @@ -1229,7 +1344,7 @@ void CRadar::Shutdown() RadioVCPRSprite.Delete(); RadioEspantosoSprite.Delete(); RadioEmotionSprite.Delete(); - RadioWaveSprite.Delete(); + RadioWaveSprite.Delete();*/ RemoveRadarSections(); } @@ -1672,7 +1787,7 @@ CRadar::DrawLegend(int32 x, int32 y, int32 sprite) case RADAR_SPRITE_PHONE: text = TheText.Get("LG_25"); break; - case RADAR_SPRITE_RADIO_WILDSTYLE: + /*case RADAR_SPRITE_RADIO_WILDSTYLE: text = TheText.Get("LG_26"); break; case RADAR_SPRITE_RADIO_FLASH: @@ -1698,7 +1813,7 @@ CRadar::DrawLegend(int32 x, int32 y, int32 sprite) break; case RADAR_SPRITE_RADIO_WAVE: text = TheText.Get("LG_34"); - break; + break;*/ default: text = TheText.Get("LG_34"); // tmp hack break; diff --git a/src/core/Radar.h b/src/core/Radar.h index 6e0f36f8..3e61f8db 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -83,20 +83,38 @@ enum eRadarSprite RADAR_SPRITE_TSHIRT, RADAR_SPRITE_TOMMY, RADAR_SPRITE_PHONE, - RADAR_SPRITE_RADIO_WILDSTYLE, - RADAR_SPRITE_RADIO_FLASH, - RADAR_SPRITE_RADIO_KCHAT, - RADAR_SPRITE_RADIO_FEVER, - RADAR_SPRITE_RADIO_VROCK, - RADAR_SPRITE_RADIO_VCPR, - RADAR_SPRITE_RADIO_ESPANTOSO, - RADAR_SPRITE_RADIO_EMOTION, - RADAR_SPRITE_RADIO_WAVE, - RADAR_SPRITE_40, // tmp - RADAR_SPRITE_41, - RADAR_SPRITE_42, - RADAR_SPRITE_43, - RADAR_SPRITE_44, + RADAR_SPRITE_EIGHTBALL, + RADAR_SPRITE_BURNER, + RADAR_SPRITE_CIPRIANI, + RADAR_SPRITE_DONALD, + RADAR_SPRITE_JOSEPH, + RADAR_SPRITE_LEONE, + RADAR_SPRITE_MARIA, + RADAR_SPRITE_MCRAY, + RADAR_SPRITE_TOSHIKO, + RADAR_SPRITE_VINCENZO, // tmp + RADAR_SPRITE_BOMB, + RADAR_SPRITE_CLOTHES, + RADAR_SPRITE_PROPERTY_RED, + RADAR_SPRITE_PHIL_CASSIDY, + RADAR_SPRITE_POWERUP, + RADAR_SPRITE_MPBASE, + RADAR_SPRITE_MPCHECKPOINT, + RADAR_SPRITE_MPPLAYER, + RADAR_SPRITE_MPOBJECTIVE, + RADAR_SPRITE_MPCAR, + RADAR_SPRITE_MPTANK, + RADAR_SPRITE_MPCARLOCKUP, + RADAR_SPRITE_MPTARGETPLAYER, + RADAR_SPRITE_MAPHERE0, + RADAR_SPRITE_MAPHERE1, + RADAR_SPRITE_MAPHERE2, + RADAR_SPRITE_MAPHERE3, + RADAR_SPRITE_MAPHERE4, + RADAR_SPRITE_MAPHERE5, + RADAR_SPRITE_MAPHERE6, + RADAR_SPRITE_MAPHERE7, + RADAR_SPRITE_MAPWAYPOINT, RADAR_SPRITE_COUNT }; @@ -219,7 +237,7 @@ public: static CSprite2d TShirtSprite; static CSprite2d TommySprite; static CSprite2d PhoneSprite; - static CSprite2d RadioWildstyleSprite; +/* static CSprite2d RadioWildstyleSprite; static CSprite2d RadioFlashSprite; static CSprite2d RadioKChatSprite; static CSprite2d RadioFeverSprite; @@ -227,7 +245,39 @@ public: static CSprite2d RadioVCPRSprite; static CSprite2d RadioEspantosoSprite; static CSprite2d RadioEmotionSprite; - static CSprite2d RadioWaveSprite; + static CSprite2d RadioWaveSprite;*/ + static CSprite2d EightBallSprite; + static CSprite2d BurnerSprite; + static CSprite2d CiprianiSprite; + static CSprite2d DonaldSprite; + static CSprite2d JosephSprite; + static CSprite2d LeoneSprite; + static CSprite2d MariaSprite; + static CSprite2d McraySprite; + static CSprite2d ToshikoSprite; + static CSprite2d VincenzoSprite; + static CSprite2d BombSprite; + static CSprite2d ClothesShopSprite; + static CSprite2d PropertyRedSprite; + static CSprite2d PhilCassidySprite; + static CSprite2d PowerupSprite; + static CSprite2d MPBase; + static CSprite2d MPCheckPoint; + static CSprite2d MPPlayer; + static CSprite2d MPObjective; + static CSprite2d MPCar; + static CSprite2d MPTank; + static CSprite2d MPCarLockup; + static CSprite2d MPTargetPlayer; + static CSprite2d MapHereSprite0; + static CSprite2d MapHereSprite1; + static CSprite2d MapHereSprite2; + static CSprite2d MapHereSprite3; + static CSprite2d MapHereSprite4; + static CSprite2d MapHereSprite5; + static CSprite2d MapHereSprite6; + static CSprite2d MapHereSprite7; + static CSprite2d MapWayPoint; static CSprite2d *RadarSprites[RADAR_SPRITE_COUNT]; static float cachedCos; static float cachedSin; diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp index dbae9ee3..ffce36f9 100644 --- a/src/core/Ropes.cpp +++ b/src/core/Ropes.cpp @@ -116,7 +116,7 @@ CRopes::RegisterRope(uintptr id, CVector pos, bool setUpdateTimer) aRopes[i].m_unk = false; aRopes[i].m_bWasRegistered = true; aRopes[i].m_updateTimer = setUpdateTimer ? CTimer::GetTimeInMilliseconds() + 20000 : 0; - for(j = 1; j < ARRAY_SIZE(CRope::m_pos); j++){ + for(j = 1; j < ARRAY_SIZE(aRopes[0].m_pos); j++){ if(j & 1) aRopes[i].m_pos[j] = aRopes[i].m_pos[j-1] + CVector(0.0f, 0.0f, 0.625f); else @@ -147,7 +147,7 @@ CRopes::FindCoorsAlongRope(uintptr id, float t, CVector *coors) float f; for(i = 0; i < ARRAY_SIZE(aRopes); i++) if(aRopes[i].m_bActive && aRopes[i].m_id == id){ - t = (ARRAY_SIZE(CRope::m_pos)-1)*clamp(t, 0.0f, 0.999f); + t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*clamp(t, 0.0f, 0.999f); j = t; f = t - j; *coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1]; diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 8d61c484..7ada0da9 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -115,8 +115,6 @@ float CStats::LongestWheelieDist; float CStats::LongestStoppieDist; float CStats::Longest2WheelDist; -// --MIAMI: functions below are done, but there are some to be moved from Frontend - void CStats::Init() { PeopleKilledByOthers = 0; diff --git a/src/core/Stats.h b/src/core/Stats.h index 7fa69396..243ff0ec 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -21,7 +21,7 @@ public: static int32 NumberKillFrenziesPassed; static int32 PeopleKilledByOthers; static int32 HelisDestroyed; - static int32 PedsKilledOfThisType[ePedType::NUM_PEDTYPES]; + static int32 PedsKilledOfThisType[NUM_PEDTYPES]; static int32 TimesDied; static int32 TimesArrested; static int32 KillsSinceLastCheckpoint; diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 4198dd84..8cdc3a66 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -39,8 +39,6 @@ #include "VarConsole.h" #include "KeyGen.h" -//--MIAMI: file done (possibly bugs) - bool CStreaming::ms_disableStreaming; bool CStreaming::ms_bLoadingBigModel; int32 CStreaming::ms_numModelsRequested; @@ -3152,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/SurfaceTable.cpp b/src/core/SurfaceTable.cpp index 8018076d..c4b184bf 100644 --- a/src/core/SurfaceTable.cpp +++ b/src/core/SurfaceTable.cpp @@ -6,8 +6,6 @@ #include "Collision.h" #include "SurfaceTable.h" -//--MIAMI: file done - float CSurfaceTable::ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; void diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index bdef6187..5ebe3f53 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -7,8 +7,6 @@ #include "Timer.h" #include "SpecialFX.h" -// --MIAMI: file done - uint32 CTimer::m_snTimeInMilliseconds; PauseModeTime CTimer::m_snTimeInMillisecondsPauseMode = 1; diff --git a/src/core/User.cpp b/src/core/User.cpp index 8d584b74..53196d03 100644 --- a/src/core/User.cpp +++ b/src/core/User.cpp @@ -10,8 +10,6 @@ #include "World.h" #include "Zones.h" -// --MIAMI: file done - CPlaceName CUserDisplay::PlaceName; COnscreenTimer CUserDisplay::OnscnTimer; CPager CUserDisplay::Pager; diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index f5ea6e53..65bc84d8 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -15,8 +15,6 @@ int32 CWanted::MaximumWantedLevel = 6; int32 CWanted::nMaximumWantedLevel = 9600; -// --MIAMI: File done except stats - void CWanted::Initialise() { diff --git a/src/core/World.cpp b/src/core/World.cpp index 3022368b..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,12 +21,9 @@ #include "RpAnimBlend.h" #include "Shadows.h" #include "TempColModels.h" -#include "Vehicle.h" #include "WaterLevel.h" #include "World.h" -// --MIAMI: file done - #define OBJECT_REPOSITION_OFFSET_Z 2.0f CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; @@ -1795,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/ZoneCull.cpp b/src/core/ZoneCull.cpp index 69c7a796..db3577ad 100644 --- a/src/core/ZoneCull.cpp +++ b/src/core/ZoneCull.cpp @@ -11,8 +11,6 @@ #include "ZoneCull.h" #include "Zones.h" -//--MIAMI: done - int32 CCullZones::NumAttributeZones; CAttributeZone CCullZones::aAttributeZones[NUMATTRIBZONES]; diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 1715d811..09f50a26 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -9,8 +9,6 @@ #include "World.h" #include "Timer.h" -//--MIAMI: file done - eLevelName CTheZones::m_CurrLevel; int16 CTheZones::FindIndex; @@ -544,7 +542,7 @@ CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity, info->gangPedThreshold[8] += info->gangPedThreshold[7]; } -//--MIAMI: unused +// unused void CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity) { @@ -553,7 +551,7 @@ CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity) ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity; } -//--MIAMI: unused +// unused void CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity) { 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..65f43aae 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -7,21 +7,47 @@ #pragma warning(disable: 4838) // narrowing conversion #pragma warning(disable: 4996) // POSIX names +#ifdef __MWERKS__ +#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc +#endif + #include <stdint.h> #include <string.h> #include <math.h> -#if defined _WIN32 && defined WITHWINDOWS -#include <windows.h> +#ifdef __MWERKS__ +#define AUDIO_MSS +#define RWLIBS // codewarrior doesn't support project level defines - so not even this is enough, but still catches most ifdefs +#endif + +#if !defined RW_D3D9 && defined LIBRW +#undef WITHD3D +#undef WITHDINPUT #endif -#if defined _WIN32 && defined WITHD3D +#if (defined WITHD3D && !defined LIBRW) +#define WITHWINDOWS +#endif + +#if defined _WIN32 && defined WITHWINDOWS && !defined _INC_WINDOWS #include <windows.h> -#ifndef USE_D3D9 -#include <d3d8types.h> -#else -#include <d3d9types.h> #endif + +#ifdef WITHD3D + #ifdef LIBRW + #define WITH_D3D // librw includes d3d9 itself via this right now + #else + #ifndef USE_D3D9 + #include <d3d8.h> + #else + #include <d3d9.h> + #endif + #endif +#endif + +#ifdef WITHDINPUT +#define DIRECTINPUT_VERSION 0x0800 +#include <dinput.h> #endif #include <rwcore.h> @@ -52,14 +78,6 @@ #define rwVENDORID_ROCKSTAR 0x0253F2 -// Get rid of bullshit windows definitions, we're not running on an 8086 -#ifdef far -#undef far -#endif -#ifdef near -#undef near -#endif - #define Max(a,b) ((a) > (b) ? (a) : (b)) #define Min(a,b) ((a) < (b) ? (a) : (b)) @@ -70,8 +88,13 @@ typedef uint8_t uint8; typedef int8_t int8; typedef uint16_t uint16; typedef int16_t int16; +#ifndef __MWERKS__ typedef uint32_t uint32; typedef int32_t int32; +#else +typedef unsigned int uint32; +typedef int int32; +#endif typedef uintptr_t uintptr; typedef intptr_t intptr; typedef uint64_t uint64; @@ -83,7 +106,7 @@ typedef uint8 bool8; typedef uint16 bool16; typedef uint32 bool32; -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined (__MWERKS__) typedef ptrdiff_t ssize_t; #endif @@ -191,6 +214,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) ((float)a * ((float)DEFAULT_SCREEN_WIDTH / (float)PSP_DEFAULT_SCREEN_WIDTH)) +#define PSP_SCALE_TO_PS2_Y(a) ((float)a * ((float)DEFAULT_SCREEN_HEIGHT / (float)PSP_DEFAULT_SCREEN_HEIGHT)) + +#define PSP_SCREEN_SCALE_X(a) ((a) * (float) SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH) +#define PSP_SCREEN_SCALE_Y(a) ((a) * (float) SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH) +#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" @@ -269,6 +304,22 @@ extern wchar *AllocUnicode(const char*src); inline float sq(float x) { return x*x; } #define SQR(x) ((x) * (x)) +#ifdef __MWERKS__ +#define M_E 2.71828182845904523536 // e +#define M_LOG2E 1.44269504088896340736 // log2(e) +#define M_LOG10E 0.434294481903251827651 // log10(e) +#define M_LN2 0.693147180559945309417 // ln(2) +#define M_LN10 2.30258509299404568402 // ln(10) +#define M_PI 3.14159265358979323846 // pi +#define M_PI_2 1.57079632679489661923 // pi/2 +#define M_PI_4 0.785398163397448309616 // pi/4 +#define M_1_PI 0.318309886183790671538 // 1/pi +#define M_2_PI 0.636619772367581343076 // 2/pi +#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi) +#define M_SQRT2 1.41421356237309504880 // sqrt(2) +#define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2) +#endif + #define PI (float)M_PI #define TWOPI (PI*2) #define HALFPI (PI/2) @@ -298,14 +349,34 @@ void re3_usererror(const char *format, ...); #define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__) #endif +#ifdef __MWERKS__ +void debug(char *f, ...); +void Error(char *f, ...); +__inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function needs to be inline - this way no call actually gets placed +// USERERROR only gets used in oal builds ... once +#else #define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__) -#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__) #define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__) +#ifndef MASTER +#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__) #define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__) +#else +#define TRACE(f, ...) +#define USERERROR(f, ...) +#endif +#endif +#ifndef MASTER #define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) ) +#else +#define assert(_Expression) +#endif #define ASSERT assert +#ifdef __MWERKS__ +#define static_assert(bool_constexpr, message) +#endif + #define _TODO(x) #define _TODOCONST(x) (x) @@ -329,6 +400,7 @@ void re3_usererror(const char *format, ...); #define CONCAT_(x,y) x##y #define CONCAT(x,y) CONCAT_(x,y) +#ifdef DEBUGMENU // Tweaking stuff for debugmenu #define TWEAKPATH ___tw___TWEAKPATH #define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path; @@ -442,6 +514,7 @@ _TWEEKCLASS(CTweakUInt32, uint32); _TWEEKCLASS(CTweakFloat, float); #undef _TWEEKCLASS +#endif #ifdef VALIDATE_SAVE_SIZE extern int32 _saveBufCount; diff --git a/src/core/config.h b/src/core/config.h index 175a182b..94b2eb60 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -1,5 +1,8 @@ #pragma once +// disables (most) stuff that wasn't in original gta-vc.exe - check section at the bottom of this file +//#define VANILLA_DEFINES + enum Config { NUMPLAYERS = 1, @@ -198,7 +201,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 @@ -346,7 +349,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #endif //#define SIMPLIER_MISSIONS // apply simplifications from mobile #define USE_ADVANCED_SCRIPT_DEBUG_OUTPUT -#define SCRIPT_LOG_FILE_LEVEL 0 // 0 == no log, 1 == overwrite every frame, 2 == full log +#define SCRIPT_LOG_FILE_LEVEL 1 // 0 == no log, 1 == overwrite every frame, 2 == full log #ifndef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #define USE_BASIC_SCRIPT_DEBUG_OUTPUT @@ -405,3 +408,87 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef PS2_ALPHA_TEST #undef NO_ISLAND_LOADING #endif + +#if defined __MWERKS__ || defined VANILLA_DEFINES +#define FINAL +#undef CHATTYSPLASH +#undef TIMEBARS + +#define MASTER +#undef VALIDATE_SAVE_SIZE +#undef NO_MOVIES +#undef DEBUGMENU + +#undef DRAW_GAME_VERSION_TEXT + +//#undef NASTY_GAME +//#undef NO_CDCHECK + +#undef GTA_PS2_STUFF +#undef USE_PS2_RAND +#undef RANDOMSPLASH +#undef PS2_MATFX + +#undef FIX_BUGS +#define THIS_IS_STUPID +#undef MORE_LANGUAGES +#undef COMPATIBLE_SAVES +#undef LOAD_INI_SETTINGS +#undef FIX_HIGH_FPS_BUGS_ON_FRONTEND + +#undef ASPECT_RATIO_SCALE +#undef PROPER_SCALING +//#undef DEFAULT_NATIVE_RESOLUTION +#undef PS2_ALPHA_TEST +#undef IMPROVED_VIDEOMODE +#undef DISABLE_LOADING_SCREEN +#undef DISABLE_VSYNC_ON_TEXTURE_CONVERSION + +#undef FIX_SPRITES + +#define PC_WATER +#undef WATER_CHEATS + +#undef USE_CUTSCENE_SHADOW_FOR_PED +#undef DISABLE_CUTSCENE_SHADOWS + +#undef XINPUT +#undef DETECT_PAD_INPUT_SWITCH +#undef KANGAROO_CHEAT +#undef RESTORE_ALLCARSHELI_CHEAT +#undef BETTER_ALLCARSAREDODO_CHEAT +#undef WALLCLIMB_CHEAT +#undef REGISTER_START_BUTTON +#undef BIND_VEHICLE_FIREWEAPON +#undef BUTTON_ICONS + +#undef FIX_RADAR + +#undef MAP_ENHANCEMENTS +#undef MUCH_SHORTER_OUTRO_SCREEN +#undef CUSTOM_FRONTEND_OPTIONS + +#undef GRAPHICS_MENU_OPTIONS +#undef NO_ISLAND_LOADING +#undef CUTSCENE_BORDERS_SWITCH +#undef MULTISAMPLING +#undef INVERT_LOOK_FOR_PAD + +#undef USE_DEBUG_SCRIPT_LOADER +#undef USE_MEASUREMENTS_IN_METERS +#undef USE_PRECISE_MEASUREMENT_CONVERTION +#undef SUPPORT_JAPANESE_SCRIPT +#undef MISSION_REPLAY +#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT + +#define DONT_FIX_REPLAY_BUGS + +#undef EXPLODING_AIRTRAIN +#undef CPLANE_ROTORS +#undef CAMERA_PICKUP +#undef CANCELLABLE_CAR_ENTER +#undef IMPROVED_CAMERA +#undef FREE_CAM +#undef BIG_IMG +#endif diff --git a/src/core/main.cpp b/src/core/main.cpp index c6624aa5..c3286ea9 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -85,6 +85,9 @@ wchar gUString2[256]; // leeds bool gMakeResources = true; bool gUseChunkFiles = false; +bool gSecondExportPass; +bool gUseModelResources; +bool gUseResources; float FramesPerSecond = 30.0f; @@ -141,6 +144,24 @@ bool gbNewRenderer = true; bool bDisplayNumOfAtomicsRendered = false; bool bDisplayPosn = false; +#ifdef __MWERKS__ +void +debug(char *fmt, ...) +{ +#ifndef MASTER + // TODO put something here +#endif +} + +void +Error(char *fmt, ...) +{ +#ifndef MASTER + // TODO put something here +#endif +} +#endif + void ValidateVersion() { @@ -517,7 +538,6 @@ Terminate3D(void) CSprite2d splash; int splashTxdId = -1; -//--MIAMI: done CSprite2d* LoadSplash(const char *name) { @@ -563,7 +583,6 @@ DestroySplashScreen(void) splashTxdId = -1; } -//--MIAMI: done Const char* GetRandomSplashScreen(void) { @@ -812,6 +831,7 @@ ProcessSlowMode(void) float FramesPerSecondCounter; int32 FrameSamples; +#ifndef MASTER struct tZonePrint { char name[11]; @@ -842,8 +862,6 @@ tZonePrint ZonePrint[] = { "WASHINBTM", "AC", CRect(-255.0f, -1200.0f, 500.0f, -1690.0f)} }; -#ifndef MASTER - void PrintMemoryUsage(void) { diff --git a/src/core/main.h b/src/core/main.h index 0f9ceb08..98813470 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -27,6 +27,9 @@ extern bool gbPrintMemoryUsage; // leeds extern bool gMakeResources; extern bool gUseChunkFiles; +extern bool gSecondExportPass; +extern bool gUseModelResources; +extern bool gUseResources; class CSprite2d; @@ -49,8 +52,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..4a2dfe00 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,7 +1,6 @@ #include <csignal> #define WITHWINDOWS #include "common.h" -#include "crossplatform.h" #include "Renderer.h" #include "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 @@ -93,18 +95,16 @@ CustomFrontendOptionsPopulate(void) if (fd) { #ifdef GRAPHICS_MENU_OPTIONS 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_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "Graphics", "WorldPipeline"); + 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_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "Graphics", "WorldPipeline"); + 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; +} + +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; +} - return original; +bool ReadIniIfExists(const char *cat, const char *key, float *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + if (value && value[0] != '\xBA') { + *out = atof(value); + return true; + } + return false; } -float CheckAndReadIniFloat(const char *cat, const char *key, float original) +bool ReadIniIfExists(const char *cat, const char *key, char *out, int size) { - 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') { + strncpy(out, value, size); + return true; + } + return false; +} - return original; +void StoreIni(const char *cat, const char *key, uint32 val) +{ + char temp[10]; +sprintf(temp, "%u", val); + cfg.set(cat, key, temp); } -void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed) +void StoreIni(const char *cat, const char *key, uint8 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", (uint32)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, int32 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, "%d", val); + cfg.set(cat, key, temp); } -void LoadINISettings() +void StoreIni(const char *cat, const char *key, int8 val) { - cfg.load_file("reLCS.ini"); + 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 @@ -787,9 +1025,13 @@ extern bool gbRenderDebugEnvMap; } #endif +#ifndef __MWERKS__ +#ifndef MASTER const int re3_buffsize = 1024; static char re3_buff[re3_buffsize]; +#endif +#ifndef MASTER void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func) { #ifdef _WIN32 @@ -843,9 +1085,11 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con assert(false); #endif } +#endif void re3_debug(const char *format, ...) { +#ifndef MASTER va_list va; va_start(va, format); #ifdef _WIN32 @@ -857,8 +1101,10 @@ void re3_debug(const char *format, ...) printf("%s", re3_buff); CDebug::DebugAddText(re3_buff); +#endif } +#ifndef MASTER void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...) { char buff[re3_buffsize *2]; @@ -898,6 +1144,8 @@ void re3_usererror(const char *format, ...) assert(false); #endif } +#endif +#endif #ifdef VALIDATE_SAVE_SIZE int32 _saveBufCount; diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp index 580245a8..9878b595 100644 --- a/src/entities/Dummy.cpp +++ b/src/entities/Dummy.cpp @@ -4,8 +4,6 @@ #include "World.h" #include "Dummy.h" -// --MIAMI: file done - void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); } void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index f7175acd..7e2104e1 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -27,8 +27,6 @@ #include "Dummy.h" #include "WindModifiers.h" -//--MIAMI: file done - int gBuildings; CEntity::CEntity(void) @@ -693,7 +691,7 @@ float BannerWindTabel[] = { 0.28f, 0.28f, 0.22f, 0.1f, 0.0f, -0.1f, -0.17f, -0.12f }; -//--MIAMI: unused +// unused void CEntity::ModifyMatrixForBannerInWind(void) { diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index de60c400..7be5df23 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -1288,7 +1288,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) int numCollisions; int mostColliding; CColPoint colpoints[MAX_COLLISION_POINTS]; - CVector shift = { 0.0f, 0.0f, 0.0f }; + CVector shift = CVector(0.0f, 0.0f, 0.0f); bool doShift = false; CEntity *boat = nil; @@ -1747,8 +1747,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) if(numCollisions <= 0) continue; - CVector moveSpeed = { 0.0f, 0.0f, 0.0f }; - CVector turnSpeed = { 0.0f, 0.0f, 0.0f }; + CVector moveSpeed = CVector(0.0f, 0.0f, 0.0f); + CVector turnSpeed = CVector(0.0f, 0.0f, 0.0f); float maxImpulseA = 0.0f; numResponses = 0; if(A->bHasContacted){ @@ -2232,8 +2232,8 @@ CPhysical::ProcessCollision(void) }else if(IsObject() && ((CObject*)this)->ObjectCreatedBy != TEMP_OBJECT){ int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases; if(responsecase == COLLRESPONSE_LAMPOST){ - CVector speedUp = { 0.0f, 0.0f, 0.0f }; - CVector speedDown = { 0.0f, 0.0f, 0.0f }; + CVector speedUp = CVector(0.0f, 0.0f, 0.0f); + CVector speedDown = CVector(0.0f, 0.0f, 0.0f); CColModel *colModel = GetColModel(); speedUp.z = colModel->boundingBox.max.z; speedDown.z = colModel->boundingBox.min.z; diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index 247aa4b1..a874343d 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 @@ -370,7 +370,7 @@ AttachVehiclePipe(rw::Clump *clump) * Neo World pipe */ -int32 WorldPipeSwitch = 0; +int32 WorldPipeSwitch = WORLDPIPE_PS2; bool LightmapEnable; float LightmapMult = 1.0f; InterpolatedFloat WorldLightmapBlend(1.0f); diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index 551d1a74..cb5fcadc 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 @@ -22,7 +22,8 @@ #error "Need librw for EXTENDED_PIPELINES" #endif -extern RwTexture *gpWhiteTexture; // from vehicle model info +//extern RwTexture *gpWhiteTexture; // from vehicle model info +static RwTexture *gpWhiteTexture; // nil works as white in librw currently namespace CustomPipes { 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 <rwcore.h> #include <rpworld.h> #include <rpmatfx.h> diff --git a/src/fakerw/rpworld.h b/src/fakerw/rpworld.h index f10a3754..8e3b09f0 100644 --- a/src/fakerw/rpworld.h +++ b/src/fakerw/rpworld.h @@ -13,6 +13,7 @@ //struct RpMaterial; typedef rw::Material RpMaterial; +typedef rw::MaterialList RpMaterialList; typedef RpMaterial *(*RpMaterialCallBack)(RpMaterial *material, void *data); diff --git a/src/leeds/base/relocatableChunk.h b/src/leeds/base/relocatableChunk.h index ea910240..2658aa21 100644 --- a/src/leeds/base/relocatableChunk.h +++ b/src/leeds/base/relocatableChunk.h @@ -19,6 +19,8 @@ namespace base void* Shrink(void* data); }; +#define VTABLE_ADDR(obj) ((void*)obj) // TODO: make this portable + class cRelocatableChunkClassInfo { public: 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<typename T> +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.cpp b/src/modelinfo/BaseModelInfo.cpp index d92e4941..ffd934ba 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -7,8 +7,9 @@ #include "BaseModelInfo.h" #include "ModelInfo.h" #include "KeyGen.h" - -//--MIAMI: file done +#include "Streaming.h" +#include "smallHeap.h" +#include "TempColModels.h" CBaseModelInfo::CBaseModelInfo(ModelInfoType type) { @@ -20,7 +21,11 @@ CBaseModelInfo::CBaseModelInfo(ModelInfoType type) m_type = type; m_num2dEffects = 0; m_bOwnsColModel = false; + m_nameKey = 0; + m_unk1 = 0; + m_unk2 = 0; m_name = new char[MAX_MODEL_NAME]; + *(int32*)m_name = 0; } void @@ -28,6 +33,7 @@ CBaseModelInfo::Shutdown(void) { DeleteCollisionModel(); DeleteRwObject(); + DeleteChunk(); m_2dEffectsID = -1; m_num2dEffects = 0; m_txdSlot = -1; @@ -36,11 +42,11 @@ CBaseModelInfo::Shutdown(void) void CBaseModelInfo::DeleteCollisionModel(void) { - if(m_colModel && m_bOwnsColModel){ + if(!gUseChunkFiles && m_colModel && m_bOwnsColModel){ if(m_colModel) delete m_colModel; - m_colModel = nil; } + m_colModel = nil; } void @@ -53,15 +59,17 @@ CBaseModelInfo::AddRef(void) void CBaseModelInfo::RemoveRef(void) { - m_refCount--; - RemoveTexDictionaryRef(); + if(m_refCount > 0){ + m_refCount--; + RemoveTexDictionaryRef(); + } } void CBaseModelInfo::SetTexDictionary(const char *name) { int slot = CTxdStore::FindTxdSlot(name); - if(slot < 0) + if(slot == -1) slot = CTxdStore::AddTxdSlot(name); m_txdSlot = slot; } @@ -73,12 +81,24 @@ CBaseModelInfo::AddTexDictionaryRef(void) } void +CBaseModelInfo::AddTexDictionaryRefGu(void) +{ + CTxdStore::AddRefGu(m_txdSlot); +} + +void CBaseModelInfo::RemoveTexDictionaryRef(void) { CTxdStore::RemoveRef(m_txdSlot); } void +CBaseModelInfo::RemoveTexDictionaryRefGu(void) +{ + CTxdStore::RemoveRefGu(m_txdSlot); +} + +void CBaseModelInfo::Init2dEffects(void) { m_2dEffectsID = -1; @@ -112,4 +132,52 @@ CBaseModelInfo::SetModelName(const char *name) m_nameKey = CKeyGen::GetUppercaseKey(name); if (!gUseChunkFiles) strcpy(m_name, name); -}
\ No newline at end of file +} + +void +CBaseModelInfo::DeleteChunk(void) +{ + // BUG? what if we're not using chunks? + if(m_chunk){ + CStreaming::UnregisterPointer(&m_chunk, 2); + cSmallHeap::msInstance.Free(m_chunk); + m_chunk = nil; + } +} + +inline int +GetColmodelID(CColModel *model) +{ + int colModelid = 0; + if(model == &gpTempColModels->ms_colModelBBox) colModelid = 1; + if(model == &gpTempColModels->ms_colModelPed1) colModelid = 2; + if(model == &gpTempColModels->ms_colModelWeapon) colModelid = 3; + if(model == &CTempColModels::ms_colModelPed2) colModelid = 4; + if(model == &CTempColModels::ms_colModelPedGroundHit) colModelid = 5; + if(model == &CTempColModels::ms_colModelDoor1) colModelid = 6; + if(model == &CTempColModels::ms_colModelBumper1) colModelid = 7; + if(model == &CTempColModels::ms_colModelPanel1) colModelid = 8; + if(model == &CTempColModels::ms_colModelBonnet1) colModelid = 9; + if(model == &CTempColModels::ms_colModelBoot1) colModelid = 10; + if(model == &CTempColModels::ms_colModelWheel1) colModelid = 11; + if(model == &CTempColModels::ms_colModelBodyPart1) colModelid = 12; + if(model == &CTempColModels::ms_colModelBodyPart2) colModelid = 13; + if(model == &CTempColModels::ms_colModelCutObj[0]) colModelid = 14; + if(model == &CTempColModels::ms_colModelCutObj[1]) colModelid = 15; + if(model == &CTempColModels::ms_colModelCutObj[2]) colModelid = 16; + if(model == &CTempColModels::ms_colModelCutObj[3]) colModelid = 17; + if(model == &CTempColModels::ms_colModelCutObj[4]) colModelid = 18; + return colModelid; +} + +void +CBaseModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + m_chunk = nil; + RcWriteThis(writer); + if(m_colModel){ + if(m_bOwnsColModel || GetColmodelID(m_colModel) != 0) + m_colModel->Write(writer, true); + writer.AddPatch(&m_colModel); + } +} diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index a93040b1..c9ea13bb 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -1,8 +1,8 @@ #pragma once -#include "Collision.h" +struct CColModel; -#define MAX_MODEL_NAME (21) +#define MAX_MODEL_NAME (24) enum ModelInfoType { @@ -23,13 +23,19 @@ class C2dEffect; class CBaseModelInfo { protected: - char *m_name; + uint32 m_unk1; + uint32 m_unk2; uint32 m_nameKey; - RwObject *m_object; + union { + char *m_name; // if not using chunks + void *m_chunk; // else + }; 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; @@ -51,6 +57,16 @@ public: virtual void ConvertAnimFileIndex(void) {} virtual int GetAnimFileIndex(void) { return -1; } + virtual void LoadModel(void *model, const void *chunk) = 0; + virtual void DeleteChunk(void); + // this writes the modelinfo struct, possibly including actual RW models + virtual void Write(base::cRelocatableChunkWriter &writer); + // this writes the RW models + virtual void *WriteModel(base::cRelocatableChunkWriter &writer) { return nil; } // = 0; // this is not in the vtable for some reason??? + // these allocate the space for a modelinfo struct and patch the vtable pointer + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer) = 0; + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer) = 0; + // one day it becomes virtual uint8 GetModelType() const { return m_type; } bool IsBuilding(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; } @@ -72,7 +88,9 @@ public: void RemoveRef(void); void SetTexDictionary(const char *name); void AddTexDictionaryRef(void); + void AddTexDictionaryRefGu(void); void RemoveTexDictionaryRef(void); + void RemoveTexDictionaryRefGu(void); void Init2dEffects(void); void Add2dEffect(C2dEffect *fx); C2dEffect *Get2dEffect(int n); diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 3fa9a36f..00c2c0fe 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -1,19 +1,30 @@ #include "common.h" +#include "main.h" #include "RwHelper.h" #include "General.h" #include "NodeName.h" #include "VisibilityPlugins.h" #include "ModelInfo.h" #include "AnimManager.h" +#include "Streaming.h" +#include "Leeds.h" -//--MIAMI: file done +base::cRelocatableChunkClassInfo CClumpModelInfo::msClassInfo("CElementGroupModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); // the real name +CClumpModelInfo CClumpModelInfo::msClassInstance; void CClumpModelInfo::DeleteRwObject(void) { if(m_clump){ - RpClumpDestroy(m_clump); + if(!gUseChunkFiles) + RpClumpDestroy(m_clump); + else{ + CStreaming::UnregisterClump(m_clump); + CStreaming::UnregisterPointer(&m_clump, 2); + DeleteChunk(); + } + m_clump = nil; RemoveTexDictionaryRef(); if(GetAnimFileIndex() != -1) @@ -54,6 +65,7 @@ CClumpModelInfo::CreateInstance(RwMatrix *m) if(m_clump){ RpClump *clump = (RpClump*)CreateInstance(); *RwFrameGetMatrix(RpClumpGetFrame(clump)) = *m; + CStreaming::RegisterInstance(clump); return (RwObject*)clump; } return nil; @@ -75,14 +87,15 @@ CClumpModelInfo::SetClump(RpClump *clump) if(GetAnimFileIndex() != -1) CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); if(IsClumpSkinned(clump)){ - int i; + //int i; RpHAnimHierarchy *hier; - RpAtomic *skinAtomic; - RpSkin *skin; + //RpAtomic *skinAtomic; + //RpSkin *skin; hier = GetAnimHierarchyFromClump(clump); assert(hier); RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); +/* skinAtomic = GetFirstAtomic(clump); assert(skinAtomic); @@ -96,6 +109,7 @@ CClumpModelInfo::SetClump(RpClump *clump) weights->w2 /= sum; weights->w3 /= sum; } +*/ RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); } } @@ -150,7 +164,7 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data) return assoc->frame ? nil : frame; } -//--MIAMI: unused +// unused RwFrame* CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data) { @@ -205,3 +219,47 @@ CClumpModelInfo::GetFrameFromId(RpClump *clump, int32 id) RwFrameForAllChildren(RpClumpGetFrame(clump), FindFrameFromIdCB, &assoc); return assoc.frame; } + + +void +CClumpModelInfo::LoadModel(void *clump, const void *chunk) +{ + m_chunk = (void*)chunk; + m_clump = (RpClump*)clump; + LoadResource(m_clump); + CStreaming::RegisterPointer(&m_chunk, 2, true); + CStreaming::RegisterClump(m_clump); + CStreaming::RegisterPointer(&m_clump, 2, true); +} + +void +CClumpModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + CBaseModelInfo::Write(writer); + if(m_clump){ + writer.AddPatch(&m_clump); + SaveResource(m_clump, writer); + } +} + +void* +CClumpModelInfo::WriteModel(base::cRelocatableChunkWriter &writer) +{ + if(m_clump) + SaveResource(m_clump, writer); + return m_clump; +} + +void +CClumpModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CClumpModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h index 0113d340..b8507e5f 100644 --- a/src/modelinfo/ClumpModelInfo.h +++ b/src/modelinfo/ClumpModelInfo.h @@ -35,6 +35,9 @@ public: char *m_animFileName; }; + static base::cRelocatableChunkClassInfo msClassInfo; + static CClumpModelInfo msClassInstance; + CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; } CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; } ~CClumpModelInfo() {} @@ -48,6 +51,12 @@ public: virtual void ConvertAnimFileIndex(void); virtual int GetAnimFileIndex(void) { return m_animFileIndex; } + virtual void LoadModel(void *model, const void *chunk); + virtual void Write(base::cRelocatableChunkWriter &writer); + virtual void *WriteModel(base::cRelocatableChunkWriter &writer); + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); void SetFrameIds(RwObjectNameIdAssocation *assocs); static RwFrame *FindFrameFromNameCB(RwFrame *frame, void *data); 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.cpp b/src/modelinfo/ModelInfo.cpp index 02df1be6..47f4e309 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -6,8 +6,6 @@ #include "ModelInfo.h" #include "KeyGen.h" -// --MIAMI: file done - CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE]; CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore; 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.cpp b/src/modelinfo/PedModelInfo.cpp index e84b9272..1d519b10 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -1,5 +1,6 @@ #include "common.h" +#include "main.h" #include "RwHelper.h" #include "General.h" #include "Bones.h" @@ -9,14 +10,19 @@ #include "VisibilityPlugins.h" #include "ModelInfo.h" #include "custompipes.h" +#include "Streaming.h" +#include "Leeds.h" +#include "TempColModels.h" -//--MIAMI: file done +base::cRelocatableChunkClassInfo CPedModelInfo::msClassInfo("CPedModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CPedModelInfo CPedModelInfo::msClassInstance; void CPedModelInfo::DeleteRwObject(void) { + CStreaming::UnregisterPointer(&m_hitColModel, 2); CClumpModelInfo::DeleteRwObject(); - if(m_hitColModel) + if(!gUseChunkFiles && m_hitColModel) delete m_hitColModel; m_hitColModel = nil; } @@ -43,13 +49,15 @@ CPedModelInfo::SetClump(RpClump *clump) #ifdef EXTENDED_PIPELINES CustomPipes::AttachRimPipe(clump); #endif + if(!IsClumpSkinned(clump)) + return; CClumpModelInfo::SetClump(clump); SetFrameIds(m_pPedIds); // not needed in VC actually if(m_hitColModel == nil) CreateHitColModelSkinned(clump); RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedCB); - if(strcmp(GetModelName(), "player") == 0) - RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); + //if(strcmp(GetModelName(), "player") == 0) + // RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); } struct ColNodeInfo @@ -75,40 +83,27 @@ ColNodeInfo m_pColNodeInfos[NUMPEDINFONODES] = { { nil, PED_FOOTR, PEDPIECE_RIGHTLEG, 0.0f, 0.15f, 0.15f }, }; -void +bool CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) { - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump); CColModel *colmodel = new CColModel; CColSphere *spheres = (CColSphere*)RwMalloc(NUMPEDINFONODES*sizeof(CColSphere)); - RwFrame *root = RpClumpGetFrame(m_clump); - RwMatrix *invmat = RwMatrixCreate(); - RwMatrix *mat = RwMatrixCreate(); - RwMatrixInvert(invmat, RwFrameGetMatrix(RpClumpGetFrame(clump))); for(int i = 0; i < NUMPEDINFONODES; i++){ - *mat = *invmat; - int id = ConvertPedNode2BoneTag(m_pColNodeInfos[i].pedNode); // this is wrong, wtf R* ??? - int idx = RpHAnimIDGetIndex(hier, id); - - // This doesn't really work as the positions are not initialized yet - RwMatrixTransform(mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT); - RwV3d pos = { 0.0f, 0.0f, 0.0f }; - RwV3dTransformPoints(&pos, &pos, 1, mat); - - spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); + spheres[i].center.x = 0.0f; + spheres[i].center.y = 0.0f; + spheres[i].center.z = 0.0f; spheres[i].radius = m_pColNodeInfos[i].radius; spheres[i].surface = SURFACE_PED; spheres[i].piece = m_pColNodeInfos[i].pieceType; } - RwMatrixDestroy(invmat); - RwMatrixDestroy(mat); colmodel->spheres = spheres; colmodel->numSpheres = NUMPEDINFONODES; colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f)); colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f)); colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; + return true; } CColModel* @@ -116,28 +111,27 @@ CPedModelInfo::AnimatePedColModelSkinned(RpClump *clump) { if(m_hitColModel == nil){ CreateHitColModelSkinned(clump); +#ifndef FIX_BUGS return m_hitColModel; +#endif + // we should really animate this now } - RwMatrix *invmat, *mat; + RwMatrix invmat, mat; CColSphere *spheres = m_hitColModel->spheres; RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump); - invmat = RwMatrixCreate(); - mat = RwMatrixCreate(); - RwMatrixInvert(invmat, RwFrameGetMatrix(RpClumpGetFrame(clump))); + RwMatrixInvert(&invmat, RwFrameGetMatrix(RpClumpGetFrame(clump))); for(int i = 0; i < NUMPEDINFONODES; i++){ - *mat = *invmat; + mat = invmat; int id = ConvertPedNode2BoneTag(m_pColNodeInfos[i].pedNode); int idx = RpHAnimIDGetIndex(hier, id); - RwMatrixTransform(mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT); - RwV3d pos = { 0.0f, 0.0f, 0.0f }; - RwV3dTransformPoints(&pos, &pos, 1, mat); + RwMatrixTransform(&mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT); + RwV3d pos = { 0.0f, 0.0f, 0.0f }; // actually CVector + RwV3dTransformPoints(&pos, &pos, 1, &mat); spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); } - RwMatrixDestroy(invmat); - RwMatrixDestroy(mat); return m_hitColModel; } @@ -155,10 +149,71 @@ CPedModelInfo::AnimatePedColModelSkinnedWorld(RpClump *clump) int idx = RpHAnimIDGetIndex(hier, id); mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; - RwV3d pos = { 0.0f, 0.0f, 0.0f }; + RwV3d pos = { 0.0f, 0.0f, 0.0f }; // actually CVector RwV3dTransformPoints(&pos, &pos, 1, mat); spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); } return m_hitColModel; } + + +struct PedChunk +{ + CColModel *colmodel; + RpClump *clump; +}; + +void +CPedModelInfo::LoadModel(void *data, const void *chunk) +{ + PedChunk *chk = (PedChunk*)data; + m_hitColModel = chk->colmodel; + CStreaming::RegisterPointer(&m_hitColModel, 2, true); + CClumpModelInfo::LoadModel(chk->clump, chunk); +} + +void +CPedModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + SetColModel(&gpTempColModels->ms_colModelPed1); + CClumpModelInfo::Write(writer); + if(m_hitColModel){ + writer.AddPatch(&m_hitColModel); + m_hitColModel->Write(writer, true); + } +} + +void* +CPedModelInfo::WriteModel(base::cRelocatableChunkWriter &writer) +{ + PedChunk *chunk = new PedChunk; // LEAK + chunk->colmodel = nil; + chunk->clump = nil; + writer.AllocateRaw(chunk, sizeof(*chunk), sizeof(void*), false, true); + + chunk->clump = (RpClump*)CClumpModelInfo::WriteModel(writer); + if(chunk->clump) + writer.AddPatch(&chunk->clump); + + chunk->colmodel = m_hitColModel; + if(chunk->colmodel){ + writer.AddPatch(&chunk->colmodel); + chunk->colmodel->Write(writer, true); + } + return nil; +} + +void +CPedModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CPedModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index 86e6b74a..7baa2bd8 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 { @@ -37,6 +38,8 @@ public: CColModel *m_hitColModel; int8 radio1, radio2; + static base::cRelocatableChunkClassInfo msClassInfo; + static CPedModelInfo msClassInstance; static RwObjectNameIdAssocation m_pPedIds[PED_NODE_MAX]; CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { m_hitColModel = nil; } @@ -44,7 +47,13 @@ public: void DeleteRwObject(void); void SetClump(RpClump *); - void CreateHitColModelSkinned(RpClump *clump); + virtual void LoadModel(void *model, const void *chunk); + virtual void Write(base::cRelocatableChunkWriter &writer); + virtual void *WriteModel(base::cRelocatableChunkWriter &writer); + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + + bool CreateHitColModelSkinned(RpClump *clump); CColModel *GetHitColModel(void) { return m_hitColModel; } CColModel *AnimatePedColModelSkinned(RpClump *clump); CColModel *AnimatePedColModelSkinnedWorld(RpClump *clump); diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index d584dada..8d0ea677 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -1,40 +1,61 @@ #include "common.h" +#include "main.h" #include "General.h" +#include "Renderer.h" #include "Camera.h" +#include "Renderer.h" #include "ModelInfo.h" #include "AnimManager.h" #include "custompipes.h" +#include "Streaming.h" +#include "smallHeap.h" +#include "Leeds.h" -//--MIAMI: file done +TempIdeData m_sTempIdeData[800]; -#define LOD_DISTANCE (300.0f) +base::cRelocatableChunkClassInfo CSimpleModelInfo::msClassInfo("CSimpleModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CSimpleModelInfo CSimpleModelInfo::msClassInstance; void CSimpleModelInfo::DeleteRwObject(void) { int i; RwFrame *f; - for(i = 0; i < m_numAtomics; i++) - if(m_atomics[i]){ - f = RpAtomicGetFrame(m_atomics[i]); - RpAtomicDestroy(m_atomics[i]); - RwFrameDestroy(f); - m_atomics[i] = nil; - RemoveTexDictionaryRef(); - if(GetAnimFileIndex() != -1) - CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); - } + if(m_atomics == nil) + return; + if(!gUseChunkFiles){ + for(i = 0; i < m_numAtomics; i++) + if(m_atomics[i]){ + f = RpAtomicGetFrame(m_atomics[i]); + RpAtomicDestroy(m_atomics[i]); + RwFrameDestroy(f); + m_atomics[i] = nil; + RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); + } + }else if(m_chunk){ + CStreaming::UnregisterPointer(&m_atomics, 2); + for(i = 0; i < m_numAtomics; i++) + CStreaming::UnregisterAtomic(m_atomics[i], nil); + DeleteChunk(); + RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); + } + m_atomics = nil; } RwObject* CSimpleModelInfo::CreateInstance(void) { RpAtomic *atomic; - if(m_atomics[0] == nil) + if(m_atomics == nil || m_atomics[0] == nil) return nil; atomic = RpAtomicClone(m_atomics[0]); RpAtomicSetFrame(atomic, RwFrameCreate()); + CStreaming::RegisterInstance(atomic, nil); return (RwObject*)atomic; } @@ -44,21 +65,20 @@ CSimpleModelInfo::CreateInstance(RwMatrix *matrix) RpAtomic *atomic; RwFrame *frame; - if(m_atomics[0] == nil) + if(m_atomics == nil || m_atomics[0] == nil) return nil; atomic = RpAtomicClone(m_atomics[0]); frame = RwFrameCreate(); *RwFrameGetMatrix(frame) = *matrix; RpAtomicSetFrame(atomic, frame); + CStreaming::RegisterInstance(atomic, nil); return (RwObject*)atomic; } void CSimpleModelInfo::Init(void) { - m_atomics[0] = nil; - m_atomics[1] = nil; - m_atomics[2] = nil; + m_atomics = new RpAtomic*[3]; m_numAtomics = 0; m_firstDamaged = 0; m_wetRoadReflection = 0; @@ -74,21 +94,30 @@ CSimpleModelInfo::Init(void) m_ignoreDrawDist = 0; m_isCodeGlass = 0; m_isArtistGlass = 0; + m_relatedModel = nil; } void CSimpleModelInfo::SetAtomic(int n, RpAtomic *atomic) { - AddTexDictionaryRef(); + if(m_atomics == nil){ + m_atomics = new RpAtomic*[3]; + m_atomics[0] = nil; + m_atomics[1] = nil; + m_atomics[2] = nil; + } m_atomics[n] = atomic; + AddTexDictionaryRef(); if(GetAnimFileIndex() != -1) CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); RpGeometry *geo = RpAtomicGetGeometry(atomic); if(m_ignoreLight) RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) & ~rpGEOMETRYLIGHT); +/* if(RpGeometryGetFlags(geo) & rpGEOMETRYNORMALS && RpGeometryGetNumTriangles(geo) > 200) debug("%s has %d polys\n", m_name, RpGeometryGetNumTriangles(geo)); +*/ #ifdef EXTENDED_PIPELINES if(m_wetRoadReflection) @@ -139,10 +168,46 @@ CSimpleModelInfo::GetLargestLodDistance(void) } RpAtomic* +CSimpleModelInfo::GetLodAtomic(int n) +{ + if(m_atomics == nil || n >= m_numAtomics) + return nil; + return m_atomics[n]; +} + +RpAtomic* +CSimpleModelInfo::GetLastAtomic(void) +{ + if(m_atomics == nil) + return nil; + if(m_firstDamaged == 0 || m_isDamaged) + return m_atomics[m_numAtomics-1]; + else + return m_atomics[m_firstDamaged-1]; +} + +RpAtomic* +CSimpleModelInfo::GetLastAtomic(float dist) +{ + int n; + if(m_atomics == nil) + return nil; + if(m_firstDamaged == 0 || m_isDamaged) + n = m_numAtomics-1; + else + n = m_firstDamaged-1; + if(dist < m_lodDistances[n] * TheCamera.LODDistMultiplier) + return m_atomics[n]; + return nil; +} + +RpAtomic* CSimpleModelInfo::GetAtomicFromDistance(float dist) { int i; i = 0; +// HACk until we figure out what's going on +if(m_atomics == nil) return nil; if(m_isDamaged) i = m_firstDamaged; for(; i < m_numAtomics; i++) @@ -154,20 +219,40 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist) RpAtomic* CSimpleModelInfo::GetFirstAtomicFromDistance(float dist) { +// HACk until we figure out what's going on +if(m_atomics == nil) return nil; if(dist < m_lodDistances[0] * TheCamera.LODDistMultiplier) return m_atomics[0]; return nil; } void -CSimpleModelInfo::FindRelatedModel(int32 minID, int32 maxID) +CSimpleModelInfo::FindRelatedModel(void) { - int i; CBaseModelInfo *mi; - for(i = minID; i <= maxID; i++){ - mi = CModelInfo::GetModelInfo(i); + int thisIndex, otherIndex; + + // find our own index in temp data + for(thisIndex = 0; thisIndex < ARRAY_SIZE(m_sTempIdeData); thisIndex++){ + if(m_sTempIdeData[thisIndex].id == -1) + break; + if(this == CModelInfo::GetModelInfo(m_sTempIdeData[thisIndex].id)) + goto found; + } + thisIndex = -1; +found: +#ifdef FIX_BUGS + if(thisIndex == -1) + return; +#endif + + for(otherIndex = 0; otherIndex < ARRAY_SIZE(m_sTempIdeData); otherIndex++){ + if(m_sTempIdeData[otherIndex].id == -1) + break; + + mi = CModelInfo::GetModelInfo(m_sTempIdeData[otherIndex].id); if(mi && mi != this && - !CGeneral::faststrcmp(GetModelName()+3, mi->GetModelName()+3)){ + !CGeneral::faststrcmp(m_sTempIdeData[thisIndex].name+3, m_sTempIdeData[otherIndex].name+3)){ assert(mi->IsSimple()); this->SetRelatedModel((CSimpleModelInfo*)mi); return; @@ -178,12 +263,14 @@ CSimpleModelInfo::FindRelatedModel(int32 minID, int32 maxID) #define NEAR_DRAW_DIST 100.0f // 0.0f in vice city void -CSimpleModelInfo::SetupBigBuilding(int32 minID, int32 maxID) +CSimpleModelInfo::SetupBigBuilding(void) { CSimpleModelInfo *related; - if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){ + if(m_lodDistances[0] < 0.0f) + m_lodDistances[0] = -m_lodDistances[0]; // what? + else if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){ m_isBigBuilding = 1; - FindRelatedModel(minID, maxID); + FindRelatedModel(); related = GetRelatedModel(); if(related){ m_lodDistances[2] = related->GetLargestLodDistance()/TheCamera.LODDistMultiplier; @@ -195,3 +282,79 @@ CSimpleModelInfo::SetupBigBuilding(int32 minID, int32 maxID) m_lodDistances[2] = NEAR_DRAW_DIST; } } + + +void +CSimpleModelInfo::LoadModel(void *atomics, const void *chunk) +{ + int i; + m_chunk = (void*)chunk; + m_atomics = (RpAtomic**)atomics; + CStreaming::RegisterPointer(m_chunk, 2, true); + CStreaming::RegisterPointer(m_atomics, 2, true); + for(i = 0; i < m_numAtomics; i++){ + LoadResource(m_atomics[i]); + CStreaming::RegisterAtomic(m_atomics[i], nil); + } +} + +void +CSimpleModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + CBaseModelInfo::Write(writer); + if(WriteModel(writer)) + writer.AddPatch(&m_atomics); + else + m_atomics = nil; + if(m_isBigBuilding) + writer.AddPatch(&m_relatedModel); +} + +void* +CSimpleModelInfo::WriteModel(base::cRelocatableChunkWriter &writer) +{ + int i; + if(m_atomics == nil || m_atomics[0] == nil) + return nil; + + // remove empty atomics + int numAtomics = 0; + for(i = 0; i < m_numAtomics; i++) + if(m_atomics[i]){ + m_atomics[numAtomics] = m_atomics[i]; +#ifdef FIX_BUGS + m_lodDistances[numAtomics] = m_lodDistances[i]; +#endif + numAtomics++; + } + if(m_firstDamaged){ + int firstDam = m_firstDamaged - m_numAtomics + numAtomics; + if(firstDam < numAtomics) + m_firstDamaged = firstDam; + else + m_firstDamaged = 0; + } + m_numAtomics = numAtomics; + + // write the actual models + writer.AllocateRaw(m_atomics, m_numAtomics*sizeof(void*), sizeof(void*), false, true); + for(i = 0; m_numAtomics; i++){ + writer.AddPatch(&m_atomics[i]); + SaveResource(m_atomics[i], writer); + } + return m_atomics; +} + +void +CSimpleModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), 0x10, false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CSimpleModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), 0x10, false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h index 986cb886..f9191944 100644 --- a/src/modelinfo/SimpleModelInfo.h +++ b/src/modelinfo/SimpleModelInfo.h @@ -2,11 +2,18 @@ #include "BaseModelInfo.h" +// For linking up models by name +struct TempIdeData +{ + char name[24]; + int16 id; +}; +extern TempIdeData m_sTempIdeData[800]; + class CSimpleModelInfo : public CBaseModelInfo { public: - // atomics[2] is often a pointer to the non-LOD modelinfo - RpAtomic *m_atomics[3]; + RpAtomic **m_atomics; // m_lodDistances[2] holds the near distance for LODs float m_lodDistances[3]; uint8 m_numAtomics; @@ -31,15 +38,26 @@ public: uint16 m_isCodeGlass : 1; uint16 m_isArtistGlass : 1; + CSimpleModelInfo *m_relatedModel; + + static base::cRelocatableChunkClassInfo msClassInfo; + static CSimpleModelInfo msClassInstance; + CSimpleModelInfo(void) : CBaseModelInfo(MITYPE_SIMPLE) {} CSimpleModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} ~CSimpleModelInfo() {} void DeleteRwObject(void); RwObject *CreateInstance(void); RwObject *CreateInstance(RwMatrix *); - RwObject *GetRwObject(void) { return (RwObject*)m_atomics[0]; } + RwObject *GetRwObject(void) { return m_atomics ? (RwObject*)m_atomics[0] : nil; } + + virtual void LoadModel(void *atomics, const void *chunk); + virtual void Write(base::cRelocatableChunkWriter &writer); + virtual void *WriteModel(base::cRelocatableChunkWriter &writer); + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); - virtual void SetAtomic(int n, RpAtomic *atomic); + /*virtual*/ void SetAtomic(int n, RpAtomic *atomic); void Init(void); void IncreaseAlpha(void); @@ -47,15 +65,18 @@ public: float GetLodDistance(int i); float GetNearDistance(void); float GetLargestLodDistance(void); + RpAtomic *GetLodAtomic(int n); + RpAtomic *GetLastAtomic(void); + RpAtomic *GetLastAtomic(float dist); RpAtomic *GetAtomicFromDistance(float dist); RpAtomic *GetFirstAtomicFromDistance(float dist); - void FindRelatedModel(int32 minID, int32 maxID); - void SetupBigBuilding(int32 minID, int32 maxID); + void FindRelatedModel(void); + void SetupBigBuilding(void); void SetNumAtomics(int n) { m_numAtomics = n; } CSimpleModelInfo *GetRelatedModel(void){ - return (CSimpleModelInfo*)m_atomics[2]; } + return m_relatedModel; } void SetRelatedModel(CSimpleModelInfo *m){ - m_atomics[2] = (RpAtomic*)m; } + m_relatedModel = m; } }; //static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error"); diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp index 0db5fb78..85b59e43 100644 --- a/src/modelinfo/TimeModelInfo.cpp +++ b/src/modelinfo/TimeModelInfo.cpp @@ -3,15 +3,20 @@ #include "Camera.h" #include "ModelInfo.h" #include "General.h" +#include "KeyGen.h" + +base::cRelocatableChunkClassInfo CTimeModelInfo::msClassInfo("CTimeModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CTimeModelInfo CTimeModelInfo::msClassInstance; + CTimeModelInfo* -CTimeModelInfo::FindOtherTimeModel(void) +CTimeModelInfo::FindOtherTimeModel(const char *modelname) { char name[40]; char *p; int i; - strcpy(name, GetModelName()); + strcpy(name, modelname); // change _nt to _dy if(p = strstr(name, "_nt")) strncpy(p, "_dy", 4); @@ -21,13 +26,29 @@ CTimeModelInfo::FindOtherTimeModel(void) else return nil; + uint32 nameKey = CKeyGen::GetUppercaseKey(name); + for(i = 0; i < MODELINFOSIZE; i++){ CBaseModelInfo *mi = CModelInfo::GetModelInfo(i); - if (mi && mi->GetModelType() == MITYPE_TIME && - !CGeneral::faststrncmp(name, mi->GetModelName(), MAX_MODEL_NAME)){ + if (mi && mi->GetModelType() == MITYPE_TIME && nameKey == mi->GetNameHashKey()){ m_otherTimeModelID = i; return (CTimeModelInfo*)mi; } } return nil; } + + +void +CTimeModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CTimeModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/TimeModelInfo.h b/src/modelinfo/TimeModelInfo.h index 6e3c64fb..67273b21 100644 --- a/src/modelinfo/TimeModelInfo.h +++ b/src/modelinfo/TimeModelInfo.h @@ -7,14 +7,21 @@ class CTimeModelInfo : public CSimpleModelInfo int32 m_timeOn; int32 m_timeOff; int32 m_otherTimeModelID; + + static base::cRelocatableChunkClassInfo msClassInfo; + static CTimeModelInfo msClassInstance; + public: CTimeModelInfo(void) : CSimpleModelInfo(MITYPE_TIME) { m_otherTimeModelID = -1; } + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + int32 GetTimeOn(void) { return m_timeOn; } int32 GetTimeOff(void) { return m_timeOff; } void SetTimes(int32 on, int32 off) { m_timeOn = on; m_timeOff = off; } int32 GetOtherTimeModel(void) { return m_otherTimeModelID; } void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; } - CTimeModelInfo *FindOtherTimeModel(void); + CTimeModelInfo *FindOtherTimeModel(const char *name); }; //static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error"); diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 4caacc7f..bd3a2154 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -1,6 +1,7 @@ #include "common.h" #include <rpmatfx.h> +#include "main.h" #include "RwHelper.h" #include "General.h" #include "NodeName.h" @@ -20,16 +21,21 @@ #include "ModelIndices.h" #include "ModelInfo.h" #include "custompipes.h" +#include "Streaming.h" +#include "Leeds.h" -//--MIAMI: done +base::cRelocatableChunkClassInfo CVehicleModelInfo::msClassInfo("CVehicleModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CVehicleModelInfo CVehicleModelInfo::msClassInstance; -int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 }; -int8 CVehicleModelInfo::ms_compsUsed[2]; -RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256]; -RwTexture *CVehicleModelInfo::ms_colourTextureTable[256]; +//int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 }; +//int8 CVehicleModelInfo::ms_compsUsed[2]; +//RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256]; +CVehicleModelInfo::Statics *CVehicleModelInfo::mspInfo; -RwTexture *gpWhiteTexture; -RwFrame *pMatFxIdentityFrame; +//RwTexture *CVehicleModelInfo::ms_colourTextureTable[256]; + +//RwTexture *gpWhiteTexture; +//RwFrame *pMatFxIdentityFrame; enum { VEHICLE_FLAG_COLLAPSE = 0x2, @@ -170,6 +176,29 @@ RwObjectNameIdAssocation *CVehicleModelInfo::ms_vehicleDescs[] = { bool gbBlackCars; bool gbPinkCars; +void +CVehicleModelInfo::Load(void *inst) +{ + if(inst) + mspInfo = (CVehicleModelInfo::Statics*)inst; + else{ + mspInfo = new CVehicleModelInfo::Statics; + memset(mspInfo, 0, sizeof(*mspInfo)); + mspInfo->ms_compsToUse[0] = -2; + mspInfo->ms_compsToUse[1] = -2; + } +} + +void* +CVehicleModelInfo::WriteStaticInfo(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(mspInfo, sizeof(*mspInfo), sizeof(void*), false, true); + if(mspInfo->unknown) + writer.AddPatch(&mspInfo->unknown); + return mspInfo; + +} + CVehicleModelInfo::CVehicleModelInfo(void) : CClumpModelInfo(MITYPE_VEHICLE) { @@ -180,7 +209,12 @@ CVehicleModelInfo::CVehicleModelInfo(void) m_positions[i].z = 0.0f; } m_numColours = 0; + CClumpModelInfo::m_animFileIndex = -1; + + memset(m_materials1, 0, sizeof(m_materials1)); + memset(m_materials2, 0, sizeof(m_materials2)); m_animFileIndex = -1; + m_normalSplay = 0.3f; } void @@ -189,16 +223,78 @@ CVehicleModelInfo::DeleteRwObject(void) int32 i; RwFrame *f; - for(i = 0; i < m_numComps; i++){ - f = RpAtomicGetFrame(m_comps[i]); - RpAtomicDestroy(m_comps[i]); - RwFrameDestroy(f); + if(!gUseChunkFiles){ + for(i = 0; i < m_numComps; i++){ + f = RpAtomicGetFrame(m_comps[i]); + RpAtomicDestroy(m_comps[i]); + RwFrameDestroy(f); + } +#ifdef FIX_BUGS + delete[] m_comps; + m_comps = nil; +#endif + m_numComps = 0; } - m_numComps = 0; + + RemoveWheels(); + + for(i = 0; i < ARRAY_SIZE(m_materials1); i++) + CStreaming::UnregisterPointer(&m_materials1[i], 2); + for(i = 0; i < ARRAY_SIZE(m_materials2); i++) + CStreaming::UnregisterPointer(&m_materials2[i], 2); + + if(m_numComps > 0){ + CStreaming::UnregisterPointer(&m_comps, 2); + for(i = 0; i < m_numComps; i++) + CStreaming::UnregisterAtomic(m_comps[i], nil); + m_comps = nil; + } + CClumpModelInfo::DeleteRwObject(); } RwObject* +RemoveWheelCB(RwObject *object, void *arg) +{ + RpAtomic *atomic = (RpAtomic*)object; + if(RwObjectGetType(object) == rpATOMIC){ + RpClumpRemoveAtomic((RpClump*)arg, atomic); +#ifdef LIBRW + CStreaming::UnregisterPointer(&atomic->inClump.next, 2); + CStreaming::UnregisterPointer(&atomic->inClump.prev, 2); + CStreaming::UnregisterPointer(&atomic->object.object.parent, 2); + CStreaming::UnregisterPointer(&atomic->object.inFrame.next, 2); + CStreaming::UnregisterPointer(&atomic->object.inFrame.prev, 2); + CStreaming::UnregisterPointer(&atomic->clump, 2); +#endif + RpAtomicDestroy(atomic); + } + return object; +} + +void +CVehicleModelInfo::RemoveWheels(void) +{ +#ifdef FIX_BUGS + if(m_clump == nil) + return; +#endif + RwObjectNameIdAssocation *desc = ms_vehicleDescs[m_vehicleType]; + for(int i = 0; desc[i].name; i++){ + RwObjectIdAssociation assoc; + + if(desc[i].flags & (VEHICLE_FLAG_COMP|VEHICLE_FLAG_POS)) + continue; + assoc.frame = nil; + assoc.id = desc[i].hierId; + RwFrameForAllChildren(RpClumpGetFrame(m_clump), + FindFrameFromIdCB, &assoc); + if(assoc.frame && desc[i].flags & VEHICLE_FLAG_ADD_WHEEL && m_wheelId != -1) + RwFrameForAllObjects(assoc.frame, RemoveWheelCB, m_clump); + } +} + +RwObject* CVehicleModelInfo::CreateInstance(void) { RpClump *clump; @@ -207,7 +303,7 @@ CVehicleModelInfo::CreateInstance(void) int32 comp1, comp2; clump = (RpClump*)CClumpModelInfo::CreateInstance(); - if(m_numComps != 0){ + if(clump && m_numComps != 0 && strcmp(m_gameName, "POLICAR") != 0){ clumpframe = RpClumpGetFrame(clump); comp1 = ChooseComponent(); @@ -221,7 +317,7 @@ CVehicleModelInfo::CreateInstance(void) RpClumpAddAtomic(clump, atomic); RwFrameAddChild(clumpframe, f); } - ms_compsUsed[0] = comp1; + mspInfo->ms_compsUsed[0] = comp1; comp2 = ChooseSecondComponent(); if(comp2 != -1 && m_comps[comp2]){ @@ -234,18 +330,27 @@ CVehicleModelInfo::CreateInstance(void) RpClumpAddAtomic(clump, atomic); RwFrameAddChild(clumpframe, f); } - ms_compsUsed[1] = comp2; + mspInfo->ms_compsUsed[1] = comp2; }else{ - ms_compsUsed[0] = -1; - ms_compsUsed[1] = -1; + mspInfo->ms_compsUsed[0] = -1; + mspInfo->ms_compsUsed[1] = -1; } + CStreaming::RegisterInstance(clump); return (RwObject*)clump; } +RpAtomic* +SplayNormals(RpAtomic *atomic, void *arg) +{ + // PSP only? + return atomic; +} + void CVehicleModelInfo::SetClump(RpClump *clump) { CClumpModelInfo::SetClump(clump); + RpClumpForAllAtomics((RpClump*)GetRwObject(), SplayNormals, this); SetAtomicRenderCallbacks(); SetFrameIds(ms_vehicleDescs[m_vehicleType]); PreprocessHierarchy(); @@ -341,7 +446,7 @@ CVehicleModelInfo::SetAtomicRendererCB(RpAtomic *atomic, void *data) }else if(strstr(name, "_lo")){ RpClumpRemoveAtomic(clump, atomic); RpAtomicDestroy(atomic); - return atomic; // BUG: not done by gta + return atomic; // BUG: nil in gta }else if(strstr(name, "_vlo")) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB); else @@ -400,6 +505,33 @@ CVehicleModelInfo::SetAtomicRendererCB_Train(RpAtomic *atomic, void *data) } RpAtomic* +CVehicleModelInfo::SetAtomicRendererCB_Ferry(RpAtomic *atomic, void *data) +{ + char *name; + bool alpha; + + name = GetFrameNodeName(RpAtomicGetFrame(atomic)); + alpha = false; + RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha); + if(strstr(name, "_hi")){ + if(alpha) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderTrainHiDetailAlphaCB); + else + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderTrainHiDetailCB); + }else if(strstr(name, "_lo")){ + if(alpha) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle); + else + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle); + }else if(strstr(name, "_vlo")) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle); + else + CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); + HideDamagedAtomicCB(atomic, nil); + return atomic; +} + +RpAtomic* CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data) { RpClump *clump; @@ -416,7 +548,31 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data) RpAtomicDestroy(atomic); return atomic; // BUG: not done by gta }else if(strstr(name, "_vlo")) - CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLoDetailCB_Boat); + else + CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); + HideDamagedAtomicCB(atomic, nil); + return atomic; +} + +RpAtomic* +CVehicleModelInfo::SetAtomicRendererCB_Boat_Far(RpAtomic *atomic, void *data) +{ + RpClump *clump; + char *name; + + clump = (RpClump*)data; + name = GetFrameNodeName(RpAtomicGetFrame(atomic)); + if(strcmp(name, "boat_hi") == 0 || !CGeneral::faststrncmp(name, "extra", 5)) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far); + else if(strstr(name, "_hi")) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB); + else if(strstr(name, "_lo")){ + RpClumpRemoveAtomic(clump, atomic); + RpAtomicDestroy(atomic); + return atomic; // BUG: not done by gta + }else if(strstr(name, "_vlo")) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far); else CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); HideDamagedAtomicCB(atomic, nil); @@ -426,6 +582,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data) RpAtomic* CVehicleModelInfo::SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data) { +/* // LCS: gone, may be better to keep it though char *name; name = GetFrameNodeName(RpAtomicGetFrame(atomic)); @@ -434,6 +591,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data) else if(strncmp(name, "rearrotor", 9) == 0) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleTailRotorAlphaCB); else +*/ CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); return atomic; } @@ -461,7 +619,7 @@ CVehicleModelInfo::SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data) }else if(strstr(name, "_lo")){ RpClumpRemoveAtomic(clump, atomic); RpAtomicDestroy(atomic); - return atomic; // BUG: not done by gta + return atomic; // BUG: nil in gta }else if(strstr(name, "_vlo")) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB); else @@ -478,13 +636,18 @@ CVehicleModelInfo::SetAtomicRenderCallbacks(void) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Train, nil); else #endif - if(m_vehicleType == VEHICLE_TYPE_HELI) + if(m_vehicleType == VEHICLE_TYPE_FERRY) + RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Ferry, nil); + else if(m_vehicleType == VEHICLE_TYPE_HELI) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Heli, nil); else if(m_vehicleType == VEHICLE_TYPE_PLANE) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_BigVehicle, nil); - else if(m_vehicleType == VEHICLE_TYPE_BOAT) - RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat, m_clump); - else if(mod_HandlingManager.GetHandlingData((tVehicleType)m_handlingId)->Flags & HANDLING_IS_HELI) + else if(m_vehicleType == VEHICLE_TYPE_BOAT){ + if(strcmp(m_gameName, "REEFER") == 0) + RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat_Far, m_clump); + else + RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat, m_clump); + }else if(mod_HandlingManager.GetHandlingData((tVehicleType)m_handlingId)->Flags & HANDLING_IS_HELI) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_RealHeli, m_clump); else RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, m_clump); @@ -532,6 +695,8 @@ CVehicleModelInfo::PreprocessHierarchy(void) m_numDoors = 0; m_numComps = 0; + m_comps = new RpAtomic*[7]; + for(i = 0; desc[i].name; i++){ RwObjectNameAssociation assoc; @@ -589,21 +754,23 @@ CVehicleModelInfo::PreprocessHierarchy(void) SetVehicleComponentFlags(assoc.frame, desc[i].flags); - if(desc[i].flags & VEHICLE_FLAG_ADD_WHEEL){ - if(m_wheelId == -1) - RwFrameDestroy(assoc.frame); - else{ - RwV3d scale; - atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance(); - RwFrameDestroy(RpAtomicGetFrame(atomic)); - RpAtomicSetFrame(atomic, assoc.frame); - RpClumpAddAtomic(m_clump, atomic); - CVisibilityPlugins::SetAtomicRenderCallback(atomic, - CVisibilityPlugins::RenderWheelAtomicCB); - scale.x = m_wheelScale; - scale.y = m_wheelScale; - scale.z = m_wheelScale; - RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT); + if(!(gMakeResources && gUseResources)){ + if(desc[i].flags & VEHICLE_FLAG_ADD_WHEEL){ + if(m_wheelId == -1) + RwFrameDestroy(assoc.frame); + else{ + RwV3d scale; + atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance(); + RwFrameDestroy(RpAtomicGetFrame(atomic)); + RpAtomicSetFrame(atomic, assoc.frame); + RpClumpAddAtomic(m_clump, atomic); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, + CVisibilityPlugins::RenderWheelAtomicCB); + scale.x = m_wheelScale; + scale.y = m_wheelScale; + scale.z = m_wheelScale; + RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT); + } } } } @@ -631,9 +798,9 @@ CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags) SETFLAGS(ATOMIC_FLAG_FRONT); else if(flags & VEHICLE_FLAG_REAR && (handling->Flags & HANDLING_IS_VAN || (flags & (VEHICLE_FLAG_LEFT|VEHICLE_FLAG_RIGHT)) == 0)) SETFLAGS(ATOMIC_FLAG_REAR); - if(flags & VEHICLE_FLAG_LEFT) + else if(flags & VEHICLE_FLAG_LEFT) SETFLAGS(ATOMIC_FLAG_LEFT); - if(flags & VEHICLE_FLAG_RIGHT) + else if(flags & VEHICLE_FLAG_RIGHT) SETFLAGS(ATOMIC_FLAG_RIGHT); if(flags & VEHICLE_FLAG_REARDOOR) @@ -748,7 +915,7 @@ CVehicleModelInfo::ChooseComponent(void) int32 n; comp = -1; - if(ms_compsToUse[0] == -2){ + if(mspInfo->ms_compsToUse[0] == -2){ if(COMPRULE_RULE(m_compRules) && IsValidCompRule(COMPRULE_RULE(m_compRules))) comp = ::ChooseComponent(COMPRULE_RULE(m_compRules), COMPRULE_COMPS(m_compRules)); else if(CGeneral::GetRandomNumberInRange(0, 3) < 2){ @@ -757,8 +924,8 @@ CVehicleModelInfo::ChooseComponent(void) comp = comps[(int)CGeneral::GetRandomNumberInRange(0, n)]; } }else{ - comp = ms_compsToUse[0]; - ms_compsToUse[0] = -2; + comp = mspInfo->ms_compsToUse[0]; + mspInfo->ms_compsToUse[0] = -2; } return comp; } @@ -771,7 +938,7 @@ CVehicleModelInfo::ChooseSecondComponent(void) int32 n; comp = -1; - if(ms_compsToUse[1] == -2){ + if(mspInfo->ms_compsToUse[1] == -2){ if(COMPRULE2_RULE(m_compRules) && IsValidCompRule(COMPRULE2_RULE(m_compRules))) comp = ::ChooseComponent(COMPRULE2_RULE(m_compRules), COMPRULE2_COMPS(m_compRules)); else if(COMPRULE_RULE(m_compRules) && IsValidCompRule(COMPRULE_RULE(m_compRules)) && @@ -782,8 +949,8 @@ CVehicleModelInfo::ChooseSecondComponent(void) comp = comps[(int)CGeneral::GetRandomNumberInRange(0, n)]; } }else{ - comp = ms_compsToUse[1]; - ms_compsToUse[1] = -2; + comp = mspInfo->ms_compsToUse[1]; + mspInfo->ms_compsToUse[1] = -2; } return comp; } @@ -798,7 +965,7 @@ struct editableMatCBData RpMaterial* CVehicleModelInfo::GetEditableMaterialListCB(RpMaterial *material, void *data) { - static RwRGBA white = { 255, 255, 255, 255 }; + RwRGBA white = { 255, 255, 255, 255 }; const RwRGBA *col; editableMatCBData *cbdata; @@ -851,7 +1018,7 @@ CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2) RpMaterial **matp; if(c1 != m_currentColour1){ - col = ms_vehicleColourTable[c1]; + col = mspInfo->ms_vehicleColourTable[c1]; for(matp = m_materials1; *matp; matp++){ colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const colp->red = col.red; @@ -862,7 +1029,7 @@ CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2) } if(c2 != m_currentColour2){ - col = ms_vehicleColourTable[c2]; + col = mspInfo->ms_vehicleColourTable[c2]; for(matp = m_materials2; *matp; matp++){ colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const colp->red = col.red; @@ -924,7 +1091,7 @@ CVehicleModelInfo::AvoidSameVehicleColour(uint8 *col1, uint8 *col2) } } -//--MIAMI: unused +// unused RwTexture* CreateCarColourTexture(uint8 r, uint8 g, uint8 b) { @@ -987,8 +1154,8 @@ CVehicleModelInfo::LoadVehicleColours(void) fd = CFileMgr::OpenFile("CARCOLS.DAT", "r"); CFileMgr::ChangeDir("\\"); - for(i = 0; i < 256; i++) - ms_colourTextureTable[i] = nil; + //for(i = 0; i < 256; i++) + // ms_colourTextureTable[i] = nil; section = 0; numCols = 0; @@ -1020,10 +1187,10 @@ CVehicleModelInfo::LoadVehicleColours(void) }else if(section == COLOURS){ sscanf(&line[start], // BUG: games doesn't add start "%d %d %d", &r, &g, &b); - ms_vehicleColourTable[numCols].red = r; - ms_vehicleColourTable[numCols].green = g; - ms_vehicleColourTable[numCols].blue = b; - ms_vehicleColourTable[numCols].alpha = 0xFF; + mspInfo->ms_vehicleColourTable[numCols].red = r; + mspInfo->ms_vehicleColourTable[numCols].green = g; + mspInfo->ms_vehicleColourTable[numCols].blue = b; + mspInfo->ms_vehicleColourTable[numCols].alpha = 0xFF; numCols++; }else if(section == CARS){ n = sscanf(&line[start], // BUG: games doesn't add start @@ -1053,6 +1220,7 @@ CVehicleModelInfo::LoadVehicleColours(void) void CVehicleModelInfo::DeleteVehicleColourTextures(void) { +/* int i; for(i = 0; i < 256; i++){ @@ -1061,6 +1229,7 @@ CVehicleModelInfo::DeleteVehicleColourTextures(void) ms_colourTextureTable[i] = nil; } } +*/ } RpMaterial* @@ -1072,6 +1241,7 @@ CVehicleModelInfo::GetMatFXEffectMaterialCB(RpMaterial *material, void *data) return nil; } +/* RpMaterial* CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data) { @@ -1088,7 +1258,9 @@ CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data) } return material; } +*/ +/* RpAtomic* CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data) { @@ -1104,6 +1276,7 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data) } return atomic; } +*/ void CVehicleModelInfo::SetEnvironmentMap(void) @@ -1180,10 +1353,162 @@ CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(int id) } if(n == 0) - return id == MI_RCBANDIT || id == MI_PIZZABOY || id == MI_BAGGAGE ? 0 : 1; + return id == MI_RCBANDIT /*|| id == MI_PIZZABOY || id == MI_BAGGAGE*/ ? 0 : 1; if(id == MI_COACH) return 8; return n - 1; } + + +struct VehicleChunk +{ + RpClump *clump; + int32 numComps; + RpAtomic **comp; + RpMaterial *materials1[NUM_FIRST_MATERIALS]; + RpMaterial *materials2[NUM_SECOND_MATERIALS]; +}; + +void +CVehicleModelInfo::LoadModel(void *data, const void *chunk) +{ + int i; + VehicleChunk *chk = (VehicleChunk*)data; + CClumpModelInfo::LoadModel(chk->clump, chunk); + + // editable materials + for(i = 0; i < NUM_FIRST_MATERIALS; i++){ + m_materials1[i] = chk->materials1[i]; + if(m_materials1[i]) + CStreaming::RegisterPointer(&m_materials1[i], 2, true); + } + for(i = 0; i < NUM_SECOND_MATERIALS; i++){ + m_materials2[i] = chk->materials2[i]; + if(m_materials2[i]) + CStreaming::RegisterPointer(&m_materials2[i], 2, true); + } + + // extra components + m_numComps = chk->numComps; + if(m_numComps > 0){ + m_comps = chk->comp; + CStreaming::RegisterPointer(&m_comps, 2, true); + for(i = 0; i < m_numComps; i++){ + LoadResource(m_comps[i]); + CStreaming::RegisterAtomic(m_comps[i], nil); + } + }else + m_comps = nil; + + m_currentColour1 = -1; + m_currentColour2 = -1; + + // add wheels + RwObjectNameIdAssocation *desc = ms_vehicleDescs[m_vehicleType]; + for(i = 0; desc[i].name; i++){ + RwObjectIdAssociation assoc; + + if(desc[i].flags & (VEHICLE_FLAG_COMP|VEHICLE_FLAG_POS)) + continue; + assoc.frame = nil; + assoc.id = desc[i].hierId; + RwFrameForAllChildren(RpClumpGetFrame(m_clump), + FindFrameFromIdCB, &assoc); + if(assoc.frame && desc[i].flags & VEHICLE_FLAG_ADD_WHEEL && m_wheelId != -1){ + RwV3d scale; + RpAtomic *atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance(); + RwFrameDestroy(RpAtomicGetFrame(atomic)); + RpAtomicSetFrame(atomic, assoc.frame); + RpClumpAddAtomic(m_clump, atomic); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, + CVisibilityPlugins::RenderWheelAtomicCB); + scale.x = m_wheelScale; + scale.y = m_wheelScale; + scale.z = m_wheelScale; + RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT); +#ifdef LIBRW + CStreaming::RegisterPointer(&atomic->inClump.next, 2, true); + CStreaming::RegisterPointer(&atomic->inClump.prev, 2, true); + CStreaming::RegisterPointer(&atomic->object.object.parent, 2, true); + CStreaming::RegisterPointer(&atomic->object.inFrame.next, 2, true); + CStreaming::RegisterPointer(&atomic->object.inFrame.prev, 2, true); + CStreaming::RegisterPointer(&atomic->clump, 2, true); +#endif + } + } +} + +void +CVehicleModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + CClumpModelInfo::Write(writer); +} + +void* +CVehicleModelInfo::WriteModel(base::cRelocatableChunkWriter &writer) +{ + if(GetRwObject() == nil) + return nil; + + int i; + VehicleChunk *chk = new VehicleChunk; + memset(chk, 0, sizeof(*chk)); + writer.AllocateRaw(chk, sizeof(*chk), sizeof(void*), false, true); + + // clump + chk->clump = (RpClump*)CClumpModelInfo::WriteModel(writer); + if(chk->clump) + writer.AddPatch(&chk->clump); + + // materials + for(i = 0; i < NUM_FIRST_MATERIALS; i++){ + if(m_materials1[i] == nil || m_vehicleType == VEHICLE_TYPE_FERRY) + chk->materials1[i] = nil; + else{ + SaveResource(m_materials1[i], writer); + chk->materials1[i] = m_materials1[i]; + writer.AddPatch(&chk->materials1[i]); + } + } + for(i = 0; i < NUM_SECOND_MATERIALS; i++){ + if(m_materials2[i] == nil || m_vehicleType == VEHICLE_TYPE_FERRY) + chk->materials2[i] = nil; + else{ + SaveResource(m_materials2[i], writer); + chk->materials2[i] = m_materials2[i]; + writer.AddPatch(&chk->materials2[i]); + } + } + + // extra components + chk->numComps = m_numComps; + chk->comp = nil; + if(m_numComps > 0){ + chk->comp = m_comps; + writer.AddPatch(&chk->comp); + + writer.AllocateRaw(m_comps, m_numComps*sizeof(void*), sizeof(void*), false, true); + for(i = 0; i < m_numComps; i++) + if(m_comps[i]){ + SaveResource(m_comps[i], writer); + writer.AddPatch(&m_comps[i]); + } + } + return chk; +} + +void +CVehicleModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CVehicleModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index f9217a41..f979c2c0 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -98,19 +98,30 @@ public: uint8 m_lastColorVariation; uint8 m_currentColour1; uint8 m_currentColour2; - RpAtomic *m_comps[6]; // LCS(TODO): pointer + RpAtomic **m_comps; + float m_normalSplay; // This is stupid, CClumpModelInfo already has it! union { int32 m_animFileIndex; char *m_animFileName; }; - static int8 ms_compsToUse[2]; - static int8 ms_compsUsed[2]; - static RwRGBA ms_vehicleColourTable[256]; - static RwTexture *ms_colourTextureTable[256]; + static base::cRelocatableChunkClassInfo msClassInfo; + static CVehicleModelInfo msClassInstance; + + struct Statics { + void *unknown; // unused too it seems + RwRGBA ms_vehicleColourTable[256]; + int8 ms_compsUsed[2]; + int8 ms_compsToUse[2]; + }; + //static RwTexture *ms_colourTextureTable[256]; + static Statics *mspInfo; static RwObjectNameIdAssocation *ms_vehicleDescs[NUM_VEHICLE_TYPES]; + static void Load(void *inst); + static void *WriteStaticInfo(base::cRelocatableChunkWriter &writer); + CVehicleModelInfo(void); void DeleteRwObject(void); RwObject *CreateInstance(void); @@ -119,6 +130,12 @@ public: void ConvertAnimFileIndex(void); int GetAnimFileIndex(void) { return m_animFileIndex; } + virtual void LoadModel(void *model, const void *chunk); + virtual void Write(base::cRelocatableChunkWriter &writer); + virtual void *WriteModel(base::cRelocatableChunkWriter &writer); + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + static RwFrame *CollapseFramesCB(RwFrame *frame, void *data); static RwObject *MoveObjectsCB(RwObject *object, void *data); static RpAtomic *HideDamagedAtomicCB(RpAtomic *atomic, void *data); @@ -128,13 +145,16 @@ public: static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); static RpAtomic *SetAtomicRendererCB_BigVehicle(RpAtomic *atomic, void *data); static RpAtomic *SetAtomicRendererCB_Train(RpAtomic *atomic, void *data); + static RpAtomic *SetAtomicRendererCB_Ferry(RpAtomic *atomic, void *data); static RpAtomic *SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data); + static RpAtomic *SetAtomicRendererCB_Boat_Far(RpAtomic *atomic, void *data); static RpAtomic *SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data); static RpAtomic *SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data); void SetAtomicRenderCallbacks(void); static RwObject *SetAtomicFlagCB(RwObject *object, void *data); static RwObject *ClearAtomicFlagCB(RwObject *atomic, void *data); + void RemoveWheels(void); void SetVehicleComponentFlags(RwFrame *frame, uint32 flags); void PreprocessHierarchy(void); void GetWheelPosn(int32 n, CVector &pos); @@ -160,7 +180,7 @@ public: static void ShutdownEnvironmentMaps(void); static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id); - static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; } + static void SetComponentsToUse(int8 c1, int8 c2) { mspInfo->ms_compsToUse[0] = c1; mspInfo->ms_compsToUse[1] = c2; } }; extern bool gbBlackCars; diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp index bd8f5cb8..1d194ec4 100644 --- a/src/modelinfo/WeaponModelInfo.cpp +++ b/src/modelinfo/WeaponModelInfo.cpp @@ -4,7 +4,8 @@ #include "AnimManager.h" #include "VisibilityPlugins.h" -//--MIAMI: file done +base::cRelocatableChunkClassInfo CWeaponModelInfo::msClassInfo("CWeaponModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CWeaponModelInfo CWeaponModelInfo::msClassInstance; void CWeaponModelInfo::SetAnimFile(const char *file) @@ -37,19 +38,34 @@ CWeaponModelInfo::Init(void) void CWeaponModelInfo::SetWeaponInfo(int32 weaponId) { - m_atomics[2] = (RpAtomic*)weaponId; + m_relatedModel = (CSimpleModelInfo*)weaponId; } eWeaponType CWeaponModelInfo::GetWeaponInfo(void) { - return (eWeaponType)(uintptr)m_atomics[2]; + return (eWeaponType)(uintptr)m_relatedModel; } +/* void CWeaponModelInfo::SetAtomic(int n, RpAtomic *atomic) { CSimpleModelInfo::SetAtomic(n, atomic); CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderWeaponCB); } +*/ +void +CWeaponModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CWeaponModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/WeaponModelInfo.h b/src/modelinfo/WeaponModelInfo.h index 548bf8a6..8dc9baf1 100644 --- a/src/modelinfo/WeaponModelInfo.h +++ b/src/modelinfo/WeaponModelInfo.h @@ -9,13 +9,21 @@ class CWeaponModelInfo : public CSimpleModelInfo int32 m_animFileIndex; char *m_animFileName; }; + + static base::cRelocatableChunkClassInfo msClassInfo; + static CWeaponModelInfo msClassInstance; + public: CWeaponModelInfo(void) : CSimpleModelInfo(MITYPE_WEAPON) { m_animFileIndex = -1; } virtual void SetAnimFile(const char *file); virtual void ConvertAnimFileIndex(void); virtual int GetAnimFileIndex(void) { return m_animFileIndex; } - virtual void SetAtomic(int n, RpAtomic *atomic); + + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + + //virtual void SetAtomic(int n, RpAtomic *atomic); void Init(void); void SetWeaponInfo(int32 weaponId); diff --git a/src/objects/DummyObject.cpp b/src/objects/DummyObject.cpp index 8656abbb..8dd1643d 100644 --- a/src/objects/DummyObject.cpp +++ b/src/objects/DummyObject.cpp @@ -3,8 +3,6 @@ #include "DummyObject.h" #include "Pools.h" -// --MIAMI: file done - CDummyObject::CDummyObject(CObject *obj) { SetModelIndexNoCreate(obj->GetModelIndex()); diff --git a/src/objects/ObjectData.cpp b/src/objects/ObjectData.cpp index 04ac0b9c..8b23f0ae 100644 --- a/src/objects/ObjectData.cpp +++ b/src/objects/ObjectData.cpp @@ -6,8 +6,6 @@ #include "FileMgr.h" #include "ObjectData.h" -//--MIAMI: file done - CObjectInfo CObjectData::ms_aObjectInfo[NUMOBJECTINFO]; // Another ugly file reader diff --git a/src/objects/Projectile.cpp b/src/objects/Projectile.cpp index fc4b25cf..fe8b0c68 100644 --- a/src/objects/Projectile.cpp +++ b/src/objects/Projectile.cpp @@ -2,8 +2,6 @@ #include "Projectile.h" -// --MIAMI: file done - CProjectile::CProjectile(int32 model) : CObject() { m_fMass = 1.0f; diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 079024f6..f3511366 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -18,8 +18,6 @@ #include <float.h> #endif -// --MIAMI: file done - CCivilianPed::CCivilianPed(ePedType pedtype, uint32 mi) : CPed(pedtype) { SetModelIndex(mi); @@ -420,7 +418,6 @@ CCivilianPed::ProcessControl(void) Avoid(); } -// --MIAMI: Done bool CPed::RunToReportCrime(eCrimeType crimeToReport) { diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 762c7f1a..9d22c98c 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -20,8 +20,6 @@ #include "Ropes.h" #include "Stinger.h" -// --MIAMI: file done except TODOs - CCopPed::CCopPed(eCopType copType, int32 modifier) : CPed(PEDTYPE_COP) { m_nCopType = copType; @@ -196,7 +194,7 @@ CCopPed::ClearPursuit(void) m_bZoneDisabled = false; ClearObjective(); if (IsPedInControl()) { - if (!m_pMyVehicle || wanted->m_nWantedLevel != 0) { + if (!m_pMyVehicle || wanted->GetWantedLevel() != 0) { if (m_pMyVehicle && (m_pMyVehicle->GetPosition() - GetPosition()).MagnitudeSqr() < sq(5.0f)) { m_nLastPedState = PED_IDLE; SetSeek((CEntity*)m_pMyVehicle, 2.5f); @@ -295,7 +293,7 @@ CCopPed::ScanForCrimes(void) if (!m_bIsInPursuit) { CPlayerPed *player = FindPlayerPed(); if ((m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) - && player->m_pWanted->m_nWantedLevel == 0) { + && player->m_pWanted->GetWantedLevel() == 0) { if (player->m_pMyVehicle #ifdef FIX_BUGS @@ -311,7 +309,7 @@ void CCopPed::CopAI(void) { CWanted *wanted = FindPlayerPed()->m_pWanted; - int wantedLevel = wanted->m_nWantedLevel; + int wantedLevel = wanted->GetWantedLevel(); CPhysical *playerOrHisVeh = FindPlayerVehicle() ? (CPhysical*)FindPlayerVehicle() : (CPhysical*)FindPlayerPed(); if (wanted->m_bIgnoredByEveryone || wanted->m_bIgnoredByCops) { diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index 2eabfe04..62b70d7d 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -9,8 +9,6 @@ #include "CarCtrl.h" #include "Accident.h" -// --MIAMI: file done - CEmergencyPed::CEmergencyPed(uint32 type) : CPed(type) { switch (type){ diff --git a/src/peds/Gangs.cpp b/src/peds/Gangs.cpp index 7e120af9..e6de0770 100644 --- a/src/peds/Gangs.cpp +++ b/src/peds/Gangs.cpp @@ -6,8 +6,6 @@ #include "Streaming.h" #include "Weapon.h" -// --MIAMI: file done - CGangInfo CGangs::Gang[NUM_GANGS]; bool CGangs::GangAttackWithCops[NUM_GANGS]; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 8be58d66..1009a9b4 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -38,8 +38,7 @@ #include "WindModifiers.h" #include "CutsceneShadow.h" #include "Clock.h" - -// --MIAMI: file done +#include "Wanted.h" CPed *gapTempPedList[50]; uint16 gnNumTempPedList; @@ -61,7 +60,6 @@ void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete(( float gfTommyFatness = 1.0f; -// --MIAMI: Done CPed::CPed(uint32 pedType) : m_pedIK(this) { #ifdef USE_CUTSCENE_SHADOW_FOR_PED @@ -370,7 +368,6 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_lastComment = UINT32_MAX; } -// --MIAMI: Done CPed::~CPed(void) { #ifdef USE_CUTSCENE_SHADOW_FOR_PED @@ -407,7 +404,6 @@ CPed::~CPed(void) DMAudio.DestroyEntity(m_audioEntityId); } -// --MIAMI: Done void CPed::Initialise(void) { @@ -418,7 +414,6 @@ CPed::Initialise(void) debug("CPed ready\n"); } -// --MIAMI: Done void CPed::SetModelIndex(uint32 mi) { @@ -450,21 +445,18 @@ CPed::SetModelIndex(uint32 mi) #endif } -// --MIAMI: Done void CPed::SetPedStats(ePedStats pedStat) { m_pedStats = CPedStats::ms_apPedStats[pedStat]; } -// --MIAMI: Done void CPed::DeleteRwObject() { CEntity::DeleteRwObject(); } -// --MIAMI: Done void CPed::BuildPedLists(void) { @@ -540,7 +532,6 @@ CPed::BuildPedLists(void) } } -// --MIAMI: Done bool CPed::OurPedCanSeeThisOne(CEntity *target, bool shootablesDoBlock) { @@ -562,7 +553,6 @@ CPed::OurPedCanSeeThisOne(CEntity *target, bool shootablesDoBlock) colpoint, ent, true, false, false, shootablesDoBlock, false, false, false, shootablesDoBlock); } -// --MIAMI: Done // Some kind of binary sort void CPed::SortPeds(CPed **list, int min, int max) @@ -600,14 +590,12 @@ CPed::SortPeds(CPed **list, int min, int max) SortPeds(list, right, max); } -// --MIAMI: Done void CPed::SetMoveState(eMoveState state) { m_nMoveState = state; } -// --MIAMI: Done void CPed::SetMoveAnim(void) { @@ -721,7 +709,6 @@ CPed::SetMoveAnim(void) } } -// --MIAMI: Done void CPed::StopNonPartialAnims(void) { @@ -733,7 +720,6 @@ CPed::StopNonPartialAnims(void) } } -// --MIAMI: Done void CPed::RestartNonPartialAnims(void) { @@ -745,7 +731,6 @@ CPed::RestartNonPartialAnims(void) } } -// --MIAMI: Done void CPed::SetStoredState(void) { @@ -764,7 +749,6 @@ CPed::SetStoredState(void) } } -// --MIAMI: Done void CPed::RestorePreviousState(void) { @@ -815,7 +799,6 @@ CPed::RestorePreviousState(void) } } -// --MIAMI: Done uint32 CPed::ScanForThreats(void) { @@ -976,7 +959,6 @@ CPed::ScanForThreats(void) } } -// --MIAMI: Done void CPed::ScanForDelayedResponseThreats(void) { @@ -996,7 +978,6 @@ CPed::ScanForDelayedResponseThreats(void) m_threatCheckTimer = 0; } -// --MIAMI: Done void CPed::CheckThreatValidity(void) { @@ -1012,7 +993,6 @@ CPed::CheckThreatValidity(void) m_threatFlags = 0; } -// --MIAMI: Done bool CPed::CanUseTorsoWhenLooking(void) { @@ -1023,7 +1003,6 @@ CPed::CanUseTorsoWhenLooking(void) return false; } -// --MIAMI: Done void CPed::SetLookFlag(float direction, bool keepTryingToLook, bool cancelPrevious) { @@ -1040,7 +1019,6 @@ CPed::SetLookFlag(float direction, bool keepTryingToLook, bool cancelPrevious) } } -// --MIAMI: Done void CPed::SetLookFlag(CEntity *target, bool keepTryingToLook, bool cancelPrevious) { @@ -1058,7 +1036,6 @@ CPed::SetLookFlag(CEntity *target, bool keepTryingToLook, bool cancelPrevious) } } -// --MIAMI: Done void CPed::ClearLookFlag(void) { if (bIsLooking) { @@ -1080,7 +1057,6 @@ CPed::ClearLookFlag(void) { } } -// --MIAMI: Done void CPed::MoveHeadToLook(void) { @@ -1159,7 +1135,6 @@ CPed::MoveHeadToLook(void) } } -// --MIAMI: Done void CPed::RestoreHeadPosition(void) { @@ -1173,7 +1148,6 @@ CPed::RestoreHeadPosition(void) } } -// --MIAMI: Done void CPed::SetAimFlag(float angle) { @@ -1193,7 +1167,6 @@ CPed::SetAimFlag(float angle) m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; } -// --MIAMI: Done void CPed::SetAimFlag(CEntity *to) { @@ -1210,7 +1183,6 @@ CPed::SetAimFlag(CEntity *to) m_lookTimer = 0; } -// --MIAMI: Done void CPed::ClearAimFlag(void) { @@ -1225,7 +1197,6 @@ CPed::ClearAimFlag(void) ((CPlayerPed*)this)->m_fFPSMoveHeading = 0.0f; } -// --MIAMI: Done void CPed::AimGun(void) { @@ -1258,7 +1229,6 @@ CPed::AimGun(void) } } -// --MIAMI: Done void CPed::RestoreGunPosition(void) { @@ -1273,14 +1243,12 @@ CPed::RestoreGunPosition(void) } } -// --MIAMI: Done bool CPed::CanWeRunAndFireWithWeapon(void) { return CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM); } -// --MIAMI: Done void CPed::ScanForInterestingStuff(void) { @@ -1374,7 +1342,6 @@ CPed::ScanForInterestingStuff(void) } } -// --MIAMI: Done bool CPed::WillChat(CPed *stranger) { @@ -1400,7 +1367,6 @@ CPed::WillChat(CPed *stranger) return true; } -// --MIAMI: Done void CPed::CalculateNewVelocity(void) { @@ -1492,7 +1458,6 @@ CPed::CalculateNewVelocity(void) } } -// --MIAMI: Done float CPed::WorkOutHeadingForMovingFirstPerson(float offset) { @@ -1516,7 +1481,6 @@ CPed::WorkOutHeadingForMovingFirstPerson(float offset) return CGeneral::LimitRadianAngle(offset + angle); } -// --MIAMI: Done void CPed::UpdatePosition(void) { @@ -1584,7 +1548,6 @@ CPed::UpdatePosition(void) m_vecMoveSpeed.y += velocityChange.y; } -// --MIAMI: Done void CPed::CalculateNewOrientation(void) { @@ -1594,7 +1557,6 @@ CPed::CalculateNewOrientation(void) SetHeading(m_fRotationCur); } -// --MIAMI: Done void CPed::ClearAll(void) { @@ -1618,7 +1580,6 @@ CPed::ClearAll(void) m_pCollidingEntity = nil; } -// --MIAMI: Done void CPed::ProcessBuoyancy(void) { @@ -1737,7 +1698,6 @@ CPed::ProcessBuoyancy(void) bTouchingWater = false; } -// --MIAMI: Done? void CPed::ProcessControl(void) { @@ -2878,7 +2838,6 @@ CPed::ProcessControl(void) ServiceTalking(); } -// --MIAMI: Done int32 CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) { @@ -3084,7 +3043,6 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) return ourCollidedSpheres; } -// --MIAMI: Done static void particleProduceFootSplash(CPed *ped, CVector const &pos, float size, int times) { @@ -3098,7 +3056,6 @@ particleProduceFootSplash(CPed *ped, CVector const &pos, float size, int times) } } -// --MIAMI: Done static void particleProduceFootDust(CPed *ped, CVector const &pos, float size, int times) { @@ -3125,7 +3082,6 @@ particleProduceFootDust(CPed *ped, CVector const &pos, float size, int times) } } -// --MIAMI: Done void CPed::PlayFootSteps(void) { @@ -3384,7 +3340,6 @@ CPed::PlayFootSteps(void) } } -// --MIAMI: Done // Actually GetLocalDirectionTo(Turn/Look) int CPed::GetLocalDirection(const CVector2D &posOffset) @@ -3400,14 +3355,12 @@ CPed::GetLocalDirection(const CVector2D &posOffset) return direction; } -// --MIAMI: Done bool CPed::SetDirectionToWalkAroundVehicle(CVehicle* veh) { return SetFollowPath(m_vecSeekPos, 0.0f, m_nMoveState, veh, m_pedInObjective, m_nMoveState == PEDMOVE_WALK ? 2000 : 250); } -// --MIAMI: Done void CPed::SetDirectionToWalkAroundObject(CEntity *obj) { @@ -3860,7 +3813,6 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj) m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 280.0f * dist * checkIntervalInTime; } -// --MIAMI: Done bool CPed::IsPedInControl(void) { @@ -3869,14 +3821,12 @@ CPed::IsPedInControl(void) && m_fHealth > 0.0f; } -// --MIAMI: Done bool CPed::IsPedShootable(void) { return m_nPedState <= PED_STATES_NO_ST; } -// --MIAMI: Done bool CPed::UseGroundColModel(void) { @@ -3886,7 +3836,6 @@ CPed::UseGroundColModel(void) m_nPedState == PED_DEAD; } -// --MIAMI: Done bool CPed::CanPedReturnToState(void) { @@ -3894,14 +3843,12 @@ CPed::CanPedReturnToState(void) m_nPedState != PED_FIGHT && m_nPedState != PED_STEP_AWAY && m_nPedState != PED_SNIPER_MODE && m_nPedState != PED_LOOK_ENTITY; } -// --MIAMI: Done bool CPed::CanSetPedState(void) { return !DyingOrDead() && m_nPedState != PED_ARRESTED && !EnteringCar() && m_nPedState != PED_STEAL_CAR; } -// --MIAMI: Done bool CPed::CanStrafeOrMouseControl(void) { @@ -3913,7 +3860,6 @@ CPed::CanStrafeOrMouseControl(void) m_nPedState == PED_ATTACK || m_nPedState == PED_FIGHT || m_nPedState == PED_AIM_GUN || m_nPedState == PED_JUMP || m_nPedState == PED_ANSWER_MOBILE; } -// --MIAMI: Done void CPed::PedSetPreviousStateCB(CAnimBlendAssociation* assoc, void* arg) { @@ -3922,7 +3868,6 @@ CPed::PedSetPreviousStateCB(CAnimBlendAssociation* assoc, void* arg) ped->m_pVehicleAnim = nil; } -// --MIAMI: Done void CPed::PedGetupCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -3958,7 +3903,6 @@ CPed::PedGetupCB(CAnimBlendAssociation* animAssoc, void* arg) ped->bGetUpAnimStarted = false; } -// --MIAMI: Done void CPed::PedLandCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -3971,7 +3915,6 @@ CPed::PedLandCB(CAnimBlendAssociation* animAssoc, void* arg) ped->RestorePreviousState(); } -// --MIAMI: Done void CPed::PedStaggerCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -3982,7 +3925,6 @@ CPed::PedStaggerCB(CAnimBlendAssociation* animAssoc, void* arg) // nothing */ } -// --MIAMI: Done void CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -4163,7 +4105,6 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg) ped->bHeldHostageInCar = false; } -// --MIAMI: Done void CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) { @@ -4240,7 +4181,6 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) ped->bVehExitWillBeInstant = false; } -// --MIAMI: Done void CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -4499,7 +4439,6 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) ped->bChangedSeat = true; } -// --MIAMI: Done bool CPed::CanBeDeleted(void) { @@ -4518,7 +4457,6 @@ CPed::CanBeDeleted(void) } } -//--MIAMI: done bool CPed::CanBeDeletedEvenInVehicle(void) { @@ -4534,7 +4472,6 @@ CPed::CanBeDeletedEvenInVehicle(void) } } -// --MIAMI: Done void CPed::AddWeaponModel(int id) { @@ -4562,7 +4499,6 @@ RemoveAllModelCB(RwObject *object, void *data) return object; } -// --MIAMI: Done void CPed::RemoveWeaponModel(int modelId) { @@ -4590,7 +4526,6 @@ CPed::RemoveWeaponModel(int modelId) m_wepModelID = -1; } -// --MIAMI: Done void CPed::RequestDelayedWeapon() { @@ -4610,7 +4545,6 @@ CPed::RequestDelayedWeapon() } } -// --MIAMI: Done void CPed::GiveDelayedWeapon(eWeaponType weapon, uint32 ammo) { @@ -4632,7 +4566,6 @@ CPed::GiveDelayedWeapon(eWeaponType weapon, uint32 ammo) } } -// --MIAMI: Done int32 CPed::GiveWeapon(eWeaponType weaponType, uint32 ammo, bool unused) { @@ -4669,14 +4602,12 @@ CPed::GiveWeapon(eWeaponType weaponType, uint32 ammo, bool unused) return slot; } -// --MIAMI: Done int CPed::GetWeaponSlot(eWeaponType weaponType) { return CWeaponInfo::GetWeaponInfo(weaponType)->m_nWeaponSlot; } -// --MIAMI: Done void CPed::SetCurrentWeapon(int slot) { @@ -4699,14 +4630,12 @@ CPed::SetCurrentWeapon(int slot) } } -// --MIAMI: Done void CPed::SetCurrentWeapon(eWeaponType weaponType) { SetCurrentWeapon(CWeaponInfo::GetWeaponInfo(weaponType)->m_nWeaponSlot); } -// --MIAMI: Done void CPed::GrantAmmo(eWeaponType weaponType, uint32 ammo) { @@ -4727,7 +4656,6 @@ CPed::GrantAmmo(eWeaponType weaponType, uint32 ammo) GetWeapon(slot).m_eWeaponState = WEAPONSTATE_READY; } -// --MIAMI: Done void CPed::SetAmmo(eWeaponType weaponType, uint32 ammo) { @@ -4752,7 +4680,6 @@ CPed::SetAmmo(eWeaponType weaponType, uint32 ammo) GetWeapon(slot).m_eWeaponState = WEAPONSTATE_READY; } -// --MIAMI: Done void CPed::ClearWeapons(void) { @@ -4763,7 +4690,6 @@ CPed::ClearWeapons(void) SetCurrentWeapon(WEAPONTYPE_UNARMED); } -// --MIAMI: Done void CPed::RemoveWeaponWhenEnteringVehicle(void) { @@ -4776,14 +4702,13 @@ CPed::RemoveWeaponWhenEnteringVehicle(void) RemoveWeaponModel(ourWeapon->m_nModelId); } } -// --MIAMI: Done, but enumarate weapon slots void CPed::ReplaceWeaponWhenExitingVehicle(void) { eWeaponType weaponType = GetWeapon()->m_eWeaponType; // If it's Uzi, we may have stored weapon. Uzi is the only gun we can use in car. - if (IsPlayer() && GetWeaponSlot(weaponType) == 5) { + if (IsPlayer() && GetWeaponSlot(weaponType) == WEAPONSLOT_SUBMACHINEGUN) { if (m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { SetCurrentWeapon(m_storedWeapon); m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; @@ -4793,7 +4718,6 @@ CPed::ReplaceWeaponWhenExitingVehicle(void) } } -// --MIAMI: Done void CPed::PreRender(void) { @@ -5028,7 +4952,6 @@ CPed::PreRender(void) CVector vecTestTemp(-1.0f, -1.0f, -1.0f); -// --MIAMI: Done void CPed::Render(void) { @@ -5078,7 +5001,6 @@ CPed::Render(void) } } -// --MIAMI: Done void CPed::CheckAroundForPossibleCollisions(void) { @@ -5111,7 +5033,6 @@ CPed::CheckAroundForPossibleCollisions(void) } } -// --MIAMI: Done void CPed::SetIdle(void) { @@ -5128,7 +5049,6 @@ CPed::SetIdle(void) } } -// --MIAMI: Done void CPed::Idle(void) { @@ -5156,14 +5076,12 @@ CPed::Idle(void) m_moved = CVector2D(0.0f, 0.0f); } -// --MIAMI: Done void CPed::ClearPause(void) { RestorePreviousState(); } -// --MIAMI: Done void CPed::Pause(void) { @@ -5172,7 +5090,6 @@ CPed::Pause(void) ClearPause(); } -// --MIAMI: Done void CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl) { @@ -5238,14 +5155,12 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl) bFallenDown = true; } -// --MIAMI: Done void CPed::ClearFall(void) { SetGetUp(); } -// --MIAMI: Done void CPed::Fall(void) { @@ -5304,7 +5219,6 @@ CPed::Fall(void) } } -// --MIAMI: Done bool CPed::CheckIfInTheAir(void) { @@ -5326,7 +5240,6 @@ CPed::CheckIfInTheAir(void) return !foundGround; } -// --MIAMI: Done void CPed::SetInTheAir(void) { @@ -5345,7 +5258,6 @@ CPed::SetInTheAir(void) } -// --MIAMI: Done void CPed::InTheAir(void) { @@ -5369,7 +5281,6 @@ CPed::InTheAir(void) } } -// --MIAMI: Done void CPed::SetLanding(void) { @@ -5405,7 +5316,6 @@ CPed::SetLanding(void) bIsLanding = true; } -// --MIAMI: Done void CPed::SetGetUp(void) { @@ -5476,7 +5386,6 @@ CPed::SetGetUp(void) } } -// --MIAMI: Done void CPed::Mug(void) { @@ -5498,7 +5407,6 @@ CPed::Mug(void) } } -// --MIAMI: Done // Unused void CPed::SetLook(float direction) @@ -5510,7 +5418,6 @@ CPed::SetLook(float direction) } } -// --MIAMI: Done void CPed::SetLook(CEntity* to) { @@ -5521,7 +5428,6 @@ CPed::SetLook(CEntity* to) } } -// --MIAMI: Done void CPed::SetLookTimer(int time) { @@ -5530,7 +5436,6 @@ CPed::SetLookTimer(int time) } } -// --MIAMI: Done void CPed::SetAttackTimer(uint32 time) { @@ -5538,7 +5443,6 @@ CPed::SetAttackTimer(uint32 time) m_attackTimer = Max(m_shootTimer, CTimer::GetTimeInMilliseconds()) + time; } -// --MIAMI: Done void CPed::SetShootTimer(uint32 time) { @@ -5547,7 +5451,6 @@ CPed::SetShootTimer(uint32 time) } } -// --MIAMI: Done void CPed::ClearLook(void) { @@ -5555,14 +5458,12 @@ CPed::ClearLook(void) ClearLookFlag(); } -// --MIAMI: Done void CPed::Look(void) { TurnBody(); } -// --MIAMI: Done bool CPed::TurnBody(void) { @@ -5596,7 +5497,6 @@ CPed::TurnBody(void) return turnDone; } -// --MIAMI: Done void CPed::SetSeek(CVector pos, float distanceToCountDone) { @@ -5615,7 +5515,6 @@ CPed::SetSeek(CVector pos, float distanceToCountDone) m_distanceToCountSeekDone = distanceToCountDone; m_vecSeekPos = pos; } -// --MIAMI: Done void CPed::SetSeek(CEntity *seeking, float distanceToCountDone) { @@ -5638,7 +5537,6 @@ CPed::SetSeek(CEntity *seeking, float distanceToCountDone) SetMoveState(PEDMOVE_STILL); } -// --MIAMI: Done void CPed::ClearSeek(void) { @@ -5646,7 +5544,6 @@ CPed::ClearSeek(void) bRunningToPhone = false; } -// --MIAMI: Done bool CPed::Seek(void) { @@ -5819,7 +5716,6 @@ CPed::Seek(void) return true; } -// --MIAMI: Done void CPed::SetFlee(CVector2D const &from, int time) { @@ -5849,7 +5745,6 @@ CPed::SetFlee(CVector2D const &from, int time) } } -// --MIAMI: Done void CPed::SetFlee(CEntity *fleeFrom, int time) { @@ -5880,7 +5775,6 @@ CPed::SetFlee(CEntity *fleeFrom, int time) } } -// --MIAMI: Done void CPed::ClearFlee(void) { @@ -5890,7 +5784,6 @@ CPed::ClearFlee(void) m_fleeTimer = 0; } -// --MIAMI: Done void CPed::Flee(void) { @@ -6078,7 +5971,6 @@ CPed::WanderRange(void) } } -// --MIAMI: Done bool CPed::SetWanderPath(int8 pathStateDest) { @@ -6127,7 +6019,6 @@ CPed::SetWanderPath(int8 pathStateDest) } } -// --MIAMI: Done void CPed::WanderPath(void) { @@ -6235,7 +6126,6 @@ CPed::WanderPath(void) Say(SOUND_PED_WAIT_DOUBLEBACK); } } -// --MIAMI: Done void CPed::Avoid(void) { @@ -6284,7 +6174,6 @@ CPed::Avoid(void) } } -// --MIAMI: Done CVector* CPed::SeekFollowingPath(void) { @@ -6306,7 +6195,6 @@ CPed::SeekFollowingPath(void) return &vecNextPathNode; } -// --MIAMI: Done bool CPed::SetFollowPath(CVector dest, float radius, eMoveState state, CEntity* walkAroundEnt, CEntity* targetEnt, int time) { @@ -6359,7 +6247,6 @@ CPed::SetFollowPath(CVector dest, float radius, eMoveState state, CEntity* walkA return SetFollowPathStatic(); } -// --MIAMI: Done bool CPed::SetFollowPathStatic(void) { @@ -6428,7 +6315,6 @@ CPed::SetFollowPathStatic(void) return true; } -// --MIAMI: Done bool CPed::SetFollowPathDynamic(void) { @@ -6812,7 +6698,6 @@ CPed::SetFollowPathDynamic(void) } } -// --MIAMI: Done void CPed::ClearFollowPath() { @@ -6823,7 +6708,6 @@ CPed::ClearFollowPath() m_nCurPathNodeId = 0; } -// --MIAMI: Done void CPed::FollowPath(void) { @@ -6854,7 +6738,6 @@ CPed::FollowPath(void) } } -// --MIAMI: Done void CPed::SetEvasiveStep(CEntity *reason, uint8 animType) { @@ -6930,7 +6813,6 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) } } -// --MIAMI: Done void CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump) { @@ -7050,7 +6932,6 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump) } } -// --MIAMI: Done void CPed::PedEvadeCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -7088,7 +6969,6 @@ CPed::PedEvadeCB(CAnimBlendAssociation* animAssoc, void* arg) } } -// --MIAMI: Done void CPed::SetDie(AnimationId animId, float delta, float speed) { @@ -7152,7 +7032,6 @@ CPed::SetDie(AnimationId animId, float delta, float speed) } } -// --MIAMI: Done void CPed::FinishDieAnimCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -7162,7 +7041,6 @@ CPed::FinishDieAnimCB(CAnimBlendAssociation *animAssoc, void *arg) ped->bIsPedDieAnimPlaying = false; } -// --MIAMI: Done void CPed::SetDead(void) { @@ -7195,14 +7073,12 @@ CPed::SetDead(void) CEventList::RegisterEvent(EVENT_DEAD_PED, EVENT_ENTITY_PED, this, nil, 1000); } -// --MIAMI: Done void CPed::Die(void) { // UNUSED: This is a perfectly empty function. } -// --MIAMI: Done void CPed::SetChat(CEntity *chatWith, uint32 time) { @@ -7219,7 +7095,6 @@ CPed::SetChat(CEntity *chatWith, uint32 time) m_lookTimer = CTimer::GetTimeInMilliseconds() + 3000; } -// --MIAMI: Done void CPed::Chat(void) { @@ -7275,7 +7150,6 @@ CPed::Chat(void) } } -// --MIAMI: Done void CPed::ClearChat(void) { @@ -7294,7 +7168,6 @@ CPed::ClearChat(void) } } -// --MIAMI: Done bool CPed::FacePhone(void) { @@ -7343,7 +7216,6 @@ CPed::FacePhone(void) #endif } -// --MIAMI: Done bool CPed::MakePhonecall(void) { @@ -7356,7 +7228,6 @@ CPed::MakePhonecall(void) return true; } -// --MIAMI: Done void StartTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg) { @@ -7365,7 +7236,6 @@ StartTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg) CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_PHONE_TALK, 4.0f); } -// --MIAMI: Done void FinishTalkingOnMobileCB(CAnimBlendAssociation *assoc, void *arg) { @@ -7378,7 +7248,6 @@ FinishTalkingOnMobileCB(CAnimBlendAssociation *assoc, void *arg) ped->m_lookTimer = 0; } -// --MIAMI: Done void CPed::SetAnswerMobile(void) { @@ -7395,7 +7264,6 @@ CPed::SetAnswerMobile(void) } } -// --MIAMI: Done void CPed::ClearAnswerMobile(void) { @@ -7415,7 +7283,6 @@ CPed::ClearAnswerMobile(void) } } -// --MIAMI: Done void CPed::AnswerMobile(void) { @@ -7448,7 +7315,6 @@ CPed::AnswerMobile(void) } } -// --MIAMI: Done void CPed::Teleport(CVector pos) { @@ -7462,7 +7328,6 @@ CPed::Teleport(CVector pos) CWorld::Add(this); } -// --MIAMI: Done void CPed::SetSeekCar(CVehicle *car, uint32 doorNode) { @@ -7486,7 +7351,6 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode) } -// --MIAMI: Done void CPed::SeekCar(void) { @@ -7669,7 +7533,6 @@ CPed::SeekCar(void) } } -// --MIAMI: Done bool CPed::CheckForExplosions(CVector2D &area) { @@ -7714,7 +7577,6 @@ CPed::CheckForExplosions(CVector2D &area) return false; } -// --MIAMI: Done CPed * CPed::CheckForGunShots(void) { @@ -7730,7 +7592,6 @@ CPed::CheckForGunShots(void) return nil; } -// --MIAMI: Done CPed * CPed::CheckForDeadPeds(void) { @@ -7746,7 +7607,6 @@ CPed::CheckForDeadPeds(void) return nil; } -// --MIAMI: Done bool CPed::IsPlayer(void) const { @@ -7759,14 +7619,12 @@ CPed::IsPlayer(void) const #endif } -// --MIAMI: Done bool CPed::IsGangMember(void) const { return m_nPedType >= PEDTYPE_GANG1 && m_nPedType <= PEDTYPE_GANG9; } -// --MIAMI: Done bool IsPedPointerValid(CPed* pPed) { @@ -7777,7 +7635,6 @@ IsPedPointerValid(CPed* pPed) return pPed->m_entryInfoList.first || pPed == FindPlayerPed(); } -// --MIAMI: Done bool IsPedPointerValid_NotInWorld(CPed* pPed) { @@ -7793,7 +7650,6 @@ IsPedPointerValid_NotInWorld(CPed* pPed) return true; } -// --MIAMI: Done bool CPed::IsPointerValid(void) { @@ -7807,7 +7663,6 @@ CPed::IsPointerValid(void) return false; } -// --MIAMI: Done void CPed::SetPedPositionInCar(void) { @@ -7900,7 +7755,6 @@ CPed::SetPedPositionInCar(void) GetMatrix() = newMat; } -// --MIAMI: Done void CPed::LookForSexyPeds(void) { @@ -7926,7 +7780,6 @@ CPed::LookForSexyPeds(void) m_lookTimer = CTimer::GetTimeInMilliseconds() + 10000; } -// --MIAMI: Done void CPed::LookForSexyCars(void) { @@ -7956,7 +7809,6 @@ CPed::LookForSexyCars(void) } } -// --MIAMI: Done bool CPed::LookForInterestingNodes(void) { @@ -8098,7 +7950,6 @@ CPed::LookForInterestingNodes(void) return true; } -// --MIAMI: Done void PlayRandomAnimationsFromAnimBlock(CPed* ped, AssocGroupId animGroup, uint32 first, uint32 amount) { @@ -8135,7 +7986,6 @@ PlayRandomAnimationsFromAnimBlock(CPed* ped, AssocGroupId animGroup, uint32 firs } } -// --MIAMI: Done void CPed::ClearWaitState(void) { @@ -8239,7 +8089,6 @@ CPed::ClearWaitState(void) m_nWaitState = WAITSTATE_FALSE; } -// --MIAMI: Done void CPed::SetWaitState(eWaitState state, void *time) { @@ -8459,7 +8308,6 @@ CPed::SetWaitState(eWaitState state, void *time) m_nWaitState = state; } -// --MIAMI: Done void CPed::Wait(void) { @@ -8903,7 +8751,6 @@ CPed::Wait(void) RestoreHeadingRate(); } -// --MIAMI: Done void CPed::DeleteSunbatheIdleAnimCB(CAnimBlendAssociation *assoc, void *arg) { @@ -8922,7 +8769,6 @@ CPed::DeleteSunbatheIdleAnimCB(CAnimBlendAssociation *assoc, void *arg) ped->Wait(); } -// --MIAMI: Done void CPed::FinishedWaitCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -8933,21 +8779,18 @@ CPed::FinishedWaitCB(CAnimBlendAssociation *animAssoc, void *arg) ped->Wait(); } -// --MIAMI: Done void CPed::RestoreHeadingRate(void) { m_headingRate = m_pedStats->m_headingChangeRate; } -// --MIAMI: Done void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { ((CPed*)arg)->RestoreHeadingRate(); } -// --MIAMI: Done void CPed::FlagToDestroyWhenNextProcessed(void) { @@ -8971,7 +8814,6 @@ CPed::FlagToDestroyWhenNextProcessed(void) m_pVehicleAnim = nil; } -// --MIAMI: Done void CPed::SetSolicit(uint32 time) { @@ -8997,7 +8839,6 @@ CPed::SetSolicit(uint32 time) } } -// --MIAMI: Done void CPed::Solicit(void) { @@ -9043,7 +8884,6 @@ CPed::Solicit(void) } } -// --MIAMI: Done void CPed::SetBuyIceCream(void) { @@ -9056,7 +8896,6 @@ CPed::SetBuyIceCream(void) SetPedState(PED_BUY_ICECREAM); } -// --MIAMI: Done void CPed::BuyIceCream(void) { @@ -9075,7 +8914,6 @@ CPed::BuyIceCream(void) } } -// --MIAMI: Done bool CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh) { @@ -9209,7 +9047,6 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh) return true; } -// --MIAMI: Done void CPed::SetLeader(CEntity *leader) { @@ -9221,7 +9058,6 @@ CPed::SetLeader(CEntity *leader) } } -// --MIAMI: Done bool CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal) { @@ -9254,7 +9090,6 @@ CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal) return CWorld::GetIsLineOfSightClear(pos, forwardPos, true, false, false, true, false, false, false); } -// --MIAMI: Done void CPed::SetJump(void) { @@ -9269,7 +9104,6 @@ CPed::SetJump(void) } } -// --MIAMI: Done void CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -9379,7 +9213,6 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::FinishJumpCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -9391,7 +9224,6 @@ CPed::FinishJumpCB(CAnimBlendAssociation *animAssoc, void *arg) animAssoc->blendDelta = -1000.0f; } -// --MIAMI: Done void CPed::FinishHitHeadCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -9408,7 +9240,6 @@ CPed::FinishHitHeadCB(CAnimBlendAssociation *animAssoc, void *arg) ped->bIsLanding = false; } -// --MIAMI: Done bool CPed::CanPedDriveOff(void) { @@ -9424,7 +9255,6 @@ CPed::CanPedDriveOff(void) } return true; } -// --MIAMI: Done void CPed::SetRadioStation(void) { @@ -9445,7 +9275,6 @@ CPed::SetRadioStation(void) } } -// --MIAMI: Done void CPed::WarpPedIntoCar(CVehicle *car) // LCS TODO: remove passenger logic { @@ -9586,14 +9415,12 @@ CPed::WarpPedIntoCarAsPassenger(CVehicle* pVehicle, int32 position) bChangedSeat = true; } -// --MIAMI: Done bool CPed::HasAttractor(void) { return m_attractor != nil; } -// --MIAMI: Done void CPed::SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float heading, float time, int32 qid) { @@ -9614,7 +9441,6 @@ CPed::SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float head m_positionInQueue = qid; } -// --MIAMI: Done void CPed::AttachPedToEntity(CEntity *ent, CVector offset, uint16 type, float rot, eWeaponType weapon) { @@ -9662,7 +9488,6 @@ CPed::AttachPedToEntity(CEntity *ent, CVector offset, uint16 type, float rot, eW PositionAttachedPed(); } -// --MIAMI: Done void CPed::DettachPedFromEntity(void) { @@ -9686,7 +9511,6 @@ CPed::DettachPedFromEntity(void) } } -// --MIAMI: Done void CPed::PositionAttachedPed() { @@ -9738,7 +9562,6 @@ CPed::PositionAttachedPed() } } -// --MIAMI: Done void CPed::Undress(const char* name) { @@ -9754,7 +9577,6 @@ CPed::Undress(const char* name) CWorld::Remove(this); } -// --MIAMI: Done void CPed::Dress(void) { 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/peds/PedAI.cpp b/src/peds/PedAI.cpp index 8b832670..cf566aba 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -30,8 +30,6 @@ #include "GameLogic.h" #include "Streaming.h" -//--MIAMI: file done - CVector vecPedCarDoorAnimOffset; CVector vecPedCarDoorLoAnimOffset; CVector vecPedVanRearDoorAnimOffset; @@ -44,7 +42,6 @@ CVector vecPedHarleyBikeJumpRhsAnimOffset; CVector vecPedDirtBikeJumpRhsAnimOffset; CVector vecPedBikeKickAnimOffset; -// --MIAMI: Done void CPed::SetObjectiveTimer(int time) { @@ -55,7 +52,6 @@ CPed::SetObjectiveTimer(int time) } } -// --MIAMI: Done void CPed::SetStoredObjective(void) { @@ -90,7 +86,6 @@ CPed::SetStoredObjective(void) } } -// --MIAMI: Done void CPed::ForceStoredObjective(eObjective objective) { @@ -124,7 +119,6 @@ CPed::ForceStoredObjective(eObjective objective) } } -// --MIAMI: Done bool CPed::IsTemporaryObjective(eObjective objective) { @@ -133,7 +127,6 @@ CPed::IsTemporaryObjective(eObjective objective) objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER; } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj) { @@ -180,7 +173,6 @@ CPed::SetObjective(eObjective newObj) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, void *entity) { @@ -415,7 +407,6 @@ CPed::SetObjective(eObjective newObj, CVector dest, float safeDist) } } -// --MIAMI: Done // Only used in 01E1: SET_CHAR_OBJ_FOLLOW_ROUTE opcode // IDA fails very badly in here, puts a fake loop and ignores SetFollowRoute call... void @@ -448,7 +439,6 @@ CPed::SetObjective(eObjective newObj, int16 routePoint, int16 routeType) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, CVector dest) { @@ -588,7 +578,6 @@ CPed::SetObjective(eObjective newObj, CVector dest) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, float heading, const CVector& pos) { @@ -605,7 +594,6 @@ CPed::SetObjective(eObjective newObj, float heading, const CVector& pos) } } -// --MIAMI: Done void CPed::ClearObjective(void) { @@ -631,7 +619,6 @@ CPed::ClearObjective(void) } } -// --MIAMI: Done void CPed::ClearLeader(void) { @@ -651,7 +638,6 @@ CPed::ClearLeader(void) } } -// --MIAMI: Done void CPed::UpdateFromLeader(void) { @@ -810,7 +796,6 @@ CPed::UpdateFromLeader(void) } } -// --MIAMI: Done void CPed::RestorePreviousObjective(void) { @@ -833,7 +818,6 @@ CPed::RestorePreviousObjective(void) bObjectiveCompleted = false; } -// --MIAMI: Done void CPed::ProcessObjective(void) { @@ -969,7 +953,7 @@ CPed::ProcessObjective(void) m_pMyVehicle->SetStatus(STATUS_PHYSICS); m_pMyVehicle->AutoPilot.m_nPrevRouteNode = 0; if (m_nPedType == PEDTYPE_COP) { - m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity); + m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->GetWantedLevel() * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity); m_pMyVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); } else { m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity * 0.8f; @@ -2105,7 +2089,6 @@ CPed::ProcessObjective(void) } } -// --MIAMI: Done void CPed::SetFollowRoute(int16 currentPoint, int16 routeType) { @@ -2118,7 +2101,6 @@ CPed::SetFollowRoute(int16 currentPoint, int16 routeType) m_nextRoutePointPos = CRouteNode::GetPointPosition(GetNextPointOnRoute()); } -// --MIAMI: Done int CPed::GetNextPointOnRoute(void) { @@ -2146,7 +2128,6 @@ CPed::GetNextPointOnRoute(void) return nextPoint; } -// --MIAMI: Done bool CPed::HaveReachedNextPointOnRoute(float distToCountReached) { @@ -2157,7 +2138,6 @@ CPed::HaveReachedNextPointOnRoute(float distToCountReached) return false; } -// --MIAMI: Done bool CPed::CanSeeEntity(CEntity *entity, float threshold) { @@ -2183,7 +2163,6 @@ CPed::CanSeeEntity(CEntity *entity, float threshold) return neededTurn < threshold || TWOPI - threshold < neededTurn; } -// --MIAMI: Done // Only used while deciding which gun ped should switch to, if no ammo left. bool CPed::SelectGunIfArmed(void) @@ -2204,7 +2183,6 @@ CPed::SelectGunIfArmed(void) SetCurrentWeapon(WEAPONTYPE_UNARMED); return false; } -// --MIAMI: Done void CPed::ReactToPointGun(CEntity *entWithGun) { @@ -2289,7 +2267,6 @@ CPed::ReactToPointGun(CEntity *entWithGun) } } -// --MIAMI: Done void CPed::ReactToAttack(CEntity *attacker) { @@ -2362,7 +2339,6 @@ CPed::ReactToAttack(CEntity *attacker) } } -// --MIAMI: Done void CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -2607,7 +2583,6 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -2827,7 +2802,6 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg) return; } -// --MIAMI: Done void CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -2913,7 +2887,6 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) } } -// --MIAMI: Done void CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -3063,7 +3036,6 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedShuffle(void) { @@ -3079,7 +3051,6 @@ CPed::PedShuffle(void) } } -// --MIAMI: Done void CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -3146,7 +3117,6 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedAnimShuffleCB(CAnimBlendAssociation* assoc, void* arg) { @@ -3158,7 +3128,6 @@ CPed::PedAnimShuffleCB(CAnimBlendAssociation* assoc, void* arg) } } -// --MIAMI: Done void CPed::SetFormation(eFormation type) { @@ -3182,7 +3151,6 @@ CPed::SetFormation(eFormation type) m_pedFormation = type; } -// --MIAMI: Done CVector CPed::GetFormationPosition(void) { @@ -3231,7 +3199,6 @@ CPed::GetFormationPosition(void) return m_pedInObjective->GetMatrix() * formationOffset; } -// --MIAMI: Done void CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -3371,11 +3338,11 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) return; } -// --MIAMI: Done void CPed::LineUpPedWithCar(PedLineUpPhase phase) { bool vehIsUpsideDown = false; + bool stillGettingInOut = false; int vehAnim; float seatPosMult = 0.0f; float currentZ; @@ -3628,8 +3595,8 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (m_pVehicleAnim && vehAnim != ANIM_VAN_GETIN_L && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE && vehAnim != ANIM_VAN_GETIN) { neededPos.z = autoZPos.z; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - } else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + } else if (neededPos.z < currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) { + adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep); @@ -3647,7 +3614,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (m_pVehicleAnim && (vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS || vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ; @@ -3659,7 +3626,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) } } - bool stillGettingInOut = false; if (CTimer::GetTimeInMilliseconds() < m_nPedStateTimer) stillGettingInOut = veh->m_vehType != VEHICLE_TYPE_BOAT || bOnBoat; @@ -3708,7 +3674,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) } -// --MIAMI: Done void CPed::SetCarJack(CVehicle* car) { @@ -3791,7 +3756,6 @@ CPed::SetCarJack(CVehicle* car) SetCarJack_AllClear(car, m_vehDoor, doorFlag); } -// --MIAMI: Done void CPed::SetCarJack_AllClear(CVehicle* car, uint32 doorNode, uint32 doorFlag) { @@ -3834,7 +3798,6 @@ CPed::SetCarJack_AllClear(CVehicle* car, uint32 doorNode, uint32 doorFlag) } } -// --MIAMI: Done void CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack) { @@ -3883,7 +3846,6 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack) veh->m_nGettingOutFlags |= GetCarDoorFlag(m_vehDoor); } -// --MIAMI: Done void CPed::BeingDraggedFromCar(void) { @@ -3949,7 +3911,6 @@ CPed::BeingDraggedFromCar(void) } } -// --MIAMI: Done void CPed::SetEnterCar(CVehicle *car, uint32 unused) { @@ -4026,7 +3987,6 @@ CPed::SetEnterCar(CVehicle *car, uint32 unused) } } -// --MIAMI: Done void CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) { @@ -4079,7 +4039,6 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) } } -// --MIAMI: Done void CPed::EnterCar(void) { @@ -4123,7 +4082,6 @@ CPed::EnterCar(void) } } -// --MIAMI: Done void CPed::QuitEnteringCar(void) { @@ -4172,7 +4130,6 @@ CPed::QuitEnteringCar(void) } } -// --MIAMI: Done void CPed::SetExitBoat(CVehicle *boat) { @@ -4181,7 +4138,7 @@ CPed::SetExitBoat(CVehicle *boat) RemoveInCarAnims(); CColModel* boatCol = boat->GetColModel(); if (boat->IsUpsideDown()) { - newPos = { 0.0f, 0.0f, boatCol->boundingBox.min.z }; + newPos = CVector(0.0f, 0.0f, boatCol->boundingBox.min.z); newPos = boat->GetMatrix() * newPos; newPos.z += 1.0f; m_vehDoor = CAR_DOOR_RF; @@ -4230,7 +4187,6 @@ CPed::SetExitBoat(CVehicle *boat) m_vecMoveSpeed = boat->m_vecMoveSpeed; } -// --MIAMI: Done // wantedDoorNode = 0 means that func. will determine it void CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode) @@ -4615,7 +4571,6 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode) } } -// --MIAMI: Done void CPed::ExitCar(void) { @@ -4687,7 +4642,6 @@ CPed::ExitCar(void) } } -// --MIAMI: Done CVector CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component) { @@ -4700,7 +4654,6 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component) return vehDoorPos; } -// --MIAMI: Done void CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen) { @@ -4769,7 +4722,6 @@ CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen) } } -// --MIAMI: Done bool CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen) { @@ -4853,7 +4805,6 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen) return canEnter; } -// --MIAMI: Done void CPed::GoToNearestDoor(CVehicle *veh) { @@ -4863,7 +4814,6 @@ CPed::GoToNearestDoor(CVehicle *veh) SetMoveState(PEDMOVE_RUN); } -// --MIAMI: Done // Unused void CPed::PedSetGetInCarPositionCB(CAnimBlendAssociation* assoc, void* arg) { @@ -4877,7 +4827,6 @@ void CPed::PedSetGetInCarPositionCB(CAnimBlendAssociation* assoc, void* arg) pPed->SetPosition(position); } -// --MIAMI: Done void CPed::SetAnimOffsetForEnterOrExitVehicle(void) { @@ -5039,7 +4988,6 @@ CPed::SetAnimOffsetForEnterOrExitVehicle(void) CAnimManager::RemoveAnimBlockRef(bikedBlock); } -// --MIAMI: Done void CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -5128,7 +5076,6 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void ped->m_nLastPedState = PED_WANDER_PATH; } -// --MIAMI: Done void CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -5225,7 +5172,6 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg) ped->SetGetUp(); } -// --MIAMI: Done uint8 CPed::GetNearestTrainDoor(CVehicle *train, CVector &doorPos) { @@ -5243,7 +5189,6 @@ CPed::GetNearestTrainDoor(CVehicle *train, CVector &doorPos) return 1; } -// --MIAMI: Done uint8 CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos) { @@ -5302,7 +5247,6 @@ CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos) return 1; } -// --MIAMI: Done :D void CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -5452,7 +5396,6 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg) } #endif -// --MIAMI: Done void CPed::RegisterThreatWithGangPeds(CEntity *attacker) { @@ -5516,7 +5459,6 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker) } } -// --MIAMI: Done // Some helper function which doesn't exist in og game. inline void SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVector2D farDist, CPathNode *closeNode, CPathNode *closeNode2, int runCount = 3) @@ -5546,7 +5488,6 @@ SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVecto } } -// --MIAMI: Done bool CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords) { @@ -5587,7 +5528,6 @@ CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords) return false; } -// --MIAMI: Done bool CPed::DuckAndCover(void) { @@ -5776,7 +5716,6 @@ CPed::DuckAndCover(void) return false; } -// --MIAMI: Done CVector CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset) { @@ -5824,7 +5763,6 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset) return veh->GetPosition() + doorPos; } -// --MIAMI: Done CVector CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatPosMult) { @@ -5910,7 +5848,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP } } -// --MIAMI: Done, but what is this parameter for? +// TODO: what is this parameter for? void CPed::SetDuck(uint32 time, bool sth) { @@ -5936,7 +5874,6 @@ CPed::SetDuck(uint32 time, bool sth) } } -// --MIAMI: Done void CPed::Duck(void) { @@ -5963,7 +5900,6 @@ CPed::Duck(void) } } -// --MIAMI: Done void CPed::ClearDuck(bool clearTimer) { @@ -5986,7 +5922,6 @@ CPed::ClearDuck(bool clearTimer) } } -// --MIAMI: Done void CPed::InformMyGangOfAttack(CEntity *attacker) { @@ -6021,7 +5956,6 @@ CPed::InformMyGangOfAttack(CEntity *attacker) } } -// --MIAMI: Done void CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -6044,7 +5978,6 @@ CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg) veh->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_OK); } -// --MIAMI: Done void CPed::SetSeekBoatPosition(CVehicle *boat) { @@ -6060,7 +5993,6 @@ CPed::SetSeekBoatPosition(CVehicle *boat) SetPedState(PED_SEEK_IN_BOAT); } -// --MIAMI: Done void CPed::SeekBoatPosition(void) { @@ -6082,7 +6014,6 @@ CPed::SeekBoatPosition(void) RestorePreviousState(); } -// --MIAMI: Done bool CPed::IsRoomToBeCarJacked(void) { @@ -6106,7 +6037,6 @@ CPed::IsRoomToBeCarJacked(void) return false; } -// --MIAMI: Done void CPed::AddInCarAnims(CVehicle* car, bool isDriver) { @@ -6141,7 +6071,6 @@ CPed::AddInCarAnims(CVehicle* car, bool isDriver) StopNonPartialAnims(); } -// --MIAMI: Done void CPed::RemoveDrivebyAnims() { @@ -6169,7 +6098,6 @@ CPed::RemoveDrivebyAnims() animAssoc->blendDelta = -1000.0f; } -// --MIAMI: Done void CPed::RemoveInCarAnims(void) { @@ -6182,7 +6110,6 @@ CPed::RemoveInCarAnims(void) } } -// --MIAMI: Done bool CPed::PositionPedOutOfCollision(void) { @@ -6321,7 +6248,6 @@ CPed::PositionPedOutOfCollision(void) return true; } -// --MIAMI: Done // "Any" means he shouldn't have to be in vehicle. bool CPed::PositionAnyPedOutOfCollision(void) @@ -6377,7 +6303,6 @@ CPed::PositionAnyPedOutOfCollision(void) return true; } -// --MIAMI: Done bool CPed::WarpPedToNearLeaderOffScreen(void) { @@ -6411,7 +6336,6 @@ CPed::WarpPedToNearLeaderOffScreen(void) return teleported; } -// --MIAMI: Done bool CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo) { @@ -6445,7 +6369,6 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo) return teleported; } -// --MIAMI: Done int32 CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWithTarget) { @@ -6720,7 +6643,6 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith return ATTACK_IN_PROGRESS; } -// --MIAMI: Done int32 CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWithTarget) { @@ -6975,7 +6897,6 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith } } -// --MIAMI: Done bool CPed::CanBeDamagedByThisGangMember(CPed* who) { diff --git a/src/peds/PedAttractor.cpp b/src/peds/PedAttractor.cpp index eeb65398..de587270 100644 --- a/src/peds/PedAttractor.cpp +++ b/src/peds/PedAttractor.cpp @@ -13,8 +13,6 @@ const int gcMaxSizeOfPizzaQueue = 5; const int gcMaxSizeOfShelterQueue = 5; const int gcMaxSizeOfIceCreamQueue = 1; -//--MIAMI: file done - std::vector<CVector> CPedShelterAttractor::ms_displacements; CPedAttractorManager* GetPedAttractorManager() @@ -106,7 +104,7 @@ bool CVehicleToEffect::HasThisEffect(C2dEffect* pEffect) const const C2dEffect* CPedAttractorManager::GetEffectForIceCreamVan(CVehicle* pVehicle, const CVector& pos) { if (!vVehicleToEffect.empty()) { - for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend(); ++assoc) { + for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end(); ++assoc) { if (assoc->GetVehicle() == pVehicle) return assoc->ChooseEffect(pos); } @@ -122,7 +120,7 @@ CVehicle* CPedAttractorManager::GetIceCreamVanForEffect(C2dEffect* pEffect) { if (vVehicleToEffect.empty()) return nil; - for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend(); ++assoc) { + for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end(); ++assoc) { if (assoc->HasThisEffect(pEffect)) return assoc->GetVehicle(); } @@ -133,7 +131,7 @@ const CPedAttractor* CPedAttractorManager::FindAssociatedAttractor(const C2dEffe { if (vecAttractors.empty()) return nil; - for (std::vector<CPedAttractor*>::const_iterator attractor = vecAttractors.cbegin(); attractor != vecAttractors.cend(); ++attractor) { + for (std::vector<CPedAttractor*>::const_iterator attractor = vecAttractors.begin(); attractor != vecAttractors.end(); ++attractor) { if ((*attractor)->GetEffect() == pEffect) return *attractor; } @@ -147,7 +145,7 @@ void CPedAttractorManager::RemoveIceCreamVanEffects(C2dEffect* pEffect) return; if (vVehicleToEffect.empty()) return; - for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) { + for (std::vector<CVehicleToEffect>::iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end();) { if (assoc->GetVehicle() != pVehicle) { ++assoc; continue; @@ -231,7 +229,7 @@ CVector CPedShelterAttractor::GetDisplacement(int32 qid) const float fRandomOffset = CGeneral::GetRandomNumberInRange(0.0f, 2.0f); CVector vecDisplacement(fRandomOffset * Sin(fRandomAngle), fRandomOffset * Cos(fRandomAngle), 0.0f); bool close = false; - for (std::vector<CVector>::const_iterator v = ms_displacements.cbegin(); v != ms_displacements.cend(); ++v) { + for (std::vector<CVector>::const_iterator v = ms_displacements.begin(); v != ms_displacements.end(); ++v) { if ((*v - vecDisplacement).Magnitude() < 1.0f) { close = true; break; @@ -267,7 +265,7 @@ void CPedShelterAttractor::ComputeAttractHeading(int32 qid, float& heading) cons bool CPedAttractor::RegisterPed(CPed* pPed) { - for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) { vApproachingQueue.erase(pPedIt); return false; @@ -320,7 +318,7 @@ static bool IsPedUsingAttractorOfThisType(int8 type, CPed* pPed) bool CPedAttractor::DeRegisterPed(CPed* pPed) { - for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { if (*pPedIt != pPed) continue; pPed->m_attractor = nil; @@ -342,12 +340,12 @@ bool CPedAttractor::DeRegisterPed(CPed* pPed) bool CPedAttractor::BroadcastArrival(CPed* pPed) { - for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) return false; } vWaitingQueue.push_back(pPed); - for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) { vApproachingQueue.erase(pPedIt); break; @@ -402,7 +400,7 @@ bool CPedAttractor::BroadcastDeparture(CPed* pPed) pPed->SetWanderPath(CGeneral::GetNodeHeadingFromVector(-vecQueueDir.y, -vecQueueDir.x)); UpdatePedStateOnDeparture(pPed); } - vWaitingQueue.erase(vWaitingQueue.cbegin() + qid); + vWaitingQueue.erase(vWaitingQueue.begin() + qid); for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { CPed* pPed = *pPedIt; CVector pos; @@ -443,7 +441,7 @@ bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed) pPed->SetWanderPath(CGeneral::GetNodeHeadingFromVector(-vecQueueDir.y, -vecQueueDir.x)); UpdatePedStateOnDeparture(pPed); } - vWaitingQueue.erase(vWaitingQueue.cbegin() + qid); + vWaitingQueue.erase(vWaitingQueue.begin() + qid); for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { CPed* pPed = *pPedIt; CVector pos; @@ -460,11 +458,11 @@ bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed) bool CPedAttractor::IsRegisteredWithPed(CPed* pPed) const { - for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) return true; } - for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) { return true; } @@ -474,7 +472,7 @@ bool CPedAttractor::IsRegisteredWithPed(CPed* pPed) const bool CPedAttractor::IsInQueue(CPed* pPed) const { - for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) { + for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) { if (*pPedIt == pPed) return true; } @@ -642,7 +640,7 @@ void CPedAttractorManager::ComputeEffectUseDir(const C2dEffect* pEffect, const C CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix, std::vector<CPedAttractor*>& vecAttractors) { CPedAttractor* pRegisteredAttractor = nil; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { CPedAttractor* pAttractor = *pAttractorIt; CVector vEffectPos; ComputeEffectPos(pAttractor->GetEffect(), matrix, vEffectPos); @@ -678,7 +676,7 @@ bool CPedAttractorManager::DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor, if (!pAttractor) return false; CPedAttractor* pFound = nil; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { pFound = *pAttractorIt; break; @@ -689,7 +687,7 @@ bool CPedAttractorManager::DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor, pFound->DeRegisterPed(pPed); if (pFound->GetNoOfRegisteredPeds() != 0) return true; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { vecAttractors.erase(pAttractorIt); break; @@ -704,7 +702,7 @@ bool CPedAttractorManager::BroadcastArrival(CPed* pPed, CPedAttractor* pAttracto if (!pAttractor) return false; CPedAttractor* pFound = nil; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { pFound = *pAttractorIt; break; @@ -721,7 +719,7 @@ bool CPedAttractorManager::BroadcastDeparture(CPed* pPed, CPedAttractor* pAttrac if (!pAttractor) return false; CPedAttractor* pFound = nil; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { pFound = *pAttractorIt; break; @@ -732,7 +730,7 @@ bool CPedAttractorManager::BroadcastDeparture(CPed* pPed, CPedAttractor* pAttrac pFound->DeRegisterPed(pPed); if (pFound->GetNoOfRegisteredPeds() != 0) return true; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { vecAttractors.erase(pAttractorIt); break; @@ -746,7 +744,7 @@ bool CPedAttractorManager::IsInQueue(CPed* pPed, CPedAttractor* pAttractor, std: { if (!pAttractor) return false; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { return (*pAttractorIt)->IsInQueue(pPed); } @@ -758,7 +756,7 @@ bool CPedAttractorManager::IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor { if (!pAttractor) return false; - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if (*pAttractorIt == pAttractor) { return (*pAttractorIt)->IsAtHeadOfQueue(pPed); } @@ -768,7 +766,7 @@ bool CPedAttractorManager::IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor bool CPedAttractorManager::IsPedRegistered(CPed* pPed, std::vector<CPedAttractor*>& vecAttractors) { - for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) { + for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) { if ((*pAttractorIt)->IsRegisteredWithPed(pPed)) return true; } diff --git a/src/peds/PedAttractor.h b/src/peds/PedAttractor.h index 85b4327b..c55e4028 100644 --- a/src/peds/PedAttractor.h +++ b/src/peds/PedAttractor.h @@ -126,8 +126,8 @@ public: class CPedAtmAttractor : public CPedAttractor { public: - virtual ePedAttractorType GetType() const override { return ATTRACTOR_ATM; }; - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override; + virtual ePedAttractorType GetType() const { return ATTRACTOR_ATM; }; + virtual void UpdatePedStateOnDeparture(CPed* pPed) const; CPedAtmAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) {}; @@ -136,9 +136,9 @@ public: class CPedIceCreamAttractor : public CPedAttractor { public: - virtual ~CPedIceCreamAttractor() override { GetPedAttractorManager()->RemoveIceCreamVanEffects(p2dEffect); } - virtual ePedAttractorType GetType() const override { return ATTRACTOR_ICECREAM; } - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {}; + virtual ~CPedIceCreamAttractor() { GetPedAttractorManager()->RemoveIceCreamVanEffects(p2dEffect); } + virtual ePedAttractorType GetType() const { return ATTRACTOR_ICECREAM; } + virtual void UpdatePedStateOnDeparture(CPed* pPed) const {}; CPedIceCreamAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) {}; @@ -147,9 +147,9 @@ public: class CPedPizzaAttractor : public CPedAttractor { public: - virtual float GetHeadOfQueueWaitTime() override { return 2000.0f; } - virtual ePedAttractorType GetType() const override { return ATTRACTOR_PIZZA; } - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override; + virtual float GetHeadOfQueueWaitTime() { return 2000.0f; } + virtual ePedAttractorType GetType() const { return ATTRACTOR_PIZZA; } + virtual void UpdatePedStateOnDeparture(CPed* pPed) const; CPedPizzaAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) {}; @@ -158,8 +158,8 @@ public: class CPedSeatAttractor : public CPedAttractor { public: - virtual ePedAttractorType GetType() const override { return ATTRACTOR_SEAT; } - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {}; + virtual ePedAttractorType GetType() const { return ATTRACTOR_SEAT; } + virtual void UpdatePedStateOnDeparture(CPed* pPed) const {}; CPedSeatAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) {}; @@ -169,12 +169,12 @@ class CPedShelterAttractor : public CPedAttractor { static std::vector<CVector> ms_displacements; public: - virtual ePedAttractorType GetType() const override { return ATTRACTOR_SHELTER; } - virtual bool BroadcastDeparture(CPed*) override; - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {}; - virtual bool IsAtHeadOfQueue(CPed* pPed) const override { return true; } - virtual void ComputeAttractPos(int qid, CVector& pos) const override; - virtual void ComputeAttractHeading(int qid, float& heading) const override; + virtual ePedAttractorType GetType() const { return ATTRACTOR_SHELTER; } + virtual bool BroadcastDeparture(CPed*); + virtual void UpdatePedStateOnDeparture(CPed* pPed) const {}; + virtual bool IsAtHeadOfQueue(CPed* pPed) const { return true; } + virtual void ComputeAttractPos(int qid, CVector& pos) const; + virtual void ComputeAttractHeading(int qid, float& heading) const; CPedShelterAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) @@ -187,8 +187,8 @@ public: class CPedStopAttractor : public CPedAttractor { public: - virtual ePedAttractorType GetType() const override { return ATTRACTOR_STOP; } - virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {}; + virtual ePedAttractorType GetType() const { return ATTRACTOR_STOP; } + virtual void UpdatePedStateOnDeparture(CPed* pPed) const {}; CPedStopAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) : CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp) diff --git a/src/peds/PedChat.cpp b/src/peds/PedChat.cpp index 470b7eeb..ec6719c6 100644 --- a/src/peds/PedChat.cpp +++ b/src/peds/PedChat.cpp @@ -4,8 +4,6 @@ #include "General.h" #include "Ped.h" -// --MIAMI: file done - // Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) PedAudioData CommentWaitTime[56] = { { 500, 800, 500, 2 }, diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index d1f39491..6c691d2d 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -26,8 +26,6 @@ #include "Glass.h" #include "SpecialFX.h" -//--MIAMI: file done - uint16 nPlayerInComboMove; RpClump* flyingClumpTemp; @@ -161,7 +159,6 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround) return stateToReturn; } -// --MIAMI: Done void CPed::SetPointGunAt(CEntity *to) { @@ -204,7 +201,6 @@ CPed::SetPointGunAt(CEntity *to) Say(SOUND_PED_ATTACK); } -// --MIAMI: Done void CPed::PointGunAt(void) { @@ -232,7 +228,6 @@ CPed::PointGunAt(void) } } -// --MIAMI: Done void CPed::ClearPointGunAt(void) { @@ -259,7 +254,6 @@ CPed::ClearPointGunAt(void) } } -// --MIAMI: Done void CPed::SetAttack(CEntity *victim) { @@ -442,7 +436,6 @@ CPed::SetAttack(CEntity *victim) SetLookTimer(100); } -// --MIAMI: Done void CPed::ClearAttack(void) { @@ -463,7 +456,6 @@ CPed::ClearAttack(void) } } -// --MIAMI: Done void CPed::ClearAttackByRemovingAnim(void) { @@ -499,7 +491,6 @@ CPed::ClearAttackByRemovingAnim(void) } } -// --MIAMI: Done void CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) { @@ -579,7 +570,6 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) } } -// --MIAMI: Done void CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg) { @@ -613,7 +603,6 @@ CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg) } } -// --MIAMI: Done uint8 CPed::CheckForPointBlankPeds(CPed *pedToVerify) { @@ -657,7 +646,6 @@ CPed::CheckForPointBlankPeds(CPed *pedToVerify) return NO_POINT_BLANK_PED; } -// --MIAMI: Done except commented things void CPed::Attack(void) { @@ -1045,7 +1033,6 @@ CPed::Attack(void) bIsAttacking = attackShouldContinue; } -// --MIAMI: Done void CPed::StartFightAttack(uint8 buttonPressure) { @@ -1135,7 +1122,6 @@ CPed::StartFightAttack(uint8 buttonPressure) nPlayerInComboMove = 0; } -// --MIAMI: Done void CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) { @@ -1385,7 +1371,6 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) } } -// --MIAMI: Done void CPed::Fight(void) { @@ -1610,7 +1595,6 @@ CPed::Fight(void) } } -// --MIAMI: Done int32 CPed::ChooseAttackAI(uint8 buttonPressure, bool fightWithWeapon) { @@ -1698,7 +1682,6 @@ CPed::ChooseAttackAI(uint8 buttonPressure, bool fightWithWeapon) return FIGHTMOVE_SHUFFLE_F; } -// --MIAMI: Done int32 CPed::ChooseAttackPlayer(uint8 buttonPressure, bool fightWithWeapon) { @@ -1947,7 +1930,6 @@ CPed::ChooseAttackPlayer(uint8 buttonPressure, bool fightWithWeapon) return choosenMove; } -// --MIAMI: Done void CPed::EndFight(uint8 endType) { @@ -1982,7 +1964,6 @@ CPed::EndFight(uint8 endType) m_nWaitTimer = 0; } -// --MIAMI: Done void CPed::PlayHitSound(CPed *hitTo) { @@ -2060,7 +2041,6 @@ CPed::PlayHitSound(CPed *hitTo) #endif } -// --MIAMI: Done bool CPed::FightStrike(CVector &touchedNodePos, bool fightWithWeapon) { @@ -2157,7 +2137,6 @@ CPed::FightStrike(CVector &touchedNodePos, bool fightWithWeapon) return false; } -// --MIAMI: Done void CPed::FightHitPed(CPed *victim, CVector &touchPoint, CVector &dir, int16 piece) { @@ -2308,7 +2287,6 @@ CPed::FightHitPed(CPed *victim, CVector &touchPoint, CVector &dir, int16 piece) } } -// --MIAMI: Done void CPed::FinishFightMoveCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -2320,7 +2298,6 @@ CPed::FinishFightMoveCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::LoadFightData(void) { @@ -2408,7 +2385,6 @@ CPed::LoadFightData(void) } } -// --MIAMI: Done void CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCountDone, uint16 time, float angle) { @@ -2431,7 +2407,6 @@ CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCount } -// --MIAMI: Done void CPed::InvestigateEvent(void) { @@ -2637,7 +2612,6 @@ CPed::InvestigateEvent(void) } } -// --MIAMI: Done void CPed::ClearInvestigateEvent(void) { @@ -2663,7 +2637,6 @@ CPed::ClearInvestigateEvent(void) SetMoveState(PEDMOVE_WALK); } -// --MIAMI: Done bool CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPieceTypes pedPiece, uint8 direction) { @@ -3235,7 +3208,6 @@ RecurseFrameChildrenToCloneCB(RwFrame *frame, void *data) return newFrame; } -// --MIAMI: Done void CPed::RemoveBodyPart(PedNode nodeId, int8 direction) { @@ -3266,7 +3238,6 @@ CPed::RemoveBodyPart(PedNode nodeId, int8 direction) } } -// --MIAMI: Done CObject* CPed::SpawnFlyingComponent(int pedNode, int8 direction) { @@ -3274,7 +3245,6 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction) return nil; } -// --MIAMI: Done // III leftover and unused void CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer) @@ -3317,14 +3287,12 @@ CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer) } } -// --MIAMI: Done bool CPed::IsPedHeadAbovePos(float zOffset) { return zOffset + GetPosition().z < GetNodePosition(PED_HEAD).z; } -// --MIAMI: Done bool CPed::PlacePedOnDryLand(void) { @@ -3376,7 +3344,6 @@ CPed::PlacePedOnDryLand(void) return true; } -// --MIAMI: Done void CPed::CollideWithPed(CPed *collideWith) { @@ -3643,7 +3610,6 @@ CPed::CollideWithPed(CPed *collideWith) } } -// --MIAMI: Done void CPed::KillPedWithCar(CVehicle *car, float impulse) { @@ -3881,7 +3847,6 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) } } -// --MIAMI: Done void CPed::DriveVehicle(void) { @@ -4189,7 +4154,6 @@ CPed::DriveVehicle(void) } } -// --MIAMI: Done void CPed::RemoveWeaponAnims(int unused, float animDelta) { diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 2925667a..475e04f1 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -7,8 +7,6 @@ #include "General.h" #include "RwHelper.h" -//--MIAMI: file done - LimbMovementInfo CPedIK::ms_torsoInfo = { DEGTORAD(50.0f), DEGTORAD(-50.0f), DEGTORAD(8.0f), DEGTORAD(45.0f), DEGTORAD(-45.0f), DEGTORAD(5.0f) }; LimbMovementInfo CPedIK::ms_headInfo = { DEGTORAD(90.0f), DEGTORAD(-90.0f), DEGTORAD(15.0f), DEGTORAD(45.0f), DEGTORAD(-45.0f), DEGTORAD(8.0f) }; LimbMovementInfo CPedIK::ms_headRestoreInfo = { DEGTORAD(90.0f), DEGTORAD(-90.0f), DEGTORAD(10.0f), DEGTORAD(45.0f), DEGTORAD(-45.0f), DEGTORAD(5.0f) }; diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp index 8012650a..840d33fc 100644 --- a/src/peds/PedPlacement.cpp +++ b/src/peds/PedPlacement.cpp @@ -4,7 +4,6 @@ #include "PedPlacement.h" #include "World.h" -// --MIAMI: Done bool CPedPlacement::FindZCoorForPed(CVector* pos) { diff --git a/src/peds/PedRoutes.cpp b/src/peds/PedRoutes.cpp index 2de90eae..3ff080e6 100644 --- a/src/peds/PedRoutes.cpp +++ b/src/peds/PedRoutes.cpp @@ -3,8 +3,6 @@ #include "main.h" #include "PedRoutes.h" -// --MIAMI: file done - CRouteNode gaRoutes[NUMPEDROUTES]; void diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index bc6395b0..bacb1a78 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -4,8 +4,6 @@ #include "FileMgr.h" #include "PedType.h" -// --MIAMI: file done - CPedType *CPedType::ms_apPedType[NUM_PEDTYPES]; CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS]; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 350b527a..7308b3fb 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -51,7 +51,6 @@ CPlayerPed::~CPlayerPed() delete m_pWanted; } -// --MIAMI: Done CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) { m_fMoveSpeed = 0.0f; @@ -100,7 +99,6 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) idleAnimBlockIndex = CAnimManager::GetAnimationBlockIndex("playidles"); } -// --MIAMI: Done void CPlayerPed::ClearWeaponTarget() { @@ -112,21 +110,18 @@ CPlayerPed::ClearWeaponTarget() ClearPointGunAt(); } -// --MIAMI: Done void CPlayerPed::SetWantedLevel(int32 level) { m_pWanted->SetWantedLevel(level); } -// --MIAMI: Done void CPlayerPed::SetWantedLevelNoDrop(int32 level) { m_pWanted->SetWantedLevelNoDrop(level); } -// --MIAMI: Done void CPlayerPed::MakeObjectTargettable(int32 handle) { @@ -138,7 +133,6 @@ CPlayerPed::MakeObjectTargettable(int32 handle) } } -// --MIAMI: Done // I don't know the actual purpose of parameter void CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity) @@ -152,7 +146,6 @@ CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity) } } -// --MIAMI: Done void CPlayerPed::ClearAdrenaline(void) { @@ -162,7 +155,6 @@ CPlayerPed::ClearAdrenaline(void) } } -// --MIAMI: Done CPlayerInfo * CPlayerPed::GetPlayerInfoForThisPlayerPed() { @@ -172,7 +164,6 @@ CPlayerPed::GetPlayerInfoForThisPlayerPed() return nil; } -// --MIAMI: Done void CPlayerPed::SetupPlayerPed(int32 index) { @@ -193,21 +184,18 @@ CPlayerPed::SetupPlayerPed(int32 index) #endif } -// --MIAMI: Done void CPlayerPed::DeactivatePlayerPed(int32 index) { CWorld::Remove(CWorld::Players[index].m_pPed); } -// --MIAMI: Done void CPlayerPed::ReactivatePlayerPed(int32 index) { CWorld::Add(CWorld::Players[index].m_pPed); } -// --MIAMI: Done void CPlayerPed::UseSprintEnergy(void) { @@ -224,7 +212,6 @@ CPlayerPed::UseSprintEnergy(void) } } -// --MIAMI: Done void CPlayerPed::MakeChangesForNewWeapon(eWeaponType weapon) { @@ -249,7 +236,6 @@ CPlayerPed::MakeChangesForNewWeapon(eWeaponType weapon) TheCamera.ClearPlayerWeaponMode(); } -// --MIAMI: Done void CPlayerPed::MakeChangesForNewWeapon(int32 slot) { @@ -257,7 +243,6 @@ CPlayerPed::MakeChangesForNewWeapon(int32 slot) MakeChangesForNewWeapon(m_weapons[slot].m_eWeaponType); } -// --MIAMI: Done void CPlayerPed::ReApplyMoveAnims(void) { @@ -277,7 +262,6 @@ CPlayerPed::ReApplyMoveAnims(void) } } -// --MIAMI: Done void CPlayerPed::SetInitialState(void) { @@ -324,7 +308,6 @@ CPlayerPed::SetInitialState(void) m_attachWepAmmo = 0; } -// --MIAMI: Done void CPlayerPed::SetRealMoveAnim(void) { @@ -568,7 +551,6 @@ CPlayerPed::SetRealMoveAnim(void) } } -// --MIAMI: Done void CPlayerPed::RestoreSprintEnergy(float restoreSpeed) { @@ -576,7 +558,6 @@ CPlayerPed::RestoreSprintEnergy(float restoreSpeed) m_fCurrentStamina += restoreSpeed * CTimer::GetTimeStep() * 0.5f; } -// --MIAMI: Done float CPlayerPed::DoWeaponSmoothSpray(void) { @@ -626,7 +607,6 @@ CPlayerPed::DoWeaponSmoothSpray(void) return -1.0f; } -// --MIAMI: Done void CPlayerPed::DoStuffToGoOnFire(void) { @@ -634,7 +614,6 @@ CPlayerPed::DoStuffToGoOnFire(void) TheCamera.ClearPlayerWeaponMode(); } -// --MIAMI: Done bool CPlayerPed::DoesTargetHaveToBeBroken(CVector target, CWeapon *weaponUsed) { @@ -646,7 +625,6 @@ CPlayerPed::DoesTargetHaveToBeBroken(CVector target, CWeapon *weaponUsed) return false; } -// --MIAMI: Done // Cancels landing anim while running & jumping? I think void CPlayerPed::RunningLand(CPad *padUsed) @@ -665,7 +643,6 @@ CPlayerPed::RunningLand(CPad *padUsed) } } -// --MIAMI: Done bool CPlayerPed::IsThisPedAnAimingPriority(CPed *suspect) { @@ -688,7 +665,6 @@ CPlayerPed::IsThisPedAnAimingPriority(CPed *suspect) return suspect->m_nPedState == PED_ABSEIL; } -// --MIAMI: Done void CPlayerPed::PlayerControlSniper(CPad *padUsed) { @@ -725,7 +701,6 @@ CPlayerPed::PlayerControlSniper(CPad *padUsed) GetWeapon()->Update(m_audioEntityId, nil); } -// --MIAMI: Done // I think R* also used goto in here. void CPlayerPed::ProcessWeaponSwitch(CPad *padUsed) @@ -816,7 +791,6 @@ switchDetectDone: } } -// --MIAMI: Done void CPlayerPed::PlayerControlM16(CPad *padUsed) { @@ -853,7 +827,6 @@ CPlayerPed::PlayerControlM16(CPad *padUsed) GetWeapon()->Update(m_audioEntityId, nil); } -// --MIAMI: Done void CPlayerPed::PlayerControlFighter(CPad *padUsed) { @@ -879,7 +852,6 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed) } } -// --MIAMI: Done void CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed) { @@ -940,7 +912,6 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed) #endif } -// --MIAMI: Done void CPlayerPed::KeepAreaAroundPlayerClear(void) { @@ -990,7 +961,6 @@ CPlayerPed::KeepAreaAroundPlayerClear(void) } } -// --MIAMI: Done void CPlayerPed::EvaluateNeighbouringTarget(CEntity *candidate, CEntity **targetPtr, float *lastCloseness, float distLimit, float angleOffset, bool lookToLeft, bool priority) { @@ -1017,7 +987,6 @@ CPlayerPed::EvaluateNeighbouringTarget(CEntity *candidate, CEntity **targetPtr, } } -// --MIAMI: Done void CPlayerPed::EvaluateTarget(CEntity *candidate, CEntity **targetPtr, float *lastCloseness, float distLimit, float angleOffset, bool priority) { @@ -1072,7 +1041,6 @@ CPlayerPed::RotatePlayerToTrackTarget(void) } } -// --MIAMI: Done bool CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) { @@ -1115,7 +1083,6 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) return true; } -// --MIAMI: Done bool CPlayerPed::FindWeaponLockOnTarget(void) { @@ -1167,7 +1134,6 @@ CPlayerPed::FindWeaponLockOnTarget(void) return true; } -// --MIAMI: Done void CPlayerPed::ProcessAnimGroups(void) { @@ -1477,7 +1443,6 @@ CPlayerPed::MovementDisabledBecauseOfTargeting(void) return m_pPointGunAt && !CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM); } -// --MIAMI: Done void CPlayerPed::PlayerControlZelda(CPad *padUsed) { @@ -1655,7 +1620,7 @@ CPlayerPed::ProcessControl(void) if (m_nEvadeAmount == 0) m_pEvadingFrom = nil; - if (m_pWanted->m_nWantedLevel > 0) + if (m_pWanted->GetWantedLevel() > 0) FindNewAttackPoints(); UpdateMeleeAttackers(); @@ -1953,7 +1918,6 @@ CPlayerPed::ProcessControl(void) UpdateRpHAnim(); } -// --MIAMI: Done bool CPlayerPed::DoesPlayerWantNewWeapon(eWeaponType weapon, bool onlyIfSlotIsEmpty) { @@ -2037,7 +2001,6 @@ CPlayerPed::PlayIdleAnimations(CPad *padUsed) } } -// --MIAMI: Done void CPlayerPed::SetNearbyPedsToInteractWithPlayer(void) { @@ -2072,7 +2035,6 @@ CPlayerPed::SetNearbyPedsToInteractWithPlayer(void) } } -// --MIAMI: Done void CPlayerPed::UpdateMeleeAttackers(void) { @@ -2115,7 +2077,6 @@ CPlayerPed::UpdateMeleeAttackers(void) && m_pMeleeList[4] == this && m_pMeleeList[5] == this; } -// --MIAMI: Done void CPlayerPed::RemovePedFromMeleeList(CPed *ped) { @@ -2128,7 +2089,6 @@ CPlayerPed::RemovePedFromMeleeList(CPed *ped) ped->m_attackTimer = 0; } -// --MIAMI: Done void CPlayerPed::GetMeleeAttackCoords(CVector& coords, int8 dir, float dist) { @@ -2161,7 +2121,6 @@ CPlayerPed::GetMeleeAttackCoords(CVector& coords, int8 dir, float dist) } } -// --MIAMI: Done int32 CPlayerPed::FindMeleeAttackPoint(CPed *victim, CVector &dist, uint32 &endOfAttackOut) { diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 4284def5..0119b475 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -29,8 +29,6 @@ #include "Clock.h" #include "WaterLevel.h" -// --MIAMI: File done - #define MIN_CREATION_DIST 40.0f // not for start of the game (look at the GeneratePedsAtStartOfGame) #define CREATION_RANGE 10.0f // added over the MIN_CREATION_DIST. #define OFFSCREEN_CREATION_MULT 0.5f @@ -537,7 +535,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree CTheZones::GetZoneInfoForTimeOfDay(&playerCentreOfWorld, &zoneInfo); CWanted *wantedInfo = playerInfo->m_pPed->m_pWanted; - if (wantedInfo->m_nWantedLevel > 2) { + if (wantedInfo->GetWantedLevel() > 2) { if (!CGame::IsInInterior() && (CGeneral::GetRandomNumber() % 32 == 0) && FindPlayerVehicle()) forceAddingCop = true; diff --git a/src/render/Antennas.cpp b/src/render/Antennas.cpp index b9da95cb..452069a0 100644 --- a/src/render/Antennas.cpp +++ b/src/render/Antennas.cpp @@ -2,8 +2,6 @@ #include "Antennas.h" -//--MIAMI: file done - CAntenna CAntennas::aAntennas[NUMANTENNAS]; void diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 515e1000..e3d3416c 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -18,8 +18,6 @@ #include "Clock.h" #include "Bridge.h" -//--MIAMI: file done - struct FlareDef { float position; diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 6c811b7f..883ad2f2 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -9,8 +9,6 @@ #include "Credits.h" #include "Pad.h" -// --MIAMI: file done - bool CCredits::bCreditsGoing; uint32 CCredits::CreditsStartTime; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 507653f6..13cbd1b3 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -5,8 +5,8 @@ #include "Camera.h" #include "CutsceneMgr.h" -#ifdef ASPECT_RATIO_SCALE float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO; +#ifdef ASPECT_RATIO_SCALE float CDraw::ms_fScaledFOV = 45.0f; #endif diff --git a/src/render/Draw.h b/src/render/Draw.h index 1a63c980..e67ab42b 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -16,10 +16,10 @@ private: static float ms_fNearClipZ; static float ms_fFarClipZ; static float ms_fFOV; -#ifdef ASPECT_RATIO_SCALE // we use this variable to scale a lot of 2D elements // so better cache it static float ms_fAspectRatio; +#ifdef ASPECT_RATIO_SCALE // similar thing for 3D rendering static float ms_fScaledFOV; #endif diff --git a/src/render/Font.cpp b/src/render/Font.cpp index b559ca7a..45ea9ac2 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -358,7 +358,7 @@ CFont::PrintChar(float x, float y, wchar c) CSprite2d::AddToBuffer( CRect(x, y + RenderState.scaleY * 4.0f, x + 32.0f * RenderState.scaleY * xScale * 0.96f, - y + 4.0f * RenderState.scaleY * + 16.0f * RenderState.scaleY), + y + 4.0f * RenderState.scaleY + 16.0f * RenderState.scaleY), RenderState.color, xoff / 16.0f, yoff / 12.8f + 0.0021f, (xoff + 1.0f) / 16.0f - 0.001f, yoff / 12.8f + 0.0021f, diff --git a/src/render/Font.h b/src/render/Font.h index 05c367fb..4046ebb5 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -1,5 +1,7 @@ #pragma once +#include "Sprite2d.h" + void AsciiToUnicode(const char *src, wchar *dst); void UnicodeStrcpy(wchar *dst, const wchar *src); void UnicodeStrcat(wchar *dst, wchar *append); diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index a11495a9..c6d02755 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "Glass.h" #include "Timer.h" diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index e896b871..12bfd040 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -26,8 +26,6 @@ #include "General.h" #include "VarConsole.h" -// --MIAMI: file done - #if defined(FIX_BUGS) #define SCREEN_SCALE_X_FIX(a) SCREEN_SCALE_X(a) #define SCREEN_SCALE_Y_FIX(a) SCREEN_SCALE_Y(a) @@ -41,14 +39,14 @@ // Game has colors inlined in code. // For easier modification we collect them here: CRGBA MONEY_COLOR(0, 207, 133, 255); -CRGBA AMMO_COLOR(255, 150, 225, 255); +CRGBA AMMO_COLOR(255, 255, 255, 255); CRGBA HEALTH_COLOR(255, 150, 225, 255); 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); @@ -132,6 +130,8 @@ CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; wchar* CHud::gLastPrintForeverString; +uint8 CHud::m_HudAlpha = 209; + struct { const char *name; @@ -188,24 +188,25 @@ struct { "", "" }, { "", "" }, { "radardisc", "radardisc" }, + { "radardiscback", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, - { "", "" }, - { "", "" }, - { "", "" }, - { "", "" }, - { "", "" }, - { "", "" }, - { "", "" }, + { "bar_inside1dark", "" }, + { "bar_inside2dark", "" }, + { "hudnumbers", "" }, + { "bar_inside1", "" }, + { "bar_inside2", "" }, + { "bar_outline", "" }, { "sitesniper", "sitesniperm" }, { "siteM16", "siteM16m" }, { "sitelaser", "sitelaserm" }, { "laserdot", "laserdotm" }, { "viewfinder_128", "viewfinder_128m" }, - { "bleeder", "" } + { "bleeder", "" }, + { "gren_rem", "noMaskNeeded" } }; RwTexture *gpSniperSightTex; @@ -214,6 +215,7 @@ RwTexture *gpLaserSightTex; RwTexture *gpLaserDotTex; RwTexture *gpViewFinderTex; +// TODO(LCS): some things were reversed from LCS but not all void CHud::Draw() { RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); @@ -406,6 +408,8 @@ void CHud::Draw() DrawMoneyCounter */ + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); // TODO(LCS): temp filtering fix for money counter, remove later + wchar sPrint[16]; wchar sPrintIcon[16]; char sTemp[16]; @@ -418,25 +422,8 @@ void CHud::Draw() m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; } if (m_DisplayScoreState != FADED_OUT) { - sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney); - AsciiToUnicode(sTemp, sPrint); - - CFont::SetPropOff(); - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); - CFont::SetCentreOff(); - CFont::SetRightJustifyOn(); - CFont::SetRightJustifyWrap(0.0f); - CFont::SetBackGroundOnlyTextOff(); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetPropOff(); - CFont::SetDropShadowPosition(2); - CFont::SetDropColor(CRGBA(0, 0, 0, alpha)); - MONEY_COLOR.a = alpha; - CFont::SetColor(MONEY_COLOR); - if (FrontEndMenuManager.m_PrefsShowHud) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); + DrawCash(); } } @@ -449,46 +436,23 @@ void CHud::Draw() alpha = CHud::DrawFadeState(HUD_WEAPON_FADING, 1); m_LastWeapon = playerPed->GetWeapon()->m_eWeaponType; } + alpha = Min(alpha, m_HudAlpha); if (m_WeaponState != FADED_OUT) { CWeapon *weapon = playerPed->GetWeapon(); - int32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition; - int32 AmmoInClip = weapon->m_nAmmoInClip; - int32 TotalAmmo = weapon->m_nAmmoTotal; - int32 Ammo, Clip; - - if (AmmoAmount <= 1 || AmmoAmount >= 1000) - sprintf(sTemp, "%d", TotalAmmo); - else { - if (WeaponType == WEAPONTYPE_FLAMETHROWER) { - Clip = AmmoInClip / 10; - - Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999); - } else { - Clip = AmmoInClip; - - Ammo = Min(TotalAmmo - AmmoInClip, 9999); - } - - sprintf(sTemp, "%d-%d", Ammo, Clip); - } - - AsciiToUnicode(sTemp, sPrint); CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType); /* DrawWeaponIcon */ if (FrontEndMenuManager.m_PrefsShowHud) { + float right = FrontEndMenuManager.m_PrefsUseWideScreen ? 468.6f : 470.0f; + float left = right - (FrontEndMenuManager.m_PrefsUseWideScreen ? 48.6f : 54.0f); if (weaponInfo->m_nModelId <= 0) { RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); if (FrontEndMenuManager.m_PrefsShowHud) Sprites[WeaponType].Draw( - CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)), - CRGBA(255, 255, 255, alpha), - 0.015f, 0.015f, - 1.0f, 0.0f, - 0.015f, 1.0f, - 1.0f, 1.0f); + CRect(PSP_SCREEN_SCALE_X(left), PSP_SCREEN_SCALE_Y(16.0f), PSP_SCREEN_SCALE_X(right), PSP_SCREEN_SCALE_Y(60.0f)), + CRGBA(255, 255, 255, alpha)); } else { CBaseModelInfo *weaponModel = CModelInfo::GetModelInfo(weaponInfo->m_nModelId); RwTexDictionary *weaponTxd = CTxdStore::GetSlot(weaponModel->GetTxdSlot())->texDict; @@ -508,12 +472,8 @@ void CHud::Draw() static CSprite2d sprite; sprite.m_pTexture = weaponIcon; sprite.Draw( - CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)), - CRGBA(255, 255, 255, alpha), - 0.015f, 0.015f, - 1.0f, 0.0f, - 0.015f, 1.0f, - 1.0f, 1.0f); + CRect(PSP_SCREEN_SCALE_X(left), PSP_SCREEN_SCALE_Y(16.0f), PSP_SCREEN_SCALE_X(right), PSP_SCREEN_SCALE_Y(60.0f)), + CRGBA(255, 255, 255, alpha)); sprite.m_pTexture = nil; #endif } @@ -521,7 +481,7 @@ void CHud::Draw() } CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.8f)); + CFont::SetScale(PSP_SCREEN_SCALE_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.18f : 0.2f), PSP_SCREEN_SCALE_Y(0.44f)); CFont::SetJustifyOff(); CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); @@ -529,13 +489,65 @@ void CHud::Draw() CFont::SetDropShadowPosition(0); CFont::SetFontStyle(FONT_STANDARD); + int32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition; + int32 AmmoInClip = weapon->m_nAmmoInClip; + int32 TotalAmmo = weapon->m_nAmmoTotal; + int32 Ammo, Clip; + if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, alpha)); AMMO_COLOR.a = alpha; CFont::SetColor(AMMO_COLOR); - if (FrontEndMenuManager.m_PrefsShowHud) - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint); + if (FrontEndMenuManager.m_PrefsShowHud) { + + + if (AmmoAmount <= 1 || AmmoAmount >= 1000) + { + sprintf(sTemp, "%d", TotalAmmo); + AsciiToUnicode(sTemp, sPrint); + float pos = 435.0f; +#ifdef FIX_BUGS + if (FrontEndMenuManager.m_PrefsUseWideScreen) + pos = 438.0f; +#endif + CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - pos), PSP_SCREEN_SCALE_Y(42.0f), sPrint); + } + else { + + if (WeaponType == WEAPONTYPE_FLAMETHROWER) { + Clip = AmmoInClip / 10; + + Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999); + } + else { + Clip = AmmoInClip; + + Ammo = Min(TotalAmmo - AmmoInClip, 9999); + } + + char sMinus[10]; + char sAmmo[20]; + char sClip[20]; + + sprintf(sMinus, "-"); + sprintf(sAmmo, "%d", Ammo); + sprintf(sClip, "%d", Clip); + + CFont::SetCentreOff(); + CFont::SetRightJustifyOn(); + AsciiToUnicode(sAmmo, sPrint); + CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 438.0f : 435.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint); + + CFont::SetRightJustifyOff(); + AsciiToUnicode(sMinus, sPrint); + CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 439.0f : 436.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint); + + AsciiToUnicode(sClip, sPrint); + CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 441.0f : 439.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint); + + } + } CFont::SetDropShadowPosition(0); } } @@ -569,23 +581,8 @@ void CHud::Draw() && CTimer::GetFrameCounter() & 8) { if (playerPed->m_fHealth >= 10 || playerPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { - - AsciiToUnicode("{", sPrintIcon); -#ifdef FIX_BUGS - sprintf(sTemp, "%03d", int32(playerPed->m_fHealth + 0.5f)); -#else - sprintf(sTemp, "%03d", (int32)playerPed->m_fHealth); -#endif - AsciiToUnicode(sTemp, sPrint); - - CFont::SetColor(HEALTH_COLOR); if (FrontEndMenuManager.m_PrefsShowHud) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint); - - if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { - // CFont::SetColor(HEALTH_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 54.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); - } + DrawHealthBar(playerPed->m_fHealth); } } } @@ -606,13 +603,7 @@ void CHud::Draw() CFont::SetColor(ARMOUR_COLOR); if (FrontEndMenuManager.m_PrefsShowHud) { - - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); - - if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4) { - // CFont::SetColor(ARMOUR_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f + 52.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); - } + DrawArmourBar(playerPed->m_fArmour); } } } @@ -621,44 +612,31 @@ void CHud::Draw() /* DrawWantedLevel */ - if (m_LastWanted == playerPed->m_pWanted->m_nWantedLevel) { + if (m_LastWanted == playerPed->m_pWanted->GetWantedLevel()) { alpha = DrawFadeState(HUD_WANTED_FADING, 0); } else { alpha = DrawFadeState(HUD_WANTED_FADING, 1); - m_LastWanted = playerPed->m_pWanted->m_nWantedLevel; + m_LastWanted = playerPed->m_pWanted->GetWantedLevel(); } if (m_WantedState != FADED_OUT) { - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); - CFont::SetJustifyOff(); - CFont::SetCentreOff(); - CFont::SetRightJustifyOn(); - CFont::SetPropOn(); - CFont::SetFontStyle(FONT_STANDARD); - - AsciiToUnicode(">", sPrintIcon); - + char wantedStar[] = "\x16"; + float starX = 441.0f; for (int i = 0; i < 6; i++) { if (FrontEndMenuManager.m_PrefsShowHud) { - if (playerPed->m_pWanted->m_nWantedLevel > i + if (playerPed->m_pWanted->GetWantedLevel() > i && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange + 2000 || CTimer::GetFrameCounter() & 4)) { - WANTED_COLOR.a = alpha; - CFont::SetColor(WANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + DrawTimeAndCashNumbers(wantedStar, starX, 63.0f, false); } else if (playerPed->m_pWanted->m_nMinWantedLevel > i && CTimer::GetFrameCounter() & 4) { - WANTED_COLOR_FLASH.a = alpha; - CFont::SetColor(WANTED_COLOR_FLASH); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); - - } else if (playerPed->m_pWanted->m_nWantedLevel <= i) { - NOTWANTED_COLOR.a = alpha; - CFont::SetColor(NOTWANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + DrawTimeAndCashNumbers(wantedStar, starX, 63.0f, true); } + if (FrontEndMenuManager.m_PrefsUseWideScreen) + starX -= 11.0f; + else + starX -= 13.5f; } } } @@ -786,14 +764,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(); @@ -803,9 +781,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; } @@ -886,13 +864,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); @@ -902,7 +881,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); } @@ -919,24 +898,8 @@ void CHud::Draw() DrawClock */ if (m_ClockState) { - CFont::SetJustifyOff(); - CFont::SetCentreOff(); - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); - CFont::SetBackGroundOnlyTextOff(); - CFont::SetPropOff(); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetRightJustifyOn(); - CFont::SetRightJustifyWrap(0.0f); - CFont::SetDropShadowPosition(2); - CFont::SetDropColor(CRGBA(0, 0, 0, 255)); - - sprintf(sTemp, "%02d:%02d", CClock::GetHours(), CClock::GetMinutes()); - AsciiToUnicode(sTemp, sPrint); - - CFont::SetColor(CLOCK_COLOR); if (FrontEndMenuManager.m_PrefsShowHud) - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f), SCREEN_SCALE_Y(22.0f), sPrint); + DrawTime(); } /* @@ -1142,20 +1105,20 @@ void CHud::Draw() // Yeah, top and bottom changed place. R* vision if (IntroRect.m_bIsUsed && IntroRect.m_bBeforeFade) { if (IntroRect.m_nTextureId >= 0) { - CRect rect = { + CRect rect ( IntroRect.m_sRect.left, IntroRect.m_sRect.top, IntroRect.m_sRect.right, - IntroRect.m_sRect.bottom }; + IntroRect.m_sRect.bottom ); CTheScripts::ScriptSprites[IntroRect.m_nTextureId].Draw(rect, IntroRect.m_sColor); } else { - CRect rect = { + CRect rect ( IntroRect.m_sRect.left, IntroRect.m_sRect.top, IntroRect.m_sRect.right, - IntroRect.m_sRect.bottom }; + IntroRect.m_sRect.bottom ); CSprite2d::DrawRect(rect, IntroRect.m_sColor); } @@ -1188,7 +1151,7 @@ void CHud::Draw() if (FrontEndMenuManager.m_PrefsShowSubtitles || !CCutsceneMgr::IsRunning()) { #ifdef CUTSCENE_BORDERS_SWITCH if (!FrontEndMenuManager.m_PrefsCutsceneBorders) - CFont::SetDropShadowPosition(2); + CFont::SetDropShadowPosition(0); #endif CFont::SetCentreSize(SCREEN_WIDTH - SCREEN_SCALE_X(60.0f)); CFont::SetScale(SCREEN_SCALE_X(0.58f), SCREEN_SCALE_Y(1.2f)); @@ -1200,7 +1163,7 @@ void CHud::Draw() onceItWasWidescreen = false; CFont::DrawFonts(); - CFont::SetDropShadowPosition(2); + CFont::SetDropShadowPosition(0); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetScale(SCREEN_SCALE_X(0.58f), SCREEN_SCALE_Y(1.22f)); @@ -1426,6 +1389,221 @@ void CHud::Draw() } } +int HealthFlashTimer = 50; + +void +CHud::DrawHealthBar(int16 value) +{ + if (m_ItemToFlash == ITEM_HEALTH) { + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth > 10.0f) { + if (HealthFlashTimer-- == 0) { + m_ItemToFlash = -1; + HealthFlashTimer = 50; + } + } + } + float fHealth = value; + float fMaxHealth = CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth; + fHealth = clamp(fHealth, 0.0f, fMaxHealth); + float fWidth = (fHealth / fMaxHealth) * 40.0f + 16.0f + 4.0f; + float u = fWidth / 64.0f; + if (value == 0) { + fWidth = 0.0f; + u = 0.0f; + } else if (value == fMaxHealth) { + fWidth = 64.0f; + u = 1.0f; + } + + if (FrontEndMenuManager.m_PrefsUseWideScreen) + fWidth *= 0.68f; + else + fWidth *= 0.85f; + + float fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f; + float fX2 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect1(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f)); + CRGBA color1(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_INSIDE2].Draw(rect1, color1, 0.0f, 0.0f, u, 0.0f, 0.0f, 1.0f, u, 1.0f); + + fX1 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect2(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f)); + CRGBA color2(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_INSIDE2DARK].Draw(rect2, color2, u, 0.0f, 1.0f, 0.0f, u, 1.0f, 1.0f, 1.0f); + + fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f; + fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect3(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f)); + CRGBA color3(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_OUTLINE].Draw(rect3, color3, 0.01f, 0.0f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f); + + if (fMaxHealth > 100.0f) + { + CFont::SetFontStyle(FONT_STANDARD); + CFont::SetDropShadowPosition(0); + CFont::SetDropColor(CRGBA(0, 0, 0, m_HudAlpha)); + CFont::SetColor(CRGBA(255, 255, 255, m_HudAlpha)); + CFont::SetCentreOn(); + if (fMaxHealth > 125.0f) + CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.3375f : 0.45f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.75f))); + else + CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.2625f : 0.35f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.6f))); + + if (FrontEndMenuManager.m_PrefsUseWideScreen) + fX1 = 375.0f + 12.0f; + else + fX1 = 360.0f + 15.0f; + CFont::PrintString(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(36.0f), (wchar*)L"+"); + } + +} + +int ArmourFlashTimer = 50; + +void +CHud::DrawArmourBar(int16 value) +{ + if (m_ItemToFlash == ITEM_ARMOUR) { + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fArmour > 10.0f) { + if (ArmourFlashTimer-- == 0) { + m_ItemToFlash = -1; + ArmourFlashTimer = 50; + } + } + } + float fArmour = value; + float fMaxArmour = CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour; + fArmour = clamp(fArmour, 0.0f, fMaxArmour); + float fWidth = (fArmour / fMaxArmour) * 40.0f + 16.0f + 4.0f; + float u = fWidth / 64.0f; + if (value == 0) { + fWidth = 0.0f; + u = 0.0f; + } else if (value == fMaxArmour) { + fWidth = 64.0f; + u = 1.0f; + } + + if (FrontEndMenuManager.m_PrefsUseWideScreen) + fWidth *= 0.68f; + else + fWidth *= 0.85f; + + float fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f; + float fX2 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect1(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f)); + CRGBA color1(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_INSIDE1].Draw(rect1, color1, 0.0f, 0.0f, u, 0.0f, 0.0f, 1.0f, u, 1.0f); + + fX1 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect2(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f)); + CRGBA color2(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_INSIDE1DARK].Draw(rect2, color2, u, 0.0f, 1.0f, 0.0f, u, 1.0f, 1.0f, 1.0f); + + fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f; + fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f); + CRect rect3(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f)); + CRGBA color3(255, 255, 255, m_HudAlpha); + Sprites[HUD_BAR_OUTLINE].Draw(rect3, color3, 0.01f, 0.0f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f); + + if (fMaxArmour > 100.0f) { + CFont::SetFontStyle(FONT_STANDARD); + CFont::SetDropShadowPosition(0); + CFont::SetDropColor(CRGBA(0, 0, 0, m_HudAlpha)); + CFont::SetColor(CRGBA(255, 255, 255, m_HudAlpha)); + CFont::SetCentreOn(); + if (fMaxArmour > 125.0f) + CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.3375f : 0.45f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.75f))); + else + CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.2625f : 0.35f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.6f))); + + if (FrontEndMenuManager.m_PrefsUseWideScreen) + fX1 = 375.0f + 12.0f; + else + fX1 = 360.0f + 15.0f; + CFont::PrintString(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(24.0f), (wchar*)L"+"); + } + +} + +void +CHud::DrawTimeAndCashNumbers(char *str, float x, float y, bool secondSet) +{ + CRGBA color(255, 255, 255, m_HudAlpha); + + float width = 11.0f; + if (FrontEndMenuManager.m_PrefsUseWideScreen) + width = 9.0f; + + float height = 10.0f; + while (*str) { + uint8 c = *str; + if (c >= '0' && c <= ':') + { + if (secondSet) c -= '%'; + else c -= '0'; + } else { + if (c == 22) { + if (secondSet) + color = CRGBA(62, 141, 188, m_HudAlpha); + else + color = CRGBA(192, 155, 54, m_HudAlpha); + } else if (!secondSet) + c = 10; + else + c = 21; + } + + int row = c / 8; + int col = c - row * 8; + float width2 = width; + if (c == 22) + width2 += 3.0f; + CRect rect(PSP_SCREEN_SCALE_X(x), PSP_SCREEN_SCALE_Y(y), PSP_SCREEN_SCALE_X(x+ width2), PSP_SCREEN_SCALE_Y(y) + PSP_SCREEN_SCALE_Y(height)); + + float u = col * 0.125f; + // TODO(LCS): some odd calculation with u going on in here if it's < 0, it might be fabs, but maybe not + + float v = row * 0.265625f; + // TODO(LCS): same odd calculation with v as above + + str++; + Sprites[HUD_HUDNUMBERS].Draw(rect, color, u, v, u + 0.125f, v, u, v + 0.265625f, u + 0.125f, v + 0.265625f); + + x += (width - 2.0f); + if (c == 10) + x -= 4.0f; + +#ifdef GTA_PSP + x = Ceil(PSP_SCREEN_SCALE_X(x)) * ((float)PSP_DEFAULT_SCREEN_WIDTH / (float)SCREEN_WIDTH); +#else + // BUG: actually above wasn't PSP only but on higher resolutions things don't look like they were meant to, so we stick with PS2 version here + x = Ceil(PSP_SCALE_TO_PS2_X(x)) * ((float)PSP_DEFAULT_SCREEN_WIDTH / (float)DEFAULT_SCREEN_WIDTH); +#endif + } +} + +void +CHud::DrawCash() +{ + char str[200]; + sprintf(str, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nMoney); + DrawTimeAndCashNumbers(str, FrontEndMenuManager.m_PrefsUseWideScreen ? 386.0f : 373.0f, 53.0f, true); +} + +void +CHud::DrawTime() +{ + // TODO(LCS): a lot more code should be here + + char str[24]; + sprintf(str, "%02d:%02d", CClock::ms_nGameClockHours, CClock::ms_nGameClockMinutes); + DrawTimeAndCashNumbers(str, FrontEndMenuManager.m_PrefsUseWideScreen ? 386.0f : 373.0f, 17.0f, false); +} + + void CHud::DrawAfterFade() { RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); @@ -2081,4 +2259,4 @@ CHud::ResetWastedText(void) BigMessageInUse[0] = 0.0f; m_BigMessage[2][0] = 0; m_BigMessage[0][0] = 0; -} +}
\ No newline at end of file diff --git a/src/render/Hud.h b/src/render/Hud.h index 831c8e0d..4ae36886 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -38,13 +38,19 @@ enum eSprites HUD_FIST, HUD_SITEROCKET = 41, HUD_RADARDISC = 50, - HUD_SITESNIPER = 63, + HUD_BAR_INSIDE1DARK = 57, + HUD_BAR_INSIDE2DARK, + HUD_HUDNUMBERS, + HUD_BAR_INSIDE1, + HUD_BAR_INSIDE2, + HUD_BAR_OUTLINE, + HUD_SITESNIPER, HUD_SITEM16, HUD_SITELASER, HUD_LASERDOT, HUD_VIEWFINDER, HUD_BLEEDER, - NUM_HUD_SPRITES = 69, + NUM_HUD_SPRITES = 70, }; extern float BigMessageInUse[6]; @@ -119,6 +125,7 @@ public: static uint32 m_LastTimeEnergyLost; static wchar* gLastPrintForeverString; + static uint8 m_HudAlpha; public: static void Draw(); @@ -139,4 +146,9 @@ public: static void Shutdown(); static float DrawFadeState(DRAW_FADE_STATE, int); static void ResetWastedText(void); + static void DrawHealthBar(int16 value); + static void DrawArmourBar(int16 value); + static void DrawTimeAndCashNumbers(char *str, float x, float y, bool secondSet); + static void DrawCash(); + static void DrawTime(); }; diff --git a/src/render/Instance.h b/src/render/Instance.h index 01dfb6a2..693cfdf1 100644 --- a/src/render/Instance.h +++ b/src/render/Instance.h @@ -9,6 +9,6 @@ class CInstance : public CPlaceable public: int m_modelIndex; public: - ~CInstance() = default; + ~CInstance() { } void Shutdown(); }; 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/PlayerSkin.cpp b/src/render/PlayerSkin.cpp index 1626716f..ee944ca7 100644 --- a/src/render/PlayerSkin.cpp +++ b/src/render/PlayerSkin.cpp @@ -16,8 +16,6 @@ #include "Lights.h" #include "MemoryMgr.h" -//--MIAMI: file done - RpClump *gpPlayerClump; float gOldFov; diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index c8f21d21..3e73c57f 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -11,8 +11,6 @@ #include "Timer.h" #include "PointLights.h" -//--MIAMI: file done - int16 CPointLights::NumLights; CRegisteredPointLight CPointLights::aLights[NUMPOINTLIGHTS]; CVector CPointLights::aCachedMapReads[32]; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 5c65eea5..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" @@ -28,8 +28,6 @@ #include "custompipes.h" #include "Frontend.h" -//--MIAMI: file done - bool gbShowPedRoadGroups; bool gbShowCarRoadGroups; bool gbShowCollisionPolys; @@ -1202,7 +1200,6 @@ CEntity::RemoveLighting(bool) { } -// --MIAMI: Done bool CPed::SetupLighting(void) { @@ -1228,7 +1225,6 @@ CPed::SetupLighting(void) return false; } -// --MIAMI: Done void CPed::RemoveLighting(bool reset) { diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp index dada2439..bd69f875 100644 --- a/src/render/Rubbish.cpp +++ b/src/render/Rubbish.cpp @@ -13,8 +13,6 @@ #include "RenderBuffer.h" #include "Rubbish.h" -//--MIAMI: file done - #define RUBBISH_MAX_DIST (23.0f) #define RUBBISH_FADE_DIST (20.0f) diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index 0251878a..07039c17 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -6,8 +6,6 @@ #include "Replay.h" #include "Skidmarks.h" -//--MIAMI: file done - CSkidmark CSkidmarks::aSkidmarks[NUMSKIDMARKS]; RwImVertexIndex SkidmarkIndexList[SKIDMARK_LENGTH * 6]; diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 18e7fd34..161bf168 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -645,8 +645,6 @@ MarkerAtomicCB(RpAtomic *atomic, void *data) return atomic; } -// --MIAMI: C3dMarker and C3dMarkers done - bool C3dMarker::AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate) { @@ -879,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; @@ -895,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; @@ -1421,7 +1419,7 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 } CRGBA FoamColour(255, 255, 255, 255); -unsigned int CSpecialParticleStuff::BoatFromStart; +uint32 CSpecialParticleStuff::BoatFromStart; void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles) diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index 3cb5a0b0..8a3efd85 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -10,8 +10,6 @@ #include "FileMgr.h" #include "Timecycle.h" -//--MIAMI: done - uint8 CTimeCycle::m_nAmbientRed[NUMHOURS][NUMWEATHERS]; uint8 CTimeCycle::m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; uint8 CTimeCycle::m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; 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/render/Weather.cpp b/src/render/Weather.cpp index ca4ef349..65343a61 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -21,8 +21,6 @@ #include "SpecialFX.h" #include "Replay.h" -//--MIAMI: file done - int32 CWeather::SoundHandle = -1; int32 CWeather::WeatherTypeInList; diff --git a/src/rw/ClumpRead.cpp b/src/rw/ClumpRead.cpp index b8d72d23..9c027dc5 100644 --- a/src/rw/ClumpRead.cpp +++ b/src/rw/ClumpRead.cpp @@ -1,7 +1,5 @@ #include "common.h" -//--MIAMI: done - struct rpGeometryList { RpGeometry **geometries; diff --git a/src/rw/Lights.cpp b/src/rw/Lights.cpp index 19115ba8..5f8ba823 100644 --- a/src/rw/Lights.cpp +++ b/src/rw/Lights.cpp @@ -11,8 +11,6 @@ #include "Frontend.h" #include "MBlur.h" -//--MIAMI: done - RpLight *pAmbient; RpLight *pDirect; RpLight *pExtraDirectionals[4] = { nil }; 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<TxdDef,TxdDef> *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<TxdDef,TxdDef>(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 @@ -111,6 +125,20 @@ CTxdStore::AddRef(int slot) } 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) { if(--GetSlot(slot)->refCount <= 0) @@ -118,6 +146,15 @@ CTxdStore::RemoveRef(int slot) } void +CTxdStore::RemoveRefGu(int slot) +{ + TxdDef *def = GetSlot(slot); + def->refCount--; + if(gUseChunkFiles) + def->refCountGu--; +} + +void CTxdStore::RemoveRefWithoutDelete(int slot) { GetSlot(slot)->refCount--; @@ -128,15 +165,32 @@ 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) { RwStream *stream; @@ -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<TxdDef> *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<TxdDef> *pool); static TxdDef *GetSlot(int slot) { assert(slot >= 0); diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 602cb705..754c8778 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -14,8 +14,6 @@ #include "custompipes.h" #include "MemoryHeap.h" -//--MIAMI: file done - CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBoatAtomicList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList; @@ -457,6 +455,14 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic) RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic) { + if(DistToCameraSq < ms_vehicleLod0Dist) + RENDERCALLBACK(atomic); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic) +{ if(DistToCameraSq < ms_bigVehicleLod1Dist) RENDERCALLBACK(atomic); return atomic; @@ -476,6 +482,40 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic) } RpAtomic* +CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic) +{ + RpClump *clump; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + if(DistToCameraSq >= ms_vehicleLod0Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + RENDERCALLBACK(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic) +{ + RpClump *clump; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + if(DistToCameraSq >= ms_bigVehicleLod1Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + RENDERCALLBACK(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; +} + +RpAtomic* CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index 13365c7a..f188096c 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -61,6 +61,9 @@ public: static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic); + static RpAtomic *RenderVehicleLoDetailCB_Boat(RpAtomic *atomic); + static RpAtomic *RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic); static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic); diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 3b9fe3de..e0a989de 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -41,8 +41,6 @@ #include "Timecycle.h" #include "Fluff.h" -// --MIAMI: file done - #define BLOCK_COUNT 22 #define SIZE_OF_SIMPLEVARS 0xE8 @@ -347,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/save/PCSave.cpp b/src/save/PCSave.cpp index dd0926cf..70ca31d2 100644 --- a/src/save/PCSave.cpp +++ b/src/save/PCSave.cpp @@ -12,8 +12,6 @@ #include "PCSave.h" #include "Text.h" -// --MIAMI: file done - const char* _psGetUserFilesFolder(); C_PcSave PcSaveHelper; diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index bfc03913..009b17c7 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -21,7 +21,11 @@ char *_strdate(char *buf); // As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, we only need type definitions so let's include <IntSafe.h>. // NOTE: It's perfectly fine to include <Windows.h> here, but it can increase build size and time in *some* conditions, and maybe substantially in future if we'll use crossplatform.h more. #ifndef _INC_WINDOWS - #include <IntSafe.h> + #ifndef __MWERKS__ + #include <IntSafe.h> + #else + #include <Windows.h> + #endif #endif #if defined RW_D3D9 || defined RWLIBS #include "win.h" diff --git a/src/skel/events.cpp b/src/skel/events.cpp index 6589ab71..3e1e95b3 100644 --- a/src/skel/events.cpp +++ b/src/skel/events.cpp @@ -9,8 +9,6 @@ #include "events.h" -// --MIAMI: file done - /* ***************************************************************************** */ diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index d39e27b1..887ac6dc 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 <windows.h> +#include <shlobj.h> +#include <basetsd.h> #include <mmsystem.h> +#include <regstr.h> #include <shellapi.h> #include <windowsx.h> -#include <basetsd.h> -#include <regstr.h> -#include <shlobj.h> + +DWORD _dwOperatingSystemVersion; +#include "resource.h" +#else +long _dwOperatingSystemVersion; +#ifndef __APPLE__ +#include <sys/sysinfo.h> +#else +#include <mach/mach_host.h> +#include <sys/sysctl.h> +#endif +#include <errno.h> +#include <locale.h> +#include <signal.h> +#include <stddef.h> #endif -#define WITHWINDOWS #include "common.h" - -#pragma warning( push ) -#pragma warning( disable : 4005) -#pragma warning( pop ) - #if (defined(_MSC_VER)) #include <tchar.h> #endif /* (defined(_MSC_VER)) */ @@ -44,8 +52,6 @@ #define MAX_SUBSYSTEMS (16) -// --MIAMI: file done - rw::EngineOpenParams openParams; static RwBool ForegroundApp = TRUE; @@ -74,23 +80,6 @@ static psGlobalType PsGlobal; size_t _dwMemAvailPhys; RwUInt32 gGameState; -#ifdef _WIN32 -DWORD _dwOperatingSystemVersion; -#include "resource.h" -#else -long _dwOperatingSystemVersion; -#ifndef __APPLE__ -#include <sys/sysinfo.h> -#else -#include <mach/mach_host.h> -#include <sys/sysctl.h> -#endif -#include <stddef.h> -#include <locale.h> -#include <signal.h> -#include <errno.h> -#endif - #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS char gSelectedJoystickName[128] = ""; #endif @@ -1648,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 ) @@ -1657,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 @@ -2095,22 +2099,30 @@ void CapturePad(RwInt32 padID) const float *axes = glfwGetJoystickAxes(glfwPad, &numAxes); GLFWgamepadstate gamepadState; - if (ControlsManager.m_bFirstCapture == false) - { + if (ControlsManager.m_bFirstCapture == false) { memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState)); + } else { + // In case connected gamepad doesn't have L-R trigger axes. + ControlsManager.m_NewState.mappedButtons[15] = ControlsManager.m_NewState.mappedButtons[16] = 0; } ControlsManager.m_NewState.buttons = (uint8*)buttons; ControlsManager.m_NewState.numButtons = numButtons; ControlsManager.m_NewState.id = glfwPad; - ControlsManager.m_NewState.isGamepad = glfwJoystickIsGamepad(glfwPad); + ControlsManager.m_NewState.isGamepad = glfwGetGamepadState(glfwPad, &gamepadState); if (ControlsManager.m_NewState.isGamepad) { - glfwGetGamepadState(glfwPad, &gamepadState); memcpy(&ControlsManager.m_NewState.mappedButtons, gamepadState.buttons, sizeof(gamepadState.buttons)); - ControlsManager.m_NewState.mappedButtons[15] = gamepadState.axes[4] > -0.8f; - ControlsManager.m_NewState.mappedButtons[16] = gamepadState.axes[5] > -0.8f; + float lt = gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER], rt = gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]; + + // glfw returns 0.0 for non-existent axises(which is bullocks) so we treat it as deadzone, and keep value of previous frame. + // otherwise if this axis is present, -1 = released, 1 = pressed + if (lt != 0.0f) + ControlsManager.m_NewState.mappedButtons[15] = lt > -0.8f; + + if (rt != 0.0f) + ControlsManager.m_NewState.mappedButtons[16] = rt > -0.8f; } - // TODO I'm not sure how to find/what to do with L2-R2, if joystick isn't registered in SDL database. + // TODO? L2-R2 axes(not buttons-that's fine) on joysticks that don't have SDL gamepad mapping AREN'T handled, and I think it's impossible to do without mapping. if (ControlsManager.m_bFirstCapture == true) { memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState)); @@ -2124,12 +2136,13 @@ void CapturePad(RwInt32 padID) RsPadEventHandler(rsPADBUTTONUP, (void *)&bs); // Gamepad axes are guaranteed to return 0.0f if that particular gamepad doesn't have that axis. + // And that's really good for sticks, because gamepads return 0.0 for them when sticks are in released state. if ( glfwPad != -1 ) { - leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 1 ? axes[0] : 0.0f; - leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 2 ? axes[1] : 0.0f; + leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_X] : numAxes >= 1 ? axes[0] : 0.0f; + leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y] : numAxes >= 2 ? axes[1] : 0.0f; - rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 3 ? axes[2] : 0.0f; - rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 4 ? axes[3] : 0.0f; + rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X] : numAxes >= 3 ? axes[2] : 0.0f; + rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y] : numAxes >= 4 ? axes[3] : 0.0f; } { @@ -2170,6 +2183,12 @@ void joysChangeCB(int jid, int event) #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/skeleton.cpp b/src/skel/skeleton.cpp index 20ac38ab..d5805681 100644 --- a/src/skel/skeleton.cpp +++ b/src/skel/skeleton.cpp @@ -13,8 +13,6 @@ #include "main.h" #include "MemoryHeap.h" -// --MIAMI: file done - static RwBool DefaultVideoMode = TRUE; RsGlobalType RsGlobal; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index d67bd5f2..650f1648 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1,8 +1,7 @@ -#if defined RW_D3D9 || defined RWLIBS +#if defined RW_D3D9 || defined RWLIBS || defined __MWERKS__ #define _WIN32_WINDOWS 0x0500 #define WINVER 0x0500 -#define DIRECTINPUT_VERSION 0x0800 #include <winerror.h> #include <windows.h> @@ -20,13 +19,11 @@ #pragma warning( push ) #pragma warning( disable : 4005) -#ifdef USE_D3D9 -#include <d3d9.h> -#else -#include <d3d8.h> +#ifdef __MWERKS__ +#define MAPVK_VK_TO_CHAR (2) // this is missing from codewarrior win32 headers - but it gets used ... how? #endif + #include <ddraw.h> -#include <dinput.h> #include <DShow.h> #pragma warning( pop ) @@ -41,6 +38,9 @@ #pragma comment( lib, "strmiids.lib" ) #pragma comment( lib, "dinput8.lib" ) +#define WITHD3D +#define WITHDINPUT +#include "common.h" #if (defined(_MSC_VER)) #include <tchar.h> #endif /* (defined(_MSC_VER)) */ @@ -53,8 +53,6 @@ #define MAX_SUBSYSTEMS (16) -// --MIAMI: file done - static RwBool ForegroundApp = TRUE; static RwBool RwInitialised = FALSE; @@ -83,7 +81,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" @@ -94,12 +91,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 @@ -578,6 +577,9 @@ _RETEX: } } +#ifdef __MWERKS__ +#pragma dont_inline on +#endif void _psPrintCpuInfo() { RwUInt32 features = _psGetCpuFeatures(); @@ -592,6 +594,9 @@ void _psPrintCpuInfo() if ( FeaturesEx & 0x80000000 ) debug("with 3DNow"); } +#ifdef __MWERKS__ +#pragma dont_inline off +#endif #endif /* @@ -2150,8 +2155,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); @@ -2159,6 +2171,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/text/Messages.cpp b/src/text/Messages.cpp index 440746c0..f55e6bd7 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -11,7 +11,7 @@ #include "Font.h" -// --MIAMI: file done +#include "Pad.h" tMessage CMessages::BriefMessages[NUMBRIEFMESSAGES]; tPreviousBrief CMessages::PreviousBriefs[NUMPREVIOUSBRIEFS]; @@ -443,6 +443,64 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2) str1[i++] = '\0'; } +int +CMessages::GetTokenPadKeyString(const wchar *in, wchar *out) +{ + wchar str[256]; + memset(str, 0, sizeof(str)); + str[0] = 'C'; + + // TODO: there was a switch here but that's stupid + str[1] = CPad::GetPad(0)->Mode + 48; + + while (*in != '~') in++; + in++; + + int i = 1; + while (*in != '~') + str[1+i++] = *(in++); + + wchar *text = TheText.Get(UnicodeToAscii(str)); + if (!text) return i; + while (text[0] != '\0') + { + if (text[0] == '~') + { + switch (text[1]) + { + case 'L': + *(out++) = 'M'; + break; + case 'N': + *(out++) = 'O'; + break; + case 'O': + *(out++) = 227; + break; + case 'R': + *(out++) = 'S'; + break; + case 'S': + *(out++) = 225; + break; + case 'T': + *(out++) = 224; + break; + case 'X': + *(out++) = 226; + break; + default: + break; + } + text += 3; + } + else { + *(out++) = *(text++); + } + } + return i; +} + void CMessages::InsertPlayerControlKeysInString(wchar *str) { @@ -452,7 +510,7 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) if (!str) return; uint16 strSize = GetWideStringLength(str); - memset(keybuf, 0, 256*sizeof(wchar)); + memset(keybuf, 0, 256*sizeof(wchar)); // not memset? :O wchar *_outstr = outstr; for (i = 0; i < strSize;) { @@ -462,9 +520,16 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) #else if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') { #endif + memset(keybuf, 0, 256 * sizeof(wchar)); i += 4; - bool done = false; - for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS && !done; cont++) { + i += GetTokenPadKeyString(&str[i], keybuf) + 1; + uint16 keybuf_size = GetWideStringLength(keybuf); + for (uint16 j = 0; j < keybuf_size; j++) { + *(_outstr++) = keybuf[j]; + keybuf[j] = '\0'; + } + + /*for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS && !done; cont++) { uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]); if (contSize != 0) { if (WideStringCompare(&str[i], ControlsManager.m_aActionNames[cont], contSize)) { @@ -478,7 +543,7 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) i += contSize + 1; } } - } + }*/ } else { *(_outstr++) = str[i++]; } @@ -823,4 +888,5 @@ CMessages::ClearThisBigPrintNow(uint32 id) ClearThisBigPrint(BIGMessages[id].m_Stack[0].m_pText); CHud::m_BigMessage[id][0] = '\0'; BigMessageInUse[id] = 0.0f; -}
\ No newline at end of file +} + diff --git a/src/text/Messages.h b/src/text/Messages.h index 602a4a08..51112908 100644 --- a/src/text/Messages.h +++ b/src/text/Messages.h @@ -62,6 +62,7 @@ public: static void ClearThisBigPrint(wchar *str); static void ClearAllMessagesDisplayedByGame(void); static void ClearThisBigPrintNow(uint32 id); + static int GetTokenPadKeyString(const wchar *in, wchar *out); // unused or cut //static void AddMessageSoonWithString(wchar*, uint32, uint16, wchar*); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index efb8b2a9..16250f79 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -9,8 +9,6 @@ #include "Text.h" #include "Timer.h" -//--MIAMI: file done - static wchar WideErrorString[25]; CText *CText::msInstance = nil; @@ -207,7 +205,7 @@ CText::GetNameOfLoadedMissionText(char *outName) void CText::ReadChunkHeader(ChunkHeader *buf, int32 file, size_t *offset) { -#if THIS_IS_STUPID +#ifdef THIS_IS_STUPID char *_buf = (char*)buf; for (int i = 0; i < sizeof(ChunkHeader); i++) { CFileMgr::Read(file, &_buf[i], 1); @@ -325,7 +323,7 @@ CKeyArray::Load(size_t length, int file, size_t* offset) entries = new CKeyEntry[numEntries]; rawbytes = (char*)entries; -#if THIS_IS_STUPID +#ifdef THIS_IS_STUPID for (uint32 i = 0; i < length; i++) { CFileMgr::Read(file, &rawbytes[i], 1); (*offset)++; @@ -400,7 +398,7 @@ CKeyArray::Search(const char *key, uint8 *result) #endif *result = false; #ifdef MASTER - sprintf(errstr, "%"); + sprintf(errstr, ""); #else sprintf(errstr, "%s missing", key); #endif // MASTER @@ -419,7 +417,7 @@ CData::Load(size_t length, int file, size_t * offset) chars = new wchar[numChars]; rawbytes = (char*)chars; -#if THIS_IS_STUPID +#ifdef THIS_IS_STUPID for(uint32 i = 0; i < length; i++){ CFileMgr::Read(file, &rawbytes[i], 1); (*offset)++; @@ -441,7 +439,7 @@ CData::Unload(void) void CMissionTextOffsets::Load(size_t table_size, int file, size_t *offset, int) { -#if THIS_IS_STUPID +#ifdef THIS_IS_STUPID size_t num_of_entries = table_size / sizeof(CMissionTextOffsets::Entry); for (size_t mi = 0; mi < num_of_entries; mi++) { for (uint32 i = 0; i < sizeof(data[mi].szMissionName); i++) { diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index a0581d5c..4a7bce16 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "main.h" #include "General.h" @@ -49,6 +49,7 @@ #include "Object.h" #include "Automobile.h" #include "Bike.h" +#include "Wanted.h" bool bAllCarCheat; @@ -4173,7 +4174,7 @@ CAutomobile::dmgDrawCarCollidingParticles(const CVector &pos, float amount) CGeneral::GetRandomNumberInRange(0.1f, 0.25f)), nil, CGeneral::GetRandomNumberInRange(0.02f, 0.08f), - CVehicleModelInfo::ms_vehicleColourTable[m_currentColour1], + CVehicleModelInfo::mspInfo->ms_vehicleColourTable[m_currentColour1], CGeneral::GetRandomNumberInRange(-40.0f, 40.0f), 0, CGeneral::GetRandomNumberInRange(0.0f, 4.0f)); @@ -4986,7 +4987,6 @@ CAutomobile::HasCarStoppedBecauseOfLight(void) return false; } -// --MIAMI: Done void CPed::DeadPedMakesTyresBloody(void) { @@ -5010,7 +5010,6 @@ CPed::DeadPedMakesTyresBloody(void) } } -// --MIAMI: Done void CPed::MakeTyresMuddySectorList(CPtrList &list) { diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 2c2b9468..6ad59769 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -37,8 +37,6 @@ #include "Bike.h" #include "Debug.h" -//--MIAMI: file done - const uint32 CBike::nSaveStructSize = #ifdef COMPATIBLE_SAVES 1260; @@ -81,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 eae764b4..d4dfcc7c 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "main.h" #include "General.h" @@ -27,8 +27,7 @@ #include "RpAnimBlend.h" #include "Record.h" #include "Shadows.h" - -//--MIAMI: file done +#include "Wanted.h" #define INVALID_ORIENTATION (-9999.99f) @@ -135,9 +134,9 @@ CBoat::ProcessControl(void) m_fBuoyancy *= 0.99f; #ifdef FIX_BUGS - if(FindPlayerPed() && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){ + if(FindPlayerPed() && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && GetModelIndex() == MI_PREDATOR){ #else - if(FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){ + if(FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && GetModelIndex() == MI_PREDATOR){ #endif CVehicle *playerVeh = FindPlayerVehicle(); if(playerVeh && playerVeh->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && @@ -1254,7 +1253,7 @@ CBoat::Teleport(CVector v) CWorld::Add(this); } -//--MIAMI: unused +// unused bool CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats) { @@ -1286,7 +1285,7 @@ CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats) return numVerts != 0; } -//--MIAMI: unused +// unused float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat) { diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index 77d66cbf..78e67d49 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -18,8 +18,6 @@ #include "Zones.h" #include "Occlusion.h" -// --MIAMI: file done - uint8 CTheCarGenerators::ProcessCounter; uint32 CTheCarGenerators::NumOfCarGenerators; CCarGenerator CTheCarGenerators::CarGeneratorArray[NUM_CARGENS]; diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index 8f23836d..a675fe4e 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -12,8 +12,6 @@ #include "Object.h" #include "World.h" -// --MIAMI: file done - #define MAX_DISTANCE_TO_FIND_CRANE (100.0f) #define CRANE_UPDATE_RADIUS (300.0f) #define CRANE_MOVEMENT_PROCESSING_RADIUS (150.0f) @@ -52,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); } } @@ -60,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/Floater.cpp b/src/vehicles/Floater.cpp index 92e3d80e..08688a3c 100644 --- a/src/vehicles/Floater.cpp +++ b/src/vehicles/Floater.cpp @@ -7,8 +7,6 @@ #include "Vehicle.h" #include "Floater.h" -//--MIAMI: done - cBuoyancy mod_Buoyancy; float fVolMultiplier = 1.0f; diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index 1a8d059c..b5dc7658 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -5,8 +5,6 @@ #include "Physical.h" #include "HandlingMgr.h" -//--MIAMI: done - cHandlingDataMgr mod_HandlingManager; const char *HandlingFilename = "HANDLING.CFG"; diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 1c1b2617..0546888a 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -32,8 +32,6 @@ #include "Replay.h" #endif -//--MIAMI: done - enum { HELI_STATUS_HOVER, @@ -480,7 +478,7 @@ CHeli::ProcessControl(void) // Shoot int shootTimeout; if (m_heliType == HELI_TYPE_RANDOM) { - switch (FindPlayerPed()->m_pWanted->m_nWantedLevel) { + switch (FindPlayerPed()->m_pWanted->GetWantedLevel()) { case 0: case 1: case 2: shootTimeout = 999999; break; @@ -758,7 +756,7 @@ CHeli::InitHelis(void) for(i = 0; i < NUM_HELIS; i++) pHelis[i] = nil; - ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&CTempColModels::ms_colModelPed1); + ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&gpTempColModels->ms_colModelPed1); } CHeli* diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 5b5536fd..48f7b8c0 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -20,8 +20,6 @@ #include "Plane.h" #include "MemoryHeap.h" -//--MIAMI: file done - CPlaneNode *pPathNodes; CPlaneNode *pPath2Nodes; CPlaneNode *pPath3Nodes; @@ -1004,7 +1002,7 @@ CPlane::TestRocketCollision(CVector *rocketPos) return false; } -//--MIAMI: unused +// unused // BUG: not in CPlane in the game void CPlane::CreateIncomingCesna(void) @@ -1028,7 +1026,7 @@ CPlane::CreateIncomingCesna(void) printf("CPlane::CreateIncomingCesna(void)\n"); } -//--MIAMI: unused +// unused void CPlane::CreateDropOffCesna(void) { @@ -1051,7 +1049,7 @@ CPlane::CreateDropOffCesna(void) printf("CPlane::CreateDropOffCesna(void)\n"); } -//--MIAMI: all unused +// all unused const CVector CPlane::FindDrugPlaneCoordinates(void) { return pDrugRunCesna->GetPosition(); } const CVector CPlane::FindDropOffCesnaCoordinates(void) { return pDropOffCesna->GetPosition(); } bool CPlane::HasCesnaLanded(void) { return CesnaMissionStatus == CESNA_STATUS_LANDED; } diff --git a/src/vehicles/Transmission.cpp b/src/vehicles/Transmission.cpp index ce4b97f4..f7851f47 100644 --- a/src/vehicles/Transmission.cpp +++ b/src/vehicles/Transmission.cpp @@ -5,7 +5,6 @@ #include "Transmission.h" //--LCS: file done - void cTransmission::InitGearRatios(void) { diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 5f6ddafa..a3d07d5c 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -217,8 +217,8 @@ void CVehicle::SetModelIndex(uint32 id) { CEntity::SetModelIndex(id); - m_aExtras[0] = CVehicleModelInfo::ms_compsUsed[0]; - m_aExtras[1] = CVehicleModelInfo::ms_compsUsed[1]; + m_aExtras[0] = CVehicleModelInfo::mspInfo->ms_compsUsed[0]; + m_aExtras[1] = CVehicleModelInfo::mspInfo->ms_compsUsed[1]; m_nNumMaxPassengers = CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(id); } @@ -330,7 +330,7 @@ CVehicle::FlyingControl(eFlightModel flightModel) case FLIGHT_MODEL_PLANE: { float fSteerLR = CPad::GetPad(0)->GetSteeringLeftRight() / 128.0f; - float fSteerUD = -CPad::GetPad(0)->GetSteeringUpDown() / 128.0f; + float fSteerUD = CPad::GetPad(0)->GetSteeringUpDown() / 128.0f; float fGunUD = Abs(CPad::GetPad(0)->GetCarGunUpDown()); #ifdef FREE_CAM if(!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController)) @@ -1505,7 +1505,7 @@ CVehicle::MakeNonDraggedPedsLeaveVehicle(CPed *ped1, CPed *ped2, CPlayerPed *&pl cop = nil; if(ped1->IsPlayer() && ped2->m_nPedType == PEDTYPE_COP && - ((CPlayerPed*)ped1)->m_pWanted->m_nWantedLevel > 0 && + ((CPlayerPed*)ped1)->m_pWanted->GetWantedLevel() > 0 && ped2->m_pedInObjective == ped1){ player = (CPlayerPed*)ped1; cop = (CCopPed*)ped2; @@ -1535,7 +1535,7 @@ CVehicle::MakeNonDraggedPedsLeaveVehicle(CPed *ped1, CPed *ped2, CPlayerPed *&pl int numPeds3 = 0; for(i = 0; i < numPeds; i++){ if(peds[i]->IsPlayer() && ped2->m_nPedType == PEDTYPE_COP && - ((CPlayerPed*)peds[i])->m_pWanted->m_nWantedLevel > 0 && + ((CPlayerPed*)peds[i])->m_pWanted->GetWantedLevel() > 0 && ped2->m_pedInObjective == peds[i]){ player = (CPlayerPed*)peds[i]; cop = (CCopPed*)ped2; 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, diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 13032300..445f31a0 100644 --- a/src/weapons/BulletInfo.cpp +++ b/src/weapons/BulletInfo.cpp @@ -25,8 +25,6 @@ #include "SurfaceTable.h" #include "Heli.h" -// --MIAMI: file done - #ifdef SQUEEZE_PERFORMANCE uint32 bulletInfoInUse; #endif diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp index 0930756c..10aa3ef5 100644 --- a/src/weapons/ProjectileInfo.cpp +++ b/src/weapons/ProjectileInfo.cpp @@ -17,8 +17,6 @@ uint32 projectileInUse; #endif -// --MIAMI: file done except TODOs - CProjectileInfo gaProjectileInfo[NUM_PROJECTILES]; CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES]; diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp index a03ed16f..788bcbe1 100644 --- a/src/weapons/ShotInfo.cpp +++ b/src/weapons/ShotInfo.cpp @@ -10,8 +10,6 @@ #include "Ped.h" #include "Fire.h" -// --MIAMI: file done - CShotInfo gaShotInfo[NUMSHOTINFOS]; float CShotInfo::ms_afRandTable[20]; diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 5f2fbf77..78d21b0a 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -513,7 +513,7 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource) if ( SQR(victimPedRadius) > (victimPedPos-fireSource).MagnitudeSqr() ) { CVector collisionDist; - CColModel* victimPedCol = &CTempColModels::ms_colModelPed1; + CColModel* victimPedCol = &gpTempColModels->ms_colModelPed1; bool useLocalPos = false; if (victimPed->m_nPedState == PED_FALL || victimPed->m_nPedState == PED_DIE && victimPed->bIsPedDieAnimPlaying @@ -3173,7 +3173,6 @@ CWeapon::HasWeaponAmmoToBeUsed(void) return m_nAmmoTotal != 0; } -// --MIAMI: Done bool CPed::IsPedDoingDriveByShooting(void) { diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index acb11a88..1f78b7d4 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -57,7 +57,7 @@ int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] = -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; +CWeaponInfo aWeaponInfo[WEAPONTYPE_TOTALWEAPONS]; char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] = { "Unarmed", @@ -102,7 +102,7 @@ char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] = CWeaponInfo* CWeaponInfo::GetWeaponInfo(eWeaponType weaponType) { - return &ms_apWeaponInfos[weaponType]; + return &aWeaponInfo[weaponType]; } void @@ -110,27 +110,27 @@ CWeaponInfo::Initialise(void) { debug("Initialising CWeaponInfo...\n"); for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) { - ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT; - ms_apWeaponInfos[i].m_fRange = 0.0f; - ms_apWeaponInfos[i].m_nFiringRate = 0; - ms_apWeaponInfos[i].m_nReload = 0; - ms_apWeaponInfos[i].m_nAmountofAmmunition = 0; - ms_apWeaponInfos[i].m_nDamage = 0; - ms_apWeaponInfos[i].m_fSpeed = 0.0f; - ms_apWeaponInfos[i].m_fRadius = 0.0f; - ms_apWeaponInfos[i].m_fLifespan = 0.0f; - ms_apWeaponInfos[i].m_fSpread = 0.0f; - ms_apWeaponInfos[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f); - ms_apWeaponInfos[i].m_AnimToPlay = ASSOCGRP_UNARMED; - ms_apWeaponInfos[i].m_fAnimLoopStart = 0.0f; - ms_apWeaponInfos[i].m_fAnimLoopEnd = 0.0f; - ms_apWeaponInfos[i].m_fAnimFrameFire = 0.0f; - ms_apWeaponInfos[i].m_fAnim2LoopStart = 0.0f; - ms_apWeaponInfos[i].m_fAnim2LoopEnd = 0.0f; - ms_apWeaponInfos[i].m_fAnim2FrameFire = 0.0f; - ms_apWeaponInfos[i].m_fAnimBreakout = 0.0f; - ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES; - ms_apWeaponInfos[i].m_nWeaponSlot = WEAPONSLOT_UNARMED; + aWeaponInfo[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT; + aWeaponInfo[i].m_fRange = 0.0f; + aWeaponInfo[i].m_nFiringRate = 0; + aWeaponInfo[i].m_nReload = 0; + aWeaponInfo[i].m_nAmountofAmmunition = 0; + aWeaponInfo[i].m_nDamage = 0; + aWeaponInfo[i].m_fSpeed = 0.0f; + aWeaponInfo[i].m_fRadius = 0.0f; + aWeaponInfo[i].m_fLifespan = 0.0f; + aWeaponInfo[i].m_fSpread = 0.0f; + aWeaponInfo[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f); + aWeaponInfo[i].m_AnimToPlay = ASSOCGRP_UNARMED; + aWeaponInfo[i].m_fAnimLoopStart = 0.0f; + aWeaponInfo[i].m_fAnimLoopEnd = 0.0f; + aWeaponInfo[i].m_fAnimFrameFire = 0.0f; + aWeaponInfo[i].m_fAnim2LoopStart = 0.0f; + aWeaponInfo[i].m_fAnim2LoopEnd = 0.0f; + aWeaponInfo[i].m_fAnim2FrameFire = 0.0f; + aWeaponInfo[i].m_fAnimBreakout = 0.0f; + aWeaponInfo[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES; + aWeaponInfo[i].m_nWeaponSlot = WEAPONSLOT_UNARMED; } debug("Loading weapon data...\n"); LoadWeaponData(); @@ -221,31 +221,31 @@ CWeaponInfo::LoadWeaponData(void) CVector vecFireOffset(fireOffsetX, fireOffsetY, fireOffsetZ); - ms_apWeaponInfos[weaponType].m_eWeaponFire = FindWeaponFireType(fireType); - ms_apWeaponInfos[weaponType].m_fRange = range; - ms_apWeaponInfos[weaponType].m_nFiringRate = firingRate; - ms_apWeaponInfos[weaponType].m_nReload = reload; - ms_apWeaponInfos[weaponType].m_nAmountofAmmunition = ammoAmount; - ms_apWeaponInfos[weaponType].m_nDamage = damage; - ms_apWeaponInfos[weaponType].m_fSpeed = speed; - ms_apWeaponInfos[weaponType].m_fRadius = radius; - ms_apWeaponInfos[weaponType].m_fLifespan = lifeSpan; - ms_apWeaponInfos[weaponType].m_fSpread = spread; - ms_apWeaponInfos[weaponType].m_vecFireOffset = vecFireOffset; - ms_apWeaponInfos[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnim2LoopStart = anim2LoopStart / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnim2LoopEnd = anim2LoopEnd / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f; - ms_apWeaponInfos[weaponType].m_fAnimBreakout = animBreakout / 30.0f; - ms_apWeaponInfos[weaponType].m_nModelId = modelId; - ms_apWeaponInfos[weaponType].m_nModel2Id = modelId2; - ms_apWeaponInfos[weaponType].m_Flags = flags; - ms_apWeaponInfos[weaponType].m_nWeaponSlot = weaponSlot; + aWeaponInfo[weaponType].m_eWeaponFire = FindWeaponFireType(fireType); + aWeaponInfo[weaponType].m_fRange = range; + aWeaponInfo[weaponType].m_nFiringRate = firingRate; + aWeaponInfo[weaponType].m_nReload = reload; + aWeaponInfo[weaponType].m_nAmountofAmmunition = ammoAmount; + aWeaponInfo[weaponType].m_nDamage = damage; + aWeaponInfo[weaponType].m_fSpeed = speed; + aWeaponInfo[weaponType].m_fRadius = radius; + aWeaponInfo[weaponType].m_fLifespan = lifeSpan; + aWeaponInfo[weaponType].m_fSpread = spread; + aWeaponInfo[weaponType].m_vecFireOffset = vecFireOffset; + aWeaponInfo[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f; + aWeaponInfo[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f; + aWeaponInfo[weaponType].m_fAnim2LoopStart = anim2LoopStart / 30.0f; + aWeaponInfo[weaponType].m_fAnim2LoopEnd = anim2LoopEnd / 30.0f; + aWeaponInfo[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f; + aWeaponInfo[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f; + aWeaponInfo[weaponType].m_fAnimBreakout = animBreakout / 30.0f; + aWeaponInfo[weaponType].m_nModelId = modelId; + aWeaponInfo[weaponType].m_nModel2Id = modelId2; + aWeaponInfo[weaponType].m_Flags = flags; + aWeaponInfo[weaponType].m_nWeaponSlot = weaponSlot; if (animLoopEnd < 98.0f && weaponType != WEAPONTYPE_FLAMETHROWER && !CWeapon::IsShotgun(weaponType)) - ms_apWeaponInfos[weaponType].m_nFiringRate = ((ms_apWeaponInfos[weaponType].m_fAnimLoopEnd - ms_apWeaponInfos[weaponType].m_fAnimLoopStart) * 900.0f); + aWeaponInfo[weaponType].m_nFiringRate = ((aWeaponInfo[weaponType].m_fAnimLoopEnd - aWeaponInfo[weaponType].m_fAnimLoopStart) * 900.0f); if (weaponType == WEAPONTYPE_DETONATOR || weaponType == WEAPONTYPE_HELICANNON) modelId = -1; @@ -257,7 +257,7 @@ CWeaponInfo::LoadWeaponData(void) for (int i = 0; i < NUM_ANIM_ASSOC_GROUPS; i++) { if (!strcmp(animToPlay, CAnimManager::GetAnimGroupName((AssocGroupId)i))) { - ms_apWeaponInfos[weaponType].m_AnimToPlay = (AssocGroupId)i; + aWeaponInfo[weaponType].m_AnimToPlay = (AssocGroupId)i; break; } } diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h index 0f53dded..d7f1563d 100644 --- a/src/weapons/WeaponInfo.h +++ b/src/weapons/WeaponInfo.h @@ -31,7 +31,6 @@ enum }; class CWeaponInfo { - static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; static char ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32]; public: static uint16 ms_aReloadSampleTime[WEAPONTYPE_TOTALWEAPONS]; |