summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-04-10 20:17:00 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-04-10 20:17:00 +0200
commitbe260b49b1e5421a96f78ae2f0512220d5805274 (patch)
tree16f21f6f45c749120e3853a4369fe39348344102 /src/core
parentrecord init (diff)
parentdisabling the code that freezes gang members (diff)
downloadre3-be260b49b1e5421a96f78ae2f0512220d5805274.tar
re3-be260b49b1e5421a96f78ae2f0512220d5805274.tar.gz
re3-be260b49b1e5421a96f78ae2f0512220d5805274.tar.bz2
re3-be260b49b1e5421a96f78ae2f0512220d5805274.tar.lz
re3-be260b49b1e5421a96f78ae2f0512220d5805274.tar.xz
re3-be260b49b1e5421a96f78ae2f0512220d5805274.tar.zst
re3-be260b49b1e5421a96f78ae2f0512220d5805274.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Camera.cpp6
-rw-r--r--src/core/CutsceneMgr.cpp440
-rw-r--r--src/core/CutsceneMgr.h50
-rw-r--r--src/core/FileLoader.cpp2
-rw-r--r--src/core/Frontend.cpp10
-rw-r--r--src/core/Frontend.h12
-rw-r--r--src/core/Game.cpp20
-rw-r--r--src/core/Game.h1
-rw-r--r--src/core/Pad.cpp394
-rw-r--r--src/core/Pad.h17
-rw-r--r--src/core/PlayerInfo.cpp900
-rw-r--r--src/core/PlayerSkin.cpp169
-rw-r--r--src/core/PlayerSkin.h21
-rw-r--r--src/core/Radar.cpp3006
-rw-r--r--src/core/Radar.h13
-rw-r--r--src/core/RwHelper.cpp7
-rw-r--r--src/core/RwTexRead.cpp203
-rw-r--r--src/core/Stats.cpp237
-rw-r--r--src/core/Stats.h27
-rw-r--r--src/core/World.cpp2
-rw-r--r--src/core/World.h2
-rw-r--r--src/core/common.h4
-rw-r--r--src/core/config.h6
-rw-r--r--src/core/main.cpp1928
-rw-r--r--src/core/obrstr.cpp236
-rw-r--r--src/core/obrstr.h16
-rw-r--r--src/core/timebars.cpp240
-rw-r--r--src/core/timebars.h10
28 files changed, 4363 insertions, 3616 deletions
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 00c838cf..91dd6573 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -142,7 +142,7 @@ CCamera::Init(void)
PlayerExhaustion = 1.0f;
DebugCamMode = CCam::MODE_NONE;
m_PedOrientForBehindOrInFront = 0.0f;
- if(!FrontEndMenuManager.m_bStartGameLoading){
+ if(!FrontEndMenuManager.m_bWantToRestart){
m_bFading = false;
CDraw::FadeValue = 0;
m_fFLOATingFade = 0.0f;
@@ -151,7 +151,7 @@ CCamera::Init(void)
m_fFLOATingFadeMusic = 0.0f;
}
m_bMoveCamToAvoidGeom = false;
- if(FrontEndMenuManager.m_bStartGameLoading)
+ if(FrontEndMenuManager.m_bWantToRestart)
m_bMoveCamToAvoidGeom = true;
m_bStartingSpline = false;
m_iTypeOfSwitch = INTERPOLATION;
@@ -3269,7 +3269,7 @@ void
CCamera::SetRwCamera(RwCamera *cam)
{
m_pRwCamera = cam;
- m_viewMatrix.Attach(&m_pRwCamera->viewMatrix, false);
+ m_viewMatrix.Attach(RwCameraGetViewMatrix(m_pRwCamera), false);
CMBlur::MotionBlurOpen(m_pRwCamera);
}
diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp
deleted file mode 100644
index 283f34b8..00000000
--- a/src/core/CutsceneMgr.cpp
+++ /dev/null
@@ -1,440 +0,0 @@
-#define WITHWINDOWS // just for VK_SPACE
-#include "common.h"
-#include "patcher.h"
-#include "General.h"
-#include "CutsceneMgr.h"
-#include "Directory.h"
-#include "Camera.h"
-#include "Streaming.h"
-#include "FileMgr.h"
-#include "main.h"
-#include "AnimManager.h"
-#include "AnimBlendAssociation.h"
-#include "AnimBlendAssocGroup.h"
-#include "AnimBlendClumpData.h"
-#include "Pad.h"
-#include "DMAudio.h"
-#include "World.h"
-#include "PlayerPed.h"
-#include "Wanted.h"
-#include "CutsceneHead.h"
-#include "RpAnimBlend.h"
-#include "ModelIndices.h"
-#include "TempColModels.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 (!CGeneral::faststricmp(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)[CUTSCENENAMESIZE] = *(char(*)[CUTSCENENAMESIZE]) *(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;
-
-RpAtomic *
-CalculateBoundingSphereRadiusCB(RpAtomic *atomic, void *data)
-{
- float radius = RpAtomicGetBoundingSphereMacro(atomic)->radius;
- RwV3d center = RpAtomicGetBoundingSphereMacro(atomic)->center;
-
- for (RwFrame *frame = RpAtomicGetFrame(atomic); RwFrameGetParent(frame); frame = RwFrameGetParent(frame))
- RwV3dTransformPoints(&center, &center, 1, RwFrameGetMatrix(frame));
-
- float size = RwV3dLength(&center) + radius;
- if (size > *(float *)data)
- *(float *)data = size;
- return atomic;
-}
-
-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(CUTSCENEDIRSIZE);
- ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
-}
-
-void
-CCutsceneMgr::Shutdown(void)
-{
- delete ms_pCutsceneDir;
-}
-
-void
-CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
-{
- int file;
- uint32 size;
- uint32 offset;
- CPlayerPed *pPlayerPed;
-
- ms_cutsceneProcessing = true;
- if (!strcasecmp(szCutsceneName, "jb"))
- ms_useLodMultiplier = true;
- CTimer::Stop();
-
- ms_pCutsceneDir->numEntries = 0;
- ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
-
- CStreaming::RemoveUnusedModelsInLoadedList();
- CGame::DrasticTidyUpMemory(true);
-
- 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 (CGeneral::faststricmp(ms_cutsceneName, "end")) {
- DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE);
- 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[CUTSCENENAMESIZE * 2];
-
- sprintf(szAnim, "%s_%s", ms_cutsceneName, animName);
- pCutsceneHead->PlayAnimation(szAnim);
-}
-
-void
-CCutsceneMgr::FinishCutscene()
-{
- CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f;
- TheCamera.FinishCutscene();
-
- FindPlayerPed()->bIsVisible = true;
- CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
-}
-
-void
-CCutsceneMgr::SetupCutsceneToStart(void)
-{
- TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset);
- TheCamera.TakeControlWithSpline(JUMP_CUT);
- 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, 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) return;
-
- 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();
- 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 (CGeneral::faststricmp(ms_cutsceneName, "end")) {
- DMAudio.StopCutSceneMusic();
- if (CGeneral::faststricmp(ms_cutsceneName, "bet"))
- DMAudio.ChangeMusicMode(MUSICMODE_GAME);
- }
- CTimer::Stop();
- CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
- 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 (CGeneral::faststricmp(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) return;
-
- ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02f;
- if (CGeneral::faststricmp(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)->GetEnterJustDown()
- || CPad::GetPad(0)->GetCharJustDown(VK_SPACE))
- FinishCutscene();
- }
-}
-
-bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; }
-
-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);
- InjectHook(0x404B40, &CalculateBoundingSphereRadiusCB, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h
deleted file mode 100644
index 7b809964..00000000
--- a/src/core/CutsceneMgr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#pragma once
-#include "CutsceneObject.h"
-
-#define CUTSCENENAMESIZE 8
-
-class CDirectory;
-class CAnimBlendAssocGroup;
-class CCutsceneHead;
-
-class CCutsceneMgr
-{
- static bool &ms_running;
- 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)[CUTSCENENAMESIZE];
- static CAnimBlendAssocGroup &ms_cutsceneAssociations;
- static CVector &ms_cutsceneOffset;
- static float &ms_cutsceneTimer;
- static bool &ms_cutsceneProcessing;
-public:
- static CDirectory *&ms_pCutsceneDir;
- static uint32 &ms_cutsceneLoadStatus;
-
- static void SetRunning(bool running) { ms_running = running; }
- static bool IsRunning(void) { return ms_running; }
- static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; }
- static bool UseLodMultiplier(void) { return ms_useLodMultiplier; }
- static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; }
- static int GetCutsceneTimeInMilleseconds(void) { return 1000.0f * ms_cutsceneTimer; }
- static char *GetCutsceneName(void) { return ms_cutsceneName; }
- static void SetCutsceneOffset(const CVector& vec) { ms_cutsceneOffset = vec; }
- 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/FileLoader.cpp b/src/core/FileLoader.cpp
index 6305bf33..e0c8b01e 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -311,7 +311,7 @@ CFileLoader::FindRelatedModelInfoCB(RpAtomic *atomic, void *data)
int n;
RpClump *clump = (RpClump*)data;
- nodename = GetFrameNodeName(RpClumpGetFrame(atomic));
+ nodename = GetFrameNodeName(RpAtomicGetFrame(atomic));
GetNameAndLOD(nodename, name, &n);
mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(name, nil);
if(mi){
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 98d67fa2..beebacf9 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -555,7 +555,7 @@ void CMenuManager::DoSettingsBeforeStartingAGame()
m_PrefsVsync = m_PrefsVsyncDisp;
DMAudio.Service();
- m_bStartGameLoading = true;
+ m_bWantToRestart = true;
ShutdownJustMenu();
UnloadTextures();
@@ -2819,7 +2819,7 @@ void CMenuManager::Process(void)
if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus() != FADE_0)
return;
- m_bStartGameLoading = false;
+ m_bWantToRestart = false;
InitialiseChangedLanguageSettings();
if (CPad::GetPad(0)->GetEscapeJustDown())
@@ -2861,9 +2861,9 @@ void CMenuManager::Process(void)
if (m_PrefsVsyncDisp != m_PrefsVsync)
m_PrefsVsync = m_PrefsVsyncDisp;
DMAudio.Service();
- m_bStartGameLoading = true;
+ m_bWantToRestart = true;
RequestFrontEndShutDown();
- m_bLoadingSavedGame = true;
+ m_bWantToLoad = true;
b_FoundRecentSavedGameWantToLoad = true;
DMAudio.SetEffectsFadeVol(0);
DMAudio.SetMusicFadeVol(0);
@@ -2960,7 +2960,7 @@ void CMenuManager::Process(void)
m_bWaitingForNewKeyBind = false;
}
- if (!m_bStartGameLoading) {
+ if (!m_bWantToRestart) {
if (m_bGameNotLoaded)
DMAudio.Service();
}
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index a97afb24..20cf9e42 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -464,7 +464,7 @@ public:
bool m_bMenuActive;
bool m_bMenuStateChanged;
bool m_bWaitingForNewKeyBind;
- bool m_bStartGameLoading;
+ bool m_bWantToRestart;
bool m_bFirstTime;
bool m_bGameNotLoaded;
int32 m_nMousePosX;
@@ -484,7 +484,7 @@ public:
bool m_bQuitGameNoCD;
bool m_bRenderGameInMenu;
bool m_bSaveMenuActive;
- bool m_bLoadingSavedGame;
+ bool m_bWantToLoad;
char field_455;
bool m_bStartWaitingForKeyBind;
bool m_bSpritesLoaded;
@@ -550,10 +550,10 @@ public:
static int32 &sthWithButtons;
static int32 &sthWithButtons2;
-#ifndef MASTER
- static bool m_PrefsMarketing;
- static bool m_PrefsDisableTutorials;
-#endif // !MASTER
+#ifndef MASTER
+ static bool m_PrefsMarketing;
+ static bool m_PrefsDisableTutorials;
+#endif // !MASTER
#ifdef MENU_MAP
static bool bMenuMapActive;
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 8571e93e..daac3ec5 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -89,8 +89,6 @@
-#define DEFAULT_VIEWWINDOW (0.7f)
-
eLevelName &CGame::currLevel = *(eLevelName*)0x941514;
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
bool &CGame::nastyGame = *(bool*)0x5F4DD4;
@@ -492,7 +490,7 @@ void CGame::ReInitGameObjectVariables(void)
CParticle::ReloadConfig();
CCullZones::ResolveVisibilities();
- if ( !FrontEndMenuManager.m_bLoadingSavedGame )
+ if ( !FrontEndMenuManager.m_bWantToLoad )
{
CCranes::InitCranes();
CTheScripts::StartTestScript();
@@ -566,7 +564,7 @@ void CGame::InitialiseWhenRestarting(void)
TheCamera.Init();
- if ( FrontEndMenuManager.m_bLoadingSavedGame == true )
+ if ( FrontEndMenuManager.m_bWantToLoad == true )
{
RestoreForStartLoad();
CStreaming::LoadScene(TheCamera.GetPosition());
@@ -574,7 +572,7 @@ void CGame::InitialiseWhenRestarting(void)
ReInitGameObjectVariables();
- if ( FrontEndMenuManager.m_bLoadingSavedGame == true )
+ if ( FrontEndMenuManager.m_bWantToLoad == true )
{
if ( GenericLoad() == true )
{
@@ -593,7 +591,7 @@ void CGame::InitialiseWhenRestarting(void)
ShutDownForRestart();
CTimer::Stop();
CTimer::Initialise();
- FrontEndMenuManager.m_bLoadingSavedGame = false;
+ FrontEndMenuManager.m_bWantToLoad = false;
ReInitGameObjectVariables();
currLevel = LEVEL_INDUSTRIAL;
CCollision::SortOutCollisionAfterLoad();
@@ -609,6 +607,9 @@ extern void (*DebugMenuProcess)(void);
void CGame::Process(void)
{
CPad::UpdatePads();
+#ifdef GTA_PS2
+ ProcessTidyUpMemory();
+#endif
TheCamera.SetMotionBlurAlpha(0);
if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
@@ -695,6 +696,13 @@ void CGame::TidyUpMemory(bool, bool)
#endif
}
+void CGame::ProcessTidyUpMemory(void)
+{
+#ifdef PS2
+ // meow
+#endif
+}
+
STARTPATCHES
InjectHook(0x48BB80, CGame::InitialiseOnceBeforeRW, PATCH_JUMP);
InjectHook(0x48BBA0, CGame::InitialiseRenderWare, PATCH_JUMP);
diff --git a/src/core/Game.h b/src/core/Game.h
index 318ff54b..30581893 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -39,4 +39,5 @@ public:
// NB: these do something on PS2
static void TidyUpMemory(bool, bool);
static void DrasticTidyUpMemory(bool);
+ static void ProcessTidyUpMemory(void);
};
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index ff7b2fb7..b03272f9 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -29,12 +29,17 @@
#include "Replay.h"
#include "Weather.h"
#include "win.h"
+#include "Streaming.h"
+#include "PathFind.h"
+#include "Wanted.h"
+#include "General.h"
CPad *Pads = (CPad*)0x6F0360; // [2]
CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C;
bool &CPad::bDisplayNoControllerMessage = *(bool *)0x95CD52;
bool &CPad::bObsoleteControllerMessage = *(bool *)0x95CDB8;
+bool CPad::bOldDisplayNoControllerMessage;
bool &CPad::m_bMapPadOneToPadTwo = *(bool *)0x95CD48;
CKeyboardState &CPad::OldKeyState = *(CKeyboardState*)0x6F1E70;
@@ -50,29 +55,217 @@ CMouseControllerState &CPad::PCTempMouseControllerState = *(CMouseControllerStat
_TODO("gbFastTime");
extern bool &gbFastTime;
-WRAPPER void WeaponCheat() { EAXJMP(0x490D90); }
-WRAPPER void HealthCheat() { EAXJMP(0x490E70); }
-WRAPPER void TankCheat() { EAXJMP(0x490EE0); }
-WRAPPER void BlowUpCarsCheat() { EAXJMP(0x491040); }
-WRAPPER void ChangePlayerCheat() { EAXJMP(0x4910B0); }
-WRAPPER void MayhemCheat() { EAXJMP(0x4911C0); }
-WRAPPER void EverybodyAttacksPlayerCheat() { EAXJMP(0x491270); }
-WRAPPER void WeaponsForAllCheat() { EAXJMP(0x491370); }
-WRAPPER void FastTimeCheat() { EAXJMP(0x4913A0); }
-WRAPPER void SlowTimeCheat() { EAXJMP(0x4913F0); }
-WRAPPER void MoneyCheat() { EAXJMP(0x491430); }
-WRAPPER void ArmourCheat() { EAXJMP(0x491460); }
-WRAPPER void WantedLevelUpCheat() { EAXJMP(0x491490); }
-WRAPPER void WantedLevelDownCheat() { EAXJMP(0x4914F0); }
-WRAPPER void SunnyWeatherCheat() { EAXJMP(0x491520); }
-WRAPPER void CloudyWeatherCheat() { EAXJMP(0x491550); }
-WRAPPER void RainyWeatherCheat() { EAXJMP(0x491580); }
-WRAPPER void FoggyWeatherCheat() { EAXJMP(0x4915B0); }
-WRAPPER void FastWeatherCheat() { EAXJMP(0x4915E0); }
-WRAPPER void OnlyRenderWheelsCheat() { EAXJMP(0x491610); }
-WRAPPER void ChittyChittyBangBangCheat() { EAXJMP(0x491640); }
-WRAPPER void StrongGripCheat() { EAXJMP(0x491670); }
-WRAPPER void NastyLimbsCheat() { EAXJMP(0x4916A0); }
+void WeaponCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT2"), true);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_BASEBALLBAT, 0);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_COLT45, 100);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_UZI, 100);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_SHOTGUN, 20);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_AK47, 200);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_M16, 200);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_SNIPERRIFLE, 5);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_ROCKETLAUNCHER, 5);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_MOLOTOV, 5);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_GRENADE, 5);
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_FLAMETHROWER, 200);
+}
+
+void HealthCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT3"), true);
+ FindPlayerPed()->m_fHealth = 100.0f;
+ if (FindPlayerVehicle()) {
+ FindPlayerVehicle()->m_fHealth = 1000.0f;
+ if (FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_CAR)
+ ((CAutomobile*)FindPlayerVehicle())->Damage.SetEngineStatus(0);
+ }
+}
+
+void TankCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CStreaming::RequestModel(MI_RHINO, 0);
+ CStreaming::LoadAllRequestedModels(false);
+ if (CStreaming::ms_aInfoForModel[MI_RHINO].m_loadState == STREAMSTATE_LOADED) {
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ int32 node = ThePaths.FindNodeClosestToCoors(FindPlayerCoors(), PATH_CAR, 100.0f);
+
+ if (node < 0) return;
+
+#ifdef FIX_BUGS
+ CAutomobile* tank = new CAutomobile(MI_RHINO, RANDOM_VEHICLE);
+#else
+ CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE);
+#endif
+ if (tank != nil) {
+ CVector pos = ThePaths.m_pathNodes[node].pos;
+ pos.z += 4.0f;
+ tank->GetPosition() = pos;
+ tank->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f));
+
+ tank->m_status = STATUS_ABANDONED;
+ tank->m_nDoorLock = CARLOCK_UNLOCKED;
+ CWorld::Add(tank);
+ }
+ }
+}
+
+void BlowUpCarsCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+
+ int i = CPools::GetVehiclePool()->GetSize();
+ while (i-- > 0) {
+ if (CVehicle *veh = CPools::GetVehiclePool()->GetSlot(i))
+ veh->BlowUpCar(nil);
+ }
+}
+
+void ChangePlayerCheat()
+{
+ int modelId;
+
+ if (FindPlayerPed()->IsPedInControl() && CModelInfo::GetModelInfo("player", nil)) {
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CPlayerPed *ped = FindPlayerPed();
+ AssocGroupId AnimGrp = ped->m_animGroup;
+ do
+ {
+ do
+ modelId = CGeneral::GetRandomNumberInRange(0, MI_CAS_WOM+1);
+ while (!CModelInfo::GetModelInfo(modelId));
+ } while (modelId >= MI_SPECIAL01 && modelId <= MI_SPECIAL04 || modelId == MI_TAXI_D);
+
+ uint8 flags = CStreaming::ms_aInfoForModel[modelId].m_flags;
+ ped->DeleteRwObject();
+ CStreaming::RequestModel(modelId, STREAMFLAGS_DEPENDENCY| STREAMFLAGS_DONT_REMOVE);
+ CStreaming::LoadAllRequestedModels(false);
+ ped->m_modelIndex = -1;
+ ped->SetModelIndex(modelId);
+ ped->m_animGroup = AnimGrp;
+ if (modelId != MI_PLAYER) {
+ if (!(flags & STREAMFLAGS_DONT_REMOVE))
+ CStreaming::SetModelIsDeletable(modelId);
+ }
+ }
+}
+
+void MayhemCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ for (int i = PEDTYPE_CIVMALE; i < PEDTYPE_SPECIAL; i++)
+ CPedType::SetThreats(i, PED_FLAG_PLAYER1 | PED_FLAG_PLAYER2 | PED_FLAG_PLAYER3 | PED_FLAG_PLAYER4 |
+ PED_FLAG_CIVMALE | PED_FLAG_CIVFEMALE | PED_FLAG_COP | PED_FLAG_GANG1 |
+ PED_FLAG_GANG2 | PED_FLAG_GANG3 | PED_FLAG_GANG4 | PED_FLAG_GANG5 |
+ PED_FLAG_GANG6 | PED_FLAG_GANG7 | PED_FLAG_GANG8 | PED_FLAG_GANG9 |
+ PED_FLAG_EMERGENCY | PED_FLAG_PROSTITUTE | PED_FLAG_CRIMINAL | PED_FLAG_SPECIAL );
+}
+
+void EverybodyAttacksPlayerCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ for (int i = PEDTYPE_CIVMALE; i < PEDTYPE_SPECIAL; i++)
+ CPedType::AddThreat(i, PED_FLAG_PLAYER1);
+}
+
+void WeaponsForAllCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CPopulation::ms_bGivePedsWeapons = !CPopulation::ms_bGivePedsWeapons;
+}
+
+void FastTimeCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ if (CTimer::GetTimeScale() < 4.0f)
+ CTimer::SetTimeScale(CTimer::GetTimeScale() * 2.0f);
+}
+
+void SlowTimeCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ if (CTimer::GetTimeScale() > 0.25f)
+ CTimer::SetTimeScale(CTimer::GetTimeScale() * 0.5f);
+}
+
+void MoneyCheat()
+{
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 250000;
+ CHud::SetHelpMessage(TheText.Get("CHEAT6"), true);
+}
+
+void ArmourCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT4"), true);
+ FindPlayerPed()->m_fArmour = 100.0f;
+}
+
+void WantedLevelUpCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT5"), true);
+ FindPlayerPed()->SetWantedLevel(min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6));
+}
+
+void WantedLevelDownCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT5"), true);
+ FindPlayerPed()->SetWantedLevel(0);
+}
+
+void SunnyWeatherCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT7"), true);
+ CWeather::ForceWeatherNow(WEATHER_SUNNY);
+}
+
+void CloudyWeatherCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT7"), true);
+ CWeather::ForceWeatherNow(WEATHER_CLOUDY);
+}
+
+void RainyWeatherCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT7"), true);
+ CWeather::ForceWeatherNow(WEATHER_RAINY);
+}
+
+void FoggyWeatherCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT7"), true);
+ CWeather::ForceWeatherNow(WEATHER_FOGGY);
+}
+
+void FastWeatherCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ gbFastTime = !gbFastTime;
+}
+
+void OnlyRenderWheelsCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CVehicle::bWheelsOnlyCheat = !CVehicle::bWheelsOnlyCheat;
+}
+
+
+void ChittyChittyBangBangCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CVehicle::bAllDodosCheat = !CVehicle::bAllDodosCheat;
+}
+
+void StrongGripCheat()
+{
+ CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
+ CVehicle::bCheat3 = !CVehicle::bCheat3;
+}
+
+void NastyLimbsCheat()
+{
+ CPed::bNastyLimbsCheat = !CPed::bNastyLimbsCheat;
+}
//////////////////////////////////////////////////////////////////////////
#ifdef KANGAROO_CHEAT
@@ -89,7 +282,7 @@ void KangarooCheat()
string = TheText.Get("CHEAT1");
m_fMass = 15.0f;
}
- CHud::SetHelpMessage(string, 1);
+ CHud::SetHelpMessage(string, true);
playerPed->m_ped_flagI80 = !playerPed->m_ped_flagI80;
playerPed->m_fMass = m_fMass;
@@ -138,6 +331,21 @@ void CKeyboardState::Clear()
LWIN = RWIN = APPS = 0;
}
+#ifdef GTA_PS2_STUFF
+void CPad::Initialise(void)
+{
+ for (int i = 0; i < MAX_PADS; i++)
+ {
+ CPad::GetPad(i)->Clear(true);
+ CPad::GetPad(i)->Mode = 0;
+ }
+
+ bObsoleteControllerMessage = false;
+ bOldDisplayNoControllerMessage = false;
+ bDisplayNoControllerMessage = false;
+}
+#endif
+
void CPad::Clear(bool bResetPlayerControls)
{
NewState.Clear();
@@ -165,13 +373,13 @@ void CPad::Clear(bool bResetPlayerControls)
bApplyBrakes = false;
- for ( int32 i = 0; i < _TODOCONST(5); i++ )
+ for ( int32 i = 0; i < HORNHISTORY_SIZE; i++ )
bHornHistory[i] = false;
iCurrHornHistory = 0;
- for ( int32 i = 0; i < _TODOCONST(12); i++ )
- _unk[i] = ' ';
+ for ( int32 i = 0; i < ARRAY_SIZE(CheatString); i++ )
+ CheatString[i] = ' ';
LastTimeTouched = CTimer::GetTimeInMilliseconds();
AverageWeapon = 0;
@@ -430,6 +638,108 @@ void CPad::StartShake_Train(float fX, float fY)
}
}
+#ifdef GTA_PS2_STUFF
+void CPad::AddToCheatString(char c)
+{
+ for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- )
+ CheatString[i + 1] = CheatString[i];
+
+#define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1)
+ // "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP
+ if ( !_CHEATCMP("URDLURDL4144") )
+ WeaponCheat();
+
+ // "4411LDRULDRU" - R2 R2 L1 L1 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP
+ else if ( !_CHEATCMP("URDLURDL1144") )
+ MoneyCheat();
+
+ // "4412LDRULDRU" - R2 R2 L1 L2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP
+ else if ( !_CHEATCMP("URDLURDL2144") )
+ ArmourCheat();
+
+ // "4413LDRULDRU" - R2 R2 L1 R1 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP
+ else if ( !_CHEATCMP("URDLURDL3144") )
+ HealthCheat();
+
+ // "4414LRLRLR" - R2 R2 L1 R2 LEFT RIGHT LEFT RIGHT LEFT RIGHT
+ else if ( !_CHEATCMP("RLRLRL4144") )
+ WantedLevelUpCheat();
+
+ // "4414UDUDUD" - R2 R2 L1 R2 UP DOWN UP DOWN UP DOWN
+ else if ( !_CHEATCMP("DUDUDU4144") )
+ WantedLevelDownCheat();
+
+ // "1234432T" - L1 L2 R1 R2 R2 R1 L2 TRIANGLE
+ else if ( !_CHEATCMP("T2344321") )
+ SunnyWeatherCheat();
+
+ // "1234432S" - L1 L2 R1 R2 R2 R1 L2 SQUARE
+ else if ( !_CHEATCMP("S2344321") )
+ CloudyWeatherCheat();
+
+ // "1234432C" - L1 L2 R1 R2 R2 R1 L2 CIRCLE
+ else if ( !_CHEATCMP("C2344321") )
+ RainyWeatherCheat();
+
+ // "1234432X" - L1 L2 R1 R2 R2 R1 L2 CROSS
+ else if ( !_CHEATCMP("X2344321") )
+ FoggyWeatherCheat();
+
+ // "CCCCCC321TCT" - CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE R1 L2 L1 TRIANGLE CIRCLE TRIANGLE
+ else if ( !_CHEATCMP("TCT123CCCCCC") )
+ TankCheat();
+
+ // "CCCSSSSS1TCT" - CIRCLE CIRCLE CIRCLE SQUARE SQUARE SQUARE SQUARE SQUARE L1 TRIANGLE CIRCLE TRIANGLE
+ else if ( !_CHEATCMP("TCT1SSSSSCCC") )
+ FastWeatherCheat();
+
+ // "241324TSCT21" - L2 R2 L1 R1 L2 R2 TRIANGLE SQUARE CIRCLE TRIANGLE L2 L1
+ else if ( !_CHEATCMP("12TCST423142") )
+ BlowUpCarsCheat();
+
+ // "RDLU12ULDR" - RIGHT DOWN LEFT UP L1 L2 UP LEFT DOWN RIGHT
+ else if ( !_CHEATCMP("RDLU21ULDR") )
+ ChangePlayerCheat();
+
+ // "DULUX3421" - DOWN UP LEFT UP CROSS R1 R2 L2 L1
+ else if ( !_CHEATCMP("1243XULUD") )
+ MayhemCheat();
+
+ // "DULUX3412" - DOWN UP LEFT UP CROSS R1 R2 L1 L2
+ else if ( !_CHEATCMP("2143XULUD") )
+ EverybodyAttacksPlayerCheat();
+
+ // "43TX21UD" - R2 R1 TRIANGLE CROSS L2 L1 UP DOWN
+ else if ( !_CHEATCMP("DU12XT34") )
+ WeaponsForAllCheat();
+
+ // "TURDS12" - TRIANGLE UP RIGHT DOWN SQUARE L1 L2
+ else if ( !_CHEATCMP("21SDRUT") )
+ FastTimeCheat();
+
+ // "TURDS34" - TRIANGLE UP RIGHT DOWN SQUARE R1 R2
+ else if ( !_CHEATCMP("43SDRUT") )
+ SlowTimeCheat();
+
+ // "11S4T1T" - L1 L1 SQUARE R2 TRIANGLE L1 TRIANGLE
+ else if ( !_CHEATCMP("T1T4S11") )
+ OnlyRenderWheelsCheat();
+
+ // "R4C32D13" - RIGHT R2 CIRCLE R1 L2 DOWN L1 R1
+ else if ( !_CHEATCMP("31D23C4R") )
+ ChittyChittyBangBangCheat();
+
+ // "3141L33T" - R1 L1 R2 L1 LEFT R1 R1 TRIANGLE
+ else if ( !_CHEATCMP("T33L1413") )
+ StrongGripCheat();
+
+ // "S1CD13TR1X" - SQUARE L1 CIRCLE DOWN L1 R1 TRIANGLE RIGHT L1 CROSS
+ else if ( !_CHEATCMP("X1RT31DC1S") )
+ NastyLimbsCheat();
+#undef _CHEATCMP
+}
+#endif
+
void CPad::AddToPCCheatString(char c)
{
for ( int32 i = ARRAY_SIZE(KeyBoardCheatString) - 2; i >= 0; i-- )
@@ -672,7 +982,7 @@ void CPad::Update(int16 unk)
ProcessPCSpecificStuff();
- if ( ++iCurrHornHistory >= _TODOCONST(5) )
+ if ( ++iCurrHornHistory >= HORNHISTORY_SIZE )
iCurrHornHistory = 0;
bHornHistory[iCurrHornHistory] = GetHorn();
@@ -689,7 +999,7 @@ void CPad::DoCheats(void)
void CPad::DoCheats(int16 unk)
{
-#ifdef PS2
+#ifdef GTA_PS2_STUFF
if ( GetTriangleJustDown() )
AddToCheatString('T');
@@ -2092,7 +2402,31 @@ int32 *CPad::EditCodesForControls(int32 *pRsKeys, int32 nSize)
return pRsKeys;
}
-STARTPATCHES
+STARTPATCHES
+ InjectHook(0x490D90, &WeaponCheat, PATCH_JUMP);
+ InjectHook(0x490E70, &HealthCheat, PATCH_JUMP);
+ InjectHook(0x490EE0, &TankCheat, PATCH_JUMP);
+ InjectHook(0x491040, &BlowUpCarsCheat, PATCH_JUMP);
+ InjectHook(0x4910B0, &ChangePlayerCheat, PATCH_JUMP);
+ InjectHook(0x4911C0, &MayhemCheat, PATCH_JUMP);
+ InjectHook(0x491270, &EverybodyAttacksPlayerCheat, PATCH_JUMP);
+ InjectHook(0x491370, &WeaponsForAllCheat, PATCH_JUMP);
+ InjectHook(0x4913A0, &FastTimeCheat, PATCH_JUMP);
+ InjectHook(0x4913F0, &SlowTimeCheat, PATCH_JUMP);
+ InjectHook(0x491430, &MoneyCheat, PATCH_JUMP);
+ InjectHook(0x491460, &ArmourCheat, PATCH_JUMP);
+ InjectHook(0x491490, &WantedLevelUpCheat, PATCH_JUMP);
+ InjectHook(0x4914F0, &WantedLevelDownCheat, PATCH_JUMP);
+ InjectHook(0x491520, &SunnyWeatherCheat, PATCH_JUMP);
+ InjectHook(0x491550, &CloudyWeatherCheat, PATCH_JUMP);
+ InjectHook(0x491580, &RainyWeatherCheat, PATCH_JUMP);
+ InjectHook(0x4915B0, &FoggyWeatherCheat, PATCH_JUMP);
+ InjectHook(0x4915E0, &FastWeatherCheat, PATCH_JUMP);
+ InjectHook(0x491610, &OnlyRenderWheelsCheat, PATCH_JUMP);
+ InjectHook(0x491640, &ChittyChittyBangBangCheat, PATCH_JUMP);
+ InjectHook(0x491670, &StrongGripCheat, PATCH_JUMP);
+ InjectHook(0x4916A0, &NastyLimbsCheat, PATCH_JUMP);
+
InjectHook(0x4916C0, &CControllerState::Clear, PATCH_JUMP);
InjectHook(0x491760, &CKeyboardState::Clear, PATCH_JUMP);
InjectHook(0x491A10, &CPad::Clear, PATCH_JUMP);
diff --git a/src/core/Pad.h b/src/core/Pad.h
index ca44a9f7..78bfac1d 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -136,6 +136,10 @@ enum
class CPad
{
public:
+ enum
+ {
+ HORNHISTORY_SIZE = 5,
+ };
CControllerState NewState;
CControllerState OldState;
CControllerState PCTempKeyState;
@@ -146,11 +150,11 @@ public:
int16 Mode;
int16 ShakeDur;
uint8 ShakeFreq;
- bool bHornHistory[5];
+ bool bHornHistory[HORNHISTORY_SIZE];
uint8 iCurrHornHistory;
uint8 DisablePlayerControls;
int8 bApplyBrakes;
- char _unk[12]; //int32 unk[3];
+ char CheatString[12];
char _pad0[3];
int32 LastTimeTouched;
int32 AverageWeapon;
@@ -161,6 +165,7 @@ public:
static bool &bDisplayNoControllerMessage;
static bool &bObsoleteControllerMessage;
+ static bool bOldDisplayNoControllerMessage;
static bool &m_bMapPadOneToPadTwo;
static CKeyboardState &OldKeyState;
@@ -172,8 +177,9 @@ public:
static CMouseControllerState &PCTempMouseControllerState;
-
-
+#ifdef GTA_PS2_STUFF
+ static void Initialise(void);
+#endif
void Clear(bool bResetPlayerControls);
void ClearMouseHistory();
void UpdateMouse();
@@ -181,6 +187,9 @@ public:
void StartShake(int16 nDur, uint8 nFreq);
void StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, float fz);
void StartShake_Train(float fX, float fY);
+#ifdef GTA_PS2_STUFF
+ void AddToCheatString(char c);
+#endif
void AddToPCCheatString(char c);
static void UpdatePads(void);
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index ead32ee7..0043c2f4 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -48,45 +48,45 @@ CPlayerInfo::GetPos()
void
CPlayerInfo::LoadPlayerSkin()
-{
- DeletePlayerSkin();
-
- m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
- if (!m_pSkinTexture)
+{
+ 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 = nil;
+{
+ if (m_pSkinTexture) {
+ RwTextureDestroy(m_pSkinTexture);
+ m_pSkinTexture = nil;
}
}
-void
-CPlayerInfo::KillPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
-
- m_WBState = WBSTATE_WASTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
- CStats::TimesDied++;
+void
+CPlayerInfo::KillPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_WASTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
+ CStats::TimesDied++;
}
-void
-CPlayerInfo::ArrestPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
-
- m_WBState = WBSTATE_BUSTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
- CStats::TimesArrested++;
+void
+CPlayerInfo::ArrestPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_BUSTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
+ CStats::TimesArrested++;
}
bool
@@ -105,102 +105,102 @@ CPlayerInfo::PlayerFailedCriticalMission()
CDarkel::ResetOnPlayerDeath();
}
-void
-CPlayerInfo::Clear(void)
-{
- m_pPed = nil;
- m_pRemoteVehicle = nil;
- if (m_pVehicleEx) {
- m_pVehicleEx->bUsingSpecialColModel = false;
- m_pVehicleEx = nil;
- }
- m_nVisibleMoney = 0;
- m_nMoney = m_nVisibleMoney;
- m_WBState = WBSTATE_PLAYING;
- m_nWBTime = 0;
- m_nTrafficMultiplier = 0;
- m_fRoadDensity = 1.0f;
- m_bInRemoteMode = false;
- m_bUnusedTaxiThing = false;
- m_nUnusedTaxiTimer = 0;
- m_nCollectedPackages = 0;
- m_nTotalPackages = 3;
- m_nTimeLastHealthLoss = 0;
- m_nTimeLastArmourLoss = 0;
- m_nNextSexFrequencyUpdateTime = 0;
- m_nNextSexMoneyUpdateTime = 0;
- m_nSexFrequency = 0;
- m_pHooker = nil;
- m_nTimeTankShotGun = 0;
- field_248 = 0;
- m_nUpsideDownCounter = 0;
- m_bInfiniteSprint = false;
- m_bFastReload = false;
- m_bGetOutOfJailFree = false;
- m_bGetOutOfHospitalFree = false;
- m_nPreviousTimeRewardedForExplosion = 0;
- m_nExplosionsSinceLastReward = 0;
+void
+CPlayerInfo::Clear(void)
+{
+ m_pPed = nil;
+ m_pRemoteVehicle = nil;
+ if (m_pVehicleEx) {
+ m_pVehicleEx->bUsingSpecialColModel = false;
+ m_pVehicleEx = nil;
+ }
+ m_nVisibleMoney = 0;
+ m_nMoney = m_nVisibleMoney;
+ m_WBState = WBSTATE_PLAYING;
+ m_nWBTime = 0;
+ m_nTrafficMultiplier = 0;
+ m_fRoadDensity = 1.0f;
+ m_bInRemoteMode = false;
+ m_bUnusedTaxiThing = false;
+ m_nUnusedTaxiTimer = 0;
+ m_nCollectedPackages = 0;
+ m_nTotalPackages = 3;
+ m_nTimeLastHealthLoss = 0;
+ m_nTimeLastArmourLoss = 0;
+ m_nNextSexFrequencyUpdateTime = 0;
+ m_nNextSexMoneyUpdateTime = 0;
+ m_nSexFrequency = 0;
+ m_pHooker = nil;
+ m_nTimeTankShotGun = 0;
+ field_248 = 0;
+ m_nUpsideDownCounter = 0;
+ m_bInfiniteSprint = false;
+ m_bFastReload = false;
+ m_bGetOutOfJailFree = false;
+ m_bGetOutOfHospitalFree = false;
+ m_nPreviousTimeRewardedForExplosion = 0;
+ m_nExplosionsSinceLastReward = 0;
}
-void
-CPlayerInfo::BlowUpRCBuggy(void)
-{
- if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
- return;
-
- CRemote::TakeRemoteControlledCarFromPlayer();
- m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
+void
+CPlayerInfo::BlowUpRCBuggy(void)
+{
+ if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
+ return;
+
+ CRemote::TakeRemoteControlledCarFromPlayer();
+ m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
}
-
-void
-CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
-{
- if (!car || car == m_pPed->m_pMyVehicle) {
- if (m_pPed->EnteringCar())
- m_pPed->QuitEnteringCar();
- }
- if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
- m_pPed->ClearObjective();
+
+void
+CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
+{
+ if (!car || car == m_pPed->m_pMyVehicle) {
+ if (m_pPed->EnteringCar())
+ m_pPed->QuitEnteringCar();
+ }
+ if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
+ m_pPed->ClearObjective();
}
-void
-CPlayerInfo::MakePlayerSafe(bool toggle)
-{
- if (toggle) {
- CTheScripts::ResetCountdownToMakePlayerUnsafe();
- m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
- CWorld::StopAllLawEnforcersInTheirTracks();
- CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20;
- CPad::StopPadsShaking();
- m_pPed->bBulletProof = true;
- m_pPed->bFireProof = true;
- m_pPed->bCollisionProof = true;
- m_pPed->bMeleeProof = true;
- m_pPed->bOnlyDamagedByPlayer = true;
- m_pPed->bExplosionProof = true;
- m_pPed->m_bCanBeDamaged = false;
- ((CPlayerPed*)m_pPed)->ClearAdrenaline();
- CancelPlayerEnteringCars(false);
- gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
- CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
- CProjectileInfo::RemoveAllProjectiles();
- CWorld::SetAllCarsCanBeDamaged(false);
- CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
- CReplay::DisableReplays();
-
- } else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
- m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
- CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20;
- m_pPed->bBulletProof = false;
- m_pPed->bFireProof = false;
- m_pPed->bCollisionProof = false;
- m_pPed->bMeleeProof = false;
- m_pPed->bOnlyDamagedByPlayer = false;
- m_pPed->bExplosionProof = false;
- m_pPed->m_bCanBeDamaged = true;
- CWorld::SetAllCarsCanBeDamaged(true);
- CReplay::EnableReplays();
- }
+void
+CPlayerInfo::MakePlayerSafe(bool toggle)
+{
+ if (toggle) {
+ CTheScripts::ResetCountdownToMakePlayerUnsafe();
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
+ CWorld::StopAllLawEnforcersInTheirTracks();
+ CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20;
+ CPad::StopPadsShaking();
+ m_pPed->bBulletProof = true;
+ m_pPed->bFireProof = true;
+ m_pPed->bCollisionProof = true;
+ m_pPed->bMeleeProof = true;
+ m_pPed->bOnlyDamagedByPlayer = true;
+ m_pPed->bExplosionProof = true;
+ m_pPed->m_bCanBeDamaged = false;
+ ((CPlayerPed*)m_pPed)->ClearAdrenaline();
+ CancelPlayerEnteringCars(false);
+ gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
+ CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
+ CProjectileInfo::RemoveAllProjectiles();
+ CWorld::SetAllCarsCanBeDamaged(false);
+ CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
+ CReplay::DisableReplays();
+
+ } else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
+ CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20;
+ m_pPed->bBulletProof = false;
+ m_pPed->bFireProof = false;
+ m_pPed->bCollisionProof = false;
+ m_pPed->bMeleeProof = false;
+ m_pPed->bOnlyDamagedByPlayer = false;
+ m_pPed->bExplosionProof = false;
+ m_pPed->m_bCanBeDamaged = true;
+ CWorld::SetAllCarsCanBeDamaged(true);
+ CReplay::EnableReplays();
+ }
}
bool
@@ -216,347 +216,347 @@ CPlayerInfo::IsRestartingAfterArrest()
}
// lastCloseness is passed to other calls of this function
-void
-CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
-{
- // This dist used for determining the angle to face
- CVector2D dist(carToTest->GetPosition() - player->GetPosition());
- float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
- while (neededTurn >= PI) {
- neededTurn -= 2 * PI;
- }
-
- while (neededTurn < -PI) {
- neededTurn += 2 * PI;
- }
-
- // This dist used for evaluating cars' distances, weird...
- // Accounts inverted needed turn (or needed turn in long way) and car dist.
- float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
- if (closeness > *lastCloseness) {
- *lastCloseness = closeness;
- *closestCarOutput = (CVehicle*)carToTest;
- }
+void
+CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
+{
+ // This dist used for determining the angle to face
+ CVector2D dist(carToTest->GetPosition() - player->GetPosition());
+ float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
+ while (neededTurn >= PI) {
+ neededTurn -= 2 * PI;
+ }
+
+ while (neededTurn < -PI) {
+ neededTurn += 2 * PI;
+ }
+
+ // This dist used for evaluating cars' distances, weird...
+ // Accounts inverted needed turn (or needed turn in long way) and car dist.
+ float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
+ if (closeness > *lastCloseness) {
+ *lastCloseness = closeness;
+ *closestCarOutput = (CVehicle*)carToTest;
+ }
}
// There is something unfinished in here... Sadly all IDBs we have have it unfinished.
-void
-CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
-{
- if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
- ++m_nExplosionsSinceLastReward;
- else
- m_nExplosionsSinceLastReward = 1;
-
- m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
- int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
- sprintf(gString, "$%d", award);
-#ifdef MONEY_MESSAGES
- // This line is a leftover from PS2, I don't know what it was meant to be.
- // CVector sth(TheCamera.GetPosition() * 4.0f);
-
- CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
-#endif
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
-
- for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
- CGeneral::GetRandomNumber();
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
- }
+void
+CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
+{
+ if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
+ ++m_nExplosionsSinceLastReward;
+ else
+ m_nExplosionsSinceLastReward = 1;
+
+ m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
+ int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
+ sprintf(gString, "$%d", award);
+#ifdef MONEY_MESSAGES
+ // This line is a leftover from PS2, I don't know what it was meant to be.
+ // CVector sth(TheCamera.GetPosition() * 4.0f);
+
+ CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
+#endif
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
+
+ for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
+ CGeneral::GetRandomNumber();
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
+ }
}
-void
-CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
-{
- // Interesting
- *size = sizeof(CPlayerInfo);
-
-INITSAVEBUF
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
- for (int i = 0; i < sizeof(CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName); i++) {
- WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName[i]);
- }
-// Save struct is different
-// VALIDATESAVEBUF(*size)
+void
+CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
+{
+ // Interesting
+ *size = sizeof(CPlayerInfo);
+
+INITSAVEBUF
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
+ for (int i = 0; i < sizeof(CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName); i++) {
+ WriteSaveBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName[i]);
+ }
+// Save struct is different
+// VALIDATESAVEBUF(*size)
}
-void
-CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
-{
-INITSAVEBUF
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney = ReadSaveBuf<uint32>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_WBState = ReadSaveBuf<int8>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_nWBTime = ReadSaveBuf<uint32>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier = ReadSaveBuf<int16>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity = ReadSaveBuf<float>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney = ReadSaveBuf<int32>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages = ReadSaveBuf<int32>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages = ReadSaveBuf<int32>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint = ReadSaveBuf<bool>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_bFastReload = ReadSaveBuf<bool>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree = ReadSaveBuf<bool>(buf);
- CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree = ReadSaveBuf<bool>(buf);
- for (int i = 0; i < sizeof(CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName); i++) {
- CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName[i] = ReadSaveBuf<char>(buf);
- }
-// Save struct is different
-// VALIDATESAVEBUF(size)
+void
+CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
+{
+INITSAVEBUF
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney = ReadSaveBuf<uint32>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_WBState = ReadSaveBuf<int8>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_nWBTime = ReadSaveBuf<uint32>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier = ReadSaveBuf<int16>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity = ReadSaveBuf<float>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney = ReadSaveBuf<int32>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages = ReadSaveBuf<int32>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages = ReadSaveBuf<int32>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint = ReadSaveBuf<bool>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_bFastReload = ReadSaveBuf<bool>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree = ReadSaveBuf<bool>(buf);
+ CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree = ReadSaveBuf<bool>(buf);
+ for (int i = 0; i < sizeof(CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName); i++) {
+ CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName[i] = ReadSaveBuf<char>(buf);
+ }
+// Save struct is different
+// VALIDATESAVEBUF(size)
}
-void
-CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
-{
- for (CPtrNode* node = carList.first; node; node = node->next) {
- CVehicle *car = (CVehicle*)node->item;
- if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
- if (!car->bUsesCollision || !car->IsVehicle())
- continue;
-
- car->m_scanCode = CWorld::GetCurrentScanCode();
- if (car->m_status != STATUS_WRECKED && car->m_status != STATUS_TRAIN_MOVING
- && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
- CVector carCentre = car->GetBoundCentre();
-
- if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f) {
- float dist = (ped->GetPosition() - carCentre).Magnitude2D();
- if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
- EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
- }
- }
- }
- }
- }
+void
+CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
+{
+ for (CPtrNode* node = carList.first; node; node = node->next) {
+ CVehicle *car = (CVehicle*)node->item;
+ if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
+ if (!car->bUsesCollision || !car->IsVehicle())
+ continue;
+
+ car->m_scanCode = CWorld::GetCurrentScanCode();
+ if (car->m_status != STATUS_WRECKED && car->m_status != STATUS_TRAIN_MOVING
+ && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
+ CVector carCentre = car->GetBoundCentre();
+
+ if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f) {
+ float dist = (ped->GetPosition() - carCentre).Magnitude2D();
+ if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
+ EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
+ }
+ }
+ }
+ }
+ }
}
-void
-CPlayerInfo::Process(void)
-{
- // Unused taxi feature. Gives you a dollar for every second with a passenger. Can be toggled via 0x29A opcode.
- bool startTaxiTimer = true;
- if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
- CVehicle *veh = m_pPed->m_pMyVehicle;
- if ((veh->m_modelIndex == MI_TAXI || veh->m_modelIndex == MI_CABBIE || veh->m_modelIndex == MI_BORGNINE)
- && veh->pDriver == m_pPed && veh->m_nNumPassengers != 0) {
- for (uint32 timePassed = CTimer::GetTimeInMilliseconds() - m_nUnusedTaxiTimer; timePassed >= 1000; m_nUnusedTaxiTimer += 1000) {
- timePassed -= 1000;
- ++m_nMoney;
- }
- startTaxiTimer = false;
- }
- }
- if (startTaxiTimer)
- m_nUnusedTaxiTimer = CTimer::GetTimeInMilliseconds();
-
- // The effect that makes money counter does while earning/losing money
- if (m_nVisibleMoney != m_nMoney) {
- int diff = m_nMoney - m_nVisibleMoney;
- int diffAbs = Abs(diff);
- int changeBy;
-
- if (diffAbs > 100000)
- changeBy = 12345;
- else if (diffAbs > 10000)
- changeBy = 1234;
- else if (diffAbs > 1000)
- changeBy = 123;
- else if (diffAbs > 50)
- changeBy = 42;
- else
- changeBy = 1;
-
- if (diff < 0)
- m_nVisibleMoney -= changeBy;
- else
- m_nVisibleMoney += changeBy;
- }
-
- if (!(CTimer::GetFrameCounter() & 15)) {
- CVector2D playerPos = m_pPed->bInVehicle ? m_pPed->m_pMyVehicle->GetPosition() : m_pPed->GetPosition();
- m_fRoadDensity = ThePaths.CalcRoadDensity(playerPos.x, playerPos.y);
- }
-
- m_fRoadDensity = clamp(m_fRoadDensity, 0.4f, 1.45f);
-
- // Because vehicle enter/exit use same key binding.
- bool enterOrExitVeh;
- if (m_pPed->bVehExitWillBeInstant && m_pPed->bInVehicle)
- enterOrExitVeh = CPad::GetPad(0)->ExitVehicleJustDown();
- else
- enterOrExitVeh = CPad::GetPad(0)->GetExitVehicle();
-
- if (enterOrExitVeh && m_pPed->m_nPedState != PED_SNIPER_MODE && m_pPed->m_nPedState != PED_ROCKET_ODE) {
- if (m_pPed->bInVehicle) {
- if (!m_pRemoteVehicle) {
- CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity;
- if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->m_modelIndex)) {
- CVehicle *veh = m_pPed->m_pMyVehicle;
- if (!veh->IsBoat() || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
-
- // This condition will always return true, else block was probably WIP Miami code.
- if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
- if (veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
- if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) {
- m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
- }
- }
- } else {
- CVector sth = 0.7f * veh->GetRight() + veh->GetPosition();
- bool found = false;
- float groundZ = CWorld::FindGroundZFor3DCoord(sth.x, sth.y, 2.0f + sth.z, &found);
-
- if (found)
- sth.z = 1.0f + groundZ;
- m_pPed->m_nPedState = PED_IDLE;
- m_pPed->SetMoveState(PEDMOVE_STILL);
- CPed::PedSetOutCarCB(0, m_pPed);
- CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
- CAnimManager::BlendAnimation(m_pPed->GetClump(), ASSOCGRP_STD, ANIM_FALL_LAND, 100.0f);
- m_pPed->GetPosition() = sth;
- m_pPed->SetMoveState(PEDMOVE_STILL);
- m_pPed->m_vecMoveSpeed = veh->m_vecMoveSpeed;
- }
- } else {
- // The code in here was under CPed::SetExitBoat in VC, did the same for here.
- m_pPed->SetExitBoat(veh);
- m_pPed->bTryingToReachDryLand = true;
- }
- }
- }
- } else {
- // Enter vehicle
- if (CPad::GetPad(0)->ExitVehicleJustDown()) {
- bool weAreOnBoat = false;
- float lastCloseness = 0.0f;
- CVehicle *carBelow = nil;
- CEntity *surfaceBelow = m_pPed->m_pCurrentPhysSurface;
- if (surfaceBelow && surfaceBelow->IsVehicle()) {
- carBelow = (CVehicle*)surfaceBelow;
- if (carBelow->IsBoat()) {
- weAreOnBoat = true;
- m_pPed->bOnBoat = true;
-#ifdef VC_PED_PORTS
- if (carBelow->m_status != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
-#else
- if (carBelow->m_status != STATUS_WRECKED)
-#endif
- m_pPed->SetSeekBoatPosition(carBelow);
- }
- }
- // Find closest car
- if (!weAreOnBoat) {
- float minX = m_pPed->GetPosition().x - 10.0f;
- float maxX = 10.0f + m_pPed->GetPosition().x;
- float minY = m_pPed->GetPosition().y - 10.0f;
- float maxY = 10.0f + m_pPed->GetPosition().y;
-
- int minXSector = CWorld::GetSectorIndexX(minX);
- if (minXSector < 0) minXSector = 0;
- int minYSector = CWorld::GetSectorIndexY(minY);
- if (minYSector < 0) minYSector = 0;
- int maxXSector = CWorld::GetSectorIndexX(maxX);
- if (maxXSector > NUMSECTORS_X - 1) maxXSector = NUMSECTORS_X - 1;
- int maxYSector = CWorld::GetSectorIndexY(maxY);
- if (maxYSector > NUMSECTORS_Y - 1) maxYSector = NUMSECTORS_Y - 1;
-
- CWorld::AdvanceCurrentScanCode();
-
- for (int curY = minYSector; curY <= maxYSector; curY++) {
- for (int curX = minXSector; curX <= maxXSector; curX++) {
- CSector *sector = CWorld::GetSector(curX, curY);
- FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES], m_pPed,
- minX, minY, maxX, maxY, &lastCloseness, &carBelow);
- FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], m_pPed,
- minX, minY, maxX, maxY, &lastCloseness, &carBelow);
- }
- }
- }
- // carBelow is now closest vehicle
- if (carBelow && !weAreOnBoat) {
- if (carBelow->m_status == STATUS_TRAIN_NOT_MOVING) {
- m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
- } else if (carBelow->IsBoat()) {
- if (!carBelow->pDriver) {
- m_pPed->m_vehEnterType = 0;
- m_pPed->SetEnterCar(carBelow, m_pPed->m_vehEnterType);
- }
- } else {
- m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, carBelow);
- }
- }
- }
- }
- }
- if (m_bInRemoteMode) {
- uint32 timeWithoutRemoteCar = CTimer::GetTimeInMilliseconds() - m_nTimeLostRemoteCar;
- if (CTimer::GetPreviousTimeInMilliseconds() - m_nTimeLostRemoteCar < 1000 && timeWithoutRemoteCar >= 1000 && m_WBState == WBSTATE_PLAYING) {
- TheCamera.SetFadeColour(0, 0, 0);
- TheCamera.Fade(1.0f, 0);
- }
- if (timeWithoutRemoteCar > 2000) {
- if (m_WBState == WBSTATE_PLAYING) {
- TheCamera.RestoreWithJumpCut();
- TheCamera.SetFadeColour(0, 0, 0);
- TheCamera.Fade(1.0f, 1);
- TheCamera.Process();
- CTimer::Stop();
- CCullZones::ForceCullZoneCoors(TheCamera.GetPosition());
- CRenderer::RequestObjectsInFrustum();
- CStreaming::LoadAllRequestedModels(false);
- CTimer::Update();
- }
- m_bInRemoteMode = false;
- CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = nil;
- if (FindPlayerVehicle()) {
- FindPlayerVehicle()->m_status = STATUS_PLAYER;
- }
- }
- }
- if (!(CTimer::GetFrameCounter() & 31)) {
- CVehicle *veh = FindPlayerVehicle();
- if (veh && m_pPed->bInVehicle && veh->GetUp().z < 0.0f
- && veh->m_vecMoveSpeed.Magnitude() < 0.05f && veh->IsCar() && !veh->bIsInWater) {
-
- if (veh->GetUp().z < -0.5f) {
- m_nUpsideDownCounter += 2;
-
- } else {
- m_nUpsideDownCounter++;
- }
- } else {
- m_nUpsideDownCounter = 0;
- }
-
- if (m_nUpsideDownCounter > 6 && veh->bCanBeDamaged) {
- veh->m_fHealth = 249.0f < veh->m_fHealth ? 249.0f : veh->m_fHealth;
- if (veh->IsCar()) {
- CAutomobile* car = (CAutomobile*)veh;
- car->Damage.SetEngineStatus(225);
- car->m_pSetOnFireEntity = nil;
- }
- }
- }
- if (FindPlayerVehicle()) {
- CVehicle *veh = FindPlayerVehicle();
- veh->m_nZoneLevel = -1;
- for (int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) {
- if (veh->pPassengers[i])
- veh->pPassengers[i]->m_nZoneLevel = 0;
- }
- CStats::DistanceTravelledInVehicle += veh->m_fDistanceTravelled;
- } else {
- CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled;
- }
+void
+CPlayerInfo::Process(void)
+{
+ // Unused taxi feature. Gives you a dollar for every second with a passenger. Can be toggled via 0x29A opcode.
+ bool startTaxiTimer = true;
+ if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
+ CVehicle *veh = m_pPed->m_pMyVehicle;
+ if ((veh->m_modelIndex == MI_TAXI || veh->m_modelIndex == MI_CABBIE || veh->m_modelIndex == MI_BORGNINE)
+ && veh->pDriver == m_pPed && veh->m_nNumPassengers != 0) {
+ for (uint32 timePassed = CTimer::GetTimeInMilliseconds() - m_nUnusedTaxiTimer; timePassed >= 1000; m_nUnusedTaxiTimer += 1000) {
+ timePassed -= 1000;
+ ++m_nMoney;
+ }
+ startTaxiTimer = false;
+ }
+ }
+ if (startTaxiTimer)
+ m_nUnusedTaxiTimer = CTimer::GetTimeInMilliseconds();
+
+ // The effect that makes money counter does while earning/losing money
+ if (m_nVisibleMoney != m_nMoney) {
+ int diff = m_nMoney - m_nVisibleMoney;
+ int diffAbs = Abs(diff);
+ int changeBy;
+
+ if (diffAbs > 100000)
+ changeBy = 12345;
+ else if (diffAbs > 10000)
+ changeBy = 1234;
+ else if (diffAbs > 1000)
+ changeBy = 123;
+ else if (diffAbs > 50)
+ changeBy = 42;
+ else
+ changeBy = 1;
+
+ if (diff < 0)
+ m_nVisibleMoney -= changeBy;
+ else
+ m_nVisibleMoney += changeBy;
+ }
+
+ if (!(CTimer::GetFrameCounter() & 15)) {
+ CVector2D playerPos = m_pPed->bInVehicle ? m_pPed->m_pMyVehicle->GetPosition() : m_pPed->GetPosition();
+ m_fRoadDensity = ThePaths.CalcRoadDensity(playerPos.x, playerPos.y);
+ }
+
+ m_fRoadDensity = clamp(m_fRoadDensity, 0.4f, 1.45f);
+
+ // Because vehicle enter/exit use same key binding.
+ bool enterOrExitVeh;
+ if (m_pPed->bVehExitWillBeInstant && m_pPed->bInVehicle)
+ enterOrExitVeh = CPad::GetPad(0)->ExitVehicleJustDown();
+ else
+ enterOrExitVeh = CPad::GetPad(0)->GetExitVehicle();
+
+ if (enterOrExitVeh && m_pPed->m_nPedState != PED_SNIPER_MODE && m_pPed->m_nPedState != PED_ROCKET_ODE) {
+ if (m_pPed->bInVehicle) {
+ if (!m_pRemoteVehicle) {
+ CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity;
+ if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->m_modelIndex)) {
+ CVehicle *veh = m_pPed->m_pMyVehicle;
+ if (!veh->IsBoat() || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
+
+ // This condition will always return true, else block was probably WIP Miami code.
+ if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
+ if (veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
+ if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) {
+ m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
+ }
+ }
+ } else {
+ CVector sth = 0.7f * veh->GetRight() + veh->GetPosition();
+ bool found = false;
+ float groundZ = CWorld::FindGroundZFor3DCoord(sth.x, sth.y, 2.0f + sth.z, &found);
+
+ if (found)
+ sth.z = 1.0f + groundZ;
+ m_pPed->m_nPedState = PED_IDLE;
+ m_pPed->SetMoveState(PEDMOVE_STILL);
+ CPed::PedSetOutCarCB(0, m_pPed);
+ CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
+ CAnimManager::BlendAnimation(m_pPed->GetClump(), ASSOCGRP_STD, ANIM_FALL_LAND, 100.0f);
+ m_pPed->GetPosition() = sth;
+ m_pPed->SetMoveState(PEDMOVE_STILL);
+ m_pPed->m_vecMoveSpeed = veh->m_vecMoveSpeed;
+ }
+ } else {
+ // The code in here was under CPed::SetExitBoat in VC, did the same for here.
+ m_pPed->SetExitBoat(veh);
+ m_pPed->bTryingToReachDryLand = true;
+ }
+ }
+ }
+ } else {
+ // Enter vehicle
+ if (CPad::GetPad(0)->ExitVehicleJustDown()) {
+ bool weAreOnBoat = false;
+ float lastCloseness = 0.0f;
+ CVehicle *carBelow = nil;
+ CEntity *surfaceBelow = m_pPed->m_pCurrentPhysSurface;
+ if (surfaceBelow && surfaceBelow->IsVehicle()) {
+ carBelow = (CVehicle*)surfaceBelow;
+ if (carBelow->IsBoat()) {
+ weAreOnBoat = true;
+ m_pPed->bOnBoat = true;
+#ifdef VC_PED_PORTS
+ if (carBelow->m_status != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
+#else
+ if (carBelow->m_status != STATUS_WRECKED)
+#endif
+ m_pPed->SetSeekBoatPosition(carBelow);
+ }
+ }
+ // Find closest car
+ if (!weAreOnBoat) {
+ float minX = m_pPed->GetPosition().x - 10.0f;
+ float maxX = 10.0f + m_pPed->GetPosition().x;
+ float minY = m_pPed->GetPosition().y - 10.0f;
+ float maxY = 10.0f + m_pPed->GetPosition().y;
+
+ int minXSector = CWorld::GetSectorIndexX(minX);
+ if (minXSector < 0) minXSector = 0;
+ int minYSector = CWorld::GetSectorIndexY(minY);
+ if (minYSector < 0) minYSector = 0;
+ int maxXSector = CWorld::GetSectorIndexX(maxX);
+ if (maxXSector > NUMSECTORS_X - 1) maxXSector = NUMSECTORS_X - 1;
+ int maxYSector = CWorld::GetSectorIndexY(maxY);
+ if (maxYSector > NUMSECTORS_Y - 1) maxYSector = NUMSECTORS_Y - 1;
+
+ CWorld::AdvanceCurrentScanCode();
+
+ for (int curY = minYSector; curY <= maxYSector; curY++) {
+ for (int curX = minXSector; curX <= maxXSector; curX++) {
+ CSector *sector = CWorld::GetSector(curX, curY);
+ FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES], m_pPed,
+ minX, minY, maxX, maxY, &lastCloseness, &carBelow);
+ FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], m_pPed,
+ minX, minY, maxX, maxY, &lastCloseness, &carBelow);
+ }
+ }
+ }
+ // carBelow is now closest vehicle
+ if (carBelow && !weAreOnBoat) {
+ if (carBelow->m_status == STATUS_TRAIN_NOT_MOVING) {
+ m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
+ } else if (carBelow->IsBoat()) {
+ if (!carBelow->pDriver) {
+ m_pPed->m_vehEnterType = 0;
+ m_pPed->SetEnterCar(carBelow, m_pPed->m_vehEnterType);
+ }
+ } else {
+ m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, carBelow);
+ }
+ }
+ }
+ }
+ }
+ if (m_bInRemoteMode) {
+ uint32 timeWithoutRemoteCar = CTimer::GetTimeInMilliseconds() - m_nTimeLostRemoteCar;
+ if (CTimer::GetPreviousTimeInMilliseconds() - m_nTimeLostRemoteCar < 1000 && timeWithoutRemoteCar >= 1000 && m_WBState == WBSTATE_PLAYING) {
+ TheCamera.SetFadeColour(0, 0, 0);
+ TheCamera.Fade(1.0f, 0);
+ }
+ if (timeWithoutRemoteCar > 2000) {
+ if (m_WBState == WBSTATE_PLAYING) {
+ TheCamera.RestoreWithJumpCut();
+ TheCamera.SetFadeColour(0, 0, 0);
+ TheCamera.Fade(1.0f, 1);
+ TheCamera.Process();
+ CTimer::Stop();
+ CCullZones::ForceCullZoneCoors(TheCamera.GetPosition());
+ CRenderer::RequestObjectsInFrustum();
+ CStreaming::LoadAllRequestedModels(false);
+ CTimer::Update();
+ }
+ m_bInRemoteMode = false;
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = nil;
+ if (FindPlayerVehicle()) {
+ FindPlayerVehicle()->m_status = STATUS_PLAYER;
+ }
+ }
+ }
+ if (!(CTimer::GetFrameCounter() & 31)) {
+ CVehicle *veh = FindPlayerVehicle();
+ if (veh && m_pPed->bInVehicle && veh->GetUp().z < 0.0f
+ && veh->m_vecMoveSpeed.Magnitude() < 0.05f && veh->IsCar() && !veh->bIsInWater) {
+
+ if (veh->GetUp().z < -0.5f) {
+ m_nUpsideDownCounter += 2;
+
+ } else {
+ m_nUpsideDownCounter++;
+ }
+ } else {
+ m_nUpsideDownCounter = 0;
+ }
+
+ if (m_nUpsideDownCounter > 6 && veh->bCanBeDamaged) {
+ veh->m_fHealth = 249.0f < veh->m_fHealth ? 249.0f : veh->m_fHealth;
+ if (veh->IsCar()) {
+ CAutomobile* car = (CAutomobile*)veh;
+ car->Damage.SetEngineStatus(225);
+ car->m_pSetOnFireEntity = nil;
+ }
+ }
+ }
+ if (FindPlayerVehicle()) {
+ CVehicle *veh = FindPlayerVehicle();
+ veh->m_nZoneLevel = -1;
+ for (int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) {
+ if (veh->pPassengers[i])
+ veh->pPassengers[i]->m_nZoneLevel = 0;
+ }
+ CStats::DistanceTravelledInVehicle += veh->m_fDistanceTravelled;
+ } else {
+ CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled;
+ }
}
STARTPATCHES
diff --git a/src/core/PlayerSkin.cpp b/src/core/PlayerSkin.cpp
deleted file mode 100644
index bf780666..00000000
--- a/src/core/PlayerSkin.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-#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"
-
-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 (strcasecmp("player.dff", info.name) != 0);
-
- offset = info.offset;
- size = info.size;
-}
-
-void
-LoadPlayerDff(void)
-{
- RwStream *stream;
- RwMemory mem;
- uint32 offset, size;
- uint8 *buffer;
- bool streamWasAdded = false;
-
- if (CdStreamGetNumImages() == 0) {
- 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) == 0)
- 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 };
- 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
deleted file mode 100644
index 2d82ec12..00000000
--- a/src/core/PlayerSkin.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#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 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
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 07ddb5d8..994c94ca 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -1,1504 +1,1506 @@
-#include "config.h"
-#include "common.h"
-#include "patcher.h"
-#include "RwHelper.h"
-#include "Radar.h"
-#include "Camera.h"
-#include "Hud.h"
-#include "World.h"
-#include "Frontend.h"
-#include "General.h"
-#include "Vehicle.h"
-#include "Pools.h"
-#include "Script.h"
-#include "TxdStore.h"
-#include "World.h"
-#include "Streaming.h"
-#include "SpecialFX.h"
-
-float &CRadar::m_radarRange = *(float*)0x8E281C;
-CBlip (&CRadar::ms_RadarTrace)[NUMRADARBLIPS] = *(CBlip(*)[NUMRADARBLIPS]) * (uintptr*)0x6ED5E0;
-CVector2D &vec2DRadarOrigin = *(CVector2D*)0x6299B8;
-int32 gRadarTxdIds[64];// = (int*)0x6299C0;
-
-CSprite2d CRadar::AsukaSprite;// = *(CSprite2d*)0x8F1A40;
-CSprite2d CRadar::BombSprite;// = (CSprite2d*)0x8F5FB4;
-CSprite2d CRadar::CatSprite;// = (CSprite2d*)0x885B24;
-CSprite2d CRadar::CentreSprite;// = (CSprite2d*)0x8F6268;
-CSprite2d CRadar::CopcarSprite;// = (CSprite2d*)0x8F1A2C;
-CSprite2d CRadar::DonSprite;// = (CSprite2d*)0x8F2BE0;
-CSprite2d CRadar::EightSprite;// = (CSprite2d*)0x8F2BCC;
-CSprite2d CRadar::ElSprite;// = (CSprite2d*)0x8F1B80;
-CSprite2d CRadar::IceSprite;// = (CSprite2d*)0x9415FC;
-CSprite2d CRadar::JoeySprite;// = (CSprite2d*)0x8F2C00;
-CSprite2d CRadar::KenjiSprite;// = (CSprite2d*)0x8F2C68;
-CSprite2d CRadar::LizSprite;// = (CSprite2d*)0x8F5830;
-CSprite2d CRadar::LuigiSprite;// = (CSprite2d*)0x8F1A3C;
-CSprite2d CRadar::NorthSprite;// = (CSprite2d*)0x8F6274;
-CSprite2d CRadar::RaySprite;// = (CSprite2d*)0x8E2A7C;
-CSprite2d CRadar::SalSprite;// = (CSprite2d*)0x8F29EC;
-CSprite2d CRadar::SaveSprite;// = (CSprite2d*)0x8F5F74;
-CSprite2d CRadar::SpraySprite;// = (CSprite2d*)0x94307C;
-CSprite2d CRadar::TonySprite;// = (CSprite2d*)0x885B58;
-CSprite2d CRadar::WeaponSprite;// = (CSprite2d*)0x941534;
-
-CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
- nil,
- &AsukaSprite,
- &BombSprite,
- &CatSprite,
- &CentreSprite,
- &CopcarSprite,
- &DonSprite,
- &EightSprite,
- &ElSprite,
- &IceSprite,
- &JoeySprite,
- &KenjiSprite,
- &LizSprite,
- &LuigiSprite,
- &NorthSprite,
- &RaySprite,
- &SalSprite,
- &SaveSprite,
- &SpraySprite,
- &TonySprite,
- &WeaponSprite
-};
-
-#define RADAR_NUM_TILES (8)
-#define RADAR_TILE_SIZE (WORLD_SIZE_X / RADAR_NUM_TILES)
-static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
-
-#define RADAR_MIN_RANGE (120.0f)
-#define RADAR_MAX_RANGE (350.0f)
-#define RADAR_MIN_SPEED (0.3f)
-#define RADAR_MAX_SPEED (0.9f)
-
-#ifdef MENU_MAP
-CRGBA CRadar::ArrowBlipColour1;
-CRGBA CRadar::ArrowBlipColour2;
-uint16 CRadar::MapLegendCounter;
-uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS];
-int CRadar::TargetMarkerId = -1;
-#endif
-
-// taken from VC
-float CRadar::cachedCos;
-float CRadar::cachedSin;
-
-uint8 CRadar::CalculateBlipAlpha(float dist)
-{
-#ifdef MENU_MAP
- if (CMenuManager::bMenuMapActive)
- return 255;
-#endif
- if (dist <= 1.0f)
- return 255;
-
- if (dist <= 5.0f)
- return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f);
-
- return 128;
-}
-
-void CRadar::ChangeBlipBrightness(int32 i, int32 bright)
-{
- int index = GetActualBlipArrayIndex(i);
- if (index != -1)
- ms_RadarTrace[index].m_bDim = bright != 1;
-}
-
-void CRadar::ChangeBlipColour(int32 i, int32 color)
-{
- int index = GetActualBlipArrayIndex(i);
- if (index != -1)
- ms_RadarTrace[index].m_nColor = color;
-}
-
-void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display)
-{
- int index = GetActualBlipArrayIndex(i);
- if (index != -1)
- ms_RadarTrace[index].m_eBlipDisplay = display;
-}
-
-void CRadar::ChangeBlipScale(int32 i, int32 scale)
-{
- int index = GetActualBlipArrayIndex(i);
- if (index != -1)
- ms_RadarTrace[index].m_wScale = scale;
-}
-
-void CRadar::ClearBlip(int32 i)
-{
- int index = GetActualBlipArrayIndex(i);
- if (index != -1) {
- SetRadarMarkerState(index, false);
- ms_RadarTrace[index].m_bInUse = false;
-#ifndef MENU_MAP
- // Ssshhh
- ms_RadarTrace[index].m_eBlipType = BLIP_NONE;
- ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
- ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE;
-#endif
- }
-}
-
-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, 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_eRadarSprite = RADAR_SPRITE_NONE;
- }
- };
-}
-
-// Why not a proper clipping algorithm?
-int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
-{
- CVector2D corners[4] = {
- { 1.0f, -1.0f }, // top right
- { 1.0f, 1.0f }, // bottom right
- { -1.0f, 1.0f }, // bottom left
- { -1.0f, -1.0f }, // top left
- };
- CVector2D tmp;
- int i, j, n;
- int laste, e, e1, e2;;
- bool inside[4];
-
- for (i = 0; i < 4; i++)
- inside[i] = IsPointInsideRadar(rect[i]);
-
- laste = -1;
- n = 0;
- for (i = 0; i < 4; i++)
- if (inside[i]) {
- // point is inside, just add
- poly[n++] = rect[i];
- }
- else {
- // point is outside but line to this point might be clipped
- e1 = LineRadarBoxCollision(poly[n], rect[i], rect[(i + 4 - 1) % 4]);
- if (e1 != -1) {
- laste = e1;
- n++;
- }
- // and line from this point might be clipped as well
- e2 = LineRadarBoxCollision(poly[n], rect[i], rect[(i + 1) % 4]);
- if (e2 != -1) {
- if (e1 == -1) {
- // if other line wasn't clipped, i.e. it was complete outside,
- // we may have to insert another vertex if last clipped line
- // was on a different edge
-
- // find the last intersection if we haven't seen it yet
- if (laste == -1)
- for (j = 3; j >= i; j--) {
- // game uses an if here for j == 0
- e = LineRadarBoxCollision(tmp, rect[j], rect[(j + 4 - 1) % 4]);
- if (e != -1) {
- laste = e;
- break;
- }
- }
- assert(laste != -1);
-
- // insert corners that were skipped
- tmp = poly[n];
- for (e = laste; e != e2; e = (e + 1) % 4)
- poly[n++] = corners[e];
- poly[n] = tmp;
- }
- n++;
- }
- }
-
- if (n == 0) {
- // If no points, either the rectangle is completely outside or completely surrounds the radar
- // no idea what's going on here...
- float m = (rect[0].y - rect[1].y) / (rect[0].x - rect[1].x);
- if ((m*rect[3].x - rect[3].y) * (m*rect[0].x - rect[0].y) < 0.0f) {
- m = (rect[0].y - rect[3].y) / (rect[0].x - rect[3].x);
- if ((m*rect[1].x - rect[1].y) * (m*rect[0].x - rect[0].y) < 0.0f) {
- poly[0] = corners[0];
- poly[1] = corners[1];
- poly[2] = corners[2];
- poly[3] = corners[3];
- n = 4;
- }
- }
- }
-
- return n;
-}
-
-bool CRadar::DisplayThisBlip(int32 counter)
-{
- switch (ms_RadarTrace[counter].m_eRadarSprite) {
- case RADAR_SPRITE_BOMB:
- case RADAR_SPRITE_SPRAY:
- case RADAR_SPRITE_WEAPON:
- return true;
- default:
- return false;
- }
-}
-
-void CRadar::Draw3dMarkers()
-{
- for (int i = 0; i < NUMRADARBLIPS; i++) {
- if (ms_RadarTrace[i].m_bInUse) {
- switch (ms_RadarTrace[i].m_eBlipType) {
- case BLIP_CAR:
- {
- CEntity *entity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
- if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
- CVector pos = entity->GetPosition();
- pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f;
- C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
- }
- break;
- }
- case BLIP_CHAR:
- {
- CEntity *entity = CPools::GetPedPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
- if (entity != nil) {
- if (((CPed*)entity)->InVehicle())
- entity = ((CPed * )entity)->m_pMyVehicle;
- }
- if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
- CVector pos = entity->GetPosition();
- pos.z += 3.0f;
- C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
- }
- break;
- }
- case BLIP_OBJECT:
- {
- CEntity *entity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
- if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
- CVector pos = entity->GetPosition();
- pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f;
- C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, 0, 128, 255, 255, 1024, 0.2f, 5);
- }
- break;
- }
- case BLIP_COORD:
- break;
- case BLIP_CONTACT_POINT:
- if (!CTheScripts::IsPlayerOnAMission()) {
- if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY)
- C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, 0, 128, 255, 128, 2048, 0.2f, 0);
- }
- break;
- }
- }
- }
-}
-
-void CRadar::DrawBlips()
-{
- if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
- RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
- RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
-
- CVector2D out;
- CVector2D in = CVector2D(0.0f, 0.0f);
- TransformRadarPointToScreenSpace(out, in);
-
-#ifdef MENU_MAP
- if (!CMenuManager::bMenuMapActive) {
-#endif
- float angle;
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN)
- 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());
-
- DrawRotatingRadarSprite(&CentreSprite, out.x, out.y, angle, 255);
-
- CVector2D vec2d;
- vec2d.x = vec2DRadarOrigin.x;
- vec2d.y = M_SQRT2 * m_radarRange + vec2DRadarOrigin.y;
- TransformRealWorldPointToRadarSpace(in, vec2d);
- LimitRadarPoint(in);
- TransformRadarPointToScreenSpace(out, in);
- DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255);
-#ifdef MENU_MAP
- }
-#endif
-
- CEntity *blipEntity = nil;
- for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) {
-#ifdef MENU_MAP
- // A little hack to reuse cleared blips in menu map. hehe
- if (!CMenuManager::bMenuMapActive || ms_RadarTrace[blipId].m_eBlipType == BLIP_CAR ||
- ms_RadarTrace[blipId].m_eBlipType == BLIP_CHAR || ms_RadarTrace[blipId].m_eBlipType == BLIP_OBJECT)
-#endif
- 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_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
- || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == 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 != nil) {
- if (((CPed*)blipEntity)->InVehicle())
- 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::IsDebugOn()) {
- 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_eRadarSprite != RADAR_SPRITE_NONE) {
- DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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
- }
- }
- }
- }
- break;
- case BLIP_COORD:
- case BLIP_CONTACT_POINT:
- if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
- || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == 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::IsDebugOn()) {
- 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[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);
- TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
- DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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;
- 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_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
- && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != 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 != nil) {
- if (((CPed*)blipEntity)->InVehicle())
- 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::IsDebugOn()) {
- 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_eRadarSprite != RADAR_SPRITE_NONE)
- DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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
- }
- }
- }
- 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_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
- && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != 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::IsDebugOn()) {
- 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[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);
- TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
- DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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;
- default:
- break;
- }
- }
-#ifdef MENU_MAP
- if (CMenuManager::bMenuMapActive) {
- CVector2D in, out;
- TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift());
- TransformRadarPointToScreenSpace(out, in);
- DrawYouAreHereSprite(out.x, out.y);
- }
-#endif
- }
-}
-
-void CRadar::DrawMap()
-{
- if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
-#if 1 // from VC
- CalculateCachedSinCos();
-#endif
- if (FindPlayerVehicle()) {
- float speed = FindPlayerSpeed().Magnitude();
- if (speed < RADAR_MIN_SPEED)
- m_radarRange = RADAR_MIN_RANGE;
- else if (speed < RADAR_MAX_SPEED)
- m_radarRange = (speed - RADAR_MIN_SPEED)/(RADAR_MAX_SPEED-RADAR_MIN_SPEED) * (RADAR_MAX_RANGE-RADAR_MIN_RANGE) + RADAR_MIN_RANGE;
- else
- m_radarRange = RADAR_MAX_RANGE;
- }
- else
- m_radarRange = RADAR_MIN_RANGE;
-
- vec2DRadarOrigin = CVector2D(FindPlayerCentreOfWorld_NoSniperShift());
- DrawRadarMap();
- }
-}
-
-void CRadar::DrawRadarMap()
-{
- // Game calculates an unused CRect here
-
- DrawRadarMask();
-
- // top left ist (0, 0)
- int x = floorf((vec2DRadarOrigin.x - WORLD_MIN_X) / RADAR_TILE_SIZE);
- int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - WORLD_MIN_Y) / RADAR_TILE_SIZE);
- StreamRadarSections(x, y);
-
- RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
- RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
- RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
- RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
- RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
- RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void*)FALSE);
-
- DrawRadarSection(x - 1, y - 1);
- DrawRadarSection(x, y - 1);
- DrawRadarSection(x + 1, y - 1);
- DrawRadarSection(x - 1, y);
- DrawRadarSection(x, y);
- DrawRadarSection(x + 1, y);
- DrawRadarSection(x - 1, y + 1);
- DrawRadarSection(x, y + 1);
- DrawRadarSection(x + 1, y + 1);
-}
-
-void CRadar::DrawRadarMask()
-{
- CVector2D corners[4] = {
- CVector2D(1.0f, -1.0f),
- CVector2D(1.0f, 1.0f),
- CVector2D(-1.0f, 1.0f),
- CVector2D(-1.0, -1.0f)
- };
-
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
- RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
- RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
- RwD3D8SetRenderState(rwRENDERSTATESTENCILFUNCTION, rwSTENCILFUNCTIONALWAYS);
-
- CVector2D out[8];
- CVector2D in;
-
- // Draw the shape we want to mask out from the radar in four segments
- for (int i = 0; i < 4; i++) {
- // First point is always the corner itself
- in.x = corners[i].x;
- in.y = corners[i].y;
- TransformRadarPointToScreenSpace(out[0], in);
-
- // Then generate a quarter of the circle
- for (int j = 0; j < 7; j++) {
- in.x = corners[i].x * Cos(j * (PI / 2.0f / 6.0f));
- in.y = corners[i].y * Sin(j * (PI / 2.0f / 6.0f));
- TransformRadarPointToScreenSpace(out[j + 1], in);
- };
-
- CSprite2d::SetMaskVertices(8, (float *)out);
- RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8);
- };
-
- RwD3D8SetRenderState(rwRENDERSTATESTENCILFUNCTION, rwSTENCILFUNCTIONGREATER);
-}
-
-void CRadar::DrawRadarSection(int32 x, int32 y)
-{
- int i;
- RwTexDictionary *txd;
- CVector2D worldPoly[8];
- CVector2D radarCorners[4];
- CVector2D radarPoly[8];
- CVector2D texCoords[8];
- CVector2D screenPoly[8];
- int numVertices;
- RwTexture *texture = nil;
-
- GetTextureCorners(x, y, worldPoly);
- ClipRadarTileCoords(x, y);
-
- assert(CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y]));
- txd = CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y])->texDict;
- if (txd)
- texture = GetFirstTexture(txd);
- if (texture == nil)
- return;
-
- for (i = 0; i < 4; i++)
- TransformRealWorldPointToRadarSpace(radarCorners[i], worldPoly[i]);
-
- numVertices = ClipRadarPoly(radarPoly, radarCorners);
-
- // FIX: can return earlier here
-// if(numVertices == 0)
- if (numVertices < 3)
- return;
-
- for (i = 0; i < numVertices; i++) {
- TransformRadarPointToRealWorldSpace(worldPoly[i], radarPoly[i]);
- TransformRealWorldToTexCoordSpace(texCoords[i], worldPoly[i], x, y);
- TransformRadarPointToScreenSpace(screenPoly[i], radarPoly[i]);
- }
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(texture));
- CSprite2d::SetVertices(numVertices, (float*)screenPoly, (float*)texCoords, CRGBA(255, 255, 255, 255));
- // check done above now
-// if(numVertices > 2)
- RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), numVertices);
-}
-
-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));
-#ifdef MENU_MAP
- if (CMenuManager::bMenuMapActive) {
- bool alreadyThere = false;
- for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
- if (MapLegendList[i] == sprite)
- alreadyThere = true;
- }
- if (!alreadyThere) {
- MapLegendList[MapLegendCounter] = sprite;
- MapLegendCounter++;
- }
- }
-#endif
-}
-
-void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha)
-{
- CVector curPosn[4];
- CVector oldPosn[4];
-
- curPosn[0].x = x - SCREEN_SCALE_X(5.6f);
- curPosn[0].y = y + SCREEN_SCALE_Y(5.6f);
-
- curPosn[1].x = x + SCREEN_SCALE_X(5.6f);
- curPosn[1].y = y + SCREEN_SCALE_Y(5.6f);
-
- curPosn[2].x = x - SCREEN_SCALE_X(5.6f);
- curPosn[2].y = y - SCREEN_SCALE_Y(5.6f);
-
- curPosn[3].x = x + SCREEN_SCALE_X(5.6f);
- curPosn[3].y = y - SCREEN_SCALE_Y(5.6f);
-
- for (uint32 i = 0; i < 4; i++) {
- oldPosn[i] = curPosn[i];
-
- curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle);
- curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle);
- }
-
- sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
-}
-
-int32 CRadar::GetActualBlipArrayIndex(int32 i)
-{
- if (i == -1)
- return -1;
- else if ((i & 0xFFFF0000) >> 16 != ms_RadarTrace[(uint16)i].m_BlipIndex)
- return -1;
- else
- return (uint16)i;
-}
-
-int32 CRadar::GetNewUniqueBlipIndex(int32 i)
-{
- if (ms_RadarTrace[i].m_BlipIndex >= UINT16_MAX - 1)
- ms_RadarTrace[i].m_BlipIndex = 1;
- else
- ms_RadarTrace[i].m_BlipIndex++;
- return i | (ms_RadarTrace[i].m_BlipIndex << 16);
-}
-
-uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
-{
- int32 c;
- switch (color) {
- case 0:
- if (bright)
- c = 0x712B49FF;
- else
- c = 0x7F0000FF;
- break;
- case 1:
- if (bright)
- c = 0x5FA06AFF;
- else
- c = 0x007F00FF;
- break;
- case 2:
- if (bright)
- c = 0x80A7F3FF;
- else
- c = 0x00007FFF;
- break;
- case 3:
- if (bright)
- c = 0xE1E1E1FF;
- else
- c = 0x7F7F7FFF;
- break;
- case 4:
- if (bright)
- c = 0xFFFF00FF;
- else
- c = 0x7F7F00FF;
- break;
- case 5:
- if (bright)
- c = 0xFF00FFFF;
- else
- c = 0x7F007FFF;
- break;
- case 6:
- if (bright)
- c = 0x00FFFFFF;
- else
- c = 0x007F7FFF;
- break;
- default:
- c = color;
- break;
- };
- return c;
-}
-
-const char* gRadarTexNames[] = {
- "radar00", "radar01", "radar02", "radar03", "radar04", "radar05", "radar06", "radar07",
- "radar08", "radar09", "radar10", "radar11", "radar12", "radar13", "radar14", "radar15",
- "radar16", "radar17", "radar18", "radar19", "radar20", "radar21", "radar22", "radar23",
- "radar24", "radar25", "radar26", "radar27", "radar28", "radar29", "radar30", "radar31",
- "radar32", "radar33", "radar34", "radar35", "radar36", "radar37", "radar38", "radar39",
- "radar40", "radar41", "radar42", "radar43", "radar44", "radar45", "radar46", "radar47",
- "radar48", "radar49", "radar50", "radar51", "radar52", "radar53", "radar54", "radar55",
- "radar56", "radar57", "radar58", "radar59", "radar60", "radar61", "radar62", "radar63",
-};
-
-void
-CRadar::Initialise()
-{
- for (int i = 0; i < NUMRADARBLIPS; i++) {
- ms_RadarTrace[i].m_BlipIndex = 1;
- 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_eRadarSprite = RADAR_SPRITE_NONE;
- }
-
- m_radarRange = 350.0f;
- for (int i = 0; i < 64; i++)
- gRadarTxdIds[i] = CTxdStore::FindTxdSlot(gRadarTexNames[i]);
-}
-
-float CRadar::LimitRadarPoint(CVector2D &point)
-{
- float dist, invdist;
-
- dist = point.Magnitude();
-#ifdef MENU_MAP
- if (CMenuManager::bMenuMapActive)
- return dist;
-#endif
- if (dist > 1.0f) {
- invdist = 1.0f / dist;
- point.x *= invdist;
- point.y *= invdist;
- }
- return dist;
-}
-
-void CRadar::LoadAllRadarBlips(uint8 *buf, uint32 size)
-{
- Initialise();
-INITSAVEBUF
- CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
-
- for (int i = 0; i < NUMRADARBLIPS; i++)
- ms_RadarTrace[i] = ReadSaveBuf<CBlip>(buf);
-
-VALIDATESAVEBUF(size);
-}
-
-void
-CRadar::LoadTextures()
-{
- CTxdStore::PushCurrentTxd();
- CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud"));
- AsukaSprite.SetTexture("radar_asuka");
- BombSprite.SetTexture("radar_bomb");
- CatSprite.SetTexture("radar_cat");
- CentreSprite.SetTexture("radar_centre");
- CopcarSprite.SetTexture("radar_copcar");
- DonSprite.SetTexture("radar_don");
- EightSprite.SetTexture("radar_eight");
- ElSprite.SetTexture("radar_el");
- IceSprite.SetTexture("radar_ice");
- JoeySprite.SetTexture("radar_joey");
- KenjiSprite.SetTexture("radar_kenji");
- LizSprite.SetTexture("radar_liz");
- LuigiSprite.SetTexture("radar_luigi");
- NorthSprite.SetTexture("radar_north");
- RaySprite.SetTexture("radar_ray");
- SalSprite.SetTexture("radar_sal");
- SaveSprite.SetTexture("radar_save");
- SpraySprite.SetTexture("radar_spray");
- TonySprite.SetTexture("radar_tony");
- WeaponSprite.SetTexture("radar_weapon");
- CTxdStore::PopCurrentTxd();
-}
-
-void RemoveMapSection(int32 x, int32 y)
-{
- if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
- CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
-}
-
-void CRadar::RemoveRadarSections()
-{
- for (int i = 0; i < 8; i++)
- for (int j = 0; j < 8; j++)
- RemoveMapSection(i, j);
-}
-
-void CRadar::RequestMapSection(int32 x, int32 y)
-{
- ClipRadarTileCoords(x, y);
- CStreaming::RequestTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y], STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY);
-}
-
-void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
-{
- *size = SAVE_HEADER_SIZE + sizeof(ms_RadarTrace);
-INITSAVEBUF
- WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
-
- for (int i = 0; i < NUMRADARBLIPS; i++)
- WriteSaveBuf(buf, ms_RadarTrace[i]);
-
-VALIDATESAVEBUF(*size);
-}
-
-void CRadar::SetBlipSprite(int32 i, int32 icon)
-{
- int index = CRadar::GetActualBlipArrayIndex(i);
- if (index != -1) {
- ms_RadarTrace[index].m_eRadarSprite = icon;
- }
-}
-
-int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display)
-{
- 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_eRadarSprite = RADAR_SPRITE_NONE;
- return CRadar::GetNewUniqueBlipIndex(nextBlip);
-}
-
-int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display)
-{
- 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_eRadarSprite = RADAR_SPRITE_NONE;
- return GetNewUniqueBlipIndex(nextBlip);
-}
-
-void CRadar::SetRadarMarkerState(int32 counter, bool flag)
-{
- CEntity *e;
- switch (ms_RadarTrace[counter].m_eBlipType) {
- case BLIP_CAR:
- e = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
- break;
- case BLIP_CHAR:
- e = CPools::GetPedPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
- break;
- case BLIP_OBJECT:
- e = CPools::GetObjectPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
- break;
- default:
- return;
- }
-
- if (e)
- e->bHasBlip = flag;
-}
-
-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;
- p2 = pos + TheCamera.GetUp()*f2;
- CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
-
- p1 = pos - TheCamera.GetUp()*f1;
- p2 = pos - TheCamera.GetUp()*f2;
- CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
-
- p1 = pos + TheCamera.GetRight()*f1;
- p2 = pos + TheCamera.GetRight()*f2;
- CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
-
- p1 = pos - TheCamera.GetRight()*f1;
- p2 = pos - TheCamera.GetRight()*f2;
- CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
-}
-
-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));
-}
-
-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;
- }
-#ifdef MENU_MAP
- // VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips
- if (CMenuManager::bMenuMapActive) {
- bool alreadyThere = false;
- for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
- if (MapLegendList[i] == -1)
- alreadyThere = true;
- }
- if (!alreadyThere) {
- MapLegendList[MapLegendCounter] = -1;
- MapLegendCounter++;
- ArrowBlipColour1 = CRGBA(red, green, blue, alpha);
- }
- }
-#endif
-}
-
-void CRadar::Shutdown()
-{
- AsukaSprite.Delete();
- BombSprite.Delete();
- CatSprite.Delete();
- CentreSprite.Delete();
- CopcarSprite.Delete();
- DonSprite.Delete();
- EightSprite.Delete();
- ElSprite.Delete();
- IceSprite.Delete();
- JoeySprite.Delete();
- KenjiSprite.Delete();
- LizSprite.Delete();
- LuigiSprite.Delete();
- NorthSprite.Delete();
- RaySprite.Delete();
- SalSprite.Delete();
- SaveSprite.Delete();
- SpraySprite.Delete();
- TonySprite.Delete();
- WeaponSprite.Delete();
- RemoveRadarSections();
-}
-
-void CRadar::StreamRadarSections(const CVector &posn)
-{
- StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f));
-}
-
-void CRadar::StreamRadarSections(int32 x, int32 y)
-{
- for (int i = 0; i < RADAR_NUM_TILES; ++i) {
- for (int j = 0; j < RADAR_NUM_TILES; ++j) {
- if ((i >= x - 1 && i <= x + 1) && (j >= y - 1 && j <= y + 1))
- RequestMapSection(i, j);
- else
- RemoveMapSection(i, j);
- };
- };
-}
-
-void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y)
-{
- out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X);
- out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + WORLD_MIN_Y));
- out.x /= RADAR_TILE_SIZE;
- out.y /= RADAR_TILE_SIZE;
-}
-
-void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in)
-{
- float s, c;
-#if 1
- s = -cachedSin;
- c = cachedCos;
-#else
- // Original code
-
- s = -Sin(TheCamera.GetForward().Heading());
- c = Cos(TheCamera.GetForward().Heading());
-
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) {
- s = 0.0f;
- c = 1.0f;
- }
- else if (TheCamera.GetLookDirection() != LOOKING_FORWARD) {
- CVector forward;
-
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
- forward.Normalise(); // a bit useless...
- }
- else
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
-
- s = -Sin(forward.Heading());
- c = Cos(forward.Heading());
- }
-#endif
-
- out.x = s * in.y + c * in.x;
- out.y = c * in.y - s * in.x;
-
- out = out * m_radarRange + vec2DRadarOrigin;
-}
-
-// Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0)
-void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
+#include "config.h"
+#include "common.h"
+#include "patcher.h"
+#include "RwHelper.h"
+#include "Radar.h"
+#include "Camera.h"
+#include "Hud.h"
+#include "World.h"
+#include "Frontend.h"
+#include "General.h"
+#include "Vehicle.h"
+#include "Pools.h"
+#include "Script.h"
+#include "TxdStore.h"
+#include "World.h"
+#include "Streaming.h"
+#include "SpecialFX.h"
+
+float &CRadar::m_radarRange = *(float*)0x8E281C;
+sRadarTrace (&CRadar::ms_RadarTrace)[NUMRADARBLIPS] = *(sRadarTrace(*)[NUMRADARBLIPS]) * (uintptr*)0x6ED5E0;
+CVector2D &vec2DRadarOrigin = *(CVector2D*)0x6299B8;
+int32 gRadarTxdIds[64];// = (int*)0x6299C0;
+
+CSprite2d CRadar::AsukaSprite;// = *(CSprite2d*)0x8F1A40;
+CSprite2d CRadar::BombSprite;// = (CSprite2d*)0x8F5FB4;
+CSprite2d CRadar::CatSprite;// = (CSprite2d*)0x885B24;
+CSprite2d CRadar::CentreSprite;// = (CSprite2d*)0x8F6268;
+CSprite2d CRadar::CopcarSprite;// = (CSprite2d*)0x8F1A2C;
+CSprite2d CRadar::DonSprite;// = (CSprite2d*)0x8F2BE0;
+CSprite2d CRadar::EightSprite;// = (CSprite2d*)0x8F2BCC;
+CSprite2d CRadar::ElSprite;// = (CSprite2d*)0x8F1B80;
+CSprite2d CRadar::IceSprite;// = (CSprite2d*)0x9415FC;
+CSprite2d CRadar::JoeySprite;// = (CSprite2d*)0x8F2C00;
+CSprite2d CRadar::KenjiSprite;// = (CSprite2d*)0x8F2C68;
+CSprite2d CRadar::LizSprite;// = (CSprite2d*)0x8F5830;
+CSprite2d CRadar::LuigiSprite;// = (CSprite2d*)0x8F1A3C;
+CSprite2d CRadar::NorthSprite;// = (CSprite2d*)0x8F6274;
+CSprite2d CRadar::RaySprite;// = (CSprite2d*)0x8E2A7C;
+CSprite2d CRadar::SalSprite;// = (CSprite2d*)0x8F29EC;
+CSprite2d CRadar::SaveSprite;// = (CSprite2d*)0x8F5F74;
+CSprite2d CRadar::SpraySprite;// = (CSprite2d*)0x94307C;
+CSprite2d CRadar::TonySprite;// = (CSprite2d*)0x885B58;
+CSprite2d CRadar::WeaponSprite;// = (CSprite2d*)0x941534;
+
+CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
+ nil,
+ &AsukaSprite,
+ &BombSprite,
+ &CatSprite,
+ &CentreSprite,
+ &CopcarSprite,
+ &DonSprite,
+ &EightSprite,
+ &ElSprite,
+ &IceSprite,
+ &JoeySprite,
+ &KenjiSprite,
+ &LizSprite,
+ &LuigiSprite,
+ &NorthSprite,
+ &RaySprite,
+ &SalSprite,
+ &SaveSprite,
+ &SpraySprite,
+ &TonySprite,
+ &WeaponSprite
+};
+
+#define RADAR_NUM_TILES (8)
+#define RADAR_TILE_SIZE (WORLD_SIZE_X / RADAR_NUM_TILES)
+static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
+
+#define RADAR_MIN_RANGE (120.0f)
+#define RADAR_MAX_RANGE (350.0f)
+#define RADAR_MIN_SPEED (0.3f)
+#define RADAR_MAX_SPEED (0.9f)
+
+#ifdef MENU_MAP
+CRGBA CRadar::ArrowBlipColour1;
+CRGBA CRadar::ArrowBlipColour2;
+uint16 CRadar::MapLegendCounter;
+uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS];
+int CRadar::TargetMarkerId = -1;
+#endif
+
+// taken from VC
+float CRadar::cachedCos;
+float CRadar::cachedSin;
+
+void ClipRadarTileCoords(int32 &x, int32 &y)
{
-#ifdef MENU_MAP
- if (CMenuManager::bMenuMapActive) {
- // fMapSize is actually half map size. Radar range is 1000, so if x is -2000, in.x + 2.0f is 0.
- out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (in.x + 2.0f) * CMenuManager::fMapSize * 2.0f / 4.0f;
- out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (2.0f - in.y) * CMenuManager::fMapSize * 2.0f / 4.0f;
- } else
-#endif
- {
-#ifdef FIX_BUGS
- out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT);
-#else
- out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + RADAR_LEFT;
-#endif
- out.y = (1.0f - in.y) * 0.5f * SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
+ if (x < 0)
+ x = 0;
+ if (x > RADAR_NUM_TILES-1)
+ x = RADAR_NUM_TILES-1;
+ if (y < 0)
+ y = 0;
+ if (y > RADAR_NUM_TILES-1)
+ y = RADAR_NUM_TILES-1;
+}
+
+void RequestMapSection(int32 x, int32 y)
+{
+ ClipRadarTileCoords(x, y);
+ CStreaming::RequestTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y], STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY);
+}
+
+void RemoveMapSection(int32 x, int32 y)
+{
+ if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
+ CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
+}
+
+// Transform from section indices to world coordinates
+void GetTextureCorners(int32 x, int32 y, CVector2D *out)
+{
+ x = x - RADAR_NUM_TILES/2;
+ y = -(y - RADAR_NUM_TILES/2);
+
+ // bottom left
+ out[0].x = RADAR_TILE_SIZE * (x);
+ out[0].y = RADAR_TILE_SIZE * (y - 1);
+
+ // bottom right
+ out[1].x = RADAR_TILE_SIZE * (x + 1);
+ out[1].y = RADAR_TILE_SIZE * (y - 1);
+
+ // top right
+ out[2].x = RADAR_TILE_SIZE * (x + 1);
+ out[2].y = RADAR_TILE_SIZE * (y);
+
+ // top left
+ out[3].x = RADAR_TILE_SIZE * (x);
+ out[3].y = RADAR_TILE_SIZE * (y);
+}
+
+
+bool IsPointInsideRadar(const CVector2D &point)
+{
+ if (point.x < -1.0f || point.x > 1.0f) return false;
+ if (point.y < -1.0f || point.y > 1.0f) return false;
+ return true;
+}
+
+// clip line p1,p2 against (-1.0, 1.0) in x and y, set out to clipped point closest to p1
+int LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D &p2)
+{
+ float d1, d2;
+ float t;
+ float x, y;
+ float shortest = 1.0f;
+ int edge = -1;
+
+ // clip against left edge, x = -1.0
+ d1 = -1.0f - p1.x;
+ d2 = -1.0f - p2.x;
+ if (d1 * d2 < 0.0f) {
+ // they are on opposite sides, get point of intersection
+ t = d1 / (d1 - d2);
+ y = (p2.y - p1.y)*t + p1.y;
+ if (y >= -1.0f && y <= 1.0f && t <= shortest) {
+ out.x = -1.0f;
+ out.y = y;
+ edge = 3;
+ shortest = t;
+ }
+ }
+
+ // clip against right edge, x = 1.0
+ d1 = p1.x - 1.0f;
+ d2 = p2.x - 1.0f;
+ if (d1 * d2 < 0.0f) {
+ // they are on opposite sides, get point of intersection
+ t = d1 / (d1 - d2);
+ y = (p2.y - p1.y)*t + p1.y;
+ if (y >= -1.0f && y <= 1.0f && t <= shortest) {
+ out.x = 1.0f;
+ out.y = y;
+ edge = 1;
+ shortest = t;
+ }
+ }
+
+ // clip against top edge, y = -1.0
+ d1 = -1.0f - p1.y;
+ d2 = -1.0f - p2.y;
+ if (d1 * d2 < 0.0f) {
+ // they are on opposite sides, get point of intersection
+ t = d1 / (d1 - d2);
+ x = (p2.x - p1.x)*t + p1.x;
+ if (x >= -1.0f && x <= 1.0f && t <= shortest) {
+ out.y = -1.0f;
+ out.x = x;
+ edge = 0;
+ shortest = t;
+ }
+ }
+
+ // clip against bottom edge, y = 1.0
+ d1 = p1.y - 1.0f;
+ d2 = p2.y - 1.0f;
+ if (d1 * d2 < 0.0f) {
+ // they are on opposite sides, get point of intersection
+ t = d1 / (d1 - d2);
+ x = (p2.x - p1.x)*t + p1.x;
+ if (x >= -1.0f && x <= 1.0f && t <= shortest) {
+ out.y = 1.0f;
+ out.x = x;
+ edge = 2;
+ shortest = t;
+ }
+ }
+
+ return edge;
+}
+
+
+uint8 CRadar::CalculateBlipAlpha(float dist)
+{
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive)
+ return 255;
+#endif
+ if (dist <= 1.0f)
+ return 255;
+
+ if (dist <= 5.0f)
+ return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f);
+
+ return 128;
+}
+
+void CRadar::ChangeBlipBrightness(int32 i, int32 bright)
+{
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_bDim = bright != 1;
+}
+
+void CRadar::ChangeBlipColour(int32 i, int32 color)
+{
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_nColor = color;
+}
+
+void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display)
+{
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_eBlipDisplay = display;
+}
+
+void CRadar::ChangeBlipScale(int32 i, int32 scale)
+{
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_wScale = scale;
+}
+
+void CRadar::ClearBlip(int32 i)
+{
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1) {
+ SetRadarMarkerState(index, false);
+ ms_RadarTrace[index].m_bInUse = false;
+#ifndef MENU_MAP
+ // Ssshhh
+ ms_RadarTrace[index].m_eBlipType = BLIP_NONE;
+ ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
+ ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE;
+#endif
+ }
+}
+
+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, 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_eRadarSprite = RADAR_SPRITE_NONE;
+ }
+ };
+}
+
+// Why not a proper clipping algorithm?
+int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
+{
+ CVector2D corners[4] = {
+ { 1.0f, -1.0f }, // top right
+ { 1.0f, 1.0f }, // bottom right
+ { -1.0f, 1.0f }, // bottom left
+ { -1.0f, -1.0f }, // top left
+ };
+ CVector2D tmp;
+ int i, j, n;
+ int laste, e, e1, e2;;
+ bool inside[4];
+
+ for (i = 0; i < 4; i++)
+ inside[i] = IsPointInsideRadar(rect[i]);
+
+ laste = -1;
+ n = 0;
+ for (i = 0; i < 4; i++)
+ if (inside[i]) {
+ // point is inside, just add
+ poly[n++] = rect[i];
+ }
+ else {
+ // point is outside but line to this point might be clipped
+ e1 = LineRadarBoxCollision(poly[n], rect[i], rect[(i + 4 - 1) % 4]);
+ if (e1 != -1) {
+ laste = e1;
+ n++;
+ }
+ // and line from this point might be clipped as well
+ e2 = LineRadarBoxCollision(poly[n], rect[i], rect[(i + 1) % 4]);
+ if (e2 != -1) {
+ if (e1 == -1) {
+ // if other line wasn't clipped, i.e. it was complete outside,
+ // we may have to insert another vertex if last clipped line
+ // was on a different edge
+
+ // find the last intersection if we haven't seen it yet
+ if (laste == -1)
+ for (j = 3; j >= i; j--) {
+ // game uses an if here for j == 0
+ e = LineRadarBoxCollision(tmp, rect[j], rect[(j + 4 - 1) % 4]);
+ if (e != -1) {
+ laste = e;
+ break;
+ }
+ }
+ assert(laste != -1);
+
+ // insert corners that were skipped
+ tmp = poly[n];
+ for (e = laste; e != e2; e = (e + 1) % 4)
+ poly[n++] = corners[e];
+ poly[n] = tmp;
+ }
+ n++;
+ }
+ }
+
+ if (n == 0) {
+ // If no points, either the rectangle is completely outside or completely surrounds the radar
+ // no idea what's going on here...
+ float m = (rect[0].y - rect[1].y) / (rect[0].x - rect[1].x);
+ if ((m*rect[3].x - rect[3].y) * (m*rect[0].x - rect[0].y) < 0.0f) {
+ m = (rect[0].y - rect[3].y) / (rect[0].x - rect[3].x);
+ if ((m*rect[1].x - rect[1].y) * (m*rect[0].x - rect[0].y) < 0.0f) {
+ poly[0] = corners[0];
+ poly[1] = corners[1];
+ poly[2] = corners[2];
+ poly[3] = corners[3];
+ n = 4;
+ }
+ }
+ }
+
+ return n;
+}
+
+bool CRadar::DisplayThisBlip(int32 counter)
+{
+ switch (ms_RadarTrace[counter].m_eRadarSprite) {
+ case RADAR_SPRITE_BOMB:
+ case RADAR_SPRITE_SPRAY:
+ case RADAR_SPRITE_WEAPON:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void CRadar::Draw3dMarkers()
+{
+ for (int i = 0; i < NUMRADARBLIPS; i++) {
+ if (ms_RadarTrace[i].m_bInUse) {
+ switch (ms_RadarTrace[i].m_eBlipType) {
+ case BLIP_CAR:
+ {
+ CEntity *entity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_CHAR:
+ {
+ CEntity *entity = CPools::GetPedPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (entity != nil) {
+ if (((CPed*)entity)->InVehicle())
+ entity = ((CPed * )entity)->m_pMyVehicle;
+ }
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += 3.0f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_OBJECT:
+ {
+ CEntity *entity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_COORD:
+ break;
+ case BLIP_CONTACT_POINT:
+ if (!CTheScripts::IsPlayerOnAMission()) {
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY)
+ C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, 0, 128, 255, 128, 2048, 0.2f, 0);
+ }
+ break;
+ }
+ }
+ }
+}
+
+void CRadar::DrawBlips()
+{
+ if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
+
+ CVector2D out;
+ CVector2D in = CVector2D(0.0f, 0.0f);
+ TransformRadarPointToScreenSpace(out, in);
+
+#ifdef MENU_MAP
+ if (!CMenuManager::bMenuMapActive) {
+#endif
+ float angle;
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN)
+ 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());
+
+ DrawRotatingRadarSprite(&CentreSprite, out.x, out.y, angle, 255);
+
+ CVector2D vec2d;
+ vec2d.x = vec2DRadarOrigin.x;
+ vec2d.y = M_SQRT2 * m_radarRange + vec2DRadarOrigin.y;
+ TransformRealWorldPointToRadarSpace(in, vec2d);
+ LimitRadarPoint(in);
+ TransformRadarPointToScreenSpace(out, in);
+ DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255);
+#ifdef MENU_MAP
+ }
+#endif
+
+ CEntity *blipEntity = nil;
+ for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) {
+#ifdef MENU_MAP
+ // A little hack to reuse cleared blips in menu map. hehe
+ if (!CMenuManager::bMenuMapActive || ms_RadarTrace[blipId].m_eBlipType == BLIP_CAR ||
+ ms_RadarTrace[blipId].m_eBlipType == BLIP_CHAR || ms_RadarTrace[blipId].m_eBlipType == BLIP_OBJECT)
+#endif
+ 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_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
+ || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == 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 != nil) {
+ if (((CPed*)blipEntity)->InVehicle())
+ 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::IsDebugOn()) {
+ 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_eRadarSprite != RADAR_SPRITE_NONE) {
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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
+ }
+ }
+ }
+ }
+ break;
+ case BLIP_COORD:
+ case BLIP_CONTACT_POINT:
+ if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
+ || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == 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::IsDebugOn()) {
+ 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[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);
+ TransformRadarPointToScreenSpace(out, in);
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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;
+ 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_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
+ && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != 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 != nil) {
+ if (((CPed*)blipEntity)->InVehicle())
+ 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::IsDebugOn()) {
+ 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_eRadarSprite != RADAR_SPRITE_NONE)
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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
+ }
+ }
+ }
+ 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_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
+ && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != 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::IsDebugOn()) {
+ 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[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);
+ TransformRadarPointToScreenSpace(out, in);
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, 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;
+ default:
+ break;
+ }
+ }
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive) {
+ CVector2D in, out;
+ TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift());
+ TransformRadarPointToScreenSpace(out, in);
+ DrawYouAreHereSprite(out.x, out.y);
+ }
+#endif
+ }
+}
+
+void CRadar::DrawMap()
+{
+ if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
+#if 1 // from VC
+ CalculateCachedSinCos();
+#endif
+ if (FindPlayerVehicle()) {
+ float speed = FindPlayerSpeed().Magnitude();
+ if (speed < RADAR_MIN_SPEED)
+ m_radarRange = RADAR_MIN_RANGE;
+ else if (speed < RADAR_MAX_SPEED)
+ m_radarRange = (speed - RADAR_MIN_SPEED)/(RADAR_MAX_SPEED-RADAR_MIN_SPEED) * (RADAR_MAX_RANGE-RADAR_MIN_RANGE) + RADAR_MIN_RANGE;
+ else
+ m_radarRange = RADAR_MAX_RANGE;
+ }
+ else
+ m_radarRange = RADAR_MIN_RANGE;
+
+ vec2DRadarOrigin = CVector2D(FindPlayerCentreOfWorld_NoSniperShift());
+ DrawRadarMap();
+ }
+}
+
+void CRadar::DrawRadarMap()
+{
+ // Game calculates an unused CRect here
+
+ DrawRadarMask();
+
+ // top left ist (0, 0)
+ int x = floorf((vec2DRadarOrigin.x - WORLD_MIN_X) / RADAR_TILE_SIZE);
+ int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - WORLD_MIN_Y) / RADAR_TILE_SIZE);
+ StreamRadarSections(x, y);
+
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
+ RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
+ RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void*)FALSE);
+
+ DrawRadarSection(x - 1, y - 1);
+ DrawRadarSection(x, y - 1);
+ DrawRadarSection(x + 1, y - 1);
+ DrawRadarSection(x - 1, y);
+ DrawRadarSection(x, y);
+ DrawRadarSection(x + 1, y);
+ DrawRadarSection(x - 1, y + 1);
+ DrawRadarSection(x, y + 1);
+ DrawRadarSection(x + 1, y + 1);
+}
+
+void CRadar::DrawRadarMask()
+{
+ CVector2D corners[4] = {
+ CVector2D(1.0f, -1.0f),
+ CVector2D(1.0f, 1.0f),
+ CVector2D(-1.0f, 1.0f),
+ CVector2D(-1.0, -1.0f)
+ };
+
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
+ RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+
+ CVector2D out[8];
+ CVector2D in;
+
+ // Draw the shape we want to mask out from the radar in four segments
+ for (int i = 0; i < 4; i++) {
+ // First point is always the corner itself
+ in.x = corners[i].x;
+ in.y = corners[i].y;
+ TransformRadarPointToScreenSpace(out[0], in);
+
+ // Then generate a quarter of the circle
+ for (int j = 0; j < 7; j++) {
+ in.x = corners[i].x * Cos(j * (PI / 2.0f / 6.0f));
+ in.y = corners[i].y * Sin(j * (PI / 2.0f / 6.0f));
+ TransformRadarPointToScreenSpace(out[j + 1], in);
+ };
+
+ CSprite2d::SetMaskVertices(8, (float *)out);
+ RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8);
+ };
+}
+
+void CRadar::DrawRadarSection(int32 x, int32 y)
+{
+ int i;
+ RwTexDictionary *txd;
+ CVector2D worldPoly[8];
+ CVector2D radarCorners[4];
+ CVector2D radarPoly[8];
+ CVector2D texCoords[8];
+ CVector2D screenPoly[8];
+ int numVertices;
+ RwTexture *texture = nil;
+
+ GetTextureCorners(x, y, worldPoly);
+ ClipRadarTileCoords(x, y);
+
+ assert(CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y]));
+ txd = CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y])->texDict;
+ if (txd)
+ texture = GetFirstTexture(txd);
+ if (texture == nil)
+ return;
+
+ for (i = 0; i < 4; i++)
+ TransformRealWorldPointToRadarSpace(radarCorners[i], worldPoly[i]);
+
+ numVertices = ClipRadarPoly(radarPoly, radarCorners);
+
+ // FIX: can return earlier here
+// if(numVertices == 0)
+ if (numVertices < 3)
+ return;
+
+ for (i = 0; i < numVertices; i++) {
+ TransformRadarPointToRealWorldSpace(worldPoly[i], radarPoly[i]);
+ TransformRealWorldToTexCoordSpace(texCoords[i], worldPoly[i], x, y);
+ TransformRadarPointToScreenSpace(screenPoly[i], radarPoly[i]);
+ }
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(texture));
+ CSprite2d::SetVertices(numVertices, (float*)screenPoly, (float*)texCoords, CRGBA(255, 255, 255, 255));
+ // check done above now
+// if(numVertices > 2)
+ RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), numVertices);
+}
+
+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));
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive) {
+ bool alreadyThere = false;
+ for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
+ if (MapLegendList[i] == sprite)
+ alreadyThere = true;
+ }
+ if (!alreadyThere) {
+ MapLegendList[MapLegendCounter] = sprite;
+ MapLegendCounter++;
+ }
+ }
+#endif
+}
+
+void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha)
+{
+ CVector curPosn[4];
+ CVector oldPosn[4];
+
+ curPosn[0].x = x - SCREEN_SCALE_X(5.6f);
+ curPosn[0].y = y + SCREEN_SCALE_Y(5.6f);
+
+ curPosn[1].x = x + SCREEN_SCALE_X(5.6f);
+ curPosn[1].y = y + SCREEN_SCALE_Y(5.6f);
+
+ curPosn[2].x = x - SCREEN_SCALE_X(5.6f);
+ curPosn[2].y = y - SCREEN_SCALE_Y(5.6f);
+
+ curPosn[3].x = x + SCREEN_SCALE_X(5.6f);
+ curPosn[3].y = y - SCREEN_SCALE_Y(5.6f);
+
+ for (uint32 i = 0; i < 4; i++) {
+ oldPosn[i] = curPosn[i];
+
+ curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle);
+ curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle);
+ }
+
+ sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
+}
+
+int32 CRadar::GetActualBlipArrayIndex(int32 i)
+{
+ if (i == -1)
+ return -1;
+ else if ((i & 0xFFFF0000) >> 16 != ms_RadarTrace[(uint16)i].m_BlipIndex)
+ return -1;
+ else
+ return (uint16)i;
+}
+
+int32 CRadar::GetNewUniqueBlipIndex(int32 i)
+{
+ if (ms_RadarTrace[i].m_BlipIndex >= UINT16_MAX - 1)
+ ms_RadarTrace[i].m_BlipIndex = 1;
+ else
+ ms_RadarTrace[i].m_BlipIndex++;
+ return i | (ms_RadarTrace[i].m_BlipIndex << 16);
+}
+
+uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
+{
+ int32 c;
+ switch (color) {
+ case 0:
+ if (bright)
+ c = 0x712B49FF;
+ else
+ c = 0x7F0000FF;
+ break;
+ case 1:
+ if (bright)
+ c = 0x5FA06AFF;
+ else
+ c = 0x007F00FF;
+ break;
+ case 2:
+ if (bright)
+ c = 0x80A7F3FF;
+ else
+ c = 0x00007FFF;
+ break;
+ case 3:
+ if (bright)
+ c = 0xE1E1E1FF;
+ else
+ c = 0x7F7F7FFF;
+ break;
+ case 4:
+ if (bright)
+ c = 0xFFFF00FF;
+ else
+ c = 0x7F7F00FF;
+ break;
+ case 5:
+ if (bright)
+ c = 0xFF00FFFF;
+ else
+ c = 0x7F007FFF;
+ break;
+ case 6:
+ if (bright)
+ c = 0x00FFFFFF;
+ else
+ c = 0x007F7FFF;
+ break;
+ default:
+ c = color;
+ break;
+ };
+ return c;
+}
+
+const char* gRadarTexNames[] = {
+ "radar00", "radar01", "radar02", "radar03", "radar04", "radar05", "radar06", "radar07",
+ "radar08", "radar09", "radar10", "radar11", "radar12", "radar13", "radar14", "radar15",
+ "radar16", "radar17", "radar18", "radar19", "radar20", "radar21", "radar22", "radar23",
+ "radar24", "radar25", "radar26", "radar27", "radar28", "radar29", "radar30", "radar31",
+ "radar32", "radar33", "radar34", "radar35", "radar36", "radar37", "radar38", "radar39",
+ "radar40", "radar41", "radar42", "radar43", "radar44", "radar45", "radar46", "radar47",
+ "radar48", "radar49", "radar50", "radar51", "radar52", "radar53", "radar54", "radar55",
+ "radar56", "radar57", "radar58", "radar59", "radar60", "radar61", "radar62", "radar63",
+};
+
+void
+CRadar::Initialise()
+{
+ for (int i = 0; i < NUMRADARBLIPS; i++) {
+ ms_RadarTrace[i].m_BlipIndex = 1;
+ 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_eRadarSprite = RADAR_SPRITE_NONE;
+ }
+
+ m_radarRange = 350.0f;
+ for (int i = 0; i < 64; i++)
+ gRadarTxdIds[i] = CTxdStore::FindTxdSlot(gRadarTexNames[i]);
+}
+
+float CRadar::LimitRadarPoint(CVector2D &point)
+{
+ float dist, invdist;
+
+ dist = point.Magnitude();
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive)
+ return dist;
+#endif
+ if (dist > 1.0f) {
+ invdist = 1.0f / dist;
+ point.x *= invdist;
+ point.y *= invdist;
+ }
+ return dist;
+}
+
+void CRadar::LoadAllRadarBlips(uint8 *buf, uint32 size)
+{
+ Initialise();
+INITSAVEBUF
+ CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
+
+ for (int i = 0; i < NUMRADARBLIPS; i++)
+ ms_RadarTrace[i] = ReadSaveBuf<sRadarTrace>(buf);
+
+VALIDATESAVEBUF(size);
+}
+
+void
+CRadar::LoadTextures()
+{
+ CTxdStore::PushCurrentTxd();
+ CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud"));
+ AsukaSprite.SetTexture("radar_asuka");
+ BombSprite.SetTexture("radar_bomb");
+ CatSprite.SetTexture("radar_cat");
+ CentreSprite.SetTexture("radar_centre");
+ CopcarSprite.SetTexture("radar_copcar");
+ DonSprite.SetTexture("radar_don");
+ EightSprite.SetTexture("radar_eight");
+ ElSprite.SetTexture("radar_el");
+ IceSprite.SetTexture("radar_ice");
+ JoeySprite.SetTexture("radar_joey");
+ KenjiSprite.SetTexture("radar_kenji");
+ LizSprite.SetTexture("radar_liz");
+ LuigiSprite.SetTexture("radar_luigi");
+ NorthSprite.SetTexture("radar_north");
+ RaySprite.SetTexture("radar_ray");
+ SalSprite.SetTexture("radar_sal");
+ SaveSprite.SetTexture("radar_save");
+ SpraySprite.SetTexture("radar_spray");
+ TonySprite.SetTexture("radar_tony");
+ WeaponSprite.SetTexture("radar_weapon");
+ CTxdStore::PopCurrentTxd();
+}
+
+void CRadar::RemoveRadarSections()
+{
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ RemoveMapSection(i, j);
+}
+
+void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
+{
+ *size = SAVE_HEADER_SIZE + sizeof(ms_RadarTrace);
+INITSAVEBUF
+ WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
+
+ for (int i = 0; i < NUMRADARBLIPS; i++)
+ WriteSaveBuf(buf, ms_RadarTrace[i]);
+
+VALIDATESAVEBUF(*size);
+}
+
+void CRadar::SetBlipSprite(int32 i, int32 icon)
+{
+ int index = CRadar::GetActualBlipArrayIndex(i);
+ if (index != -1) {
+ ms_RadarTrace[index].m_eRadarSprite = icon;
+ }
+}
+
+int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display)
+{
+ 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_eRadarSprite = RADAR_SPRITE_NONE;
+ return CRadar::GetNewUniqueBlipIndex(nextBlip);
+}
+
+int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display)
+{
+ 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_eRadarSprite = RADAR_SPRITE_NONE;
+ return GetNewUniqueBlipIndex(nextBlip);
+}
+
+void CRadar::SetRadarMarkerState(int32 counter, bool flag)
+{
+ CEntity *e;
+ switch (ms_RadarTrace[counter].m_eBlipType) {
+ case BLIP_CAR:
+ e = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ case BLIP_CHAR:
+ e = CPools::GetPedPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ case BLIP_OBJECT:
+ e = CPools::GetObjectPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ default:
+ return;
+ }
+
+ if (e)
+ e->bHasBlip = flag;
+}
+
+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;
+ p2 = pos + TheCamera.GetUp()*f2;
+ CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
+
+ p1 = pos - TheCamera.GetUp()*f1;
+ p2 = pos - TheCamera.GetUp()*f2;
+ CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
+
+ p1 = pos + TheCamera.GetRight()*f1;
+ p2 = pos + TheCamera.GetRight()*f2;
+ CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
+
+ p1 = pos - TheCamera.GetRight()*f1;
+ p2 = pos - TheCamera.GetRight()*f2;
+ CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
+}
+
+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));
+}
+
+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;
+ }
+#ifdef MENU_MAP
+ // VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips
+ if (CMenuManager::bMenuMapActive) {
+ bool alreadyThere = false;
+ for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
+ if (MapLegendList[i] == -1)
+ alreadyThere = true;
+ }
+ if (!alreadyThere) {
+ MapLegendList[MapLegendCounter] = -1;
+ MapLegendCounter++;
+ ArrowBlipColour1 = CRGBA(red, green, blue, alpha);
+ }
+ }
+#endif
+}
+
+void CRadar::Shutdown()
+{
+ AsukaSprite.Delete();
+ BombSprite.Delete();
+ CatSprite.Delete();
+ CentreSprite.Delete();
+ CopcarSprite.Delete();
+ DonSprite.Delete();
+ EightSprite.Delete();
+ ElSprite.Delete();
+ IceSprite.Delete();
+ JoeySprite.Delete();
+ KenjiSprite.Delete();
+ LizSprite.Delete();
+ LuigiSprite.Delete();
+ NorthSprite.Delete();
+ RaySprite.Delete();
+ SalSprite.Delete();
+ SaveSprite.Delete();
+ SpraySprite.Delete();
+ TonySprite.Delete();
+ WeaponSprite.Delete();
+ RemoveRadarSections();
+}
+
+void CRadar::StreamRadarSections(const CVector &posn)
+{
+ StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f));
+}
+
+void CRadar::StreamRadarSections(int32 x, int32 y)
+{
+ for (int i = 0; i < RADAR_NUM_TILES; ++i) {
+ for (int j = 0; j < RADAR_NUM_TILES; ++j) {
+ if ((i >= x - 1 && i <= x + 1) && (j >= y - 1 && j <= y + 1))
+ RequestMapSection(i, j);
+ else
+ RemoveMapSection(i, j);
+ };
+ };
+}
+
+void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y)
+{
+ out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X);
+ out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + WORLD_MIN_Y));
+ out.x /= RADAR_TILE_SIZE;
+ out.y /= RADAR_TILE_SIZE;
+}
+
+void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in)
+{
+ float s, c;
+#if 1
+ s = -cachedSin;
+ c = cachedCos;
+#else
+ // Original code
+
+ s = -Sin(TheCamera.GetForward().Heading());
+ c = Cos(TheCamera.GetForward().Heading());
+
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) {
+ s = 0.0f;
+ c = 1.0f;
+ }
+ else if (TheCamera.GetLookDirection() != LOOKING_FORWARD) {
+ CVector forward;
+
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
+ forward.Normalise(); // a bit useless...
+ }
+ else
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
+
+ s = -Sin(forward.Heading());
+ c = Cos(forward.Heading());
+ }
+#endif
+
+ out.x = s * in.y + c * in.x;
+ out.y = c * in.y - s * in.x;
+
+ out = out * m_radarRange + vec2DRadarOrigin;
+}
+
+// Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0)
+void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
+{
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive) {
+ // fMapSize is actually half map size. Radar range is 1000, so if x is -2000, in.x + 2.0f is 0.
+ out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (in.x + 2.0f) * CMenuManager::fMapSize * 2.0f / 4.0f;
+ out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (2.0f - in.y) * CMenuManager::fMapSize * 2.0f / 4.0f;
+ } else
+#endif
+ {
+#ifdef FIX_BUGS
+ out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT);
+#else
+ out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + RADAR_LEFT;
+#endif
+ out.y = (1.0f - in.y) * 0.5f * SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
+ }
+}
+
+void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in)
+{
+ float s, c;
+#if 1
+ s = cachedSin;
+ c = cachedCos;
+#else
+ // Original code
+
+ float s, c;
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) {
+ s = 0.0f;
+ c = 1.0f;
+ }
+ else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
+ s = Sin(TheCamera.GetForward().Heading());
+ c = Cos(TheCamera.GetForward().Heading());
+ }
+ else {
+ CVector forward;
+
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
+ forward.Normalise(); // a bit useless...
+ }
+ else
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
+
+ s = Sin(forward.Heading());
+ c = Cos(forward.Heading());
+ }
+#endif
+
+ float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_radarRange);
+ float y = (in.y - vec2DRadarOrigin.y) * (1.0f / m_radarRange);
+
+ out.x = s * y + c * x;
+ out.y = c * y - s * x;
+}
+
+void
+CRadar::CalculateCachedSinCos()
+{
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED
+#ifdef MENU_MAP
+ || CMenuManager::bMenuMapActive
+#endif
+ ) {
+ cachedSin = 0.0f;
+ cachedCos = 1.0f;
+ } else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
+ cachedSin = Sin(TheCamera.GetForward().Heading());
+ cachedCos = Cos(TheCamera.GetForward().Heading());
+ } else {
+ CVector forward;
+
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
+ forward.Normalise(); // a bit useless...
+ }
+ else
+ forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
+
+ cachedSin = Sin(forward.Heading());
+ cachedCos = Cos(forward.Heading());
+ }
+}
+
+#ifdef MENU_MAP
+void
+CRadar::InitFrontEndMap()
+{
+ CalculateCachedSinCos();
+ vec2DRadarOrigin.x = 0.0f;
+ vec2DRadarOrigin.y = 0.0f;
+ m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace
+ for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
+ MapLegendList[i] = RADAR_SPRITE_NONE;
+ }
+ MapLegendCounter = 0;
+ ArrowBlipColour1 = CRGBA(0, 0, 0, 0);
+ ArrowBlipColour2 = CRGBA(0, 0, 0, 0);
+}
+
+void
+CRadar::DrawYouAreHereSprite(float x, float y)
+{
+ static uint32 lastChange = 0;
+ static bool show = true;
+
+ if (show) {
+ if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 500) {
+ lastChange = CTimer::GetTimeInMillisecondsPauseMode();
+ show = !show;
+ }
+ } else {
+ if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 200) {
+ lastChange = CTimer::GetTimeInMillisecondsPauseMode();
+ show = !show;
+ }
+ }
+
+ if (show) {
+ float left = x - SCREEN_SCALE_X(12.0f);
+ float top = y - SCREEN_SCALE_Y(2.0f);
+ float right = SCREEN_SCALE_X(12.0) + x;
+ float bottom = y - SCREEN_SCALE_Y(26.0f);
+ CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 217, 106, 255));
+ }
+ MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
+}
+
+void
+CRadar::ToggleTargetMarker(float x, float y)
+{
+ if (TargetMarkerId == -1) {
+ int nextBlip;
+ for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) {
+ if (!ms_RadarTrace[nextBlip].m_bInUse)
+ break;
+ }
+ ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD;
+ ms_RadarTrace[nextBlip].m_nColor = 0x333333FF;
+ ms_RadarTrace[nextBlip].m_bDim = 1;
+ ms_RadarTrace[nextBlip].m_bInUse = 1;
+ ms_RadarTrace[nextBlip].m_Radius = 1.0f;
+ CVector pos(x, y, CWorld::FindGroundZForCoord(x,y));
+ ms_RadarTrace[nextBlip].m_vec2DPos = pos;
+ ms_RadarTrace[nextBlip].m_vecPos = pos;
+ ms_RadarTrace[nextBlip].m_nEntityHandle = 0;
+ ms_RadarTrace[nextBlip].m_wScale = 5;
+ ms_RadarTrace[nextBlip].m_eBlipDisplay = BLIP_DISPLAY_BLIP_ONLY;
+ ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_NONE;
+ TargetMarkerId = CRadar::GetNewUniqueBlipIndex(nextBlip);
+ } else {
+ ClearBlip(TargetMarkerId);
+ TargetMarkerId = -1;
}
-}
-
-void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in)
-{
- float s, c;
-#if 1
- s = cachedSin;
- c = cachedCos;
-#else
- // Original code
-
- float s, c;
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) {
- s = 0.0f;
- c = 1.0f;
- }
- else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
- s = Sin(TheCamera.GetForward().Heading());
- c = Cos(TheCamera.GetForward().Heading());
- }
- else {
- CVector forward;
-
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
- forward.Normalise(); // a bit useless...
- }
- else
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
-
- s = Sin(forward.Heading());
- c = Cos(forward.Heading());
- }
-#endif
-
- float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_radarRange);
- float y = (in.y - vec2DRadarOrigin.y) * (1.0f / m_radarRange);
-
- out.x = s * y + c * x;
- out.y = c * y - s * x;
-}
-
-// Transform from section indices to world coordinates
-void CRadar::GetTextureCorners(int32 x, int32 y, CVector2D *out)
-{
- x = x - RADAR_NUM_TILES/2;
- y = -(y - RADAR_NUM_TILES/2);
-
- // bottom left
- out[0].x = RADAR_TILE_SIZE * (x);
- out[0].y = RADAR_TILE_SIZE * (y - 1);
-
- // bottom right
- out[1].x = RADAR_TILE_SIZE * (x + 1);
- out[1].y = RADAR_TILE_SIZE * (y - 1);
-
- // top right
- out[2].x = RADAR_TILE_SIZE * (x + 1);
- out[2].y = RADAR_TILE_SIZE * (y);
-
- // top left
- out[3].x = RADAR_TILE_SIZE * (x);
- out[3].y = RADAR_TILE_SIZE * (y);
-}
-
-void CRadar::ClipRadarTileCoords(int32 &x, int32 &y)
-{
- if (x < 0)
- x = 0;
- if (x > RADAR_NUM_TILES-1)
- x = RADAR_NUM_TILES-1;
- if (y < 0)
- y = 0;
- if (y > RADAR_NUM_TILES-1)
- y = RADAR_NUM_TILES-1;
-}
-
-
-bool CRadar::IsPointInsideRadar(const CVector2D &point)
-{
- if (point.x < -1.0f || point.x > 1.0f) return false;
- if (point.y < -1.0f || point.y > 1.0f) return false;
- return true;
-}
-
-// clip line p1,p2 against (-1.0, 1.0) in x and y, set out to clipped point closest to p1
-int CRadar::LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D &p2)
-{
- float d1, d2;
- float t;
- float x, y;
- float shortest = 1.0f;
- int edge = -1;
-
- // clip against left edge, x = -1.0
- d1 = -1.0f - p1.x;
- d2 = -1.0f - p2.x;
- if (d1 * d2 < 0.0f) {
- // they are on opposite sides, get point of intersection
- t = d1 / (d1 - d2);
- y = (p2.y - p1.y)*t + p1.y;
- if (y >= -1.0f && y <= 1.0f && t <= shortest) {
- out.x = -1.0f;
- out.y = y;
- edge = 3;
- shortest = t;
- }
- }
-
- // clip against right edge, x = 1.0
- d1 = p1.x - 1.0f;
- d2 = p2.x - 1.0f;
- if (d1 * d2 < 0.0f) {
- // they are on opposite sides, get point of intersection
- t = d1 / (d1 - d2);
- y = (p2.y - p1.y)*t + p1.y;
- if (y >= -1.0f && y <= 1.0f && t <= shortest) {
- out.x = 1.0f;
- out.y = y;
- edge = 1;
- shortest = t;
- }
- }
-
- // clip against top edge, y = -1.0
- d1 = -1.0f - p1.y;
- d2 = -1.0f - p2.y;
- if (d1 * d2 < 0.0f) {
- // they are on opposite sides, get point of intersection
- t = d1 / (d1 - d2);
- x = (p2.x - p1.x)*t + p1.x;
- if (x >= -1.0f && x <= 1.0f && t <= shortest) {
- out.y = -1.0f;
- out.x = x;
- edge = 0;
- shortest = t;
- }
- }
-
- // clip against bottom edge, y = 1.0
- d1 = p1.y - 1.0f;
- d2 = p2.y - 1.0f;
- if (d1 * d2 < 0.0f) {
- // they are on opposite sides, get point of intersection
- t = d1 / (d1 - d2);
- x = (p2.x - p1.x)*t + p1.x;
- if (x >= -1.0f && x <= 1.0f && t <= shortest) {
- out.y = 1.0f;
- out.x = x;
- edge = 2;
- shortest = t;
- }
- }
-
- return edge;
-}
-
-void
-CRadar::CalculateCachedSinCos()
-{
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED
-#ifdef MENU_MAP
- || CMenuManager::bMenuMapActive
-#endif
- ) {
- cachedSin = 0.0f;
- cachedCos = 1.0f;
- } else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
- cachedSin = Sin(TheCamera.GetForward().Heading());
- cachedCos = Cos(TheCamera.GetForward().Heading());
- } else {
- CVector forward;
-
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON) {
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetForward();
- forward.Normalise(); // a bit useless...
- }
- else
- forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
-
- cachedSin = Sin(forward.Heading());
- cachedCos = Cos(forward.Heading());
- }
-}
-
-#ifdef MENU_MAP
-void
-CRadar::InitFrontEndMap()
-{
- CalculateCachedSinCos();
- vec2DRadarOrigin.x = 0.0f;
- vec2DRadarOrigin.y = 0.0f;
- m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace
- for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
- MapLegendList[i] = RADAR_SPRITE_NONE;
- }
- MapLegendCounter = 0;
- ArrowBlipColour1 = CRGBA(0, 0, 0, 0);
- ArrowBlipColour2 = CRGBA(0, 0, 0, 0);
-}
-
-void
-CRadar::DrawYouAreHereSprite(float x, float y)
-{
- static uint32 lastChange = 0;
- static bool show = true;
-
- if (show) {
- if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 500) {
- lastChange = CTimer::GetTimeInMillisecondsPauseMode();
- show = !show;
- }
- } else {
- if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 200) {
- lastChange = CTimer::GetTimeInMillisecondsPauseMode();
- show = !show;
- }
- }
-
- if (show) {
- float left = x - SCREEN_SCALE_X(12.0f);
- float top = y - SCREEN_SCALE_Y(2.0f);
- float right = SCREEN_SCALE_X(12.0) + x;
- float bottom = y - SCREEN_SCALE_Y(26.0f);
- CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 217, 106, 255));
- }
- MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
-}
-
-void
-CRadar::ToggleTargetMarker(float x, float y)
-{
- if (TargetMarkerId == -1) {
- int nextBlip;
- for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) {
- if (!ms_RadarTrace[nextBlip].m_bInUse)
- break;
- }
- ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD;
- ms_RadarTrace[nextBlip].m_nColor = 0x333333FF;
- ms_RadarTrace[nextBlip].m_bDim = 1;
- ms_RadarTrace[nextBlip].m_bInUse = 1;
- ms_RadarTrace[nextBlip].m_Radius = 1.0f;
- CVector pos(x, y, CWorld::FindGroundZForCoord(x,y));
- ms_RadarTrace[nextBlip].m_vec2DPos = pos;
- ms_RadarTrace[nextBlip].m_vecPos = pos;
- ms_RadarTrace[nextBlip].m_nEntityHandle = 0;
- ms_RadarTrace[nextBlip].m_wScale = 5;
- ms_RadarTrace[nextBlip].m_eBlipDisplay = BLIP_DISPLAY_BLIP_ONLY;
- ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_NONE;
- TargetMarkerId = CRadar::GetNewUniqueBlipIndex(nextBlip);
- } else {
- ClearBlip(TargetMarkerId);
- TargetMarkerId = -1;
- }
-}
-#endif
-
-STARTPATCHES
- InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP);
- 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(0x4A4200, CRadar::DrawMap, PATCH_JUMP);
- InjectHook(0x4A42F0, CRadar::DrawBlips, PATCH_JUMP);
- InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP);
- InjectHook(0x4A4F30, CRadar::LimitRadarPoint, PATCH_JUMP);
- InjectHook(0x4A4F90, CRadar::CalculateBlipAlpha, PATCH_JUMP);
- InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP);
- 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(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(0x4A5870, CRadar::ShowRadarTrace, PATCH_JUMP);
- InjectHook(0x4A59C0, CRadar::ShowRadarMarker, 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);
- InjectHook(0x4A60E0, CRadar::RemoveRadarSections, PATCH_JUMP);
- InjectHook(0x4A6100, (void (*)(int32, int32))&CRadar::StreamRadarSections, PATCH_JUMP);
- InjectHook(0x4A64A0, CRadar::ClipRadarPoly, PATCH_JUMP);
- InjectHook(0x4A67E0, CRadar::DrawRadarSection, PATCH_JUMP);
- InjectHook(0x4A69C0, CRadar::DrawRadarMask, PATCH_JUMP);
- InjectHook(0x4A6B60, (void (*)(const CVector&))&CRadar::StreamRadarSections, PATCH_JUMP);
- InjectHook(0x4A6C20, CRadar::DrawRadarMap, PATCH_JUMP);
- InjectHook(0x4A6E30, CRadar::SaveAllRadarBlips, PATCH_JUMP);
- InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP);
-
- InjectHook(0x4A61C0, CRadar::GetTextureCorners, PATCH_JUMP);
- InjectHook(0x4A6160, CRadar::IsPointInsideRadar, PATCH_JUMP);
- InjectHook(0x4A6250, CRadar::LineRadarBoxCollision, PATCH_JUMP);
-ENDPATCHES
+}
+#endif
+
+STARTPATCHES
+ InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP);
+ 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(0x4A4200, CRadar::DrawMap, PATCH_JUMP);
+ InjectHook(0x4A42F0, CRadar::DrawBlips, PATCH_JUMP);
+ InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP);
+ InjectHook(0x4A4F30, CRadar::LimitRadarPoint, PATCH_JUMP);
+ InjectHook(0x4A4F90, CRadar::CalculateBlipAlpha, PATCH_JUMP);
+ InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP);
+ 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(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(0x4A5870, CRadar::ShowRadarTrace, PATCH_JUMP);
+ InjectHook(0x4A59C0, CRadar::ShowRadarMarker, 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);
+ InjectHook(0x4A6020, ClipRadarTileCoords, PATCH_JUMP);
+ InjectHook(0x4A6060, RequestMapSection, PATCH_JUMP);
+ InjectHook(0x4A60A0, RemoveMapSection, PATCH_JUMP);
+ InjectHook(0x4A60E0, CRadar::RemoveRadarSections, PATCH_JUMP);
+ InjectHook(0x4A6100, (void (*)(int32, int32))&CRadar::StreamRadarSections, PATCH_JUMP);
+ InjectHook(0x4A6160, IsPointInsideRadar, PATCH_JUMP);
+ InjectHook(0x4A61C0, GetTextureCorners, PATCH_JUMP);
+ InjectHook(0x4A6250, LineRadarBoxCollision, PATCH_JUMP);
+ InjectHook(0x4A64A0, CRadar::ClipRadarPoly, PATCH_JUMP);
+ InjectHook(0x4A67E0, CRadar::DrawRadarSection, PATCH_JUMP);
+ InjectHook(0x4A69C0, CRadar::DrawRadarMask, PATCH_JUMP);
+ InjectHook(0x4A6B60, (void (*)(const CVector&))&CRadar::StreamRadarSections, PATCH_JUMP);
+ InjectHook(0x4A6C20, CRadar::DrawRadarMap, PATCH_JUMP);
+ InjectHook(0x4A6E30, CRadar::SaveAllRadarBlips, PATCH_JUMP);
+ InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP);
+ //InjectHook(0x4A7000, `global constructor keyed to'Radar.cpp, PATCH_JUMP);
+ //InjectHook(0x4A7260, sRadarTrace::sRadarTrace, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 6d5bb196..27f3a6f0 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -56,7 +56,7 @@ enum
BLIP_MODE_SQUARE,
};
-struct CBlip
+struct sRadarTrace
{
uint32 m_nColor;
uint32 m_eBlipType; // eBlipType
@@ -71,7 +71,7 @@ struct CBlip
uint16 m_eBlipDisplay; // eBlipDisplay
uint16 m_eRadarSprite; // eRadarSprite
};
-static_assert(sizeof(CBlip) == 0x30, "CBlip: error");
+static_assert(sizeof(sRadarTrace) == 0x30, "sRadarTrace: error");
// Values for screen space
#define RADAR_LEFT (40.0f)
@@ -83,7 +83,7 @@ class CRadar
{
public:
static float &m_radarRange;
- static CBlip (&ms_RadarTrace)[NUMRADARBLIPS];
+ static sRadarTrace (&ms_RadarTrace)[NUMRADARBLIPS];
static CSprite2d AsukaSprite;
static CSprite2d BombSprite;
static CSprite2d CatSprite;
@@ -144,7 +144,6 @@ public:
static void LoadAllRadarBlips(uint8 *buf, uint32 size);
static void LoadTextures();
static void RemoveRadarSections();
- static void RequestMapSection(int32 x, int32 y);
static void SaveAllRadarBlips(uint8*, uint32*);
static void SetBlipSprite(int32 i, int32 icon);
static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay);
@@ -161,10 +160,6 @@ public:
static void TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in);
static void TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in);
- // no in CRadar in the game:
- static void GetTextureCorners(int32 x, int32 y, CVector2D *out);
- static void ClipRadarTileCoords(int32 &x, int32 &y);
- static bool IsPointInsideRadar(const CVector2D &);
- static int LineRadarBoxCollision(CVector2D &, const CVector2D &, const CVector2D &);
+ // no in CRadar in the game:
static void CalculateCachedSinCos();
};
diff --git a/src/core/RwHelper.cpp b/src/core/RwHelper.cpp
index 6325bf15..44866f4f 100644
--- a/src/core/RwHelper.cpp
+++ b/src/core/RwHelper.cpp
@@ -347,13 +347,6 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
return (nil);
}
-WRAPPER void ReadVideoCardCapsFile(uint32&, uint32&, uint32&, uint32&) { EAXJMP(0x5926C0); }
-WRAPPER bool CheckVideoCardCaps(void) { EAXJMP(0x592740); }
-WRAPPER void WriteVideoCardCapsFile(void) { EAXJMP(0x5927D0); }
-WRAPPER void ConvertingTexturesScreen(uint32, uint32, const char*) { EAXJMP(0x592880); }
-WRAPPER void DealWithTxdWriteError(uint32, uint32, const char*) { EAXJMP(0x592BF0); }
-WRAPPER bool CreateTxdImageForVideoCard() { EAXJMP(0x592C70); }
-
void CreateDebugFont()
{
;
diff --git a/src/core/RwTexRead.cpp b/src/core/RwTexRead.cpp
index 6b717b34..ef1ac197 100644
--- a/src/core/RwTexRead.cpp
+++ b/src/core/RwTexRead.cpp
@@ -3,10 +3,24 @@
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#pragma warning( pop )
+#define WITHWINDOWS
#include "common.h"
#include "win.h"
#include "patcher.h"
#include "Timer.h"
+#ifdef GTA_PC
+#include "FileMgr.h"
+#include "Pad.h"
+#include "main.h"
+#include "Directory.h"
+#include "Streaming.h"
+#include "TxdStore.h"
+#include "CdStream.h"
+#include "Font.h"
+#include "Sprite2d.h"
+#include "Text.h"
+#include "RwHelper.h"
+#endif //GTA_PC
float &texLoadTime = *(float*)0x8F1B50;
int32 &texNumLoaded = *(int32*)0x8F252C;
@@ -132,9 +146,198 @@ RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict)
return texDict;
}
+#ifdef GTA_PC
+WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); }
+
+void
+ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8)
+{
+ cap32 = UINT32_MAX;
+ cap24 = UINT32_MAX;
+ cap16 = UINT32_MAX;
+ cap8 = UINT32_MAX;
+
+ int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "rb");
+ if (file != 0) {
+ CFileMgr::Read(file, (char*)&cap32, 4);
+ CFileMgr::Read(file, (char*)&cap24, 4);
+ CFileMgr::Read(file, (char*)&cap16, 4);
+ CFileMgr::Read(file, (char*)&cap8, 4);
+ CFileMgr::CloseFile(file);
+ }
+}
+
+bool
+CheckVideoCardCaps(void)
+{
+ uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888);
+ uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888);
+ uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555);
+ uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888);
+ uint32 fcap32, fcap24, fcap16, fcap8;
+ ReadVideoCardCapsFile(fcap32, fcap24, fcap16, fcap8);
+ return cap32 != fcap32 || cap24 != fcap24 || cap16 != fcap16 || cap8 != fcap8;
+}
+
+void
+WriteVideoCardCapsFile(void)
+{
+ uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888);
+ uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888);
+ uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555);
+ uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888);
+ int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "wb");
+ if (file != 0) {
+ CFileMgr::Write(file, (char*)&cap32, 4);
+ CFileMgr::Write(file, (char*)&cap24, 4);
+ CFileMgr::Write(file, (char*)&cap16, 4);
+ CFileMgr::Write(file, (char*)&cap8, 4);
+ CFileMgr::CloseFile(file);
+ }
+}
+
+bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
+void DoRWStuffEndOfFrame(void);
+
+void
+ConvertingTexturesScreen(uint32 num, uint32 count, const char *text)
+{
+ HandleExit();
+
+ CSprite2d *splash = LoadSplash(nil);
+ if (!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255))
+ return;
+
+ CSprite2d::SetRecipNearClip();
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+ DefinedState();
+
+ RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
+ splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255));
+
+ CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), SCREEN_SCALE_FROM_RIGHT(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(64, 64, 64, 255));
+ CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(255, 217, 106, 255));
+ CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(220.0f)), CRGBA(50, 50, 50, 210));
+
+ CFont::SetBackgroundOff();
+ CFont::SetPropOn();
+ CFont::SetScale(SCREEN_SCALE_X(0.45f), SCREEN_SCALE_Y(0.7f));
+ CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f));
+ CFont::SetJustifyOff();
+ CFont::SetColor(CRGBA(255, 217, 106, 255));
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text));
+ CFont::DrawFonts();
+ DoRWStuffEndOfFrame();
+}
+
+void
+DealWithTxdWriteError(uint32 num, uint32 count, const char *text)
+{
+ while (!RsGlobal.quit) {
+ ConvertingTexturesScreen(num, count, text);
+ CPad::UpdatePads();
+ if (CPad::GetPad(0)->GetEscapeJustDown())
+ break;
+ }
+ RsGlobal.quit = false;
+ LoadingScreen(nil, nil, nil);
+ RsGlobal.quit = true;
+}
+
+bool
+CreateTxdImageForVideoCard()
+{
+ uint8 *buf = new uint8[CDSTREAM_SECTOR_SIZE];
+ CDirectory *pDir = new CDirectory(TXDSTORESIZE);
+ CDirectory::DirectoryInfo dirInfo;
+
+ CStreaming::FlushRequestList();
+
+ RwFileFunctions *filesys = RwOsGetFileInterface();
+
+ RwStream *img = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMWRITE, "models\\txd.img");
+ if (img == nil) {
+ if (_dwOperatingSystemVersion == OS_WINNT || _dwOperatingSystemVersion == OS_WIN2000 || _dwOperatingSystemVersion == OS_WINXP) {
+ DealWithTxdWriteError(0, TXDSTORESIZE, "CVT_CRT");
+ delete []buf;
+ delete pDir;
+ }
+ return false;
+ }
+
+ int32 i;
+ for (i = 0; i < TXDSTORESIZE; i++) {
+ ConvertingTexturesScreen(i, TXDSTORESIZE, "CVT_MSG");
+
+ if (CTxdStore::GetSlot(i) != nil && CStreaming::IsObjectInCdImage(i + STREAM_OFFSET_TXD)) {
+ CStreaming::RequestTxd(i, STREAMFLAGS_KEEP_IN_MEMORY);
+ CStreaming::RequestModelStream(0);
+ CStreaming::FlushChannels();
+
+ char filename[64];
+ sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i));
+
+ if (CTxdStore::GetSlot(i)->texDict) {
+ int32 pos = filesys->rwftell(img->Type.file.fpFile);
+
+ if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) {
+ DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR");
+ RwStreamClose(img, nil);
+ delete []buf;
+ delete pDir;
+ CStreaming::RemoveTxd(i);
+ return false;
+ }
+
+ int32 size = filesys->rwftell(img->Type.file.fpFile) - pos;
+ int32 num = size % CDSTREAM_SECTOR_SIZE;
+
+ size /= CDSTREAM_SECTOR_SIZE;
+ if (num != 0) {
+ size++;
+ num = CDSTREAM_SECTOR_SIZE - num;
+ RwStreamWrite(img, buf, num);
+ }
+
+ dirInfo.offset = pos / CDSTREAM_SECTOR_SIZE;
+ dirInfo.size = size;
+ strncpy(dirInfo.name, filename, sizeof(dirInfo.name));
+ pDir->AddItem(dirInfo);
+ CStreaming::RemoveTxd(i);
+ }
+ CStreaming::FlushRequestList();
+ }
+ }
+
+ RwStreamClose(img, nil);
+ delete []buf;
+
+ if (!pDir->WriteDirFile("models\\txd.dir")) {
+ DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR");
+ delete pDir;
+ return false;
+ }
+
+ delete pDir;
+
+ WriteVideoCardCapsFile();
+ return true;
+}
+#endif // GTA_PC
+
STARTPATCHES
InjectHook(0x592380, RwTextureGtaStreamRead, PATCH_JUMP);
InjectHook(0x5924A0, RwTexDictionaryGtaStreamRead, PATCH_JUMP);
InjectHook(0x592550, RwTexDictionaryGtaStreamRead1, PATCH_JUMP);
InjectHook(0x592650, RwTexDictionaryGtaStreamRead2, PATCH_JUMP);
+
+ InjectHook(0x5926C0, ReadVideoCardCapsFile, PATCH_JUMP);
+ InjectHook(0x592740, CheckVideoCardCaps, PATCH_JUMP);
+ InjectHook(0x5927D0, WriteVideoCardCapsFile, PATCH_JUMP);
+ InjectHook(0x592880, ConvertingTexturesScreen, PATCH_JUMP);
+ InjectHook(0x592BF0, DealWithTxdWriteError, PATCH_JUMP);
+ InjectHook(0x592C70, CreateTxdImageForVideoCard, PATCH_JUMP);
ENDPATCHES
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index aeb7afe5..02092a30 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -1,14 +1,14 @@
#include "common.h"
#include "patcher.h"
#include "Stats.h"
-
-WRAPPER void CStats::SaveStats(uint8 *buf, uint32 *size) { EAXJMP(0x4ab3e0); }
+#include "Text.h"
+#include "World.h"
int32 &CStats::DaysPassed = *(int32*)0x8F2BB8;
int32 &CStats::HeadsPopped = *(int32*)0x8F647C;
-bool& CStats::CommercialPassed = *(bool*)0x8F4334;
-bool& CStats::IndustrialPassed = *(bool*)0x8E2A68;
-bool& CStats::SuburbanPassed = *(bool*)0x8F2740;
+int32& CStats::CommercialPassed = *(int32*)0x8F4334;
+int32& CStats::IndustrialPassed = *(int32*)0x8E2A68;
+int32& CStats::SuburbanPassed = *(int32*)0x8F2740;
int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C;
int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50;
int32 &CStats::HelisDestroyed = *(int32*)0x8E2A64;
@@ -48,7 +48,7 @@ int32& CStats::LongestFlightInDodo = *(int32*)0x8F5FE4;
int32& CStats::TimeTakenDefuseMission = *(int32*)0x880E24;
int32& CStats::TotalNumberKillFrenzies = *(int32*)0x8E2884;
int32& CStats::TotalNumberMissions = *(int32*)0x8E2820;
-int32& CStats::ShotsMade = *(int32*)0x8E2BE8;
+int32& CStats::RoundsFiredByPlayer = *(int32*)0x8E2BE8;
int32& CStats::KgsOfExplosivesUsed = *(int32*)0x8F2510;
int32& CStats::InstantHitsFiredByPlayer = *(int32*)0x943070;
int32& CStats::InstantHitsHitByPlayer = *(int32*)0x95CB8C;
@@ -62,7 +62,7 @@ void CStats::Init()
{
PeopleKilledByOthers = 0;
PeopleKilledByPlayer = 0;
- ShotsMade = 0;
+ RoundsFiredByPlayer = 0;
CarsExploded = 0;
HelisDestroyed = 0;
ProgressMade = 0;
@@ -200,6 +200,229 @@ void CStats::SetTotalNumberMissions(int32 total)
TotalNumberMissions = total;
}
+wchar *CStats::FindCriminalRatingString()
+{
+ int rating = FindCriminalRatingNumber();
+
+ if (rating < 10) return TheText.Get("RATNG1");
+ if (rating < 25) return TheText.Get("RATNG2");
+ if (rating < 70) return TheText.Get("RATNG3");
+ if (rating < 150) return TheText.Get("RATNG4");
+ if (rating < 250) return TheText.Get("RATNG5");
+ if (rating < 450) return TheText.Get("RATNG6");
+ if (rating < 700) return TheText.Get("RATNG7");
+ if (rating < 1000) return TheText.Get("RATNG8");
+ if (rating < 1400) return TheText.Get("RATNG9");
+ if (rating < 1900) return TheText.Get("RATNG10");
+ if (rating < 2500) return TheText.Get("RATNG11");
+ if (rating < 3200) return TheText.Get("RATNG12");
+ if (rating < 4000) return TheText.Get("RATNG13");
+ if (rating < 5000) return TheText.Get("RATNG14");
+ return TheText.Get("RATNG15");
+}
+
+int32 CStats::FindCriminalRatingNumber()
+{
+ int32 rating;
+
+ rating = FiresExtinguished + 10 * HighestLevelAmbulanceMission + CriminalsCaught + LivesSavedWithAmbulance
+ + 30 * HelisDestroyed + TotalLegitimateKills - 3 * TimesArrested - 3 * TimesDied
+ + CWorld::Players[CWorld::PlayerInFocus].m_nMoney / 5000;
+ if (rating <= 0) rating = 0;
+
+ if (InstantHitsFiredByPlayer > 100)
+ rating += (float)CStats::InstantHitsHitByPlayer / (float)CStats::InstantHitsFiredByPlayer * 500.0f;
+ if (TotalProgressInGame)
+ rating += (float)CStats::ProgressMade / (float)CStats::TotalProgressInGame * 1000.0f;
+ if (!IndustrialPassed && rating >= 3521)
+ rating = 3521;
+ if (!CommercialPassed && rating >= 4552)
+ rating = 4552;
+ return rating;
+}
+
+void CStats::SaveStats(uint8 *buf, uint32 *size)
+{
+ CheckPointReachedSuccessfully();
+ uint8 *buf_start = buf;
+ *size = sizeof(PeopleKilledByPlayer) +
+ sizeof(PeopleKilledByOthers) +
+ sizeof(CarsExploded) +
+ sizeof(RoundsFiredByPlayer) +
+ sizeof(PedsKilledOfThisType) +
+ sizeof(HelisDestroyed) +
+ sizeof(ProgressMade) +
+ sizeof(TotalProgressInGame) +
+ sizeof(KgsOfExplosivesUsed) +
+ sizeof(InstantHitsFiredByPlayer) +
+ sizeof(InstantHitsHitByPlayer) +
+ sizeof(CarsCrushed) +
+ sizeof(HeadsPopped) +
+ sizeof(TimesArrested) +
+ sizeof(TimesDied) +
+ sizeof(DaysPassed) +
+ sizeof(mmRain) +
+ sizeof(MaximumJumpDistance) +
+ sizeof(MaximumJumpHeight) +
+ sizeof(MaximumJumpFlips) +
+ sizeof(MaximumJumpSpins) +
+ sizeof(BestStuntJump) +
+ sizeof(NumberOfUniqueJumpsFound) +
+ sizeof(TotalNumberOfUniqueJumps) +
+ sizeof(MissionsGiven) +
+ sizeof(MissionsPassed) +
+ sizeof(PassengersDroppedOffWithTaxi) +
+ sizeof(MoneyMadeWithTaxi) +
+ sizeof(IndustrialPassed) +
+ sizeof(CommercialPassed) +
+ sizeof(SuburbanPassed) +
+ sizeof(ElBurroTime) +
+ sizeof(DistanceTravelledOnFoot) +
+ sizeof(DistanceTravelledInVehicle) +
+ sizeof(Record4x4One) +
+ sizeof(Record4x4Two) +
+ sizeof(Record4x4Three) +
+ sizeof(Record4x4Mayhem) +
+ sizeof(LivesSavedWithAmbulance) +
+ sizeof(CriminalsCaught) +
+ sizeof(HighestLevelAmbulanceMission) +
+ sizeof(FiresExtinguished) +
+ sizeof(LongestFlightInDodo) +
+ sizeof(TimeTakenDefuseMission) +
+ sizeof(NumberKillFrenziesPassed) +
+ sizeof(TotalNumberKillFrenzies) +
+ sizeof(TotalNumberMissions) +
+ sizeof(FastestTimes) +
+ sizeof(HighestScores) +
+ sizeof(KillsSinceLastCheckpoint) +
+ sizeof(TotalLegitimateKills) +
+ sizeof(LastMissionPassedName);
+
+#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); buf += sizeof(data);
+ CopyToBuf(buf, PeopleKilledByPlayer);
+ CopyToBuf(buf, PeopleKilledByOthers);
+ CopyToBuf(buf, CarsExploded);
+ CopyToBuf(buf, RoundsFiredByPlayer);
+ CopyToBuf(buf, PedsKilledOfThisType);
+ CopyToBuf(buf, HelisDestroyed);
+ CopyToBuf(buf, ProgressMade);
+ CopyToBuf(buf, TotalProgressInGame);
+ CopyToBuf(buf, KgsOfExplosivesUsed);
+ CopyToBuf(buf, InstantHitsFiredByPlayer);
+ CopyToBuf(buf, InstantHitsHitByPlayer);
+ CopyToBuf(buf, CarsCrushed);
+ CopyToBuf(buf, HeadsPopped);
+ CopyToBuf(buf, TimesArrested);
+ CopyToBuf(buf, TimesDied);
+ CopyToBuf(buf, DaysPassed);
+ CopyToBuf(buf, mmRain);
+ CopyToBuf(buf, MaximumJumpDistance);
+ CopyToBuf(buf, MaximumJumpHeight);
+ CopyToBuf(buf, MaximumJumpFlips);
+ CopyToBuf(buf, MaximumJumpSpins);
+ CopyToBuf(buf, BestStuntJump);
+ CopyToBuf(buf, NumberOfUniqueJumpsFound);
+ CopyToBuf(buf, TotalNumberOfUniqueJumps);
+ CopyToBuf(buf, MissionsGiven);
+ CopyToBuf(buf, MissionsPassed);
+ CopyToBuf(buf, PassengersDroppedOffWithTaxi);
+ CopyToBuf(buf, MoneyMadeWithTaxi);
+ CopyToBuf(buf, IndustrialPassed);
+ CopyToBuf(buf, CommercialPassed);
+ CopyToBuf(buf, SuburbanPassed);
+ CopyToBuf(buf, ElBurroTime);
+ CopyToBuf(buf, DistanceTravelledOnFoot);
+ CopyToBuf(buf, DistanceTravelledInVehicle);
+ CopyToBuf(buf, Record4x4One);
+ CopyToBuf(buf, Record4x4Two);
+ CopyToBuf(buf, Record4x4Three);
+ CopyToBuf(buf, Record4x4Mayhem);
+ CopyToBuf(buf, LivesSavedWithAmbulance);
+ CopyToBuf(buf, CriminalsCaught);
+ CopyToBuf(buf, HighestLevelAmbulanceMission);
+ CopyToBuf(buf, FiresExtinguished);
+ CopyToBuf(buf, LongestFlightInDodo);
+ CopyToBuf(buf, TimeTakenDefuseMission);
+ CopyToBuf(buf, NumberKillFrenziesPassed);
+ CopyToBuf(buf, TotalNumberKillFrenzies);
+ CopyToBuf(buf, TotalNumberMissions);
+ CopyToBuf(buf, FastestTimes);
+ CopyToBuf(buf, HighestScores);
+ CopyToBuf(buf, KillsSinceLastCheckpoint);
+ CopyToBuf(buf, TotalLegitimateKills);
+ CopyToBuf(buf, LastMissionPassedName);
+
+ assert(buf - buf_start == *size);
+#undef CopyToBuf
+}
+
+void CStats::LoadStats(uint8 *buf, uint32 size)
+{
+ uint8* buf_start = buf;
+
+#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); buf += sizeof(data);
+
+ CopyFromBuf(buf, PeopleKilledByPlayer);
+ CopyFromBuf(buf, PeopleKilledByOthers);
+ CopyFromBuf(buf, CarsExploded);
+ CopyFromBuf(buf, RoundsFiredByPlayer);
+ CopyFromBuf(buf, PedsKilledOfThisType);
+ CopyFromBuf(buf, HelisDestroyed);
+ CopyFromBuf(buf, ProgressMade);
+ CopyFromBuf(buf, TotalProgressInGame);
+ CopyFromBuf(buf, KgsOfExplosivesUsed);
+ CopyFromBuf(buf, InstantHitsFiredByPlayer);
+ CopyFromBuf(buf, InstantHitsHitByPlayer);
+ CopyFromBuf(buf, CarsCrushed);
+ CopyFromBuf(buf, HeadsPopped);
+ CopyFromBuf(buf, TimesArrested);
+ CopyFromBuf(buf, TimesDied);
+ CopyFromBuf(buf, DaysPassed);
+ CopyFromBuf(buf, mmRain);
+ CopyFromBuf(buf, MaximumJumpDistance);
+ CopyFromBuf(buf, MaximumJumpHeight);
+ CopyFromBuf(buf, MaximumJumpFlips);
+ CopyFromBuf(buf, MaximumJumpSpins);
+ CopyFromBuf(buf, BestStuntJump);
+ CopyFromBuf(buf, NumberOfUniqueJumpsFound);
+ CopyFromBuf(buf, TotalNumberOfUniqueJumps);
+ CopyFromBuf(buf, MissionsGiven);
+ CopyFromBuf(buf, MissionsPassed);
+ CopyFromBuf(buf, PassengersDroppedOffWithTaxi);
+ CopyFromBuf(buf, MoneyMadeWithTaxi);
+ CopyFromBuf(buf, IndustrialPassed);
+ CopyFromBuf(buf, CommercialPassed);
+ CopyFromBuf(buf, SuburbanPassed);
+ CopyFromBuf(buf, ElBurroTime);
+ CopyFromBuf(buf, DistanceTravelledOnFoot);
+ CopyFromBuf(buf, DistanceTravelledInVehicle);
+ CopyFromBuf(buf, Record4x4One);
+ CopyFromBuf(buf, Record4x4Two);
+ CopyFromBuf(buf, Record4x4Three);
+ CopyFromBuf(buf, Record4x4Mayhem);
+ CopyFromBuf(buf, LivesSavedWithAmbulance);
+ CopyFromBuf(buf, CriminalsCaught);
+ CopyFromBuf(buf, HighestLevelAmbulanceMission);
+ CopyFromBuf(buf, FiresExtinguished);
+ CopyFromBuf(buf, LongestFlightInDodo);
+ CopyFromBuf(buf, TimeTakenDefuseMission);
+ CopyFromBuf(buf, NumberKillFrenziesPassed);
+ CopyFromBuf(buf, TotalNumberKillFrenzies);
+ CopyFromBuf(buf, TotalNumberMissions);
+ CopyFromBuf(buf, FastestTimes);
+ CopyFromBuf(buf, HighestScores);
+ CopyFromBuf(buf, KillsSinceLastCheckpoint);
+ CopyFromBuf(buf, TotalLegitimateKills);
+ CopyFromBuf(buf, LastMissionPassedName);
+
+ assert(buf - buf_start == size);
+#undef CopyFromBuf
+}
+
STARTPATCHES
InjectHook(0x48C5A3, CStats::Init, PATCH_JUMP); // CGame::ReInitGameObjectVariables
+ InjectHook(0x4AB3E0, CStats::SaveStats, PATCH_JUMP);
+ InjectHook(0x4AB670, CStats::LoadStats, PATCH_JUMP);
+ InjectHook(0x4AB090, CStats::FindCriminalRatingString, PATCH_JUMP);
+ InjectHook(0x4AB2A0, CStats::FindCriminalRatingNumber, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 029b2307..ac3259f9 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -11,9 +11,9 @@ public:
};
static int32 &DaysPassed;
static int32 &HeadsPopped;
- static bool& CommercialPassed;
- static bool& IndustrialPassed;
- static bool& SuburbanPassed;
+ static int32& CommercialPassed;
+ static int32& IndustrialPassed;
+ static int32& SuburbanPassed;
static int32 &NumberKillFrenziesPassed;
static int32 &PeopleKilledByOthers;
static int32 &HelisDestroyed;
@@ -53,7 +53,7 @@ public:
static int32 &TimeTakenDefuseMission;
static int32 &TotalNumberKillFrenzies;
static int32 &TotalNumberMissions;
- static int32 &ShotsMade;
+ static int32 &RoundsFiredByPlayer;
static int32 &KgsOfExplosivesUsed;
static int32 &InstantHitsFiredByPlayer;
static int32 &InstantHitsHitByPlayer;
@@ -64,24 +64,27 @@ public:
static int32(&HighestScores)[TOTAL_HIGHEST_SCORES];
public:
+ static void Init(void);
static void RegisterFastestTime(int32, int32);
static void RegisterHighestScore(int32, int32);
- static void AnotherKillFrenzyPassed();
- static void AnotherLifeSavedWithAmbulance();
- static void AnotherCriminalCaught();
- static void RegisterLevelAmbulanceMission(int32);
- static void AnotherFireExtinguished();
+ static void RegisterElBurroTime(int32);
static void Register4x4OneTime(int32);
static void Register4x4TwoTime(int32);
static void Register4x4ThreeTime(int32);
static void Register4x4MayhemTime(int32);
+ static void AnotherLifeSavedWithAmbulance();
+ static void AnotherCriminalCaught();
+ static void RegisterLevelAmbulanceMission(int32);
+ static void AnotherFireExtinguished();
+ static wchar *FindCriminalRatingString();
static void RegisterLongestFlightInDodo(int32);
static void RegisterTimeTakenDefuseMission(int32);
+ static void AnotherKillFrenzyPassed();
static void SetTotalNumberKillFrenzies(int32);
static void SetTotalNumberMissions(int32);
- static void CheckPointReachedUnsuccessfully() { KillsSinceLastCheckpoint = 0; };
static void CheckPointReachedSuccessfully() { TotalLegitimateKills += KillsSinceLastCheckpoint; KillsSinceLastCheckpoint = 0; };
- static void RegisterElBurroTime(int32);
+ static void CheckPointReachedUnsuccessfully() { KillsSinceLastCheckpoint = 0; };
+ static int32 FindCriminalRatingNumber();
static void SaveStats(uint8 *buf, uint32 *size);
- static void Init(void);
+ static void LoadStats(uint8 *buf, uint32 size);
};
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 4a0230ce..d64569b3 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -56,6 +56,8 @@ WRAPPER void CWorld::FindMissionEntitiesIntersectingCube(const CVector&, const C
WRAPPER void CWorld::ClearCarsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B50E0); }
WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B52B0); }
WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); }
+WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); }
+WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); }
void
CWorld::Initialise()
diff --git a/src/core/World.h b/src/core/World.h
index c4103eb2..07e7889f 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -132,6 +132,7 @@ public:
static void SetAllCarsCanBeDamaged(bool);
static void ExtinguishAllCarFiresInArea(CVector, float);
static void SetCarsOnFire(float, float, float, float, CEntity*);
+ static void SetPedsOnFire(float, float, float, float, CEntity*);
static void Initialise();
static void AddParticles();
@@ -140,6 +141,7 @@ public:
static void RepositionCertainDynamicObjects();
static void RemoveStaticObjects();
static void Process();
+ static void TriggerExplosion(const CVector &, float, float, CEntity*, bool);
};
extern CColPoint *gaTempSphereColPoints;
diff --git a/src/core/common.h b/src/core/common.h
index b58b93af..6ea88f2f 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -84,12 +84,14 @@ extern void **rwengine;
#define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (448)
#define DEFAULT_ASPECT_RATIO (4.0f/3.0f)
+#define DEFAULT_VIEWWINDOW (0.7f)
// game uses maximumWidth/Height, but this probably won't work
// with RW windowed mode
#define SCREEN_WIDTH ((float)RsGlobal.width)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
+#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f)))
// This scales from PS2 pixel coordinates to the real resolution
#define SCREEN_STRETCH_X(a) ((a) * (float) SCREEN_WIDTH / DEFAULT_SCREEN_WIDTH)
@@ -105,10 +107,8 @@ extern void **rwengine;
#ifdef ASPECT_RATIO_SCALE
#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"
diff --git a/src/core/config.h b/src/core/config.h
index f653f724..8dea3216 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -79,6 +79,7 @@ enum Config {
NUMPICKUPMESSAGES = 16,
NUMBULLETTRACES = 16,
NUMMBLURSTREAKS = 4,
+ NUMSKIDMARKS = 32,
NUMONSCREENTIMERENTRIES = 1,
NUMRADARBLIPS = 32,
@@ -125,7 +126,9 @@ enum Config {
NUM_GARAGE_STORED_CARS = 6,
- NUM_CRANES = 8
+ NUM_CRANES = 8,
+
+ NUM_EXPLOSIONS = 48,
};
// We'll use this once we're ready to become independent of the game
@@ -150,6 +153,7 @@ enum Config {
//#define MASTER
#if defined GTA_PS2
+# define GTA_PS2_STUFF
# define RANDOMSPLASH
#elif defined GTA_PC
# define GTA3_1_1_PATCH
diff --git a/src/core/main.cpp b/src/core/main.cpp
index fb5beee0..93e4c71c 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -1,6 +1,11 @@
#include "common.h"
+#include "rpmatfx.h"
+#include "rpskin.h"
+#include "rphanim.h"
+#include "rtbmp.h"
#include "patcher.h"
#include "main.h"
+#include "CdStream.h"
#include "General.h"
#include "RwHelper.h"
#include "Clouds.h"
@@ -52,9 +57,7 @@
#include "Debug.h"
#include "Console.h"
#include "timebars.h"
-
-#define DEFAULT_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f)))
-
+#include "GenericGameStorage.h"
GlobalScene &Scene = *(GlobalScene*)0x726768;
@@ -68,293 +71,68 @@ char *gString2 = (char*)0x878A40;
wchar *gUString = (wchar*)0x74B018;
wchar *gUString2 = (wchar*)0x6EDD70;
-bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8;
-
-
-char version_name[64];
float FramesPerSecond = 30.0f;
bool gbPrintShite = false;
bool &gbModelViewer = *(bool*)0x95CD93;
-bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
-bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
-void DoRWStuffEndOfFrame(void);
+int32 frameCount;
+
+RwRGBA gColourTop;
+
+bool gameAlreadyInitialised;
+
+float NumberOfChunksLoaded;
+#define TOTALNUMCHUNKS 73.0f
-void RenderScene(void);
-void RenderDebugShit(void);
-void RenderEffects(void);
-void Render2dStuff(void);
-void RenderMenus(void);
-void DoFade(void);
-void Render2dStuffAfterFade(void);
+bool g_SlowMode = false;
+char version_name[64];
-CSprite2d *LoadSplash(const char *name);
+void GameInit(void);
+void SystemInit(void);
+void TheGame(void);
extern void (*DebugMenuProcess)(void);
extern void (*DebugMenuRender)(void);
void DebugMenuInit(void);
void DebugMenuPopulate(void);
-void PrintGameVersion();
-
-RwRGBA gColourTop;
-
-void
-InitialiseGame(void)
-{
- LoadingScreen(nil, nil, "loadsc0");
- CGame::Initialise("DATA\\GTA3.DAT");
-}
-
-#ifndef MASTER
-void
-TheModelViewer(void)
-{
-#ifdef ASPECT_RATIO_SCALE
- CDraw::SetAspectRatio(CDraw::FindAspectRatio());
-#endif
- CAnimViewer::Update();
- CTimer::Update();
- SetLightsWithTimeOfDayColour(Scene.world);
- CRenderer::ConstructRenderList();
- DoRWStuffStartOfFrame(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(),
- CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
- 255);
-
- CSprite2d::InitPerFrame();
- CFont::InitPerFrame();
- DefinedState();
- CVisibilityPlugins::InitAlphaEntityList();
- CAnimViewer::Render();
- Render2dStuff();
- DoRWStuffEndOfFrame();
-}
-#endif
void
-Idle(void *arg)
+ValidateVersion()
{
-#ifdef ASPECT_RATIO_SCALE
- CDraw::SetAspectRatio(CDraw::FindAspectRatio());
-#endif
-
- CTimer::Update();
-
-#ifdef TIMEBARS
- tbInit();
-#endif
-
- CSprite2d::InitPerFrame();
- CFont::InitPerFrame();
-
- // We're basically merging FrontendIdle and Idle (just like TheGame on PS2)
-#ifdef PS2_SAVE_DIALOG
- // Only exists on PC FrontendIdle, probably some PS2 bug fix
- if (FrontEndMenuManager.m_bMenuActive)
- CSprite2d::SetRecipNearClip();
-
- if (FrontEndMenuManager.m_bGameNotLoaded) {
- CPad::UpdatePads();
- FrontEndMenuManager.Process();
- } else {
- CPointLights::InitPerFrame();
-#ifdef TIMEBARS
- tbStartTimer(0, "CGame::Process");
-#endif
- CGame::Process();
-#ifdef TIMEBARS
- tbEndTimer("CGame::Process");
- tbStartTimer(0, "DMAudio.Service");
-#endif
- DMAudio.Service();
-
-#ifdef TIMEBARS
- tbEndTimer("DMAudio.Service");
-#endif
- }
-
- if (RsGlobal.quit)
- return;
-#else
- CPointLights::InitPerFrame();
-#ifdef TIMEBARS
- tbStartTimer(0, "CGame::Process");
-#endif
- CGame::Process();
-#ifdef TIMEBARS
- tbEndTimer("CGame::Process");
- tbStartTimer(0, "DMAudio.Service");
-#endif
-
- DMAudio.Service();
-
-#ifdef TIMEBARS
- tbEndTimer("DMAudio.Service");
-#endif
-#endif
-
- if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){
- FrontEndMenuManager.m_bStartGameLoading = true;
- FrontEndMenuManager.m_bLoadingSavedGame = false;
- return;
- }
-
- if(FrontEndMenuManager.m_bStartGameLoading || b_FoundRecentSavedGameWantToLoad)
- return;
-
- SetLightsWithTimeOfDayColour(Scene.world);
-
- if(arg == nil)
- return;
-
- if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) &&
- TheCamera.GetScreenFadeStatus() != FADE_2){
-#ifdef GTA_PC
- if (!FrontEndMenuManager.m_bRenderGameInMenu) {
- // This is from SA, but it's nice for windowed mode
- RwV2d pos;
- pos.x = SCREEN_WIDTH / 2.0f;
- pos.y = SCREEN_HEIGHT / 2.0f;
- RsMouseSetPos(&pos);
- }
-#endif
-#ifdef TIMEBARS
- tbStartTimer(0, "CnstrRenderList");
-#endif
- CRenderer::ConstructRenderList();
-#ifdef TIMEBARS
- tbEndTimer("CnstrRenderList");
- tbStartTimer(0, "PreRender");
-#endif
- CRenderer::PreRender();
-#ifdef TIMEBARS
- tbEndTimer("PreRender");
-#endif
+ int32 file = CFileMgr::OpenFile("models\\coll\\peds.col", "rb");
+ char buff[128];
- if(CWeather::LightningFlash && !CCullZones::CamNoRain()){
- if(!DoRWStuffStartOfFrame_Horizon(255, 255, 255, 255, 255, 255, 255))
- return;
- }else{
- if(!DoRWStuffStartOfFrame_Horizon(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(),
- CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
- 255))
- return;
+ if ( file != -1 )
+ {
+ CFileMgr::Seek(file, 100, SEEK_SET);
+
+ for ( int i = 0; i < 128; i++ )
+ {
+ CFileMgr::Read(file, &buff[i], sizeof(char));
+ buff[i] -= 23;
+ if ( buff[i] == '\0' )
+ break;
+ CFileMgr::Seek(file, 99, SEEK_CUR);
}
-
- DefinedState();
-
- // BUG. This has to be done BEFORE RwCameraBeginUpdate
- RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip());
- RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart());
-
-#ifdef TIMEBARS
- tbStartTimer(0, "RenderScene");
-#endif
- RenderScene();
-#ifdef TIMEBARS
- tbEndTimer("RenderScene");
-#endif
- RenderDebugShit();
- RenderEffects();
-
-#ifdef TIMEBARS
- tbStartTimer(0, "RenderMotionBlur");
-#endif
- if((TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) &&
- TheCamera.m_ScreenReductionPercentage > 0.0f)
- TheCamera.SetMotionBlurAlpha(150);
- TheCamera.RenderMotionBlur();
-#ifdef TIMEBARS
- tbEndTimer("RenderMotionBlur");
- tbStartTimer(0, "Render2dStuff");
-#endif
- Render2dStuff();
-#ifdef TIMEBARS
- tbEndTimer("Render2dStuff");
-#endif
- }else{
- float viewWindow = DEFAULT_VIEWWINDOW;
-#ifdef ASPECT_RATIO_SCALE
- CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
-#else
- CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO);
-#endif
- CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
- if(!RsCameraBeginUpdate(Scene.camera))
+
+ if ( !strncmp(buff, "grandtheftauto3", 15) )
+ {
+ strncpy(version_name, &buff[15], 64);
+ CFileMgr::CloseFile(file);
return;
+ }
}
-#ifdef PS2_SAVE_DIALOG
- if (FrontEndMenuManager.m_bMenuActive)
- DefinedState();
-#endif
-#ifdef TIMEBARS
- tbStartTimer(0, "RenderMenus");
-#endif
- RenderMenus();
-#ifdef TIMEBARS
- tbEndTimer("RenderMenus");
- tbStartTimer(0, "DoFade");
-#endif
- DoFade();
-#ifdef TIMEBARS
- tbEndTimer("DoFade");
- tbStartTimer(0, "Render2dStuff-Fade");
-#endif
- Render2dStuffAfterFade();
-#ifdef TIMEBARS
- tbEndTimer("Render2dStuff-Fade");
-#endif
- CCredits::Render();
-
-#ifdef TIMEBARS
- tbDisplay();
-#endif
-
- DoRWStuffEndOfFrame();
-
-// if(g_SlowMode)
-// ProcessSlowMode();
-}
-
-void
-FrontendIdle(void)
-{
-#ifdef ASPECT_RATIO_SCALE
- CDraw::SetAspectRatio(CDraw::FindAspectRatio());
-#endif
-
- CTimer::Update();
- CSprite2d::SetRecipNearClip(); // this should be on InitialiseRenderWare according to PS2 asm. seems like a bug fix
- CSprite2d::InitPerFrame();
- CFont::InitPerFrame();
- CPad::UpdatePads();
- FrontEndMenuManager.Process();
-
- if(RsGlobal.quit)
- return;
-
- float viewWindow = DEFAULT_VIEWWINDOW;
-#ifdef ASPECT_RATIO_SCALE
- CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
-#else
- CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO);
-#endif
- CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
- if(!RsCameraBeginUpdate(Scene.camera))
- return;
-
- DefinedState(); // seems redundant, but breaks resolution change.
- RenderMenus();
- DoFade();
- Render2dStuffAfterFade();
-// CFont::DrawFonts(); // redundant
- DoRWStuffEndOfFrame();
+ LoadingScreen("Invalid version", NULL, NULL);
+
+ while(true)
+ {
+ ;
+ }
}
bool
@@ -363,7 +141,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha);
CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha);
- CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO);
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
@@ -381,7 +159,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
bool
DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha)
{
- CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO);
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
@@ -394,17 +172,6 @@ DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16
return true;
}
-void
-DoRWStuffEndOfFrame(void)
-{
- CDebug::DisplayScreenStrings(); // custom
- CDebug::DebugDisplayTextBuffer();
- FlushObrsPrintfs();
- RwCameraEndUpdate(Scene.camera);
- RsCameraShowRaster(Scene.camera);
-}
-
-
// This is certainly a very useful function
void
DoRWRenderHorizon(void)
@@ -413,127 +180,6 @@ DoRWRenderHorizon(void)
}
void
-RenderScene(void)
-{
- CClouds::Render();
- DoRWRenderHorizon();
- CRenderer::RenderRoads();
- CCoronas::RenderReflections();
- RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
- CRenderer::RenderEverythingBarRoads();
- CRenderer::RenderBoats();
- DefinedState();
- CWaterLevel::RenderWater();
- CRenderer::RenderFadingInEntities();
- CRenderer::RenderVehiclesButNotBoats();
- CWeather::RenderRainStreaks();
-}
-
-void
-RenderDebugShit(void)
-{
- CTheScripts::RenderTheScriptDebugLines();
- if(gbShowCollisionLines)
- CRenderer::RenderCollisionLines();
-}
-
-void
-RenderEffects(void)
-{
- CGlass::Render();
- CWaterCannons::Render();
- CSpecialFX::Render();
- CShadows::RenderStaticShadows();
- CShadows::RenderStoredShadows();
- CSkidmarks::Render();
- CAntennas::Render();
- CRubbish::Render();
- CCoronas::Render();
- CParticle::Render();
- CPacManPickups::Render();
- CWeaponEffects::Render();
- CPointLights::RenderFogEffect();
- CMovingThings::Render();
- CRenderer::RenderFirstPersonVehicle();
-}
-
-void
-Render2dStuff(void)
-{
- RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
- RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
- RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
-
- CReplay::Display();
- CPickups::RenderPickUpText();
-
- if(TheCamera.m_WideScreenOn)
- TheCamera.DrawBordersForWideScreen();
-
- CPed *player = FindPlayerPed();
- int weaponType = 0;
- if(player)
- weaponType = player->GetWeapon()->m_eWeaponType;
-
- bool firstPersonWeapon = false;
- int cammode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
- if(cammode == CCam::MODE_SNIPER ||
- cammode == CCam::MODE_SNIPER_RUNABOUT ||
- cammode == CCam::MODE_ROCKETLAUNCHER ||
- cammode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT)
- firstPersonWeapon = true;
-
- // Draw black border for sniper and rocket launcher
- if((weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_ROCKETLAUNCHER) && firstPersonWeapon){
- CRGBA black(0, 0, 0, 255);
-
- // top and bottom strips
- if (weaponType == WEAPONTYPE_ROCKETLAUNCHER) {
- CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(180)), black);
- CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(170), SCREEN_WIDTH, SCREEN_HEIGHT), black);
- }
- else {
- CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(210)), black);
- CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(210), SCREEN_WIDTH, SCREEN_HEIGHT), black);
- }
- CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH / 2 - SCREEN_SCALE_X(210), SCREEN_HEIGHT), black);
- CSprite2d::DrawRect(CRect(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(210), 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), black);
- }
-
- MusicManager.DisplayRadioStationName();
- TheConsole.Display();
-/*
- if(CSceneEdit::m_bEditOn)
- CSceneEdit::Draw();
- else
-*/
- CHud::Draw();
- CUserDisplay::OnscnTimer.ProcessForDisplay();
- CMessages::Display();
- CDarkel::DrawMessages();
- CGarages::PrintMessages();
- CPad::PrintErrorMessage();
- CFont::DrawFonts();
-
- DebugMenuRender();
-}
-
-void
-RenderMenus(void)
-{
- if(FrontEndMenuManager.m_bMenuActive)
- FrontEndMenuManager.DrawFrontEnd();
-}
-
-bool &JustLoadedDontFadeInYet = *(bool*)0x95CDB4;
-bool &StillToFadeOut = *(bool*)0x95CD99;
-uint32 &TimeStartedCountingForFade = *(uint32*)0x9430EC;
-uint32 &TimeToStayFadedBeforeFadeOut = *(uint32*)0x611564;
-
-void
DoFade(void)
{
if(CTimer::GetIsPaused())
@@ -613,139 +259,95 @@ DoFade(void)
}
}
-float FramesPerSecondCounter;
-int32 FrameSamples;
-
-struct tZonePrint
-{
- char name[12];
- CRect rect;
-};
-
-tZonePrint ZonePrint[] =
-{
- { "suburban", CRect(-1639.4f, 1014.3f, -226.23f, -1347.9f) },
- { "comntop", CRect(-223.52f, 203.62f, 616.79f, -413.6f) },
- { "comnbtm", CRect(-227.24f, -413.6f, 620.51f, -911.84f) },
- { "comse", CRect( 200.35f, -911.84f, 620.51f, -1737.3f) },
- { "comsw", CRect(-223.52f, -911.84f, 200.35f, -1737.3f) },
- { "industsw", CRect( 744.05f, -473.0f, 1067.5f, -1331.5f) },
- { "industne", CRect( 1067.5f, 282.19f, 1915.3f, -473.0f) },
- { "industnw", CRect( 744.05f, 324.95f, 1067.5f, -473.0f) },
- { "industse", CRect( 1070.3f, -473.0f, 1918.1f, -1331.5f) },
- { "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
-};
-
-#ifndef MASTER
void
-DisplayGameDebugText()
+DoRWStuffEndOfFrame(void)
{
- static bool bDisplayPosn = false;
- static bool bDisplayRate = false;
+ CDebug::DisplayScreenStrings(); // custom
+ CDebug::DebugDisplayTextBuffer();
+ FlushObrsPrintfs();
+ RwCameraEndUpdate(Scene.camera);
+ RsCameraShowRaster(Scene.camera);
+}
+static RwBool
+PluginAttach(void)
+{
+ if( !RpWorldPluginAttach() )
{
- SETTWEAKPATH("GameDebugText");
- TWEAKBOOL(bDisplayPosn);
- TWEAKBOOL(bDisplayRate);
+ printf("Couldn't attach world plugin\n");
+
+ return FALSE;
}
-
-
- char str[200];
- wchar ustr[200];
- wchar ver[200];
-
- AsciiToUnicode(version_name, ver);
-
- CFont::SetPropOn();
- CFont::SetBackgroundOff();
- CFont::SetFontStyle(FONT_BANK);
- CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f));
- CFont::SetCentreOff();
- CFont::SetRightJustifyOff();
- CFont::SetWrapx(SCREEN_WIDTH);
- CFont::SetJustifyOff();
- CFont::SetBackGroundOnlyTextOff();
- CFont::SetColor(CRGBA(255, 108, 0, 255));
- CFont::PrintString(10.0f, 10.0f, ver);
-
- FrameSamples++;
- FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
- FramesPerSecond = FramesPerSecondCounter / FrameSamples;
- if ( FrameSamples > 30 )
+ if( !RpSkinPluginAttach() )
{
- FramesPerSecondCounter = 0.0f;
- FrameSamples = 0;
+ printf("Couldn't attach RpSkin plugin\n");
+
+ return FALSE;
}
-
- if ( !TheCamera.WorldViewerBeingUsed
- && CPad::GetPad(1)->GetSquare()
- && CPad::GetPad(1)->GetTriangle()
- && CPad::GetPad(1)->GetLeftShoulder2JustDown() )
+
+ if( !RpHAnimPluginAttach() )
{
- bDisplayPosn = !bDisplayPosn;
+ printf("Couldn't attach RpHAnim plugin\n");
+
+ return FALSE;
}
-
- if ( CPad::GetPad(1)->GetSquare()
- && CPad::GetPad(1)->GetTriangle()
- && CPad::GetPad(1)->GetRightShoulder2JustDown() )
+
+ if( !NodeNamePluginAttach() )
{
- bDisplayRate = !bDisplayRate;
+ printf("Couldn't attach node name plugin\n");
+
+ return FALSE;
}
- if ( bDisplayPosn || bDisplayRate )
+ if( !CVisibilityPlugins::PluginAttach() )
{
- CVector pos = FindPlayerCoors();
- int32 ZoneId = ARRAY_SIZE(ZonePrint)-1; // no zone
-
- for ( int32 i = 0; i < ARRAY_SIZE(ZonePrint)-1; i++ )
- {
- if ( pos.x > ZonePrint[i].rect.left
- && pos.x < ZonePrint[i].rect.right
- && pos.y > ZonePrint[i].rect.bottom
- && pos.y < ZonePrint[i].rect.top )
- {
- ZoneId = i;
- }
- }
-
- //NOTE: fps should be 30, but its 29 due to different fp2int conversion
- if ( bDisplayRate )
- sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, F-%d, %s", pos.x, pos.y, pos.z, (int32)FramesPerSecond, ZonePrint[ZoneId].name);
- else
- sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, %s", pos.x, pos.y, pos.z, ZonePrint[ZoneId].name);
-
- AsciiToUnicode(str, ustr);
+ printf("Couldn't attach visibility plugins\n");
- CFont::SetPropOff();
- CFont::SetBackgroundOff();
- CFont::SetScale(0.7f, 1.5f);
- CFont::SetCentreOff();
- CFont::SetRightJustifyOff();
- CFont::SetJustifyOff();
- CFont::SetBackGroundOnlyTextOff();
- CFont::SetWrapx(640.0f);
- CFont::SetFontStyle(FONT_HEADING);
+ return FALSE;
+ }
+
+ if( !RpAnimBlendPluginAttach() )
+ {
+ printf("Couldn't attach RpAnimBlend plugin\n");
- CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::PrintString(42.0f, 42.0f, ustr);
+ return FALSE;
+ }
+
+ if( !RpMatFXPluginAttach() )
+ {
+ printf("Couldn't attach RpMatFX plugin\n");
- CFont::SetColor(CRGBA(255, 108, 0, 255));
- CFont::PrintString(40.0f, 40.0f, ustr);
+ return FALSE;
}
+
+ return TRUE;
}
-#endif
-void
-Render2dStuffAfterFade(void)
+static RwBool
+Initialise3D(void *param)
{
-#ifndef MASTER
- DisplayGameDebugText();
- //PrintGameVersion();
-#endif
+ if (RsRwInitialise(param))
+ {
+ //
+ DebugMenuInit();
+ DebugMenuPopulate();
+ //
- CHud::DrawAfterFade();
- CFont::DrawFonts();
+ return CGame::InitialiseRenderWare();
+ }
+
+ return (FALSE);
+}
+
+static void
+Terminate3D(void)
+{
+ CGame::ShutdownRenderWare();
+
+ RsRwTerminate();
+
+ return;
}
CSprite2d splash;
@@ -796,8 +398,41 @@ DestroySplashScreen(void)
splashTxdId = -1;
}
-float NumberOfChunksLoaded;
-#define TOTALNUMCHUNKS 73.0f
+char*
+GetRandomSplashScreen(void)
+{
+ int index;
+ static int index2 = 0;
+ static char splashName[128];
+ static int splashIndex[24] = {
+ 25, 22, 4, 13,
+ 1, 21, 14, 16,
+ 10, 12, 5, 9,
+ 11, 18, 3, 2,
+ 19, 23, 7, 17,
+ 15, 6, 8, 20
+ };
+
+ index = splashIndex[4*index2 + CGeneral::GetRandomNumberInRange(0, 3)];
+ index2++;
+ if(index2 == 6)
+ index2 = 0;
+ sprintf(splashName, "loadsc%d", index);
+ return splashName;
+}
+
+char*
+GetLevelSplashScreen(int level)
+{
+ static char *splashScreens[4] = {
+ nil,
+ "splash1",
+ "splash2",
+ "splash3",
+ };
+
+ return splashScreens[level];
+}
void
ResetLoadingScreenBar()
@@ -820,8 +455,10 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
splash = LoadSplash(splashscreen);
+#ifndef GTA_PS2
if(RsGlobal.quit)
return;
+#endif
if(DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)){
CSprite2d::SetRecipNearClip();
@@ -914,131 +551,585 @@ LoadingIslandScreen(const char *levelName)
DoRWStuffEndOfFrame();
}
-char*
-GetLevelSplashScreen(int level)
-{
- static char *splashScreens[4] = {
- nil,
- "splash1",
- "splash2",
- "splash3",
- };
-
- return splashScreens[level];
+void
+ProcessSlowMode(void)
+{
+ int16 lX = CPad::GetPad(0)->NewState.LeftStickX;
+ int16 lY = CPad::GetPad(0)->NewState.LeftStickY;
+ int16 rX = CPad::GetPad(0)->NewState.RightStickX;
+ int16 rY = CPad::GetPad(0)->NewState.RightStickY;
+ int16 L1 = CPad::GetPad(0)->NewState.LeftShoulder1;
+ int16 L2 = CPad::GetPad(0)->NewState.LeftShoulder2;
+ int16 R1 = CPad::GetPad(0)->NewState.RightShoulder1;
+ int16 R2 = CPad::GetPad(0)->NewState.RightShoulder2;
+ int16 up = CPad::GetPad(0)->NewState.DPadUp;
+ int16 down = CPad::GetPad(0)->NewState.DPadDown;
+ int16 left = CPad::GetPad(0)->NewState.DPadLeft;
+ int16 right = CPad::GetPad(0)->NewState.DPadRight;
+ int16 start = CPad::GetPad(0)->NewState.Start;
+ int16 select = CPad::GetPad(0)->NewState.Select;
+ int16 square = CPad::GetPad(0)->NewState.Square;
+ int16 triangle = CPad::GetPad(0)->NewState.Triangle;
+ int16 cross = CPad::GetPad(0)->NewState.Cross;
+ int16 circle = CPad::GetPad(0)->NewState.Circle;
+ int16 L3 = CPad::GetPad(0)->NewState.LeftShock;
+ int16 R3 = CPad::GetPad(0)->NewState.RightShock;
+ int16 networktalk = CPad::GetPad(0)->NewState.NetworkTalk;
+ int16 stop = true;
+
+ do
+ {
+ if ( CPad::GetPad(1)->GetLeftShoulder1JustDown() || CPad::GetPad(1)->GetRightShoulder1() )
+ break;
+
+ if ( stop )
+ {
+ CTimer::Stop();
+ stop = false;
+ }
+
+ CPad::UpdatePads();
+
+ RwCameraBeginUpdate(Scene.camera);
+ RwCameraEndUpdate(Scene.camera);
+
+ if ( CPad::GetPad(1)->GetLeftShoulder1JustDown() || CPad::GetPad(1)->GetRightShoulder1() )
+ break;
+
+ } while (!CPad::GetPad(1)->GetRightShoulder1());
+
+
+ CPad::GetPad(0)->OldState.LeftStickX = lX;
+ CPad::GetPad(0)->OldState.LeftStickY = lY;
+ CPad::GetPad(0)->OldState.RightStickX = rX;
+ CPad::GetPad(0)->OldState.RightStickY = rY;
+ CPad::GetPad(0)->OldState.LeftShoulder1 = L1;
+ CPad::GetPad(0)->OldState.LeftShoulder2 = L2;
+ CPad::GetPad(0)->OldState.RightShoulder1 = R1;
+ CPad::GetPad(0)->OldState.RightShoulder2 = R2;
+ CPad::GetPad(0)->OldState.DPadUp = up;
+ CPad::GetPad(0)->OldState.DPadDown = down;
+ CPad::GetPad(0)->OldState.DPadLeft = left;
+ CPad::GetPad(0)->OldState.DPadRight = right;
+ CPad::GetPad(0)->OldState.Start = start;
+ CPad::GetPad(0)->OldState.Select = select;
+ CPad::GetPad(0)->OldState.Square = square;
+ CPad::GetPad(0)->OldState.Triangle = triangle;
+ CPad::GetPad(0)->OldState.Cross = cross;
+ CPad::GetPad(0)->OldState.Circle = circle;
+ CPad::GetPad(0)->OldState.LeftShock = L3;
+ CPad::GetPad(0)->OldState.RightShock = R3;
+ CPad::GetPad(0)->OldState.NetworkTalk = networktalk;
+ CPad::GetPad(0)->NewState.LeftStickX = lX;
+ CPad::GetPad(0)->NewState.LeftStickY = lY;
+ CPad::GetPad(0)->NewState.RightStickX = rX;
+ CPad::GetPad(0)->NewState.RightStickY = rY;
+ CPad::GetPad(0)->NewState.LeftShoulder1 = L1;
+ CPad::GetPad(0)->NewState.LeftShoulder2 = L2;
+ CPad::GetPad(0)->NewState.RightShoulder1 = R1;
+ CPad::GetPad(0)->NewState.RightShoulder2 = R2;
+ CPad::GetPad(0)->NewState.DPadUp = up;
+ CPad::GetPad(0)->NewState.DPadDown = down;
+ CPad::GetPad(0)->NewState.DPadLeft = left;
+ CPad::GetPad(0)->NewState.DPadRight = right;
+ CPad::GetPad(0)->NewState.Start = start;
+ CPad::GetPad(0)->NewState.Select = select;
+ CPad::GetPad(0)->NewState.Square = square;
+ CPad::GetPad(0)->NewState.Triangle = triangle;
+ CPad::GetPad(0)->NewState.Cross = cross;
+ CPad::GetPad(0)->NewState.Circle = circle;
+ CPad::GetPad(0)->NewState.LeftShock = L3;
+ CPad::GetPad(0)->NewState.RightShock = R3;
+ CPad::GetPad(0)->NewState.NetworkTalk = networktalk;
}
-char*
-GetRandomSplashScreen(void)
-{
- int index;
- static int index2 = 0;
- static char splashName[128];
- static int splashIndex[24] = {
- 25, 22, 4, 13,
- 1, 21, 14, 16,
- 10, 12, 5, 9,
- 11, 18, 3, 2,
- 19, 23, 7, 17,
- 15, 6, 8, 20
- };
- index = splashIndex[4*index2 + CGeneral::GetRandomNumberInRange(0, 3)];
- index2++;
- if(index2 == 6)
- index2 = 0;
- sprintf(splashName, "loadsc%d", index);
- return splashName;
-}
+float FramesPerSecondCounter;
+int32 FrameSamples;
-#include "rwcore.h"
-#include "rpworld.h"
-#include "rpmatfx.h"
-#include "rpskin.h"
-#include "rphanim.h"
-#include "rtbmp.h"
+struct tZonePrint
+{
+ char name[12];
+ CRect rect;
+};
-_TODO("temp, move this includes out of here")
+tZonePrint ZonePrint[] =
+{
+ { "suburban", CRect(-1639.4f, 1014.3f, -226.23f, -1347.9f) },
+ { "comntop", CRect(-223.52f, 203.62f, 616.79f, -413.6f) },
+ { "comnbtm", CRect(-227.24f, -413.6f, 620.51f, -911.84f) },
+ { "comse", CRect( 200.35f, -911.84f, 620.51f, -1737.3f) },
+ { "comsw", CRect(-223.52f, -911.84f, 200.35f, -1737.3f) },
+ { "industsw", CRect( 744.05f, -473.0f, 1067.5f, -1331.5f) },
+ { "industne", CRect( 1067.5f, 282.19f, 1915.3f, -473.0f) },
+ { "industnw", CRect( 744.05f, 324.95f, 1067.5f, -473.0f) },
+ { "industse", CRect( 1070.3f, -473.0f, 1918.1f, -1331.5f) },
+ { "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
+};
-static RwBool
-PluginAttach(void)
+#ifndef MASTER
+void
+DisplayGameDebugText()
{
- if( !RpWorldPluginAttach() )
+ static bool bDisplayPosn = false;
+ static bool bDisplayRate = false;
+
{
- printf("Couldn't attach world plugin\n");
-
- return FALSE;
+ SETTWEAKPATH("GameDebugText");
+ TWEAKBOOL(bDisplayPosn);
+ TWEAKBOOL(bDisplayRate);
}
+
+
+ char str[200];
+ wchar ustr[200];
+ wchar ver[200];
- if( !RpSkinPluginAttach() )
- {
- printf("Couldn't attach RpSkin plugin\n");
-
- return FALSE;
- }
+ AsciiToUnicode(version_name, ver);
+
+ CFont::SetPropOn();
+ CFont::SetBackgroundOff();
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f));
+ CFont::SetCentreOff();
+ CFont::SetRightJustifyOff();
+ CFont::SetWrapx(SCREEN_WIDTH);
+ CFont::SetJustifyOff();
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetColor(CRGBA(255, 108, 0, 255));
+ CFont::PrintString(10.0f, 10.0f, ver);
+
+ FrameSamples++;
+ FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
+ FramesPerSecond = FramesPerSecondCounter / FrameSamples;
- if( !RpHAnimPluginAttach() )
+ if ( FrameSamples > 30 )
{
- printf("Couldn't attach RpHAnim plugin\n");
-
- return FALSE;
+ FramesPerSecondCounter = 0.0f;
+ FrameSamples = 0;
}
-
- if( !NodeNamePluginAttach() )
+
+ if ( !TheCamera.WorldViewerBeingUsed
+ && CPad::GetPad(1)->GetSquare()
+ && CPad::GetPad(1)->GetTriangle()
+ && CPad::GetPad(1)->GetLeftShoulder2JustDown() )
{
- printf("Couldn't attach node name plugin\n");
-
- return FALSE;
+ bDisplayPosn = !bDisplayPosn;
}
-
- if( !CVisibilityPlugins::PluginAttach() )
+
+ if ( CPad::GetPad(1)->GetSquare()
+ && CPad::GetPad(1)->GetTriangle()
+ && CPad::GetPad(1)->GetRightShoulder2JustDown() )
{
- printf("Couldn't attach visibility plugins\n");
-
- return FALSE;
+ bDisplayRate = !bDisplayRate;
}
- if( !RpAnimBlendPluginAttach() )
+ if ( bDisplayPosn || bDisplayRate )
{
- printf("Couldn't attach RpAnimBlend plugin\n");
+ CVector pos = FindPlayerCoors();
+ int32 ZoneId = ARRAY_SIZE(ZonePrint)-1; // no zone
- return FALSE;
- }
-
- if( !RpMatFXPluginAttach() )
- {
- printf("Couldn't attach RpMatFX plugin\n");
+ for ( int32 i = 0; i < ARRAY_SIZE(ZonePrint)-1; i++ )
+ {
+ if ( pos.x > ZonePrint[i].rect.left
+ && pos.x < ZonePrint[i].rect.right
+ && pos.y > ZonePrint[i].rect.bottom
+ && pos.y < ZonePrint[i].rect.top )
+ {
+ ZoneId = i;
+ }
+ }
+
+ //NOTE: fps should be 30, but its 29 due to different fp2int conversion
+ if ( bDisplayRate )
+ sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, F-%d, %s", pos.x, pos.y, pos.z, (int32)FramesPerSecond, ZonePrint[ZoneId].name);
+ else
+ sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, %s", pos.x, pos.y, pos.z, ZonePrint[ZoneId].name);
- return FALSE;
+ AsciiToUnicode(str, ustr);
+
+ CFont::SetPropOff();
+ CFont::SetBackgroundOff();
+ CFont::SetScale(0.7f, 1.5f);
+ CFont::SetCentreOff();
+ CFont::SetRightJustifyOff();
+ CFont::SetJustifyOff();
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetWrapx(640.0f);
+ CFont::SetFontStyle(FONT_HEADING);
+
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
+ CFont::PrintString(42.0f, 42.0f, ustr);
+
+ CFont::SetColor(CRGBA(255, 108, 0, 255));
+ CFont::PrintString(40.0f, 40.0f, ustr);
}
+}
+#endif
- return TRUE;
+void
+RenderScene(void)
+{
+ CClouds::Render();
+ DoRWRenderHorizon();
+ CRenderer::RenderRoads();
+ CCoronas::RenderReflections();
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
+ CRenderer::RenderEverythingBarRoads();
+ CRenderer::RenderBoats();
+ DefinedState();
+ CWaterLevel::RenderWater();
+ CRenderer::RenderFadingInEntities();
+ CRenderer::RenderVehiclesButNotBoats();
+ CWeather::RenderRainStreaks();
}
-static RwBool
-Initialise3D(void *param)
+void
+RenderDebugShit(void)
{
- if (RsRwInitialise(param))
- {
- //
- DebugMenuInit();
- DebugMenuPopulate();
- //
+ CTheScripts::RenderTheScriptDebugLines();
+ if(gbShowCollisionLines)
+ CRenderer::RenderCollisionLines();
+}
- return CGame::InitialiseRenderWare();
+void
+RenderEffects(void)
+{
+ CGlass::Render();
+ CWaterCannons::Render();
+ CSpecialFX::Render();
+ CShadows::RenderStaticShadows();
+ CShadows::RenderStoredShadows();
+ CSkidmarks::Render();
+ CAntennas::Render();
+ CRubbish::Render();
+ CCoronas::Render();
+ CParticle::Render();
+ CPacManPickups::Render();
+ CWeaponEffects::Render();
+ CPointLights::RenderFogEffect();
+ CMovingThings::Render();
+ CRenderer::RenderFirstPersonVehicle();
+}
+
+void
+Render2dStuff(void)
+{
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
+
+ CReplay::Display();
+ CPickups::RenderPickUpText();
+
+ if(TheCamera.m_WideScreenOn)
+ TheCamera.DrawBordersForWideScreen();
+
+ CPed *player = FindPlayerPed();
+ int weaponType = 0;
+ if(player)
+ weaponType = player->GetWeapon()->m_eWeaponType;
+
+ bool firstPersonWeapon = false;
+ int cammode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
+ if(cammode == CCam::MODE_SNIPER ||
+ cammode == CCam::MODE_SNIPER_RUNABOUT ||
+ cammode == CCam::MODE_ROCKETLAUNCHER ||
+ cammode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT)
+ firstPersonWeapon = true;
+
+ // Draw black border for sniper and rocket launcher
+ if((weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_ROCKETLAUNCHER) && firstPersonWeapon){
+ CRGBA black(0, 0, 0, 255);
+
+ // top and bottom strips
+ if (weaponType == WEAPONTYPE_ROCKETLAUNCHER) {
+ CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(180)), black);
+ CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(170), SCREEN_WIDTH, SCREEN_HEIGHT), black);
+ }
+ else {
+ CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(210)), black);
+ CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(210), SCREEN_WIDTH, SCREEN_HEIGHT), black);
+ }
+ CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH / 2 - SCREEN_SCALE_X(210), SCREEN_HEIGHT), black);
+ CSprite2d::DrawRect(CRect(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(210), 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), black);
}
- return (FALSE);
+ MusicManager.DisplayRadioStationName();
+ TheConsole.Display();
+/*
+ if(CSceneEdit::m_bEditOn)
+ CSceneEdit::Draw();
+ else
+*/
+ CHud::Draw();
+ CUserDisplay::OnscnTimer.ProcessForDisplay();
+ CMessages::Display();
+ CDarkel::DrawMessages();
+ CGarages::PrintMessages();
+ CPad::PrintErrorMessage();
+ CFont::DrawFonts();
+
+ DebugMenuRender();
+}
+
+void
+RenderMenus(void)
+{
+#ifdef PS2
+ if (FrontEndMenuManager.m_bWantToDraw)
+ {
+ gMainHeap.PushMemId(_TODOCONST(17));
+ FrontEndMenuManager.DrawFrontEnd();
+ gMainHeap.PopMemId();
+ }
+#else
+ if(FrontEndMenuManager.m_bMenuActive)
+ FrontEndMenuManager.DrawFrontEnd();
+#endif
}
+void
+Render2dStuffAfterFade(void)
+{
+#ifndef MASTER
+ DisplayGameDebugText();
+#endif
+
+ CHud::DrawAfterFade();
+ CFont::DrawFonts();
+}
-static void
-Terminate3D(void)
+void
+Idle(void *arg)
{
- CGame::ShutdownRenderWare();
+#ifdef ASPECT_RATIO_SCALE
+ CDraw::SetAspectRatio(CDraw::FindAspectRatio());
+#endif
+
+ CTimer::Update();
+
+#ifdef TIMEBARS
+ tbInit();
+#endif
+
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+
+ // We're basically merging FrontendIdle and Idle (just like TheGame on PS2)
+#ifdef PS2_SAVE_DIALOG
+ // Only exists on PC FrontendIdle, probably some PS2 bug fix
+ if (FrontEndMenuManager.m_bMenuActive)
+ CSprite2d::SetRecipNearClip();
- RsRwTerminate();
+ if (FrontEndMenuManager.m_bGameNotLoaded) {
+ CPad::UpdatePads();
+ FrontEndMenuManager.Process();
+ } else {
+ CPointLights::InitPerFrame();
+#ifdef TIMEBARS
+ tbStartTimer(0, "CGame::Process");
+#endif
+ CGame::Process();
+#ifdef TIMEBARS
+ tbEndTimer("CGame::Process");
+ tbStartTimer(0, "DMAudio.Service");
+#endif
+ DMAudio.Service();
- return;
+#ifdef TIMEBARS
+ tbEndTimer("DMAudio.Service");
+#endif
+ }
+
+ if (RsGlobal.quit)
+ return;
+#else
+ CPointLights::InitPerFrame();
+#ifdef TIMEBARS
+ tbStartTimer(0, "CGame::Process");
+#endif
+ CGame::Process();
+#ifdef TIMEBARS
+ tbEndTimer("CGame::Process");
+ tbStartTimer(0, "DMAudio.Service");
+#endif
+
+ DMAudio.Service();
+
+#ifdef TIMEBARS
+ tbEndTimer("DMAudio.Service");
+#endif
+#endif
+
+ if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){
+ FrontEndMenuManager.m_bWantToRestart = true;
+ FrontEndMenuManager.m_bWantToLoad = false;
+ return;
+ }
+
+ if(FrontEndMenuManager.m_bWantToRestart || b_FoundRecentSavedGameWantToLoad)
+ return;
+
+ SetLightsWithTimeOfDayColour(Scene.world);
+
+ if(arg == nil)
+ return;
+
+ if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) &&
+ TheCamera.GetScreenFadeStatus() != FADE_2)
+ {
+#ifdef GTA_PC
+ if (!FrontEndMenuManager.m_bRenderGameInMenu) {
+ // This is from SA, but it's nice for windowed mode
+ RwV2d pos;
+ pos.x = SCREEN_WIDTH / 2.0f;
+ pos.y = SCREEN_HEIGHT / 2.0f;
+ RsMouseSetPos(&pos);
+ }
+#endif
+#ifdef TIMEBARS
+ tbStartTimer(0, "CnstrRenderList");
+#endif
+ CRenderer::ConstructRenderList();
+#ifdef TIMEBARS
+ tbEndTimer("CnstrRenderList");
+ tbStartTimer(0, "PreRender");
+#endif
+ CRenderer::PreRender();
+#ifdef TIMEBARS
+ tbEndTimer("PreRender");
+#endif
+
+ if(CWeather::LightningFlash && !CCullZones::CamNoRain()){
+ if(!DoRWStuffStartOfFrame_Horizon(255, 255, 255, 255, 255, 255, 255))
+ return;
+ }else{
+ if(!DoRWStuffStartOfFrame_Horizon(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(),
+ CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
+ 255))
+ return;
+ }
+
+ DefinedState();
+
+ // BUG. This has to be done BEFORE RwCameraBeginUpdate
+ RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip());
+ RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart());
+
+#ifdef TIMEBARS
+ tbStartTimer(0, "RenderScene");
+#endif
+ RenderScene();
+#ifdef TIMEBARS
+ tbEndTimer("RenderScene");
+#endif
+ RenderDebugShit();
+ RenderEffects();
+
+#ifdef TIMEBARS
+ tbStartTimer(0, "RenderMotionBlur");
+#endif
+ if((TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) &&
+ TheCamera.m_ScreenReductionPercentage > 0.0f)
+ TheCamera.SetMotionBlurAlpha(150);
+ TheCamera.RenderMotionBlur();
+#ifdef TIMEBARS
+ tbEndTimer("RenderMotionBlur");
+ tbStartTimer(0, "Render2dStuff");
+#endif
+ Render2dStuff();
+#ifdef TIMEBARS
+ tbEndTimer("Render2dStuff");
+#endif
+ }else{
+#ifdef ASPECT_RATIO_SCALE
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
+#else
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
+#endif
+ CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
+ RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ if(!RsCameraBeginUpdate(Scene.camera))
+ return;
+ }
+
+#ifdef PS2_SAVE_DIALOG
+ if (FrontEndMenuManager.m_bMenuActive)
+ DefinedState();
+#endif
+#ifdef TIMEBARS
+ tbStartTimer(0, "RenderMenus");
+#endif
+ RenderMenus();
+#ifdef TIMEBARS
+ tbEndTimer("RenderMenus");
+ tbStartTimer(0, "DoFade");
+#endif
+ DoFade();
+#ifdef TIMEBARS
+ tbEndTimer("DoFade");
+ tbStartTimer(0, "Render2dStuff-Fade");
+#endif
+ Render2dStuffAfterFade();
+#ifdef TIMEBARS
+ tbEndTimer("Render2dStuff-Fade");
+#endif
+ CCredits::Render();
+
+#ifdef TIMEBARS
+ tbDisplay();
+#endif
+
+ DoRWStuffEndOfFrame();
+
+ if(g_SlowMode)
+ ProcessSlowMode();
+}
+
+void
+FrontendIdle(void)
+{
+#ifdef ASPECT_RATIO_SCALE
+ CDraw::SetAspectRatio(CDraw::FindAspectRatio());
+#endif
+
+ CTimer::Update();
+ CSprite2d::SetRecipNearClip(); // this should be on InitialiseRenderWare according to PS2 asm. seems like a bug fix
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+ CPad::UpdatePads();
+ FrontEndMenuManager.Process();
+
+ if(RsGlobal.quit)
+ return;
+
+#ifdef ASPECT_RATIO_SCALE
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
+#else
+ CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
+#endif
+ CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
+ RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ if(!RsCameraBeginUpdate(Scene.camera))
+ return;
+
+ DefinedState(); // seems redundant, but breaks resolution change.
+ RenderMenus();
+ DoFade();
+ Render2dStuffAfterFade();
+// CFont::DrawFonts(); // redundant
+ DoRWStuffEndOfFrame();
+}
+
+void
+InitialiseGame(void)
+{
+ LoadingScreen(nil, nil, "loadsc0");
+ CGame::Initialise("DATA\\GTA3.DAT");
}
RsEventStatus
@@ -1056,7 +1147,7 @@ AppEventHandler(RsEvent event, void *param)
{
CameraSize(Scene.camera, (RwRect *)param,
- DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
+ SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
return rsEVENTPROCESSED;
}
@@ -1133,58 +1224,615 @@ AppEventHandler(RsEvent event, void *param)
}
}
-void PrintGameVersion()
+#ifndef MASTER
+void
+TheModelViewer(void)
{
- CFont::SetPropOn();
- CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(0.5f));
- CFont::SetCentreOff();
- CFont::SetRightJustifyOff();
- CFont::SetBackGroundOnlyTextOff();
- CFont::SetFontStyle(FONT_BANK);
- CFont::SetWrapx(SCREEN_WIDTH);
- CFont::SetDropShadowPosition(0);
- CFont::SetDropColor(CRGBA(0, 0, 0, 255));
- CFont::SetColor(CRGBA(235, 170, 50, 255));
+#if (defined(GTA_PS2) || defined(GTA_XBOX))
+ //TODO
+#else
+#ifdef ASPECT_RATIO_SCALE
+ CDraw::SetAspectRatio(CDraw::FindAspectRatio());
+#endif
+ CAnimViewer::Update();
+ CTimer::Update();
+ SetLightsWithTimeOfDayColour(Scene.world);
+ CRenderer::ConstructRenderList();
+ DoRWStuffStartOfFrame(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(),
+ CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
+ 255);
- strcpy(gString, "RE3");
- AsciiToUnicode(gString, gUString);
- CFont::PrintString(SCREEN_SCALE_X(10.5f), SCREEN_SCALE_Y(8.0f), gUString);
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+ DefinedState();
+ CVisibilityPlugins::InitAlphaEntityList();
+ CAnimViewer::Render();
+ Render2dStuff();
+ DoRWStuffEndOfFrame();
+#endif
}
+#endif
-void
-ValidateVersion()
+void TheGame(void)
{
- int32 file = CFileMgr::OpenFile("models\\coll\\peds.col", "rb");
- char buff[128];
+ printf("Into TheGame!!!\n");
- if ( file != -1 )
+#ifdef GTA_PS2
+ gMainHeap.PushMemId(_TODOCONST(1));
+#endif
+
+ CTimer::Initialise();
+
+#ifdef GTA_PS2
+ CGame::Initialise();
+#else
+ CGame::Initialise("DATA\\GTA3.DAT");
+#endif
+
+ char *splash = GetRandomSplashScreen(); // inlined here
+
+ LoadingScreen("Starting Game", NULL, splash);
+
+#ifdef GTA_PS2
+ if ( TheMemoryCard.CheckCardInserted(_TODOCONST(0)) == _TODOCONST(26)
+ && TheMemoryCard.ChangeDirectory(_TODOCONST(0), TheMemoryCard.field154)
+ && TheMemoryCard.FindMostRecentFileName(_TODOCONST(0), TheMemoryCard.field37) == 1
+ && TheMemoryCard.CheckDataNotCorrupt(TheMemoryCard.field37))
{
- CFileMgr::Seek(file, 100, SEEK_SET);
-
- for ( int i = 0; i < 128; i++ )
+ strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.field37);
+ TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true;
+
+ if (CMenuManager::m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad())
{
- CFileMgr::Read(file, &buff[i], sizeof(char));
- buff[i] -= 23;
- if ( buff[i] == '\0' )
+ CMenuManager::m_PrefsLanguage = TheMemoryCard.GetLanguageToLoad();
+ TheText.Unload();
+ TheText.Load();
+ }
+
+ CGame::currLevel = TheMemoryCard.GetLevelToLoad();
+ }
+#else
+ //TODO
+#endif
+
+ while (true)
+ {
+#ifdef PS2
+ if (TheMemoryCard.m_bWantToLoad)
+#else
+ if (FrontEndMenuManager.m_bWantToLoad)
+#endif
+ {
+ char *splash1 = GetLevelSplashScreen(CGame::currLevel);
+ LoadSplash(splash1);
+ }
+
+#ifdef PS2
+ TheMemoryCard.m_bWantToLoad = false;
+#else
+ FrontEndMenuManager.m_bWantToLoad = false;
+#endif
+
+ CTimer::Update();
+
+#ifdef PS2
+ while (!(FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad))
+#else
+ while (!(FrontEndMenuManager.m_bWantToRestart || b_FoundRecentSavedGameWantToLoad))
+#endif
+ {
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+
+#ifdef GTA_PS2
+ gMainHeap.PushMemId(_TODOCONST(12));
+#endif
+ CPointLights::NumLights = 0;
+ CGame::Process();
+#ifdef GTA_PS2
+ gMainHeap.PopMemId();
+#endif
+
+ DMAudio.Service();
+
+ if (CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing())
+ {
+#ifdef PS2
+ TheMemoryCard.m_bWantToLoad = false;
+#else
+ FrontEndMenuManager.m_bWantToLoad = false;
+#endif
+ FrontEndMenuManager.m_bWantToRestart = true;
break;
- CFileMgr::Seek(file, 99, SEEK_CUR);
+ }
+
+#ifdef PS2
+ if (FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad)
+#else
+ if (FrontEndMenuManager.m_bWantToRestart || b_FoundRecentSavedGameWantToLoad)
+#endif
+ break;
+
+ SetLightsWithTimeOfDayColour(Scene.world);
+#ifdef GTA_PS2
+ gMainHeap.PushMemId(_TODOCONST(15));
+#endif
+
+ if (!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu == true && TheCamera.GetScreenFadeStatus() != FADE_2 )
+ {
+#ifdef GTA_PS2
+ gMainHeap.PushMemId(_TODOCONST(11));
+#endif
+ CRenderer::ConstructRenderList();
+ CRenderer::PreRender();
+#ifdef GTA_PS2
+ gMainHeap.PopMemId();
+#endif
+
+ if (CWeather::LightningFlash && !CCullZones::CamNoRain())
+ DoRWStuffStartOfFrame_Horizon(255, 255, 255, 255, 255, 255, 255);
+ else
+ DoRWStuffStartOfFrame_Horizon(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(), CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), 255);
+
+ DefinedState();
+ RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip());
+ RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart());
+
+ RenderScene();
+ RenderDebugShit();
+ RenderEffects();
+
+ if ((TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) && TheCamera.m_ScreenReductionPercentage > 0.0f)
+ TheCamera.SetMotionBlurAlpha(150);
+ TheCamera.RenderMotionBlur();
+
+ Render2dStuff();
+ }
+ else
+ {
+ CameraSize(Scene.camera, NULL, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
+ CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
+ RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ if (!RsCameraBeginUpdate(Scene.camera))
+ break;
+ }
+
+ RenderMenus();
+
+#ifdef PS2
+ if (TheMemoryCard.m_bWantToLoad)
+#else
+ if (FrontEndMenuManager.m_bWantToLoad)
+#endif
+ {
+#ifdef GTA_PS2
+ gMainHeap.PopMemId();
+#endif
+ break;
+ }
+
+ DoFade();
+ Render2dStuffAfterFade();
+ CCredits::Render();
+
+ DoRWStuffEndOfFrame();
+
+ while (frameCount < 2)
+ ;
+
+ frameCount = 0;
+
+ CTimer::Update();
+
+#ifdef GTA_PS2
+ gMainHeap.PopMemId();
+#endif
+
+ if (g_SlowMode)
+ ProcessSlowMode();
}
-
- if ( !strncmp(buff, "grandtheftauto3", 15) )
+
+ CPad::ResetCheats();
+ CPad::StopPadsShaking();
+ DMAudio.ChangeMusicMode(MUSICMODE_DISABLE);
+ CGame::ShutDownForRestart();
+ CTimer::Stop();
+
+#ifdef PS2
+ if (FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad)
+#else
+ if (FrontEndMenuManager.m_bWantToRestart || b_FoundRecentSavedGameWantToLoad)
+#endif
{
- strncpy(version_name, &buff[15], 64);
- CFileMgr::CloseFile(file);
- return;
+#ifdef PS2
+ if (TheMemoryCard.b_FoundRecentSavedGameWantToLoad)
+#else
+ if (b_FoundRecentSavedGameWantToLoad)
+#endif
+ {
+ FrontEndMenuManager.m_bWantToRestart = true;
+#ifdef PS2
+ TheMemoryCard.m_bWantToLoad = true;
+#else
+ FrontEndMenuManager.m_bWantToLoad = true;
+#endif
+ }
+
+ CGame::InitialiseWhenRestarting();
+ DMAudio.ChangeMusicMode(MUSICMODE_GAME);
+ FrontEndMenuManager.m_bWantToRestart = false;
+
+ continue;
}
+
+ break;
}
- LoadingScreen("Invalid version", NULL, NULL);
+ DMAudio.Terminate();
+}
+
+
+void SystemInit()
+{
+#ifdef __MWERKS__
+ mwInit();
+#endif
- while(true)
- {
+#ifdef GTA_PS2
+ InitMemoryMgr();
+#endif
+
+#ifdef GTA_PS2
+ CFileMgr::InitCdSystem();
+
+ char path[256];
+
+ sprintf(path, "cdrom0:\\%s%s;1", "SYSTEM\\", "IOPRP23.IMG");
+
+ sceSifInitRpc(0);
+
+ while ( !sceSifRebootIop(path) )
+ ;
+ while( !sceSifSyncIop() )
;
+
+ sceSifInitRpc(0);
+
+ CFileMgr::InitCdSystem();
+
+ sceFsReset();
+#endif
+
+ CFileMgr::Initialise();
+
+#ifdef GTA_PS2
+ CFileMgr::InitCd();
+
+ Char modulepath[256];
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "SIO2MAN.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "PADMAN.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "LIBSD.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "SDRDRV.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "MCMAN.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "MCSERV.IRX");
+ LoadModule(modulepath);
+#endif
+
+
+#ifdef GTA_PS2
+ ThreadParam param;
+
+ param.entry = &IdleThread;
+ param.stack = idleThreadStack;
+ param.stackSize = 2048;
+ param.initPriority = 127;
+ param.gpReg = &_gp;
+
+ int thread = CreateThread(&param);
+ StartThread(thread, NULL);
+#else
+ //
+#endif
+
+
+ CPad::Initialise();
+ CPad::GetPad(0)->Mode = 0;
+
+ CGame::frenchGame = false;
+ CGame::germanGame = false;
+ CGame::nastyGame = true;
+ CMenuManager::m_PrefsAllowNastyGame = true;
+
+#ifdef GTA_PS2
+ int32 lang = sceScfGetLanguage();
+ if ( lang == SCE_ITALIAN_LANGUAGE )
+ CMenuManager::m_PrefsLanguage = LANGUAGE_ITALIAN;
+ else if ( lang == SCE_SPANISH_LANGUAGE )
+ CMenuManager::m_PrefsLanguage = LANGUAGE_SPANISH;
+ else if ( lang == SCE_GERMAN_LANGUAGE )
+ {
+ CGame::germanGame = true;
+ CGame::nastyGame = false;
+ CMenuManager::m_PrefsAllowNastyGame = false;
+ CMenuManager::m_PrefsLanguage = LANGUAGE_GERMAN;
}
+ else if ( lang == SCE_FRENCH_LANGUAGE )
+ {
+ CGame::frenchGame = true;
+ CGame::nastyGame = false;
+ CMenuManager::m_PrefsAllowNastyGame = false;
+ CMenuManager::m_PrefsLanguage = LANGUAGE_FRENCH;
+ }
+ else
+ CMenuManager::m_PrefsLanguage = LANGUAGE_AMERICAN;
+
+ FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame();
+#else
+ //
+#endif
+
+#ifdef PS2
+ TheMemoryCard.Init();
+#endif
+}
+
+void GameInit()
+{
+ if ( !gameAlreadyInitialised )
+ {
+#ifdef GTA_PS2
+ char path[256];
+
+ strcpy(path, "cdrom0:\\");
+ strcat(path, "SYSTEM\\");
+ strcat(path, "CDSTREAM.IRX");
+ LoadModule(path);
+
+ strcpy(path, "cdrom0:\\");
+ strcat(path, "SYSTEM\\");
+ strcat(path, "SAMPMAN.IRX");
+ LoadModule(path);
+
+ strcpy(path, "cdrom0:\\");
+ strcat(path, "SYSTEM\\");
+ strcat(path, "MUSICSTR.IRX");
+ LoadModule(path);
+#endif
+ CdStreamInit(MAX_CDCHANNELS);
+
+#ifdef PS2
+ Initialise3D(); //no params
+#else
+ //TODO
+#endif
+
+#ifdef GTA_PS2
+ char *files[] =
+ {
+ "\\ANIM\\CUTS.IMG;1",
+ "\\ANIM\\CUTS.DIR;1",
+ "\\ANIM\\PED.IFP;1",
+ "\\MODELS\\FRONTEND.TXD;1",
+ "\\MODELS\\FONTS.TXD;1",
+ "\\MODELS\\HUD.TXD;1",
+ "\\MODELS\\PARTICLE.TXD;1",
+ "\\MODELS\\MISC.TXD;1",
+ "\\MODELS\\GENERIC.TXD;1",
+ "\\MODELS\\GTA3.DIR;1",
+ "\\TEXT\\ENGLISH.GXT;1",
+ "\\TEXT\\FRENCH.GXT;1",
+ "\\TEXT\\GERMAN.GXT;1",
+ "\\TEXT\\ITALIAN.GXT;1",
+ "\\TEXT\\SPANISH.GXT;1",
+ "\\TXD\\LOADSC0.TXD;1",
+ "\\TXD\\LOADSC1.TXD;1",
+ "\\TXD\\LOADSC2.TXD;1",
+ "\\TXD\\LOADSC3.TXD;1",
+ "\\TXD\\LOADSC4.TXD;1",
+ "\\TXD\\LOADSC5.TXD;1",
+ "\\TXD\\LOADSC6.TXD;1",
+ "\\TXD\\LOADSC7.TXD;1",
+ "\\TXD\\LOADSC8.TXD;1",
+ "\\TXD\\LOADSC9.TXD;1",
+ "\\TXD\\LOADSC10.TXD;1",
+ "\\TXD\\LOADSC11.TXD;1",
+ "\\TXD\\LOADSC12.TXD;1",
+ "\\TXD\\LOADSC13.TXD;1",
+ "\\TXD\\LOADSC14.TXD;1",
+ "\\TXD\\LOADSC15.TXD;1",
+ "\\TXD\\LOADSC16.TXD;1",
+ "\\TXD\\LOADSC17.TXD;1",
+ "\\TXD\\LOADSC18.TXD;1",
+ "\\TXD\\LOADSC19.TXD;1",
+ "\\TXD\\LOADSC20.TXD;1",
+ "\\TXD\\LOADSC21.TXD;1",
+ "\\TXD\\LOADSC22.TXD;1",
+ "\\TXD\\LOADSC23.TXD;1",
+ "\\TXD\\LOADSC24.TXD;1",
+ "\\TXD\\LOADSC25.TXD;1",
+ "\\TXD\\NEWS.TXD;1",
+ "\\MODELS\\COLL\\GENERIC.COL;1",
+ "\\MODELS\\COLL\\INDUST.COL;1",
+ "\\MODELS\\COLL\\COMMER.COL;1",
+ "\\MODELS\\COLL\\SUBURB.COL;1",
+ "\\MODELS\\COLL\\WEAPONS.COL;1",
+ "\\MODELS\\COLL\\VEHICLES.COL;1",
+ "\\MODELS\\COLL\\PEDS.COL;1",
+ "\\MODELS\\GENERIC\\AIR_VLO.DFF;1",
+ "\\MODELS\\GENERIC\\WEAPONS.DFF;1",
+ "\\MODELS\\GENERIC\\WHEELS.DFF;1",
+ "\\MODELS\\GENERIC\\LOPLYGUY.DFF;1",
+ "\\MODELS\\GENERIC\\ARROW.DFF;1",
+ "\\MODELS\\GENERIC\\ZONECYLB.DFF;1",
+ "\\DATA\\MAPS\\COMNTOP.IPL;1",
+ "\\DATA\\MAPS\\COMNBTM.IPL;1",
+ "\\DATA\\MAPS\\COMSE.IPL;1",
+ "\\DATA\\MAPS\\COMSW.IPL;1",
+ "\\DATA\\MAPS\\CULL.IPL;1",
+ "\\DATA\\MAPS\\INDUSTNE.IPL;1",
+ "\\DATA\\MAPS\\INDUSTNW.IPL;1",
+ "\\DATA\\MAPS\\INDUSTSE.IPL;1",
+ "\\DATA\\MAPS\\INDUSTSW.IPL;1",
+ "\\DATA\\MAPS\\SUBURBNE.IPL;1",
+ "\\DATA\\MAPS\\SUBURBSW.IPL;1",
+ "\\DATA\\MAPS\\OVERVIEW.IPL;1",
+ "\\DATA\\MAPS\\PROPS.IPL;1",
+ "\\DATA\\MAPS\\GTA3.IDE;1",
+ "\\DATA\\PATHS\\FLIGHT.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT2.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT3.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT4.DAT;1",
+ "\\DATA\\PATHS\\TRACKS.DAT;1",
+ "\\DATA\\PATHS\\TRACKS2.DAT;1",
+ "\\DATA\\PATHS\\CHASE0.DAT;1",
+ "\\DATA\\PATHS\\CHASE1.DAT;1",
+ "\\DATA\\PATHS\\CHASE2.DAT;1",
+ "\\DATA\\PATHS\\CHASE3.DAT;1",
+ "\\DATA\\PATHS\\CHASE4.DAT;1",
+ "\\DATA\\PATHS\\CHASE5.DAT;1",
+ "\\DATA\\PATHS\\CHASE6.DAT;1",
+ "\\DATA\\PATHS\\CHASE7.DAT;1",
+ "\\DATA\\PATHS\\CHASE10.DAT;1",
+ "\\DATA\\PATHS\\CHASE11.DAT;1",
+ "\\DATA\\PATHS\\CHASE14.DAT;1",
+ "\\DATA\\PATHS\\CHASE16.DAT;1",
+ "\\DATA\\PATHS\\CHASE18.DAT;1",
+ "\\DATA\\PATHS\\CHASE19.DAT;1"
+ };
+
+ for ( int32 i = 0; i < ARRAY_SIZE(files); i++ )
+ SkyRegisterFileOnCd([i]);
+#endif
+
+ CreateDebugFont();
+
+#ifdef GTA_PS2
+ AddIntcHandler(_TODOCONST(2), VBlankCounter, 0);
+#endif
+
+ CameraSize(Scene.camera, NULL, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
+
+ CSprite2d::SetRecipNearClip();
+ CTxdStore::Initialise();
+#ifdef GTA_PS2
+ gMainHeap.PushMemId(_TODOCONST(9));
+#endif
+ CFont::Initialise();
+ CHud::Initialise();
+#ifdef GTA_PS2
+ gMainHeap.PopMemId();
+#endif
+
+ ValidateVersion();
+
+#ifdef GTA_PS2
+ sceCdCLOCK rtc;
+ sceCdReadClock(&rtc);
+ uint32 seed = rtc.minute + rtc.day;
+ uint32 seed2 = (seed << 4)-seed;
+ uint32 seed3 = (seed2 << 4)-seed2;
+ srand ((seed3<<4)+rtc.second);
+#else
+ //TODO: mysrand();
+#endif
+
+ gameAlreadyInitialised = true;
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+#ifdef __MWERKS__
+ mwInit(); // metrowerks initialisation
+#endif
+
+ SystemInit();
+
+#ifdef PS2
+ int32 state = TheMemoryCard.CheckCardStateAtGameStartUp(_TODOCONST(0));
+
+ if ( state == _TODOCONST(2) || state == _TODOCONST(1) && state != _TODOCONST(3) && state != _TODOCONST(0) )
+ {
+ GameInit();
+
+ TheText.Unload();
+ TheText.Load();
+
+ CFont::Initialise();
+
+ FrontEndMenuManager.DrawMemoryCardStartUpMenus();
+ }
+#endif
+
+#ifdef GTA_PS2
+ {
+ if (gameAlreadyInitialised)
+ RpSkySuspend();
+
+ InitMPEGPlayer();
+
+ PlayMPEG("cdrom0:\\MOVIES\\DMAPAL.PSS;1", false);
+
+ if (CGame::frenchGame || CGame::germanGame)
+ PlayMPEG("cdrom0:\\MOVIES\\INTROPAF.PSS;1", true);
+ else
+ PlayMPEG("cdrom0:\\MOVIES\\INTROPAL.PSS;1", true);
+
+ ShutdownMPEGPlayer();
+
+ if ( gameAlreadyInitialised )
+ RpSkyResume();
+ }
+#else
+ //TODO
+#endif
+
+ GameInit();
+
+ if ( CGame::frenchGame || CGame::germanGame )
+ LoadingScreen(NULL, version_name, "loadsc24");
+ else
+ LoadingScreen(NULL, version_name, "loadsc0");
+
+ DMAudio.Initialise();
+
+ TheGame();
+
+ CGame::ShutDown();
+
+ RwEngineStop();
+ RwEngineClose();
+ RwEngineTerm();
+
+#ifdef __MWERKS__
+ mwExit(); // metrowerks shutdown
+#endif
+
+ return 0;
}
STARTPATCHES
diff --git a/src/core/obrstr.cpp b/src/core/obrstr.cpp
index 3663d134..d9f7e9b4 100644
--- a/src/core/obrstr.cpp
+++ b/src/core/obrstr.cpp
@@ -1,119 +1,119 @@
-#include "common.h"
-#include "Debug.h"
-#include "obrstr.h"
-
-char obrstr[128];
-char obrstr2[128];
-
-void ObrInt(int32 n1)
-{
- IntToStr(n1, obrstr);
- CDebug::DebugAddText(obrstr);
-}
-
-void ObrInt2(int32 n1, int32 n2)
-{
- IntToStr(n1, obrstr);
- strcat(obrstr, " ");
- IntToStr(n2, obrstr2);
- strcat(obrstr, obrstr2);
- CDebug::DebugAddText(obrstr);
-}
-
-void ObrInt3(int32 n1, int32 n2, int32 n3)
-{
- IntToStr(n1, obrstr);
- strcat(obrstr, " ");
- IntToStr(n2, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n3, obrstr2);
- strcat(obrstr, obrstr2);
- CDebug::DebugAddText(obrstr);
-}
-
-void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4)
-{
- IntToStr(n1, obrstr);
- strcat(obrstr, " ");
- IntToStr(n2, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n3, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n4, obrstr2);
- strcat(obrstr, obrstr2);
- CDebug::DebugAddText(obrstr);
-}
-
-void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5)
-{
- IntToStr(n1, obrstr);
- strcat(obrstr, " ");
- IntToStr(n2, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n3, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n4, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n5, obrstr2);
- strcat(obrstr, obrstr2);
- CDebug::DebugAddText(obrstr);
-}
-
-void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
-{
- IntToStr(n1, obrstr);
- strcat(obrstr, " ");
- IntToStr(n2, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n3, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n4, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n5, obrstr2);
- strcat(obrstr, obrstr2);
- strcat(obrstr, " ");
- IntToStr(n6, obrstr2);
- strcat(obrstr, obrstr2);
- CDebug::DebugAddText(obrstr);
-}
-
-void IntToStr(int32 inNum, char *outStr)
-{
- bool isNeg = inNum < 0;
-
- if (isNeg) {
- inNum = -inNum;
- *outStr = '-';
- }
-
- int16 digits = 1;
-
- if (inNum > 9) {
- int32 _inNum = inNum;
- do {
- digits++;
- _inNum /= 10;
- } while (_inNum > 9);
- }
-
- int32 strSize = digits;
- if (isNeg)
- strSize++;
-
- char *pStr = &outStr[strSize];
- int32 i = 0;
- do {
- *(pStr-- - 1) = (inNum % 10) + '0';
- inNum /= 10;
- } while (++i < strSize);
- outStr[strSize] = '\0';
+#include "common.h"
+#include "Debug.h"
+#include "obrstr.h"
+
+char obrstr[128];
+char obrstr2[128];
+
+void ObrInt(int32 n1)
+{
+ IntToStr(n1, obrstr);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt2(int32 n1, int32 n2)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt3(int32 n1, int32 n2, int32 n3)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n5, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n5, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n6, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void IntToStr(int32 inNum, char *outStr)
+{
+ bool isNeg = inNum < 0;
+
+ if (isNeg) {
+ inNum = -inNum;
+ *outStr = '-';
+ }
+
+ int16 digits = 1;
+
+ if (inNum > 9) {
+ int32 _inNum = inNum;
+ do {
+ digits++;
+ _inNum /= 10;
+ } while (_inNum > 9);
+ }
+
+ int32 strSize = digits;
+ if (isNeg)
+ strSize++;
+
+ char *pStr = &outStr[strSize];
+ int32 i = 0;
+ do {
+ *(pStr-- - 1) = (inNum % 10) + '0';
+ inNum /= 10;
+ } while (++i < strSize);
+ outStr[strSize] = '\0';
} \ No newline at end of file
diff --git a/src/core/obrstr.h b/src/core/obrstr.h
index 6838afb5..c1633614 100644
--- a/src/core/obrstr.h
+++ b/src/core/obrstr.h
@@ -1,9 +1,9 @@
-#pragma once
-
-void ObrInt(int32 n1);
-void ObrInt2(int32 n1, int32 n2);
-void ObrInt3(int32 n1, int32 n2, int32 n3);
-void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4);
-void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5);
-void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6);
+#pragma once
+
+void ObrInt(int32 n1);
+void ObrInt2(int32 n1, int32 n2);
+void ObrInt3(int32 n1, int32 n2, int32 n3);
+void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4);
+void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5);
+void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6);
void IntToStr(int32 inNum, char *outStr); \ No newline at end of file
diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp
index 30421731..93d85f8d 100644
--- a/src/core/timebars.cpp
+++ b/src/core/timebars.cpp
@@ -1,121 +1,121 @@
-#ifndef MASTER
-#include "common.h"
-#include "Font.h"
-#include "Frontend.h"
-#include "Timer.h"
-#include "Text.h"
-
-#define MAX_TIMERS (50)
-#define MAX_MS_COLLECTED (40)
-
-// enables frame time output
-#define FRAMETIME
-
-struct sTimeBar
-{
- char name[20];
- float startTime;
- float endTime;
- int32 unk;
-};
-
-struct
-{
- sTimeBar Timers[MAX_TIMERS];
- uint32 count;
-} TimerBar;
-float MaxTimes[MAX_TIMERS];
-float MaxFrameTime;
-
-uint32 curMS;
-uint32 msCollected[MAX_MS_COLLECTED];
-#ifdef FRAMETIME
-float FrameInitTime;
-#endif
-
-void tbInit()
-{
- TimerBar.count = 0;
- uint32 i = CTimer::GetFrameCounter() & 0x7F;
- if (i == 0) {
- do
- MaxTimes[i++] = 0.0f;
- while (i != MAX_TIMERS);
-#ifdef FRAMETIME
- MaxFrameTime = 0.0f;
-#endif
- }
-#ifdef FRAMETIME
- FrameInitTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
-#endif
-}
-
-void tbStartTimer(int32 unk, char *name)
-{
- strcpy(TimerBar.Timers[TimerBar.count].name, name);
- TimerBar.Timers[TimerBar.count].unk = unk;
- TimerBar.Timers[TimerBar.count].startTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
- TimerBar.count++;
-}
-
-void tbEndTimer(char* name)
-{
- uint32 n = 1500;
- for (uint32 i = 0; i < TimerBar.count; i++) {
- if (strcmp(name, TimerBar.Timers[i].name) == 0)
- n = i;
- }
- assert(n != 1500);
- TimerBar.Timers[n].endTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
-}
-
-float Diag_GetFPS()
-{
- return 39000.0f / (msCollected[(curMS - 1) % MAX_MS_COLLECTED] - msCollected[curMS % MAX_MS_COLLECTED]);
-}
-
-void tbDisplay()
-{
- char temp[200];
- wchar wtemp[200];
-
-#ifdef FRAMETIME
- float FrameEndTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
-#endif
-
- msCollected[(curMS++) % MAX_MS_COLLECTED] = RsTimer();
- CFont::SetBackgroundOff();
- CFont::SetBackgroundColor(CRGBA(0, 0, 0, 128));
- CFont::SetScale(0.48f, 1.12f);
- CFont::SetCentreOff();
- CFont::SetJustifyOff();
- CFont::SetWrapx(640.0f);
- CFont::SetRightJustifyOff();
- CFont::SetPropOn();
- CFont::SetFontStyle(FONT_BANK);
- sprintf(temp, "FPS: %.2f", Diag_GetFPS());
- AsciiToUnicode(temp, wtemp);
- CFont::SetColor(CRGBA(255, 255, 255, 255));
- if (!CMenuManager::m_PrefsMarketing || !CMenuManager::m_PrefsDisableTutorials) {
- CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * (4.0f / DEFAULT_SCREEN_HEIGHT), wtemp);
-
-#ifndef FINAL
- // Timers output (my own implementation)
- for (uint32 i = 0; i < TimerBar.count; i++) {
- MaxTimes[i] = max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
- sprintf(temp, "%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]);
- AsciiToUnicode(temp, wtemp);
- CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (i + 2)) / DEFAULT_SCREEN_HEIGHT), wtemp);
- }
-
-#ifdef FRAMETIME
- MaxFrameTime = max(MaxFrameTime, FrameEndTime - FrameInitTime);
- sprintf(temp, "Frame Time: %.2f", MaxFrameTime);
- AsciiToUnicode(temp, wtemp);
-
- CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (TimerBar.count + 4)) / DEFAULT_SCREEN_HEIGHT), wtemp);
-#endif // FRAMETIME
-#endif // !FINAL
- }
-}
+#ifndef MASTER
+#include "common.h"
+#include "Font.h"
+#include "Frontend.h"
+#include "Timer.h"
+#include "Text.h"
+
+#define MAX_TIMERS (50)
+#define MAX_MS_COLLECTED (40)
+
+// enables frame time output
+#define FRAMETIME
+
+struct sTimeBar
+{
+ char name[20];
+ float startTime;
+ float endTime;
+ int32 unk;
+};
+
+struct
+{
+ sTimeBar Timers[MAX_TIMERS];
+ uint32 count;
+} TimerBar;
+float MaxTimes[MAX_TIMERS];
+float MaxFrameTime;
+
+uint32 curMS;
+uint32 msCollected[MAX_MS_COLLECTED];
+#ifdef FRAMETIME
+float FrameInitTime;
+#endif
+
+void tbInit()
+{
+ TimerBar.count = 0;
+ uint32 i = CTimer::GetFrameCounter() & 0x7F;
+ if (i == 0) {
+ do
+ MaxTimes[i++] = 0.0f;
+ while (i != MAX_TIMERS);
+#ifdef FRAMETIME
+ MaxFrameTime = 0.0f;
+#endif
+ }
+#ifdef FRAMETIME
+ FrameInitTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
+#endif
+}
+
+void tbStartTimer(int32 unk, char *name)
+{
+ strcpy(TimerBar.Timers[TimerBar.count].name, name);
+ TimerBar.Timers[TimerBar.count].unk = unk;
+ TimerBar.Timers[TimerBar.count].startTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
+ TimerBar.count++;
+}
+
+void tbEndTimer(char* name)
+{
+ uint32 n = 1500;
+ for (uint32 i = 0; i < TimerBar.count; i++) {
+ if (strcmp(name, TimerBar.Timers[i].name) == 0)
+ n = i;
+ }
+ assert(n != 1500);
+ TimerBar.Timers[n].endTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
+}
+
+float Diag_GetFPS()
+{
+ return 39000.0f / (msCollected[(curMS - 1) % MAX_MS_COLLECTED] - msCollected[curMS % MAX_MS_COLLECTED]);
+}
+
+void tbDisplay()
+{
+ char temp[200];
+ wchar wtemp[200];
+
+#ifdef FRAMETIME
+ float FrameEndTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerFrame();
+#endif
+
+ msCollected[(curMS++) % MAX_MS_COLLECTED] = RsTimer();
+ CFont::SetBackgroundOff();
+ CFont::SetBackgroundColor(CRGBA(0, 0, 0, 128));
+ CFont::SetScale(0.48f, 1.12f);
+ CFont::SetCentreOff();
+ CFont::SetJustifyOff();
+ CFont::SetWrapx(640.0f);
+ CFont::SetRightJustifyOff();
+ CFont::SetPropOn();
+ CFont::SetFontStyle(FONT_BANK);
+ sprintf(temp, "FPS: %.2f", Diag_GetFPS());
+ AsciiToUnicode(temp, wtemp);
+ CFont::SetColor(CRGBA(255, 255, 255, 255));
+ if (!CMenuManager::m_PrefsMarketing || !CMenuManager::m_PrefsDisableTutorials) {
+ CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * (4.0f / DEFAULT_SCREEN_HEIGHT), wtemp);
+
+#ifndef FINAL
+ // Timers output (my own implementation)
+ for (uint32 i = 0; i < TimerBar.count; i++) {
+ MaxTimes[i] = max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
+ sprintf(temp, "%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]);
+ AsciiToUnicode(temp, wtemp);
+ CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (i + 2)) / DEFAULT_SCREEN_HEIGHT), wtemp);
+ }
+
+#ifdef FRAMETIME
+ MaxFrameTime = max(MaxFrameTime, FrameEndTime - FrameInitTime);
+ sprintf(temp, "Frame Time: %.2f", MaxFrameTime);
+ AsciiToUnicode(temp, wtemp);
+
+ CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (TimerBar.count + 4)) / DEFAULT_SCREEN_HEIGHT), wtemp);
+#endif // FRAMETIME
+#endif // !FINAL
+ }
+}
#endif // !MASTER \ No newline at end of file
diff --git a/src/core/timebars.h b/src/core/timebars.h
index 8ffccd8e..6d3b853e 100644
--- a/src/core/timebars.h
+++ b/src/core/timebars.h
@@ -1,6 +1,6 @@
-#pragma once
-
-void tbInit();
-void tbStartTimer(int32, char*);
-void tbEndTimer(char*);
+#pragma once
+
+void tbInit();
+void tbStartTimer(int32, char*);
+void tbEndTimer(char*);
void tbDisplay(); \ No newline at end of file