From 4b8d9be79935ef83f0c1ff73a9f551855e8d9e7f Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 23 Jun 2014 14:54:36 +0200 Subject: [PATCH] Numberplates now randomised a bit --- SilentPatch/StdAfx.h | 6 ++++++ SilentPatch/Vehicle.cpp | 9 ++++++++- SilentPatch/Vehicle.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SilentPatch/StdAfx.h b/SilentPatch/StdAfx.h index 7317549..91af79e 100644 --- a/SilentPatch/StdAfx.h +++ b/SilentPatch/StdAfx.h @@ -34,6 +34,12 @@ void GTAdelete(void* data); extern unsigned char& nGameClockDays; extern unsigned char& nGameClockMonths; +template +inline T random(T a, T b) +{ + return a + static_cast(rand() * (1.0f/(RAND_MAX+1)) * (b - a)); +} + //#define HIDE_MATERIAL //#define EXPAND_ALPHA_ENTITY_LISTS 800 //#define EXPAND_BOAT_ALPHA_ATOMIC_LISTS 400 diff --git a/SilentPatch/Vehicle.cpp b/SilentPatch/Vehicle.cpp index 619cf93..29890d2 100644 --- a/SilentPatch/Vehicle.cpp +++ b/SilentPatch/Vehicle.cpp @@ -5,6 +5,7 @@ WRAPPER void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) { WRAPARG(pAtomic); WRAPARG(nAlpha); EAXJMP(0x6D2960); } WRAPPER void CVehicle::Render() { EAXJMP(0x6D0E60); } +WRAPPER bool CVehicle::IsLawEnforcementVehicle() { EAXJMP(0x6D2370); } static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data) { @@ -27,7 +28,13 @@ bool CVehicle::CustomCarPlate_TextureCreate(CVehicleModelInfo* pModelInfo) CCustomCarPlateMgr::GeneratePlateText(PlateText, 8); PlateTexture = CCustomCarPlateMgr::CreatePlateTexture(PlateText, pModelInfo->m_nPlateType); - PlateDesign = pModelInfo->m_nPlateType != -1 ? pModelInfo->m_nPlateType : CCustomCarPlateMgr::GetMapRegionPlateDesign(); + //PlateDesign = pModelInfo->m_nPlateType != -1 ? pModelInfo->m_nPlateType : CCustomCarPlateMgr::GetMapRegionPlateDesign(); + if ( pModelInfo->m_nPlateType != -1 ) + PlateDesign = pModelInfo->m_nPlateType; + else if ( IsLawEnforcementVehicle() ) + PlateDesign = CCustomCarPlateMgr::GetMapRegionPlateDesign(); + else + PlateDesign = random(0, 20) == 0 ? random(0, 3) : CCustomCarPlateMgr::GetMapRegionPlateDesign(); assert(PlateDesign >= 0 && PlateDesign < 3); diff --git a/SilentPatch/Vehicle.h b/SilentPatch/Vehicle.h index 6bc3710..818ac9e 100644 --- a/SilentPatch/Vehicle.h +++ b/SilentPatch/Vehicle.h @@ -113,6 +113,8 @@ public: void CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo); void CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo); + bool IsLawEnforcementVehicle(); + static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); };