From d7a256d056f0e12598f2390075c321419001a660 Mon Sep 17 00:00:00 2001 From: silent Date: Mon, 17 Feb 2014 18:04:58 +0000 Subject: [PATCH] Code cleanups Unworking ColAccel Lotta other stuff I forgot about by now git-svn-id: svn://localhost/vcspc/trunk@31 9f344024-d43e-4b27-bde7-3d027e20192d --- VCS PC/Audio.cpp | 45 +- VCS PC/Audio.h | 34 +- VCS PC/CClock.cpp | 13 - VCS PC/CClock.h | 38 - VCS PC/CGridref.cpp | 12 +- VCS PC/CPed.cpp | 10 +- VCS PC/CPed.h | 13 +- VCS PC/CText.cpp | 115 --- VCS PC/CText.h | 70 -- VCS PC/CVehicle.h | 22 +- VCS PC/CWanted.h | 1 - VCS PC/Clock.cpp | 21 + VCS PC/Clock.h | 21 + VCS PC/ColAccel.cpp | 66 ++ VCS PC/ColAccel.h | 25 + VCS PC/Coronas.cpp | 31 - VCS PC/DLCManager.cpp | 30 +- VCS PC/DLCManager.h | 18 +- VCS PC/Darkel.cpp | 24 +- VCS PC/EmpireMgr.cpp | 63 +- VCS PC/EmpireMgr.h | 21 +- VCS PC/FileMgr.cpp | 109 +++ VCS PC/FileMgr.h | 12 +- VCS PC/{CFont.cpp => Font.cpp} | 176 +--- VCS PC/{CFont.h => Font.h} | 41 +- VCS PC/Frontend.cpp | 125 ++- VCS PC/Frontend.h | 15 +- VCS PC/Garages.cpp | 16 +- VCS PC/General.cpp | 19 + VCS PC/General.h | 56 +- VCS PC/Hud.cpp | Bin 69674 -> 69196 bytes VCS PC/Hud.h | 98 +- VCS PC/MemoryMgr.h | 1 + VCS PC/ModelInfo.cpp | 148 ++- VCS PC/ModelInfo.h | 202 ++-- VCS PC/PlayerInfo.cpp | 2 +- VCS PC/PlayerInfo.h | 6 +- VCS PC/Pools.cpp | 3 +- VCS PC/Pools.h | 12 + VCS PC/Project2dfx.cpp | 31 +- VCS PC/RW.cpp | 13 + VCS PC/Radar.cpp | 87 ++ VCS PC/Radar.h | 5 + VCS PC/Script.cpp | 2 +- VCS PC/Script.h | 3 +- VCS PC/Sprite.cpp | 3 + VCS PC/Sprite.h | 1 + VCS PC/Stats.cpp | 68 +- VCS PC/StdAfx.h | 42 +- VCS PC/Text.cpp | 68 ++ VCS PC/Text.h | 76 ++ VCS PC/UpdateManager.cpp | 37 +- VCS PC/UpdateManager.h | 6 +- VCS PC/UserDisplay.cpp | 5 +- VCS PC/VCS PC.vcxproj | 19 +- VCS PC/VCS PC.vcxproj.filters | 48 +- VCS PC/VCSPC.cpp | 1615 +++++++++++++++----------------- VCS PC/Vehicle.cpp | 71 ++ VCS PC/VideoPlayer.cpp | 9 +- VCS PC/VideoPlayer.h | 2 +- VCS PC/WidescreenSupport.cpp | 121 ++- 61 files changed, 2226 insertions(+), 1840 deletions(-) delete mode 100644 VCS PC/CClock.cpp delete mode 100644 VCS PC/CClock.h delete mode 100644 VCS PC/CText.cpp delete mode 100644 VCS PC/CText.h create mode 100644 VCS PC/Clock.cpp create mode 100644 VCS PC/Clock.h create mode 100644 VCS PC/ColAccel.cpp create mode 100644 VCS PC/ColAccel.h rename VCS PC/{CFont.cpp => Font.cpp} (56%) rename VCS PC/{CFont.h => Font.h} (57%) create mode 100644 VCS PC/Text.cpp create mode 100644 VCS PC/Text.h create mode 100644 VCS PC/Vehicle.cpp diff --git a/VCS PC/Audio.cpp b/VCS PC/Audio.cpp index 070e583..7872bf2 100644 --- a/VCS PC/Audio.cpp +++ b/VCS PC/Audio.cpp @@ -2,6 +2,10 @@ signed char CAERadioTrackManager::bTracksPlayedRecently[NUM_RADIOSTATIONS]; +static std::map AudioSettingsMap; + +WRAPPER void CAudioEngine::ReportFrontendAudioEvent(long nSoundID, float fUnk, float fVolume) { WRAPARG(nSoundID); WRAPARG(fUnk); WRAPARG(fVolume); EAXJMP(0x506EA0); } + signed char CAERadioTrackManager::GetNextTrackByStation(BYTE stationID) { static const BYTE numberOfRadioTracks[NUM_RADIOSTATIONS] = @@ -30,4 +34,43 @@ bool CAERadioTrackManager::Load() return true; } -WRAPPER void CMusicManager::ReportFrontendAudioEvent(long nSoundID, float fUnk, float fVolume) { WRAPARG(nSoundID); WRAPARG(fUnk); WRAPARG(fVolume); EAXJMP(0x506EA0); } \ No newline at end of file +void CAEVehicleAudioEntity::GetVehicleAudioSettings(short nModelID) +{ + AudioSettings = AudioSettingsMap[nModelID]; +} + +void CAEVehicleAudioEntity::LoadVehicleAudioSettings() +{ + if ( FILE* hFile = CFileMgr::OpenFile("DATA\\VEHAUDIOSETS.DAT", "r") ) + { + while ( const char* pLine = CFileLoader::LoadLine(hFile) ) + { + if ( pLine[0] && pLine[0] != '#' ) + { + signed int nModelID, nVehType, nEngineOn, nEngineOff, nRadioSound, nHornTon, nDoorSound, nUnk, nRadioNum, nRadioType, nScannerName; + tVehicleAudioSettings NewEntry; + char ModelName[40]; + + sscanf(pLine, "%s %d %d %d %d %f %f %d %f %d %d %d %d %d %f", ModelName, &nVehType, &nEngineOn, &nEngineOff, &nRadioSound, + &NewEntry.BassDepth, &NewEntry.unk1, &nHornTon, &NewEntry.HornFreq, &nDoorSound, &nUnk, &nRadioNum, &nRadioType, &nScannerName, + &NewEntry.EngineVolumeBoost); + + CModelInfo::GetModelInfo(ModelName, &nModelID); + + NewEntry.VehicleType = static_cast(nVehType); + NewEntry.EngineOnSound = static_cast(nEngineOn); + NewEntry.EngineOffSound = static_cast(nEngineOff); + NewEntry.RadioSoundType = static_cast(nRadioSound); + NewEntry.HornTon = static_cast(nHornTon); + NewEntry.DoorSound = static_cast(nDoorSound); + NewEntry.unk2 = static_cast(nUnk); + NewEntry.RadioNum = static_cast(nRadioNum); + NewEntry.RadioType = static_cast(nRadioType); + NewEntry.PoliceScannerName = static_cast(nScannerName); + + AudioSettingsMap[static_cast(nModelID)] = NewEntry; + } + } + CFileMgr::CloseFile(hFile); + } +} \ No newline at end of file diff --git a/VCS PC/Audio.h b/VCS PC/Audio.h index d97c1cb..309e4b8 100644 --- a/VCS PC/Audio.h +++ b/VCS PC/Audio.h @@ -33,6 +33,23 @@ #define NJ_OFFSET (MR_OFFSET+MR_STREAMS) #define RE_OFFSET (NJ_OFFSET+NJ_STREAMS) +struct tVehicleAudioSettings +{ + signed char VehicleType; + short EngineOnSound; + short EngineOffSound; + signed char RadioSoundType; // 0 - standard, 1 - HQ, 2 - bikes + float BassDepth; + float unk1; + signed char HornTon; + float HornFreq; + signed char DoorSound; + signed char unk2; + signed char RadioNum; + signed char RadioType; + signed char PoliceScannerName; + float EngineVolumeBoost; +}; class CAERadioTrackManager { @@ -46,10 +63,25 @@ class CAERadioTrackManager static bool Load(); }; -class CMusicManager +class CAEVehicleAudioEntity +{ +private: + BYTE pad[128]; + tVehicleAudioSettings AudioSettings; + +public: + void GetVehicleAudioSettings(short nModelID); + + // VCS PC class extension + static void LoadVehicleAudioSettings(); +}; + +class CAudioEngine { public: void ReportFrontendAudioEvent(long nSoundID, float fUnk, float fVolume); }; +static_assert(sizeof(tVehicleAudioSettings) == 0x24, "tVehicleAudioSettings has wrong size!"); + #endif \ No newline at end of file diff --git a/VCS PC/CClock.cpp b/VCS PC/CClock.cpp deleted file mode 100644 index 039689a..0000000 --- a/VCS PC/CClock.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "StdAfx.h" - -WRAPPER bool CClock::GetIsTimeInRange(unsigned char bHourA, unsigned char bHourB) { WRAPARG(bHourA); WRAPARG(bHourB); EAXJMP(0x52CEE0); } - -bool CClock::Convert24To12(BYTE& bHour) -{ - bool bPastMorning = bHour >= 12; - bHour %= 12; - if ( !bHour ) - bHour = 12; - - return bPastMorning; -} \ No newline at end of file diff --git a/VCS PC/CClock.h b/VCS PC/CClock.h deleted file mode 100644 index e645f0f..0000000 --- a/VCS PC/CClock.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __CCLOCK -#define __CCLOCK - -#define WIN32_LEAN_AND_MEAN - -class CClock -{ -private: - BYTE bClockHasBeenStored; - BYTE __pad1[3]; - WORD wStoredGameClockSeconds; - BYTE bStoredGameClockMinutes; - BYTE bStoredGameClockHours; - BYTE bStoredGameMonthDay; - BYTE bStoredGameMonth; - BYTE bGameDayOfWeek; - WORD wGameClockSeconds; - BYTE bGameClockMinutes; - BYTE bGameClockHours; - BYTE bGameMonthDay; - BYTE bGameMonth; - DWORD LastClockTick; - DWORD MillisecondsPerGameMinute; - -public: - BYTE GetHour() - { return bGameClockHours; }; - BYTE GetMinute() - { return bGameClockMinutes; }; - - static bool GetIsTimeInRange(unsigned char bHourA, unsigned char bHourB); - - static bool Convert24To12(BYTE& bHour); -}; - -static_assert(sizeof(CClock) == CClock_ARRAYSIZE, "CClock class has wrong size!"); - -#endif \ No newline at end of file diff --git a/VCS PC/CGridref.cpp b/VCS PC/CGridref.cpp index dc72ff3..a91d025 100644 --- a/VCS PC/CGridref.cpp +++ b/VCS PC/CGridref.cpp @@ -9,18 +9,18 @@ void CGridref::Draw() BYTE zoneY; GetIDByPlayerPosition(&zoneX, &zoneY); - CFont::SetTextBackground(0, 0); - CFont::SetTextUseProportionalValues(false); + CFont::SetBackground(0, 0); + CFont::SetProportional(false); CFont::SetFontStyle(FONT_Pricedown); - CFont::SetTextAlignment(ALIGN_Center); - CFont::SetTextOutline(1); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); + CFont::SetOrientation(ALIGN_Center); + CFont::SetEdge(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetScale(_width(0.35), _height(0.65)); CFont::SetColor(CRGBA(BaseColors[2])); _snprintf(ZoneID, sizeof(ZoneID), "%c%d", zoneX + 100, zoneY); CFont::PrintString(_x(150.0), _y(7.5), ZoneID); CFont::PrintString(_x(115.0), _y(7.5), GetNameByID(zoneX, zoneY)); - CFont::SetTextOutline(0); + CFont::SetEdge(0); } } diff --git a/VCS PC/CPed.cpp b/VCS PC/CPed.cpp index 7168e43..ecb496b 100644 --- a/VCS PC/CPed.cpp +++ b/VCS PC/CPed.cpp @@ -34,9 +34,9 @@ void CPed::GetBonePosition(CVector* result, int boneID, bool bUnk) } } -BYTE CPed::func_5E6580() +BYTE CPed::GetWeaponSkill() { - DWORD dwFunc = (DWORD)FUNC_CPed_func_5E6580; + DWORD dwFunc = (DWORD)FUNC_CPed_GetWeaponSkill; BYTE bResult; _asm { @@ -55,7 +55,7 @@ long double CPed::GetCrosshairSize() long double crosshairSize; weaponID = weaponSlots[m_bActiveWeapon].dwType; - unkData = func_5E6580(); + unkData = GetWeaponSkill(); weapPtr = CWeaponInfo::GetWeaponInfo(weaponID, unkData); crosshairSize = 0.5 / weapPtr->GetAccuracy(); @@ -68,8 +68,8 @@ long double CPed::GetCrosshairSize() void CPed::Remap() { CPedData* pTempPedData = &CPedData::pPedData[CPools::GetPedPool()->GetIndexOnly(this)]; - CPedModelInfoVCS::AssignColoursToModel(pTempPedData->m_color1, pTempPedData->m_color2, pTempPedData->m_color3, pTempPedData->m_color4); - CPedModelInfoVCS::SetEnvironmentMap(m_pRwObject); + CPedModelInfoVCS::SetPedColour(pTempPedData->m_color1, pTempPedData->m_color2, pTempPedData->m_color3, pTempPedData->m_color4); + CPedModelInfoVCS::SetEditableMaterials(m_pRwObject); } CPed* CPedData::Constructor(CPed* pPed, WORD model) diff --git a/VCS PC/CPed.h b/VCS PC/CPed.h index 9e44449..6bbf3e1 100644 --- a/VCS PC/CPed.h +++ b/VCS PC/CPed.h @@ -4,7 +4,7 @@ #define WIN32_LEAN_AND_MEAN #define FUNC_CPed__GiveWeapon 0x5E6080 -#define FUNC_CPed_func_5E6580 0x5E6580 +#define FUNC_CPed_GetWeaponSkill 0x5E6580 #define FUNC_CPed__GetBonePosition 0x5E4280 class CPedFlags @@ -146,7 +146,7 @@ class CPedFlags class CVehicle; class CPed; -class CPlayerData +class CPlayerPedData { public: CWanted* m_Wanted; // 0x0 @@ -230,7 +230,7 @@ class NOVMT CPed : public CPhysical BYTE __pad1[820]; CPedFlags pedFlags; CPedIntelligence* pPedIntelligence; - CPlayerData* pPlayerData; + CPlayerPedData* pPlayerData; BYTE __pad7[80]; int iMoveAnimGroup; BYTE __pad2[104]; @@ -269,7 +269,7 @@ class NOVMT CPed : public CPhysical { return fHealth; }; inline float GetArmour() { return fArmour; }; - inline CPlayerData* GetPlayerData() + inline CPlayerPedData* GetPlayerData() { return pPlayerData; }; inline BYTE GetActiveWeapon() { return m_bActiveWeapon; }; @@ -281,7 +281,7 @@ class NOVMT CPed : public CPhysical void GiveWeapon(int WeaponType, int WeaponAmmo); void GetBonePosition(CVector* result, int boneID, bool bUnk); - BYTE func_5E6580(); + BYTE GetWeaponSkill(); long double GetCrosshairSize(); void Remap(); @@ -301,8 +301,7 @@ friend class CPed; CPedData() : m_color1(0), m_color2(0), m_color3(0), m_color4(0) - { - } + {} void SetColours(BYTE a, BYTE b, BYTE c, BYTE d) { m_color1 = a; m_color2 = b; m_color3 = c; m_color4 = d; }; diff --git a/VCS PC/CText.cpp b/VCS PC/CText.cpp deleted file mode 100644 index b759e4d..0000000 --- a/VCS PC/CText.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "StdAfx.h" - -const char* CText::GetText(const char* entry) -{ - static char missingText[24]; - char* outputText; - if ( CLEOGetTextFunc ) - { - outputText = CLEOGetTextFunc(this, entry); - if ( !*outputText ) - { - _snprintf(missingText, sizeof(missingText), "%s missing", entry); - return missingText; - } - return outputText; - } - else - { - bool found; - if ( *entry == '\0' || *entry == ' ' ) - return ""; - - outputText = tkeyMain.Locate(entry, &found); - - if ( !found ) - { - if ( missionLoaded || *mpackNumber || haveTabl ) - { - outputText = tkeyMission.Locate(entry, &found); - if ( !found ) - { - _snprintf(missingText, sizeof(missingText), "%s missing", entry); - return missingText; - } - } - } - } - return outputText; -} - -void CText::ReloadFontsFiles(bool bUnk) -{ - UNREFERENCED_PARAMETER(bUnk); -#ifdef INCLUDE_MULTIFONTFILES - Load(unkFlag); - if ( bCanReloadFonts && bLastFontsID != GetFontsIDByLanguage() ) - { - int slot = CTxdStore::FindTxdSlot("fontDetails"); - if ( slot == -1 ) - slot = CTxdStore::AddTxdSlot("fontDetails"); - CTxdStore::LoadTxd(slot, GetFontsTXDByLanguage()); - CTxdStore::AddRef(slot); - CTxdStore::PushCurrentTxd(); - CTxdStore::SetCurrentTxd(slot); - texFonts[0].Load("font2", "font2m"); - texFonts[1].Load("font1", "font1m"); - CFont::LoadFontValues(); - CTxdStore::PopCurrentTxd(); - } -#endif -} - -void CText::TextNumberFormat(const char* pszText, int nNumber1, int nNumber2, int nNumber3, int nNumber4, int nNumber5, int nNumber6, char* pszOutBuf) -{ - DWORD dwFunc = (DWORD)FUNC_CText__TextNumberFormat; - _asm - { - push pszOutBuf - push nNumber6 - push nNumber5 - push nNumber4 - push nNumber3 - push nNumber2 - push nNumber1 - push pszText - mov ecx, this - call dwFunc - } -} - -void CText::Load(bool bUnk) -{ - DWORD dwFunc = (DWORD)FUNC_CText__Load; - _asm - { - movzx eax, bUnk - push eax - mov ecx, this - call dwFunc - } -} - -void CText::Clear(bool bUnk) -{ - DWORD dwFunc = (DWORD)FUNC_CText__Clear; - _asm - { - movzx eax, bUnk - push eax - mov ecx, this - call dwFunc - } -} - -char* CText::TKey::Locate(const char* key, bool* found) -{ - DWORD dwFunc = (DWORD)FUNC_CText_TKey__Locate; - _asm - { - push found - push key - mov ecx, this - call dwFunc - } -} \ No newline at end of file diff --git a/VCS PC/CText.h b/VCS PC/CText.h deleted file mode 100644 index 8f11c01..0000000 --- a/VCS PC/CText.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef __CTEXT -#define __CTEXT - -#define FUNC_CText__GetText 0x6A0050 -#define FUNC_CText__TextNumberFormat 0x69DE90 -#define FUNC_CText__Clear 0x69FF20 -#define FUNC_CText__Load 0x6A01A0 -#define FUNC_CText_TKey__Locate 0x6A0000 - -enum eLanguages -{ - LANG_English, - //LANG_Spanish, - LANG_Polish, - NUM_LANGUAGES -}; - - -class CText -{ -private: - struct TKey - { - struct - { - const char *text; - unsigned long hash; - } *data; - DWORD size; - - char * Locate(const char *key, bool* found); - }; - struct TDat - { - void* data; - DWORD size; - }; - struct Table - { - struct Entry - { - char name[8]; - void* offset; - }; - Entry tablEntries[200]; - WORD size; - }; - TKey tkeyMain; - TDat tdatMain; - TKey tkeyMission; - TDat tdatMission; - BYTE _f20; - bool haveTabl; - bool cderrorInitialized; - bool missionLoaded; - char missionName[8]; - char cderrorText[256]; - Table table; - -public: - const char* GetText(const char* entry); - void ReloadFontsFiles(bool bUnk); - void TextNumberFormat(const char* pszText, int nNumber1, int nNumber2, int nNumber3, int nNumber4, int nNumber5, int nNumber6, char* pszOutBuf); - void Load(bool bUnk); - void Clear(bool bUnk); -}; - -static_assert(sizeof(CText) == CText_ARRAYSIZE, "CText class has wrong size!"); - -#endif \ No newline at end of file diff --git a/VCS PC/CVehicle.h b/VCS PC/CVehicle.h index ed839c5..63bbece 100644 --- a/VCS PC/CVehicle.h +++ b/VCS PC/CVehicle.h @@ -1,8 +1,6 @@ #ifndef __CVEHICLE #define __CVEHICLE -#define WIN32_LEAN_AND_MEAN - struct CVehicleFlags { //0x428 @@ -96,15 +94,27 @@ class NOVMT CVehicle : public CPhysical public: CVehicleFlags& GetVehicleFlags() - { return m_nVehicleFlags; }; + { return m_nVehicleFlags; } CEntity* GetDamagingEntity() { return pDamagingEntity; } + + void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); }; -class CAutomobile : public CVehicle +class NOVMT CAutomobile : public CVehicle { -private: - BYTE padding[760]; +public: + BYTE paddd[172]; + RwFrame* m_pCarNode[20]; // May be wrong? + BYTE padding[432]; + float m_fRotorSpeed; + BYTE __moarpad[72]; +}; + +class NOVMT CHeli : public CAutomobile +{ +public: + void ProcessRotorsAlpha(); }; static_assert(sizeof(CVehicle) == CVehicle_ARRAYSIZE, "CVehicle class has wrong size!"); diff --git a/VCS PC/CWanted.h b/VCS PC/CWanted.h index 5fe18f8..d6c2d50 100644 --- a/VCS PC/CWanted.h +++ b/VCS PC/CWanted.h @@ -36,6 +36,5 @@ class CWanted }; static_assert(sizeof(CWanted) == CWanted_ARRAYSIZE, "CWanted class has wrong size!"); -//static_assert(sizeof(CWanted) == CWanted_ARRAYSIZE); #endif \ No newline at end of file diff --git a/VCS PC/Clock.cpp b/VCS PC/Clock.cpp new file mode 100644 index 0000000..564d3fb --- /dev/null +++ b/VCS PC/Clock.cpp @@ -0,0 +1,21 @@ +#include "StdAfx.h" + +unsigned char& CClock::ms_nGameClockHours = *(unsigned char*)0xB70153; +unsigned char& CClock::ms_nGameClockMinutes = *(unsigned char*)0xB70152; + +bool CClock::GetIsTimeInRange(unsigned char bHourA, unsigned char bHourB) +{ + if ( bHourA > bHourB ) + return ms_nGameClockHours >= bHourA || ms_nGameClockHours < bHourB; + return ms_nGameClockHours >= bHourA && ms_nGameClockHours < bHourB; +} + +bool CClock::Convert24To12(unsigned char& bHour) +{ + bool bPastMorning = bHour >= 12; + bHour %= 12; + if ( !bHour ) + bHour = 12; + + return bPastMorning; +} \ No newline at end of file diff --git a/VCS PC/Clock.h b/VCS PC/Clock.h new file mode 100644 index 0000000..269df4d --- /dev/null +++ b/VCS PC/Clock.h @@ -0,0 +1,21 @@ +#ifndef __CLOCK +#define __CLOCK + +class CClock +{ +private: + static unsigned char& ms_nGameClockHours; + static unsigned char& ms_nGameClockMinutes; + +public: + static inline unsigned char GetHours() + { return ms_nGameClockHours; } + static inline unsigned char GetMinutes() + { return ms_nGameClockMinutes; } + + static bool GetIsTimeInRange(unsigned char bHourA, unsigned char bHourB); + + static bool Convert24To12(unsigned char& bHour); +}; + +#endif \ No newline at end of file diff --git a/VCS PC/ColAccel.cpp b/VCS PC/ColAccel.cpp new file mode 100644 index 0000000..bcfc71a --- /dev/null +++ b/VCS PC/ColAccel.cpp @@ -0,0 +1,66 @@ +#include "StdAfx.h" + +const char*& CColAccel::mp_cCacheName = *(const char**)0x8D0F84; +int& CColAccel::m_iCachingColSize = *(int*)0xBC409C; +int& CColAccel::m_iCacheState = *(int*)0xBC40A0; +int& CColAccel::m_iNumColItems = *(int*)0xBC40A8; +int& CColAccel::m_iNumSections = *(int*)0xBC40B4; +int& CColAccel::m_iNumColBounds = *(int*)0xBC40B8; +int& CColAccel::m_iNumIPLItems = *(int*)0xBC40B0; +void*& CColAccel::mp_caccColItems = *(void**)0xBC40A4; +void*& CColAccel::mp_caccIPLItems = *(void**)0xBC40AC; +int*& CColAccel::m_iSectionSize = *(int**)0xBC4098; +void*& CColAccel::m_iplDefs = *(void**)0xBC4094; +void*& CColAccel::m_colBounds = *(void**)0xBC4090; + +void CColAccel::startCache() +{ + // Call SA startCache... + ((void(*)())0x5B31A0)(); + + // ...and now finish what R* never did + if ( FILE* hFile = CFileMgr::OpenFile(mp_cCacheName, "rb") ) + { + // Parse generated cinfo.bin + CFileMgr::Read(hFile, &m_iNumColItems, sizeof(int)); + mp_caccColItems = new char[m_iNumColItems * 48]; + CFileMgr::Read(hFile, mp_caccColItems, m_iNumColItems * 48); + + CFileMgr::Read(hFile, &m_iNumSections, sizeof(int)); + CFileMgr::Read(hFile, m_iSectionSize, m_iNumSections * sizeof(int)); + + CFileMgr::Read(hFile, m_iplDefs, 0x3400); + + CFileMgr::Read(hFile, &m_iNumColBounds, sizeof(int)); + CFileMgr::Read(hFile, m_colBounds, m_iNumColBounds * 24); + + CFileMgr::Read(hFile, &m_iNumIPLItems, sizeof(int)); + mp_caccIPLItems = new char[m_iNumIPLItems * 20]; + CFileMgr::Read(hFile, mp_caccIPLItems, m_iNumIPLItems * 20); + + m_iCacheState = 2; + + CFileMgr::CloseFile(hFile); + } + else + { + // Generate a new one + m_iNumSections = 0; + m_iNumColBounds = 0; + m_iNumColItems = 0; + m_iNumIPLItems = 0; + + mp_caccColItems = new char[m_iCachingColSize * 48]; + mp_caccIPLItems = new char[20][64]; + + m_iCacheState = 1; + } +} + +void CColAccel::endCache() +{ + ((void(*)())0x5B2AD0)(); + + delete mp_caccColItems; + delete mp_caccIPLItems; +} \ No newline at end of file diff --git a/VCS PC/ColAccel.h b/VCS PC/ColAccel.h new file mode 100644 index 0000000..6adef64 --- /dev/null +++ b/VCS PC/ColAccel.h @@ -0,0 +1,25 @@ +#ifndef __COLACCEL +#define __COLACCEL + +class CColAccel +{ +private: + static const char*& mp_cCacheName; + static int& m_iCachingColSize; + static int& m_iCacheState; + static int& m_iNumColItems; + static int& m_iNumSections; + static int& m_iNumColBounds; + static int& m_iNumIPLItems; + static void*& mp_caccColItems; + static void*& mp_caccIPLItems; + static int*& m_iSectionSize; + static void*& m_iplDefs; + static void*& m_colBounds; + +public: + static void startCache(); + static void endCache(); +}; + +#endif \ No newline at end of file diff --git a/VCS PC/Coronas.cpp b/VCS PC/Coronas.cpp index c147a74..5ee68e8 100644 --- a/VCS PC/Coronas.cpp +++ b/VCS PC/Coronas.cpp @@ -34,37 +34,6 @@ void CCoronas::RegisterCorona(unsigned int nID, CEntity* pAttachTo, unsigned cha A *= static_cast((fDistFromCam-35.0f) * (2.0f/3.0f)); } - /*auto it = aCoronas.begin(); - - for ( ; it != aCoronas.end(); it++ ) - { - if ( it->Identifier == nID ) - break; - } - - if ( it != aCoronas.end() ) - { - if ( it->FadedIntensity == 0 && A == 0 ) - { - it->Identifier = 0; - --NumCoronas; - return; - } - } - else - { - if ( A ) - { - bool bFoundFreeSlot = false; - for ( it = aCoronas.begin(); it != aCoronas.end(); it++ ) - { - if ( !it->Identifier ) - { - bFoundFreeSlot = true; - break; - } - }*/ - bool bFoundFreeSlot = false; std::vector::iterator freeSlotIt; auto it = aCoronas.begin(); diff --git a/VCS PC/DLCManager.cpp b/VCS PC/DLCManager.cpp index 9e82203..a9ec81f 100644 --- a/VCS PC/DLCManager.cpp +++ b/VCS PC/DLCManager.cpp @@ -62,17 +62,22 @@ void CDLCManager::LoadLevelFiles() for ( int i = 0; i < NUM_DLC_PACKS; ++i ) { - if ( m_pDLC[i]->IsEnabled() ) + if ( m_pDLC[i]->CheckInstallState(i) ) { - char cLevelsPath[MAX_PATH]; - char cDLCName[32]; - _snprintf(cLevelsPath, sizeof(cLevelsPath), "dlc\\dlc%d\\content.dat", i); - - if ( !CFileLoader::ParseLevelFile(cLevelsPath, cDLCName) ) - m_pDLC[i]->Activate(false); - - if ( _strnicmp(cDLCName, m_pDLC[i]->GetName(), sizeof(cDLCName)) ) - m_pDLC[i]->Activate(false); + if ( m_pDLC[i]->IsEnabled() ) + { + char cLevelsPath[MAX_PATH]; + char cDLCName[32]; + _snprintf(cLevelsPath, sizeof(cLevelsPath), "dlc\\dlc%d\\content.dat", i); + + if ( !CFileLoader::ParseLevelFile(cLevelsPath, cDLCName) ) + m_pDLC[i]->Activate(false); + else + { + if ( _strnicmp(cDLCName, m_pDLC[i]->GetName(), sizeof(cDLCName)) ) + m_pDLC[i]->Activate(false); + } + } } } @@ -90,5 +95,8 @@ void CDLCManager::HandleButtonClick(int nMenuEntry) const char* pDLCName = m_pDLC[nDLC]->GetName(); // Toggle DLC on/off - CUpdateManager::SetDLCStatus(pDLCName, CUpdateManager::GetDLCStatus(pDLCName, false) == false); + if ( m_pDLC[nDLC]->IsInstalled() ) + CUpdateManager::SetDLCStatus(pDLCName, CUpdateManager::GetDLCStatus(pDLCName, false) == false); + else + FrontEndMenuManager.SwitchToNewScreen(48); } \ No newline at end of file diff --git a/VCS PC/DLCManager.h b/VCS PC/DLCManager.h index b04f8ce..36f61c7 100644 --- a/VCS PC/DLCManager.h +++ b/VCS PC/DLCManager.h @@ -7,7 +7,7 @@ class CExpansionPack { private: - bool m_bActive; + bool m_bActive, m_bInstalled; const char* m_pInternalName; public: @@ -17,16 +17,23 @@ class CExpansionPack { return false; } inline void Activate(bool bState) - { LogToFile("Pack %s is %s", m_pInternalName, bState ? "ACTIVE" : "INACTIVE"); m_bActive = bState; } + { LogToFile("Pack %s is %s", m_pInternalName, bState ? "ACTIVE" : "INACTIVE"); m_bActive = bState; } + inline bool CheckInstallState(int nIndex) { + char cLevelsPath[MAX_PATH]; + _snprintf(cLevelsPath, sizeof(cLevelsPath), "dlc\\dlc%d\\content.dat", nIndex); + return m_bInstalled = GetFileAttributes(cLevelsPath) != INVALID_FILE_ATTRIBUTES; } + inline bool IsEnabled() { return m_bActive; } + inline bool IsInstalled() + { return m_bInstalled; } inline bool IsActive() { return CUpdateManager::GetDLCStatus(m_pInternalName, false); } inline const char* GetName() { return m_pInternalName; } CExpansionPack(const char* pName) - : m_bActive(false), m_pInternalName(pName) + : m_bActive(false), m_bInstalled(false), m_pInternalName(pName) { } }; @@ -44,11 +51,10 @@ class CTimedExpansionPack : public CExpansionPack CTimedExpansionPack(const char* pName, const CDate& BeginDate, const CDate& EndDate) : CExpansionPack(pName), m_launchDate(BeginDate), m_expirationDate(EndDate) - { - } + {} // Just to make the compiler shut the fuck up - CTimedExpansionPack& operator=(const CTimedExpansionPack&) { }; + CTimedExpansionPack& operator=(const CTimedExpansionPack&) {} }; class CDLCManager diff --git a/VCS PC/Darkel.cpp b/VCS PC/Darkel.cpp index 8979c77..c9c7519 100644 --- a/VCS PC/Darkel.cpp +++ b/VCS PC/Darkel.cpp @@ -61,13 +61,13 @@ void CDarkel::DrawMessages() CMessages::AddBigMessage(pStartMessage, 3000, 0); } } - CFont::SetTextBackground(0, 0); + CFont::SetBackground(0, 0); CFont::SetScale(_width(0.5f), _height(1.1f)); - CFont::SetTextAlignment(ALIGN_Right); - CFont::SetTextWrapX(0.0f); + CFont::SetOrientation(ALIGN_Right); + CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_Eurostile); - CFont::SetTextOutline(1); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); + CFont::SetEdge(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(BaseColors[4]); if ( TimeLimit >= 0 ) @@ -84,10 +84,10 @@ void CDarkel::DrawMessages() fPosXOffset = 0.0f; // TODO: Flashing - CFont::SetTextUseProportionalValues(true); - CFont::PrintString(_x(88.0f + fPosXOffset), _y(148.0f), TheText.GetText("TIME")); + CFont::SetProportional(true); + CFont::PrintString(_x(88.0f + fPosXOffset), _y(148.0f), TheText.Get("TIME")); - CFont::SetTextUseProportionalValues(false); + CFont::SetProportional(false); CFont::SetColor(BaseColors[11]); CFont::PrintString(_x(32.0f), _y(148.0f), gString); } @@ -102,11 +102,11 @@ void CDarkel::DrawMessages() else fPosXOffset = 0.0f; - CFont::SetTextUseProportionalValues(true); + CFont::SetProportional(true); CFont::SetColor(BaseColors[8]); - CFont::PrintString(_x(88.0f + fPosXOffset), _y(175.0f), TheText.GetText("RAMP_KL")); + CFont::PrintString(_x(88.0f + fPosXOffset), _y(175.0f), TheText.Get("RAMP_KL")); - CFont::SetTextUseProportionalValues(false); + CFont::SetProportional(false); CFont::PrintString(_x(32.0f), _y(175.0f), gString); return; } @@ -115,7 +115,7 @@ void CDarkel::DrawMessages() if ( bStandardSoundAndMessages ) { if ( CTimer::m_snTimeInMilliseconds - TimeOfFrenzyStart < 5000 ) - CMessages::AddBigMessage(TheText.GetText("KILLPA"), 3000, 0); + CMessages::AddBigMessage(TheText.Get("KILLPA"), 3000, 0); } return; } diff --git a/VCS PC/EmpireMgr.cpp b/VCS PC/EmpireMgr.cpp index bf530bd..d0931bf 100644 --- a/VCS PC/EmpireMgr.cpp +++ b/VCS PC/EmpireMgr.cpp @@ -1,7 +1,7 @@ #include "StdAfx.h" -CEmpire CEmpireManager::m_empire[NUM_EMPIRES]; -EmpireType CEmpireManager::m_empireType[NUM_EMPIRE_TYPES]; +CEmpire CEmpireManager::m_empire[NUM_EMPIRES]; +tEmpireType CEmpireManager::m_empireType[NUM_EMPIRE_TYPES]; void CEmpireManager::Initialise() { @@ -11,8 +11,10 @@ void CEmpireManager::Initialise() { SECTION_NOTHING, SECTION_PLACES, - SECTION_TYPES + SECTION_TYPES, + SECTION_DATA } curFileSection = SECTION_NOTHING; + CAtomicModelInfo* pCurrentModelForDataParsing = nullptr; while ( const char* pLine = CFileLoader::LoadLine(hFile) ) { @@ -24,11 +26,10 @@ void CEmpireManager::Initialise() { if ( SECTION4(pLine, 'p', 'l', 'a', 'c') ) curFileSection = SECTION_PLACES; - else - { - if ( SECTION4(pLine, 't', 'y', 'p', 'e') ) - curFileSection = SECTION_TYPES; - } + else if ( SECTION4(pLine, 't', 'y', 'p', 'e') ) + curFileSection = SECTION_TYPES; + else if ( SECTION4(pLine, 'd', 'a', 't', 'a') ) + curFileSection = SECTION_DATA; break; } case SECTION_PLACES: @@ -75,6 +76,37 @@ void CEmpireManager::Initialise() } break; } + case SECTION_DATA: + { + if ( SECTION3(pLine, 'e', 'n', 'd') ) + { + if ( pCurrentModelForDataParsing ) + pCurrentModelForDataParsing->GetEmpireData()->ReduceContainerSize(); + curFileSection = SECTION_NOTHING; + } + else + { + if ( pLine[0] == '%' ) + { + if ( pCurrentModelForDataParsing ) + pCurrentModelForDataParsing->GetEmpireData()->ReduceContainerSize(); + + pCurrentModelForDataParsing = CModelInfo::GetModelInfo(pLine+2)->AsAtomicModelInfoPtr(); + pCurrentModelForDataParsing->InitEmpireData(); + } + else + { + CSimpleTransform tempTransform; + unsigned int nIndex; + + assert(pCurrentModelForDataParsing); + sscanf(pLine, "%d %f %f %f %f", &nIndex, &tempTransform.m_translate.x, &tempTransform.m_translate.y, &tempTransform.m_translate.z, &tempTransform.m_heading); + + pCurrentModelForDataParsing->GetEmpireData()->AddEntry(static_cast(nIndex), tempTransform); + } + } + break; + } } } @@ -98,6 +130,12 @@ void CEmpireManager::Process() }*/ } +void CEmpireBuildingData::ReduceContainerSize() +{ + for ( auto it = m_buildingData.begin(); it != m_buildingData.end(); it++ ) + it->second.shrink_to_fit(); +} + void CEmpire::Place() { if ( m_nType == -1 ) @@ -140,15 +178,6 @@ void CEmpire::Place() pModelRect->y2 = boundingRect.y2; if ( boundingRect.y1 > pModelRect->y1 ) pModelRect->y1 = boundingRect.y1; - - /*if ( boundingRect.x < pModelRect->x ) - pModelRect->x = boundingRect.x; - if ( boundingRect.w > pModelRect->w ) - pModelRect->w = boundingRect.w; - if ( boundingRect.h < pModelRect->h ) - pModelRect->h = boundingRect.h; - if ( boundingRect.y > pModelRect->y ) - pModelRect->y = boundingRect.y;*/ } } diff --git a/VCS PC/EmpireMgr.h b/VCS PC/EmpireMgr.h index b6d49d4..a75dd87 100644 --- a/VCS PC/EmpireMgr.h +++ b/VCS PC/EmpireMgr.h @@ -6,11 +6,23 @@ class CBuilding; -struct EmpireType +struct tEmpireType { int nNormalBuilding[3], nDamagedBuilding[3]; }; +class CEmpireBuildingData +{ +private: + std::map> m_buildingData; + +public: + inline void AddEntry(unsigned short nType, const CSimpleTransform& vecPos) + { m_buildingData[nType].push_back(vecPos); } + + void ReduceContainerSize(); +}; + class CEmpire { private: @@ -23,8 +35,7 @@ class CEmpire public: CEmpire() : m_bPlaced(false), m_bDefined(false), m_pBuilding(nullptr), m_nType(-1), m_nScale(0) - { - } + {} inline CSimpleTransform* GetTransform() { return &m_placement; } @@ -50,10 +61,10 @@ class CEmpireManager { private: static CEmpire m_empire[NUM_EMPIRES]; - static EmpireType m_empireType[NUM_EMPIRE_TYPES]; + static tEmpireType m_empireType[NUM_EMPIRE_TYPES]; public: - static inline EmpireType* GetInfo(int nIndex) + static inline tEmpireType* GetInfo(int nIndex) { return &m_empireType[nIndex]; } static inline CEmpire* GetEmpire(int nIndex) { assert(nIndex >= 0 && nIndex < NUM_EMPIRES); diff --git a/VCS PC/FileMgr.cpp b/VCS PC/FileMgr.cpp index 63d9f74..931b8bf 100644 --- a/VCS PC/FileMgr.cpp +++ b/VCS PC/FileMgr.cpp @@ -20,6 +20,8 @@ WRAPPER void CFileLoader::LoadCollisionFile(const char* pFileName, unsigned char static WRAPPER void InitPostIDEStuff() { EAXJMP(0x5B924E); } static WRAPPER void InitPostLoadLevelStuff() { EAXJMP(0x5B930F); } +static WRAPPER void SetAtomicModelInfoFlags(CAtomicModelInfo* pInfo, unsigned int dwFlags) { WRAPARG(pInfo); WRAPARG(dwFlags); EAXJMP(0x5B3B20); } + const char* CFileLoader::LoadLine(FILE* hFile) { static char cLineBuffer[512]; @@ -44,6 +46,107 @@ const char* CFileLoader::LoadLine(FILE* hFile) return p; } +int CFileLoader::LoadObject(const char* pLine) +{ + int objID; //objCount; + char modelName[24], texName[24]; + //float drawDist[3]; + float fDrawDist; + unsigned int flags; + + if ( sscanf(pLine, "%d %s %s %f %d", &objID, modelName, texName, &fDrawDist, &flags) != 5 ) + { + LogToFile("ERROR: Invalid line found when parsing an IDE file: %s", pLine); + return -1; + } + if ( fDrawDist < 4.0f ) + return -1; + /*if ( sscanf(pLine, "%d %s %s %f %d", &objID, modelName, texName, &fDrawDist, &flags) != 5 || drawDist[0] < 4.0f ) + { + // No instances of such lines in files whatsoever + // Might have been used by LodAtomicModelInfos? + /*if ( sscanf(pLine, "%d %s %s %d", &objID, modelName, texName, &objCount) != 4 ) + return -1; + + switch ( objCount ) + { + case 1: + sscanf(pLine, "%d %s %s %d %f %d", &objID, modelName, texName, &objCount, &drawDist[0], &flags); + break; + case 2: + sscanf(pLine, "%d %s %s %d %f %f %d", &objID, modelName, texName, &objCount, &drawDist[0], &drawDist[1], &flags); + break; + case 3: + sscanf(pLine, "%d %s %s %d %f %f %f %d", &objID, modelName, texName, &objCount, &drawDist[0], &drawDist[1], &drawDist[2], &flags); + break; + } + }*/ + + if ( !CModelInfo::ms_modelInfoPtrs[objID] ) + { + CAtomicModelInfo* pModel; + + if ( flags & 0x1000 ) + pModel = CModelInfo::AddDamageAtomicModel(objID); + else + pModel = CModelInfo::AddAtomicModel(objID); + + pModel->fLodDistanceUnscaled = fDrawDist; + pModel->ulHashKey = CKeyGen::GetUppercaseKey(modelName); + pModel->SetTexDictionary(texName); + SetAtomicModelInfoFlags(pModel, flags); + + /*// TEMP dbug code + unsigned int nTemp = *(unsigned short*)((BYTE*)pModel + 0x12); + + if ( !(nTemp & 0x100) ) + { + nTemp &= 0x7800; + assert(nTemp != 0x3000); + }*/ + } + return objID; +} + +/*std::map TempMap; + +void LogName(int nIndex, const char* pName) +{ + TempMap[nIndex] = pName; +} + +void __declspec(naked) CatchVehNames() +{ + _asm + { + lea eax, [esp+0F8h-30h] + push eax + push ecx + call LogName + add esp, 8 + mov eax, [esp+0F8h-94h] + push eax + mov eax, 4C6770h + call eax + mov ecx, 5B6FD6h + jmp ecx + } +} + +void DumpVehicleAudioSettings() +{ + if ( FILE* hFile = CFileMgr::OpenFile("vehaudiosettings.txt", "w") ) + { + for ( short i = 400; i < 612; i++ ) + { + tVehicleAudioSettings VehicleAudio = ((tVehicleAudioSettings(__stdcall*)(short))0x4F5C10)(i); + fprintf(hFile, "%s,\t%d,\t%d,\t%d,\t%d,\t%g,\t%g,\t%d,\t%g,\t%d,\t%d,\t%d,\t%d,\t%d,\t%g\n", TempMap[i].c_str(), VehicleAudio.VehicleType, VehicleAudio.EngineOnSound, VehicleAudio.EngineOffSound, VehicleAudio.RadioSoundType, VehicleAudio.BassDepth, VehicleAudio.unk1, VehicleAudio.HornTon, VehicleAudio.HornFreq, VehicleAudio.DoorSound, VehicleAudio.unk2, VehicleAudio.RadioNum, VehicleAudio.RadioType, VehicleAudio.PoliceScannerName, VehicleAudio.EngineVolumeBoost); + } + + CFileMgr::CloseFile(hFile); + } +}*/ + void CFileLoader::LoadLevels() { RwTexDictionary* pPushedDictionary = RwTexDictionaryGetCurrent(); @@ -56,6 +159,7 @@ void CFileLoader::LoadLevels() Memory::Patch(0x590D2B, 31 + m_pObjectsList->size() + m_pScenesList->size()); Memory::Patch(0x590D68, 31 + m_pObjectsList->size() + m_pScenesList->size()); + //Memory::InjectHook(0x5B6FD0, CatchVehNames, PATCH_JUMP); // IMG for ( auto it = m_pImagesList->cbegin(); it != m_pImagesList->cend(); it++ ) @@ -86,6 +190,9 @@ void CFileLoader::LoadLevels() #endif InitPostIDEStuff(); CPedModelInfoVCS::LoadPedColours(); + CAEVehicleAudioEntity::LoadVehicleAudioSettings(); + + //DumpVehicleAudioSettings(); for ( int i = 0; i < 20000; ++i ) { @@ -106,6 +213,8 @@ void CFileLoader::LoadLevels() EndLevelLists(); RwTexDictionarySetCurrent(pPushedDictionary); InitPostLoadLevelStuff(); + + //CColAccel::endCache(); } bool CFileLoader::ParseLevelFile(const char* pFileName, char* pDLCName) diff --git a/VCS PC/FileMgr.h b/VCS PC/FileMgr.h index edb677b..0782227 100644 --- a/VCS PC/FileMgr.h +++ b/VCS PC/FileMgr.h @@ -40,7 +40,7 @@ class CFileLoader static char m_cTimecycPath[64]; static char m_cFrontendPath[64]; -public: +private: static inline void BeginLevelLists() { if ( !m_pImagesList ) m_pImagesList = new tFileLoaderList; if ( !m_pObjectsList ) m_pObjectsList = new tFileLoaderList; @@ -48,11 +48,12 @@ class CFileLoader if ( !m_pCollisionsList ) m_pCollisionsList = new tFileLoaderList; } static inline void EndLevelLists() - { if ( m_pImagesList ) delete m_pImagesList; - if ( m_pObjectsList ) delete m_pObjectsList; - if ( m_pScenesList ) delete m_pScenesList; - if ( m_pCollisionsList ) delete m_pCollisionsList; } + { delete m_pImagesList; + delete m_pObjectsList; + delete m_pScenesList; + delete m_pCollisionsList; } +public: static inline char* GetParticlesPath() { return m_cParticlesPath; } static inline char* GetPedgrpPath() @@ -68,6 +69,7 @@ class CFileLoader static void LoadScene(const char* pFileName); static void LoadCollisionFile(const char* pFileName, unsigned char bUnk); + static int LoadObject(const char* pLine); static const char* LoadLine(FILE* hFile); static void LoadLevels(); static bool ParseLevelFile(const char* pFileName, char* pDLCName); diff --git a/VCS PC/CFont.cpp b/VCS PC/Font.cpp similarity index 56% rename from VCS PC/CFont.cpp rename to VCS PC/Font.cpp index 6d0b1ca..e38397b 100644 --- a/VCS PC/CFont.cpp +++ b/VCS PC/Font.cpp @@ -7,16 +7,30 @@ CFont::tDetails& CFont::Details = *(CFont::tDetails*)0xC71A60; WRAPPER void CFont::SetWrapx(float fWrap) { WRAPARG(fWrap); EAXJMP(0x7194D0); } WRAPPER void CFont::LoadFontValues() { EAXJMP(0x7187C0); } WRAPPER void CFont::RenderFontBuffer() { EAXJMP(0x719840); } +WRAPPER void CFont::SetColor(CRGBA color) { WRAPARG(color); EAXJMP(0x719430); } +WRAPPER void CFont::SetDropColor(CRGBA color) { WRAPARG(color); EAXJMP(0x719510); } +WRAPPER void CFont::SetDropShadowPosition(signed char bShadow) { WRAPARG(bShadow); EAXJMP(0x719570); } +WRAPPER void CFont::SetEdge(signed char bEdge) { WRAPARG(bEdge); EAXJMP(0x719590); } +WRAPPER void CFont::SetSlantRefPoint(float fOne, float fTwo) { WRAPARG(fOne); WRAPARG(fTwo); EAXJMP(0x719400); } +WRAPPER void CFont::SetSlant(float fAngle) { WRAPARG(fAngle); EAXJMP(0x719420); } +WRAPPER void CFont::SetCentreSize(float fSize) { WRAPARG(fSize); EAXJMP(0x7194E0); } +WRAPPER void CFont::SetRightJustifyWrap(float fWrap) { WRAPARG(fWrap); EAXJMP(0x7194F0); } +WRAPPER void CFont::SetJustify(bool bJustify) { WRAPARG(bJustify); EAXJMP(0x719600); } +WRAPPER void CFont::SetProportional(bool bProportional) { WRAPARG(bProportional); EAXJMP(0x7195B0); } +WRAPPER void CFont::SetBackground(unsigned char bUseBackground, unsigned char bBackgroundType) { WRAPARG(bUseBackground); WRAPARG(bBackgroundType); EAXJMP(0x7195C0); } +WRAPPER void CFont::SetOrientation(unsigned char bOrientation) { WRAPARG(bOrientation); EAXJMP(0x719610); } +WRAPPER void CFont::PrintString(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A700); } +WRAPPER void CFont::PrintStringFromBottom(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A820); } unsigned char CFont::FindSubFontCharacter(char character, unsigned char bFontType) { UNREFERENCED_PARAMETER(bFontType); if ( character == 4 ) - return 155; + return 187; if ( character >= 16 && character <= 26 ) - return character + 128; + return character + 160; if ( character >= 59 && character <= 61 ) - return character + 97; + return character + 129; /*if ( character == 59 ) return 157; if ( character == 60 ) @@ -97,13 +111,13 @@ void CFont::SetScaleLang(float scaleX, float scaleY) Details.textLetterSizeY = scaleY; switch ( FrontEndMenuManager.GetLanguage() ) { - //case LANG_Spanish: + //case LANGUAGE_Spanish: // Details.textLetterSizeX = scaleX * 0.85f; // return; - case LANG_Polish: + case LANGUAGE_Polish: Details.textLetterSizeX = scaleX * 0.95f; return; - default: // LANG_English + default: // LANGUAGE_English Details.textLetterSizeX = scaleX; return; } @@ -123,156 +137,6 @@ void CFont::SetFontStyle(unsigned char bFont) } } -void CFont::SetColor(CRGBA colour) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextColour; - _asm - { - push colour - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextBorderRGBA(CRGBA colour) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextBorderRGBA; - _asm - { - mov eax, colour - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextShadow(unsigned char bShadow) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextShadow; - _asm - { - movzx eax, bShadow - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextOutline(unsigned char bOutline) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextOutline; - _asm - { - movzx eax, bOutline - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::ResetSlantedTextPos(float fOne, float fTwo) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__ResetSlantedTextPos; - _asm - { - mov eax, fTwo - push eax - mov eax, fOne - push eax - call dwFunc - add esp, 8 - } -} - -void CFont::SetTextSlanted(float fAngle) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextSlanted; - _asm - { - mov eax, fAngle - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetCentreSize(float fUnk) -{ - DWORD dwFunc = (DWORD)0x7194E0; - _asm - { - mov eax, fUnk - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextWrapX(float fWrap) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextWrapX; - _asm - { - mov eax, fWrap - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextJustify(bool bJustify) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextJustify; - _asm - { - movzx eax, bJustify - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextUseProportionalValues(bool bUseProportionalValues) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextUseProportionalValues; - _asm - { - movzx eax, bUseProportionalValues - push eax - call dwFunc - add esp, 4 - } -} - -void CFont::SetTextBackground(unsigned char bUseBackground, unsigned char bBackgroundType) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextBackground; - _asm - { - movzx eax, bBackgroundType - push eax - movzx eax, bUseBackground - push eax - call dwFunc - add esp, 8 - } -} - -void CFont::SetTextAlignment(unsigned char bAlign) -{ - DWORD dwFunc = (DWORD)FUNC_CFont__SetTextAlignment; - _asm - { - movzx eax, bAlign - push eax - call dwFunc - add esp, 4 - } -} - -WRAPPER void CFont::PrintString(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A700); } -WRAPPER void CFont::PrintStringFromBottom(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A820); } - void CFont::Initialise() { CPNGArchive FontsSPTA("models\\fonts.spta"); diff --git a/VCS PC/CFont.h b/VCS PC/Font.h similarity index 57% rename from VCS PC/CFont.h rename to VCS PC/Font.h index 8691bd1..5ebbf01 100644 --- a/VCS PC/CFont.h +++ b/VCS PC/Font.h @@ -1,18 +1,5 @@ -#ifndef __CFONT -#define __CFONT - -#define FUNC_CFont__ResetSlantedTextPos 0x719400 -#define FUNC_CFont__SetTextSlanted 0x719420 -#define FUNC_CFont__SetTextColour 0x719430 -#define FUNC_CFont__SetFontStyle 0x719490 -#define FUNC_CFont__SetTextWrapX 0x7194F0 -#define FUNC_CFont__SetTextBorderRGBA 0x719510 -#define FUNC_CFont__SetTextShadow 0x719570 -#define FUNC_CFont__SetTextOutline 0x719590 -#define FUNC_CFont__SetTextUseProportionalValues 0x7195B0 -#define FUNC_CFont__SetTextBackground 0x7195C0 -#define FUNC_CFont__SetTextJustify 0x719600 -#define FUNC_CFont__SetTextAlignment 0x719610 +#ifndef __FONT +#define __FONT enum // Align { @@ -88,19 +75,19 @@ class CFont static void SetScale(float scaleX, float scaleY); static void SetScaleLang(float scaleX, float scaleY); static void SetFontStyle(unsigned char bFont); - static void SetColor(CRGBA colour); - static void SetTextBorderRGBA(CRGBA colour); - static void SetTextShadow(unsigned char bShadow); - static void SetTextOutline(unsigned char bOutline); - static void ResetSlantedTextPos(float fOne, float fTwo); - static void SetTextSlanted(float fAngle); - static void SetCentreSize(float fUnk); - static void SetTextWrapX(float fWrap); - static void SetTextJustify(bool bJustify); + static void SetColor(CRGBA color); + static void SetDropColor(CRGBA color); + static void SetDropShadowPosition(signed char bShadow); + static void SetEdge(signed char bEdge); + static void SetSlantRefPoint(float fOne, float fTwo); + static void SetSlant(float fAngle); + static void SetCentreSize(float fSize); + static void SetRightJustifyWrap(float fWrap); + static void SetJustify(bool bJustify); static void RenderFontBuffer(); - static void SetTextUseProportionalValues(bool bUseProportionalValues); - static void SetTextBackground(unsigned char bUseBackground, unsigned char bBackgroundType); - static void SetTextAlignment(unsigned char bAlign); + static void SetProportional(bool bProportional); + static void SetBackground(unsigned char bUseBackground, unsigned char bBackgroundType); + static void SetOrientation(unsigned char bOrientation); static void PrintString(float posX, float posY, const char* pText); static void PrintStringFromBottom(float posX, float posY, const char* pText); static void SetWrapx(float fWrap); diff --git a/VCS PC/Frontend.cpp b/VCS PC/Frontend.cpp index f87d47a..9e9125f 100644 --- a/VCS PC/Frontend.cpp +++ b/VCS PC/Frontend.cpp @@ -225,6 +225,7 @@ MenuItem CMenuManager::ms_pMenus[] = { 37, "FEL_ENG", ACTION_STANDARD, 28, 0, -72, 3, 0, 0, //38, "FEL_SPA", ACTION_STANDARD, 28, 0, 0, 3, 0, 0, 38, "FEL_POL", ACTION_STANDARD, 28, 0, 0, 3, 0, 0, + 39, "FEL_HUN", ACTION_STANDARD, 28, 0, 0, 3, 0, 0, 2, "FEDS_TB", ACTION_STANDARD, 4, 0, 0, 3, 0, 0 }, @@ -352,16 +353,23 @@ MenuItem CMenuManager::ms_pMenus[] = { { "FEH_DLC", 33, 4, 1, "FEE_RES", ACTION_NONE, 0, 0, 0, 0, 0, 0, 5, "FEM_OK", ACTION_STANDARD, 33, 0, 16, 3, 0, 0 }, + + // Downloadable Content - DLC installation prompt + { "FEH_DLC", 45, 2, + 1, "FEE_IXX", ACTION_NONE, 0, 0, 0, 0, 0, 0, + 5, "FEM_NO", ACTION_STANDARD, 45, 0, -9, 3, 0, 0, + 57, "FEM_YES", ACTION_STANDARD, 44, 0, 16, 3, 0, 0 }, }; static inline const char* GetTitlePCByLanguage() { - static const char* const cTitlePCNames[] = { "title_pc_EN", /*"title_pc_ES",*/ "title_pc_PL" }; + static const char* const cTitlePCNames[] = { "title_pc_EN", /*"title_pc_ES",*/ "title_pc_PL", "title_pc_EN" }; return cTitlePCNames[FrontEndMenuManager.GetLanguage()]; } WRAPPER void CMenuManager::ShowFullscreenMessage(const char* pMessage, bool bUnk1, bool bUnk2) { WRAPARG(pMessage); WRAPARG(bUnk1); WRAPARG(bUnk2); EAXJMP(0x579330); } +WRAPPER void CMenuManager::SwitchToNewScreen(signed char bScreen) { WRAPARG(bScreen); EAXJMP(0x573680); } void CMenuManager::DrawBackEnd() { @@ -387,13 +395,13 @@ void CMenuManager::DrawBackEnd() CUpdateManager::ReportUpdaterScreenSeen(); // Wrong place } - CFont::SetTextBackground(0, 0); - CFont::SetTextUseProportionalValues(false); + CFont::SetBackground(0, 0); + CFont::SetProportional(false); CFont::SetFontStyle(FONT_PagerFont); - CFont::SetTextAlignment(ALIGN_Right); - CFont::SetTextWrapX(0.0); - CFont::SetTextOutline(1); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); + CFont::SetOrientation(ALIGN_Right); + CFont::SetRightJustifyWrap(0.0); + CFont::SetEdge(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetScale(_width(0.25f), _height(0.4f)); CFont::SetColor(BaseColors[11]); CFont::PrintString(_x(2.5f), _ydown(13.0f), MOD_VERSION" BUILD "BUILDNUMBER_STR); @@ -423,30 +431,30 @@ void CMenuManager::DrawBackEnd() { textures[16].Draw(CRect(_x(135.0f), _y(122.5f), _x(15.0f), _y(2.5f)), CRGBA(255, 255, 255, 255)); - CFont::SetTextUseProportionalValues(true); + CFont::SetProportional(true); CFont::SetScale(_width(0.8f), _height(1.2f)); CFont::SetFontStyle(FONT_RageItalic); - //CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); - //CFont::SetTextOutline(1); - CFont::SetTextAlignment(ALIGN_Center); + //CFont::SetDropColor(CRGBA(0, 0, 0, 255)); + //CFont::SetEdge(1); + CFont::SetOrientation(ALIGN_Center); CFont::SetColor(CRGBA(MODDB_RED_R, MODDB_RED_G, MODDB_RED_B, 255)); - CFont::PrintString(_x(75.0f), _y(115.0f), TheText.GetText("FEP_MOD")); + CFont::PrintString(_x(75.0f), _y(115.0f), TheText.Get("FEP_MOD")); - CFont::SetTextUseProportionalValues(false); + CFont::SetProportional(false); CFont::SetFontStyle(FONT_PagerFont); CFont::SetScale(_width(0.375f), _height(0.725f)); if ( nDaysTillDeadline >= 3 ) CFont::SetColor(CRGBA(255, 255, 255, 255)); - CMessages::InsertNumberInString(TheText.GetText(nDaysTillDeadline == 1 ? "FEP_DY2" : "FEP_DYZ"), nDaysTillDeadline, -1, -1, -1, -1, -1, gString); + CMessages::InsertNumberInString(TheText.Get(nDaysTillDeadline == 1 ? "FEP_DY2" : "FEP_DYZ"), nDaysTillDeadline, -1, -1, -1, -1, -1, gString); CFont::PrintString(_x(75.0f), _y(140.0f), gString); } } #endif - CFont::SetTextUseProportionalValues(true); - CFont::SetTextOutline(0); + CFont::SetProportional(true); + CFont::SetEdge(0); } void CMenuManager::DrawRadioStationIcons() @@ -497,7 +505,7 @@ void CMenuManager::DrawRadioStationIcons() while ( bLoopCounter < 11 ); } -int CMenuManager::DrawSliders(float posX, float posY, float, float height, float distBetweenRects, float filledAmount, int iWidth) +int CMenuManager::DisplaySlider(float posX, float posY, float, float height, float distBetweenRects, float filledAmount, int iWidth) { BYTE loopCounter = NUM_SLIDERS * 2; BYTE positionCounter = 0; @@ -568,7 +576,7 @@ void CMenuManager::DrawLeftColumn(MenuItem::MenuEntry& pPosition, const char* pT CFont::PrintString(fPosX + _xleft(25.0f), fPosY, pText); - CFont::SetTextAlignment(ALIGN_Right); + CFont::SetOrientation(ALIGN_Right); CFont::PrintString(fPosX, fPosY, cSlotNumberText); } else @@ -679,15 +687,15 @@ void CMenuManager::PrintStats() DWORD dwStatsToShow = CStats::ConstructStatLine(99999, nIndents); CFont::SetFontStyle(FONT_Eurostile); - CFont::SetTextOutline(1); + CFont::SetEdge(1); // Criminal Rating CFont::SetScale(_width(0.425f), _height(0.85f)); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); - CFont::SetTextAlignment(ALIGN_Left); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); + CFont::SetOrientation(ALIGN_Left); CFont::SetColor(CRGBA(MENU_INACTIVE_R, MENU_INACTIVE_G, MENU_INACTIVE_B, 255)); - CFont::PrintString(_xleft(50.0f), _y(85.0f), TheText.GetText("CRIMRA")); - CFont::SetTextAlignment(ALIGN_Right); + CFont::PrintString(_xleft(50.0f), _y(85.0f), TheText.Get("CRIMRA")); + CFont::SetOrientation(ALIGN_Right); CFont::PrintString(_x(50.0f), _y(85.0f), CStats::FindCriminalRatingNumber()); CFont::SetScale(_width(0.3f), _height(0.7f)); @@ -717,11 +725,11 @@ void CMenuManager::PrintStats() CStats::ConstructStatLine(dwLoopCounter, nIndents); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, static_cast(fTextAlpha))); - CFont::SetTextAlignment(ALIGN_Left); + CFont::SetDropColor(CRGBA(0, 0, 0, static_cast(fTextAlpha))); + CFont::SetOrientation(ALIGN_Left); CFont::SetColor(CRGBA(255, 255, 255, static_cast(fTextAlpha))); CFont::PrintString(_xleft(50.0f + (nIndents * 3.0f)), fStartingPos, gString); - CFont::SetTextAlignment(ALIGN_Right); + CFont::SetOrientation(ALIGN_Right); CFont::PrintString(_x(50.0f), fStartingPos, gUString); } ++dwLoopCounter; @@ -732,17 +740,17 @@ void CMenuManager::PrintUpdaterScreen() { CFont::SetScale(_width(0.8f), _height(1.2f)); CFont::SetFontStyle(FONT_RageItalic); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); - CFont::SetTextOutline(1); - CFont::SetTextAlignment(ALIGN_Center); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); + CFont::SetEdge(1); + CFont::SetOrientation(ALIGN_Center); CFont::SetColor(CRGBA(MENU_INACTIVE_R, MENU_INACTIVE_G, MENU_INACTIVE_B, 255)); - CFont::PrintString(_x(137.5f), _y(15.0f), TheText.GetText("FEU_POW")); + CFont::PrintString(_x(137.5f), _y(15.0f), TheText.Get("FEU_POW")); CFont::SetFontStyle(FONT_Eurostile); CFont::SetScale(_width(0.3f), _height(0.7f)); CFont::SetColor(CRGBA(255, 255, 255, 255)); - CFont::SetTextAlignment(ALIGN_Left); + CFont::SetOrientation(ALIGN_Left); float fStartingPos = _height(100.0f); @@ -774,10 +782,10 @@ void CMenuManager::PrintUpdaterScreen() CFont::SetScale(_width(0.35f), _height(0.7f)); CFont::SetFontStyle(FONT_PagerFont); - CFont::SetTextAlignment(ALIGN_Center); + CFont::SetOrientation(ALIGN_Center); if ( CUpdateManager::IsDownloading() ) { - CMessages::InsertNumberInString(TheText.GetText("FEU_PRC"), static_cast(dDownloadPercentage), -1, -1, -1, -1, -1, gString); + CMessages::InsertNumberInString(TheText.Get("FEU_PRC"), static_cast(dDownloadPercentage), -1, -1, -1, -1, -1, gString); CFont::PrintString(static_cast(RsGlobal.MaximumWidth / 2), _ydown(105.0f), gString); } @@ -788,6 +796,9 @@ void CMenuManager::PrintDLCScreen() if ( currentMenuEntry > 1 ) { m_nFocusedDLC = CDLCManager::GetActiveDLCWithIndex(currentMenuEntry-2); + + bool bThisDLCIsEnabled = CDLCManager::GetDLC(static_cast(m_nFocusedDLC))->IsActive(); + bool bThisDLCIsInstalled = CDLCManager::GetDLC(static_cast(m_nFocusedDLC))->IsInstalled(); if ( m_nLastFocusedDLC != m_nFocusedDLC ) { m_nLastFocusedDLC = m_nFocusedDLC; @@ -798,11 +809,10 @@ void CMenuManager::PrintDLCScreen() _snprintf(cVideoPath, sizeof(cVideoPath), "movies\\dlc%d.bik", m_nFocusedDLC); CVideoPlayer::Release(); - CVideoPlayer::Create(cVideoPath, &videoFrame, false); + CVideoPlayer::Create(cVideoPath, &videoFrame, false, !bThisDLCIsInstalled); } char cGXTName[8]; - bool bThisDLCIsEnabled = CDLCManager::GetDLC(static_cast(m_nFocusedDLC))->IsActive(); _snprintf(cGXTName, sizeof(cGXTName), "FEE_D%02d", m_nFocusedDLC); CSprite2d::DrawRect(CRect(_x(251.5f), _ymiddle(195.5f), _x(26.5f), _ymiddle(-66.5f)), CRGBA(0, 0, 0, 255)); @@ -811,19 +821,24 @@ void CMenuManager::PrintDLCScreen() CFont::SetWrapx(_x(30.0f)); CFont::SetColor(CRGBA(255, 255, 255, 255)); - CFont::SetTextShadow(1); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); + CFont::SetDropShadowPosition(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetScale(_width(0.35f), _height(0.7f)); CFont::SetFontStyle(FONT_PagerFont); - CFont::SetTextJustify(true); - CFont::PrintString(_x(249.0f), _ymiddle(142.5f), TheText.GetText(cGXTName)); + CFont::SetJustify(true); + CFont::PrintString(_x(249.0f), _ymiddle(142.5f), TheText.Get(cGXTName)); - if ( bThisDLCIsEnabled ) - CFont::SetColor(CRGBA(MENU_UPDATES_R, MENU_UPDATES_G, MENU_UPDATES_B, 255)); + if ( !bThisDLCIsInstalled ) + CFont::SetColor(CRGBA(MENU_RED_R, MENU_RED_G, MENU_RED_B, 255)); + else + { + if ( bThisDLCIsEnabled ) + CFont::SetColor(CRGBA(MENU_UPDATES_R, MENU_UPDATES_G, MENU_UPDATES_B, 255)); + } CFont::SetScale(_width(0.6f), _height(1.1f)); - CFont::SetTextJustify(false); - CFont::SetTextAlignment(ALIGN_Center); - CFont::PrintString(_x(140.0f), _ymiddle(-87.5f), TheText.GetText(bThisDLCIsEnabled ? "FEE_ON" : "FEE_OFF")); + CFont::SetJustify(false); + CFont::SetOrientation(ALIGN_Center); + CFont::PrintString(_x(140.0f), _ymiddle(-87.5f), TheText.Get(bThisDLCIsInstalled ? (bThisDLCIsEnabled ? "FEE_ON" : "FEE_OFF") : "FEE_ABS")); } else { @@ -895,7 +910,7 @@ void CMenuManager::ReadFrontendTextures() DLCArchive.CloseArchive(); } -void CMenuManager::SwitchToNewScreen(signed char bScreen) +void CMenuManager::SwitchToNewScreenVCS(signed char bScreen) { if ( !bScreen ) m_fStatsScrollPos = -120.0f; @@ -943,6 +958,18 @@ void CMenuManager::SwitchToNewScreen(signed char bScreen) // Focus on DLC entry when exiting from any DLC-oriented screen if ( bLastScreen == 46 || bLastScreen == 47 ) currentMenuEntry = 4; + + // Automatically check for updates and mark focused DLC for installation + if ( bScreen == 44 && bLastScreen == 48 ) + { + CUpdateManager::SetDLCStatus(CDLCManager::GetDLC(m_nFocusedDLC)->GetName(), true); + CUpdateManager::ForceUpdate(); + } + + // Correct the first entry + if ( bScreen == 48 ) + _snprintf(MenuEntriesList[48].entryList[0].entry, sizeof(MenuEntriesList->entryList->entry), "FEE_I%02d", m_nFocusedDLC); + } const char* CMenuManager::ProcessDLCSlot(int nSlotID) @@ -1090,12 +1117,12 @@ float CMenuManager::GetTextYPosNextItem(const MenuItem::MenuEntry& pPosition) fprintf(hFile, "GRAND THEFT AUTO VICE CITY STORIES "); wcstombs(multiByteBuf, L"Śtątystykię!", 512); // fputs(, hFile); - fprintf(hFile, "%s

