From 0f9178568b3470d35ffc1d5e21a230d8cc11eef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 16 Sep 2019 20:32:58 +0300 Subject: Peds, a fix and a tad of VC --- src/core/General.h | 9 +-------- src/core/World.h | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/General.h b/src/core/General.h index 366c571c..d73cf36f 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -54,14 +54,7 @@ public: static float LimitRadianAngle(float angle) { - float result; - - if (angle < -25.0f) - result = -25.0f; - else if (angle > 25.0f) - result = 25.0f; - else - result = angle; + float result = clamp(angle, -25.0f, 25.0f); while (result >= PI) { result -= 2 * PI; diff --git a/src/core/World.h b/src/core/World.h index b24e66f0..523585e7 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -56,9 +56,10 @@ class CWorld static CPtrList &ms_listMovingEntityPtrs; static CSector (*ms_aSectors)[NUMSECTORS_X]; // [NUMSECTORS_Y][NUMSECTORS_X]; static uint16 &ms_nCurrentScanCode; - static CColPoint &ms_testSpherePoint; public: + static CColPoint& ms_testSpherePoint; + static uint8 &PlayerInFocus; static CPlayerInfo *Players; static CEntity *&pIgnoreEntity; -- cgit v1.2.3 From 0c385195d8ac10ac677d1b470af7845615ce742a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 27 Sep 2019 00:01:50 +0300 Subject: Peds, ProcessObjective and fixes --- src/core/config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 81e2f2fb..161cf898 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -137,5 +137,6 @@ enum Config { #define USE_DEBUG_SCRIPT_LOADER #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher #define ANIMATE_PED_COL_MODEL -#define CANCELLABLE_CAR_ENTER //#define REMOVE_TREADABLE_PATHFIND +#define CANCELLABLE_CAR_ENTER +#define VC_PED_PORTS -- cgit v1.2.3 From 6362ceeff305b47063622b2ce19152b699963a66 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 17:03:00 +0300 Subject: Full CCutsceneMgr --- src/core/Camera.cpp | 6 + src/core/Camera.h | 11 ++ src/core/CutsceneMgr.cpp | 419 +++++++++++++++++++++++++++++++++++++++++++++ src/core/CutsceneMgr.h | 27 +++ src/core/Pad.h | 1 + src/core/TempColModels.cpp | 2 +- src/core/TempColModels.h | 2 +- 7 files changed, 466 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index cb16c3ad..93680dc1 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -30,6 +30,12 @@ WRAPPER void CCamera::SetCamPositionForFixedMode(const CVector&, const CVector&) WRAPPER void CCamera::Init(void) { EAXJMP(0x46BAD0); } WRAPPER void CCamera::SetRwCamera(RwCamera*) { EAXJMP(0x46FEC0); } WRAPPER void CCamera::Process(void) { EAXJMP(0x46D3F0); } +WRAPPER void CCamera::LoadPathSplines(int file) { EAXJMP(0x46D1D0); } +WRAPPER uint32 CCamera::GetCutSceneFinishTime(void) { EAXJMP(0x46B920); } +WRAPPER void CCamera::FinishCutscene(void) { EAXJMP(0x46B560); } +WRAPPER void CCamera::SetCamCutSceneOffSet(const CVector&) { EAXJMP(0x46FC30); }; +WRAPPER void CCamera::TakeControlWithSpline(short) { EAXJMP(0x471620); }; +WRAPPER void CCamera::RestoreWithJumpCut(void) { EAXJMP(0x46FAE0); }; bool CCamera::GetFading() diff --git a/src/core/Camera.h b/src/core/Camera.h index 1f38963b..de725b19 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -444,6 +444,7 @@ int m_iModeObbeCamIsInForCar; bool Get_Just_Switched_Status() { return m_bJust_Switched; } inline const CMatrix& GetCameraMatrix(void) { return m_cameraMatrix; } CVector &GetGameCamPosition(void) { return m_vecGameCamPos; } + float GetPositionAlongSpline(void) { return m_fPositionAlongSpline; } bool IsPointVisible(const CVector ¢er, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius); @@ -480,6 +481,16 @@ int m_iModeObbeCamIsInForCar; void SetRwCamera(RwCamera*); void Process(); + void LoadPathSplines(int file); + uint32 GetCutSceneFinishTime(void); + void FinishCutscene(void); + + void SetCamCutSceneOffSet(const CVector&); + void TakeControlWithSpline(short); + void SetWideScreenOn(void) { m_WideScreenOn = true; } + void SetWideScreenOff(void) { m_WideScreenOn = false; } + void RestoreWithJumpCut(void); + void dtor(void) { this->CCamera::~CCamera(); } }; static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error"); diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index a54e8ff6..40ae0d2e 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -1,8 +1,427 @@ #include "common.h" #include "patcher.h" #include "CutsceneMgr.h" +#include "Directory.h" +#include "Camera.h" +#include "Streaming.h" +#include "FileMgr.h" +#include "main.h" +#include "AnimManager.h" +#include "AnimBlendAssocGroup.h" +#include "AnimBlendClumpData.h" +#include "Pad.h" +#include "DMAudio.h" +#include "World.h" +#include "PlayerPed.h" +#include "CutsceneHead.h" +#include "RpAnimBlend.h" +#include "ModelIndices.h" +#include "TempColModels.h" +#include "MusicManager.h" + +const struct { + const char *szTrackName; + int iTrackId; +} musicNameIdAssoc[] = { + { "JB", STREAMED_SOUND_NEWS_INTRO }, + { "BET", STREAMED_SOUND_BANK_INTRO }, + { "L1_LG", STREAMED_SOUND_CUTSCENE_LUIGI1_LG }, + { "L2_DSB", STREAMED_SOUND_CUTSCENE_LUIGI2_DSB }, + { "L3_DM", STREAMED_SOUND_CUTSCENE_LUIGI3_DM }, + { "L4_PAP", STREAMED_SOUND_CUTSCENE_LUIGI4_PAP }, + { "L5_TFB", STREAMED_SOUND_CUTSCENE_LUIGI5_TFB }, + { "J0_DM2", STREAMED_SOUND_CUTSCENE_JOEY0_DM2 }, + { "J1_LFL", STREAMED_SOUND_CUTSCENE_JOEY1_LFL }, + { "J2_KCL", STREAMED_SOUND_CUTSCENE_JOEY2_KCL }, + { "J3_VH", STREAMED_SOUND_CUTSCENE_JOEY3_VH }, + { "J4_ETH", STREAMED_SOUND_CUTSCENE_JOEY4_ETH }, + { "J5_DST", STREAMED_SOUND_CUTSCENE_JOEY5_DST }, + { "J6_TBJ", STREAMED_SOUND_CUTSCENE_JOEY6_TBJ }, + { "T1_TOL", STREAMED_SOUND_CUTSCENE_TONI1_TOL }, + { "T2_TPU", STREAMED_SOUND_CUTSCENE_TONI2_TPU }, + { "T3_MAS", STREAMED_SOUND_CUTSCENE_TONI3_MAS }, + { "T4_TAT", STREAMED_SOUND_CUTSCENE_TONI4_TAT }, + { "T5_BF", STREAMED_SOUND_CUTSCENE_TONI5_BF }, + { "S0_MAS", STREAMED_SOUND_CUTSCENE_SAL0_MAS }, + { "S1_PF", STREAMED_SOUND_CUTSCENE_SAL1_PF }, + { "S2_CTG", STREAMED_SOUND_CUTSCENE_SAL2_CTG }, + { "S3_RTC", STREAMED_SOUND_CUTSCENE_SAL3_RTC }, + { "S5_LRQ", STREAMED_SOUND_CUTSCENE_SAL5_LRQ }, + { "S4_BDBA", STREAMED_SOUND_CUTSCENE_SAL4_BDBA }, + { "S4_BDBB", STREAMED_SOUND_CUTSCENE_SAL4_BDBB }, + { "S2_CTG2", STREAMED_SOUND_CUTSCENE_SAL2_CTG2 }, + { "S4_BDBD", STREAMED_SOUND_CUTSCENE_SAL4_BDBD }, + { "S5_LRQB", STREAMED_SOUND_CUTSCENE_SAL5_LRQB }, + { "S5_LRQC", STREAMED_SOUND_CUTSCENE_SAL5_LRQC }, + { "A1_SS0", STREAMED_SOUND_CUTSCENE_ASUKA_1_SSO }, + { "A2_PP", STREAMED_SOUND_CUTSCENE_ASUKA_2_PP }, + { "A3_SS", STREAMED_SOUND_CUTSCENE_ASUKA_3_SS }, + { "A4_PDR", STREAMED_SOUND_CUTSCENE_ASUKA_4_PDR }, + { "A5_K2FT", STREAMED_SOUND_CUTSCENE_ASUKA_5_K2FT}, + { "K1_KBO", STREAMED_SOUND_CUTSCENE_KENJI1_KBO }, + { "K2_GIS", STREAMED_SOUND_CUTSCENE_KENJI2_GIS }, + { "K3_DS", STREAMED_SOUND_CUTSCENE_KENJI3_DS }, + { "K4_SHI", STREAMED_SOUND_CUTSCENE_KENJI4_SHI }, + { "K5_SD", STREAMED_SOUND_CUTSCENE_KENJI5_SD }, + { "R0_PDR2", STREAMED_SOUND_CUTSCENE_RAY0_PDR2 }, + { "R1_SW", STREAMED_SOUND_CUTSCENE_RAY1_SW }, + { "R2_AP", STREAMED_SOUND_CUTSCENE_RAY2_AP }, + { "R3_ED", STREAMED_SOUND_CUTSCENE_RAY3_ED }, + { "R4_GF", STREAMED_SOUND_CUTSCENE_RAY4_GF }, + { "R5_PB", STREAMED_SOUND_CUTSCENE_RAY5_PB }, + { "R6_MM", STREAMED_SOUND_CUTSCENE_RAY6_MM }, + { "D1_STOG", STREAMED_SOUND_CUTSCENE_DONALD1_STOG }, + { "D2_KK", STREAMED_SOUND_CUTSCENE_DONALD2_KK }, + { "D3_ADO", STREAMED_SOUND_CUTSCENE_DONALD3_ADO }, + { "D5_ES", STREAMED_SOUND_CUTSCENE_DONALD5_ES }, + { "D7_MLD", STREAMED_SOUND_CUTSCENE_DONALD7_MLD }, + { "D4_GTA", STREAMED_SOUND_CUTSCENE_DONALD4_GTA }, + { "D4_GTA2", STREAMED_SOUND_CUTSCENE_DONALD4_GTA2 }, + { "D6_STS", STREAMED_SOUND_CUTSCENE_DONALD6_STS }, + { "A6_BAIT", STREAMED_SOUND_CUTSCENE_ASUKA6_BAIT }, + { "A7_ETG", STREAMED_SOUND_CUTSCENE_ASUKA7_ETG }, + { "A8_PS", STREAMED_SOUND_CUTSCENE_ASUKA8_PS }, + { "A9_ASD", STREAMED_SOUND_CUTSCENE_ASUKA9_ASD }, + { "K4_SHI2", STREAMED_SOUND_CUTSCENE_KENJI4_SHI2 }, + { "C1_TEX", STREAMED_SOUND_CUTSCENE_CATALINA1_TEX }, + { "EL_PH1", STREAMED_SOUND_CUTSCENE_ELBURRO1_PH1 }, + { "EL_PH2", STREAMED_SOUND_CUTSCENE_ELBURRO2_PH2 }, + { "EL_PH3", STREAMED_SOUND_CUTSCENE_ELBURRO3_PH3 }, + { "EL_PH4", STREAMED_SOUND_CUTSCENE_ELBURRO4_PH4 }, + { "YD_PH1", STREAMED_SOUND_CUTSCENE_YARDIE_PH1 }, + { "YD_PH2", STREAMED_SOUND_CUTSCENE_YARDIE_PH2 }, + { "YD_PH3", STREAMED_SOUND_CUTSCENE_YARDIE_PH3 }, + { "YD_PH4", STREAMED_SOUND_CUTSCENE_YARDIE_PH4 }, + { "HD_PH1", STREAMED_SOUND_CUTSCENE_HOODS_PH1 }, + { "HD_PH2", STREAMED_SOUND_CUTSCENE_HOODS_PH2 }, + { "HD_PH3", STREAMED_SOUND_CUTSCENE_HOODS_PH3 }, + { "HD_PH4", STREAMED_SOUND_CUTSCENE_HOODS_PH4 }, + { "HD_PH5", STREAMED_SOUND_CUTSCENE_HOODS_PH5 }, + { "MT_PH1", STREAMED_SOUND_CUTSCENE_MARTY_PH1 }, + { "MT_PH2", STREAMED_SOUND_CUTSCENE_MARTY_PH2 }, + { "MT_PH3", STREAMED_SOUND_CUTSCENE_MARTY_PH3 }, + { "MT_PH4", STREAMED_SOUND_CUTSCENE_MARTY_PH4 }, + { NULL, NULL } +}; + +int +FindCutsceneAudioTrackId(const char *szCutsceneName) +{ + for (int i = 0; musicNameIdAssoc[i].szTrackName; i++) + { + if (!strcmpi(musicNameIdAssoc[i].szTrackName, szCutsceneName)) + return musicNameIdAssoc[i].iTrackId; + } + return -1; +} bool &CCutsceneMgr::ms_running = *(bool*)0x95CCF5; bool &CCutsceneMgr::ms_cutsceneProcessing = *(bool*)0x95CD9F; CDirectory *&CCutsceneMgr::ms_pCutsceneDir = *(CDirectory**)0x8F5F88; CCutsceneObject *(&CCutsceneMgr::ms_pCutsceneObjects)[NUMCUTSCENEOBJECTS] = *(CCutsceneObject*(*)[NUMCUTSCENEOBJECTS]) *(uintptr*) 0x862170; +int32 &CCutsceneMgr::ms_numCutsceneObjs = *(int32*)0x942FA4; +bool &CCutsceneMgr::ms_loaded = *(bool*)0x95CD95; +bool &CCutsceneMgr::ms_animLoaded = *(bool*)0x95CDA0; +bool &CCutsceneMgr::ms_useLodMultiplier = *(bool*)0x95CD74; +char(&CCutsceneMgr::ms_cutsceneName)[8] = *(char(*)[8]) *(uintptr*)0x70D9D0; +CAnimBlendAssocGroup &CCutsceneMgr::ms_cutsceneAssociations = *(CAnimBlendAssocGroup*)0x709C58; +CVector &CCutsceneMgr::ms_cutsceneOffset = *(CVector*)0x8F2C0C; +float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548; +uint32 &CCutsceneMgr::ms_cutsceneLoadStatus = *(uint32*)0x95CB40; + +WRAPPER RpAtomic* CalculateBoundingSphereRadiusCB(RpAtomic * atomic, void *data) { EAXJMP(0x404B40); } + +void +CCutsceneMgr::Initialise(void) +{ + ms_numCutsceneObjs = 0; + ms_loaded = false; + ms_running = false; + ms_animLoaded = false; + ms_cutsceneProcessing = false; + ms_useLodMultiplier = false; + + ms_pCutsceneDir = new CDirectory(512); + ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); +} + +void +CCutsceneMgr::Shutdown(void) +{ + if (ms_pCutsceneDir) + delete ms_pCutsceneDir; +} + +void +CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName) +{ + int file; + uint32 size; + uint32 offset; + CPlayerPed *pPlayerPed; + + ms_cutsceneProcessing = true; + if (!strcmpi(szCutsceneName, "jb")) + ms_useLodMultiplier = true; + CTimer::Stop(); + + ms_pCutsceneDir->numEntries = 0; + ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); + + CStreaming::RemoveUnusedModelsInLoadedList(); + CGame::DrasticTidyUpMemory(); + + strcpy(ms_cutsceneName, szCutsceneName); + file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb"); + + // Load animations + sprintf(gString, "%s.IFP", szCutsceneName); + if (ms_pCutsceneDir->FindItem(gString, offset, size)) { + CStreaming::MakeSpaceFor(size << 11); + CStreaming::ImGonnaUseStreamingMemory(); + CFileMgr::Seek(file, offset << 11, SEEK_SET); + CAnimManager::LoadAnimFile(file, false); + ms_cutsceneAssociations.CreateAssociations(szCutsceneName); + CStreaming::IHaveUsedStreamingMemory(); + ms_animLoaded = true; + } else { + ms_animLoaded = false; + } + + // Load camera data + sprintf(gString, "%s.DAT", szCutsceneName); + if (ms_pCutsceneDir->FindItem(gString, offset, size)) { + CFileMgr::Seek(file, offset << 11, SEEK_SET); + TheCamera.LoadPathSplines(file); + } + + CFileMgr::CloseFile(file); + + if (strcmpi(ms_cutsceneName, "end")) { + DMAudio.ChangeMusicMode(2); + int trackId = FindCutsceneAudioTrackId(szCutsceneName); + if (trackId != -1) { + printf("Start preload audio %s\n", szCutsceneName); + DMAudio.PreloadCutSceneMusic(trackId); + printf("End preload audio %s\n", szCutsceneName); + } + } + + ms_cutsceneTimer = 0.0f; + ms_loaded = true; + ms_cutsceneOffset = CVector(0.0f, 0.0f, 0.0f); + + pPlayerPed = FindPlayerPed(); + CTimer::Update(); + + pPlayerPed->m_pWanted->ClearQdCrimes(); + pPlayerPed->bIsVisible = false; + pPlayerPed->m_fCurrentStamina = pPlayerPed->m_fMaxStamina; + CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_80; + CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(true); +} + +void +CCutsceneMgr::SetHeadAnim(const char *animName, CObject *pObject) +{ + CCutsceneHead *pCutsceneHead = (CCutsceneHead*)pObject; + char szAnim[16]; + + sprintf(szAnim, "%s_%s", ms_cutsceneName, animName); + pCutsceneHead->PlayAnimation(szAnim); +} + +void +CCutsceneMgr::FinishCutscene() +{ + CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001; + TheCamera.FinishCutscene(); + + FindPlayerPed()->bIsVisible = true; + CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); +} + +void +CCutsceneMgr::SetupCutsceneToStart(void) +{ + TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset); + TheCamera.TakeControlWithSpline(2); + TheCamera.SetWideScreenOn(); + + ms_cutsceneOffset.z++; + + for (int i = ms_numCutsceneObjs - 1; i >= 0; i--) { + assert(RwObjectGetType(ms_pCutsceneObjects[i]->m_rwObject) == rpCLUMP); + if (CAnimBlendAssociation *pAnimBlendAssoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)ms_pCutsceneObjects[i]->m_rwObject)) { + assert(pAnimBlendAssoc->hierarchy->sequences[0].HasTranslation()); + ms_pCutsceneObjects[i]->GetPosition() = ms_cutsceneOffset + ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrame(0))->translation; + CWorld::Add(ms_pCutsceneObjects[i]); + pAnimBlendAssoc->SetRun(); + } else { + ms_pCutsceneObjects[i]->GetPosition() = ms_cutsceneOffset; + } + } + + CTimer::Update(); + CTimer::Update(); + ms_running = true; + ms_cutsceneTimer = 0.0f; +} + +void +CCutsceneMgr::SetCutsceneAnim(const char *animName, CObject *pObject) +{ + CAnimBlendAssociation *pNewAnim; + CAnimBlendClumpData *pAnimBlendClumpData; + + assert(RwObjectGetType(pObject->m_rwObject) == rpCLUMP); + RpAnimBlendClumpRemoveAllAssociations((RpClump*)pObject->m_rwObject); + + pNewAnim = ms_cutsceneAssociations.CopyAnimation(animName); + pNewAnim->SetCurrentTime(0.0f); + pNewAnim->flags |= ASSOC_HAS_TRANSLATION; + pNewAnim->flags &= ~ASSOC_RUNNING; + + pAnimBlendClumpData = *RPANIMBLENDCLUMPDATA(pObject->m_rwObject); + pAnimBlendClumpData->link.Prepend(&pNewAnim->link); +} + +CCutsceneHead * +CCutsceneMgr::AddCutsceneHead(CObject *pObject, int modelId) +{ + CCutsceneHead *pHead = new CCutsceneHead(pObject); + pHead->SetModelIndex(modelId); + CWorld::Add(pHead); + ms_pCutsceneObjects[ms_numCutsceneObjs++] = pHead; + return pHead; +} + +CCutsceneObject * +CCutsceneMgr::CreateCutsceneObject(int modelId) +{ + CBaseModelInfo *pModelInfo; + CColModel *pColModel; + float radius; + RpClump *clump; + CCutsceneObject *pCutsceneObject; + + if (modelId >= MI_CUTOBJ01 && modelId <= MI_CUTOBJ05) { + pModelInfo = CModelInfo::GetModelInfo(modelId); + pColModel = &CTempColModels::ms_colModelCutObj[modelId - MI_CUTOBJ01]; + radius = 0.0f; + + pModelInfo->SetColModel(pColModel); + clump = (RpClump*)pModelInfo->GetRwObject(); + assert(RwObjectGetType(clump) == rpCLUMP); + RpClumpForAllAtomics(clump, (RpAtomicCallBack)CalculateBoundingSphereRadiusCB, &radius); + + pColModel->boundingSphere.radius = radius; + pColModel->boundingBox.min = CVector(-radius, -radius, -radius); + pColModel->boundingBox.max = CVector(radius, radius, radius); + } + + pCutsceneObject = new CCutsceneObject(); + pCutsceneObject->SetModelIndex(modelId); + ms_pCutsceneObjects[ms_numCutsceneObjs++] = pCutsceneObject; + return pCutsceneObject; +} + +void +CCutsceneMgr::DeleteCutsceneData(void) +{ + if (ms_loaded) { + ms_cutsceneProcessing = false; + ms_useLodMultiplier = false; + + for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { + CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); + ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); + if (ms_pCutsceneObjects[ms_numCutsceneObjs]) + delete ms_pCutsceneObjects[ms_numCutsceneObjs]; + } + ms_numCutsceneObjs = 0; + + if (ms_animLoaded) + CAnimManager::RemoveLastAnimFile(); + + ms_animLoaded = false; + TheCamera.RestoreWithJumpCut(); + TheCamera.SetWideScreenOff(); + ms_running = false; + ms_loaded = false; + + FindPlayerPed()->bIsVisible = true; + CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; + CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); + + if (strcmpi(ms_cutsceneName, "end")) { + DMAudio.StopCutSceneMusic(); + if (strcmpi(ms_cutsceneName, "bet")) + DMAudio.ChangeMusicMode(1); + } + CTimer::Stop(); + //TheCamera.GetScreenFadeStatus() == 2; // what for?? + CGame::DrasticTidyUpMemory(); + CTimer::Update(); + } +} + +void +CCutsceneMgr::Update(void) +{ + enum { + CUTSCENE_LOADING_0 = 0, + CUTSCENE_LOADING_AUDIO, + CUTSCENE_LOADING_2, + CUTSCENE_LOADING_3, + CUTSCENE_LOADING_4 + }; + + switch (ms_cutsceneLoadStatus) { + case CUTSCENE_LOADING_AUDIO: + SetupCutsceneToStart(); + if (strcmpi(ms_cutsceneName, "end")) + DMAudio.PlayPreloadedCutSceneMusic(); + ms_cutsceneLoadStatus++; + break; + case CUTSCENE_LOADING_2: + case CUTSCENE_LOADING_3: + ms_cutsceneLoadStatus++; + break; + case CUTSCENE_LOADING_4: + ms_cutsceneLoadStatus = CUTSCENE_LOADING_0; + break; + default: + break; + } + + if (ms_running) { + ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; + if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { + if (CPad::GetPad(0)->GetCrossJustDown() + || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) + || CPad::GetPad(0)->GetLeftMouseJustDown() + || CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() // NOTE: In original code it's a single CPad method + || CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) + FinishCutscene(); + } + } +} + +bool CCutsceneMgr::HasCutsceneFinished() { return TheCamera.GetPositionAlongSpline() == 1.0; } + +STARTPATCHES +InjectHook(0x4045D0, &CCutsceneMgr::Initialise, PATCH_JUMP); +InjectHook(0x404630, &CCutsceneMgr::Shutdown, PATCH_JUMP); +InjectHook(0x404650, &CCutsceneMgr::LoadCutsceneData, PATCH_JUMP); +InjectHook(0x405140, &CCutsceneMgr::FinishCutscene, PATCH_JUMP); +InjectHook(0x404D80, &CCutsceneMgr::SetHeadAnim, PATCH_JUMP); +InjectHook(0x404DC0, &CCutsceneMgr::SetupCutsceneToStart, PATCH_JUMP); +InjectHook(0x404D20, &CCutsceneMgr::SetCutsceneAnim, PATCH_JUMP); +InjectHook(0x404CD0, &CCutsceneMgr::AddCutsceneHead, PATCH_JUMP); +InjectHook(0x404BE0, &CCutsceneMgr::CreateCutsceneObject, PATCH_JUMP); +InjectHook(0x4048E0, &CCutsceneMgr::DeleteCutsceneData, PATCH_JUMP); +InjectHook(0x404EE0, &CCutsceneMgr::Update, PATCH_JUMP); +InjectHook(0x4051B0, &CCutsceneMgr::GetCutsceneTimeInMilleseconds, PATCH_JUMP); +InjectHook(0x4051F0, &CCutsceneMgr::HasCutsceneFinished, PATCH_JUMP); +ENDPATCHES \ No newline at end of file diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h index aa5a2eb2..4f62d7c8 100644 --- a/src/core/CutsceneMgr.h +++ b/src/core/CutsceneMgr.h @@ -2,6 +2,8 @@ #include "CutsceneObject.h" class CDirectory; +class CAnimBlendAssocGroup; +class CCutsceneHead; class CCutsceneMgr { @@ -9,10 +11,35 @@ class CCutsceneMgr static bool &ms_cutsceneProcessing; static CCutsceneObject *(&ms_pCutsceneObjects)[NUMCUTSCENEOBJECTS]; + static int32 &ms_numCutsceneObjs; + static bool &ms_loaded; + static bool &ms_animLoaded; + static bool &ms_useLodMultiplier; + + static char(&ms_cutsceneName)[8]; + static CAnimBlendAssocGroup &ms_cutsceneAssociations; + static CVector &ms_cutsceneOffset; + static float &ms_cutsceneTimer; public: static CDirectory *&ms_pCutsceneDir; + static uint32 &ms_cutsceneLoadStatus; static bool IsRunning(void) { return ms_running; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; } + static int GetCutsceneTimeInMilleseconds() { return 1000.0f * ms_cutsceneTimer; } + static char *GetCutsceneName(void) { return ms_cutsceneName; } + static bool HasCutsceneFinished(void); + + static void Initialise(void); + static void Shutdown(void); + static void LoadCutsceneData(const char *szCutsceneName); + static void FinishCutscene(void); + static void SetHeadAnim(const char *animName, CObject *pObject); + static void SetupCutsceneToStart(void); + static void SetCutsceneAnim(const char *animName, CObject *pObject); + static CCutsceneHead *AddCutsceneHead(CObject *pObject, int modelId); + static CCutsceneObject *CreateCutsceneObject(int modelId); + static void DeleteCutsceneData(void); + static void Update(void); }; diff --git a/src/core/Pad.h b/src/core/Pad.h index 4f129e85..eca334ee 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -368,6 +368,7 @@ public: bool GetLeftShoulder2JustDown() { return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); } bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } + bool GetStartJustDown() { return !!(NewState.Start && !OldState.Start); } /* int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; } diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index 07ac7989..d2d3f5fb 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -10,7 +10,7 @@ CColModel &CTempColModels::ms_colModelWheel1 = *(CColModel*)0x878C40; CColModel &CTempColModels::ms_colModelPanel1 = *(CColModel*)0x87BDD8; CColModel &CTempColModels::ms_colModelBodyPart2 = *(CColModel*)0x87BE30; CColModel &CTempColModels::ms_colModelBodyPart1 = *(CColModel*)0x87BE88; -CColModel &CTempColModels::ms_colModelCutObj = *(CColModel*)0x87C960; +CColModel (&CTempColModels::ms_colModelCutObj)[5] = *(CColModel(*)[5]) *(uintptr*)0x87C960; CColModel &CTempColModels::ms_colModelPedGroundHit = *(CColModel*)0x880480; CColModel &CTempColModels::ms_colModelBoot1 = *(CColModel*)0x880670; CColModel &CTempColModels::ms_colModelDoor1 = *(CColModel*)0x880850; diff --git a/src/core/TempColModels.h b/src/core/TempColModels.h index f91ac77e..263904d3 100644 --- a/src/core/TempColModels.h +++ b/src/core/TempColModels.h @@ -13,7 +13,7 @@ public: static CColModel &ms_colModelPanel1; static CColModel &ms_colModelBodyPart2; static CColModel &ms_colModelBodyPart1; - static CColModel &ms_colModelCutObj; + static CColModel (&ms_colModelCutObj)[5]; static CColModel &ms_colModelPedGroundHit; static CColModel &ms_colModelBoot1; static CColModel &ms_colModelDoor1; -- cgit v1.2.3 From 45ead4d0bf00aea9c94f8606d2c49736309621b3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 17:31:14 +0300 Subject: Refactoring --- src/core/CutsceneMgr.cpp | 80 ++++++++++++++++++++++++------------------------ src/core/CutsceneMgr.h | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) (limited to 'src/core') diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index 40ae0d2e..b3737c4d 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -329,41 +329,41 @@ CCutsceneMgr::CreateCutsceneObject(int modelId) void CCutsceneMgr::DeleteCutsceneData(void) { - if (ms_loaded) { - ms_cutsceneProcessing = false; - ms_useLodMultiplier = false; + if (!ms_loaded) return; - for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { - CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); - ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); - if (ms_pCutsceneObjects[ms_numCutsceneObjs]) - delete ms_pCutsceneObjects[ms_numCutsceneObjs]; - } - ms_numCutsceneObjs = 0; + ms_cutsceneProcessing = false; + ms_useLodMultiplier = false; - if (ms_animLoaded) - CAnimManager::RemoveLastAnimFile(); + for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { + CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); + ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); + if (ms_pCutsceneObjects[ms_numCutsceneObjs]) + delete ms_pCutsceneObjects[ms_numCutsceneObjs]; + } + ms_numCutsceneObjs = 0; - ms_animLoaded = false; - TheCamera.RestoreWithJumpCut(); - TheCamera.SetWideScreenOff(); - ms_running = false; - ms_loaded = false; + if (ms_animLoaded) + CAnimManager::RemoveLastAnimFile(); - FindPlayerPed()->bIsVisible = true; - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; - CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); + ms_animLoaded = false; + TheCamera.RestoreWithJumpCut(); + TheCamera.SetWideScreenOff(); + ms_running = false; + ms_loaded = false; - if (strcmpi(ms_cutsceneName, "end")) { - DMAudio.StopCutSceneMusic(); - if (strcmpi(ms_cutsceneName, "bet")) - DMAudio.ChangeMusicMode(1); - } - CTimer::Stop(); - //TheCamera.GetScreenFadeStatus() == 2; // what for?? - CGame::DrasticTidyUpMemory(); - CTimer::Update(); + FindPlayerPed()->bIsVisible = true; + CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; + CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); + + if (strcmpi(ms_cutsceneName, "end")) { + DMAudio.StopCutSceneMusic(); + if (strcmpi(ms_cutsceneName, "bet")) + DMAudio.ChangeMusicMode(1); } + CTimer::Stop(); + //TheCamera.GetScreenFadeStatus() == 2; // what for?? + CGame::DrasticTidyUpMemory(); + CTimer::Update(); } void @@ -395,20 +395,20 @@ CCutsceneMgr::Update(void) break; } - if (ms_running) { - ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; - if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { - if (CPad::GetPad(0)->GetCrossJustDown() - || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) - || CPad::GetPad(0)->GetLeftMouseJustDown() - || CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() // NOTE: In original code it's a single CPad method - || CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) - FinishCutscene(); - } + if (!ms_running) return; + + ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; + if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { + if (CPad::GetPad(0)->GetCrossJustDown() + || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) + || CPad::GetPad(0)->GetLeftMouseJustDown() + || CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() // NOTE: In original code it's a single CPad method + || CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) + FinishCutscene(); } } -bool CCutsceneMgr::HasCutsceneFinished() { return TheCamera.GetPositionAlongSpline() == 1.0; } +bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0; } STARTPATCHES InjectHook(0x4045D0, &CCutsceneMgr::Initialise, PATCH_JUMP); diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h index 4f62d7c8..69ce58a6 100644 --- a/src/core/CutsceneMgr.h +++ b/src/core/CutsceneMgr.h @@ -27,7 +27,7 @@ public: static bool IsRunning(void) { return ms_running; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; } - static int GetCutsceneTimeInMilleseconds() { return 1000.0f * ms_cutsceneTimer; } + static int GetCutsceneTimeInMilleseconds(void) { return 1000.0f * ms_cutsceneTimer; } static char *GetCutsceneName(void) { return ms_cutsceneName; } static bool HasCutsceneFinished(void); -- cgit v1.2.3 From ef65ad81ceda9ae04d4ddfd1e79fe5377ae7d07f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 18:01:05 +0300 Subject: Added f for floats, removed checks for delete --- src/core/CutsceneMgr.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/core') diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index b3737c4d..ccb0bf64 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -148,8 +148,7 @@ CCutsceneMgr::Initialise(void) void CCutsceneMgr::Shutdown(void) { - if (ms_pCutsceneDir) - delete ms_pCutsceneDir; + delete ms_pCutsceneDir; } void @@ -234,7 +233,7 @@ CCutsceneMgr::SetHeadAnim(const char *animName, CObject *pObject) void CCutsceneMgr::FinishCutscene() { - CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001; + CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f; TheCamera.FinishCutscene(); FindPlayerPed()->bIsVisible = true; @@ -337,8 +336,7 @@ CCutsceneMgr::DeleteCutsceneData(void) for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); - if (ms_pCutsceneObjects[ms_numCutsceneObjs]) - delete ms_pCutsceneObjects[ms_numCutsceneObjs]; + delete ms_pCutsceneObjects[ms_numCutsceneObjs]; } ms_numCutsceneObjs = 0; @@ -397,7 +395,7 @@ CCutsceneMgr::Update(void) if (!ms_running) return; - ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; + ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02f; if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { if (CPad::GetPad(0)->GetCrossJustDown() || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) @@ -408,7 +406,7 @@ CCutsceneMgr::Update(void) } } -bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0; } +bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; } STARTPATCHES InjectHook(0x4045D0, &CCutsceneMgr::Initialise, PATCH_JUMP); -- cgit v1.2.3 From b13c4de6a4f73177af63a527ca505e76fba3abab Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 18:16:52 +0300 Subject: Added CUTSCENEDIRSIZE to Config enum and CUTSCENENAMESIZE macro --- src/core/CutsceneMgr.cpp | 6 +++--- src/core/CutsceneMgr.h | 4 +++- src/core/config.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index ccb0bf64..1461c858 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -123,7 +123,7 @@ int32 &CCutsceneMgr::ms_numCutsceneObjs = *(int32*)0x942FA4; bool &CCutsceneMgr::ms_loaded = *(bool*)0x95CD95; bool &CCutsceneMgr::ms_animLoaded = *(bool*)0x95CDA0; bool &CCutsceneMgr::ms_useLodMultiplier = *(bool*)0x95CD74; -char(&CCutsceneMgr::ms_cutsceneName)[8] = *(char(*)[8]) *(uintptr*)0x70D9D0; +char(&CCutsceneMgr::ms_cutsceneName)[CUTSCENENAMESIZE] = *(char(*)[CUTSCENENAMESIZE]) *(uintptr*)0x70D9D0; CAnimBlendAssocGroup &CCutsceneMgr::ms_cutsceneAssociations = *(CAnimBlendAssocGroup*)0x709C58; CVector &CCutsceneMgr::ms_cutsceneOffset = *(CVector*)0x8F2C0C; float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548; @@ -141,7 +141,7 @@ CCutsceneMgr::Initialise(void) ms_cutsceneProcessing = false; ms_useLodMultiplier = false; - ms_pCutsceneDir = new CDirectory(512); + ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE); ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); } @@ -224,7 +224,7 @@ void CCutsceneMgr::SetHeadAnim(const char *animName, CObject *pObject) { CCutsceneHead *pCutsceneHead = (CCutsceneHead*)pObject; - char szAnim[16]; + char szAnim[CUTSCENENAMESIZE * 2]; sprintf(szAnim, "%s_%s", ms_cutsceneName, animName); pCutsceneHead->PlayAnimation(szAnim); diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h index 69ce58a6..9b942030 100644 --- a/src/core/CutsceneMgr.h +++ b/src/core/CutsceneMgr.h @@ -1,6 +1,8 @@ #pragma once #include "CutsceneObject.h" +#define CUTSCENENAMESIZE 8 + class CDirectory; class CAnimBlendAssocGroup; class CCutsceneHead; @@ -16,7 +18,7 @@ class CCutsceneMgr static bool &ms_animLoaded; static bool &ms_useLodMultiplier; - static char(&ms_cutsceneName)[8]; + static char(&ms_cutsceneName)[CUTSCENENAMESIZE]; static CAnimBlendAssocGroup &ms_cutsceneAssociations; static CVector &ms_cutsceneOffset; static float &ms_cutsceneTimer; diff --git a/src/core/config.h b/src/core/config.h index 161cf898..366b195e 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -8,6 +8,7 @@ enum Config { MODELINFOSIZE = 5500, TXDSTORESIZE = 850, EXTRADIRSIZE = 128, + CUTSCENEDIRSIZE = 512, SIMPLEMODELSIZE = 5000, TIMEMODELSIZE = 30, -- cgit v1.2.3 From 5854016ec51458711eacc7b1ac1fa415ee9db979 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 21:39:58 +0300 Subject: PlayerSkin --- src/core/Frontend.cpp | 2 +- src/core/PlayerInfo.cpp | 24 ++++++- src/core/PlayerInfo.h | 1 + src/core/PlayerSkin.cpp | 166 +++++++++++++++++++++++++++++++++++++++++++++++- src/core/PlayerSkin.h | 16 ++++- 5 files changed, 205 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index effcb0b4..30b80634 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -2383,7 +2383,7 @@ void CMenuManager::SwitchToNewScreen(int32 screen) // Set player skin. if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - CPlayerSkin::BeginFrontEndSkinEdit(); + CPlayerSkin::BeginFrontendSkinEdit(); m_bSkinsFound = false; } diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 8c505eb4..dc72848d 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -4,9 +4,9 @@ #include "PlayerInfo.h" #include "Frontend.h" #include "Vehicle.h" +#include "PlayerSkin.h" WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); } -WRAPPER void CPlayerInfo::LoadPlayerSkin() { EAXJMP(0x4A1700); } WRAPPER void CPlayerInfo::AwardMoneyForExplosion(CVehicle *vehicle) { EAXJMP(0x4A15F0); } WRAPPER void CPlayerInfo::Process(void) { EAXJMP(0x49FD30); } @@ -22,3 +22,25 @@ CVector& CPlayerInfo::GetPos() return m_pPed->m_pMyVehicle->GetPosition(); return m_pPed->GetPosition(); } + +void CPlayerInfo::LoadPlayerSkin() +{ + DeletePlayerSkin(); + + m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName); + if (!m_pSkinTexture) + m_pSkinTexture = CPlayerSkin::GetSkinTexture(DEFAULT_SKIN_NAME); +} + +void CPlayerInfo::DeletePlayerSkin() +{ + if (m_pSkinTexture) { + RwTextureDestroy(m_pSkinTexture); + m_pSkinTexture = NULL; + } +} + +STARTPATCHES +InjectHook(0x4A1700, &CPlayerInfo::LoadPlayerSkin, PATCH_JUMP); +InjectHook(0x4A1750, &CPlayerInfo::DeletePlayerSkin, PATCH_JUMP); +ENDPATCHES diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index 29290f6e..f0b879ee 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -68,6 +68,7 @@ public: void MakePlayerSafe(bool); void LoadPlayerSkin(); + void DeletePlayerSkin(); void AwardMoneyForExplosion(CVehicle *vehicle); void SetPlayerSkin(char* skin); CVector& GetPos(); diff --git a/src/core/PlayerSkin.cpp b/src/core/PlayerSkin.cpp index 1c9ca2c6..6290351a 100644 --- a/src/core/PlayerSkin.cpp +++ b/src/core/PlayerSkin.cpp @@ -1,5 +1,169 @@ #include "common.h" #include "patcher.h" +#include "main.h" #include "PlayerSkin.h" +#include "TxdStore.h" +#include "rtbmp.h" +#include "ClumpModelInfo.h" +#include "VisibilityPlugins.h" +#include "World.h" +#include "PlayerInfo.h" +#include "CdStream.h" +#include "FileMgr.h" +#include "Directory.h" +#include "RwHelper.h" +#include "Timer.h" +#include "Lights.h" -WRAPPER void CPlayerSkin::BeginFrontEndSkinEdit() { EAXJMP(0x59BC70); } +int CPlayerSkin::m_txdSlot; + +void +FindPlayerDff(uint32 &offset, uint32 &size) +{ + int file; + CDirectory::DirectoryInfo info; + + file = CFileMgr::OpenFile("models\\gta3.dir", "rb"); + + do { + if (!CFileMgr::Read(file, (char*)&info, sizeof(CDirectory::DirectoryInfo))) + return; + } while (strcmpi("player.dff", info.name)); + + offset = info.offset; + size = info.size; +} + +void +LoadPlayerDff(void) +{ + RwStream *stream; + RwMemory mem; + uint32 offset, size; + uint8 *buffer; + bool streamWasAdded = false; + + if (!CdStreamGetNumImages()) { + CdStreamAddImage("models\\gta3.img"); + streamWasAdded = true; + } + + FindPlayerDff(offset, size); + buffer = (uint8*)RwMallocAlign(size << 11, 2048); + CdStreamRead(0, buffer, offset, size); + CdStreamSync(0); + + mem.start = buffer; + mem.length = size << 11; + stream = RwStreamOpen(rwSTREAMMEMORY, rwSTREAMREAD, &mem); + + if (RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)) + gpPlayerClump = RpClumpStreamRead(stream); + + RwStreamClose(stream, &mem); + RwFreeAlign(buffer); + + if (streamWasAdded) + CdStreamRemoveImages(); +} + +void +CPlayerSkin::Initialise(void) +{ + m_txdSlot = CTxdStore::AddTxdSlot("skin"); + CTxdStore::Create(m_txdSlot); + CTxdStore::AddRef(m_txdSlot); +} + +void +CPlayerSkin::Shutdown(void) +{ + CTxdStore::RemoveTxdSlot(m_txdSlot); +} + +RwTexture * +CPlayerSkin::GetSkinTexture(const char *texName) +{ + RwTexture *tex; + RwRaster *raster; + int32 width, height, depth, format; + + CTxdStore::PushCurrentTxd(); + CTxdStore::SetCurrentTxd(m_txdSlot); + tex = RwTextureRead(texName, NULL); + CTxdStore::PopCurrentTxd(); + if (tex) return tex; + + if (!strcmp(DEFAULT_SKIN_NAME, texName)) + sprintf(gString, "models\\generic\\player.bmp"); + else + sprintf(gString, "skins\\%s.bmp", texName); + + if (RwImage *image = RtBMPImageRead(gString)) { + RwImageFindRasterFormat(image, rwRASTERTYPETEXTURE, &width, &height, &depth, &format); + raster = RwRasterCreate(width, height, depth, format); + RwRasterSetFromImage(raster, image); + + tex = RwTextureCreate(raster); + RwTextureSetName(tex, texName); + RwTextureSetFilterMode(tex, rwFILTERLINEAR); // filtering bugfix from VC + RwTexDictionaryAddTexture(CTxdStore::GetSlot(m_txdSlot)->texDict, tex); + + RwImageDestroy(image); + } + return tex; +} + +void +CPlayerSkin::BeginFrontendSkinEdit(void) +{ + LoadPlayerDff(); + RpClumpForAllAtomics(gpPlayerClump, CClumpModelInfo::SetAtomicRendererCB, CVisibilityPlugins::RenderPlayerCB); + CWorld::Players[0].LoadPlayerSkin(); + gOldFov = CDraw::GetFOV(); + CDraw::SetFOV(30.0f); +} + +void +CPlayerSkin::EndFrontendSkinEdit(void) +{ + RpClumpDestroy(gpPlayerClump); + gpPlayerClump = NULL; + CDraw::SetFOV(gOldFov); +} + +void +CPlayerSkin::RenderFrontendSkinEdit(void) +{ + static float rotation = 0.0f; + RwRGBAReal AmbientColor = { 0.65f, 0.65f, 0.65f, 1.0f }; + const RwV3d pos = { 1.35f, 0.35f, 7.725f }; + const RwV3d axis1 = { 1.0f, 0.0f, 0.0f }; + const RwV3d axis2 = { 0.0f, 0.0f, 1.0f }; + static uint32 LastFlash = 0; + + RwFrame *frame = RpClumpGetFrame(gpPlayerClump); + + if (CTimer::GetTimeInMillisecondsPauseMode() - LastFlash > 7) { + rotation += 2.0f; + if (rotation > 360.0f) + rotation -= 360.0f; + LastFlash = CTimer::GetTimeInMillisecondsPauseMode(); + } + RwFrameTransform(frame, RwFrameGetMatrix(RwCameraGetFrame(Scene.camera)), rwCOMBINEREPLACE); + RwFrameTranslate(frame, &pos, rwCOMBINEPRECONCAT); + RwFrameRotate(frame, &axis1, -90.0f, rwCOMBINEPRECONCAT); + RwFrameRotate(frame, &axis2, rotation, rwCOMBINEPRECONCAT); + RwFrameUpdateObjects(frame); + SetAmbientColours(&AmbientColor); + RpClumpRender(gpPlayerClump); +} + +STARTPATCHES +InjectHook(0x59B9B0, &CPlayerSkin::Initialise, PATCH_JUMP); +InjectHook(0x59B9E0, &CPlayerSkin::Shutdown, PATCH_JUMP); +InjectHook(0x59B9F0, &CPlayerSkin::GetSkinTexture, PATCH_JUMP); +InjectHook(0x59BC70, &CPlayerSkin::BeginFrontendSkinEdit, PATCH_JUMP); +InjectHook(0x59BCB0, &CPlayerSkin::EndFrontendSkinEdit, PATCH_JUMP); +InjectHook(0x59BCE0, &CPlayerSkin::RenderFrontendSkinEdit, PATCH_JUMP); +ENDPATCHES \ No newline at end of file diff --git a/src/core/PlayerSkin.h b/src/core/PlayerSkin.h index 61e09cdf..2d82ec12 100644 --- a/src/core/PlayerSkin.h +++ b/src/core/PlayerSkin.h @@ -1,7 +1,21 @@ #pragma once +#define DEFAULT_SKIN_NAME "$$\"\"" + +static RpClump *gpPlayerClump;// = *(RpClump**)0x660FF8; +static float gOldFov;// = *(float*)0x660FFC; + +void LoadPlayerDff(void); +void FindPlayerDff(uint32 &offset, uint32 &size); + class CPlayerSkin { + static int m_txdSlot; public: - static void BeginFrontEndSkinEdit(); + static void Initialise(); + static void Shutdown(); + static RwTexture *GetSkinTexture(const char *texName); + static void BeginFrontendSkinEdit(); + static void EndFrontendSkinEdit(); + static void RenderFrontendSkinEdit(); }; \ No newline at end of file -- cgit v1.2.3 From 90f085c1ca771faa2a369efa9cc43c49bdb3199a Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 22:07:05 +0300 Subject: zero check --- src/core/PlayerSkin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/PlayerSkin.cpp b/src/core/PlayerSkin.cpp index 6290351a..111333ec 100644 --- a/src/core/PlayerSkin.cpp +++ b/src/core/PlayerSkin.cpp @@ -43,7 +43,7 @@ LoadPlayerDff(void) uint8 *buffer; bool streamWasAdded = false; - if (!CdStreamGetNumImages()) { + if (CdStreamGetNumImages() == 0) { CdStreamAddImage("models\\gta3.img"); streamWasAdded = true; } -- cgit v1.2.3 From 0ee5a46f718889f545dc8cf2d4f5c54dd3956453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 3 Oct 2019 04:02:02 +0300 Subject: Fixes & peds --- src/core/config.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 366b195e..f82967d5 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -139,5 +139,4 @@ enum Config { #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher #define ANIMATE_PED_COL_MODEL //#define REMOVE_TREADABLE_PATHFIND -#define CANCELLABLE_CAR_ENTER #define VC_PED_PORTS -- cgit v1.2.3 From 5b119ca78d44bb2f5c63f6e14b677fbacb38711b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 13:21:00 +0300 Subject: Added missed config.h --- src/core/config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index f82967d5..4a9fa792 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -67,6 +67,7 @@ enum Config { NUMANTENNAS = 8, NUMCORONAS = 56, NUMPOINTLIGHTS = 32, + NUMMONEYMESSAGES = 16, NUMONSCREENTIMERENTRIES = 1, NUMRADARBLIPS = 32, -- cgit v1.2.3 From 72e12f6aae10e294c9265dd58c75db5c5c54bd24 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 22:28:56 +0300 Subject: CPickups --- src/core/Pools.cpp | 1 + src/core/Pools.h | 1 + src/core/config.h | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index a76bbb6d..847fa753 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -13,6 +13,7 @@ CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18; CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); } +WRAPPER void CPools::MakeSureSlotInObjectPoolIsEmpty(int32 handle) { EAXJMP(0x4A2DB0); } #if 0 void diff --git a/src/core/Pools.h b/src/core/Pools.h index bdf668c2..4e6bd547 100644 --- a/src/core/Pools.h +++ b/src/core/Pools.h @@ -49,4 +49,5 @@ public: static CVehicle *GetVehicle(int32 handle); static int32 GetObjectRef(CObject *object); static CObject *GetObject(int32 handle); + static void MakeSureSlotInObjectPoolIsEmpty(int32 handle); }; diff --git a/src/core/config.h b/src/core/config.h index 4a9fa792..49bef3fa 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -68,10 +68,14 @@ enum Config { NUMCORONAS = 56, NUMPOINTLIGHTS = 32, NUMMONEYMESSAGES = 16, + NUMPICKUPMESSAGES = 16, NUMONSCREENTIMERENTRIES = 1, NUMRADARBLIPS = 32, - NUMPICKUPS = 336, + NUMGENERALPICKUPS = 320, + NUMSCRIPTEDPICKUPS = 16, + NUMPICKUPS = NUMGENERALPICKUPS + NUMSCRIPTEDPICKUPS, + NUMCOLLECTEDPICKUPS = 20, NUMEVENTS = 64, NUM_CARGENS = 160, @@ -141,3 +145,4 @@ enum Config { #define ANIMATE_PED_COL_MODEL //#define REMOVE_TREADABLE_PATHFIND #define VC_PED_PORTS +//#define MONEY_MESSAGES \ No newline at end of file -- cgit v1.2.3 From 54f36ad9604190987350a9c38a0f82a0c7b960a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 4 Oct 2019 01:19:07 +0300 Subject: Fix radar --- src/core/Radar.cpp | 348 +++++++++++++++++++++++++++++++++++++---------------- src/core/Radar.h | 30 ++--- 2 files changed, 256 insertions(+), 122 deletions(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index f04e14d1..7eff743a 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -16,8 +16,7 @@ #include "Streaming.h" float &CRadar::m_RadarRange = *(float*)0x8E281C; -CBlip *CRadar::ms_RadarTrace = (CBlip*)0x6ED5E0; - +CBlip (&CRadar::ms_RadarTrace)[NUMRADARBLIPS] = *(CBlip(*)[NUMRADARBLIPS]) * (uintptr*)0x6ED5E0; CVector2D &vec2DRadarOrigin = *(CVector2D*)0x6299B8; int *gRadarTxdIds = (int*)0x6299C0; @@ -78,13 +77,13 @@ static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not #if 0 WRAPPER void CRadar::CalculateBlipAlpha(float) { EAXJMP(0x4A4F90); } #else -int CRadar::CalculateBlipAlpha(float dist) +uint8 CRadar::CalculateBlipAlpha(float dist) { if (dist <= 1.0f) return 255; if (dist <= 5.0f) - return (((1.0f - ((dist * 0.25f) - 0.25f)) * 255.0f) + (((dist * 0.25f) - 0.25f) * 128.0f)); + return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f); return 128; } @@ -109,18 +108,18 @@ void CRadar::ChangeBlipColour(int32 i, int32) #endif #if 1 -WRAPPER void CRadar::ChangeBlipDisplay(int32, int16) { EAXJMP(0x4A5810); } +WRAPPER void CRadar::ChangeBlipDisplay(int32, eBlipDisplay) { EAXJMP(0x4A5810); } #else -void CRadar::ChangeBlipDisplay(int32 i, int16 flag) +void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display) { } #endif #if 1 -WRAPPER void CRadar::ChangeBlipScale(int32, int16) { EAXJMP(0x4A57E0); } +WRAPPER void CRadar::ChangeBlipScale(int32, int32) { EAXJMP(0x4A57E0); } #else -void CRadar::ChangeBlipScale(int32 i, int16 scale) +void CRadar::ChangeBlipScale(int32 i, int32 scale) { } @@ -136,17 +135,17 @@ void CRadar::ClearBlip(int32 i) #endif #if 0 -WRAPPER void CRadar::ClearBlipForEntity(int16, int32) { EAXJMP(0x4A56C0); } +WRAPPER void CRadar::ClearBlipForEntity(eBlipType, int32) { EAXJMP(0x4A56C0); } #else -void CRadar::ClearBlipForEntity(int16 type, int32 id) +void CRadar::ClearBlipForEntity(eBlipType type, int32 id) { for (int i = 0; i < NUMRADARBLIPS; i++) { if (type == ms_RadarTrace[i].m_eBlipType && id == ms_RadarTrace[i].m_nEntityHandle) { - SetRadarMarkerState(i, 0); - ms_RadarTrace[i].m_bInUse = 0; - ms_RadarTrace[i].m_eBlipType = 0; - ms_RadarTrace[i].m_eBlipDisplay = 0; - ms_RadarTrace[i].m_IconID = 0; + SetRadarMarkerState(i, false); + ms_RadarTrace[i].m_bInUse = false; + ms_RadarTrace[i].m_eBlipType = BLIP_NONE; + ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; + ms_RadarTrace[i].m_IconID = RADAR_SPRITE_NONE; } }; } @@ -291,82 +290,176 @@ void CRadar::DrawBlips() TransformRadarPointToScreenSpace(out, in); DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255); - /* - DrawEntityBlip - */ - for (int i = 0; i < NUMRADARBLIPS; i++) { - if (ms_RadarTrace[i].m_bInUse) { - if (ms_RadarTrace[i].m_eBlipType <= BLIP_OBJECT) { - CEntity *e = nil; - switch (ms_RadarTrace[i].m_eBlipType) { - case BLIP_CAR: - e = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[i].m_nEntityHandle); - break; - case BLIP_CHAR: - e = CPools::GetPedPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle); - break; - case BLIP_OBJECT: - e = CPools::GetObjectPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle); - break; - }; - - if (e) { - if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + CEntity *blipEntity = nil; + for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { + if (!ms_RadarTrace[blipId].m_bInUse) + continue; + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + case BLIP_CHAR: + case BLIP_OBJECT: + if (ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SAVE + || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_WEAPON) { + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + case BLIP_CHAR: + blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + if (blipEntity && ((CPed*)blipEntity)->bInVehicle && ((CPed*)blipEntity)->m_pMyVehicle) { + blipEntity = ((CPed*)blipEntity)->m_pMyVehicle; + } + break; + case BLIP_OBJECT: + blipEntity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + default: + break; + } + if (blipEntity) { + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + if (CTheScripts::DbgFlag) { + ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; + } + } + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); + float dist = LimitRadarPoint(in); + TransformRadarPointToScreenSpace(out, in); + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) { + DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); + } else { + ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); + } + } + } + } + break; + case BLIP_COORD: + case BLIP_CONTACT_POINT: + if ((ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SAVE + || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_WEAPON) + && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { + + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { if (CTheScripts::DbgFlag) { - ShowRadarMarker(e->GetPosition(), GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim), ms_RadarTrace->m_Radius); - - ms_RadarTrace[i].m_Radius = ms_RadarTrace[i].m_Radius - 0.1f; - if (ms_RadarTrace[i].m_Radius >= 1.0f) - ms_RadarTrace[i].m_Radius = 5.0; + ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; } } - if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - vec2d = e->GetPosition(); - TransformRealWorldPointToRadarSpace(in, vec2d); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); float dist = LimitRadarPoint(in); - int a = CalculateBlipAlpha(dist); TransformRadarPointToScreenSpace(out, in); - - int32 col = GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim); - - if (ms_RadarTrace[i].m_IconID) - DrawRadarSprite(ms_RadarTrace[i].m_IconID, out.x, out.y, a); - else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[i].m_wScale, ((col >> 24)), ((col >> 16) & 0xFF), ((col >> 8)), 255); + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) { + DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); + } else { + ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); + } } } - } + break; + default: + break; + } + } + for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { + if (!ms_RadarTrace[blipId].m_bInUse) + continue; + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + case BLIP_CHAR: + case BLIP_OBJECT: + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SAVE + && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_WEAPON) { + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + case BLIP_CHAR: + blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + if (blipEntity && ((CPed*)blipEntity)->bInVehicle && ((CPed*)blipEntity)->m_pMyVehicle) { + blipEntity = ((CPed*)blipEntity)->m_pMyVehicle; + } + break; + case BLIP_OBJECT: + blipEntity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + default: + break; + } - /* - DrawCoordBlip - */ - if (ms_RadarTrace[i].m_eBlipType >= BLIP_COORD) { - if (ms_RadarTrace[i].m_eBlipType != BLIP_CONTACT_POINT || ms_RadarTrace[i].m_eBlipType == BLIP_CONTACT_POINT && DisplayThisBlip(i) || !CTheScripts::IsPlayerOnAMission()) { - if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + if (blipEntity) { + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + if (CTheScripts::DbgFlag) { + ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; + } + } + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); + float dist = LimitRadarPoint(in); + TransformRadarPointToScreenSpace(out, in); + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) + DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); + else + ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); + } + } + } + break; + default: + break; + } + } + for (int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { + if (!ms_RadarTrace[blipId].m_bInUse) + continue; + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_COORD: + case BLIP_CONTACT_POINT: + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SAVE + && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_WEAPON + && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { + + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { if (CTheScripts::DbgFlag) { - ShowRadarMarker(ms_RadarTrace[i].m_vecPos, GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim), ms_RadarTrace->m_Radius); - ms_RadarTrace[i].m_Radius = ms_RadarTrace[i].m_Radius - 0.1f; - if (ms_RadarTrace[i].m_Radius >= 1.0f) - ms_RadarTrace[i].m_Radius = 5.0f; + ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; } } - - if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[i].m_vec2DPos); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); float dist = LimitRadarPoint(in); - int a = CalculateBlipAlpha(dist); TransformRadarPointToScreenSpace(out, in); - - int32 col = GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim); - - if (ms_RadarTrace[i].m_IconID) - DrawRadarSprite(ms_RadarTrace[i].m_IconID, out.x, out.y, a); + if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) + DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[i].m_wScale, ((col >> 24)), ((col >> 16) & 0xFF), ((col >> 8)), 255); + ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); } } - } - }; + break; + default: + break; + } } } } @@ -531,9 +624,9 @@ void CRadar::DrawRadarSection(int32 x, int32 y) #endif #if 0 -WRAPPER void CRadar::DrawRadarSprite(int32 sprite, float x, float y, int32 alpha) { EAXJMP(0x4A5EF0); } +WRAPPER void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) { EAXJMP(0x4A5EF0); } #else -void CRadar::DrawRadarSprite(int32 sprite, float x, float y, int32 alpha) +void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) { RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha)); } @@ -570,12 +663,17 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float } #endif -#if 1 +#if 0 WRAPPER int32 CRadar::GetActualBlipArrayIndex(int32) { EAXJMP(0x4A41C0); } #else int32 CRadar::GetActualBlipArrayIndex(int32 i) { - return int32(); + if (i == -1) + return -1; + else if ((i & 0xFFFF0000) >> 16 != ms_RadarTrace[(uint16)i].m_BlipIndex) + return -1; + else + return (uint16)i; } #endif @@ -589,9 +687,9 @@ int32 CRadar::GetNewUniqueBlipIndex(int32 i) #endif #if 0 -WRAPPER int32 CRadar::GetRadarTraceColour(int32 color, bool bright) { EAXJMP(0x4A5BB0); } +WRAPPER uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright) { EAXJMP(0x4A5BB0); } #else -int32 CRadar::GetRadarTraceColour(int32 color, bool bright) +uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright) { int32 c; switch (color) { @@ -605,13 +703,13 @@ int32 CRadar::GetRadarTraceColour(int32 color, bool bright) if (bright) c = 0x5FA06AFF; else - c = 0x7F00FF; + c = 0x007F00FF; break; case 2: if (bright) c = 0x80A7F3FF; else - c = 0x007FFF; + c = 0x00007FFF; break; case 3: if (bright) @@ -633,9 +731,9 @@ int32 CRadar::GetRadarTraceColour(int32 color, bool bright) break; case 6: if (bright) - c = 0xFFFFFF; + c = 0x00FFFFFF; else - c = 0x7F7FFF; + c = 0x007F7FFF; break; default: c = color; @@ -727,37 +825,70 @@ void CRadar::SaveAllRadarBlips(int32) } #endif -#if 1 +#if 0 WRAPPER void CRadar::SetBlipSprite(int32, int32) { EAXJMP(0x4A5840); } #else void CRadar::SetBlipSprite(int32 i, int32 icon) { - + int index = CRadar::GetActualBlipArrayIndex(i); + if (index != -1) { + ms_RadarTrace[index].m_IconID = icon; + } } #endif -#if 1 -WRAPPER int32 CRadar::SetCoordBlip(eBlipType, CVector, int32, eBlipDisplay) { EAXJMP(0x4A5590); } +#if 0 +WRAPPER int32 CRadar::SetCoordBlip(eBlipType, CVector, int32, eBlipDisplay display) { EAXJMP(0x4A5590); } #else -int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 flag, eBlipDisplay) +int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display) { - return 0; + int nextBlip; + for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) { + if (!ms_RadarTrace[nextBlip].m_bInUse) + break; + } + ms_RadarTrace[nextBlip].m_eBlipType = type; + ms_RadarTrace[nextBlip].m_nColor = color; + ms_RadarTrace[nextBlip].m_bDim = 1; + ms_RadarTrace[nextBlip].m_bInUse = 1; + ms_RadarTrace[nextBlip].m_Radius = 1.0f; + ms_RadarTrace[nextBlip].m_vec2DPos = pos; + ms_RadarTrace[nextBlip].m_vecPos = pos; + ms_RadarTrace[nextBlip].m_nEntityHandle = 0; + ms_RadarTrace[nextBlip].m_wScale = 1; + ms_RadarTrace[nextBlip].m_eBlipDisplay = display; + ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE; + return CRadar::GetNewUniqueBlipIndex(nextBlip); } #endif -#if 1 +#if 0 WRAPPER int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) { EAXJMP(0x4A5640); } #else -int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) +int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display) { - return 0; + int nextBlip; + for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) { + if (!ms_RadarTrace[nextBlip].m_bInUse) + break; + } + ms_RadarTrace[nextBlip].m_eBlipType = type; + ms_RadarTrace[nextBlip].m_nColor = color; + ms_RadarTrace[nextBlip].m_bDim = 1; + ms_RadarTrace[nextBlip].m_bInUse = 1; + ms_RadarTrace[nextBlip].m_Radius = 1.0f; + ms_RadarTrace[nextBlip].m_nEntityHandle = handle; + ms_RadarTrace[nextBlip].m_wScale = 1; + ms_RadarTrace[nextBlip].m_eBlipDisplay = display; + ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE; + return CRadar::GetNewUniqueBlipIndex(nextBlip); } #endif #if 0 -WRAPPER void CRadar::SetRadarMarkerState(int32, int32) { EAXJMP(0x4A5C60); } +WRAPPER void CRadar::SetRadarMarkerState(int32, bool) { EAXJMP(0x4A5C60); } #else -void CRadar::SetRadarMarkerState(int32 counter, int32 flag) +void CRadar::SetRadarMarkerState(int32 counter, bool flag) { CEntity *e; switch (ms_RadarTrace[counter].m_eBlipType) { @@ -780,11 +911,11 @@ void CRadar::SetRadarMarkerState(int32 counter, int32 flag) #endif #if 0 -WRAPPER void CRadar::ShowRadarMarker(CVector pos, int16 color, float radius) { EAXJMP(0x4A59C0); } +WRAPPER void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) { EAXJMP(0x4A59C0); } #else -void CRadar::ShowRadarMarker(CVector pos, int16 color, float radius) { - float f1 = radius * 0.5f; - float f2 = radius * 1.4f; +void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) { + float f1 = radius * 1.4f; + float f2 = radius * 0.5f; CVector p1, p2; p1 = pos + TheCamera.GetUp()*f1; @@ -806,10 +937,13 @@ void CRadar::ShowRadarMarker(CVector pos, int16 color, float radius) { #endif #if 0 -WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha) { EAXJMP(0x4A5870); } +WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha) { EAXJMP(0x4A5870); } #else -void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha) +void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha) { + if (!CHud::m_Wants_To_Draw_Hud || TheCamera.m_WideScreenOn) + return; + CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size + 1.0f), y - SCREEN_SCALE_Y(size + 1.0f), SCREEN_SCALE_X(size + 1.0f) + x, SCREEN_SCALE_Y(size + 1.0f) + y), CRGBA(0, 0, 0, alpha)); CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha)); } @@ -1076,7 +1210,7 @@ STARTPATCHES // InjectHook(0x4A3F60, CRadar::Shutdown, PATCH_JUMP); // InjectHook(0x4A4030, CRadar::LoadTextures, PATCH_JUMP); // InjectHook(0x4A4180, CRadar::GetNewUniqueBlipIndex, PATCH_JUMP); -// InjectHook(0x4A41C0, CRadar::GetActualBlipArrayIndex, PATCH_JUMP); + InjectHook(0x4A41C0, CRadar::GetActualBlipArrayIndex, PATCH_JUMP); InjectHook(0x4A4200, CRadar::DrawMap, PATCH_JUMP); InjectHook(0x4A42F0, CRadar::DrawBlips, PATCH_JUMP); // InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP); @@ -1086,18 +1220,18 @@ STARTPATCHES InjectHook(0x4A50D0, CRadar::TransformRealWorldPointToRadarSpace, PATCH_JUMP); InjectHook(0x4A5300, CRadar::TransformRadarPointToRealWorldSpace, PATCH_JUMP); InjectHook(0x4A5530, CRadar::TransformRealWorldToTexCoordSpace, PATCH_JUMP); -// InjectHook(0x4A5590, CRadar::SetCoordBlip, PATCH_JUMP); -// InjectHook(0x4A5640, CRadar::SetEntityBlip, PATCH_JUMP); + InjectHook(0x4A5590, CRadar::SetCoordBlip, PATCH_JUMP); + InjectHook(0x4A5640, CRadar::SetEntityBlip, PATCH_JUMP); InjectHook(0x4A56C0, CRadar::ClearBlipForEntity, PATCH_JUMP); // InjectHook(0x4A5720, CRadar::ClearBlip, PATCH_JUMP); // InjectHook(0x4A5770, CRadar::ChangeBlipColour, PATCH_JUMP); // InjectHook(0x4A57A0, CRadar::ChangeBlipBrightness, PATCH_JUMP); // InjectHook(0x4A57E0, CRadar::ChangeBlipScale, PATCH_JUMP); // InjectHook(0x4A5810, CRadar::ChangeBlipDisplay, PATCH_JUMP); -// InjectHook(0x4A5840, CRadar::SetBlipSprite, PATCH_JUMP); + InjectHook(0x4A5840, CRadar::SetBlipSprite, PATCH_JUMP); InjectHook(0x4A5870, CRadar::ShowRadarTrace, PATCH_JUMP); InjectHook(0x4A59C0, CRadar::ShowRadarMarker, PATCH_JUMP); - //InjectHook(0x4A5BB0, CRadar::GetRadarTraceColour, PATCH_JUMP); + InjectHook(0x4A5BB0, CRadar::GetRadarTraceColour, PATCH_JUMP); InjectHook(0x4A5C60, CRadar::SetRadarMarkerState, PATCH_JUMP); InjectHook(0x4A5D10, CRadar::DrawRotatingRadarSprite, PATCH_JUMP); InjectHook(0x4A5EF0, CRadar::DrawRadarSprite, PATCH_JUMP); diff --git a/src/core/Radar.h b/src/core/Radar.h index 1ec28070..6bb445fd 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -47,8 +47,8 @@ enum eRadarSprite struct CBlip { - int32 m_nColor; - int16 m_eBlipType; // eBlipType + uint32 m_nColor; + uint16 m_eBlipType; // eBlipType int32 m_nEntityHandle; CVector2D m_vec2DPos; CVector m_vecPos; @@ -57,8 +57,8 @@ struct CBlip bool m_bInUse; float m_Radius; int16 m_wScale; - int16 m_eBlipDisplay; // eBlipDisplay - int16 m_IconID; // eRadarSprite + uint16 m_eBlipDisplay; // eBlipDisplay + uint16 m_IconID; // eRadarSprite }; static_assert(sizeof(CBlip) == 0x30, "CBlip: error"); @@ -72,7 +72,7 @@ class CRadar { public: static float &m_RadarRange; - static CBlip *ms_RadarTrace; //[NUMRADARBLIPS] + static CBlip (&ms_RadarTrace)[NUMRADARBLIPS]; static CSprite2d *AsukaSprite; static CSprite2d *BombSprite; static CSprite2d *CatSprite; @@ -96,13 +96,13 @@ public: static CSprite2d *RadarSprites[21]; public: - static int CalculateBlipAlpha(float dist); + static uint8 CalculateBlipAlpha(float dist); static void ChangeBlipBrightness(int32 i, int32 bright); static void ChangeBlipColour(int32 i, int32); - static void ChangeBlipDisplay(int32 i, int16 flag); - static void ChangeBlipScale(int32 i, int16 scale); + static void ChangeBlipDisplay(int32 i, eBlipDisplay display); + static void ChangeBlipScale(int32 i, int32 scale); static void ClearBlip(int32 i); - static void ClearBlipForEntity(int16 type, int32 id); + static void ClearBlipForEntity(eBlipType type, int32 id); static int ClipRadarPoly(CVector2D *out, const CVector2D *in); static bool DisplayThisBlip(int32 i); static void Draw3dMarkers(); @@ -111,11 +111,11 @@ public: static void DrawRadarMap(); static void DrawRadarMask(); static void DrawRadarSection(int32 x, int32 y); - static void DrawRadarSprite(int32 sprite, float x, float y, int32 alpha); + static void DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha); static void DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha); static int32 GetActualBlipArrayIndex(int32 i); static int32 GetNewUniqueBlipIndex(int32 i); - static int32 GetRadarTraceColour(int32 color, bool bright); + static uint32 GetRadarTraceColour(uint32 color, bool bright); static void Initialise(); static float LimitRadarPoint(CVector2D &point); static void LoadAllRadarBlips(int32); @@ -125,11 +125,11 @@ public: static void RequestMapSection(int32 x, int32 y); static void SaveAllRadarBlips(int32); static void SetBlipSprite(int32 i, int32 icon); - static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay flag); + static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay); static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay); - static void SetRadarMarkerState(int32 i, int32 flag); - static void ShowRadarMarker(CVector pos, int16 color, float radius); - static void ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha); + static void SetRadarMarkerState(int32 i, bool flag); + static void ShowRadarMarker(CVector pos, uint32 color, float radius); + static void ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha); static void Shutdown(); static void StreamRadarSections(const CVector &posn); static void StreamRadarSections(int32 x, int32 y); -- cgit v1.2.3 From cc621ba0995f659c32dee4b7d7870902ef50c9eb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Oct 2019 16:04:27 +0300 Subject: Corona widescreen fix --- src/core/common.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/common.h b/src/core/common.h index b3a271c6..caa305d6 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -92,9 +92,11 @@ extern void **rwengine; #define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a)) #ifdef ASPECT_RATIO_SCALE -#define SCREEN_SCALE_AR(a) ((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) +#define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO) +#define SCREEN_SCALE_AR2(a) ((a) / (DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO)) #else #define SCREEN_SCALE_AR(a) (a) +#define SCREEN_SCALE_AR2(a) (a) #endif #include "maths.h" -- cgit v1.2.3 From aa4e7ad5eb554b1219f7eaae53e5ddc0d4478dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 5 Oct 2019 16:44:03 +0300 Subject: CDarkel, walkaround fix --- src/core/Streaming.cpp | 8 ++++---- src/core/config.h | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index a7bde91e..d15415ea 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1021,7 +1021,7 @@ CStreaming::RemoveAllUnusedModels(void) for(i = 0; i < MAXVEHICLESLOADED; i++) RemoveLoadedVehicle(); - for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){ + for(i = NUMDEFAULTMODELS; i < MODELINFOSIZE; i++){ if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED && ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE && CModelInfo::GetModelInfo(i)->m_refCount == 0){ @@ -2408,8 +2408,8 @@ CStreaming::MemoryCardSave(uint8 *buffer, uint32 *length) { int i; - *length = NUM_DEFAULT_MODELS; - for(i = 0; i < NUM_DEFAULT_MODELS; i++) + *length = NUMDEFAULTMODELS; + for(i = 0; i < NUMDEFAULTMODELS; i++) if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED) buffer[i] = ms_aInfoForModel[i].m_flags; else @@ -2421,7 +2421,7 @@ CStreaming::MemoryCardLoad(uint8 *buffer, uint32 length) { uint32 i; - assert(length == NUM_DEFAULT_MODELS); + assert(length == NUMDEFAULTMODELS); for(i = 0; i < length; i++) if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED) if(buffer[i] != 0xFF) diff --git a/src/core/config.h b/src/core/config.h index 49bef3fa..520bcc72 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -32,6 +32,7 @@ enum Config { NUMDUMMIES = 2802, // 2368 on PS2 NUMAUDIOSCRIPTOBJECTS = 256, NUMCUTSCENEOBJECTS = 50, + NUMDEFAULTMODELS = 200, NUMTEMPOBJECTS = 30, @@ -138,11 +139,25 @@ enum Config { #endif #define FIX_BUGS // fix bugs in the game, TODO: use this more + +// Pad #define KANGAROO_CHEAT + +// Hud #define ASPECT_RATIO_SCALE + +// Script #define USE_DEBUG_SCRIPT_LOADER + +// Vehicles #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher -#define ANIMATE_PED_COL_MODEL //#define REMOVE_TREADABLE_PATHFIND + +// Pickups +//#define MONEY_MESSAGES + +// Peds +#define ANIMATE_PED_COL_MODEL #define VC_PED_PORTS -//#define MONEY_MESSAGES \ No newline at end of file +#define NEW_WALK_AROUND_ALGORITHM +#define CANCELLABLE_CAR_ENTER \ No newline at end of file -- cgit v1.2.3 From 365f9e9caff6f61ef08ca67526fd85f9a010d965 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Oct 2019 17:32:01 +0300 Subject: Triangular radar blips --- src/core/Radar.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/core/Radar.h | 8 ++++++ src/core/config.h | 5 +++- 3 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 7eff743a..ebb71f5f 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -335,7 +335,18 @@ void CRadar::DrawBlips() if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) { DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); } else { +#ifdef TRIANGULAR_BLIPS + CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + CVector &blipPos = blipEntity->GetPosition(); + uint8 mode = BLIP_MODE_TRIANGULAR_UP; + if (blipPos.z - pos.z <= 2.0f) { + if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); +#else ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); +#endif } } } @@ -363,7 +374,18 @@ void CRadar::DrawBlips() if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) { DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); } else { +#ifdef TRIANGULAR_BLIPS + CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; + uint8 mode = BLIP_MODE_TRIANGULAR_UP; + if (blipPos.z - pos.z <= 2.0f) { + if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); +#else ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); +#endif } } } @@ -417,7 +439,20 @@ void CRadar::DrawBlips() if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); else +#ifdef TRIANGULAR_BLIPS + { + CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + CVector &blipPos = blipEntity->GetPosition(); + uint8 mode = BLIP_MODE_TRIANGULAR_UP; + if (blipPos.z - pos.z <= 2.0f) { + if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); + } +#else ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); +#endif } } } @@ -453,7 +488,20 @@ void CRadar::DrawBlips() if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist)); else +#ifdef TRIANGULAR_BLIPS + { + CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; + uint8 mode = BLIP_MODE_TRIANGULAR_UP; + if (blipPos.z - pos.z <= 2.0f) { + if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); + } +#else ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); +#endif } } break; @@ -949,6 +997,30 @@ void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 gree } #endif +void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha, uint8 mode) +{ + if (!CHud::m_Wants_To_Draw_Hud || TheCamera.m_WideScreenOn) + return; + + switch (mode) + { + case BLIP_MODE_TRIANGULAR_UP: + // size++; // VC does size + 1 for triangles + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(size + 3.0f), y + SCREEN_SCALE_Y(size + 2.0f), x - (SCREEN_SCALE_X(size + 3.0f)), y + SCREEN_SCALE_Y(size + 2.0f), x, y - (SCREEN_SCALE_Y(size + 3.0f)), x, y - (SCREEN_SCALE_Y(size + 3.0f)), CRGBA(0, 0, 0, alpha)); + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(size + 1.0f), y + SCREEN_SCALE_Y(size + 1.0f), x - (SCREEN_SCALE_X(size + 1.0f)), y + SCREEN_SCALE_Y(size + 1.0f), x, y - (SCREEN_SCALE_Y(size + 1.0f)), x, y - (SCREEN_SCALE_Y(size + 1.0f)), CRGBA(red, green, blue, alpha)); + break; + case BLIP_MODE_TRIANGULAR_DOWN: + // size++; // VC does size + 1 for triangles + CSprite2d::Draw2DPolygon(x, y + SCREEN_SCALE_Y(size + 2.0f), x, y + SCREEN_SCALE_Y(size + 3.0f), x + SCREEN_SCALE_X(size + 3.0f), y - (SCREEN_SCALE_Y(size + 2.0f)), x - (SCREEN_SCALE_X(size + 3.0f)), y - (SCREEN_SCALE_Y(size + 2.0f)), CRGBA(0, 0, 0, alpha)); + CSprite2d::Draw2DPolygon(x, y + SCREEN_SCALE_Y(size + 1.0f), x, y + SCREEN_SCALE_Y(size + 1.0f), x + SCREEN_SCALE_X(size + 1.0f), y - (SCREEN_SCALE_Y(size + 1.0f)), x - (SCREEN_SCALE_X(size + 1.0f)), y - (SCREEN_SCALE_Y(size + 1.0f)), CRGBA(red, green, blue, alpha)); + break; + case BLIP_MODE_SQUARE: + CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size + 1.0f), y - SCREEN_SCALE_Y(size + 1.0f), SCREEN_SCALE_X(size + 1.0f) + x, SCREEN_SCALE_Y(size + 1.0f) + y), CRGBA(0, 0, 0, alpha)); + CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha)); + break; + } +} + #if 1 WRAPPER void CRadar::Shutdown() { EAXJMP(0x4A3F60); } #else diff --git a/src/core/Radar.h b/src/core/Radar.h index 6bb445fd..d6b249db 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -45,6 +45,13 @@ enum eRadarSprite RADAR_SPRITE_COUNT = 21, }; +enum +{ + BLIP_MODE_TRIANGULAR_UP = 0, + BLIP_MODE_TRIANGULAR_DOWN, + BLIP_MODE_SQUARE, +}; + struct CBlip { uint32 m_nColor; @@ -130,6 +137,7 @@ public: static void SetRadarMarkerState(int32 i, bool flag); static void ShowRadarMarker(CVector pos, uint32 color, float radius); static void ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha); + static void ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha, uint8 mode); static void Shutdown(); static void StreamRadarSections(const CVector &posn); static void StreamRadarSections(int32 x, int32 y); diff --git a/src/core/config.h b/src/core/config.h index 520bcc72..767abbe4 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -160,4 +160,7 @@ enum Config { #define ANIMATE_PED_COL_MODEL #define VC_PED_PORTS #define NEW_WALK_AROUND_ALGORITHM -#define CANCELLABLE_CAR_ENTER \ No newline at end of file +#define CANCELLABLE_CAR_ENTER + +// Blips +#define TRIANGULAR_BLIPS \ No newline at end of file -- cgit v1.2.3 From 42fbe50739763872320879039e0e908ce9c2c543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 5 Oct 2019 21:50:02 +0300 Subject: Fixes --- src/core/config.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 767abbe4..cfad6d85 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -143,8 +143,9 @@ enum Config { // Pad #define KANGAROO_CHEAT -// Hud +// Hud & radar #define ASPECT_RATIO_SCALE +#define TRIANGULAR_BLIPS // Script #define USE_DEBUG_SCRIPT_LOADER @@ -161,6 +162,3 @@ enum Config { #define VC_PED_PORTS #define NEW_WALK_AROUND_ALGORITHM #define CANCELLABLE_CAR_ENTER - -// Blips -#define TRIANGULAR_BLIPS \ No newline at end of file -- cgit v1.2.3 From 96eee4f10ffd5b5fccf417aba580108b160e3842 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 6 Oct 2019 02:41:35 +0300 Subject: Fixed CCamera::SetWideScreenOff dupe, removed goto in CStreaming::RetryLoadFile --- src/core/Camera.cpp | 22 +++++++++++++++++++--- src/core/Camera.h | 16 ++++++++-------- src/core/Streaming.cpp | 9 +++------ 3 files changed, 30 insertions(+), 17 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 93680dc1..775ab46a 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -22,7 +22,6 @@ WRAPPER void CCamera::CamShake(float strength, float x, float y, float z) { EAXJ WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); } WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); } WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); } -WRAPPER void CCamera::SetWidescreenOff(void) { EAXJMP(0x46FF10); } WRAPPER void CamShakeNoPos(CCamera*, float) { EAXJMP(0x46B100); } WRAPPER void CCamera::TakeControl(CEntity*, int16, int16, int32) { EAXJMP(0x471500); } WRAPPER void CCamera::TakeControlNoEntity(const CVector&, int16, int32) { EAXJMP(0x4715B0); } @@ -33,8 +32,6 @@ WRAPPER void CCamera::Process(void) { EAXJMP(0x46D3F0); } WRAPPER void CCamera::LoadPathSplines(int file) { EAXJMP(0x46D1D0); } WRAPPER uint32 CCamera::GetCutSceneFinishTime(void) { EAXJMP(0x46B920); } WRAPPER void CCamera::FinishCutscene(void) { EAXJMP(0x46B560); } -WRAPPER void CCamera::SetCamCutSceneOffSet(const CVector&) { EAXJMP(0x46FC30); }; -WRAPPER void CCamera::TakeControlWithSpline(short) { EAXJMP(0x471620); }; WRAPPER void CCamera::RestoreWithJumpCut(void) { EAXJMP(0x46FAE0); }; bool @@ -1333,6 +1330,25 @@ CCamera::Find3rdPersonQuickAimPitch(void) return -(DEGTORAD(((0.5f - m_f3rdPersonCHairMultY) * 1.8f * 0.5f * Cams[ActiveCam].FOV)) + rot); } +void +CCamera::SetCamCutSceneOffSet(const CVector &pos) +{ + m_vecCutSceneOffset = pos; +}; + +void +CCamera::TakeControlWithSpline(short nSwitch) +{ + m_iModeToGoTo = CCam::MODE_FLYBY; + m_bLookingAtPlayer = false; + m_bLookingAtVector = false; + m_bcutsceneFinished = false; + m_iTypeOfSwitch = nSwitch; + m_bStartInterScript = true; + + //FindPlayerPed(); // unused +}; + STARTPATCHES InjectHook(0x42C760, (bool (CCamera::*)(const CVector ¢er, float radius, const CMatrix *mat))&CCamera::IsSphereVisible, PATCH_JUMP); InjectHook(0x46FD00, &CCamera::SetFadeColour, PATCH_JUMP); diff --git a/src/core/Camera.h b/src/core/Camera.h index de725b19..0fd372c3 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -380,11 +380,11 @@ uint32 unknown; CVector m_RealPreviousCameraPosition; CVector m_cvecAimingTargetCoors; CVector m_vecFixedModeVector; + CVector m_vecFixedModeSource; + CVector m_vecFixedModeUpOffSet; + CVector m_vecCutSceneOffset; - // one of those has to go - CVector m_vecFixedModeSource; - CVector m_vecFixedModeUpOffSet; -// CVector m_vecCutSceneOffset; + // one of those has to go CVector m_cvecStartingSourceForInterPol; CVector m_cvecStartingTargetForInterPol; CVector m_cvecStartingUpForInterPol; @@ -394,7 +394,7 @@ uint32 unknown; CVector m_vecSourceWhenInterPol; CVector m_vecTargetWhenInterPol; CVector m_vecUpWhenInterPol; - CVector m_vecClearGeometryVec; + //CVector m_vecClearGeometryVec; CVector m_vecGameCamPos; CVector SourceDuringInter; @@ -468,7 +468,8 @@ int m_iModeObbeCamIsInForCar; void DrawBordersForWideScreen(void); void Restore(void); - void SetWidescreenOff(void); + void SetWideScreenOn(void) { m_WideScreenOn = true; } + void SetWideScreenOff(void) { m_WideScreenOn = false; } float Find3rdPersonQuickAimPitch(void); @@ -487,8 +488,6 @@ int m_iModeObbeCamIsInForCar; void SetCamCutSceneOffSet(const CVector&); void TakeControlWithSpline(short); - void SetWideScreenOn(void) { m_WideScreenOn = true; } - void SetWideScreenOff(void) { m_WideScreenOn = false; } void RestoreWithJumpCut(void); void dtor(void) { this->CCamera::~CCamera(); } @@ -500,6 +499,7 @@ static_assert(offsetof(CCamera, m_uiTransitionState) == 0x89, "CCamera: error"); static_assert(offsetof(CCamera, m_uiTimeTransitionStart) == 0x94, "CCamera: error"); static_assert(offsetof(CCamera, m_BlurBlue) == 0x9C, "CCamera: error"); static_assert(offsetof(CCamera, Cams) == 0x1A4, "CCamera: error"); +static_assert(offsetof(CCamera, m_vecCutSceneOffset) == 0x6F8, "CCamera: error"); static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size"); extern CCamera &TheCamera; diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index d15415ea..227a4a9f 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1719,8 +1719,10 @@ CStreaming::RetryLoadFile(int32 ch) } switch(ms_channel[ch].state){ + case CHANNELSTATE_ERROR: + ms_channel[ch].numTries++; + if (CdStreamGetStatus(ch) == STREAM_READING || CdStreamGetStatus(ch) == STREAM_WAITING) break; case CHANNELSTATE_IDLE: -streamread: CdStreamRead(ch, ms_pStreamingBuffer[ch], ms_channel[ch].position, ms_channel[ch].size); ms_channel[ch].state = CHANNELSTATE_READING; ms_channel[ch].field24 = -600; @@ -1731,11 +1733,6 @@ streamread: CTimer::SetCodePause(false); } break; - case CHANNELSTATE_ERROR: - ms_channel[ch].numTries++; - if(CdStreamGetStatus(ch) != STREAM_READING && CdStreamGetStatus(ch) != STREAM_WAITING) - goto streamread; - break; } } -- cgit v1.2.3 From fe2ae13c80024e5167abbbbb6ab130126ab26951 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 6 Oct 2019 02:42:22 +0300 Subject: Fixed player blip heading when looking left/right/behind --- src/core/Radar.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index ebb71f5f..0d6cbc82 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -277,6 +277,10 @@ void CRadar::DrawBlips() float angle; if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1) angle = PI + FindPlayerHeading(); +#ifdef FIX_BUGS + else if (TheCamera.GetLookDirection() != LOOKING_FORWARD) + angle = FindPlayerHeading() - (PI + (TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind).Heading()); +#endif else angle = FindPlayerHeading() - (PI + TheCamera.GetForward().Heading()); -- cgit v1.2.3