diff --git a/VCS PC/CCamera.cpp b/VCS PC/CCamera.cpp index fa40f8d..3301c8e 100644 --- a/VCS PC/CCamera.cpp +++ b/VCS PC/CCamera.cpp @@ -11,7 +11,7 @@ WRAPPER bool CCamera::IsPositionVisible(const CVector& vecPos, float fRadius) { void CCamera::GetScreenRect(CRect& rect) { - float fScreenRatio = *ScreenAspectRatio; + float fScreenRatio = ScreenAspectRatio; float dScreenHeightWeWannaCut = ((-9.0f/16.0f) * fScreenRatio + 1.0f); float dBorderProportionsFix = ((-144643.0f/50000.0f) * fScreenRatio * fScreenRatio) + ((807321.0f/100000.0f) * fScreenRatio) - (551143.0f/100000.0f); diff --git a/VCS PC/CWanted.h b/VCS PC/CWanted.h index bb15ec7..9cb0116 100644 --- a/VCS PC/CWanted.h +++ b/VCS PC/CWanted.h @@ -31,6 +31,8 @@ class CWanted public: inline int GetWantedLevel() { return m_WantedLevel; } + inline int GetWantedLevelBeforeParole() { return m_WantedLevelBeforeParole; } + inline int GetTimeWantedLevelChanged() { return m_LastTimeWantedLevelChanged; } bool ShouldSendViceSquad(); }; diff --git a/VCS PC/EmpireMgr.cpp b/VCS PC/EmpireMgr.cpp index 21df280..cc073a2 100644 --- a/VCS PC/EmpireMgr.cpp +++ b/VCS PC/EmpireMgr.cpp @@ -119,6 +119,10 @@ void CEmpireManager::Initialise() sscanf(pLine, "%d %c %f %f %f %f", &nTypeID, &nSubgroup, &tempData.m_translate.x, &tempData.m_translate.y, &tempData.m_translate.z, &tempData.m_heading); nSubgroup = static_cast(tolower(nSubgroup)); + // Normalize the angle + while ( tempData.m_heading < 0.0f ) + tempData.m_heading += 360.0f; + // Get the index and increase it afterwards unsigned char nIndex = countMap[PackKey(static_cast(nTypeID), nSubgroup)]; pCurrentModelForDataParsing->GetEmpireData()->AddEntry(static_cast(nTypeID), nSubgroup, nIndex++, tempData); diff --git a/VCS PC/Frontend.cpp b/VCS PC/Frontend.cpp index 54e3b4f..5e9e6be 100644 --- a/VCS PC/Frontend.cpp +++ b/VCS PC/Frontend.cpp @@ -384,7 +384,7 @@ void CMenuManager::DrawBackEnd() { // Calculate proper dimensions // Displayed image is 16:9 - CVector2D vecSplashScale = WidescreenSupport::GetFullscreenImageDimensions(16.0f/9.0f, *ScreenAspectRatio, false); + CVector2D vecSplashScale = WidescreenSupport::GetFullscreenImageDimensions(16.0f/9.0f, ScreenAspectRatio, false); CSprite2d::DrawRect(CRect(-5.0f, RsGlobal.MaximumHeight + 5.0f, RsGlobal.MaximumWidth + 5.0f, RsGlobal.MaximumHeight * 0.95f - 5.0f), CRGBA(7, 7, 7, 255)); textures[13].Draw(CRect(-2.5f - (vecSplashScale.x-RsGlobal.MaximumWidth), RsGlobal.MaximumHeight * 0.95f, RsGlobal.MaximumWidth + 2.5f, -2.5f - (vecSplashScale.y-RsGlobal.MaximumHeight)), CRGBA(255, 255, 255, 255)); @@ -638,7 +638,7 @@ void CMenuManager::DrawOutroSplash() { LoadSplashes(true, 0); - CVector2D vecSplashScale = WidescreenSupport::GetFullscreenImageDimensions(512.0f/400.0f, *ScreenAspectRatio, true); + CVector2D vecSplashScale = WidescreenSupport::GetFullscreenImageDimensions(512.0f/400.0f, ScreenAspectRatio, true); rectSpriteDimensions.x1 = 0.5f * (RsGlobal.MaximumWidth - vecSplashScale.x); rectSpriteDimensions.y1 = 0.5f * (RsGlobal.MaximumHeight + vecSplashScale.y); diff --git a/VCS PC/Hud.cpp b/VCS PC/Hud.cpp index 61b873a..1e8fb86 100644 Binary files a/VCS PC/Hud.cpp and b/VCS PC/Hud.cpp differ diff --git a/VCS PC/Hud.h b/VCS PC/Hud.h index 38c13f9..37369b5 100644 --- a/VCS PC/Hud.h +++ b/VCS PC/Hud.h @@ -88,6 +88,7 @@ class CHud static bool HelpMessageShown(); static void DrawHUD(); + static void DrawWanted(); static void DrawOnscreenTimer(); static void DrawPermanentTexts(); static void DrawRadioName(void* object, const char* radioName); diff --git a/VCS PC/Maths.h b/VCS PC/Maths.h index 8dce2e4..b006a3f 100644 --- a/VCS PC/Maths.h +++ b/VCS PC/Maths.h @@ -197,6 +197,14 @@ class CMatrix matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; } + inline void SetScale(float fScale) + { + matrix.right.x = fScale; matrix.right.y = 0.0f; matrix.right.z = 0.0f; + matrix.up.x = 0.0f; matrix.up.y = fScale; matrix.up.z = 0.0f; + matrix.at.x = 0.0f; matrix.at.y = 0.0f; matrix.at.z = fScale; + matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; + } + inline void RotateX(float fAngle) { CMatrix RotationMatrix; diff --git a/VCS PC/StdAfx.h b/VCS PC/StdAfx.h index 9d14475..bacc472 100644 --- a/VCS PC/StdAfx.h +++ b/VCS PC/StdAfx.h @@ -61,8 +61,9 @@ //#define ROTORS_TEST //#define DEBUG_GETMODELINFO_WRAPPER //#define FANCY_FRONTEND_CONTROLLERS_TEST +#define SHOW_FOV_FANCY_RHYME -#define NEW_SHADOWS_TEST +//#define NEW_SHADOWS_TEST //#define MAKE_ZZCOOL_MOVIE_DEMO @@ -159,7 +160,7 @@ extern DWORD* memoryAvailable; extern DWORD* memoryUsed; extern float* WidthAspectRatio; extern float* HeightAspectRatio; -extern float* ScreenAspectRatio; +extern float& ScreenAspectRatio; extern float* fFOV; extern BYTE* bWants_To_Draw_Hud; extern BYTE* radarGrey; diff --git a/VCS PC/TimeCycle.cpp b/VCS PC/TimeCycle.cpp new file mode 100644 index 0000000..914f100 --- /dev/null +++ b/VCS PC/TimeCycle.cpp @@ -0,0 +1,5 @@ +#include "StdAfx.h" +#include "TimeCycle.h" + +int& CTimeCycle::m_CurrentStoredValue = *(int*)0xB79FD0; +CVector* const CTimeCycle::m_VectorToSun = (CVector*)0xB7CA50; \ No newline at end of file diff --git a/VCS PC/TimeCycle.h b/VCS PC/TimeCycle.h new file mode 100644 index 0000000..a67187d --- /dev/null +++ b/VCS PC/TimeCycle.h @@ -0,0 +1,11 @@ +#ifndef __TIMECYCLE +#define __TIMECYCLE + +class CTimeCycle +{ +public: + static int& m_CurrentStoredValue; + static CVector* const m_VectorToSun; +}; + +#endif \ No newline at end of file diff --git a/VCS PC/Timer.cpp b/VCS PC/Timer.cpp index adfd10f..6e29e3c 100644 --- a/VCS PC/Timer.cpp +++ b/VCS PC/Timer.cpp @@ -4,4 +4,4 @@ int& CTimer::m_snTimeInMilliseconds = *(int*)0xB7CB84; int& CTimer::m_snTimeInMillisecondsPauseMode = *(int*)0xB7CB7C; float& CTimer::ms_fTimeStep = *(float*)0xB7CB5C; -unsigned int& CTimer::m_FrameCounter = *(unsigned int*)0xB7CB4C; \ No newline at end of file +//unsigned int& CTimer::m_FrameCounter = *(unsigned int*)0xB7CB4C; \ No newline at end of file diff --git a/VCS PC/Timer.h b/VCS PC/Timer.h index 55e21d7..089035a 100644 --- a/VCS PC/Timer.h +++ b/VCS PC/Timer.h @@ -7,7 +7,12 @@ class CTimer static int& m_snTimeInMilliseconds; static int& m_snTimeInMillisecondsPauseMode; static float& ms_fTimeStep; - static unsigned int& m_FrameCounter; + //static unsigned int& m_FrameCounter; }; +inline bool ShowFlashingItem(signed int nOnDuration, signed int nOffDuration) +{ + return CTimer::m_snTimeInMillisecondsPauseMode % (nOnDuration+nOffDuration) < nOnDuration; +} + #endif \ No newline at end of file diff --git a/VCS PC/VCS PC.vcxproj b/VCS PC/VCS PC.vcxproj index 98abb90..977e9d0 100644 --- a/VCS PC/VCS PC.vcxproj +++ b/VCS PC/VCS PC.vcxproj @@ -366,6 +366,7 @@ popd + @@ -433,6 +434,7 @@ popd + diff --git a/VCS PC/VCS PC.vcxproj.filters b/VCS PC/VCS PC.vcxproj.filters index 7a5f9d5..0624fbe 100644 --- a/VCS PC/VCS PC.vcxproj.filters +++ b/VCS PC/VCS PC.vcxproj.filters @@ -213,6 +213,9 @@ Source Files + + Source Files + @@ -428,6 +431,9 @@ Header Files + + Header Files + diff --git a/VCS PC/VCSPC.cpp b/VCS PC/VCSPC.cpp index 668fe22..87835cf 100644 --- a/VCS PC/VCSPC.cpp +++ b/VCS PC/VCSPC.cpp @@ -65,7 +65,7 @@ void LoadGameFailedMessage(unsigned char bMessageIndex); void MessageLoop(); void CdStreamClearNames(); void ParseCommandlineFile(); -void ParseCommandlineArgument(const char* pArg); +char* ParseCommandlineArgument(char* pArg); BOOL IsAlreadyRunning(); CVehicle* __fastcall VehiclePoolGetAt(CVehiclePool* pThis, int unused, int nIdentifier); CPed* __fastcall PedPoolGetAt(CPedPool* pThis, int unused, int nIdentifier); @@ -160,6 +160,7 @@ void WidescreenSupportRecalculateHack3(); void WidescreenFOVHack(); void WidescreenFOVHack2(); void WidescreenBordersHack(); +void AimpointCalc(); void WidescreenTextPositionHack(); void WidescreenSkyWidthHack(); void Widescreen_SwitchInject(); @@ -321,7 +322,7 @@ BYTE* bWants_To_Draw_Hud; BYTE* radarGrey; float* WidthAspectRatio; float* HeightAspectRatio; -float* ScreenAspectRatio; +float& ScreenAspectRatio = *(float*)0xC3EFA4; float* fFOV; bool* bHideStyledTextWhileFading; char* latestMissionName; @@ -389,7 +390,7 @@ const float fNewDrawDistance = MAX_DRAW_DISTANCE; const float fSkyMultFix = 3.5f; const float fRadarTileDimensions = 2000.0; const float fMinusRadarTileDimensions = -2000.0; -const float fRadarTileDimensions2 = 7.0;; +const float fRadarTileDimensions2 = 7.0f; const float fSubtitlesWidth = 0.45f; const float fSubtitlesHeight = 0.9f; const float fTextBoxPosY = 20.0f; @@ -397,12 +398,12 @@ const float* const pRefFal = &fRefZVal; static const float fWeaponIconWidth = 75.0f; static const float fWeaponIconHeight = 72.0f; -static const float fWLStarPosX = HUD_POS_X - 116.0f; +/*static const float fWLStarPosX = HUD_POS_X - 115.25f; 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 float fWLStarAlpha = HUD_TRANSPARENCY;*/ static const char aEnglish_gxt[] = "ENGLISH.GXT"; static const char aSpanish_gxt[] = "SPANISH.GXT"; @@ -583,19 +584,20 @@ void OnGameTermination() DWORD WINAPI ProcessEmergencyKey(LPVOID lpParam) { -#if DEVBUILD - bool bKeyState = false, bFPSState = true; +#ifdef DEVBUILD + bool bKeyState = false, bFPSState = true; + static float fCurrentFOV = 70.0f; #endif UNREFERENCED_PARAMETER(lpParam); LogToFile("Emergency key thread created"); - while ( !(GetKeyState(VK_PAUSE) & 0x8000) ) + while ( !(GetAsyncKeyState(VK_PAUSE) & 0x8000) ) { Sleep(250); -#if DEVBUILD - if ( GetKeyState(VK_F9) & 0x8000 ) +#ifdef DEVBUILD + if ( GetAsyncKeyState(VK_F9) & 0x8000 ) { if ( !bKeyState ) { @@ -609,6 +611,28 @@ DWORD WINAPI ProcessEmergencyKey(LPVOID lpParam) if ( bKeyState ) bKeyState = false; } + + if ( GetAsyncKeyState(VK_OEM_4) & 0x8000 ) + { + fCurrentFOV -= 1.0f; + if ( fCurrentFOV < 15.0f ) + fCurrentFOV = 15.0f; + + Memory::Patch(0x522F3A, &fCurrentFOV); + Memory::Patch(0x522F5D, &fCurrentFOV); + Memory::Patch(0x522F7A, fCurrentFOV); + } + + if ( GetAsyncKeyState(VK_OEM_6) & 0x8000 ) + { + fCurrentFOV += 1.0f; + if ( fCurrentFOV > 170.0f ) + fCurrentFOV = 170.0f; + + Memory::Patch(0x522F3A, &fCurrentFOV); + Memory::Patch(0x522F5D, &fCurrentFOV); + Memory::Patch(0x522F7A, fCurrentFOV); + } #endif #if !defined DEVBUILD && !defined COMPILE_RC @@ -879,7 +903,6 @@ __forceinline void DefineVariables() radarGrey = (BYTE*)0xA444A4; WidthAspectRatio = (float*)0x859520; HeightAspectRatio = (float*)0x859524; - ScreenAspectRatio = (float*)0xC3EFA4; fFOV = (float*)0x8D5038; bHideStyledTextWhileFading = (bool*)0xA44489; latestMissionName = (char*)0xB78A00; @@ -1935,14 +1958,29 @@ void TempExitFix() ExitProcess(0); } -static const RwMatrix* pMat; +/*static const RwMatrix* pMat; static const RwSphere* pSphere; +#include "TimeCycle.h" + struct CShadowCamera { RwCamera* m_pCamera; RwTexture* m_pTexture; + void Rescale(RpLight* pLight) + { + /*RwMatrix* pCamMat = RwFrameGetMatrix(RwCameraGetFrame(m_pCamera)); + RwMatrix* pLightMat = RwFrameGetMatrix(RpLightGetFrame(pLight)); + + pCamMat->right = pLightMat->right; + pCamMat->up = pLightMat->up; + pCamMat->at = pLightMat->at; + + RwMatrixUpdate(pCamMat); + RwFrameUpdateObjects(RwCameraGetFrame(m_pCamera));*/ +/* } + RwCamera* SetCenter(RwV3d* vector) { RwFrame* pCamFrame = RwCameraGetFrame(m_pCamera); @@ -1954,18 +1992,27 @@ struct CShadowCamera m_pCamera->farPlane * -0.5 * pCamFrame->modelling.at.z + vector->z);*/ //Helper.SetTranslateOnly(538.648, -1065.9757, 11.0); - CVector vecToSun; + - vecToSun.x = pMat->pos.x - 538.6483f; - vecToSun.y = pMat->pos.y - -1065.9757f; - vecToSun.z = pMat->pos.z - 11.0f; + //CVector vecToSun(pMat->pos - CTimeCycle::m_VectorToSun[CTimeCycle::m_CurrentStoredValue]); +/* CVector vecToSun = -CTimeCycle::m_VectorToSun[CTimeCycle::m_CurrentStoredValue]; + vecToSun.z = 0.0f; vecToSun.Normalize(); + //CMatrix ScalingMatrix; + + //ScalingMatrix.SetScale(1.0f); - Helper.SetRotateOnly(-M_PI/2, 0.0, atan2(-vecToSun.x, vecToSun.y)); + /*vecToSun.x = pMat->pos.x - 538.6483f; + vecToSun.y = pMat->pos.y - -1065.9757f; + vecToSun.z = pMat->pos.z - 11.0f;*/ + +/* Helper.SetRotateOnly(-M_PI/2, 0.0, atan2(-vecToSun.x, vecToSun.y)); vecToSun = pMat->pos - (vecToSun*pSphere->radius * 1.1f); Helper.SetTranslateOnly(vecToSun.x, vecToSun.y, vecToSun.z); + //CMatrix SecondHelper = Helper * ScalingMatrix; + //Helper.CopyOnlyMatrix(SecondHelper); //Helper.SetTranslateOnly(vector->x, vector->y, vector->z); Helper.UpdateRW(); @@ -1982,7 +2029,7 @@ struct CShadowCamera vecAt += matrix->at;*/ // pos - CCoronas::RegisterCorona(111111112, nullptr, 255, 255, 0, 255, vecPos, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); +/* CCoronas::RegisterCorona(111111112, nullptr, 255, 255, 0, 255, vecPos, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); // right CCoronas::RegisterCorona(111111112 + 1, nullptr, 255, 0, 0, 255, vecRight, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); @@ -2002,7 +2049,7 @@ struct CShadowCamera //memcpy(pCamMat, &Helper.matrix, sizeof(RwMatrix)); //RwMatrixUpdate(pCamMat); - RwFrameUpdateObjects(pCamFrame); +/* RwFrameUpdateObjects(pCamFrame); RwFrameOrthoNormalize(pCamFrame); return m_pCamera; @@ -2019,7 +2066,7 @@ RwV3d* CheckRenderingSrc(RwV3d* pointsOut, const RwSphere* pointsIn, RwInt32 num //vecIn.x = -2.0f; //vecIn.y = 0.0; //vecIn.z = 0.0f; - *pointsOut = matrix->pos; +/* *pointsOut = matrix->pos; pMat = matrix; pSphere = pointsIn; @@ -2029,7 +2076,31 @@ RwV3d* CheckRenderingSrc(RwV3d* pointsOut, const RwSphere* pointsIn, RwInt32 num return pointsOut; } -static const RwV3d FakeSunValues = { 0 }; +float* RescaleHook(float* pointsOut, const RwV3d* pointsIn, RwInt32 numPoints, const RwMatrix* matrix) +{ + //RwV3d vecIn = pointsIn->center; + + /*vecIn.x *= 5.0f; + vecIn.y *= 5.0f; + vecIn.z *= 5.0f;*/ + //vecIn.x = -2.0f; + //vecIn.y = 0.0; + //vecIn.z = 0.0f; +/* pointsOut[0] = matrix->pos.x; + pointsOut[1] = matrix->pos.y; + pointsOut[2] = matrix->pos.z; + pointsOut[3] *= 2.0f; + //*pointsOut = matrix->pos; + + //pMat = matrix; + //pSphere = pointsIn; + + //auto* pVec = RwV3dTransformPoints(pointsOut, &vecIn, numPoints, matrix); + + return pointsOut; +} + +static const RwV3d FakeSunValues = { 0 };*/ void* __stdcall CorrectedMallocTest(int nSize, int nAlign) { @@ -2174,16 +2245,22 @@ __forceinline void Main_Patches() Patch(0x7064C2, 9); Patch(0x7064F9, 8); Patch(0x53E159, 0xC3); - Patch(0x70BDA0, 0x042474FF); - Patch(0x70BDA4, 0xC40350B9); - Patch(0x70BDA8, 0xADF2E800); - Patch(0x70BDAC, 0x90C3FFFF); + //Patch(0x70BDA0, 0x042474FF); + //Patch(0x70BDA4, 0xC40350B9); + //Patch(0x70BDA8, 0xADF2E800); + //Patch(0x70BDAC, 0x90C3FFFF); Patch(0x707E09, 0x9090C031); Patch(0x707E0D, 0x90); + //Patch(0x707E4F, 0x900CC483); + //Patch(0x707E53, 0x90); Patch(0x707E14, &FakeSunValues); Patch(0x707E1B, &FakeSunValues); InjectHook(0x70663A, CheckRenderingSrc); + //InjectHook(0x706573, RescaleHook); InjectMethod(0x70664C, CShadowCamera::SetCenter, PATCH_NOTHING); + InjectMethod(0x705981, CShadowCamera::Rescale, PATCH_NOTHING); + //static const float fFrustumSize = 2.0f; + //Patch(0x7065CC, &fFrustumSize); #endif #ifndef DONT_FIX_STREAMING @@ -2209,6 +2286,12 @@ __forceinline void Main_Patches() Patch(0x4C9290, 0xE281); Patch(0x4C9292, 0xFFFDFFFC); + // Bumped up shadows quality + Memory::Patch(0x706825, 8); + Memory::Patch(0x706832, 8); + Memory::Patch(0x7064C2, 9); + Memory::Patch(0x7064F9, 8); + // 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 @@ -2321,13 +2404,14 @@ __forceinline void Main_Patches() if ( !IVHudPresent() ) { InjectHook(0x58FBD6, CHud::DrawHUD); + InjectHook(0x58FBDB, CHud::DrawWanted); Patch(0x58D896, &fWeaponIconHeight); Patch(0x58D94D, &fWeaponIconHeight); Patch(0x58D8CB, &fWeaponIconWidth); Patch(0x58D935, &fWeaponIconWidth); //Patch(0x58D89B, HUD_TRANSPARENCY); - Patch(0x58DF18, 0xE990); + /*Patch(0x58DF18, 0xE990); Patch(0x58DE23, 0xEB); InjectHook(0x588B60, CHud::GetYPosBasedOnHealth, PATCH_JUMP); Patch(0x58DD41, 0); @@ -2347,7 +2431,7 @@ __forceinline void Main_Patches() Patch(0x58DCC0, &fWLStarWidth); Patch(0x58DD86, &fWLStarWidth); Patch(0x58DFED, &fWLStarDistance); - Patch(0x58D9BA, &fWLStarAlpha); + Patch(0x58D9BA, &fWLStarAlpha);*/ /*Patch(0x5834C2, &fRadarWidth); Patch(0x58781B, &fRadarWidth); Patch(0x58A449, &fRadarWidth); @@ -3228,7 +3312,7 @@ __forceinline void Main_Patches() patch(0x7469A0, 0x909000B0, 4); // Commandline arguments - patch(0x619C40, &CommandlineEventHack, 4); + Patch(0x619C40, &CommandlineEventHack); InjectHook(0x7488FB, ReadCommandlineFile, PATCH_JUMP); // DLC support @@ -3393,10 +3477,11 @@ __forceinline void Main_Patches() patch(0x57639A, &WidescreenSupport::f0pt7_h, 4); Patch(0x714843, &fSkyMultFix); Patch(0x714860, &fSkyMultFix); - patch(0x70CEF8, &WidescreenSupport::fScreenCoorsFix, 4); - patch(0x71DA8D, &WidescreenSupport::fScreenCoorsFix, 4); + Patch(0x70CEF8, &WidescreenSupport::fScreenCoorsFix); + Patch(0x71DA8D, &WidescreenSupport::fScreenCoorsFix); // patch(0x52C9DB, &WidescreenSupport::fSpawningFix, 4); // Tmp - patch(0x514986, &WidescreenSupport::fAimpointFix, 4); + ///Patch(0x514986, &WidescreenSupport::fAimpointFix); + //Patch(0x50AD53, &WidescreenSupport::fAimpointFix); // Not needed? Patch(0x58BBCB, &fTextBoxPosY); /*patch(0x58C0DE, &WidescreenSupport::fTextDrawsWidthMultiplier, 4); patch(0x58C12D, &WidescreenSupport::fTextDrawsWidthMultiplier, 4); @@ -3414,6 +3499,7 @@ __forceinline void Main_Patches() InjectHook(0x72FCF9, WidescreenFOVHack, PATCH_JUMP); InjectHook(0x514D63, WidescreenFOVHack2, PATCH_CALL); InjectHook(0x514878, WidescreenBordersHack); + InjectHook(0x51499E, AimpointCalc, PATCH_JUMP); InjectHook(0x5BC8FF, CameraInitHack, PATCH_JUMP); InjectHook(0x58C3C8, WidescreenTextPositionHack, PATCH_CALL); InjectHook(0x58BB88, WidescreenSupport::GetTextBoxPos, PATCH_CALL); @@ -3423,6 +3509,7 @@ __forceinline void Main_Patches() // InjectHook(0x58C0BB, Widescreen_TextDrawsFix, PATCH_CALL); InjectHook(0x58C1EC, Widescreen_TextDrawsFix2, PATCH_JUMP); patch(0x58BB8D, 0x05EB, 2); + Nop(0x50AD79, 6); Nop(0x58C3CD, 1); // Nop(0x714846, 1); Nop(0x514D68, 1); @@ -4464,14 +4551,14 @@ void ParseCommandlineFile() ParseCommandlineArgument(strtok(cLine, " ")); while ( char* pNextArg = strtok(nullptr, " ") ) - ParseCommandlineArgument(pNextArg); + pNextArg = ParseCommandlineArgument(pNextArg); } fclose(hFile); } } -void ParseCommandlineArgument(const char* pArg) +char* ParseCommandlineArgument(char* pArg) { if ( pArg ) { @@ -4479,33 +4566,48 @@ void ParseCommandlineArgument(const char* pArg) { SetWindowTextW(RsGlobal.ps->window, L"GTA: San Andreas"); RsGlobal.AppName = "GTA: San Andreas"; - return; + return pArg; } if ( !_strnicmp(pArg, "-nointro", 8) ) { // TODO: Define this variable properly *(DWORD*)0xC8D4C0 = 5; - return; + return pArg; } if ( !_strnicmp(pArg, "-notimefix", 10) ) { bNoTimeFix = true; - return; + return pArg; + } + + if ( !_strnicmp(pArg, "-pedshadowquality", 18) ) + { + pArg = strtok(nullptr, " "); + int nNewShadowQuality = atoi(pArg); + + if ( nNewShadowQuality >= 1 && nNewShadowQuality <= 4 ) + { + Memory::Patch(0x706825, static_cast(nNewShadowQuality + 5)); + Memory::Patch(0x706832, static_cast(nNewShadowQuality + 5)); + Memory::Patch(0x7064C2, static_cast(nNewShadowQuality + 6)); + Memory::Patch(0x7064F9, static_cast(nNewShadowQuality + 5)); + } + return pArg; } #ifdef DEVBUILD if ( !_strnicmp(pArg, "-noautocheck", 13) ) { CUpdateManager::DisableAutoCheck(); - return; + return pArg; } if ( !_strnicmp(pArg, "-zombiedlc", 10) ) { CDLCManager::ToggleDebugOverride(DLC_HALLOWEEN); - return; + return pArg; } /*if ( !_strnicmp(pArg, "-2dfx", 5) ) @@ -4515,6 +4617,7 @@ void ParseCommandlineArgument(const char* pArg) }*/ #endif } + return pArg; } BOOL IsAlreadyRunning() @@ -5980,7 +6083,7 @@ void __declspec(naked) WidescreenFOVHack() jmp WidescreenFOVHack_JumpBack WidescreenFOVHack_DoFOV: - fmul [WidescreenSupport::fFOVMultiplier] + //fmul [WidescreenSupport::fFOVMultiplier] fst [esp+14h] fmul [esp+50h] fstp [esp+10h] @@ -5988,7 +6091,7 @@ void __declspec(naked) WidescreenFOVHack() } } -void __declspec(naked) WidescreenFOVHack2() +/*void __declspec(naked) WidescreenFOVHack2() { _asm { @@ -6007,9 +6110,40 @@ void __declspec(naked) WidescreenFOVHack2() fld [eax] mov eax, [fFOV] fmul [eax] - fmul [WidescreenSupport::fFOVMultiplier] + //fmul [WidescreenSupport::fFOVMultiplier] retn } +}*/ + +static float CalcFOV() +{ + float TehFOV = ScreenAspectRatio > 1.0f ? *fFOV * ScreenAspectRatio : *fFOV; + return TehFOV >= 175.0f ? 175.0f : TehFOV; +} + +void __declspec(naked) WidescreenFOVHack2() +{ + _asm + { + push ecx + call CalcFOV + pop ecx + retn + } +} + +void __declspec(naked) AimpointCalc() +{ + _asm + { + fstp st + mov edx, [ScreenAspectRatio] + fmul [edx] + mov edi, [esp+1Ch+14h] + mov edx, edi + mov ebx, 5149A6h + jmp ebx + } } void __declspec(naked) WidescreenBordersHack() diff --git a/VCS PC/WidescreenSupport.cpp b/VCS PC/WidescreenSupport.cpp index ceaee41..db8aa43 100644 --- a/VCS PC/WidescreenSupport.cpp +++ b/VCS PC/WidescreenSupport.cpp @@ -59,7 +59,8 @@ 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); +//const float WidescreenSupport::fFOVMultiplier = 1.0f/((4.0f/3.0f)/1.1f); +//const float WidescreenSupport::fFOVMultiplier = 1.0f/((4.0f/3.0f)/1.0f); void WidescreenSupport::Recalculate(int nWidth, int nHeight, bool bAlways) { @@ -136,9 +137,11 @@ void WidescreenSupport::Recalculate(int nWidth, int nHeight, bool bAlways) fCTSliderRight = 0.5f + (50.0f/fNewResolutionWidthMultiplier); fCTSliderLeft = 0.5f - (50.0f/fNewResolutionWidthMultiplier); fScreenCoorsFix = 44800.0f/fNewResolutionWidthMultiplier; - fAimpointFix = (9.0f/12800.0f)*fNewResolutionWidthMultiplier + 0.1f; + //fAimpointFix = (9.0f/12800.0f)*fNewResolutionWidthMultiplier + 0.1f; fMapZonePosX2 = 7.5f/fNewResolutionWidthMultiplier; + fAimpointFix = 0.5f * atan(RAD_TO_DEG * SetAspectRatio()) /** ((4.0f/3.0f)/1.1f)*/; + f0pt7_h = 0.7f/fNewResolutionHeightMultiplier; f0pt95_h = 0.95f/fNewResolutionHeightMultiplier; f1pt2_h = 1.2f/fNewResolutionHeightMultiplier; @@ -161,23 +164,23 @@ float WidescreenSupport::SetAspectRatio() switch ( FrontEndMenuManager.m_bAspectRatioMode ) { case 1: - return *ScreenAspectRatio = 4.0f/3.0f; + return ScreenAspectRatio = 4.0f/3.0f; case 2: - return *ScreenAspectRatio = 5.0f/4.0f; + return ScreenAspectRatio = 5.0f/4.0f; case 3: - return *ScreenAspectRatio = 15.0f/9.0f; + return ScreenAspectRatio = 15.0f/9.0f; case 4: - return *ScreenAspectRatio = 16.0f/9.0f; + return ScreenAspectRatio = 16.0f/9.0f; case 5: - return *ScreenAspectRatio = 16.0f/10.0f; + return ScreenAspectRatio = 16.0f/10.0f; default: - return *ScreenAspectRatio = static_cast(RsGlobal.MaximumWidth) / RsGlobal.MaximumHeight; + return ScreenAspectRatio = static_cast(RsGlobal.MaximumWidth) / RsGlobal.MaximumHeight; } } float WidescreenSupport::GetTextPosition() { - float fScreenRatio = *ScreenAspectRatio; + float fScreenRatio = ScreenAspectRatio; double dTextPos = (-3375.0 * fScreenRatio * fScreenRatio) + (10800.0 * fScreenRatio) - 8545.0; return dTextPos > 80.0 ? static_cast(dTextPos) : 80.0f; } @@ -197,7 +200,7 @@ unsigned char WidescreenSupport::GetTextBoxPos() dTextBoxPos -= dTextBoxPos * dBorderProportionsFix; return dTextBoxPos > 0.0 ? dTextBoxPos : 0;*/ - float fScreenRatio = *ScreenAspectRatio; + float fScreenRatio = ScreenAspectRatio; float dScreenHeightWeWannaCut = ((-9.0f/16.0f) * fScreenRatio + 1.0f); float dBorderProportionsFix = ((-144643.0f/50000.0f) * fScreenRatio * fScreenRatio) + ((807321.0f/100000.0f) * fScreenRatio) - (551143.0f/100000.0f); diff --git a/VCS PC/WidescreenSupport.h b/VCS PC/WidescreenSupport.h index cfa1bbb..3bdf1d2 100644 --- a/VCS PC/WidescreenSupport.h +++ b/VCS PC/WidescreenSupport.h @@ -63,7 +63,7 @@ class WidescreenSupport // static float fTextDrawsWidthMultiplier; - static const float fFOVMultiplier; + //static const float fFOVMultiplier; static void Recalculate(int nWidth, int nHeight, bool bAlways); static float SetAspectRatio();