------------------------------------------------------------------- \n"); fprintf(hFile, "   \n"); fprintf(hFile, " \n"); -// fwprintf(hFile, L"

%s: \n", CStats::SACharsToASCII(TheText.GetText("FES_DAT"), 0)); -// fwprintf(hFile, L"%s
%s:
", dateBuf, CStats::SACharsToASCII(TheText.GetText("FES_CMI"), 0)); +// fwprintf(hFile, L"

%s: \n", CStats::SACharsToASCII(TheText.Get("FES_DAT"), 0)); +// fwprintf(hFile, L"%s
%s:
", dateBuf, CStats::SACharsToASCII(TheText.Get("FES_CMI"), 0)); fclose(hFile); @@ -1195,7 +1222,7 @@ void LoadingScreen() LoadingSprites[CurrentLoadingSprite].Draw(CRect(-5.0f, RsGlobal.MaximumHeight + 5.0f, RsGlobal.MaximumWidth + 5.0f, -5.0f), CRGBA(255, 255, 255, 255)); } } - + if ( *(bool*)0xBAB31E || *(bool*)0xBAB31F ) CSprite2d::DrawRect(CRect(-5.0f, RsGlobal.MaximumHeight + 5.0f, RsGlobal.MaximumWidth + 5.0f, -5.0f), CRGBA(0, 0, 0, *(bool*)0xBAB31E ? 255 - *(unsigned char*)0xBAB320 : *(unsigned char*)0xBAB320)); else diff --git a/VCS PC/Frontend.h b/VCS PC/Frontend.h index e1494fe..e094cba 100644 --- a/VCS PC/Frontend.h +++ b/VCS PC/Frontend.h @@ -9,7 +9,7 @@ #define MENU_SLIDER_POSY 135.0f -#define NUM_MENUS 46 // Relevant for debugging only +#define NUM_MENUS 47 // Relevant for debugging only #define NUM_ENTRIES_PER_MENU 14 #define NUM_SLIDERS 8 @@ -50,6 +50,10 @@ #define MODDB_RED_G 0x34 #define MODDB_RED_B 0x34 +#define MENU_RED_R 0xFF +#define MENU_RED_G 0x48 +#define MENU_RED_B 0x4D + #define MAX_AA 8 #define SET_FILE_VERSION 7 @@ -161,7 +165,7 @@ class CMenuManager static MenuItem ms_pMenus[]; public: - BYTE GetHudMode() + BYTE GetHudMode() { return hudMode; }; BYTE GetLanguage() @@ -176,14 +180,15 @@ class CMenuManager void SetTitleLanguage(DWORD lang) { titleLanguage = lang; }; - void SetTextLanguage(BYTE lang) + void SetKeyboardLayout(BYTE lang) { textLanguage = lang; }; void ShowFullscreenMessage(const char* pMessage, bool bUnk1, bool bUnk2); + void SwitchToNewScreen(signed char bScreen); void DrawBackEnd(); void DrawRadioStationIcons(); - int DrawSliders(float posX, float posY, float, float height, float distBetweenRects, float filledAmount, int width); + int DisplaySlider(float posX, float posY, float, float height, float distBetweenRects, float filledAmount, int width); void DrawLeftColumn(MenuItem::MenuEntry& pPosition, const char* pText, const char* pRightText); //float GetLeftColumnPos_Height(long posY); float GetRightColumnPos(MenuVar& sPosY); @@ -192,7 +197,7 @@ class CMenuManager void PrintUpdaterScreen(); void PrintDLCScreen(); void ReadFrontendTextures(); - void SwitchToNewScreen(signed char bScreen); + void SwitchToNewScreenVCS(signed char bScreen); const char* ProcessDLCSlot(int nSlotID); float GetTextYPos(const MenuItem::MenuEntry& pPosition); diff --git a/VCS PC/Garages.cpp b/VCS PC/Garages.cpp index 3cd8430..9920e2d 100644 --- a/VCS PC/Garages.cpp +++ b/VCS PC/Garages.cpp @@ -7,29 +7,29 @@ void CGarages::PrintMessages() else { CFont::SetScale(_width(0.6f), _height(1.1f)); - CFont::SetTextUseProportionalValues(true); - CFont::SetTextBackground(0, 0); + CFont::SetProportional(true); + CFont::SetBackground(0, 0); CFont::SetCentreSize(_width(500.0f)); - CFont::SetTextAlignment(ALIGN_Center); + CFont::SetOrientation(ALIGN_Center); CFont::SetFontStyle(FONT_Eurostile); CFont::SetColor(CRGBA(BaseColors[3])); - CFont::SetTextOutline(1); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); + CFont::SetEdge(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); char tmpString[552]; if ( garages->MessageNumber2 < 0 ) { if ( garages->MessageNumber1 < 0 ) - CFont::PrintString(static_cast(RsGlobal.MaximumWidth / 2), _y(275.0f), TheText.GetText(garages->MessageIDString)); + CFont::PrintString(static_cast(RsGlobal.MaximumWidth / 2), _y(275.0f), TheText.Get(garages->MessageIDString)); else { - TheText.TextNumberFormat(TheText.GetText(garages->MessageIDString), garages->MessageNumber1, -1, -1, -1, -1, -1, tmpString); + CMessages::InsertNumberInString(TheText.Get(garages->MessageIDString), garages->MessageNumber1, -1, -1, -1, -1, -1, tmpString); CFont::PrintString(static_cast(RsGlobal.MaximumWidth / 2), _y(275.0f), tmpString); } } else { - TheText.TextNumberFormat(TheText.GetText(garages->MessageIDString), garages->MessageNumber1, garages->MessageNumber2, -1, -1, -1, -1, tmpString); + CMessages::InsertNumberInString(TheText.Get(garages->MessageIDString), garages->MessageNumber1, garages->MessageNumber2, -1, -1, -1, -1, tmpString); CFont::PrintString(static_cast(RsGlobal.MaximumWidth / 2), _y(275.0f), tmpString); } } diff --git a/VCS PC/General.cpp b/VCS PC/General.cpp index 7dad2e0..0d08f2a 100644 --- a/VCS PC/General.cpp +++ b/VCS PC/General.cpp @@ -8,6 +8,10 @@ WRAPPER void CEntity::UpdateRW() { EAXJMP(0x446F90); } WRAPPER void CEntity::RegisterReference(CEntity** pAddress) { WRAPARG(pAddress); EAXJMP(0x571B70); } WRAPPER void CEntity::CleanUpOldReference(CEntity** pAddress) { WRAPARG(pAddress); EAXJMP(0x571A00); } +WRAPPER unsigned int CKeyGen::GetUppercaseKey(const char* pEntry) { WRAPARG(pEntry); EAXJMP(0x53CF30); } + +bool& CGame::bMissionPackGame = *(bool*)0xB72910; + /*void CMatrix::UpdateRW() { if ( pMatrix ) @@ -75,4 +79,19 @@ void CMatrix::SetRotateZOnly(float fAngle) matrix.right.x = cos(fAngle); matrix.right.y = sin(fAngle); matrix.right.z = 0.0f; +} + +void CMatrix::SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ) +{ + matrix.right.x = cos(fAngleZ) * cos(fAngleY) - sin(fAngleZ) * sin(fAngleX) * sin(fAngleY); + matrix.right.y = cos(fAngleZ) * sin(fAngleX) * sin(fAngleY) + sin(fAngleZ) * cos(fAngleY); + matrix.right.z = -cos(fAngleX) * sin(fAngleY); + + matrix.up.x = -sin(fAngleZ) * cos(fAngleX); + matrix.up.y = cos(fAngleZ) * cos(fAngleX); + matrix.up.z = sin(fAngleX); + + matrix.at.x = sin(fAngleZ) * sin(fAngleX) * cos(fAngleY) + cos(fAngleZ) * sin(fAngleY); + matrix.at.y = sin(fAngleZ) * sin(fAngleY) - cos(fAngleZ) * sin(fAngleX) * cos(fAngleY); + matrix.at.z = cos(fAngleX) * cos(fAngleY); } \ No newline at end of file diff --git a/VCS PC/General.h b/VCS PC/General.h index adb0db2..80d81cf 100644 --- a/VCS PC/General.h +++ b/VCS PC/General.h @@ -48,7 +48,7 @@ class CVector2D public: float x, y; - CVector2D() + CVector2D() {} CVector2D(float fX, float fY) @@ -68,11 +68,9 @@ class CMatrix : pMatrix(nullptr), haveRwMatrix(FALSE) {} - CMatrix(RwMatrix* rwMatrix, bool bAttach) - : pMatrix(rwMatrix), haveRwMatrix(bAttach) - { - memcpy(&matrix, rwMatrix, sizeof(RwMatrix)); - } + CMatrix(RwMatrix* rwMatrix, bool bAttach=false) + : matrix(*rwMatrix), haveRwMatrix(bAttach), pMatrix(bAttach ? rwMatrix : nullptr) + {} CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos) { @@ -127,6 +125,8 @@ class CMatrix void SetRotateXOnly(float fAngle); void SetRotateYOnly(float fAngle); void SetRotateZOnly(float fAngle); + + void SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ); }; class CSimpleTransform @@ -137,9 +137,9 @@ class CSimpleTransform }; class CRGBA -{ +{ public: - BYTE r, g, b, a; + BYTE r, g, b, a; inline CRGBA() {} @@ -160,10 +160,10 @@ class CRGBA }; class CRect -{ +{ public: float x1, y1; - float x2, y2; + float x2, y2; inline CRect() {} inline CRect(float a, float b, float c, float d) @@ -175,13 +175,15 @@ class CRect class CPlaceable { private: - CSimpleTransform m_transform; - CMatrix* m_pCoords; + CSimpleTransform m_transform; + CMatrix* m_pCoords; public: // Line up the VMTs virtual ~CPlaceable() {} + inline CPlaceable() {} + explicit inline CPlaceable(int dummy) { // Dummy ctor @@ -241,16 +243,16 @@ class NOVMT CEntity : public CPlaceable unsigned long bIsInSafePosition : 1; // is entity in a collision free safe position unsigned long bWasPostponed : 1; // was entity control processing postponed unsigned long bIsVisible : 1; //is the entity visible - + unsigned long bIsBIGBuilding : 1; // Set if this entity is a big building unsigned long bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage - unsigned long bStreamingDontDelete : 1; // Dont let the streaming remove this + unsigned long bStreamingDontDelete : 1; // Dont let the streaming remove this unsigned long bRemoveFromWorld : 1; // remove this entity next time it should be processed unsigned long bHasHitWall : 1; // has collided with a building (changes subsequent collisions) unsigned long bImBeingRendered : 1; // don't delete me because I'm being rendered unsigned long bDrawLast :1; // draw object last unsigned long bDistanceFade :1; // Fade entity because it is far away - + unsigned long bDontCastShadowsOn : 1; // Dont cast shadows on this object unsigned long bOffscreen : 1; // offscreen flag. This can only be trusted when it is set to true unsigned long bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them @@ -259,7 +261,7 @@ class NOVMT CEntity : public CPlaceable unsigned long bHasPreRenderEffects : 1; // Object has a prerender effects attached to it unsigned long bIsTempBuilding : 1; // whether or not the building is temporary (i.e. can be created and deleted more than once) unsigned long bDontUpdateHierarchy : 1; // Don't update the aniamtion hierarchy this frame - + unsigned long bHasRoadsignText : 1; // entity is roadsign and has some 2deffect text stuff to be rendered unsigned long bDisplayedSuperLowLOD : 1; unsigned long bIsProcObject : 1; // set object has been generate by procedural object generator @@ -293,7 +295,7 @@ class NOVMT CEntity : public CPlaceable // Dummy ctor } - inline short& ModelIndex() + inline short& ModelIndex() { return m_nModelIndex; }; inline short GetModelIndex() { return m_nModelIndex; } @@ -312,7 +314,7 @@ class NOVMT CPhysical : public CEntity unsigned int b0x01 : 1; // 64 unsigned int bApplyGravity : 1; unsigned int bDisableFriction : 1; - unsigned int bCollidable : 1; + unsigned int bCollidable : 1; unsigned int b0x10 : 1; unsigned int bDisableMovement : 1; unsigned int b0x40 : 1; @@ -386,6 +388,24 @@ class NOVMT CPhysical : public CEntity : CEntity(0) {} }; +// TODO: Move it away +class CKeyGen +{ +public: + static unsigned int GetUppercaseKey(const char* pEntry); +}; + +// TODO: Move away? +class CGame +{ +private: + static bool& bMissionPackGame; + +public: + static inline bool IsMissionPackGame() + { return bMissionPackGame; } +}; + bool CalcScreenCoors(const CVector& vecIn, CVector* vecOut); void LoadingScreenLoadingFile(const char* pText); diff --git a/VCS PC/Hud.cpp b/VCS PC/Hud.cpp index 0ae70267e181aa79c821cb4a0921fdc8c3ba6981..be2f31d0c9a53806a6615c963d294e3032f7a61b 100644 GIT binary patch delta 4337 zcmb_fdr(x@89x`6RTf-eSuP90vIv-EH3X>v1%w3w(FSBzYg5O7JVa2kY>=8q8!e&73Xd%6`PA1XT1<7-$mT}>?5bFE~h?1!w5WwUIQg)K_TVe^=Z%})1iSd5FV zky%-*2TMlv#(U*xOc2Mz*BLPpPM+TT!}g?E_p5qikQb%I!wlUFr^oHl@w4-9v#0na zXTh-~zv%W2MdN})`4q0>=Mwxv>%W}vSo>$6unv2fRWTdeNdB_2Ev%eX)5;b$n?3V~ zybx!wSnu%s6sLddDF&Je(c5?4o*BOr1;d?Czp0}`3JB508VEC|f6>Zd=zB%<1&jF9 zZiFsE#BTdiSo$;2a#W8sA!>Yl+0c1bfo&qFZb5P^yFq>O%pXdGJy<6V zYBT}S4U`S7ln>49RkFL0rSg3E5q=$73*|gra1r^SiSAaEsh`D&wuEb%9yNiEArWTL z>QN_Jx*}F8uxEY|-fl5rbG#M-w{>{z-WRv6J-#mM8sbr(f3^~$_*c8O~ad!`{F01l=)6UQ%L5-F2Sj~G``@x#${I% zmfqdaS*paY%p#v=O~PcR)(_K0Lf@_BPHM3(RZj0#AzwGx1|J*x-O}1 zi%p=6UMvM{{jET1n!ND@Uc&!x$oju5Jfu~?rUE{*NEImi8hu|3x% zWxG+39_{T8lvjmR40k3;qaC-DIQ^b>&UOlqCe|cf-TxD%Gj9|)*;O*Lwa|8NIVuj8 zyIf_OIUh*zWbE!%x!Ao@oC8~992$P5#%smp(&j_=0%1A4%+2lo;S!evw8%Z^%K>fo zQUaf2&!K;Q)Kjze>yJ{OamVN^>A=Hg$-xBgup!wOAiPK^b^qpyAlPuICkBHnLeYIh z0mo^%(dcmVNGK*Uw9pKQNb6Nn)6vP}$vnArdm1V(_ebFy2l;cYBC?t)ue)&@SfX5m zQPn#idymXTu3n9_U#M`hHx6SxKPC?8)FiVpQYhll(Nf;p4jd2XYjP8vuou!D$6MWm zJr>=)2T*uyFWt#_bSxbi#|vF&GWgoRj@Q$(9wU85{%zgRMi zSq|HA1wNKCcmvlCEJWeJMvilKzy|Y)7dejOgqHZ4(Y;v-!|!gAtP5fK$%+Ur_V1&?3pu|I9G$FPjsjl(bKz3 z8;W}$kVYqD+B|+P?`%6JE|$YoB|`s_1|8>3uAyr>;tPEmT-v09`CJd79pH!qf1(g_ zX(20^H!>B?a^6mKyD@T6O=lH>Mhf@wbBUOKPBx5eh4(M6Cu!=?e#yb5Yr33AT6Va? zCl+Z}d{qUxERSBX`WZeiJtcIOBko$7S3Fc*%YPztZd@xANa$GPT~GG2$fV=t!PPi+ zHC$#t#~quu2UB3G&>(N0vGcvTnEX;JHT?M-XD75APR6A#cKa;C)cvRzIlBi&-B8?p12@&5x2_03A@)Tl{_qS8zgTM=bp3uWc&d{_>~-_=PWD_IFEV9RKL zHsa#D%VkAT`PYS1{d0L2u-#Q5@0JdxzZLovYPnZ~Sccp$-|*A&-$BHYCB!kCb935@ zH<_olkcfCb`1z2ix|ENPsQgEtU!j-y)s)$U=5h@t?r7=PY9UT1>S>}#mcJ$X)e=b5 z54_Z+dU1G}4>8*A{nT$mOz(3}5k$QI&l+MaO5*)Y0TCCjEey)g7#m zis=q2vvq7OmE2N#tEK|mN@J!GIc4*M4D`R(ghTt{_lseI8s;)_|KczquI+o&@+>qA zm(VRg%ju`1m_nqAa0_UqfR)krdcJFvF(`Ca(?0!FIKzkiZwSrQ2?q(&+%A3+>7Y=k75SYeSbM}-wuN~W2q zOf#8I$2Q=Zsne9HVE@n{D&eWIq6mmJnQS6Kok=MbnixAe&d~IaPA1JbJ#Tm4eecm_ z-*);(|Jb+pXRuvK z+(b>{$V$?TWA$V$d_9l^L#!cI=r5>?XuId?v$XBe-1I{h1I?zM9mvMaq zd_9%=)GNe;Tn`~tJLJx$!u%!{=FMfP0%bAI?j=naO9zmqh4`SzmjUxz*i{0>tEh*E zc*zdvu{e^1(Msg$3#@H{YnIG3VY~zpw4nGT0Us8nyGuM&KjoB|I zD%vs`{yxuA`{%&?^PLf`YJ=_#;jB9TWhQ!LEyVY;VHL_P$WXQ}_wxe%3gb3(N;|r9 z57~w;Yr$Vrz!4Zg+=bGAeNPb+A0Hh{qu};c{B{|I%!gbA;!q&fQ&9X)_h4wWk{@$T zTOY1a)W!%?(|QH$o@yO8_VQLGXtz%4!1X5vY8x4F?Yy#52-hq?29W(~BJ6KY1b2Bl zeCIw4-bNGjzNCSfsyI&jx`{Cg8e~r&ZLQ zrHcMo2el_QfcsF&(h-7AFQ5*W<_Oh{L&1}Lj(F0^!kACbIS;f%W1xGR^bu6qS5e88 z9Xzp20awt{kue<;tt8mse@6+<19eC3CTQzu4$Ew=_>ulzt!^L&7Q$f*NCmo7l!yP|+PdSo>^d`yBm>+UM z)o)gg0|cn$4DWre63QH`KXc&HXbSBYv#H=d9S_Z?)9Khjl^F(3Yv9{aCmq8QN^K2P zLPF)L8oW(si&-;F42q>>&($A*_D3<`I_ z*^2wa)v#egL>J^*0z+JujP5%wThh-5ZTSirX9qt5eZv+BRR-K2Zj|*8pNq^nWH)ft ziP(9qXU15{2W<(X=k2tQw}~ZWS3}`sB4~ERQQFTg?4)g;Z^cECZ_r*@;GWC|%ll75 z+;uH1``}GV|Jj91wD)W9$C*NT4gJ>Ci=znNV=UuHiU1b$2c79u-6DxFHq#BwO>==mH64GR`6S`k5iry|i-aIA}B`WscF+%sJ;w|mCAsGfg zwLtfc)fiJ+a8AU5Wuls@W=1*P6KiN+A_v!`U@W=l+=woNwu5}*aBn}RV_p7y7@XA8 z{`h1SZS!)RH^i9j@^6I0H@>0sU4ARP_(=)O{P8*2nDeHX7rOl7t(@m~`Q|TVv}^pY zz?eT6Ot!76jJ8>6!Bm9TYG)OQ2UJL8jFSg3mM{r^=1 z@638`=w7x8Y8f_dJDv&r3r;1zb(Dw7)xet#|569m`Bqt_D!d{D%f3jj2*H|F>755l zL8$$U9iIN8bBWR}A9@CIVe|oe^h>*36-75X!aNM&6Gj9N6!~mmxj(stDtXaWnRJua zFgoylC6-&kzWu0O4_ObUBw#Fm^D2X(ArvUMBY+559$#uqQ2&K<2{8HpH5e=W@Zk;# zI4ivQl_3a558pm~AWU&{j~c86Re0^;A4mC@x>Bq+f^Ti@7-M|P9lGH2Z*Q9e)yV-Y e<3sO_$GYNGxv@g$X1prx*gdsMbF5RXy7O;RGF)*0 diff --git a/VCS PC/Hud.h b/VCS PC/Hud.h index ee845b4..f0a160f 100644 --- a/VCS PC/Hud.h +++ b/VCS PC/Hud.h @@ -34,73 +34,42 @@ class CHud friend void Main_Patches(); private: - bool bShouldFPSBeDisplayed : 1; - bool bLCSPS2Style : 1; - bool bShouldGridrefBeDisplayed : 1; -// bool bDrawDevLogos : 1; - - int CarNameStage; - char* pCarNameToDisplay; - char* pLastCarName; - char* pCarName; - int CarNameShowingTime; - int CarNameFadingTime; - - int m_ZoneState; - int m_ZoneFadeTimer; - int m_ZoneNameTimer; - char* m_pZoneName; - char* m_pLastZoneName; - char* m_ZoneToPrint; - - float BigMessage2Alpha; - float BigMessage3Alpha; - - static int& m_HelpMessageState; + static bool bShouldFPSBeDisplayed; + static bool bLCSPS2Style; + + static int CarNameStage; + static const char* pCarNameToDisplay; + static const char* pLastCarName; + static const char* pCarName; + static int CarNameShowingTime; + static int CarNameFadingTime; + + static int m_ZoneState; + static int m_ZoneFadeTimer; + static int m_ZoneNameTimer; + static const char* m_pZoneName; + static const char* m_pLastZoneName; + static const char* m_ZoneToPrint; + + static float BigMessage2Alpha; + static float BigMessage3Alpha; + + static int& m_HelpMessageState; static char m_PagerMessage[16]; //float BigMessage3PosY; static CSprite2d* const Sprites; +private: + static void PrintHealthForPlayer(int playerID, float posX, float posY); + static void PrintArmourForPlayer(int playerID, float posX, float posY); + static void PrintBreathForPlayer(int playerID, float posX, float posY); + static void DrawWeaponAmmo(CPed* ped, float fX, float fY); + public: - /*CHud() - { - bShouldFPSBeDisplayed = false; - bLCSPS2Style = false; - bShouldGridrefBeDisplayed = false; - bDrawDevLogos = false; - CarNameStage = 0; - pCarNameToDisplay = NULL; - pLastCarName = NULL; - pCarName = NULL; - CarNameShowingTime = 0; - CarNameFadingTime = 0; - - m_ZoneState = 0; - m_ZoneFadeTimer = 0; - m_ZoneNameTimer = 0; - m_pZoneName = NULL; - m_pLastZoneName = NULL; - m_ZoneToPrint = NULL; - };*/ - - bool ShouldDisplayFPS() - { return bShouldFPSBeDisplayed; }; - bool IsStyleLCS() - { return bLCSPS2Style; } - bool ShouldDisplayGridref() - { return bShouldGridrefBeDisplayed; }; - /*bool ShouldLogosBeDrawn() - { return bDrawDevLogos; };*/ - void SetFPSDisplay(bool a) - { bShouldFPSBeDisplayed = a; }; - void SetGridrefDisplay(bool a) - { bShouldGridrefBeDisplayed = a; }; - void SetStyleDisplay(bool a) - { bLCSPS2Style = a; }; - /*void SetDevLogosDisplay(bool a) - { bDrawDevLogos = a; };*/ + static inline void SetFPSDisplay(bool a) + { bShouldFPSBeDisplayed = a; };; static void DrawBarChart(float fX, float fY, WORD wWidth, WORD wHeight, float fPercentage, BYTE drawBlueLine, BYTE drawPercentage, BYTE drawBorder, CRGBA dwColor, CRGBA dwForeColor); static void DrawWeaponIcon(CPed* pPed, int iX, int iY, float fAlpha); @@ -108,6 +77,7 @@ class CHud static void GetRidOfAllCustomHUDMessages(); static void Initialise(); static void ReInitialise(); + static void Shutdown(); static void SetVehicleName(char* carName); static void SetZoneName(char* zoneName, bool bIgnoreIntID); static void SetPagerMessage(char* pMsg); @@ -116,10 +86,6 @@ class CHud static void DrawHUD(); static void DrawOnscreenTimer(); static void DrawPermanentTexts(); - static void PrintHealthForPlayer(int playerID, float posX, float posY); - static void PrintArmourForPlayer(int playerID, float posX, float posY); - static void PrintBreathForPlayer(int playerID, float posX, float posY); - static void DrawWeaponAmmo(CPed* ped, float fX, float fY); static void DrawRadioName(void* object, const char* radioName); static void DrawVehicleName(); static void DrawAreaName(); @@ -130,9 +96,7 @@ class CHud static void DrawBigMessage3(); static void DrawBarChartWithRoundBorder(float fX, float fY, WORD wWidth, WORD wHeight, float fPercentage, BYTE drawBlueLine, BYTE drawPercentage, BYTE drawBorder, CRGBA dwColor, CRGBA dwForeColor); static void DrawSquareBar(float fX, float fY, WORD wWidth, WORD wHeight, float fPercentage, BYTE drawBlueLine, BYTE drawShadow, BYTE drawBorder, CRGBA dwColour, CRGBA dwForeColor); - static float GetScreenCoordsForPlayerItem(BYTE plrID, float position, BYTE offset); + static float GetYPosBasedOnHealth(unsigned char plrID, float position, signed char offset); }; -extern CHud hud; - #endif \ No newline at end of file diff --git a/VCS PC/MemoryMgr.h b/VCS PC/MemoryMgr.h index 1c60eb5..a3468a2 100644 --- a/VCS PC/MemoryMgr.h +++ b/VCS PC/MemoryMgr.h @@ -3,6 +3,7 @@ #define WRAPPER __declspec(naked) #define EAXJMP(a) { _asm mov eax, a _asm jmp eax } +#define VARJMP(a) { _asm jmp a } #define WRAPARG(a) UNREFERENCED_PARAMETER(a) #define NOVMT __declspec(novtable) diff --git a/VCS PC/ModelInfo.cpp b/VCS PC/ModelInfo.cpp index d578c65..6269096 100644 --- a/VCS PC/ModelInfo.cpp +++ b/VCS PC/ModelInfo.cpp @@ -1,20 +1,47 @@ #include "StdAfx.h" // Static variables -CBaseModelInfo** CModelInfo::ms_modelInfoPtrs = (CBaseModelInfo**)0xA9B0C8; +CBaseModelInfo** CModelInfo::ms_modelInfoPtrs = (CBaseModelInfo**)0xA9B0C8; -CDynamicStore CModelInfo::ms_pedModelStore; -CDynamicStore CModelInfo::ms_clumpModelStore; +CDynamicStore CModelInfo::ms_pedModelStore; +CDynamicStore CModelInfo::ms_atomicModelStore; +CDynamicStore CModelInfo::ms_damageAtomicModelStore; +CDynamicStore CModelInfo::ms_timeModelStore; -CRGBA CPedModelInfoVCS::ms_pedColourTable[NUM_PED_COLOURS]; -BYTE CPedModelInfoVCS::bLastPedPrimaryColour; -BYTE CPedModelInfoVCS::bLastPedSecondaryColour; -BYTE CPedModelInfoVCS::bLastPedTertiaryColour; -BYTE CPedModelInfoVCS::bLastPedQuaternaryColour; +CRGBA CPedModelInfoVCS::ms_pedColourTable[NUM_PED_COLOURS]; +BYTE CPedModelInfoVCS::bLastPedPrimaryColour; +BYTE CPedModelInfoVCS::bLastPedSecondaryColour; +BYTE CPedModelInfoVCS::bLastPedTertiaryColour; +BYTE CPedModelInfoVCS::bLastPedQuaternaryColour; // Wrappers WRAPPER CBaseModelInfo* CModelInfo::GetModelInfo(const char* pName, int* pOutID) { WRAPARG(pName); WRAPARG(pOutID); EAXJMP(0x4C5940); } +WRAPPER void CBaseModelInfo::Init() { EAXJMP(0x4C4B10); } +WRAPPER void CBaseModelInfo::Shutdown() { EAXJMP(0x4C4D50); } + +WRAPPER void CClumpModelInfo::DeleteRwObject() { EAXJMP(0x4C4E70); } +WRAPPER RpAtomic* CClumpModelInfo::CreateInstance_(RwMatrix* pMatrix) { WRAPARG(pMatrix); EAXJMP(0x4C5110); } +WRAPPER RpAtomic* CClumpModelInfo::CreateInstance() { EAXJMP(0x4C5140); } +WRAPPER void CClumpModelInfo::SetAnimFile(const char* pName) { WRAPARG(pName); EAXJMP(0x4C5200); } +WRAPPER void CClumpModelInfo::ConvertAnimFileIndex() { EAXJMP(0x4C5250); } +WRAPPER void CClumpModelInfo::SetClump(RpClump* pClump) { WRAPARG(pClump); EAXJMP(0x4C4F70); } + +WRAPPER void CAtomicModelInfo::DeleteRwObject() { EAXJMP(0x4C4440); } +WRAPPER RpAtomic* CAtomicModelInfo::CreateInstance_(RwMatrix* pMatrix) { WRAPARG(pMatrix); EAXJMP(0x4C44D0); } +WRAPPER RpAtomic* CAtomicModelInfo::CreateInstance() { EAXJMP(0x4C4530); } +WRAPPER void CAtomicModelInfo::SetAtomic(RpAtomic* pAtomic) { WRAPARG(pAtomic); EAXJMP(0x4C4360); } + +WRAPPER RpAtomic* CDamageAtomicModelInfo::CreateInstance_(RwMatrix* pMatrix) { WRAPARG(pMatrix); EAXJMP(0x4C4910); } +WRAPPER RpAtomic* CDamageAtomicModelInfo::CreateInstance() { EAXJMP(0x4C4960); } + +WRAPPER void CPedModelInfo::SetClump(RpClump* pClump) { WRAPARG(pClump); EAXJMP(0x4C7340); } + +void CColModel::operator delete(void* mem) +{ + CPools::GetColModelPool()->Delete(reinterpret_cast(mem)); +} + bool CModelInfo::IsBikeModel(int modelID) { // Temp @@ -24,20 +51,37 @@ bool CModelInfo::IsBikeModel(int modelID) CPedModelInfoVCS* CModelInfo::AddPedModel(int nModelID) { - CPedModelInfoVCS* pNewEntry = ms_pedModelStore.Add(); + auto pNewEntry = ms_pedModelStore.Add(); + pNewEntry->Init(); + ms_modelInfoPtrs[nModelID] = pNewEntry; + return pNewEntry; +} + +CAtomicModelInfo* CModelInfo::AddAtomicModel(int nModelID) +{ + auto pNewEntry = ms_atomicModelStore.Add(); pNewEntry->Init(); ms_modelInfoPtrs[nModelID] = pNewEntry; return pNewEntry; } -CClumpModelInfo* CModelInfo::AddClumpModel(int nModelID) +CDamageAtomicModelInfo* CModelInfo::AddDamageAtomicModel(int nModelID) { - CClumpModelInfo* pNewEntry = ms_clumpModelStore.Add(); + auto pNewEntry = ms_damageAtomicModelStore.Add(); pNewEntry->Init(); ms_modelInfoPtrs[nModelID] = pNewEntry; return pNewEntry; } +CTimeModelInfo* CModelInfo::AddTimeModel(int nModelID) +{ + auto pNewEntry = ms_timeModelStore.Add(); + pNewEntry->Init(); + ms_modelInfoPtrs[nModelID] = pNewEntry; + return pNewEntry; +} + + void CModelInfo::ShutDown() { // Iterate thru entire stores and call ShutDown() on each entry @@ -53,8 +97,8 @@ void CModelInfo::ShutDown() } { - // Clump model store - auto pEntry = ms_clumpModelStore.GetFirstEntry(); + // Atomic model store + auto pEntry = ms_atomicModelStore.GetFirstEntry(); while ( pEntry ) { @@ -62,6 +106,27 @@ void CModelInfo::ShutDown() pEntry = pEntry->m_pPrev; } } + + { + // Damageatomic model store + auto pEntry = ms_damageAtomicModelStore.GetFirstEntry(); + + while ( pEntry ) + { + pEntry->m_entry.Shutdown(); + pEntry = pEntry->m_pPrev; + } + } +} + +void CBaseModelInfo::SetTexDictionary(const char* pDict) +{ + int nSlot = CTxdStore::FindTxdSlot(pDict); + + if ( nSlot == -1 ) + usTextureDictionary = CTxdStore::AddTxdSlot(pDict); + else + usTextureDictionary = nSlot; } void CBaseModelInfo::AddRef() @@ -70,6 +135,42 @@ void CBaseModelInfo::AddRef() CTxdStore::AddRef(usTextureDictionary); } +void CClumpModelInfo::Init() +{ + CBaseModelInfo::Init(); + nAnimIndex = -1; +} + +void CAtomicModelInfo::Shutdown() +{ + delete pEmpireData; + CBaseModelInfo::Shutdown(); +} + +void CDamageAtomicModelInfo::Init() +{ + CBaseModelInfo::Init(); + pAtomic2 = nullptr; +} + +void CDamageAtomicModelInfo::DeleteRwObject() +{ + if ( pAtomic2 ) + { + RpAtomicDestroy(pAtomic2); + RwFrameDestroy(RpAtomicGetFrame(pAtomic2)); + pAtomic2 = nullptr; + } + CAtomicModelInfo::DeleteRwObject(); +} + +void CPedModelInfo::DeleteRwObject() +{ + CClumpModelInfo::DeleteRwObject(); + delete HitColModel; + HitColModel = nullptr; +} + void CPedModelInfoVCS::LoadPedColours() { if ( FILE* hFile = CFileMgr::OpenFile("DATA\\PEDCOLS.DAT", "r") ) @@ -92,11 +193,8 @@ void CPedModelInfoVCS::LoadPedColours() { if ( SECTION3(pLine, 'c', 'o', 'l') ) curFileSection = SECTION_RGB; - else - { - if ( SECTION3(pLine, 'p', 'e', 'd') ) - curFileSection = SECTION_READPEDCOLS; - } + else if ( SECTION3(pLine, 'p', 'e', 'd') ) + curFileSection = SECTION_READPEDCOLS; break; } @@ -142,7 +240,7 @@ void CPedModelInfoVCS::LoadPedColours() &colours[13][0], &colours[13][1], &colours[13][2], &colours[13][3], &colours[14][0], &colours[14][1], &colours[14][2], &colours[14][3], &colours[15][0], &colours[15][1], &colours[15][2], &colours[15][3]); - CPedModelInfoVCS* modelInfo = static_cast(CModelInfo::GetModelInfo(modelName, nullptr)); + CPedModelInfoVCS* modelInfo = static_cast(CModelInfo::GetModelInfo(modelName)); modelInfo->m_bNumPossibleColours = static_cast(valuesGet - 1) / 4; for ( int i = 0; i < modelInfo->m_bNumPossibleColours; ++i ) { @@ -161,7 +259,7 @@ void CPedModelInfoVCS::LoadPedColours() } } -void CPedModelInfoVCS::AssignColoursToModel(BYTE primaryColour, BYTE secondaryColour, BYTE tertiaryColour, BYTE quaternaryColour) +void CPedModelInfoVCS::SetPedColour(unsigned char primaryColour, unsigned char secondaryColour, unsigned char tertiaryColour, unsigned char quaternaryColour) { bLastPedPrimaryColour = primaryColour; bLastPedSecondaryColour = secondaryColour; @@ -169,21 +267,21 @@ void CPedModelInfoVCS::AssignColoursToModel(BYTE primaryColour, BYTE secondaryCo bLastPedQuaternaryColour = quaternaryColour; } -void CPedModelInfoVCS::SetEnvironmentMap(RpClump* clump) +void CPedModelInfoVCS::SetEditableMaterials(RpClump* pClump) { std::pair* pData = materialRestoreData; - RpClumpForAllAtomics(clump, SetEnvironmentMapCB, &pData); + RpClumpForAllAtomics(pClump, SetEditableMaterialsCB, &pData); pData->first = nullptr; } -RpAtomic* CPedModelInfoVCS::SetEnvironmentMapCB(RpAtomic* pAtomic, void* pData) +RpAtomic* CPedModelInfoVCS::SetEditableMaterialsCB(RpAtomic* pAtomic, void* pData) { if ( RpAtomicGetFlags(pAtomic) & rpATOMICRENDER ) - RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), SetEnvironmentMapCB, pData); + RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), SetEditableMaterialsCB, pData); return pAtomic; } -RpMaterial* CPedModelInfoVCS::SetEnvironmentMapCB(RpMaterial* pMaterial, void* pData) +RpMaterial* CPedModelInfoVCS::SetEditableMaterialsCB(RpMaterial* pMaterial, void* pData) { int colorIndexToUse; diff --git a/VCS PC/ModelInfo.h b/VCS PC/ModelInfo.h index cfe6aee..e18325f 100644 --- a/VCS PC/ModelInfo.h +++ b/VCS PC/ModelInfo.h @@ -4,7 +4,7 @@ // Not used with CDynamicStore-based storages #define NUM_VEHICLE_MODELS 212 #define NUM_PED_MODELS 278 -#define NUM_CLUMP_MODELS 100 +#define NUM_DAMAGEATOMIC_MODELS 100 #define NUM_PED_COLOURS 128 #define NUM_POSSIBLE_COLOURS_FOR_PED 16 @@ -342,6 +342,15 @@ class CColModel BYTE unknownFlags; BYTE pad [ 2 ]; CColData* pColData; + +public: + ~CColModel() + { + // Dirty! + ((void(__thiscall*)(CColModel*))0x40F700)(this); + } + + void operator delete(void* mem); }; class C2dEffect @@ -352,26 +361,25 @@ class C2dEffect DWORD nCount; }; -class NOVMT CBaseModelInfo +class CTimeInfo +{ +public: + unsigned char bTimeOn, bTimeOff; + signed short nPairedModel; + +public: + CTimeInfo(signed short nModel) + : nPairedModel(nModel) + {} +}; + +class CAtomicModelInfo; +class CDamageAtomicModelInfo; +class CLodAtomicModelInfo; + +class CBaseModelInfo { public: - virtual ~CBaseModelInfo() { }; - virtual void* AsAtomicModelInfoPtr(); - virtual void* AsDamageAtomicModelInfoPtr(); - virtual void* AsLodAtomicModelInfoPtr(); - virtual unsigned char GetModelType(); - virtual void* GetTimeInfo(); - virtual void Init(); - virtual void Shutdown(); - virtual void DeleteRwObject(); - virtual void GetRwModelType(); - virtual RpAtomic* CreateInstance_(RwMatrix* pMatrix); - virtual RpAtomic* CreateInstance(); - virtual void SetAnimFile(const char* pName); - virtual void ConvertAnimFileIndex(); - virtual int GetAnimFileIndex(); - -protected: unsigned int ulHashKey; // +4 Generated by CKeyGen::GetUppercaseKey(char const *) called by CBaseModelInfo::SetModelName(char const *) unsigned short usNumberOfRefs: 16; // +8 short usTextureDictionary: 16; // +10 @@ -414,49 +422,115 @@ class NOVMT CBaseModelInfo RwObject* pRwObject; // +28 public: + virtual ~CBaseModelInfo() {} + virtual CAtomicModelInfo* AsAtomicModelInfoPtr() { return nullptr; } + virtual CDamageAtomicModelInfo* AsDamageAtomicModelInfoPtr() { return nullptr; } + virtual CLodAtomicModelInfo* AsLodAtomicModelInfoPtr() { return nullptr; } + virtual unsigned char GetModelType()=0; + virtual CTimeInfo* GetTimeInfo() { return nullptr; } + virtual void Init(); + virtual void Shutdown(); + virtual void DeleteRwObject()=0; + virtual int GetRwModelType()=0; + virtual RpAtomic* CreateInstance_(RwMatrix* pMatrix)=0; + virtual RpAtomic* CreateInstance()=0; + virtual void SetAnimFile(const char* pName) { UNREFERENCED_PARAMETER(pName); } + virtual void ConvertAnimFileIndex() {} + virtual int GetAnimFileIndex() { return -1; } + CBaseModelInfo() : usNumberOfRefs(0), usTextureDictionary(-1) - { - SETVMT(0x85BB9C); - } + {} inline CColModel* GetColModel() { return pColModel; } inline unsigned int GetHash() { return ulHashKey; } inline short GetTextureDict() { return usTextureDictionary; } + void SetTexDictionary(const char* pDict); void AddRef(); }; -class NOVMT CClumpModelInfo : public CBaseModelInfo +class CClumpModelInfo : public CBaseModelInfo +{ +public: + int nAnimIndex; + +public: + virtual unsigned char GetModelType() override { return 5; } + virtual void Init() override; + virtual void DeleteRwObject() override; + virtual int GetRwModelType() override { return rpCLUMP; } + virtual RpAtomic* CreateInstance_(RwMatrix* pMatrix) override; + virtual RpAtomic* CreateInstance() override; + virtual void SetAnimFile(const char* pName) override; + virtual void ConvertAnimFileIndex() override; + virtual int GetAnimFileIndex() override { return nAnimIndex; } + virtual CColModel* GetBoundingBox() { return pColModel; } + virtual void SetClump(RpClump* pClump); +}; + +class CAtomicModelInfo : public CBaseModelInfo +{ +private: + // VCS PC class extension (NONSTATIC) + CEmpireBuildingData* pEmpireData; + +public: + virtual CAtomicModelInfo* AsAtomicModelInfoPtr() override { return this; } + virtual unsigned char GetModelType() override { return 1; } + virtual void Shutdown() override; + virtual void DeleteRwObject() override; + virtual int GetRwModelType() override { return rpATOMIC; } + virtual RpAtomic* CreateInstance_(RwMatrix* pMatrix) override; + virtual RpAtomic* CreateInstance() override; + virtual void SetAtomic(RpAtomic* pAtomic); + + inline void InitEmpireData() + { if ( !pEmpireData ) pEmpireData = new CEmpireBuildingData; } + inline CEmpireBuildingData* GetEmpireData() + { return pEmpireData; } + + CAtomicModelInfo() + : pEmpireData(nullptr) + {} +}; + +class CDamageAtomicModelInfo : public CAtomicModelInfo { -protected: +public: RpAtomic* pAtomic2; public: - CClumpModelInfo() - { - SETVMT(0x85BC30); - } + virtual CDamageAtomicModelInfo* AsDamageAtomicModelInfoPtr() override { return this; } + virtual void Init() override; + virtual void DeleteRwObject() override; + virtual RpAtomic* CreateInstance_(RwMatrix* pMatrix) override; + virtual RpAtomic* CreateInstance() override; }; -class NOVMT CSimpleModelInfo : public CBaseModelInfo +class CTimeModelInfo : public CAtomicModelInfo { +private: + CTimeInfo timeInfo; + public: - CSimpleModelInfo() - { - SETVMT(0x85BBF0); - } + virtual unsigned char GetModelType() override { return 3; } + virtual CTimeInfo* GetTimeInfo() override { return &timeInfo; } + + CTimeModelInfo() + : timeInfo(-1) + {} }; -class NOVMT CPedModelInfo : public CClumpModelInfo +class CPedModelInfo : public CClumpModelInfo { -protected: +public: DWORD MotionAnimGroup; DWORD DefPedType; DWORD DefPedStats; WORD CanDriveCars; WORD PedFlags; - void* HitColModel; + CColModel* HitColModel; BYTE FirstRadioStation; BYTE SecondRadioStation; BYTE Race; @@ -466,37 +540,39 @@ class NOVMT CPedModelInfo : public CClumpModelInfo WORD NextVoice; public: + virtual unsigned char GetModelType() override { return 7; } + virtual void DeleteRwObject() override; + virtual void SetClump(RpClump* pClump) override; + CPedModelInfo() : HitColModel(nullptr) - { - SETVMT(0x85BDC0); - } + {} virtual ~CPedModelInfo() { - // TODO: Reverse + delete HitColModel; } }; -class NOVMT CPedModelInfoVCS : public CPedModelInfo // VCS PC class extension +class CPedModelInfoVCS : public CPedModelInfo // VCS PC class extension { -protected: - BYTE m_primaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; - BYTE m_secondaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; - BYTE m_tertiaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; - BYTE m_quaternaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; - BYTE m_bNumPossibleColours; - BYTE m_bLastColourChoice; +public: + unsigned char m_primaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; + unsigned char m_secondaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; + unsigned char m_tertiaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; + unsigned char m_quaternaryPedColours[NUM_POSSIBLE_COLOURS_FOR_PED]; + unsigned char m_bNumPossibleColours; + unsigned char m_bLastColourChoice; static CRGBA ms_pedColourTable[NUM_PED_COLOURS]; - static BYTE bLastPedPrimaryColour, bLastPedSecondaryColour, bLastPedTertiaryColour, bLastPedQuaternaryColour; + static unsigned char bLastPedPrimaryColour, bLastPedSecondaryColour, bLastPedTertiaryColour, bLastPedQuaternaryColour; public: static void LoadPedColours(); - static void AssignColoursToModel(BYTE primaryColour, BYTE secondaryColour, BYTE tertiaryColour, BYTE quaternaryColour); - static void SetEnvironmentMap(RpClump* clump); - static RpAtomic* SetEnvironmentMapCB(RpAtomic* pAtomic, void* pData); - static RpMaterial* SetEnvironmentMapCB(RpMaterial* pMaterial, void* pData); + static void SetPedColour(unsigned char primaryColour, unsigned char secondaryColour, unsigned char tertiaryColour, unsigned char quaternaryColour); + static void SetEditableMaterials(RpClump* pClump); + static RpAtomic* SetEditableMaterialsCB(RpAtomic* pAtomic, void* pData); + static RpMaterial* SetEditableMaterialsCB(RpMaterial* pMaterial, void* pData); void GetRandomPedColour(BYTE& colour1, BYTE& colour2, BYTE& colour3, BYTE& colour4); }; @@ -504,12 +580,6 @@ class NOVMT CPedModelInfoVCS : public CPedModelInfo // VCS PC class extension static_assert(sizeof(CBaseModelInfo) == CBaseModelInfo_ARRAYSIZE, "CBaseModelInfo class has wrong size!"); static_assert(sizeof(CPedModelInfo) == CPedModelInfo_ARRAYSIZE, "CPedModelInfo class has wrong size!"); -struct ModelCarsData -{ - DWORD count; - BYTE objects[CVehicleModelInfo_ARRAYSIZE * NUM_VEHICLE_MODELS]; // CVehicleModelInfo[NUM_VEHICLES] -}; - class CModelInfo { public: @@ -519,16 +589,20 @@ class CModelInfo ModelCarsData* ModelCarsMalloc; #endif static CDynamicStore ms_pedModelStore; - static CDynamicStore ms_clumpModelStore; + static CDynamicStore ms_atomicModelStore; + static CDynamicStore ms_damageAtomicModelStore; + static CDynamicStore ms_timeModelStore; public: - static inline void GetModelInfoUInt16(const char* pName, unsigned short* pOutID) - { int nID; GetModelInfo(pName, &nID); if ( pOutID ) *pOutID = static_cast(nID); } + static inline unsigned short GetModelInfoUInt16(const char* pName) + { int nID; GetModelInfo(pName, &nID); return static_cast(nID); } - static CBaseModelInfo* GetModelInfo(const char* pName, int* pOutID); + static CBaseModelInfo* GetModelInfo(const char* pName, int* pOutID = nullptr); + static CAtomicModelInfo* AddAtomicModel(int nModelID); static bool IsBikeModel(int modelID); static CPedModelInfoVCS* AddPedModel(int nModelID); - static CClumpModelInfo* AddClumpModel(int nModelID); + static CDamageAtomicModelInfo* AddDamageAtomicModel(int nModelID); + static CTimeModelInfo* AddTimeModel(int nModelID); static void ShutDown(); }; diff --git a/VCS PC/PlayerInfo.cpp b/VCS PC/PlayerInfo.cpp index 0dc26ad..5ff742d 100644 --- a/VCS PC/PlayerInfo.cpp +++ b/VCS PC/PlayerInfo.cpp @@ -4,7 +4,7 @@ WRAPPER void CPlayerInfo::KillPlayer() { EAXJMP(0x56E580); } WRAPPER void CPlayerInfo::ArrestPlayer() { EAXJMP(0x56E5D0); } -CWanted* FindPlayerWanted(int nPlayerID) +CWanted* FindPlayerWanted(signed int nPlayerID) { if ( nPlayerID < 0 ) return CWorld::Players[CWorld::PlayerInFocus].GetPlayerData().m_Wanted; diff --git a/VCS PC/PlayerInfo.h b/VCS PC/PlayerInfo.h index fdf29cc..9c95c76 100644 --- a/VCS PC/PlayerInfo.h +++ b/VCS PC/PlayerInfo.h @@ -12,7 +12,7 @@ class CPlayerInfo { private: CPed* pPed; // 0x0 - CPlayerData data; // 0x4 + CPlayerPedData data; // 0x4 CVehicle* pVehicle; // 0xB0 CVehicle* pSpecCar; // 0xB4 DWORD Score; // 0xB8 @@ -75,7 +75,7 @@ class CPlayerInfo public: inline CPed* GetPed() const { return pPed; }; - inline CPlayerData& GetPlayerData() + inline CPlayerPedData& GetPlayerData() { return data; }; inline BYTE GetMaxHealth() const { return MaxHealth; }; @@ -92,7 +92,7 @@ class CPlayerInfo void ArrestPlayer(); }; -CWanted* FindPlayerWanted(int nPlayerID); +CWanted* FindPlayerWanted(signed int nPlayerID); static_assert(sizeof(CPlayerInfo) == CPlayer_ARRAYSIZE, "CPlayerInfo class has wrong size!"); diff --git a/VCS PC/Pools.cpp b/VCS PC/Pools.cpp index 56a6280..f7d9af8 100644 --- a/VCS PC/Pools.cpp +++ b/VCS PC/Pools.cpp @@ -3,4 +3,5 @@ CPedPool*& CPools::ms_pPedPool = *(CPedPool**)0xB74490; CVehiclePool*& CPools::ms_pVehiclePool = *(CVehiclePool**)0xB74494; CBuildingPool*& CPools::ms_pBuildingPool = *(CBuildingPool**)0xB74498; -CDummyPool*& CPools::ms_pDummyPool = *(CDummyPool**)0xB744A0; \ No newline at end of file +CDummyPool*& CPools::ms_pDummyPool = *(CDummyPool**)0xB744A0; +CColModelPool*& CPools::ms_pColModelPool = *(CColModelPool**)0xB744A4; \ No newline at end of file diff --git a/VCS PC/Pools.h b/VCS PC/Pools.h index f3b0f19..bac547d 100644 --- a/VCS PC/Pools.h +++ b/VCS PC/Pools.h @@ -69,6 +69,14 @@ class CPool ++m_pSlotInfos[m_nFirstFree].a.m_uID; return &m_pSlots[m_nFirstFree]; } + + void Delete(CBase* pObject) + { + int nIndex = reinterpret_cast(pObject) - m_pSlots; + m_pSlotInfos[nIndex].a.m_bFree = true; + if ( nIndex < m_nFirstFree ) + m_nFirstFree = nIndex; + } }; template @@ -82,6 +90,7 @@ typedef CPool> CPedPool; typedef CPool> CVehiclePool; typedef CPool CBuildingPool; typedef CPool CDummyPool; +typedef CPool CColModelPool; class CPools { @@ -90,6 +99,7 @@ class CPools static CVehiclePool*& ms_pVehiclePool; static CBuildingPool*& ms_pBuildingPool; static CDummyPool*& ms_pDummyPool; + static CColModelPool*& ms_pColModelPool; public: static inline CPedPool* GetPedPool() @@ -100,6 +110,8 @@ class CPools { return ms_pBuildingPool; } static inline CDummyPool* GetDummyPool() { return ms_pDummyPool; } + static inline CColModelPool* GetColModelPool() + { return ms_pColModelPool; } }; static_assert(sizeof(CPool) == CPool_ARRAYSIZE, "CPool class has wrong size!"); diff --git a/VCS PC/Project2dfx.cpp b/VCS PC/Project2dfx.cpp index ef0828f..fd9d34e 100644 --- a/VCS PC/Project2dfx.cpp +++ b/VCS PC/Project2dfx.cpp @@ -278,18 +278,18 @@ void CProject2dfx::EnumerateLampposts() void CProject2dfx::Init() { - CModelInfo::GetModelInfoUInt16("bouy", &miBouy); - CModelInfo::GetModelInfoUInt16("doublestreetlght1", &miDoublestreetlght1); - CModelInfo::GetModelInfoUInt16("high_lampost", &miHigh_lampost); - CModelInfo::GetModelInfoUInt16("lampost_coast", &miLampost_coast); - CModelInfo::GetModelInfoUInt16("lamppost1", &miLamppost1); - CModelInfo::GetModelInfoUInt16("lamproad3", &miLamproad3); - CModelInfo::GetModelInfoUInt16("mlamppost", &miMlamppost); - CModelInfo::GetModelInfoUInt16("Streetlamp1", &miStreetlamp1); - CModelInfo::GetModelInfoUInt16("bollardlight", &miBollardlight); - CModelInfo::GetModelInfoUInt16("lamppost2", &miLamppost2); - CModelInfo::GetModelInfoUInt16("Streetlamp2", &miStreetlamp2); - CModelInfo::GetModelInfoUInt16("docks_lights", &miDockslights); + miBouy = CModelInfo::GetModelInfoUInt16("bouy"); + miDoublestreetlght1 = CModelInfo::GetModelInfoUInt16("doublestreetlght1"); + miHigh_lampost = CModelInfo::GetModelInfoUInt16("high_lampost"); + miLampost_coast = CModelInfo::GetModelInfoUInt16("lampost_coast"); + miLamppost1 = CModelInfo::GetModelInfoUInt16("lamppost1"); + miLamproad3 = CModelInfo::GetModelInfoUInt16("lamproad3"); + miMlamppost = CModelInfo::GetModelInfoUInt16("mlamppost"); + miStreetlamp1 = CModelInfo::GetModelInfoUInt16("Streetlamp1"); + miBollardlight = CModelInfo::GetModelInfoUInt16("bollardlight"); + miLamppost2 = CModelInfo::GetModelInfoUInt16("lamppost2"); + miStreetlamp2 = CModelInfo::GetModelInfoUInt16("Streetlamp2"); + miDockslights = CModelInfo::GetModelInfoUInt16("docks_lights"); m_pLampposts = new std::vector; @@ -298,8 +298,7 @@ void CProject2dfx::Init() void CProject2dfx::Shutdown() { - if ( m_pLampposts ) - delete m_pLampposts; + delete m_pLampposts; } void CProject2dfx::Render() @@ -307,9 +306,7 @@ void CProject2dfx::Render() if ( CClock::GetIsTimeInRange(20, 7) ) { unsigned char bAlpha; - - // TODO: This is wrong, change asap - unsigned int nTime = clock_struct->GetHour() * 60 + clock_struct->GetMinute(); + unsigned int nTime = CClock::GetHours() * 60 + CClock::GetMinutes(); if ( nTime >= 20 * 60 ) bAlpha = static_cast((5.0f/6.0f)*nTime - 1000.0f); diff --git a/VCS PC/RW.cpp b/VCS PC/RW.cpp index 6206b7a..1ad8b0f 100644 --- a/VCS PC/RW.cpp +++ b/VCS PC/RW.cpp @@ -22,10 +22,23 @@ WRAPPER RwCamera* RwCameraClear(RwCamera* camera, RwRGBA* colour, RwInt32 clearM WRAPPER RwBool RwImageDestroy(RwImage* image) { WRAPARG(image); EAXJMP(0x802740); } WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { WRAPARG(ipImage); WRAPARG(nRasterType); WRAPARG(npWidth); WRAPARG(npHeight); WRAPARG(npDepth); WRAPARG(npFormat); EAXJMP(0x8042C0); } WRAPPER RwImage* RtPNGImageRead(const RwChar* imageName) { WRAPARG(imageName); EAXJMP(0x7CF9B0); } +WRAPPER RwBool RwFrameDestroy(RwFrame* frame) { WRAPARG(frame); EAXJMP(0x7F05A0); } +WRAPPER RwBool RpAtomicDestroy(RpAtomic* atomic) { WRAPARG(atomic); EAXJMP(0x749DC0); } +WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { WRAPARG(frame); WRAPARG(callBack); WRAPARG(data); EAXJMP(0x7F1200); } +WRAPPER RwCamera* RwCameraCreate() { EAXJMP(0x7EE4F0); } +WRAPPER RwFrame* RwFrameCreate() { EAXJMP(0x7F0410); } +WRAPPER RwCamera* RwCameraSetViewWindow(RwCamera* camera, const RwV2d* viewWindow) { WRAPARG(camera); WRAPARG(viewWindow); EAXJMP(0x7EE410); } +WRAPPER RwCamera* RwCameraSetProjection(RwCamera* camera, RwCameraProjection projection) { WRAPARG(camera); WRAPARG(projection); EAXJMP(0x7EE3A0); } +WRAPPER void _rwObjectHasFrameSetFrame(void* object, RwFrame* frame) { WRAPARG(object); WRAPARG(frame); EAXJMP(0x804EF0); } WRAPPER void DoRWStuffEndOfFrame() { EAXJMP(0x53D840); } RwCamera* RwCameraBeginUpdate(RwCamera* camera) { return camera->beginUpdate(camera); +} + +RwCamera* RwCameraEndUpdate(RwCamera* camera) +{ + return camera->endUpdate(camera); } \ No newline at end of file diff --git a/VCS PC/Radar.cpp b/VCS PC/Radar.cpp index 25cd049..7a87e36 100644 --- a/VCS PC/Radar.cpp +++ b/VCS PC/Radar.cpp @@ -3,6 +3,7 @@ CSprite2d* const CRadar::RadarBlipSprites = (CSprite2d*)0xBAA250; WRAPPER void CRadar::ChangeBlipBrightness(int nBlipID, int nBrightness) { WRAPARG(nBlipID); WRAPARG(nBrightness); EAXJMP(0x583C70); } +WRAPPER void CRadar::DrawRadarSection(int nX, int nY) { WRAPARG(nX); WRAPARG(nY); EAXJMP(0x586110); } static const char* const RadarBlipSpriteFilenames[NUM_BLIP_SPRITES] = { "", "", "radar_centre", "arrow", "radar_north", "", "radar_gun", "radar_bomb", @@ -134,4 +135,90 @@ void CRadar::LoadTextures() RadarBlipSprites[i].SetTextureFromSPTA(HudSPTA, RadarBlipSpriteFilenames[i]); HudSPTA.CloseArchive(); +} + +static RwCamera* pRadarCam; + +void CRadar::Draw3DRadar(int nX, int nY) +{ + static bool bCamCreated = false; + + if ( !bCamCreated ) + { + pRadarCam = RwCameraCreate(); + RwCameraSetFrame(pRadarCam, RwFrameCreate()); + RwCameraSetRaster(pRadarCam, RwRasterCreate(512, 512, 0, rwRASTERTYPECAMERATEXTURE)); + RwCameraSetZRaster(pRadarCam, RwRasterCreate(512, 512, 0, rwRASTERTYPEZBUFFER)); + + RwV2d vecViewWindow = { tan(M_PI/3), tan(M_PI/3) }; + + RwCameraSetViewWindow(pRadarCam, &vecViewWindow); + RwCameraSetProjection(pRadarCam, rwPERSPECTIVE); + bCamCreated = true; + + // helper matrix + /*CMatrix matTemp; + matTemp.SetRotateYOnly(-M_PI); + matTemp.SetTranslateOnly(0.0, 0.0, 1.0f); + + memcpy(RwFrameGetMatrix(RwCameraGetFrame(pRadarCam)), &matTemp.matrix, sizeof(RwMatrix));*/ + } + + RwRGBA color = { 255, 255, 255, 255 }; + + RwCameraEndUpdate(Scene); + RwCameraClear(pRadarCam, &color, rwCAMERACLEARIMAGE); + RwCameraBeginUpdate(pRadarCam); + + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, false); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, false); + + DrawRadarSection(nX - 1, nY - 1); + DrawRadarSection(nX, nY - 1); + DrawRadarSection(nX + 1, nY - 1); + DrawRadarSection(nX - 1, nY); + DrawRadarSection(nX, nY); + DrawRadarSection(nX + 1, nY); + DrawRadarSection(nX - 1, nY + 1); + DrawRadarSection(nX, nY + 1); + DrawRadarSection(nX + 1, nY + 1); + + RwCameraEndUpdate(pRadarCam); + RwCameraBeginUpdate(Scene); + + /*CSprite2d::SetVertices(CRect(_xleft(35.0f), _ydown(107.0f), _xleft(35.0f + 94.0f), _ydown(107.0f - (94.0f * 448.0f / 480.0f))), + CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY), + 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);*/ + + CSprite2d::SetVertices(CRect(_xleft(35.0f), _ydown(107.0f), _xleft(35.0f + 94.0f), _ydown(107.0f - (94.0f * 448.0f / 480.0f))), CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY), CRGBA(255, 255, 255, HUD_TRANSPARENCY)); + + /*aSpriteVertices[0].rhw = 0.41f; + aSpriteVertices[1].rhw = 0.41f; + aSpriteVertices[2].rhw = 1.0f; + aSpriteVertices[3].rhw = 1.0f;*/ + + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwCameraGetRaster(pRadarCam)); + RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, aSpriteVertices, 4); +} + +void CRadar::TransformRadarPointToScreenSpace(CVector2D& vecOut, const CVector2D& vecIn) +{ + //RwV2d vecViewWindow = { 3.0f, 3.0f }; + //CVector vecTemp(vecIn.x * 1.0f, -vecIn.y; + CMatrix matTemp; + matTemp.SetRotateXOnly(-M_PI + M_PI/6); + matTemp.SetTranslateOnly(0.0, sin(M_PI/6), cos(M_PI/6)); + memcpy(RwFrameGetMatrix(RwCameraGetFrame(pRadarCam)), &matTemp.matrix, sizeof(RwMatrix)); + + //RwCameraSetViewWindow(pRadarCam, &vecViewWindow); + //RwCameraSetProjection(pRadarCam, rwPERSPECTIVE); + + CVector vecOutTemp = matTemp * CVector(vecIn.x, vecIn.y); + + + vecOut.x = ((vecOutTemp.x / vecOutTemp.z) + 1.0f) * 256.0f; + vecOut.y = ((vecOutTemp.y / vecOutTemp.z) + 1.0f) * 256.0f; + + //vecOut.x = (vecIn.x + 1.0f) * 256.0f; + //vecOut.y = (vecIn.y + 1.0f) * 256.0f; } \ No newline at end of file diff --git a/VCS PC/Radar.h b/VCS PC/Radar.h index 1747386..9ed8fd0 100644 --- a/VCS PC/Radar.h +++ b/VCS PC/Radar.h @@ -10,9 +10,14 @@ class CRadar public: static void ChangeBlipBrightness(int nBlipID, int nBrightness); + static void DrawRadarSection(int nX, int nY); static DWORD GetRadarTraceColour(int colour, bool bDark, bool bFriend); static void LoadTextures(); + + // 3D radar test + static void Draw3DRadar(int nX, int nY); + static void TransformRadarPointToScreenSpace(CVector2D& vecOut, const CVector2D& vecIn); }; #endif \ No newline at end of file diff --git a/VCS PC/Script.cpp b/VCS PC/Script.cpp index c327c32..2a8fa3e 100644 --- a/VCS PC/Script.cpp +++ b/VCS PC/Script.cpp @@ -342,7 +342,7 @@ void CRunningScript::ProcessVCSCommands(WORD opcode) char cString[8]; GetStringParam(cString, 8); CollectParameters(2); - CUserDisplay::Pager.AddMessage(const_cast(TheText.GetText(cString)), static_cast(scriptParams[0].iParam), static_cast(scriptParams[1].iParam)); + CUserDisplay::Pager.AddMessage(const_cast(TheText.Get(cString)), static_cast(scriptParams[0].iParam), static_cast(scriptParams[1].iParam)); return; } diff --git a/VCS PC/Script.h b/VCS PC/Script.h index 540767b..7db966c 100644 --- a/VCS PC/Script.h +++ b/VCS PC/Script.h @@ -160,8 +160,7 @@ class CMappedVariable ~CMappedVariable() { - if ( pVarData ) - delete[] pVarData; + delete[] pVarData; } }; diff --git a/VCS PC/Sprite.cpp b/VCS PC/Sprite.cpp index ff85cca..cbc45f7 100644 --- a/VCS PC/Sprite.cpp +++ b/VCS PC/Sprite.cpp @@ -3,6 +3,9 @@ // Wrappers WRAPPER void CSprite2d::SetVertices(const CRect& rect, const CRGBA& rgb1, const CRGBA& rgb2, const CRGBA& rgb3, const CRGBA& rgb4) { WRAPARG(rect); WRAPARG(rgb1); WRAPARG(rgb2); WRAPARG(rgb3); WRAPARG(rgb4); EAXJMP(0x727420); } +// TODO: Name params +WRAPPER void CSprite2d::SetVertices(const CRect&, const CRGBA&, const CRGBA&, const CRGBA&, const CRGBA&, float, float, float, float, float, float, float, float) { EAXJMP(0x727710); } + WRAPPER void CSprite2d::InitPerFrame() { EAXJMP(0x727350); } void CSprite2d::SetTexture(const char* name, const char* maskName) diff --git a/VCS PC/Sprite.h b/VCS PC/Sprite.h index 61ce0c1..95fd689 100644 --- a/VCS PC/Sprite.h +++ b/VCS PC/Sprite.h @@ -28,6 +28,7 @@ class CSprite2d static void InitPerFrame(); static void SetVertices(const CRect& rect, const CRGBA& rgb1, const CRGBA& rgb2, const CRGBA& rgb3, const CRGBA& rgb4); + static void SetVertices(const CRect&, const CRGBA&, const CRGBA&, const CRGBA&, const CRGBA&, float, float, float, float, float, float, float, float); static void DrawRect(const CRect& rect, const CRGBA& colour); }; diff --git a/VCS PC/Stats.cpp b/VCS PC/Stats.cpp index 2655b84..e9980a1 100644 --- a/VCS PC/Stats.cpp +++ b/VCS PC/Stats.cpp @@ -227,47 +227,47 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { if ( nStat == nTempValue++ ) { - strcpy(gString, TheText.GetText("ST_GANG")); + strcpy(gString, TheText.Get("ST_GANG")); switch ( nTheMostHatedGang ) { case 7: { - strcpy(gUString, TheText.GetText("ST_GNG1")); + strcpy(gUString, TheText.Get("ST_GNG1")); return 0; } case 8: { - strcpy(gUString, TheText.GetText("ST_GNG2")); + strcpy(gUString, TheText.Get("ST_GNG2")); return 0; } case 9: { - strcpy(gUString, TheText.GetText("ST_GNG3")); + strcpy(gUString, TheText.Get("ST_GNG3")); return 0; } case 10: { - strcpy(gUString, TheText.GetText("ST_GNG4")); + strcpy(gUString, TheText.Get("ST_GNG4")); return 0; } case 11: { - strcpy(gUString, TheText.GetText("ST_GNG5")); + strcpy(gUString, TheText.Get("ST_GNG5")); return 0; } case 12: { - strcpy(gUString, TheText.GetText("ST_GNG6")); + strcpy(gUString, TheText.Get("ST_GNG6")); return 0; } case 13: { - strcpy(gUString, TheText.GetText("ST_GNG7")); + strcpy(gUString, TheText.Get("ST_GNG7")); return 0; } case 14: { - strcpy(gUString, TheText.GetText("ST_GNG8")); + strcpy(gUString, TheText.Get("ST_GNG8")); return 0; } } @@ -471,7 +471,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Greatest insane stunt gUString[0] = '\0'; - strcpy(gString, TheText.GetText("BSTSTU")); + strcpy(gString, TheText.Get("BSTSTU")); return 0; } @@ -482,67 +482,67 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { case 1: { - strcpy(gUString, TheText.GetText("INSTUN")); + strcpy(gUString, TheText.Get("INSTUN")); return 0; } case 2: { - strcpy(gUString, TheText.GetText("FLINST")); + strcpy(gUString, TheText.Get("FLINST")); return 0; } case 3: { - strcpy(gUString, TheText.GetText("PRINST")); + strcpy(gUString, TheText.Get("PRINST")); return 0; } case 4: { - strcpy(gUString, TheText.GetText("DBINST")); + strcpy(gUString, TheText.Get("DBINST")); return 0; } case 5: { - strcpy(gUString, TheText.GetText("DBFINS")); + strcpy(gUString, TheText.Get("DBFINS")); return 0; } case 6: { - strcpy(gUString, TheText.GetText("DBPINS")); + strcpy(gUString, TheText.Get("DBPINS")); return 0; } case 7: { - strcpy(gUString, TheText.GetText("TRINST")); + strcpy(gUString, TheText.Get("TRINST")); return 0; } case 8: { - strcpy(gUString, TheText.GetText("FLTRST")); + strcpy(gUString, TheText.Get("FLTRST")); return 0; } case 9: { - strcpy(gUString, TheText.GetText("PRTRST")); + strcpy(gUString, TheText.Get("PRTRST")); return 0; } case 10: { - strcpy(gUString, TheText.GetText("QUINST")); + strcpy(gUString, TheText.Get("QUINST")); return 0; } case 11: { - strcpy(gUString, TheText.GetText("FQUINS")); + strcpy(gUString, TheText.Get("FQUINS")); return 0; } case 12: { - strcpy(gUString, TheText.GetText("PQUINS")); + strcpy(gUString, TheText.Get("PQUINS")); return 0; } default: { - strcpy(gUString, TheText.GetText("NOSTUC")); + strcpy(gUString, TheText.Get("NOSTUC")); return 0; } } @@ -791,7 +791,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Course name _snprintf(gUString, sizeof(gUString), "ST_R_%02d", i + 1); - strcpy(gString, TheText.GetText(gUString)); + strcpy(gString, TheText.Get(gUString)); gUString[0] = '\0'; return 0; } @@ -833,7 +833,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Sanchez Time Trial gUString[0] = '\0'; - strcpy(gString, TheText.GetText("ST_SATT")); + strcpy(gString, TheText.Get("ST_SATT")); return 0; } @@ -845,7 +845,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Course X _snprintf(gUString, sizeof(gUString), "ST_C_%02d", i + 1); - strcpy(gString, TheText.GetText(gUString)); + strcpy(gString, TheText.Get(gUString)); gUString[0] = '\0'; nIndents = 1; return 0; @@ -889,7 +889,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // BMX Time Trial gUString[0] = '\0'; - strcpy(gString, TheText.GetText("ST_BMXT")); + strcpy(gString, TheText.Get("ST_BMXT")); return 0; } @@ -901,7 +901,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Course X _snprintf(gUString, sizeof(gUString), "ST_C_%02d", i + 1); - strcpy(gString, TheText.GetText(gUString)); + strcpy(gString, TheText.Get(gUString)); gUString[0] = '\0'; nIndents = 1; return 0; @@ -945,7 +945,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Quad Bike Time Trial gUString[0] = '\0'; - strcpy(gString, TheText.GetText("ST_QBTT")); + strcpy(gString, TheText.Get("ST_QBTT")); return 0; } @@ -957,7 +957,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Course X _snprintf(gUString, sizeof(gUString), "ST_C_%02d", i + 1); - strcpy(gString, TheText.GetText(gUString)); + strcpy(gString, TheText.Get(gUString)); gUString[0] = '\0'; nIndents = 1; return 0; @@ -1001,7 +1001,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Monster Truck Time Trial gUString[0] = '\0'; - strcpy(gString, TheText.GetText("ST_MOTT")); + strcpy(gString, TheText.Get("ST_MOTT")); return 0; } @@ -1013,7 +1013,7 @@ long CStats::ConstructStatLine(int nStat, int& nIndents) { // Course X _snprintf(gUString, sizeof(gUString), "ST_C_%02d", i + 1); - strcpy(gString, TheText.GetText(gUString)); + strcpy(gString, TheText.Get(gUString)); gUString[0] = '\0'; nIndents = 1; return 0; @@ -1117,7 +1117,7 @@ void CStats::BuildStatLine(char* pEntryName, void* pVal1, int nType, void* pVal2 { if ( pEntryName ) { - const char* pText = TheText.GetText(pEntryName); + const char* pText = TheText.Get(pEntryName); gUString[0] = '\0'; strncpy(gString, pText, sizeof(gString)); @@ -1165,7 +1165,7 @@ void CStats::BuildStatLine(char* pEntryName, void* pVal1, int nType, void* pVal2 } case STATTYPE_OUTOF: { - _snprintf(gUString, sizeof(gUString), "%d %s %d", *static_cast(pVal1), TheText.GetText("FEST_OO"), *static_cast(pVal2)); + _snprintf(gUString, sizeof(gUString), "%d %s %d", *static_cast(pVal1), TheText.Get("FEST_OO"), *static_cast(pVal2)); return; } } diff --git a/VCS PC/StdAfx.h b/VCS PC/StdAfx.h index 8bbbafe..9004568 100644 --- a/VCS PC/StdAfx.h +++ b/VCS PC/StdAfx.h @@ -1,4 +1,8 @@ #pragma warning(disable:4481) // nonstandard extension used: override specifier 'override' +#pragma warning(disable:4401) // member is bit field +#pragma warning(disable:4733) // handler not registered as safe handler +#pragma warning(disable:4725) // instruction may be inaccurate on some Pentiums + #define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES @@ -47,6 +51,8 @@ //#define LIST_MEMORY //#define MAKE_CONSOLE //#define DUMP_MENUS +//#define V_RADAR_TEST +//#define ROTORS_TEST //#define MAKE_ZZCOOL_MOVIE_DEMO @@ -66,12 +72,6 @@ // TODO: Remove this, ugh #define _patchHandling(h, n) strncpy((char*)((DWORD)0x8D3978 + h * 14), n, 14) -/*#define GAMEVER_10EU_noCD 0 -#define GAMEVER_10US_HOODLUM 1 -#define GAMEVER_11EU_noCD 2 -#define GAMEVER_10EU 3 -#define GAMEVER_UNKNOWN 255*/ - #define MOD_VERSION "v3.0 BETA" #define VERSION_NAME "Blue Hesper" #define VERSION_NAME_UPPERCASE "BLUE HESPER" @@ -92,7 +92,6 @@ #define CEntity_ARRAYSIZE 0x38 #define CPlaceable_ARRAYSIZE 0x14 #define LoadedObjectInfo_ARRAYSIZE 0x14 -#define CClock_ARRAYSIZE 0x1C #define CMenuManager_ARRAYSIZE 0x1B78 #define CVehicle_ARRAYSIZE 0x5A0 #define CPlayerData_ARRAYSIZE 0xAC @@ -118,7 +117,13 @@ void LogToFile(const char* str, ...); void ToLower(char* str, BYTE len); -int random(int a, int b); + +// Some handy funcs +template +inline T random(T a, T b) +{ + return a + static_cast(rand() * (1.0f/32768.0f) * (b - a)); +} #ifdef MAKE_CONSOLE #define echo(x, ...) printf(x, __VA_ARGS__) @@ -126,13 +131,6 @@ int random(int a, int b); #define echo(x, ...) #endif -/*if ( dwAddress >= 0x7466D0 && dwAddress < 0x857000 ) - { - if ( dwAddress < 0x7BA940 ) - dwAddress += 0x50; - else - dwAddress += 0x40;*/ - #if defined DEVBUILD && !defined MAKE_ZZCOOL_MOVIE_DEMO void EnterAmazingScreenshotMode(bool bEnable); #endif @@ -152,6 +150,7 @@ void EnterAmazingScreenshotMode(bool bEnable); #include "MemoryMgr.h" #include "Rs.h" #include "WidescreenSupport.h" +//#include "ColAccel.h" #include "General.h" #include "Coronas.h" #include "Timer.h" @@ -179,10 +178,10 @@ void EnterAmazingScreenshotMode(bool bEnable); #include "Pools.h" #include "Script.h" #include "Streaming.h" -#include "CText.h" +#include "Text.h" #include "RwEngineInstance.h" -#include "CFont.h" -#include "CClock.h" +#include "Font.h" +#include "Clock.h" #include "Hud.h" #include "UpdateManager.h" #include "DLCManager.h" @@ -231,14 +230,12 @@ extern float* ScreenAspectRatio; extern float* fFOV; extern BYTE* bWants_To_Draw_Hud; extern BYTE* radarGrey; -extern BYTE* mpackNumber; extern bool* bHideStyledTextWhileFading; extern float* currentFPS; extern RsGlobalType& RsGlobal; -extern CClock* clock_struct; extern CRGBA* BaseColors; extern CMenuManager& FrontEndMenuManager; -extern CMusicManager* MusicManager; +extern CAudioEngine& AudioEngine; extern std::pair* const materialRestoreData; //extern CGridref* gridref; extern CText& TheText; @@ -255,9 +252,8 @@ extern CRunningScript* ScriptsArray; extern RwIm2DVertex* const aSpriteVertices; extern RwTexture** const gpCoronaTexture; extern RwCamera*& Scene; -extern void (*BigMessageRestOfFunc)(); extern void (*TheScriptsInitFunc)(); -extern char* (__thiscall *CLEOGetTextFunc)(CText* object, const char* key); +extern const char* (__thiscall *CLEOGetTextFunc)(CText*, const char*); extern CCRC32 HashingClass; extern bool InAmazingScreenshotMode; diff --git a/VCS PC/Text.cpp b/VCS PC/Text.cpp new file mode 100644 index 0000000..fc97bdc --- /dev/null +++ b/VCS PC/Text.cpp @@ -0,0 +1,68 @@ +#include "StdAfx.h" + +WRAPPER void CText::Load(bool bKeepMissionText) { WRAPARG(bKeepMissionText); EAXJMP(0x6A01A0); } +WRAPPER void CText::Unload(bool bKeepMissionText) { WRAPARG(bKeepMissionText); EAXJMP(0x69FF20); } +WRAPPER const char* CKeyArray::Search(const char* pKey, unsigned char* bFound) { WRAPARG(pKey); WRAPARG(bFound); EAXJMP(0x6A0000); } + +const char* (__thiscall *CLEOGetTextFunc)(CText*, const char*); + +const char* CText::Get(const char* pEntry) +{ + static char GxtErrorString[24]; + const char* outputText; + + if ( CLEOGetTextFunc ) + { + outputText = CLEOGetTextFunc(this, pEntry); + if ( !*outputText ) + { + _snprintf(GxtErrorString, sizeof(GxtErrorString), "%s missing", pEntry); + return GxtErrorString; + } + return outputText; + } + else + { + unsigned char bFound; + if ( pEntry[0] == '\0' || pEntry[0] == ' ' ) + return ""; + + outputText = tkeyMain.Search(pEntry, &bFound); + + if ( !bFound ) + { + if ( missionLoaded || CGame::IsMissionPackGame() || haveTabl ) + { + outputText = tkeyMission.Search(pEntry, &bFound); + if ( !bFound ) + { + _snprintf(GxtErrorString, sizeof(GxtErrorString), "%s missing", pEntry); + return GxtErrorString; + } + } + } + } + return outputText; +} + +void CText::ReloadFontsFiles(bool bKeepMissionText) +{ + UNREFERENCED_PARAMETER(bKeepMissionText); +#ifdef INCLUDE_MULTIFONTFILES + Load(bKeepMissionText); + if ( bCanReloadFonts && bLastFontsID != GetFontsIDByLanguage() ) + { + int slot = CTxdStore::FindTxdSlot("fontDetails"); + if ( slot == -1 ) + slot = CTxdStore::AddTxdSlot("fontDetails"); + CTxdStore::LoadTxd(slot, GetFontsTXDByLanguage()); + CTxdStore::AddRef(slot); + CTxdStore::PushCurrentTxd(); + CTxdStore::SetCurrentTxd(slot); + texFonts[0].Load("font2", "font2m"); + texFonts[1].Load("font1", "font1m"); + CFont::LoadFontValues(); + CTxdStore::PopCurrentTxd(); + } +#endif +} \ No newline at end of file diff --git a/VCS PC/Text.h b/VCS PC/Text.h new file mode 100644 index 0000000..24b5506 --- /dev/null +++ b/VCS PC/Text.h @@ -0,0 +1,76 @@ +#ifndef __TEXT__ // Whoa, __TEXT was defined somewhere already :o +#define __TEXT__ + +enum eLanguages +{ + LANGUAGE_English, + //LANGUAGE_Spanish, + LANGUAGE_Polish, + LANGUAGE_Hungarian, + NUM_LANGUAGES +}; + +enum eKeyboardSets +{ + KEYBOARD_QWERTY, + KEYBOARD_AZERTY, + KEYBOARD_QWERTZ +}; + +class CKeyArray +{ +private: + struct + { + const char* text; + unsigned long hash; + }* data; + unsigned int size; + +public: + const char* Search(const char* pKey, unsigned char* bFound); +}; + +class CData +{ +private: + void* data; + unsigned int size; +}; + +class CMissionTextOffsets +{ +private: + struct Entry + { + char name[8]; + void* offset; + } tablEntries[200]; + unsigned int size; +}; + +class CText +{ +private: + CKeyArray tkeyMain; + CData tdatMain; + CKeyArray tkeyMission; + CData tdatMission; + BYTE _f20; + bool haveTabl; + bool cderrorInitialized; + bool missionLoaded; + char missionName[8]; + char cderrorText[256]; + CMissionTextOffsets table; + +public: + const char* Get(const char* pEntry); + void ReloadFontsFiles(bool bKeepMissionText); + void Load(bool bKeepMissionText); + void Unload(bool bKeepMissionText); +}; + +static_assert(sizeof(CText) == CText_ARRAYSIZE, "CText class has wrong size!"); + +#endif \ No newline at end of file diff --git a/VCS PC/UpdateManager.cpp b/VCS PC/UpdateManager.cpp index 894714f..32d54ba 100644 --- a/VCS PC/UpdateManager.cpp +++ b/VCS PC/UpdateManager.cpp @@ -7,6 +7,7 @@ long CUpdateManager::nInterfaceStatus; long CUpdateManager::nLastInterfaceStatus; long CUpdateManager::nDrawingState; bool CUpdateManager::bSeenUpdaterScreenYet; +unsigned char CUpdateManager::bForceUpdate; char* CUpdateManager::pMessages[NUM_MESSAGES_PER_UPT_SCREEN]; #ifdef DEVBUILD @@ -34,6 +35,7 @@ void CUpdateManager::Init() } bSeenUpdaterScreenYet = false; + bForceUpdate = false; nActiveMessages = 0; nInterfaceStatus = nLastInterfaceStatus = UPTMODULESTATE_IDLE; } @@ -61,6 +63,12 @@ void CUpdateManager::Process() if ( pUptModuleInterface ) nInterfaceStatus = pUptModuleInterface->Process(); + if ( bForceUpdate == 1 ) + { + pUptModuleInterface->PerformUpdateCheck(); + ++bForceUpdate; + } + if ( nLastInterfaceStatus != nInterfaceStatus ) { switch ( nInterfaceStatus ) @@ -70,12 +78,17 @@ void CUpdateManager::Process() bSeenUpdaterScreenYet = false; break; - case UPTMODULESTATE_NEW_UPDATES: + case UPTMODULESTATE_NEW_UPDATES: + if ( bForceUpdate == 2 ) + { + pUptModuleInterface->PerformFilesDownload(); + ++bForceUpdate; + } bSeenUpdaterScreenYet = false; break; case UPTMODULESTATE_ALL_READY: - EchoMessage(TheText.GetText("UPT_INS")); + EchoMessage(TheText.Get("UPT_INS")); bSeenUpdaterScreenYet = false; break; } @@ -239,13 +252,13 @@ void CUpdateManager::Display() if ( nDrawingState ) { - CFont::SetTextBackground(0, 0); - CFont::SetTextUseProportionalValues(true); + CFont::SetBackground(0, 0); + CFont::SetProportional(true); CFont::SetFontStyle(FONT_Eurostile); - CFont::SetTextAlignment(ALIGN_Right); - CFont::SetTextOutline(1); + CFont::SetOrientation(ALIGN_Right); + CFont::SetEdge(1); CFont::SetScale(_width(0.35f), _height(0.65f)); - CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, static_cast(nTextAlpha))); + CFont::SetDropColor(CRGBA(0, 0, 0, static_cast(nTextAlpha))); if ( nDrawingState == 2 || nDrawingState == 5 ) CFont::SetColor(CRGBA(MENU_UPDATES_R, MENU_UPDATES_G, MENU_UPDATES_B, static_cast(nTextAlpha))); else @@ -254,23 +267,23 @@ void CUpdateManager::Display() switch ( nInterfaceStatus ) { case UPTMODULESTATE_IDLE: - CFont::PrintString(_x(15.0f), _y(3.5f), TheText.GetText(pUptModuleInterface->UpdateServiceOn() ? "FEU_NOU" : "FEU_USA")); + CFont::PrintString(_x(15.0f), _y(3.5f), TheText.Get(pUptModuleInterface->UpdateServiceOn() ? "FEU_NOU" : "FEU_USA")); break; case UPTMODULESTATE_CHECKING: - CFont::PrintString(_x(15.0f), _y(3.5f), TheText.GetText("FEU_CHK")); + CFont::PrintString(_x(15.0f), _y(3.5f), TheText.Get("FEU_CHK")); break; case UPTMODULESTATE_NEW_UPDATES: - CFont::PrintString(_x(15.0f), _y(3.5f), TheText.GetText("FEU_NEW")); + CFont::PrintString(_x(15.0f), _y(3.5f), TheText.Get("FEU_NEW")); break; case UPTMODULESTATE_DOWNLOADING: - CMessages::InsertNumberInString(TheText.GetText("FEU_DLU"), static_cast(pUptModuleInterface->GetProgress()), -1, -1, -1, -1, -1, gString); + CMessages::InsertNumberInString(TheText.Get("FEU_DLU"), static_cast(pUptModuleInterface->GetProgress()), -1, -1, -1, -1, -1, gString); CFont::PrintString(_x(15.0f), _y(3.5f), gString); break; case UPTMODULESTATE_ALL_READY: - CFont::PrintString(_x(15.0f), _y(3.5f), TheText.GetText("FEU_RDY")); + CFont::PrintString(_x(15.0f), _y(3.5f), TheText.Get("FEU_RDY")); break; } } diff --git a/VCS PC/UpdateManager.h b/VCS PC/UpdateManager.h index 681cc64..e4b5af5 100644 --- a/VCS PC/UpdateManager.h +++ b/VCS PC/UpdateManager.h @@ -16,6 +16,7 @@ class CUpdateManager static long nLastInterfaceStatus; static long nDrawingState; static bool bSeenUpdaterScreenYet; + static unsigned char bForceUpdate; static char* pMessages[NUM_MESSAGES_PER_UPT_SCREEN]; #ifdef DEVBUILD @@ -26,7 +27,7 @@ class CUpdateManager static inline bool AnyTextDisplaysNow() { return nDrawingState != 0; } - static inline bool IsDownloading() + static inline bool IsDownloading() { return nInterfaceStatus == UPTMODULESTATE_DOWNLOADING || nInterfaceStatus == UPTMODULESTATE_ALL_READY; } static inline bool AreUpdatesSeen() @@ -34,6 +35,9 @@ class CUpdateManager static inline void ReportUpdaterScreenSeen() { bSeenUpdaterScreenYet = true; } + + static inline void ForceUpdate() + { if ( !bForceUpdate ) bForceUpdate = 1; } static inline bool GetDLCStatus(const char* pName, bool bDefault) { return pUptModuleInterface->GetDLCStatus(pName, bDefault); } diff --git a/VCS PC/UserDisplay.cpp b/VCS PC/UserDisplay.cpp index cc0189f..8a69292 100644 --- a/VCS PC/UserDisplay.cpp +++ b/VCS PC/UserDisplay.cpp @@ -251,7 +251,7 @@ void COnscreenTimer::Process() { if ( nPrevTime / 1000 < m_timer.m_nSoundOnTime && !TheCamera.m_WideScreenOn ) { - MusicManager->ReportFrontendAudioEvent(33, 0.0f, 1.0f); + AudioEngine.ReportFrontendAudioEvent(33, 0.0f, 1.0f); m_timer.m_bFlashing = true; } else @@ -480,8 +480,7 @@ void CUserDisplay::Init() void CUserDisplay::Process() { - DWORD dwFunc = 0x5720A0; - _asm call dwFunc + ((void(*)())0x5720A0)(); Pager.Process(); } \ No newline at end of file diff --git a/VCS PC/VCS PC.vcxproj b/VCS PC/VCS PC.vcxproj index d6c4db6..4a0cf4a 100644 --- a/VCS PC/VCS PC.vcxproj +++ b/VCS PC/VCS PC.vcxproj @@ -160,6 +160,7 @@ popd NotSet $(SolutionDir)dependencies\include;$(SolutionDir)dependencies\include\rwsdk;%(AdditionalIncludeDirectories) Sync + Disabled binkw32.lib;%(AdditionalDependencies) @@ -305,11 +306,9 @@ popd - - true @@ -317,11 +316,16 @@ popd true true + + + true + + @@ -340,7 +344,6 @@ popd - @@ -355,6 +358,7 @@ popd Create + @@ -364,6 +368,7 @@ popd Use + @@ -383,22 +388,22 @@ popd - + + - + - @@ -412,9 +417,9 @@ popd - + diff --git a/VCS PC/VCS PC.vcxproj.filters b/VCS PC/VCS PC.vcxproj.filters index 71ffc9e..97b1d19 100644 --- a/VCS PC/VCS PC.vcxproj.filters +++ b/VCS PC/VCS PC.vcxproj.filters @@ -36,18 +36,12 @@ Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files @@ -57,9 +51,6 @@ Source Files - - Source Files - Source Files @@ -195,6 +186,21 @@ Source Files\DLC + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -203,18 +209,12 @@ Header Files - - Header Files - Header Files Header Files - - Header Files - Header Files @@ -224,12 +224,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -395,6 +389,18 @@ Header Files\DLC + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/VCS PC/VCSPC.cpp b/VCS PC/VCSPC.cpp index c811c2a..6ab0815 100644 --- a/VCS PC/VCSPC.cpp +++ b/VCS PC/VCSPC.cpp @@ -8,7 +8,7 @@ void CollectPCInfo(); void DetermineGameVer(); void DefineVariables(); //void CheckStructures(); -void LoadNewWindowIcon(); +void InjectDelayedPatches(); void Main_Patches(); void PatchMenus(); void AnimationStylesPatching(); @@ -67,9 +67,11 @@ void InCarKilledCounterBreak(); void Language_CASE_English(); void Language_CASE_Spanish(); void Language_CASE_Polish(); +void Language_CASE_Hungarian(); void MissionLanguage_CASE_English(); void MissionLanguage_CASE_Spanish(); void MissionLanguage_CASE_Polish(); +void MissionLanguage_CASE_Hungarian(); void CGameLogic__Update_Busted(); void CGameLogic__Update_Wasted(); void AssignViceSquadToVehicle(); @@ -160,6 +162,8 @@ void CommandlineEventHack(); void ReadCommandlineFile(); void LoadGameWithDLCHack(); void DLCMenuAction(); +void VehAudioHook(); +void RotorsHook(); #ifdef INCLUDE_MULTIFONTFILES void MultipleFontsDAT_Inject(); void MultipleFontsTXD_Inject(); @@ -179,7 +183,6 @@ BYTE bShouldEcho = 0; // Objects & variables CCRC32 HashingClass; CConfiscatedWeapons weaponsToReturn; -CHud hud; DWORD stackPtr; HANDLE gStreamFiles[NUM_STREAMS]; char gStreamNames[NUM_STREAMS][64]; @@ -196,9 +199,6 @@ char gUString[552]; CSprite2d DevLogos[1]; #endif - -void* _CText__load_JumpBack; -void* _CText__loadMission_JumpBack; void* _ProcessEnexMarkers_JumpBack; //void* CGameLogic__Update_Busted_JumpBack; //void* CGameLogic__Update_Wasted_JumpBack; @@ -278,7 +278,6 @@ DWORD* memoryUsed; eFlash* wFlashingComponentID; BYTE* bWants_To_Draw_Hud; BYTE* radarGrey; -BYTE* mpackNumber; long* CTRubberMaxPos; long* CTRubberMinPos; float* WidthAspectRatio; @@ -300,10 +299,9 @@ float* currentFPS; RsGlobalType& RsGlobal = *(RsGlobalType*)0xC17040; CCamera& TheCamera = *(CCamera*)0xB6F028; CText& TheText = *(CText*)0xC1B340; -CClock* clock_struct; CRGBA* BaseColors; CMenuManager& FrontEndMenuManager = *(CMenuManager*)0xBA6748; -CMusicManager* MusicManager; +CAudioEngine& AudioEngine = *(CAudioEngine*)0xB6BC90; RpClump** arrowClump; std::pair* const materialRestoreData = (std::pair*)0xB4DBE8; CBlurStage* blurStages; @@ -325,10 +323,7 @@ void** rwengine = (void**)0xC97B24; void (*replacedTXDLoadFunc)(); void (*replacedTXDReleaseFunc)(); -void (*BigMessageRestOfFunc)(); void (*TheScriptsInitFunc)(); -void (*DInputPadInitFunc)(); -char* (__thiscall *CLEOGetTextFunc)(CText* object, const char* key); const float LoadingBarHeight = 27.5f; const float LoadingBarWidth = 155.0f; @@ -361,26 +356,23 @@ const float fSubtitlesHeight = 0.9; const float fTextBoxPosY = 20.0f; const float* const pRefFal = &fRefZVal; -const float fWeaponIconWidth = 75.0f; -const float fWeaponIconHeight = 72.0f; -const float fWLStarPosX = HUD_POS_X - 116.0f; -const float fWLStarPosY = HUD_POS_Y + 53.0f; -const float fWLStarHeight = 1.5f; -const float fWLStarWidth = 0.95f; -const float fWLStarDistance = 20.0f; -const float fWLStarAlpha = HUD_TRANSPARENCY; - -/*const char aFlinst[] = "FLINST"; -const char aDbfins[] = "DBFINS"; -const char aFltrst[] = "FLTRST"; -const char aFquins[] = "FQUINS";*/ -const char aEnglish_gxt[] = "ENGLISH.GXT"; -const char aSpanish_gxt[] = "SPANISH.GXT"; -const char aPolish_gxt[] = "POLISH.GXT"; -const char aFem_24H[] = "FEM_24H"; -const char aFem_12H[] = "FEM_12H"; -const char aFem_Fps[] = "FEM_FPS"; -const char aFem_Asd[] = "FEM_AS%d"; +static const float fWeaponIconWidth = 75.0f; +static const float fWeaponIconHeight = 72.0f; +static const float fWLStarPosX = HUD_POS_X - 116.0f; +static const float fWLStarPosY = HUD_POS_Y + 53.0f; +static const float fWLStarHeight = 1.5f; +static const float fWLStarWidth = 0.95f; +static const float fWLStarDistance = 20.0f; +static const float fWLStarAlpha = HUD_TRANSPARENCY; + +static const char aEnglish_gxt[] = "ENGLISH.GXT"; +static const char aSpanish_gxt[] = "SPANISH.GXT"; +static const char aPolish_gxt[] = "POLISH.GXT"; +static const char aHungarian_gxt[] = "HUNGARIAN.GXT"; +static const char aFem_24H[] = "FEM_24H"; +static const char aFem_12H[] = "FEM_12H"; +static const char aFem_Fps[] = "FEM_FPS"; +static const char aFem_Asd[] = "FEM_AS%d"; #ifdef ADD_UNFINISHED_WINDOWED_MODE const char aWindowed[] = "WINDOWED"; #endif @@ -496,8 +488,8 @@ const CutsceneData cutsceneStreams[] = { { "JERA1", CUTSCENE_OFFSET+CUT_JERA1 { "MARA1", CUTSCENE_OFFSET+CUT_MARA1 }, { "MARA2", CUTSCENE_OFFSET+CUT_MARA2 }, { "MARA5", CUTSCENE_OFFSET+CUT_MARA5 }, { "PHILA1", CUTSCENE_OFFSET+CUT_PHILA1 }, { "PHILA2", CUTSCENE_OFFSET+CUT_PHILA2 }, { "PHILA3", CUTSCENE_OFFSET+CUT_PHILA3 }, { "PHILA4", CUTSCENE_OFFSET+CUT_PHILA4 } }; -const void* const _CText__load_Jumptable[] = { Language_CASE_English, /*Language_CASE_Spanish,*/ Language_CASE_Polish }; -const void* const _CText__loadMission_Jumptable[] = { MissionLanguage_CASE_English, /*MissionLanguage_CASE_Spanish,*/ MissionLanguage_CASE_Polish }; +const void* const _CText__load_Jumptable[] = { Language_CASE_English, /*Language_CASE_Spanish,*/ Language_CASE_Polish, Language_CASE_Hungarian }; +const void* const _CText__loadMission_Jumptable[] = { MissionLanguage_CASE_English, /*MissionLanguage_CASE_Spanish,*/ MissionLanguage_CASE_Polish, MissionLanguage_CASE_Hungarian }; /*const void* HJ_Stats_Jumptable[] = { (void*)0x55AC7E, FlamingStunt, (void*)0x55AC97, (void*)0x55ACB0, DoubleFlamingStunt, (void*)0x55ACC9, @@ -556,7 +548,7 @@ DWORD WINAPI ProcessEmergencyKey(LPVOID lpParam) { bKeyState = true; bFPSState = bFPSState == false; - hud.SetFPSDisplay(bFPSState); + CHud::SetFPSDisplay(bFPSState); } } else @@ -762,8 +754,6 @@ __forceinline void DefineVariables() { LogToFile("Assigning variables..."); - _CText__load_JumpBack = (void*)0x6A020E; - _CText__loadMission_JumpBack = (void*)0x69FD31; _ProcessEnexMarkers_JumpBack = (void*)0x440F43; //CGameLogic__Update_Busted_JumpBack = (void*)0x442D34; //CGameLogic__Update_Wasted_JumpBack = (void*)0x442D0B; @@ -843,7 +833,6 @@ __forceinline void DefineVariables() wFlashingComponentID = (eFlash*)0xBAB1DC; bWants_To_Draw_Hud = (BYTE*)0xA444A0; radarGrey = (BYTE*)0xA444A4; - mpackNumber = (BYTE*)0xB72910; CTRubberMaxPos = (long*)0x57BCAB; CTRubberMinPos = (long*)0x57BCBD; WidthAspectRatio = (float*)0x859520; @@ -862,9 +851,7 @@ __forceinline void DefineVariables() PriorityText = (char*)0xBAB040; Garage_MessageIDString = (char*)0x96C014; currentFPS = (float*)0xB7CB50; - clock_struct = (CClock*)0xB70144; BaseColors = (CRGBA*)0xBAB22C; - MusicManager = (CMusicManager*)0xB6BC90; arrowClump = (RpClump**)0xC7C6F0; blurStages = (CBlurStage*)0x8D5190; //gridref = (CGridref*)0xC72FB0; @@ -884,7 +871,6 @@ __forceinline void DefineVariables() replacedTXDReleaseFunc = (void(*)())*((int*)0x53BBCC); *(int*)&replacedTXDReleaseFunc += (int)0x53BBCB + 5; - BigMessageRestOfFunc = (void(*)())(void(*)())0x58CFA8; /*return; } @@ -918,7 +904,7 @@ __forceinline void DefineVariables() assert(sizeof(CClock) == CClock_ARRAYSIZE); assert(sizeof(CMenuManager) == CMenuManager_ARRAYSIZE); assert(sizeof(CVehicle) == CVehicle_ARRAYSIZE); - assert(sizeof(CPlayerData) == CPlayerData_ARRAYSIZE); + assert(sizeof(CPlayerPedData) == CPlayerData_ARRAYSIZE); assert(sizeof(CGridref) == CGridref_ARRAYSIZE); assert(sizeof(COnscreenTimer) == COnscreenTimer_ARRAYSIZE); /*if ( sizeof(CMenuItem) != CMenuItem_ARRAYSIZE ) @@ -975,8 +961,8 @@ __forceinline void DefineVariables() if ( sizeof(CVehicle) != CVehicle_ARRAYSIZE ) LogToFile("Warning: Vehicle class has wrong size - 0x%X", sizeof(CVehicle)); - if ( sizeof(CPlayerData) != CPlayerData_ARRAYSIZE ) - LogToFile("Warning: PlayerData class has wrong size - 0x%X", sizeof(CPlayerData)); + if ( sizeof(CPlayerPedData) != CPlayerData_ARRAYSIZE ) + LogToFile("Warning: PlayerData class has wrong size - 0x%X", sizeof(CPlayerPedData)); if ( sizeof(CGridref) != CGridref_ARRAYSIZE ) LogToFile("Warning: Gridref class has wrong size - 0x%X", sizeof(CGridref)); @@ -1417,6 +1403,42 @@ long double SquareRadar(CVector2D& pos) #endif +#ifdef V_RADAR_TEST + +void __declspec(naked) Draw3DRadarHook() +{ + _asm + { + push edi + push esi + call CRadar::Draw3DRadar + add esp, 30h + pop edi + pop esi + pop ebp + pop ebx + add esp, 2Ch + retn + } +} + +void __declspec(naked) RadarTransformHook() +{ + _asm + { + push edx + mov edx, [esp+4+8] + push edx + push eax + call CRadar::TransformRadarPointToScreenSpace + add esp, 8 + pop edx + retn + } +} + +#endif + #ifdef INCLUDE_TRIANGLE_RADAR long double TriangleRadar(CVector2D& pos) @@ -1849,11 +1871,12 @@ void __declspec(naked) CamHack() } } -void TempExitFix() +// Fixed +/*void TempExitFix() { CUpdateManager::InstallIfNeeded(); ExitProcess(0); -} +}*/ __forceinline void Main_Patches() { @@ -1862,30 +1885,32 @@ __forceinline void Main_Patches() LogToFile("Patching miscellaneous game data..."); - /*call(0x732B30, &myfunc, PATCH_JUMP); - nop(0x6C447C, 5); - nop(0x6C44B3, 5); - nop(0x6C44E6, 5); - nop(0x6C4519, 5);*/ + // TEMPORARY WORKAROUND FOR A CRASH + Patch(0x6195E0, 0xC3); #ifdef INCLUDE_SQUARE_RADAR InjectHook(0x5832F0, SquareRadar, PATCH_JUMP); - patch(0x585719, 0, 4); - patch(0x585721, 0, 4); - patch(0x585729, 0, 4); - patch(0x585731, 0, 4); - patch(0x585739, 0, 4); - patch(0x585741, 0, 4); - patch(0x585749, 0, 4); - patch(0x585751, 0, 4); + Patch(0x585719, 0.0); + Patch(0x585721, 0.0); + Patch(0x585729, 0.0); + Patch(0x585731, 0.0); + Patch(0x585739, 0.0); + Patch(0x585741, 0.0); + Patch(0x585749, 0.0); + Patch(0x585751, 0.0); #endif #ifdef INCLUDE_TRIANGLE_RADAR InjectHook(0x5832F0, TriangleRadar, PATCH_JUMP); InjectHook(0x585850, TriangleRadarMask, PATCH_JUMP); - patch(0x58581B, 2, 4); - patch(0x585895, 3, 1); - patch(0x58589C, 3, 1); + Patch(0x58581B, 2); + Patch(0x585895, 3); + Patch(0x58589C, 3); +#endif + +#ifdef V_RADAR_TEST + InjectHook(0x58696E, Draw3DRadarHook, PATCH_JUMP); + InjectHook(0x586408, RadarTransformHook); #endif #ifdef INCLUDE_COOL_BINK_SCREEN @@ -1945,9 +1970,8 @@ __forceinline void Main_Patches() // InjectHook(0x5B6449, TraceTXDLoads); InjectHook(0x731CCB, TraceTXDLoads2, PATCH_JUMP); #endif - DInputPadInitFunc = (void(*)())(*(int*)0x748814 + 0x748813 + 5); - InjectHook(0x748813, LoadNewWindowIcon); + //InjectHook(0x748813, LoadNewWindowIcon); // SAORS connection //patch(0x868A5C, &saors, 4); @@ -1965,7 +1989,7 @@ __forceinline void Main_Patches() #endif /*#if DEBUG // Resolution selection box - nop(0x746225, 2); + Nop(0x746225, 2); #endif*/ // Crash fix @@ -1983,8 +2007,8 @@ __forceinline void Main_Patches() InjectHook(0x442D2F, CGameLogic__Update_Busted); // Don't change velocity when colliding with peds in a vehicle - //call(0x5F12CA, &CPhysical__ApplyMoveForce_nop, PATCH_CALL); - Patch(0x5F12CA, 0x901CC483); // add esp, 1Ch; nop + //call(0x5F12CA, &CPhysical__ApplyMoveForce_Nop, PATCH_CALL); + Patch(0x5F12CA, 0x901CC483); // add esp, 1Ch; Nop Nop(0x5F12CA + 4, 1); // Garages capacity tweak @@ -2097,7 +2121,7 @@ __forceinline void Main_Patches() Patch(0x58DF18, 0xE990); Patch(0x58DE23, 0xEB); - InjectHook(0x588B60, CHud::GetScreenCoordsForPlayerItem, PATCH_JUMP); + InjectHook(0x588B60, CHud::GetYPosBasedOnHealth, PATCH_JUMP); Patch(0x58DD41, 0); Nop(0x58DE84, 6); Nop(0x58DE9F, 6); @@ -2155,6 +2179,7 @@ __forceinline void Main_Patches() InjectHook(0x5BD76F, CHud::Initialise); InjectHook(0x53BD51, CHud::ReInitialise); InjectHook(0x53CA84, CHud::ReInitialise); + InjectHook(0x53BBA2, CHud::Shutdown); InjectHook(0x4E9EF8, RadioNameInject, PATCH_JUMP); InjectHook(0x588B44, CHud::GetRidOfAllCustomHUDMessages, PATCH_JUMP); //InjectHook(0x588A4B, HUDInitialiseBreak, PATCH_JUMP); @@ -2168,27 +2193,27 @@ __forceinline void Main_Patches() InjectHook(0x58C83E, BigMessage1Inject, PATCH_JUMP); InjectHook(0x58D3D9, BigMessage2Inject, PATCH_JUMP); InjectHook(0x58CB9C, BigMessage3Inject, PATCH_JUMP); - Patch(0x58C278, &hud.CarNameStage); - Patch(0x58C286, &hud.CarNameStage); - Patch(0x58CAB5, &hud.CarNameStage); - Patch(0x58CAD3, &hud.CarNameStage); - Patch(0x58D27F, &hud.m_ZoneState); - Patch(0x58C28C, &hud.m_ZoneState); - Patch(0x58C295, &hud.m_ZoneState); - Patch(0x58CADC, &hud.m_ZoneState); - Patch(0x58CAE6, &hud.m_ZoneState); - Patch(0x58D289, &hud.m_ZoneFadeTimer); - Patch(0x58D33A, &hud.BigMessage2Alpha); - Patch(0x58D3A1, &hud.BigMessage2Alpha); - Patch(0x58D3A7, &hud.BigMessage2Alpha); - Patch(0x58D3AD, &hud.BigMessage2Alpha); - Patch(0x58D3C0, &hud.BigMessage2Alpha); + Patch(0x58C278, &CHud::CarNameStage); + Patch(0x58C286, &CHud::CarNameStage); + Patch(0x58CAB5, &CHud::CarNameStage); + Patch(0x58CAD3, &CHud::CarNameStage); + Patch(0x58D27F, &CHud::m_ZoneState); + Patch(0x58C28C, &CHud::m_ZoneState); + Patch(0x58C295, &CHud::m_ZoneState); + Patch(0x58CADC, &CHud::m_ZoneState); + Patch(0x58CAE6, &CHud::m_ZoneState); + Patch(0x58D289, &CHud::m_ZoneFadeTimer); + Patch(0x58D33A, &CHud::BigMessage2Alpha); + Patch(0x58D3A1, &CHud::BigMessage2Alpha); + Patch(0x58D3A7, &CHud::BigMessage2Alpha); + Patch(0x58D3AD, &CHud::BigMessage2Alpha); + Patch(0x58D3C0, &CHud::BigMessage2Alpha); Nop(0x58C729, 6); - Patch(0x58CAC7, &hud.BigMessage3Alpha); - Patch(0x58CB7B, &hud.BigMessage3Alpha); - Patch(0x58CB81, &hud.BigMessage3Alpha); - Patch(0x58CB94, &hud.BigMessage3Alpha); + Patch(0x58CAC7, &CHud::BigMessage3Alpha); + Patch(0x58CB7B, &CHud::BigMessage3Alpha); + Patch(0x58CB81, &CHud::BigMessage3Alpha); + Patch(0x58CB94, &CHud::BigMessage3Alpha); /*Patch(0x58CA99, &hud.BigMessage3PosY); Patch(0x58CB1C, &hud.BigMessage3PosY); Patch(0x58CB44, &hud.BigMessage3PosY);*/ @@ -2279,7 +2304,7 @@ __forceinline void Main_Patches() if ( (BYTE)dwFunc == 0xE9 ) { dwFunc = (*(DWORD*)0x44CC21) + 0x44CC25 + 0x66; - //nop(dwFunc, 17); + //Nop(dwFunc, 17); patch(dwFunc, 0x0FEB, 2); dwFunc += 17; patch(dwFunc, 0x68, 1); @@ -2303,6 +2328,18 @@ __forceinline void Main_Patches() Patch(0x49362D, &ScriptCheckpointsColours_IndirectTable); Patch(0x493634, &ScriptCheckpointsColours_Jumptable); + // Removed prostitute subtitiles + Patch(0x666951, 0x1FEB); + Patch(0x66724E, 0x1FEB); + Patch(0x66689D, 0x4AEB); + Patch(0x666E21, 0x22EB); + Patch(0x667169, 0xEB04C483); + Patch(0x66716D, 0x45); + Nop(0x666E07, 5); + + // No stats update box + Patch(0x55B980, 0xC3); + // Spheres colours //dwFunc = 0x4810E0 + 0x2B; // patch(dwFunc, MARKER_SET_COLOR_A, 4); @@ -2327,7 +2364,7 @@ __forceinline void Main_Patches() patch(0x70CDAF, 0xED, 1);*/ // Growing/shrinking 3DMarkers - Patch(0x440F26, 0.0); + Patch(0x440F26, 0.0f); InjectHook(0x72576B, C3DMarkerSizeHack, PATCH_CALL); Nop(0x725770, 1); @@ -2380,184 +2417,188 @@ __forceinline void Main_Patches() Patch(0x4F781E, 0x8D); Patch(0x4F7827, &audioGearboxSoundTable); + // Car sounds DAT file + InjectHook(0x4F77B8, VehAudioHook, PATCH_JUMP); + Nop(0x4F77EF, 1); + + // Failed :( +#ifdef ROTORS_TEST + InjectHook(0x6C444B, RotorsHook, PATCH_JUMP); +#endif + // radio IDs - patch(0x489B8D, 9, 1); - patch(0x489B91, 10, 4); - - patch(0x4E8385, 11, 1); - patch(0x4E83A1, 10, 1); - charptr(0x4E83C6, "FEA_FM%d"); - - patch(0x4EB3C7, 12, 1); - patch(0x4EB3CE, 11, 1); - patch(0x4EB424, 11, 1); - patch(0x4EB47B, 11, 1); - - patch(0x4E9EE4, 11, 1); - patch(0x4E9EE9, 12, 1); - patch(0x4E9EEE, 11, 1); - - patch(0x573A2D, 11, 1); - patch(0x573A31, 12, 1); - - patch(0x4E8295, 10, 1); - patch(0x4E82A3, 11, 1); - - patch(0x4E83FB, 11, 1); - - patch(0x4EB8CB, 11, 1); - patch(0x4EB907, 11, 1); - patch(0x4EB91E, 11, 1); - - patch(0x4EB6A0, 11, 1); - patch(0x4EB795, 11, 1); - patch(0x4EB799, 12, 1); - patch(0x4EB79D, 245, 1); - patch(0x4EB7A3, 11, 1); - patch(0x4EB7AB, 10, 1); - patch(0x4EB7BD, 11, 1); - - patch(0x4EA68E, 10, 1); - patch(0x4EA738, 10, 1); - patch(0x4EA810, 10, 1); - patch(0x4EA876, 10, 1); - patch(0x4EA8E0, 10, 1); - - patch(0x4EA93B, 10, 1); - patch(0x4EAAA2, 10, 1); - patch(0x4EAAC0, 10, 1); - -// patch(0x4EAC86, 10, 1); - patch(0x4EAD6D, 10, 1); - patch(0x4EAD7F, 10, 1); - patch(0x4EAD8E, 10, 1); -// patch(0x4EADF0, 9, 1); - patch(0x4EADF5, 10, 1); - patch(0x4EAE19, 10, 1); -// patch(0x4EAE46, 9, 1); -// patch(0x4EAEDC, 9, 1); -// patch(0x4EAF1E, 9, 1); -// patch(0x4EAF87, 9, 1); - patch(0x4EB03F, 10, 1); - patch(0x4EB04D, 10, 1); - patch(0x4EB07E, 10, 1); - - patch(0x4EB1CE, 10, 1); - patch(0x4EB1DA, 10, 1); - patch(0x4EB1EB, 10, 1); - patch(0x4EB21E, 10, 1); - patch(0x4EB3A0, 10, 1); - patch(0x4EB3B0, 10, 1); - - patch(0x4EBA14, 11, 1); - patch(0x4EBBA2, 10, 1); - patch(0x4EBBEC, 10, 1); - patch(0x4EBDF2, 10, 1); - - patch(0x4E9991, 11, 1); - patch(0x4E99A6, 11, 1); - patch(0x4E9A3B, 0xEB, 1); - patch(0x4E9D03, 11, 1); - patch(0x4E9D5A, 11, 1); - patch(0x5B9494, 11, 1); - patch(0x4E8074, 11, 1); - -// patch(0x4EA276, 0xEB, 1); + Patch(0x489B8D, 9); + Patch(0x489B91, 10); + + Patch(0x4E8385, 11); + Patch(0x4E83A1, 10); + Patch(0x4E83C6, "FEA_FM%d"); + + Patch(0x4EB3C7, 12); + Patch(0x4EB3CE, 11); + Patch(0x4EB424, 11); + Patch(0x4EB47B, 11); + + Patch(0x4E9EE4, 11); + Patch(0x4E9EE9, 12); + Patch(0x4E9EEE, 11); + + Patch(0x573A2D, 11); + Patch(0x573A31, 12); + + Patch(0x4E8295, 10); + Patch(0x4E82A3, 11); + + Patch(0x4E83FB, 11); + + Patch(0x4EB8CB, 11); + Patch(0x4EB907, 11); + Patch(0x4EB91E, 11); + + Patch(0x4EB6A0, 11); + Patch(0x4EB795, 11); + Patch(0x4EB799, 12); + Patch(0x4EB79D, 245); + Patch(0x4EB7A3, 11); + Patch(0x4EB7AB, 10); + Patch(0x4EB7BD, 11); + + Patch(0x4EA68E, 10); + Patch(0x4EA738, 10); + Patch(0x4EA810, 10); + Patch(0x4EA876, 10); + Patch(0x4EA8E0, 10); + + Patch(0x4EA93B, 10); + Patch(0x4EAAA2, 10); + Patch(0x4EAAC0, 10); + +// Patch(0x4EAC86, 10); + Patch(0x4EAD6D, 10); + Patch(0x4EAD7F, 10); + Patch(0x4EAD8E, 10); +// Patch(0x4EADF0, 9); + Patch(0x4EADF5, 10); + Patch(0x4EAE19, 10); +// Patch(0x4EAE46, 9); +// Patch(0x4EAEDC, 9); +// Patch(0x4EAF1E, 9); +// Patch(0x4EAF87, 9); + Patch(0x4EB03F, 10); + Patch(0x4EB04D, 10); + Patch(0x4EB07E, 10); + + Patch(0x4EB1CE, 10); + Patch(0x4EB1DA, 10); + Patch(0x4EB1EB, 10); + Patch(0x4EB21E, 10); + Patch(0x4EB3A0, 10); + Patch(0x4EB3B0, 10); + + Patch(0x4EBA14, 11); + Patch(0x4EBBA2, 10); + Patch(0x4EBBEC, 10); + Patch(0x4EBDF2, 10); + + Patch(0x4E9991, 11); + Patch(0x4E99A6, 11); + Patch(0x4E9A3B, 0xEB); + Patch(0x4E9D03, 11); + Patch(0x4E9D5A, 11); + Patch(0x5B9494, 11); + Patch(0x4E8074, 11); + +// Patch(0x4EA276, 0xEB); // Proper radio - call(0x4EA670, &NoRadioCommercialsHack, PATCH_JUMP); - _asm - { - mov eax, offset CAERadioTrackManager::GetNextTrackByStation - mov dwFunc, eax - } - call(0x4EA270, dwFunc, PATCH_JUMP); - patch(0x4EA6F1, iRadioTracks, 4); - patch(0x4EA7A9, iRadioTracks, 4); + InjectHook(0x4EA670, NoRadioCommercialsHack, PATCH_JUMP); + InjectMethod(0x4EA270, CAERadioTrackManager::GetNextTrackByStation, PATCH_JUMP); + Patch(0x4EA6F1, &iRadioTracks); + Patch(0x4EA7A9, &iRadioTracks); - patch(0x4EA76A, iRadioIntros, 4); - patch(0x4EA770, iRadioIntros, 4); + Patch(0x4EA76A, &iRadioIntros); + Patch(0x4EA770, &iRadioIntros); - patch(0x4EA721, iRadioOutros, 4); - patch(0x4EA727, iRadioOutros, 4); - patch(0x4EA7D9, iRadioOutros, 4); - patch(0x4EA7DF, iRadioOutros, 4); - patch(0x4EA841, iRadioOutros, 4); - patch(0x4EA847, iRadioOutros, 4); + Patch(0x4EA721, &iRadioOutros); + Patch(0x4EA727, &iRadioOutros); + Patch(0x4EA7D9, &iRadioOutros); + Patch(0x4EA7DF, &iRadioOutros); + Patch(0x4EA841, &iRadioOutros); + Patch(0x4EA847, &iRadioOutros); - patch(0x4E9584, &iAdvertsRange[1], 4); - patch(0x4E958A, &iAdvertsRange[0], 4); + Patch(0x4E9584, &iAdvertsRange[1]); + Patch(0x4E958A, &iAdvertsRange[0]); - patch(0x4DC13B, iBeatsStreams, 4); + Patch(0x4DC13B, &iBeatsStreams); - patch(0x4EA71E, 2, 1); - patch(0x4EA767, 2, 1); - patch(0x4EA7D6, 2, 1); - patch(0x4EA83E, 2, 1); + Patch(0x4EA71E, 2); + Patch(0x4EA767, 2); + Patch(0x4EA7D6, 2); + Patch(0x4EA83E, 2); static const float fFadeRadius = 0.9f; - patch(0x4D703B, &fFadeRadius, 4); -// nop(0x4D7039, 6); - nop(0x4D6FF0, 2); - - patch(0x4D6ED3, AMBIENCE_OFFSET+1, 4); - patch(0x4D6F74, AMBIENCE_OFFSET+2, 4); - patch(0x4D6F7E, AMBIENCE_OFFSET+3, 4); -// patch(0x4D6F88, AMBIENCE_OFFSET+34, 4); -// patch(0x4D6F94, AMBIENCE_OFFSET+4, 4); - patch(0x4D6F9E, AMBIENCE_OFFSET+4, 4); - patch(0x4D6FB1, CR_OFFSET+1/*AMBIENCE_OFFSET+5*/, 4); - patch(0x4D6FC3, CR_OFFSET+10/*AMBIENCE_OFFSET+22*/, 4); - patch(0x4D6FFC, AMBIENCE_OFFSET+5, 4); -// patch(0x4D7006, AMBIENCE_OFFSET+33, 4); -// patch(0x4D7010, AMBIENCE_OFFSET+27, 4); - patch(0x4D7023, NJ_OFFSET+4/*AMBIENCE_OFFSET+4*/, 4); -// patch(0x4D7063, AMBIENCE_OFFSET+8, 4); -// patch(0x4D70B9, AMBIENCE_OFFSET+9, 4); -// patch(0x4D70C6, AMBIENCE_OFFSET+11, 4); -// patch(0x4D70D0, AMBIENCE_OFFSET+13, 4); -// patch(0x4D70DA, AMBIENCE_OFFSET+17, 4); -// patch(0x4D70E4, AMBIENCE_OFFSET+19, 4); -// patch(0x4D70EE, AMBIENCE_OFFSET+21, 4); -// patch(0x4D70F8, AMBIENCE_OFFSET+23, 4); -// patch(0x4D7102, AMBIENCE_OFFSET+24, 4); -// patch(0x4D7109, AMBIENCE_OFFSET+38, 4); -// patch(0x4D7113, AMBIENCE_OFFSET+27, 4); -// patch(0x4D711A, AMBIENCE_OFFSET+35, 4); -// patch(0x4D7121, AMBIENCE_OFFSET+36, 4); -// patch(0x4D7128, AMBIENCE_OFFSET, 4); -// patch(0x4D712F, AMBIENCE_OFFSET+2, 4); -// patch(0x4D7136, AMBIENCE_OFFSET+16, 4); -// patch(0x4D713D, AMBIENCE_OFFSET+28, 4); - patch(0x4D7378, AMBIENCE_OFFSET, 4); - patch(0x4D73B1, AMBIENCE_OFFSET, 4); -// patch(0x4D74B5, AMBIENCE_OFFSET+31, 4); -// patch(0x4D74D5, AMBIENCE_OFFSET+31, 4); - patch(0x4D7532, AMBIENCE_OFFSET, 4); - - nop(0x5D3F08, 5); - nop(0x5D4108, 5); - - call(0x4E81F3, &CAERadioTrackManager::ResetExtra, PATCH_JUMP); - call(0x5B962B, &RadioResetWrapper, PATCH_JUMP); - call(0x5D40DA, &SaveRadios, PATCH_JUMP); - call(0x5D42DA, &LoadRadios, PATCH_JUMP); - - patch(0x4842CD, sizeof(iBeatsStreams)/sizeof(short) - 3, 1); - - patch(0x4F31A7, 0, 1); + Patch(0x4D703B, &fFadeRadius); +// Nop(0x4D7039, 6); + Nop(0x4D6FF0, 2); + + Patch(0x4D6ED3, AMBIENCE_OFFSET+1); + Patch(0x4D6F74, AMBIENCE_OFFSET+2); + Patch(0x4D6F7E, AMBIENCE_OFFSET+3); +// Patch(0x4D6F88, AMBIENCE_OFFSET+34); +// Patch(0x4D6F94, AMBIENCE_OFFSET+4); + Patch(0x4D6F9E, AMBIENCE_OFFSET+4); + Patch(0x4D6FB1, CR_OFFSET+1/*AMBIENCE_OFFSET+5*/); + Patch(0x4D6FC3, CR_OFFSET+10/*AMBIENCE_OFFSET+22*/); + Patch(0x4D6FFC, AMBIENCE_OFFSET+5); +// Patch(0x4D7006, AMBIENCE_OFFSET+33); +// Patch(0x4D7010, AMBIENCE_OFFSET+27); + Patch(0x4D7023, NJ_OFFSET+4/*AMBIENCE_OFFSET+4*/); +// Patch(0x4D7063, AMBIENCE_OFFSET+8, 4); +// Patch(0x4D70B9, AMBIENCE_OFFSET+9, 4); +// Patch(0x4D70C6, AMBIENCE_OFFSET+11, 4); +// Patch(0x4D70D0, AMBIENCE_OFFSET+13, 4); +// Patch(0x4D70DA, AMBIENCE_OFFSET+17, 4); +// Patch(0x4D70E4, AMBIENCE_OFFSET+19, 4); +// Patch(0x4D70EE, AMBIENCE_OFFSET+21, 4); +// Patch(0x4D70F8, AMBIENCE_OFFSET+23, 4); +// Patch(0x4D7102, AMBIENCE_OFFSET+24, 4); +// Patch(0x4D7109, AMBIENCE_OFFSET+38, 4); +// Patch(0x4D7113, AMBIENCE_OFFSET+27, 4); +// Patch(0x4D711A, AMBIENCE_OFFSET+35, 4); +// Patch(0x4D7121, AMBIENCE_OFFSET+36, 4); +// Patch(0x4D7128, AMBIENCE_OFFSET, 4); +// Patch(0x4D712F, AMBIENCE_OFFSET+2, 4); +// Patch(0x4D7136, AMBIENCE_OFFSET+16, 4); +// Patch(0x4D713D, AMBIENCE_OFFSET+28, 4); + Patch(0x4D7378, AMBIENCE_OFFSET); + Patch(0x4D73B1, AMBIENCE_OFFSET); +// Patch(0x4D74B5, AMBIENCE_OFFSET+31, 4); +// Patch(0x4D74D5, AMBIENCE_OFFSET+31, 4); + Patch(0x4D7532, AMBIENCE_OFFSET); + + Nop(0x5D3F08, 5); + Nop(0x5D4108, 5); + + InjectHook(0x4E81F3, CAERadioTrackManager::ResetExtra, PATCH_JUMP); + InjectHook(0x5B962B, RadioResetWrapper, PATCH_JUMP); + InjectHook(0x5D40DA, SaveRadios, PATCH_JUMP); + InjectHook(0x5D42DA, LoadRadios, PATCH_JUMP); + + Patch(0x4842CD, sizeof(iBeatsStreams)/sizeof(short) - 3); + + Patch(0x4F31A7, 0); // Radio EQ scratched - patch(0x4E9DB5, 0x909000B2, 4); - patch(0x5B9530, 0x90045D88, 4); + Patch(0x4E9DB5, 0x909000B2); + Patch(0x5B9530, 0x90045D88); // Cutscene data - call(0x5B10C0, &SetCutsceneModelHack, PATCH_JUMP); - patch(0x5AFA51, cutsceneStreams, 4); - patch(0x5AFA5A, cutsceneStreams, 4); + InjectHook(0x5B10C0, SetCutsceneModelHack, PATCH_JUMP); + Patch(0x5AFA51, &cutsceneStreams); + Patch(0x5AFA5A, cutsceneStreams); // charptr(0x5B10C1, "csplr"); - nop(0x4D5EA3, 5); - nop(0x4668F4, 2); + Nop(0x4D5EA3, 5); + Nop(0x4668F4, 2); // Fullscreen message menu blue patch(0x574056, 0x6AFF, 2); @@ -2570,10 +2611,10 @@ __forceinline void Main_Patches() call(0x574061, (DWORD)0x7170C0, PATCH_NOTHING); // Own language switch - patch(0x69FCF7, NUM_LANGUAGES - 1, 1); - patch(0x69FCFD, &_CText__loadMission_Jumptable, 4); - patch(0x6A01D4, NUM_LANGUAGES - 1, 1); - patch(0x6A01DA, &_CText__load_Jumptable, 4); + Patch(0x69FCF7, NUM_LANGUAGES - 1); + Patch(0x69FCFD, &_CText__loadMission_Jumptable); + Patch(0x6A01D4, NUM_LANGUAGES - 1); + Patch(0x6A01DA, &_CText__load_Jumptable); #ifdef INCLUDE_MULTIFONTFILES // Multiple font files @@ -2590,6 +2631,7 @@ __forceinline void Main_Patches() // Fonts related things Patch(0x718B6C, 4); Patch(0x718B6F, 0x85); + Patch(0x7199D3, 0x0CEB); Patch(0x71985E, CFont::Sprite); Patch(0x719B08, CFont::Sprite); Patch(0x718797, CFont::Size->bPropValue); @@ -2618,19 +2660,12 @@ __forceinline void Main_Patches() InjectHook(0x74747E, InitialiseLanguage); // SPTA support - /*_asm - { - mov eax, offset CSprite2d::SetTexture - mov dwFunc, eax - } - call(0x7272B0, dwFunc, PATCH_JUMP);*/ InjectHook(0x5900B0, LoadSplashes, PATCH_JUMP); InjectHook(0x58FF60, LoadingScreen, PATCH_JUMP); - Nop(0x53BC3F, 5); // Dirty crashfix - nop(0x574673, 5); - nop(0x5746A0, 5); - nop(0x5746CE, 5); + Nop(0x574673, 5); + Nop(0x5746A0, 5); + Nop(0x5746CE, 5); patch(0x573088, 0xCB8B, 2); call(0x572ED8, 0x57308A, PATCH_JUMP); _asm @@ -2649,24 +2684,19 @@ __forceinline void Main_Patches() // Autoupdater - call(0x53E77C, &CUpdateManager::Process, PATCH_NOTHING); - call(0x748EDA, &CUpdateManager::InstallIfNeeded, PATCH_NOTHING); - call(0x53BF4E, &UpdaterProcessHack, PATCH_NOTHING); - call(0x579526, &UpdaterMenuDrawHack, PATCH_JUMP); - call(0x579D50, &UpdaterTextSwap, PATCH_JUMP); -// call(0x576E13, &MenuToggleHack, PATCH_JUMP -// call(0x573680, &SetToNewMenuHack, PATCH_JUMP); - patch(0x57CD84, MenuActionsTable, 4); - patch(0x57CD8B, MenuActionsAddresses, 4); - patch(0x57CD74, NUM_MENU_ACTIONS-7, 1); - patch(0x573830, 0xCE8B, 2); - patch(0x573832, 0x5E, 1); - _asm - { - mov eax, offset CMenuManager::SwitchToNewScreen - mov dwFunc, eax - } - call(0x573833, dwFunc, PATCH_JUMP); + InjectHook(0x53E77C, CUpdateManager::Process); + InjectHook(0x748EDA, CUpdateManager::InstallIfNeeded); + InjectHook(0x53BF4E, UpdaterProcessHack); + InjectHook(0x579526, UpdaterMenuDrawHack, PATCH_JUMP); + InjectHook(0x579D50, UpdaterTextSwap, PATCH_JUMP); +// InjectHook(0x576E13, MenuToggleHack, PATCH_JUMP +// InjectHook(0x573680, SetToNewMenuHack, PATCH_JUMP); + Patch(0x57CD84, MenuActionsTable); + Patch(0x57CD8B, MenuActionsAddresses); + Patch(0x57CD74, NUM_MENU_ACTIONS-7); + Patch(0x573830, 0xCE8B); + Patch(0x573832, 0x5E); + InjectMethod(0x573833, CMenuManager::SwitchToNewScreenVCS, PATCH_JUMP); static DWORD dwDummy; // Savegame compatibility @@ -2678,22 +2708,22 @@ __forceinline void Main_Patches() call(0x579434, (DWORD)0x53D840, PATCH_CALL); patch(0x5D334F, 0x08EB, 2); patch(0x5D327E, &dwDummy, 4); - nop(0x5D0887, 2); - nop(0x5D150C, 5); - nop(0x5D1516, 5); - nop(0x5D1520, 5); - nop(0x5D1538, 5); + Nop(0x5D0887, 2); + Nop(0x5D150C, 5); + Nop(0x5D1516, 5); + Nop(0x5D1520, 5); + Nop(0x5D1538, 5); // Stats - need map! - nop(0x5D1560, 5); - nop(0x5D157C, 5); - - nop(0x5D0897, 2); - nop(0x5D1934, 5); - nop(0x5D193E, 5); - nop(0x5D1948, 5); - nop(0x5D1960, 5); - nop(0x5D1988, 5); - nop(0x5D19A4, 5); + Nop(0x5D1560, 5); + Nop(0x5D157C, 5); + + Nop(0x5D0897, 2); + Nop(0x5D1934, 5); + Nop(0x5D193E, 5); + Nop(0x5D1948, 5); + Nop(0x5D1960, 5); + Nop(0x5D1988, 5); + Nop(0x5D19A4, 5); patch(0x579439, 0x90000CC2, 4); call(0x53C71F, &LoadGameFailedMessage_Inject, PATCH_JUMP); @@ -2713,8 +2743,8 @@ __forceinline void Main_Patches() call(0x6191E4, &CFileMgr::Seek, PATCH_NOTHING); call(0x6191F7, &CFileMgr::Read, PATCH_NOTHING); call(0x61923C, &CFileMgr::CloseFile, PATCH_NOTHING); - nop(0x5D18D8, 5); - nop(0x5D1EA9, 2); + Nop(0x5D18D8, 5); + Nop(0x5D1EA9, 2); // Frame Limiter patch(0x53E923, 0x42EB56, 4); @@ -2727,9 +2757,9 @@ __forceinline void Main_Patches() call(0x579EF3, &FrameLimit_StringInject, PATCH_NOTHING); call(0x57CD05, &FrameLimit_SetFPS, PATCH_JUMP); /*call(0x573BB8, &FrameLimit_SetFPS2, PATCH_CALL); - nop(0x573BBD, 1);*/ + Nop(0x573BBD, 1);*/ call(0x573BF0, &FrameLimit_SetFPS2, PATCH_JUMP); - nop(0x573BB8, 3); + Nop(0x573BB8, 3); // No green blip patch(0x53E1EC, 0xEB, 1); @@ -2791,37 +2821,42 @@ __forceinline void Main_Patches() patch(0x8562B0, 0xC3, 1); patch(0x4C6517, 0x22EB, 2); - nop(0x4C6857, 7); + Nop(0x4C6857, 7); - call(0x5B74A7, &CModelInfo::AddPedModel, PATCH_NOTHING); + InjectHook(0x5B74A7, CModelInfo::AddPedModel); + InjectHook(0x5B3F32, CModelInfo::AddTimeModel); + Patch(0x4C491B, offsetof(CDamageAtomicModelInfo, pAtomic2)); + Patch(0x4C496E, offsetof(CDamageAtomicModelInfo, pAtomic2)); + Patch(0x4C48D8, offsetof(CDamageAtomicModelInfo, pAtomic2)); - /*patch(0x4C640B, &CModelInfo::ms_clumpModelStore.m_NumObjects, 4); - patch(0x4C6428, &CModelInfo::ms_clumpModelStore.m_NumObjects, 4); - patch(0x4C6651, &CModelInfo::ms_clumpModelStore.m_NumObjects, 4); - patch(0x4C6662, &CModelInfo::ms_clumpModelStore.m_NumObjects, 4); - patch(0x4C682F, &CModelInfo::ms_clumpModelStore.m_NumObjects, 4); - //patch(0x84BC11, &CModelInfo::ms_clumpModelStore, 4); - //patch(c, &CModelInfo::ms_clumpModelStore, 4); + /*patch(0x4C640B, &CModelInfo::ms_damageAtomicModelStore.m_NumObjects, 4); + patch(0x4C6428, &CModelInfo::ms_damageAtomicModelStore.m_NumObjects, 4); + patch(0x4C6651, &CModelInfo::ms_damageAtomicModelStore.m_NumObjects, 4); + patch(0x4C6662, &CModelInfo::ms_damageAtomicModelStore.m_NumObjects, 4); + patch(0x4C682F, &CModelInfo::ms_damageAtomicModelStore.m_NumObjects, 4); + //patch(0x84BC11, &CModelInfo::ms_damageAtomicModelStore, 4); + //patch(c, &CModelInfo::ms_damageAtomicModelStore, 4); - patch(0x4C6416, &CModelInfo::ms_clumpModelStore.m_Objects, 4); - patch(0x4C665D, &CModelInfo::ms_clumpModelStore.m_Objects, 4); + patch(0x4C6416, &CModelInfo::ms_damageAtomicModelStore.m_Objects, 4); + patch(0x4C665D, &CModelInfo::ms_damageAtomicModelStore.m_Objects, 4); //patch(0x4C5D1C, NUM_CLUMP_MODELS, 1); //patch(0x4C5866, NUM_CLUMP_MODELS, 1);*/ - patch(0x84BC10, 0xC3, 1); - patch(0x856240, 0xC3, 1); + Patch(0x84BC10, 0xC3); + Patch(0x856240, 0xC3); patch(0x4C64C8, 0x22EB, 2); - nop(0x4C684B, 7); + Nop(0x4C684B, 7); - call(0x5B3D8E, &CModelInfo::AddClumpModel, PATCH_NOTHING); + //call(0x5B3D8E, &CModelInfo::AddDamageAtomicModel, PATCH_NOTHING); + InjectHook(0x5B85DD, CFileLoader::LoadObject); - call(0x4C6616, &CModelInfo::ShutDown, PATCH_JUMP); + InjectHook(0x4C6616, CModelInfo::ShutDown, PATCH_JUMP); // Old style Rhino - patch(0x6A80CA, &fRhinoHitStrength, 4); + Patch(0x6A80CA, &fRhinoHitStrength); // SF weather patch(0x72A640, 0xE9, 1); @@ -2951,16 +2986,20 @@ __forceinline void Main_Patches() patch(0x577370, &StatsMenuActionHack, 4); // Brightness - patchf(0x573B8A, 96.0 / 512.0); - patch(0x573B96, 96, 4); - patch(0x57A8A9, &fBrightnessStep, 4); - patch(0x573487, &fBrightnessStep2, 4); - patch(0x5734AD, &fBrightnessMax, 4); - patch(0x5734BC, &fBrightnessMax, 4); + Patch(0x573B8A, 96.0 / 512.0); + Patch(0x573B96, 96); + Patch(0x57A8A9, &fBrightnessStep); + Patch(0x573487, &fBrightnessStep2); + Patch(0x5734AD, &fBrightnessMax); + Patch(0x5734BC, &fBrightnessMax); // Widescreen - nop(0x745BC9, 2); - nop(0x7459E1, 2); + Patch(0x745B71, 0x9090687D); + Patch(0x74596C, 0x9090127D); + Nop(0x745970, 2); + Nop(0x745B75, 2); + //Nop(0x745BC9, 2); + Nop(0x7459E1, 2); // call(0x5BD61A, &CamHack, PATCH_JUMP); @@ -2970,9 +3009,9 @@ __forceinline void Main_Patches() GetWindowRect(GetDesktopWindow(), &desktop); _snprintf(aNoDesktopMode, sizeof(aNoDesktopMode), "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); - patch(0x746363, desktop.right, 4); - patch(0x746368, desktop.bottom, 4); - patch(0x7463C8, aNoDesktopMode, 4); + Patch(0x746363, desktop.right); + Patch(0x746368, desktop.bottom); + Patch(0x7463C8, aNoDesktopMode); // BINK video player call(0x748AFA, &VideoPlayerCreate1, PATCH_JUMP); @@ -2995,25 +3034,29 @@ __forceinline void Main_Patches() call(0x7488FB, &ReadCommandlineFile, PATCH_JUMP); // DLC support - patch(0x5BF8B2, CFileLoader::GetParticlesPath(), 4); - patch(0x5BCFF7, CFileLoader::GetPedgrpPath(), 4); - patch(0x5BC0AA, CFileLoader::GetPopcyclePath(), 4); - patch(0x5BBADA, CFileLoader::GetTimecycPath(), 4); + Patch(0x5BF8B2, CFileLoader::GetParticlesPath()); + Patch(0x5BCFF7, CFileLoader::GetPedgrpPath()); + Patch(0x5BC0AA, CFileLoader::GetPopcyclePath()); + Patch(0x5BBADA, CFileLoader::GetTimecycPath()); - //nop(0x53BC8B, 5); + //Nop(0x53BC8B, 5); //call(0x53BC95, &CDLCManager::LoadLevelFiles, PATCH_CALL); - call(0x748C3F, &LoadGameWithDLCHack, PATCH_NOTHING); - call(0x53BC95, &CFileLoader::ParseLevelFile, PATCH_CALL); - call(0x53BC9B, &CFileLoader::ParseLevelFile, PATCH_CALL); - call(0x53BCA0, &CFileLoader::LoadLevels, PATCH_CALL); - patch(0x5B9299, 0xC3, 1); - nop(0x5B931E, 3); - nop(0x5BCFEC, 5); - nop(0x5BD00B, 5); - nop(0x5BC09F, 5); - nop(0x5BC0BE, 5); - nop(0x5BBACF, 5); - nop(0x5BBAEA, 5); + InjectHook(0x748C3F, LoadGameWithDLCHack); + InjectHook(0x53BC95, CFileLoader::ParseLevelFile, PATCH_CALL); + InjectHook(0x53BC9B, CFileLoader::ParseLevelFile, PATCH_CALL); + InjectHook(0x53BCA0, CFileLoader::LoadLevels, PATCH_CALL); + Patch(0x5B9299, 0xC3); + Nop(0x5B931E, 3); + Nop(0x5BCFEC, 5); + Nop(0x5BD00B, 5); + Nop(0x5BC09F, 5); + Nop(0x5BC0BE, 5); + Nop(0x5BBACF, 5); + Nop(0x5BBAEA, 5); + + // ColAccel + //InjectHook(0x53BC8B, CColAccel::startCache); + //Patch(0x5B2BA1, 0x30EB); // Pools fixes InjectHook(0x4048E0, VehiclePoolGetAt, PATCH_JUMP); @@ -3055,7 +3098,7 @@ __forceinline void Main_Patches() // -//- related to sliders _asm { - mov eax, offset CMenuManager::DrawSliders + mov eax, offset CMenuManager::DisplaySlider mov dwFunc, eax } call(0x576860, dwFunc, PATCH_JUMP); @@ -3187,11 +3230,11 @@ __forceinline void Main_Patches() // call(0x58C0BB, &Widescreen_TextDrawsFix, PATCH_CALL); call(0x58C1EC, &Widescreen_TextDrawsFix2, PATCH_JUMP); patch(0x58BB8D, 0x05EB, 2); - nop(0x58C3CD, 1); -// nop(0x714846, 1); - nop(0x514D68, 1); - nop(0x53E2AD, 2); -// nop(0x58C0C0, 1); + Nop(0x58C3CD, 1); +// Nop(0x714846, 1); + Nop(0x514D68, 1); + Nop(0x53E2AD, 2); +// Nop(0x58C0C0, 1); // 64 radar tiles dwFunc = *(DWORD*)0x584C98; @@ -3287,7 +3330,7 @@ __forceinline void Main_Patches() // No arrow.txd patch(0x57A511, 0xDBE9, 4); - nop(0x57A516, 1); + Nop(0x57A516, 1); // .set versioning #if SET_FILE_VERSION != 6 && !defined DEVBUILD @@ -3301,24 +3344,20 @@ __forceinline void Main_Patches() // patch(0x585CD4, 0x40400000, 4); // 3.0 // Steady crosshair - _asm - { - mov eax, offset CPed::GetCrosshairSize - mov dwFunc, eax - } - call(0x58E26C, dwFunc, PATCH_NOTHING); + InjectMethod(0x58E26C, CPed::GetCrosshairSize, PATCH_NOTHING); // No plane radar stuff - call(0x58A3AA, 0x58A5A8, PATCH_JUMP); - patch(0x5869D2, 0xE990, 2); + InjectHook(0x58A3AA, 0x58A5A8, PATCH_JUMP); + Patch(0x5869D2, 0xE990); + Nop(0x5880B1, 5); // VCS radar colours - call(0x584770, &CRadar::GetRadarTraceColour, PATCH_JUMP); - patch(0x5838B6, 5, 4); - patch(0x583A17, 0, 4); + InjectHook(0x584770, CRadar::GetRadarTraceColour, PATCH_JUMP); + Patch(0x5838B6, 5); + Patch(0x583A17, 0); // No Tab stats - patch(0x58FC2C, 0xEB, 1); + Patch(0x58FC2C, 0xEB); // FPS meter & gridref stuff patch(0x58FD0E, 0xE8, 1); @@ -3337,18 +3376,18 @@ __forceinline void Main_Patches() patch(0x590478, 2, 1); //patch(0x590D2B, 93, 4); //patch(0x590D68, 93, 4); - call(0x590480, &CHud::DrawSquareBar, PATCH_NOTHING); + InjectHook(0x590480, CHud::DrawSquareBar); // One loading music - patch(0x5B9B1F, 0xC030, 2); - nop(0x5B9B21, 3); -// nop(0x748CF6, 5); + Patch(0x5B9B1F, 0xC030); + Nop(0x5B9B21, 3); +// Nop(0x748CF6, 5); // No player.img & clothes.dat - nop(0x5A834D, 5); + Nop(0x5A834D, 5); // No hunger - nop(0x5700F0, 5); + Nop(0x5700F0, 5); // HUD.txd stuff /*patch(0x588852, &hudTextures, 4); @@ -3375,14 +3414,14 @@ __forceinline void Main_Patches() // No stream.ini, gta3.ini and clothes stuff - nop(0x5BA215, 5); - nop(0x5BF865, 5); - nop(0x5BF996, 5); - nop(0x5A8227, 5); -// nop(0x5B8F21, 5); + Nop(0x5BA215, 5); + Nop(0x5BF865, 5); + Nop(0x5BF996, 5); + Nop(0x5A8227, 5); +// Nop(0x5B8F21, 5); // No peds.col - nop(0x5BD606, 5); + Nop(0x5BD606, 5); // Ped colors! call(0x5E7687, &InjectPedMapping, PATCH_JUMP); @@ -3406,7 +3445,7 @@ __forceinline void Main_Patches() // patch(0x4406DF, 0xAE, 1); // patch(0x, 0xD230, 2); // patch(0x748E69, 0xEB, 1); - call(0x748E6B, &TempExitFix, PATCH_NOTHING); // Temporary fix + //call(0x748E6B, &TempExitFix, PATCH_NOTHING); // Temporary fix call(0x4083C0, &CdStreamClearNames, PATCH_JUMP); patch(0x53BB60, NUM_IMG_FILES, 1); patch(0x406B75, NUM_STREAMS, 4); @@ -3451,8 +3490,8 @@ __forceinline void Main_Patches() patch(0x406B81, gStreamNames, 4); patch(0x406B98, &gStreamNames[NUM_STREAMS+1], 4); charptr(0x406C2B, "ANIM\\ANIM.IMG"); -// nop(0x43E65D, 2); -// nop(0x43E669, 2); +// Nop(0x43E65D, 2); +// Nop(0x43E669, 2); #ifdef INCLUDE_STREAMING_TEXT call(0x40E120, &CStreaming::MakeSpaceFor, PATCH_JUMP); #endif @@ -3467,12 +3506,12 @@ __forceinline void Main_Patches() Another: 0x450A60 and nearby 0x554D8D*/ - patch(0x5B527C, &fNewDrawDistance, 4); - patch(0x5545E8, &fNewDrawDistance, 4); - patch(0x554602, &fNewDrawDistance, 4); - patch(0x55462C, &fNewDrawDistance, 4); - patchf(0x554D93, MAX_DRAW_DISTANCE); - patchf(0x555A74, MAX_DRAW_DISTANCE); + Patch(0x5B527C, &fNewDrawDistance); + Patch(0x5545E8, &fNewDrawDistance); + Patch(0x554602, &fNewDrawDistance); + Patch(0x55462C, &fNewDrawDistance); + Patch(0x554D93, MAX_DRAW_DISTANCE); + Patch(0x555A74, MAX_DRAW_DISTANCE); // 12 save slots patch(0x619166, SlotSaveDate, 4); @@ -3506,74 +3545,74 @@ __forceinline void Main_Patches() //patch(0x579D52, ACTION_JOYMOUSE, 1); patch(0x57B6F5, ACTION_CLICKORARROWS, 1); - patch(0x57344F, sizeof(MenuItem), 4); - patch(0x5736FD, sizeof(MenuItem), 4); - patch(0x573703, sizeof(MenuItem), 4); - patch(0x57371B, sizeof(MenuItem), 4); - patch(0x573730, sizeof(MenuItem), 4); - patch(0x573745, sizeof(MenuItem), 4); - patch(0x573768, sizeof(MenuItem), 4); - patch(0x573E93, sizeof(MenuItem), 4); - patch(0x576B02, sizeof(MenuItem), 4); - patch(0x576B18, sizeof(MenuItem), 4); - patch(0x576B30, sizeof(MenuItem), 4); - patch(0x576B4F, sizeof(MenuItem), 4); - patch(0x57700A, sizeof(MenuItem), 4); - patch(0x579562, sizeof(MenuItem), 4); - patch(0x579678, sizeof(MenuItem), 4); - patch(0x5796A9, sizeof(MenuItem), 4); - patch(0x57981A, sizeof(MenuItem), 4); - patch(0x5798D0, sizeof(MenuItem), 4); - patch(0x579AAA, sizeof(MenuItem), 4); - patch(0x579AD7, sizeof(MenuItem), 4); - patch(0x579B24, sizeof(MenuItem), 4); - patch(0x579B52, sizeof(MenuItem), 4); - patch(0x579B69, sizeof(MenuItem), 4); - patch(0x579C78, sizeof(MenuItem), 4); - patch(0x579D14, sizeof(MenuItem), 4); - patch(0x579D37, sizeof(MenuItem), 4); - patch(0x579D8B, sizeof(MenuItem), 4); - patch(0x57A182, sizeof(MenuItem), 4); - patch(0x57A22E, sizeof(MenuItem), 4); - patch(0x57A397, sizeof(MenuItem), 4); - patch(0x57A44D, sizeof(MenuItem), 4); - patch(0x57A543, sizeof(MenuItem), 4); - patch(0x57A60B, sizeof(MenuItem), 4); - patch(0x57A653, sizeof(MenuItem), 4); - patch(0x57A69B, sizeof(MenuItem), 4); - patch(0x57A6DC, sizeof(MenuItem), 4); - patch(0x57A71F, sizeof(MenuItem), 4); - patch(0x57A772, sizeof(MenuItem), 4); - patch(0x57A7B6, sizeof(MenuItem), 4); - patch(0x57B277, sizeof(MenuItem), 4); - patch(0x57B4E4, sizeof(MenuItem), 4); - patch(0x57B50D, sizeof(MenuItem), 4); - patch(0x57B582, sizeof(MenuItem), 4); - patch(0x57B5BD, sizeof(MenuItem), 4); - patch(0x57B61F, sizeof(MenuItem), 4); - patch(0x57B692, sizeof(MenuItem), 4); - patch(0x57B6E7, sizeof(MenuItem), 4); - patch(0x57C30D, sizeof(MenuItem), 4); - patch(0x57CD60, sizeof(MenuItem), 4); - patch(0x57D281, sizeof(MenuItem), 4); - patch(0x57D2CA, sizeof(MenuItem), 4); - patch(0x57D6D3, sizeof(MenuItem), 4); - patch(0x57D6FB, sizeof(MenuItem), 4); - patch(0x57E3EC, sizeof(MenuItem), 4); - patch(0x57FDF9, sizeof(MenuItem), 4); - patch(0x57FE4B, sizeof(MenuItem), 4); - patch(0x57FE8A, sizeof(MenuItem), 4); - patch(0x57FF54, sizeof(MenuItem), 4); - patch(0x57FFA4, sizeof(MenuItem), 4); - patch(0x58030B, sizeof(MenuItem), 4); - patch(0x58048B, sizeof(MenuItem), 4); - patch(0x5804E0, sizeof(MenuItem), 4); - patch(0x5805C8, sizeof(MenuItem), 4); - - patch(0x57B29A, NUM_ENTRIES_PER_MENU, 1); - patch(0x57FED9, NUM_ENTRIES_PER_MENU, 1); - patch(0x57B521, NUM_ENTRIES_PER_MENU, 1); - patch(0x57B5D2, NUM_ENTRIES_PER_MENU - 1, 4); + Patch(0x57344F, sizeof(MenuItem)); + Patch(0x5736FD, sizeof(MenuItem)); + Patch(0x573703, sizeof(MenuItem)); + Patch(0x57371B, sizeof(MenuItem)); + Patch(0x573730, sizeof(MenuItem)); + Patch(0x573745, sizeof(MenuItem)); + Patch(0x573768, sizeof(MenuItem)); + Patch(0x573E93, sizeof(MenuItem)); + Patch(0x576B02, sizeof(MenuItem)); + Patch(0x576B18, sizeof(MenuItem)); + Patch(0x576B30, sizeof(MenuItem)); + Patch(0x576B4F, sizeof(MenuItem)); + Patch(0x57700A, sizeof(MenuItem)); + Patch(0x579562, sizeof(MenuItem)); + Patch(0x579678, sizeof(MenuItem)); + Patch(0x5796A9, sizeof(MenuItem)); + Patch(0x57981A, sizeof(MenuItem)); + Patch(0x5798D0, sizeof(MenuItem)); + Patch(0x579AAA, sizeof(MenuItem)); + Patch(0x579AD7, sizeof(MenuItem)); + Patch(0x579B24, sizeof(MenuItem)); + Patch(0x579B52, sizeof(MenuItem)); + Patch(0x579B69, sizeof(MenuItem)); + Patch(0x579C78, sizeof(MenuItem)); + Patch(0x579D14, sizeof(MenuItem)); + Patch(0x579D37, sizeof(MenuItem)); + Patch(0x579D8B, sizeof(MenuItem)); + Patch(0x57A182, sizeof(MenuItem)); + Patch(0x57A22E, sizeof(MenuItem)); + Patch(0x57A397, sizeof(MenuItem)); + Patch(0x57A44D, sizeof(MenuItem)); + Patch(0x57A543, sizeof(MenuItem)); + Patch(0x57A60B, sizeof(MenuItem)); + Patch(0x57A653, sizeof(MenuItem)); + Patch(0x57A69B, sizeof(MenuItem)); + Patch(0x57A6DC, sizeof(MenuItem)); + Patch(0x57A71F, sizeof(MenuItem)); + Patch(0x57A772, sizeof(MenuItem)); + Patch(0x57A7B6, sizeof(MenuItem)); + Patch(0x57B277, sizeof(MenuItem)); + Patch(0x57B4E4, sizeof(MenuItem)); + Patch(0x57B50D, sizeof(MenuItem)); + Patch(0x57B582, sizeof(MenuItem)); + Patch(0x57B5BD, sizeof(MenuItem)); + Patch(0x57B61F, sizeof(MenuItem)); + Patch(0x57B692, sizeof(MenuItem)); + Patch(0x57B6E7, sizeof(MenuItem)); + Patch(0x57C30D, sizeof(MenuItem)); + Patch(0x57CD60, sizeof(MenuItem)); + Patch(0x57D281, sizeof(MenuItem)); + Patch(0x57D2CA, sizeof(MenuItem)); + Patch(0x57D6D3, sizeof(MenuItem)); + Patch(0x57D6FB, sizeof(MenuItem)); + Patch(0x57E3EC, sizeof(MenuItem)); + Patch(0x57FDF9, sizeof(MenuItem)); + Patch(0x57FE4B, sizeof(MenuItem)); + Patch(0x57FE8A, sizeof(MenuItem)); + Patch(0x57FF54, sizeof(MenuItem)); + Patch(0x57FFA4, sizeof(MenuItem)); + Patch(0x58030B, sizeof(MenuItem)); + Patch(0x58048B, sizeof(MenuItem)); + Patch(0x5804E0, sizeof(MenuItem)); + Patch(0x5805C8, sizeof(MenuItem)); + + Patch(0x57B29A, NUM_ENTRIES_PER_MENU); + Patch(0x57FED9, NUM_ENTRIES_PER_MENU); + Patch(0x57B521, NUM_ENTRIES_PER_MENU); + Patch(0x57B5D2, NUM_ENTRIES_PER_MENU - 1); // Menu mouse hax _asm @@ -3593,10 +3632,10 @@ __forceinline void Main_Patches() patch(0x57FE92, 0x3A8C8D90, 4); patch(0x57FE62, 0x0C89, 2); patch(0x57FE64, 0x24, 1); - nop(0x57FE5B, 4); - nop(0x57FE65, 6); - nop(0x57FE9A, 7); - nop(0x57FEA2, 9); + Nop(0x57FE5B, 4); + Nop(0x57FE65, 6); + Nop(0x57FE9A, 7); + Nop(0x57FEA2, 9); // No "To stop Carl..." message patch(0x63E8DF, 0xEB, 1); @@ -3611,21 +3650,21 @@ __forceinline void Main_Patches() patch(0x72C1B7, 0xEB, 1); // arrow.dff as marker - patch(0x725636, C3DMarkers::GetPosZMult(), 4); - patch(0x7259A1, C3DMarkers::GetPosZMult(), 4); - patch(0x72564B, C3DMarkers::GetMovingMult(), 4); - patch(0x7259A9, C3DMarkers::GetMovingMult(), 4); - nop(0x72563A, 6); - nop(0x72599F, 6); - nop(0x72502B, 6); - nop(0x725647, 2); - call(0x725037, &InjectArrowMarker, PATCH_NOTHING); - patch(0x726DA6, 5, 1); + Patch(0x725636, C3DMarkers::GetPosZMult()); + Patch(0x7259A1, C3DMarkers::GetPosZMult()); + Patch(0x72564B, C3DMarkers::GetMovingMult()); + Patch(0x7259A9, C3DMarkers::GetMovingMult()); + Nop(0x72563A, 6); + Nop(0x72599F, 6); + Nop(0x72502B, 6); + Nop(0x725647, 2); + InjectHook(0x725037, InjectArrowMarker); + Patch(0x726DA6, 5); // Arrow sizes - patchf(0x585DA5, 2.5); // Vehicles - patchf(0x585E4D, 1.5); // Peds - patchf(0x585F8E, 1.0); // Objects + Patch(0x585DA5, 2.5f); // Vehicles + Patch(0x585E4D, 1.5f); // Peds + Patch(0x585F8E, 1.0f); // Objects // Coronas stored in a vector InjectHook(0x6FC180, CCoronas::RegisterCorona, PATCH_JUMP); @@ -3634,12 +3673,8 @@ __forceinline void Main_Patches() //InjectHook(0x5BA306, CCoronas::Init); // Own BaseColors::BaseColors - _asm - { - mov eax, offset CRGBA::BaseColors__Constructor - mov dwFunc, eax - } - call(0x84F1F5, dwFunc, PATCH_NOTHING); + // TODO: Come up with something nicer? + InjectMethod(0x84F1F5, CRGBA::BaseColors__Constructor, PATCH_NOTHING); // Weapon sounds // Beretta @@ -3696,7 +3731,7 @@ __forceinline void Main_Patches() patch(0x4DDD7E, 0x1A, 1); // All time blur - /*nop(0x704D6C, 2); + /*Nop(0x704D6C, 2); patch(0x704D6F, 0, 4); call(0x704D73, 0x7030A0, PATCH_NOTHING); blurStages[0].fValueToActivate = 0.0; @@ -3776,330 +3811,109 @@ __forceinline void PatchMenus() #ifdef LIST_MEMORY ListMemory(); #endif - patch(0x57345A, &MenuEntriesList->entryList->action, 4); - patch(0x57370A, &MenuEntriesList->startingMenuEntry, 4); - patch(0x573713, &MenuEntriesList->prevMenu, 4); - patch(0x573728, &MenuEntriesList->prevMenu, 4); - patch(0x57373D, &MenuEntriesList->prevMenu, 4); - patch(0x573752, &MenuEntriesList->prevMenu, 4); - patch(0x573772, &MenuEntriesList->entryList->targetMenu, 4); - patch(0x573EA9, &MenuEntriesList->entryList->action, 4); - patch(0x576B08, &MenuEntriesList->entryList[1].targetMenu, 4); - patch(0x576B1E, &MenuEntriesList->entryList[1].targetMenu, 4); - patch(0x576B38, MenuEntriesList, 4); - patch(0x576B58, &MenuEntriesList->entryList->entry, 4); - patch(0x577017, &MenuEntriesList->entryList->action, 4); - patch(0x57723D, &MenuEntriesList->entryList->targetMenu, 4); - patch(0x577280, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x5772F2, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x579568, MenuEntriesList, 4); - patch(0x57967E, MenuEntriesList, 4); - patch(0x5796AF, &MenuEntriesList->entryList->action, 4); - patch(0x57981F, &MenuEntriesList->entryList->entry, 4); - patch(0x5798D6, &MenuEntriesList->entryList->action, 4); - patch(0x5798FC, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x579AB2, &MenuEntriesList->entryList->align, 4); - patch(0x579AE4, &MenuEntriesList->entryList->posX, 4); - patch(0x579AEE, &MenuEntriesList->entryList->posY, 4); - patch(0x579AF7, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x579B10, &MenuEntriesList->name[4], 4); - patch(0x579B17, &MenuEntriesList->entryList->posX, 4); - patch(0x579B2E, &MenuEntriesList->name[6], 4); - patch(0x579B3A, &MenuEntriesList->entryList->posY, 4); - patch(0x579B43, &MenuEntriesList->entryList->posX, 4); - patch(0x579B5A, &MenuEntriesList->entryList->posY, 4); - patch(0x579B70, &MenuEntriesList->entryList->action, 4); - patch(0x579B7A, &MenuEntriesList->entryList->action, 4); - patch(0x579B8B, &MenuEntriesList->entryList->entry, 4); - patch(0x579B9F, &MenuEntriesList->entryList->specialDescFlag, 4); - //patch(0x579BC3, &MenuEntriesList->entryList->posX, 4); - //patch(0x579C83, &MenuEntriesList->entryList->posX, 4); - patch(0x579D20, &MenuEntriesList->entryList->action, 4); - patch(0x579D3F, &MenuEntriesList->name[6], 4); - patch(0x579D4A, &MenuEntriesList->entryList->posY, 4); - patch(0x579D93, &MenuEntriesList->entryList->action, 4); - //patch(0x57A18A, &MenuEntriesList->entryList->posY, 4); - //patch(0x57A1BD, &MenuEntriesList->entryList->posX, 4); - patch(0x57A235, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x57A39F, &MenuEntriesList->entryList->posY, 4); - patch(0x57A455, &MenuEntriesList->entryList->align, 4); - patch(0x57A469, &MenuEntriesList->entryList->posX, 4); - patch(0x57A4B9, &MenuEntriesList->entryList->posX, 4); - patch(0x57A4DA, &MenuEntriesList->entryList->posX, 4); - patch(0x57A54F, &MenuEntriesList->entryList->posY, 4); - patch(0x57A615, &MenuEntriesList->entryList->entry, 4); - patch(0x57A65D, &MenuEntriesList->entryList->entry, 4); - patch(0x57A6A5, &MenuEntriesList->entryList->entry, 4); - patch(0x57A6E6, &MenuEntriesList->entryList->entry, 4); - patch(0x57A729, &MenuEntriesList->entryList->entry, 4); - patch(0x57A77C, &MenuEntriesList->entryList->entry, 4); - patch(0x57A7BE, &MenuEntriesList->entryList->action, 4); - patch(0x57B27E, &MenuEntriesList->entryList->action, 4); - patch(0x57B4F2, &MenuEntriesList->entryList->action, 4); - patch(0x57B519, &MenuEntriesList->entryList->action, 4); - patch(0x57B52A, &MenuEntriesList->entryList->action, 4); - patch(0x57B534, &MenuEntriesList->entryList->action, 4); - patch(0x57B588, &MenuEntriesList->entryList->action, 4); - patch(0x57B5A4, &MenuEntriesList->entryList->action, 4); - patch(0x57B5C9, &MenuEntriesList->entryList->action, 4); - patch(0x57B5E9, &MenuEntriesList->entryList[1].action, 4); - patch(0x57B601, &MenuEntriesList->entryList->action, 4); - patch(0x57B629, &MenuEntriesList->entryList->action, 4); - patch(0x57B69C, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x57B6F1, &MenuEntriesList->entryList->specialDescFlag, 4); - patch(0x57C313, &MenuEntriesList->entryList->action, 4); - patch(0x57CD6B, &MenuEntriesList->entryList->action, 4); - patch(0x57D26C, &MenuEntriesList->entryList[2].targetMenu, 4); - patch(0x57D287, &MenuEntriesList->entryList[2].targetMenu, 4); - patch(0x57D2D2, &MenuEntriesList->entryList[2].targetMenu, 4); - patch(0x57D6D8, &MenuEntriesList->entryList->entry, 4); - patch(0x57D701, &MenuEntriesList->entryList->entry, 4); - patch(0x57E3F7, &MenuEntriesList->entryList->action, 4); - patch(0x57FE0A, &MenuEntriesList->entryList->action, 4); - patch(0x57FE25, &MenuEntriesList->entryList->entry, 4); - //patch(0x57FE57, &MenuEntriesList->entryList->posY, 4); - //patch(0x57FE96, &MenuEntriesList->entryList->posY, 4); - patch(0x57FF5F, &MenuEntriesList->entryList->action, 4); - patch(0x57FFAE, &MenuEntriesList->entryList->action, 4); - patch(0x580316, &MenuEntriesList->entryList->action, 4); - patch(0x580496, &MenuEntriesList->entryList->action, 4); - patch(0x5804EB, &MenuEntriesList->entryList->action, 4); - patch(0x5805D3, &MenuEntriesList->entryList->action, 4); - - patch(0x57FE57, &MenuEntriesList->entryList, 4); - patch(0x57FE96, &MenuEntriesList->entryList, 4); - - // Stats menu - /*MenuEntriesList[0].entryList[0].action = 0x15; - strncpy(MenuEntriesList[0].entryList[0].entry, "FEDS_TB", 8); - MenuEntriesList[0].entryList[0].specialDescFlag = 0xC; - MenuEntriesList[0].entryList[0].targetMenu = 0; - MenuEntriesList[0].entryList[0].posX = 320; - MenuEntriesList[0].entryList[0].posY = 380; - MenuEntriesList[0].entryList[0].align = 3; -// MenuEntriesList[0].entryList[0].field_11 = 0; - - // Select language menu - - // English - MenuEntriesList[28].entryList[LANG_English].action = 0x25; - strncpy(MenuEntriesList[28].entryList[LANG_English].entry, "FEL_ENG", 8); - MenuEntriesList[28].entryList[LANG_English].specialDescFlag = 0; - MenuEntriesList[28].entryList[LANG_English].targetMenu = 28; - MenuEntriesList[28].entryList[LANG_English].posX = 320; - MenuEntriesList[28].entryList[LANG_English].posY = 132 + LANG_English * 30; - MenuEntriesList[28].entryList[LANG_English].align = 3; -// MenuEntriesList[28].entryList[LANG_English].field_11 = 0; - - // Spanish - /*MenuEntriesList[28].entryList[LANG_Spanish].action = 0x25 + LANG_Spanish; - strncpy(MenuEntriesList[28].entryList[LANG_Spanish].entry, "FEL_SPA", 8); - MenuEntriesList[28].entryList[LANG_Spanish].specialDescFlag = 0xB; - MenuEntriesList[28].entryList[LANG_Spanish].targetMenu = 28; - MenuEntriesList[28].entryList[LANG_Spanish].posX = 320; - MenuEntriesList[28].entryList[LANG_Spanish].posY = 132 + LANG_Spanish * 30; - MenuEntriesList[28].entryList[LANG_Spanish].align = 3;*/ -// MenuEntriesList[28].entryList[LANG_Spanish].field_11 = 0; - - // Polish - /*MenuEntriesList[28].entryList[LANG_Polish].action = 0x25 + LANG_Polish; - strncpy(MenuEntriesList[28].entryList[LANG_Polish].entry, "FEL_POL", 8); - MenuEntriesList[28].entryList[LANG_Polish].specialDescFlag = 0xB; - MenuEntriesList[28].entryList[LANG_Polish].targetMenu = 28; - MenuEntriesList[28].entryList[LANG_Polish].posX = 320; - MenuEntriesList[28].entryList[LANG_Polish].posY = 132 + LANG_Polish * 30; - MenuEntriesList[28].entryList[LANG_Polish].align = 3; -// MenuEntriesList[28].entryList[LANG_Polish].field_11 = 0; - - // BACK button - MenuEntriesList[28].entryList[NUM_LANGUAGES].action = 0x2; - strncpy(MenuEntriesList[28].entryList[NUM_LANGUAGES].entry, "FEDS_TB", 8); - MenuEntriesList[28].entryList[NUM_LANGUAGES].specialDescFlag = 0xB; - MenuEntriesList[28].entryList[NUM_LANGUAGES].targetMenu = 4; - MenuEntriesList[28].entryList[NUM_LANGUAGES].posX = 490; - MenuEntriesList[28].entryList[NUM_LANGUAGES].posY = 380; - MenuEntriesList[28].entryList[NUM_LANGUAGES].align = 1; -// MenuEntriesList[28].entryList[NUM_LANGUAGES].field_11 = 1; - - // Load/Delete/Save entries - MenuEntriesList[9].entryList[1].screenHorAlign = -1; - MenuEntriesList[9].entryList[2].screenHorAlign = -1; - MenuEntriesList[9].entryList[3].screenHorAlign = -1; - MenuEntriesList[9].entryList[4].screenHorAlign = -1; - MenuEntriesList[9].entryList[5].screenHorAlign = -1; - MenuEntriesList[9].entryList[6].screenHorAlign = -1; - MenuEntriesList[9].entryList[7].screenHorAlign = -1; - MenuEntriesList[9].entryList[8].screenHorAlign = -1; - - MenuEntriesList[10].entryList[1].screenHorAlign = -1; - MenuEntriesList[10].entryList[2].screenHorAlign = -1; - MenuEntriesList[10].entryList[3].screenHorAlign = -1; - MenuEntriesList[10].entryList[4].screenHorAlign = -1; - MenuEntriesList[10].entryList[5].screenHorAlign = -1; - MenuEntriesList[10].entryList[6].screenHorAlign = -1; - MenuEntriesList[10].entryList[7].screenHorAlign = -1; - MenuEntriesList[10].entryList[8].screenHorAlign = -1; - - MenuEntriesList[16].entryList[1].screenHorAlign = -1; - MenuEntriesList[16].entryList[2].screenHorAlign = -1; - MenuEntriesList[16].entryList[3].screenHorAlign = -1; - MenuEntriesList[16].entryList[4].screenHorAlign = -1; - MenuEntriesList[16].entryList[5].screenHorAlign = -1; - MenuEntriesList[16].entryList[6].screenHorAlign = -1; - MenuEntriesList[16].entryList[7].screenHorAlign = -1; - MenuEntriesList[16].entryList[8].screenHorAlign = -1; - - MenuEntriesList[9].entryList[9].posX = 320; - MenuEntriesList[9].entryList[9].align = 1; - - MenuEntriesList[10].entryList[9].posX = 320; - MenuEntriesList[10].entryList[9].align = 1; - - MenuEntriesList[16].entryList[9].posX = 320; - MenuEntriesList[16].entryList[9].align = 1; - - // Audio menu - MenuItem::MenuEntry backups[5]; - memcpy(backups, &MenuEntriesList[3].entryList[3], sizeof(MenuItem::MenuEntry) * 5); - memcpy(&MenuEntriesList[3].entryList[2], backups, sizeof(MenuItem::MenuEntry) * 5); - - MenuEntriesList[3].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[3].entryList[0].align = 2; - MenuEntriesList[3].entryList[1].align = 2; - - /*MenuEntriesList[3].entryList[2].action = 0x1F; - strncpy(MenuEntriesList[3].entryList[2].entry, "FEA_ART", 8); - MenuEntriesList[3].entryList[2].align = 2; - - MenuEntriesList[3].entryList[3].action = 0x5; - strncpy(MenuEntriesList[3].entryList[2].entry, "FEA_TIT", 8);*/ - - /*MenuEntriesList[3].entryList[2].align = 2; - MenuEntriesList[3].entryList[3].posY = 195; - - MenuEntriesList[3].entryList[4].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[3].entryList[4].align = 2; - - memset(&MenuEntriesList[3].entryList[7], 0, sizeof(MenuItem::MenuEntry)); - - // Display menu - MenuEntriesList[4].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[4].entryList[0].align = 2; - MenuEntriesList[4].entryList[1].align = 2; - MenuEntriesList[4].entryList[2].align = 2; - MenuEntriesList[4].entryList[3].align = 2; - MenuEntriesList[4].entryList[4].align = 2; - //MenuEntriesList[4].entryList[5].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[4].entryList[5].align = 2; - - // User track options menu - MenuEntriesList[26].entryList[1].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[26].entryList[1].align = 2; - MenuEntriesList[26].entryList[2].align = 2; - MenuEntriesList[26].entryList[3].align = 3; - - // Advanced settings menu - MenuEntriesList[27].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[27].entryList[0].align = 2; - MenuEntriesList[27].entryList[1].align = 2; - MenuEntriesList[27].entryList[2].align = 2; - MenuEntriesList[27].entryList[3].align = 2; - MenuEntriesList[27].entryList[4].align = 2; - //MenuEntriesList[27].entryList[5].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[27].entryList[5].align = 2; - MenuEntriesList[27].entryList[6].align = 2; - - // Options - MenuEntriesList[33].entryList[0].posX = 320; - // LANGUAGE SETUP temporary cut - MenuEntriesList[33].entryList[4].action = 5; - strncpy(MenuEntriesList[33].entryList[4].entry, "FEO_UPT", 8); - MenuEntriesList[33].entryList[4].specialDescFlag = 0xB; - MenuEntriesList[33].entryList[4].targetMenu = 44; - MenuEntriesList[33].entryList[4].posX = 0; - MenuEntriesList[33].entryList[4].posY = 0; - MenuEntriesList[33].entryList[4].align = 3; - - MenuEntriesList[33].entryList[5].action = 0x2; - strncpy(MenuEntriesList[33].entryList[5].entry, "FEDS_TB", 8); - MenuEntriesList[33].entryList[5].specialDescFlag = 0xB; - MenuEntriesList[33].entryList[5].targetMenu = 0; - MenuEntriesList[33].entryList[5].posX = 0; - MenuEntriesList[33].entryList[5].posY = 0; - MenuEntriesList[33].entryList[5].align = 3; - - // Controller settings - MenuEntriesList[36].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[36].entryList[0].align = 2; - - // Mouse settings - MenuEntriesList[39].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[39].entryList[0].align = 2; - MenuEntriesList[39].entryList[1].align = 2; - MenuEntriesList[39].entryList[2].align = 2; - MenuEntriesList[39].entryList[3].align = 2; - - // Joypad settings - MenuEntriesList[40].entryList[0].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[40].entryList[0].align = 2; - MenuEntriesList[40].entryList[1].align = 2; - MenuEntriesList[40].entryList[2].align = 2; - MenuEntriesList[40].entryList[3].posX = (int)MENU_TEXT_POSITION_LCOLUMN; - MenuEntriesList[40].entryList[3].align = 2; - MenuEntriesList[40].entryList[4].align = 2; - MenuEntriesList[40].entryList[5].align = 2; - - // Updater menu - strncpy(MenuEntriesList[44].name, "FEH_UPT", 8); - MenuEntriesList[44].prevMenu = 33; - MenuEntriesList[44].startingMenuEntry = 0; - - MenuEntriesList[44].entryList[0].action = ACTION_UPDATER_BUTTON; - strncpy(MenuEntriesList[44].entryList[0].entry, "FEU_UPC", 8); - MenuEntriesList[44].entryList[0].specialDescFlag = 13; - MenuEntriesList[44].entryList[0].targetMenu = 44; - MenuEntriesList[44].entryList[0].posX = 320; - MenuEntriesList[44].entryList[0].posY = 370; - MenuEntriesList[44].entryList[0].align = 3; - - MenuEntriesList[44].entryList[1].action = 0x2; - strncpy(MenuEntriesList[44].entryList[1].entry, "FEDS_TB", 8); - MenuEntriesList[44].entryList[1].specialDescFlag = 0xB; - MenuEntriesList[44].entryList[1].targetMenu = 0; - MenuEntriesList[44].entryList[1].posX = 0; - MenuEntriesList[44].entryList[1].posY = 0; - MenuEntriesList[44].entryList[1].align = 3; - - - memset(&MenuEntriesList[0].entryList[1], 0, sizeof(MenuItem::MenuEntry) * 11 ); - memset(&MenuEntriesList[28].entryList[NUM_LANGUAGES + 1], 0, sizeof(MenuItem::MenuEntry) * ( 11 - NUM_LANGUAGES ) ); - memset(&MenuEntriesList[33].entryList[6], 0, sizeof(MenuItem::MenuEntry) * 6 ); - memset(&MenuEntriesList[44].entryList[2], 0, sizeof(MenuItem::MenuEntry) * 10 ); - - // Other texts - strncpy(MenuEntriesList[0].name, "FEH_STA", 8); - strncpy(MenuEntriesList[6].name, "FEH_NGA", 8); - strncpy(MenuEntriesList[7].name, "FEH_NGA", 8); - strncpy(MenuEntriesList[10].name, "FEH_DEL", 8); - strncpy(MenuEntriesList[12].name, "FEH_DEL", 8); - strncpy(MenuEntriesList[26].name, "FEH_TIT", 8); - strncpy(MenuEntriesList[39].name, "FEM_MOU", 8); - strncpy(MenuEntriesList[40].name, "FEM_TIT", 8); - strncpy(MenuEntriesList[33].entryList[3].entry, "FEO_LAN", 8); - - strncpy(MenuEntriesList[41].entryList[1].entry, "FEP_SGA", 8); - strncpy(MenuEntriesList[41].entryList[2].entry, "FEP_MAP", 8); - strncpy(MenuEntriesList[41].entryList[4].entry, "FEP_BRI", 8);*/ - - charptr(0x57F75D, "FEM_CCR"); - charptr(0x57F79C, "FEM_CFT"); - charptr(0x57F702, "FEH_SCN"); - charptr(0x57F709, "FEH_CCN"); - charptr(0x579C56, "FEM_SL%X"); + using namespace Memory; + + Patch(0x57345A, &MenuEntriesList->entryList->action); + Patch(0x57370A, &MenuEntriesList->startingMenuEntry); + Patch(0x573713, &MenuEntriesList->prevMenu); + Patch(0x573728, &MenuEntriesList->prevMenu); + Patch(0x57373D, &MenuEntriesList->prevMenu); + Patch(0x573752, &MenuEntriesList->prevMenu); + Patch(0x573772, &MenuEntriesList->entryList->targetMenu); + Patch(0x573EA9, &MenuEntriesList->entryList->action); + Patch(0x576B08, &MenuEntriesList->entryList[1].targetMenu); + Patch(0x576B1E, &MenuEntriesList->entryList[1].targetMenu); + Patch(0x576B38, MenuEntriesList); + Patch(0x576B58, &MenuEntriesList->entryList->entry); + Patch(0x577017, &MenuEntriesList->entryList->action); + Patch(0x57723D, &MenuEntriesList->entryList->targetMenu); + Patch(0x577280, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x5772F2, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x579568, MenuEntriesList); + Patch(0x57967E, MenuEntriesList); + Patch(0x5796AF, &MenuEntriesList->entryList->action); + Patch(0x57981F, &MenuEntriesList->entryList->entry); + Patch(0x5798D6, &MenuEntriesList->entryList->action); + Patch(0x5798FC, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x579AB2, &MenuEntriesList->entryList->align); + Patch(0x579AE4, &MenuEntriesList->entryList->posX); + Patch(0x579AEE, &MenuEntriesList->entryList->posY); + Patch(0x579AF7, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x579B10, &MenuEntriesList->name[4]); + Patch(0x579B17, &MenuEntriesList->entryList->posX); + Patch(0x579B2E, &MenuEntriesList->name[6]); + Patch(0x579B3A, &MenuEntriesList->entryList->posY); + Patch(0x579B43, &MenuEntriesList->entryList->posX); + Patch(0x579B5A, &MenuEntriesList->entryList->posY); + Patch(0x579B70, &MenuEntriesList->entryList->action); + Patch(0x579B7A, &MenuEntriesList->entryList->action); + Patch(0x579B8B, &MenuEntriesList->entryList->entry); + Patch(0x579B9F, &MenuEntriesList->entryList->specialDescFlag); + //Patch(0x579BC3, &MenuEntriesList->entryList->posX); + //Patch(0x579C83, &MenuEntriesList->entryList->posX); + Patch(0x579D20, &MenuEntriesList->entryList->action); + Patch(0x579D3F, &MenuEntriesList->name[6]); + Patch(0x579D4A, &MenuEntriesList->entryList->posY); + Patch(0x579D93, &MenuEntriesList->entryList->action); + //Patch(0x57A18A, &MenuEntriesList->entryList->posY); + //Patch(0x57A1BD, &MenuEntriesList->entryList->posX); + Patch(0x57A235, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x57A39F, &MenuEntriesList->entryList->posY); + Patch(0x57A455, &MenuEntriesList->entryList->align); + Patch(0x57A469, &MenuEntriesList->entryList->posX); + Patch(0x57A4B9, &MenuEntriesList->entryList->posX); + Patch(0x57A4DA, &MenuEntriesList->entryList->posX); + Patch(0x57A54F, &MenuEntriesList->entryList->posY); + Patch(0x57A615, &MenuEntriesList->entryList->entry); + Patch(0x57A65D, &MenuEntriesList->entryList->entry); + Patch(0x57A6A5, &MenuEntriesList->entryList->entry); + Patch(0x57A6E6, &MenuEntriesList->entryList->entry); + Patch(0x57A729, &MenuEntriesList->entryList->entry); + Patch(0x57A77C, &MenuEntriesList->entryList->entry); + Patch(0x57A7BE, &MenuEntriesList->entryList->action); + Patch(0x57B27E, &MenuEntriesList->entryList->action); + Patch(0x57B4F2, &MenuEntriesList->entryList->action); + Patch(0x57B519, &MenuEntriesList->entryList->action); + Patch(0x57B52A, &MenuEntriesList->entryList->action); + Patch(0x57B534, &MenuEntriesList->entryList->action); + Patch(0x57B588, &MenuEntriesList->entryList->action); + Patch(0x57B5A4, &MenuEntriesList->entryList->action); + Patch(0x57B5C9, &MenuEntriesList->entryList->action); + Patch(0x57B5E9, &MenuEntriesList->entryList[1].action); + Patch(0x57B601, &MenuEntriesList->entryList->action); + Patch(0x57B629, &MenuEntriesList->entryList->action); + Patch(0x57B69C, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x57B6F1, &MenuEntriesList->entryList->specialDescFlag); + Patch(0x57C313, &MenuEntriesList->entryList->action); + Patch(0x57CD6B, &MenuEntriesList->entryList->action); + Patch(0x57D26C, &MenuEntriesList->entryList[2].targetMenu); + Patch(0x57D287, &MenuEntriesList->entryList[2].targetMenu); + Patch(0x57D2D2, &MenuEntriesList->entryList[2].targetMenu); + Patch(0x57D6D8, &MenuEntriesList->entryList->entry); + Patch(0x57D701, &MenuEntriesList->entryList->entry); + Patch(0x57E3F7, &MenuEntriesList->entryList->action); + Patch(0x57FE0A, &MenuEntriesList->entryList->action); + Patch(0x57FE25, &MenuEntriesList->entryList->entry); + //Patch(0x57FE57, &MenuEntriesList->entryList->posY); + //Patch(0x57FE96, &MenuEntriesList->entryList->posY); + Patch(0x57FF5F, &MenuEntriesList->entryList->action); + Patch(0x57FFAE, &MenuEntriesList->entryList->action); + Patch(0x580316, &MenuEntriesList->entryList->action); + Patch(0x580496, &MenuEntriesList->entryList->action); + Patch(0x5804EB, &MenuEntriesList->entryList->action); + Patch(0x5805D3, &MenuEntriesList->entryList->action); + + Patch(0x57FE57, &MenuEntriesList->entryList); + Patch(0x57FE96, &MenuEntriesList->entryList); + + Patch(0x57F75D, "FEM_CCR"); + Patch(0x57F79C, "FEM_CFT"); + Patch(0x57F702, "FEH_SCN"); + Patch(0x57F709, "FEH_CCN"); + Patch(0x579C56, "FEM_SL%X"); #ifdef DUMP_MENUS - FILE* hDumpFile = fopen("menu_dump.log", "w"); - if ( hDumpFile ) + if ( FILE* hDumpFile = fopen("menu_dump.log", "w") ) { fputs("{ ", hDumpFile); for ( int i = 0; i < NUM_MENUS; ++i ) @@ -4152,12 +3966,15 @@ __forceinline void PatchMenus() __forceinline void AnimationStylesPatching() { - static const char* player1armedAnims[] = { + static const char* player1armedAnims[] = { "walk_player", "run_1armed", "sprint_civi", "idle_stance", "roadcross", "walk_start" }; + + using namespace Memory; + // playersprint_armed - charptr(&animationStyles[60].namesPtr[2], "playersprint_armed"); + Patch(&animationStyles[60].namesPtr[2], "playersprint_armed"); // player1armed strncpy(animationStyles[118].name, "player1armed", 16); @@ -4184,20 +4001,20 @@ __forceinline void AnimationStylesPatching() animationStyles[120].unkDataPtr = (CAnimationStyleUnkData*)0x8A7788; // Driving anims - charptr(0x8D108C, "CAR_sit"); - charptr(0x8D10B0, "Drive_L"); - charptr(0x8D10B4, "Drive_R"); - charptr(0x8D10D0, "CAR_LB"); - charptr(0x8D10F4, "Drive_L_slow"); - charptr(0x8D10F8, "Drive_R_slow"); + Patch(0x8D108C, "CAR_sit"); + Patch(0x8D10B0, "Drive_L"); + Patch(0x8D10B4, "Drive_R"); + Patch(0x8D10D0, "CAR_LB"); + Patch(0x8D10F4, "Drive_L_slow"); + Patch(0x8D10F8, "Drive_R_slow"); // Checks inject - call(0x6099DE, &ExtraWeaponAnimationsInject, PATCH_JUMP); - nop(0x6099A5, 2); - nop(0x609983, 6); + InjectHook(0x6099DE, ExtraWeaponAnimationsInject, PATCH_JUMP); + Nop(0x6099A5, 2); + Nop(0x609983, 6); // Animations number - patch(0x5BF6C7, 121, 4); + Patch(0x5BF6C7, 121); } __forceinline void UserFiles() @@ -4230,27 +4047,16 @@ __forceinline void UserFiles() Patch(0x619045, "GTAVCSsf"); } -void LoadNewWindowIcon() +void InjectDelayedPatches() { - DInputPadInitFunc(); - /*if ( HANDLE hIcon = LoadImage(NULL, "data\\icons\\app.ico", IMAGE_ICON, 0, 0, - LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE) ) - ::SendMessage(RsGlobal.ps->window, WM_SETICON, ICON_BIG, (LPARAM)hIcon);*/ - if ( *(BYTE*)0x6A0050 == 0xE9 ) - CLEOGetTextFunc = (char*(__thiscall*)(CText* object, const char* key))(*(int*)0x6A0051 + 0x6A0050 + 5); + CLEOGetTextFunc = (const char*(__thiscall*)(CText*, const char*))(*(int*)0x6A0051 + 0x6A0050 + 5); else - CLEOGetTextFunc = (char*(__thiscall*)(CText* object, const char* key))0x0; + CLEOGetTextFunc = nullptr; TheScriptsInitFunc = (void(*)())(*(int*)0x53BDD8 + 0x53BDD7 + 5); - DWORD dwFunc; - _asm - { - mov eax, CText::GetText - mov dwFunc, eax - } - call(0x6A0050, dwFunc, PATCH_JUMP); + InjectMethod(0x6A0050, CText::Get, PATCH_JUMP); CUpdateManager::Init(); // CDLCManager::InitialiseWithUpdater(); @@ -4274,13 +4080,6 @@ void LoadNewWindowIcon() #endif } -#define FUNC_random 0x407180 - -int random(int a, int b) -{ - return a + (static_cast(rand()) * (1.0/32768.0) * (b - a)); -} - void HighspeedCamShake(float shake) { TheCamera.CamShake(shake * 0.025f); @@ -4361,7 +4160,7 @@ eFontFileIDs GetFontsIDByLanguage() { switch ( FrontEndMenuManager.GetLanguage() ) { - case LANG_Polish: + case LANGUAGE_Polish: return FONTF_Polish; default: return FONTF_European; @@ -4374,38 +4173,41 @@ void InitialiseLanguage() { FrontEndMenuManager.SetTitleLanguage(0); - switch ( (int)GetKeyboardLayout(0) & 0x3FF ) + switch ( reinterpret_cast(GetKeyboardLayout(0)) & 0x3FF ) { - //case LANG_SPANISH: - // FrontEndMenuManager.SetTextLanguage(LANG_Spanish); - // break; - case LANG_POLISH: - FrontEndMenuManager.SetTextLanguage(LANG_Polish); + case LANG_GERMAN: + case LANG_HUNGARIAN: + FrontEndMenuManager.SetKeyboardLayout(KEYBOARD_QWERTZ); + break; + case LANG_FRENCH: + FrontEndMenuManager.SetKeyboardLayout(KEYBOARD_AZERTY); break; default: - FrontEndMenuManager.SetTextLanguage(LANG_English); + FrontEndMenuManager.SetKeyboardLayout(KEYBOARD_QWERTY); break; } switch ( GetUserDefaultLCID() & 0x3FF ) { //case LANG_SPANISH: - // FrontEndMenuManager.SetLanguage(LANG_Spanish); + // FrontEndMenuManager.SetLanguage(LANGUAGE_Spanish); // break; case LANG_POLISH: - FrontEndMenuManager.SetLanguage(LANG_Polish); + FrontEndMenuManager.SetLanguage(LANGUAGE_Polish); + break; + case LANG_HUNGARIAN: + FrontEndMenuManager.SetLanguage(LANGUAGE_Hungarian); break; default: - FrontEndMenuManager.SetLanguage(LANG_English); + FrontEndMenuManager.SetLanguage(LANGUAGE_English); break; } - TheText.Clear(0); - TheText.Load(0); + TheText.Load(false); } void LoadGameFailedMessage(unsigned char bMessageIndex) { - char* pMessage; + const char* pMessage; switch ( bMessageIndex ) { @@ -4483,14 +4285,14 @@ void ParseCommandlineArgument(const char* pArg) { if ( pArg ) { - if ( !strnicmp(pArg, "-novcsname", 10) ) + if ( !_strnicmp(pArg, "-novcsname", 10) ) { SetWindowTextW(RsGlobal.ps->window, L"GTA: San Andreas"); RsGlobal.AppName = "GTA: San Andreas"; return; } - if ( !strnicmp(pArg, "-nointro", 8) ) + if ( !_strnicmp(pArg, "-nointro", 8) ) { // TODO: Define this variable properly *(DWORD*)0xC8D4C0 = 5; @@ -4498,19 +4300,19 @@ void ParseCommandlineArgument(const char* pArg) } #ifdef DEVBUILD - if ( !strnicmp(pArg, "-noautocheck", 13) ) + if ( !_strnicmp(pArg, "-noautocheck", 13) ) { CUpdateManager::DisableAutoCheck(); return; } - if ( !strncmp(pArg, "-zombiedlc", 10) ) + if ( !_strnicmp(pArg, "-zombiedlc", 10) ) { CDLCManager::ToggleDebugOverride(DLC_HALLOWEEN); return; } - /*if ( !strncmp(pArg, "-2dfx", 5) ) + /*if ( !_strnicmp(pArg, "-2dfx", 5) ) { CDLCManager::ToggleDebugOverride(DLC_2DFX); return; @@ -4537,8 +4339,12 @@ BOOL IsAlreadyRunning() SetForegroundWindow(RsGlobal.ps->window); } } + + // No point in hooking if we're about to terminate this process! ;) return TRUE; } + + InjectDelayedPatches(); return FALSE; } @@ -4563,23 +4369,23 @@ void EnterAmazingScreenshotMode(bool bEnable) if ( bEnable ) { - nop(0x53BF8A, 2); - nop(0x53BF96, 6); - nop(0x58FCC2, 4); - nop(0x58D4BE, 8); - patch(0x561B06, 1, 1); - patch(0xB7CB49, 1, 1); + Memory::Nop(0x53BF8A, 2); + Memory::Nop(0x53BF96, 6); + Memory::Nop(0x58FCC2, 4); + Memory::Nop(0x58D4BE, 8); + Memory::Patch(0x561B06, 1); + Memory::Patch(0xB7CB49, 1); } else { - patch(0x53BF8A, 0xC084, 2); - patch(0x53BF96, 0x0298850F, 4); - patch(0x58FCC2, 0x4D75C084, 4); - patch(0x58D4BE, 0x850FC084, 4); - patch(0x58D4C2, 0x000000AF, 4); - patch(0x53BF9A, 0, 2); - patch(0x561B06, 0, 1); - patch(0xB7CB49, 0, 1); + Memory::Patch(0x53BF8A, 0xC084); + Memory::Patch(0x53BF96, 0x0298850F); + Memory::Patch(0x58FCC2, 0x4D75C084); + Memory::Patch(0x58D4BE, 0x850FC084); + Memory::Patch(0x58D4C2, 0x000000AF); + Memory::Patch(0x53BF9A, 0); + Memory::Patch(0x561B06, 0); + Memory::Patch(0xB7CB49, 0); } //VirtualProtect((void*)0x401000, 0x4A2400, dwProtect[0], &dwProtect[1]); @@ -5083,7 +4889,8 @@ void __declspec(naked) Language_CASE_English() _asm { push offset aEnglish_gxt - jmp _CText__load_JumpBack + mov edx, 6A020Eh + jmp edx } } @@ -5092,7 +4899,8 @@ void __declspec(naked) Language_CASE_Spanish() _asm { push offset aSpanish_gxt - jmp _CText__load_JumpBack + mov edx, 6A020Eh + jmp edx } } @@ -5101,7 +4909,18 @@ void __declspec(naked) Language_CASE_Polish() _asm { push offset aPolish_gxt - jmp _CText__load_JumpBack + mov edx, 6A020Eh + jmp edx + } +} + +void __declspec(naked) Language_CASE_Hungarian() +{ + _asm + { + push offset aHungarian_gxt + mov edx, 6A020Eh + jmp edx } } @@ -5110,7 +4929,8 @@ void __declspec(naked) MissionLanguage_CASE_English() _asm { push offset aEnglish_gxt - jmp _CText__loadMission_JumpBack + mov eax, 69FD31h + jmp eax } } @@ -5119,7 +4939,8 @@ void __declspec(naked) MissionLanguage_CASE_Spanish() _asm { push offset aSpanish_gxt - jmp _CText__loadMission_JumpBack + mov eax, 69FD31h + jmp eax } } @@ -5128,7 +4949,18 @@ void __declspec(naked) MissionLanguage_CASE_Polish() _asm { push offset aPolish_gxt - jmp _CText__loadMission_JumpBack + mov eax, 69FD31h + jmp eax + } +} + +void __declspec(naked) MissionLanguage_CASE_Hungarian() +{ + _asm + { + push offset aHungarian_gxt + mov eax, 69FD31h + jmp eax } } @@ -5695,7 +5527,7 @@ void __declspec(naked) MenuEntriesAlignHack() push ALIGN_Right MenuEntriesAlignHack_Finish: - call CFont::SetTextAlignment + call CFont::SetOrientation jmp MenuEntriesAlignHack_JumpBack } } @@ -6083,8 +5915,8 @@ void __declspec(naked) Widescreen_StringInject() void __declspec(naked) Widescreen_TextDrawsFix2() { - static const float fWidthDiv = 1.0/640.0; - static const float fHeightDiv = 1.0/448.0; + static const float fWidthDiv = 1.0f/640.0f; + static const float fHeightDiv = 1.0f/448.0f; _asm { lea ecx, [esp+1A0h-190h] @@ -6378,7 +6210,7 @@ void __declspec(naked) FrameLimit_StringInject() push 0 push RsGlobalFrameLimits[eax*4] push offset aFem_Fps - call CText::GetText + call CText::Get push eax call CMessages::InsertNumberInString add esp, 20h @@ -6765,6 +6597,31 @@ void __declspec(naked) DLCMenuAction() } } +void __declspec(naked) VehAudioHook() +{ + _asm + { + push edx + push eax + mov ecx, ebp + call CAEVehicleAudioEntity::GetVehicleAudioSettings + pop edx + mov eax, 4F77D8h + jmp eax + } +} + +void __declspec(naked) RotorsHook() +{ + _asm + { + mov ecx, esi + call CHeli::ProcessRotorsAlpha + mov ecx, 6C4521h + jmp ecx + } +} + void OpaqueRadarHack2(RwPrimitiveType primType, RwIm2DVertex *vertices, RwInt32 numVertices) { RwIm2DRenderPrimitive(primType, vertices, numVertices); @@ -6824,7 +6681,7 @@ void __declspec(naked) InjectWindowedMode() //mov eax, [esp+30h] //push offset aWindowed //mov ecx, TheText - //call CText::GetText + //call CText::Get //mov stackPtr, eax //pushad //popad diff --git a/VCS PC/Vehicle.cpp b/VCS PC/Vehicle.cpp new file mode 100644 index 0000000..b0934d2 --- /dev/null +++ b/VCS PC/Vehicle.cpp @@ -0,0 +1,71 @@ +#include "StdAfx.h" + +static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data) +{ + if ( RpAtomicGetFlags(pObject) & rpATOMICRENDER ) + *static_cast(data) = pObject; + return pObject; +} + +static RpMaterial* SetCompAlphaCB(RpMaterial* pMaterial, void* data) +{ + pMaterial->color.alpha = reinterpret_cast(data); + return pMaterial; +} + +void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) +{ + RpGeometry* pGeometry = RpAtomicGetGeometry(pAtomic); + pGeometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR; + + RpGeometryForAllMaterials(pGeometry, SetCompAlphaCB, reinterpret_cast(nAlpha)); +} + +void CHeli::ProcessRotorsAlpha() +{ + double dRotorsSpeed, dMovingRotorSpeed; + + if ( m_fRotorSpeed > 0.0 ) + dRotorsSpeed = min(1.7 * (1.0/0.22) * m_fRotorSpeed, 1.5); + else + dRotorsSpeed = 0.0; + + dMovingRotorSpeed = dRotorsSpeed - 0.4; + if ( dMovingRotorSpeed < 0.0 ) + dMovingRotorSpeed = 0.0; + + int nStaticRotorAlpha = min((1.5-dRotorsSpeed) * 255.0, 255); + int nMovingRotorAlpha = min(dMovingRotorSpeed * 150.0, 150); + + if ( m_pCarNode[11] ) + { + RpAtomic* pOutAtomic = nullptr; + RwFrameForAllObjects(m_pCarNode[11], GetCurrentAtomicObjectCB, &pOutAtomic); + if ( pOutAtomic ) + SetComponentAtomicAlpha(pOutAtomic, nStaticRotorAlpha); + } + + if ( m_pCarNode[13] ) + { + RpAtomic* pOutAtomic = nullptr; + RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic); + if ( pOutAtomic ) + SetComponentAtomicAlpha(pOutAtomic, nStaticRotorAlpha); + } + + if ( m_pCarNode[12] ) + { + RpAtomic* pOutAtomic = nullptr; + RwFrameForAllObjects(m_pCarNode[12], GetCurrentAtomicObjectCB, &pOutAtomic); + if ( pOutAtomic ) + SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); + } + + if ( m_pCarNode[14] ) + { + RpAtomic* pOutAtomic = nullptr; + RwFrameForAllObjects(m_pCarNode[14], GetCurrentAtomicObjectCB, &pOutAtomic); + if ( pOutAtomic ) + SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); + } +} \ No newline at end of file diff --git a/VCS PC/VideoPlayer.cpp b/VCS PC/VideoPlayer.cpp index 7e04ee7..70fc68d 100644 --- a/VCS PC/VideoPlayer.cpp +++ b/VCS PC/VideoPlayer.cpp @@ -33,7 +33,7 @@ void CVideoPlayer::UpdateVideoFrame(const CRect* pVideoFrame) } } -void CVideoPlayer::Create(const char* pFileName, const CRect* pVideoFrame, bool bAudio) +void CVideoPlayer::Create(const char* pFileName, const CRect* pVideoFrame, bool bAudio, bool bBlackWhite) { SYSTEM_INFO info; unsigned int openFlags; @@ -59,11 +59,14 @@ void CVideoPlayer::Create(const char* pFileName, const CRect* pVideoFrame, bool BinkSetSoundTrack(0, nullptr); openFlags = BINKSNDTRACK; } + if ( bBlackWhite ) + openFlags |= BINKGRAYSCALE; + m_hBinkPlayer = BinkOpen(pFileName, openFlags); if ( m_hBinkPlayer ) { BinkDoFrameAsync(m_hBinkPlayer, 0, m_bExtraThreadIndex); - m_hBinkBuffer = BinkBufferOpen(RsGlobal.ps->window, m_hBinkPlayer->Width, m_hBinkPlayer->Height, BINKBUFFERSTRETCHXINT | BINKBUFFERSTRETCHYINT/*BINKBUFFERSTRETCHY*/); + m_hBinkBuffer = BinkBufferOpen(RsGlobal.ps->window, m_hBinkPlayer->Width, m_hBinkPlayer->Height, BINKBUFFERAUTO /*BINKBUFFERSTRETCHXINT | BINKBUFFERSTRETCHYINT*//*BINKBUFFERSTRETCHY*/); if ( !pVideoFrame ) { @@ -85,7 +88,7 @@ void CVideoPlayer::Create(const char* pFileName, const CRect* pVideoFrame, bool else BinkBufferSetScale(m_hBinkBuffer, static_cast(abs(pVideoFrame->x2 - pVideoFrame->x1)), static_cast(abs(pVideoFrame->y2 - pVideoFrame->y1))); - m_pVideoRaster = RwRasterCreate(m_hBinkPlayer->Width, m_hBinkPlayer->Height, 32, rwRASTERTYPECAMERATEXTURE); + m_pVideoRaster = RwRasterCreate(m_hBinkPlayer->Width, m_hBinkPlayer->Height, 0, rwRASTERTYPECAMERATEXTURE); m_bSurfaceMask = ( RwRasterGetFormat(m_pVideoRaster) == rwRASTERFORMAT565 ) ? BINKSURFACE565 : BINKSURFACE32; UpdateVideoFrame(pVideoFrame); diff --git a/VCS PC/VideoPlayer.h b/VCS PC/VideoPlayer.h index 639b145..702f3a1 100644 --- a/VCS PC/VideoPlayer.h +++ b/VCS PC/VideoPlayer.h @@ -15,7 +15,7 @@ class CVideoPlayer static void UpdateVideoFrame(const CRect* pVideoFrame); public: - static void Create(const char* pFileName, const CRect* pVideoFrame = nullptr, bool bAudio = true); + static void Create(const char* pFileName, const CRect* pVideoFrame = nullptr, bool bAudio = true, bool bBlackWhite = false); static void Release(); static bool PlayNextFullscreenFrame(); static void PlayNextFrame(); diff --git a/VCS PC/WidescreenSupport.cpp b/VCS PC/WidescreenSupport.cpp index 67d5000..86bdfea 100644 --- a/VCS PC/WidescreenSupport.cpp +++ b/VCS PC/WidescreenSupport.cpp @@ -5,60 +5,57 @@ long*& WidescreenSupport::nCTRubberSliderMinPos = CTRubberMinPos; long*& WidescreenSupport::nCTRubberSliderMaxPos = CTRubberMaxPos; float*& WidescreenSupport::fHorizontalAspectRatio = WidthAspectRatio; float*& WidescreenSupport::fVerticalAspectRatio = HeightAspectRatio; -float WidescreenSupport::fScreenWidthMultiplier = 640.0; -float WidescreenSupport::fScreenWidthDivider = 1.0/640.0; -float WidescreenSupport::fScreenHeightMultiplier = 448.0; -float WidescreenSupport::f4 = 4.0/640.0; -float WidescreenSupport::f40 = 40.0/640.0; -float WidescreenSupport::f45 = 45.0/640.0; -float WidescreenSupport::f50 = 50.0/640.0; -float WidescreenSupport::f55 = 55.0/640.0; -float WidescreenSupport::f60 = 60.0/640.0; -float WidescreenSupport::f70 = 70.0/640.0; -float WidescreenSupport::f95 = 95.0/640.0; -float WidescreenSupport::f100 = 100.0/640.0; -float WidescreenSupport::f160 = 160.0/640.0; -float WidescreenSupport::f350 = 350.0/640.0; -float WidescreenSupport::f555 = 555.0/640.0; -float WidescreenSupport::f580 = 580.0/640.0; -float WidescreenSupport::f0pt3 = 0.3/640.0; -float WidescreenSupport::f1pt3 = 1.3/640.0; -float WidescreenSupport::f0pt49 = 0.49/640.0; -float WidescreenSupport::f0pt42 = 0.42/640.0; -float WidescreenSupport::f0pt35 = 0.35/640.0; -float WidescreenSupport::f0pt7 = 0.7/640.0; -float WidescreenSupport::f0pt8 = 0.8/640.0; -float WidescreenSupport::f0pt56 = 0.56/640.0; -float WidescreenSupport::fMenuSliderPosX = 0.5 + (MENU_TEXT_POSITION_RCOLUMN/640.0); -float WidescreenSupport::fMenuSliderWidth = MENU_SLIDER_WIDTH/640.0; -float WidescreenSupport::fMenuMessageWidth = 640.0 - 210.0; -float WidescreenSupport::fCTSliderRight = 0.5 + (50.0/640.0); -float WidescreenSupport::fCTSliderLeft = 0.5 - (50.0/640.0); -float WidescreenSupport::fScreenCoorsFix = 44800.0/640.0; -//float WidescreenSupport::fSpawningFix = 44800.0/640.0; -float WidescreenSupport::fAimpointFix = 0.5; -float WidescreenSupport::fMapZonePosX2 = 7.5/640.0; -//float WidescreenSupport::fSkyMultFix = 1.4; - -float WidescreenSupport::f0pt7_h = 0.7/448.0; -float WidescreenSupport::f0pt95_h = 0.95/448.0; -float WidescreenSupport::f1pt2_h = 1.2/448.0; -float WidescreenSupport::f2pt1_h = 2.1/448.0; -float WidescreenSupport::f1_h = 1.0/448.0; -float WidescreenSupport::f28_h = 28.0/448.0; -float WidescreenSupport::f97_centh = 0.5 - 127.0/448.0; -float WidescreenSupport::fMenuSliderPosY2 = MENU_SLIDER_POSY / 448.0; -float WidescreenSupport::fMenuSliderPosY3 = (MENU_SLIDER_POSY - 30.0) / 448.0; -float WidescreenSupport::fMenuSliderPosY4 = (MENU_SLIDER_POSY - MENU_SLIDER_WIDTH / 2.0) / 448.0; -float WidescreenSupport::fMenuSliderHeight2 = MENU_SLIDER_HEIGHT / 448.0; - -float WidescreenSupport::fProperWidthMultiplier = 1.0; -float WidescreenSupport::fProperHeightMultiplier = 480.0/448.0; - -//float WidescreenSupport::fTextDrawsWidthMultiplier; - -//const float WidescreenSupport::fFOVMultiplier = 1.0/((4.0/3.0)/1.2); -const float WidescreenSupport::fFOVMultiplier = 1.0/((4.0/3.0)/1.1); +float WidescreenSupport::fScreenWidthMultiplier = 640.0f; +float WidescreenSupport::fScreenWidthDivider = 1.0f/640.0f; +float WidescreenSupport::fScreenHeightMultiplier = 448.0f; +float WidescreenSupport::f4 = 4.0f/640.0f; +float WidescreenSupport::f40 = 40.0f/640.0f; +float WidescreenSupport::f45 = 45.0f/640.0f; +float WidescreenSupport::f50 = 50.0f/640.0f; +float WidescreenSupport::f55 = 55.0f/640.0f; +float WidescreenSupport::f60 = 60.0f/640.0f; +float WidescreenSupport::f70 = 70.0f/640.0f; +float WidescreenSupport::f95 = 95.0f/640.0f; +float WidescreenSupport::f100 = 100.0f/640.0f; +float WidescreenSupport::f160 = 160.0f/640.0f; +float WidescreenSupport::f350 = 350.0f/640.0f; +float WidescreenSupport::f555 = 555.0f/640.0f; +float WidescreenSupport::f580 = 580.0f/640.0f; +float WidescreenSupport::f0pt3 = 0.3f/640.0f; +float WidescreenSupport::f1pt3 = 1.3f/640.0f; +float WidescreenSupport::f0pt49 = 0.49f/640.0f; +float WidescreenSupport::f0pt42 = 0.42f/640.0f; +float WidescreenSupport::f0pt35 = 0.35f/640.0f; +float WidescreenSupport::f0pt7 = 0.7f/640.0f; +float WidescreenSupport::f0pt8 = 0.8f/640.0f; +float WidescreenSupport::f0pt56 = 0.56f/640.0f; +float WidescreenSupport::fMenuSliderPosX = 0.5f + (MENU_TEXT_POSITION_RCOLUMN/640.0f); +float WidescreenSupport::fMenuSliderWidth = MENU_SLIDER_WIDTH/640.0f; +float WidescreenSupport::fMenuMessageWidth = 640.0f - 210.0f; +float WidescreenSupport::fCTSliderRight = 0.5f + (50.0f/640.0f); +float WidescreenSupport::fCTSliderLeft = 0.5f - (50.0/640.0f); +float WidescreenSupport::fScreenCoorsFix = 44800.0f/640.0f; +//float WidescreenSupport::fSpawningFix = 44800.0f/640.0f; +float WidescreenSupport::fAimpointFix = 0.5f; +float WidescreenSupport::fMapZonePosX2 = 7.5f/640.0f; +//float WidescreenSupport::fSkyMultFix = 1.4f; + +float WidescreenSupport::f0pt7_h = 0.7f/448.0f; +float WidescreenSupport::f0pt95_h = 0.95f/448.0f; +float WidescreenSupport::f1pt2_h = 1.2f/448.0f; +float WidescreenSupport::f2pt1_h = 2.1f/448.0f; +float WidescreenSupport::f1_h = 1.0f/448.0f; +float WidescreenSupport::f28_h = 28.0f/448.0f; +float WidescreenSupport::f97_centh = 0.5f - 127.0f/448.0f; +float WidescreenSupport::fMenuSliderPosY2 = MENU_SLIDER_POSY / 448.0f; +float WidescreenSupport::fMenuSliderPosY3 = (MENU_SLIDER_POSY - 30.0f) / 448.0f; +float WidescreenSupport::fMenuSliderPosY4 = (MENU_SLIDER_POSY - MENU_SLIDER_WIDTH / 2.0f) / 448.0f; +float WidescreenSupport::fMenuSliderHeight2 = MENU_SLIDER_HEIGHT / 448.0f; + +float WidescreenSupport::fProperWidthMultiplier = 1.0f; +float WidescreenSupport::fProperHeightMultiplier = 480.0f/448.0f; + +const float WidescreenSupport::fFOVMultiplier = 1.0f/((4.0f/3.0f)/1.1f); void WidescreenSupport::Recalculate(long nWidth, long nHeight, bool bAlways) { @@ -160,15 +157,15 @@ float WidescreenSupport::SetAspectRatio() switch ( FrontEndMenuManager.m_bAspectRatioMode ) { case 1: - return *ScreenAspectRatio = 4.0/3.0; + return *ScreenAspectRatio = 4.0f/3.0f; case 2: - return *ScreenAspectRatio = 5.0/4.0; + return *ScreenAspectRatio = 5.0f/4.0f; case 3: - return *ScreenAspectRatio = 15.0/9.0; + return *ScreenAspectRatio = 15.0f/9.0f; case 4: - return *ScreenAspectRatio = 16.0/9.0; + return *ScreenAspectRatio = 16.0f/9.0f; case 5: - return *ScreenAspectRatio = 16.0/10.0; + return *ScreenAspectRatio = 16.0f/10.0f; default: return *ScreenAspectRatio = static_cast(RsGlobal.MaximumWidth) / RsGlobal.MaximumHeight; } @@ -177,8 +174,8 @@ float WidescreenSupport::SetAspectRatio() float WidescreenSupport::GetTextPosition() { float fScreenRatio = *ScreenAspectRatio; - long double dTextPos = (-3375.0 * fScreenRatio * fScreenRatio) + (10800.0 * fScreenRatio) - 8545.0; - return dTextPos > 80.0 ? dTextPos : 80.0; + double dTextPos = (-3375.0 * fScreenRatio * fScreenRatio) + (10800.0 * fScreenRatio) - 8545.0; + return dTextPos > 80.0 ? static_cast(dTextPos) : 80.0f; } /*float WidescreenSupport::GetSkyWidth() @@ -203,5 +200,5 @@ unsigned char WidescreenSupport::GetTextBoxPos() if ( dBorderProportionsFix < 0.0 ) dBorderProportionsFix = 0.0; - return dScreenHeightWeWannaCut > 0.0 ? (RsGlobal.MaximumHeight / 2) * (dScreenHeightWeWannaCut - dBorderProportionsFix) : 0; + return dScreenHeightWeWannaCut > 0.0 ? static_cast((RsGlobal.MaximumHeight / 2) * (dScreenHeightWeWannaCut - dBorderProportionsFix)) : 0; } \ No newline at end of file