removed windows.h for most .cpps

This commit is contained in:
aap 2020-03-27 20:53:47 +01:00
parent 43b092033c
commit e7c18fc17f
13 changed files with 362 additions and 331 deletions

View file

@ -3906,8 +3906,8 @@ MACRO_STOP
#pragma warning( disable : 344 ) #pragma warning( disable : 344 )
#endif /* (defined(__ICL)) */ #endif /* (defined(__ICL)) */
//nobody needed that - AAP
#include <windows.h> //#include <windows.h>
#if (defined(RWDEBUG)) #if (defined(RWDEBUG))
#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) #if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC))

View file

@ -1,3 +1,4 @@
#define WITHWINDOWS // for our script loading hack
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"

View file

@ -43,6 +43,7 @@ BOOL _gbCdStreamOverlapped;
BOOL _gbCdStreamAsync; BOOL _gbCdStreamAsync;
DWORD _gdwCdStreamFlags; DWORD _gdwCdStreamFlags;
DWORD WINAPI CdStreamThread(LPVOID lpThreadParameter);
void void
CdStreamInitThread(void) CdStreamInitThread(void)

View file

@ -39,7 +39,6 @@ int32 CdStreamSync(int32 channel);
void AddToQueue(Queue *queue, int32 item); void AddToQueue(Queue *queue, int32 item);
int32 GetFirstInQueue(Queue *queue); int32 GetFirstInQueue(Queue *queue);
void RemoveFirstInQueue(Queue *queue); void RemoveFirstInQueue(Queue *queue);
DWORD WINAPI CdStreamThread(LPVOID lpThreadParameter);
bool CdStreamAddImage(char const *path); bool CdStreamAddImage(char const *path);
char *CdStreamGetImageName(int32 cd); char *CdStreamGetImageName(int32 cd);
void CdStreamRemoveImages(void); void CdStreamRemoveImages(void);

View file

@ -1,3 +1,4 @@
#define WITHWINDOWS // just for VK_SPACE
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "General.h" #include "General.h"
@ -27,79 +28,79 @@ const struct {
{ "BET", STREAMED_SOUND_BANK_INTRO }, { "BET", STREAMED_SOUND_BANK_INTRO },
{ "L1_LG", STREAMED_SOUND_CUTSCENE_LUIGI1_LG }, { "L1_LG", STREAMED_SOUND_CUTSCENE_LUIGI1_LG },
{ "L2_DSB", STREAMED_SOUND_CUTSCENE_LUIGI2_DSB }, { "L2_DSB", STREAMED_SOUND_CUTSCENE_LUIGI2_DSB },
{ "L3_DM", STREAMED_SOUND_CUTSCENE_LUIGI3_DM }, { "L3_DM", STREAMED_SOUND_CUTSCENE_LUIGI3_DM },
{ "L4_PAP", STREAMED_SOUND_CUTSCENE_LUIGI4_PAP }, { "L4_PAP", STREAMED_SOUND_CUTSCENE_LUIGI4_PAP },
{ "L5_TFB", STREAMED_SOUND_CUTSCENE_LUIGI5_TFB }, { "L5_TFB", STREAMED_SOUND_CUTSCENE_LUIGI5_TFB },
{ "J0_DM2", STREAMED_SOUND_CUTSCENE_JOEY0_DM2 }, { "J0_DM2", STREAMED_SOUND_CUTSCENE_JOEY0_DM2 },
{ "J1_LFL", STREAMED_SOUND_CUTSCENE_JOEY1_LFL }, { "J1_LFL", STREAMED_SOUND_CUTSCENE_JOEY1_LFL },
{ "J2_KCL", STREAMED_SOUND_CUTSCENE_JOEY2_KCL }, { "J2_KCL", STREAMED_SOUND_CUTSCENE_JOEY2_KCL },
{ "J3_VH", STREAMED_SOUND_CUTSCENE_JOEY3_VH }, { "J3_VH", STREAMED_SOUND_CUTSCENE_JOEY3_VH },
{ "J4_ETH", STREAMED_SOUND_CUTSCENE_JOEY4_ETH }, { "J4_ETH", STREAMED_SOUND_CUTSCENE_JOEY4_ETH },
{ "J5_DST", STREAMED_SOUND_CUTSCENE_JOEY5_DST }, { "J5_DST", STREAMED_SOUND_CUTSCENE_JOEY5_DST },
{ "J6_TBJ", STREAMED_SOUND_CUTSCENE_JOEY6_TBJ }, { "J6_TBJ", STREAMED_SOUND_CUTSCENE_JOEY6_TBJ },
{ "T1_TOL", STREAMED_SOUND_CUTSCENE_TONI1_TOL }, { "T1_TOL", STREAMED_SOUND_CUTSCENE_TONI1_TOL },
{ "T2_TPU", STREAMED_SOUND_CUTSCENE_TONI2_TPU }, { "T2_TPU", STREAMED_SOUND_CUTSCENE_TONI2_TPU },
{ "T3_MAS", STREAMED_SOUND_CUTSCENE_TONI3_MAS }, { "T3_MAS", STREAMED_SOUND_CUTSCENE_TONI3_MAS },
{ "T4_TAT", STREAMED_SOUND_CUTSCENE_TONI4_TAT }, { "T4_TAT", STREAMED_SOUND_CUTSCENE_TONI4_TAT },
{ "T5_BF", STREAMED_SOUND_CUTSCENE_TONI5_BF }, { "T5_BF", STREAMED_SOUND_CUTSCENE_TONI5_BF },
{ "S0_MAS", STREAMED_SOUND_CUTSCENE_SAL0_MAS }, { "S0_MAS", STREAMED_SOUND_CUTSCENE_SAL0_MAS },
{ "S1_PF", STREAMED_SOUND_CUTSCENE_SAL1_PF }, { "S1_PF", STREAMED_SOUND_CUTSCENE_SAL1_PF },
{ "S2_CTG", STREAMED_SOUND_CUTSCENE_SAL2_CTG }, { "S2_CTG", STREAMED_SOUND_CUTSCENE_SAL2_CTG },
{ "S3_RTC", STREAMED_SOUND_CUTSCENE_SAL3_RTC }, { "S3_RTC", STREAMED_SOUND_CUTSCENE_SAL3_RTC },
{ "S5_LRQ", STREAMED_SOUND_CUTSCENE_SAL5_LRQ }, { "S5_LRQ", STREAMED_SOUND_CUTSCENE_SAL5_LRQ },
{ "S4_BDBA", STREAMED_SOUND_CUTSCENE_SAL4_BDBA }, { "S4_BDBA", STREAMED_SOUND_CUTSCENE_SAL4_BDBA },
{ "S4_BDBB", STREAMED_SOUND_CUTSCENE_SAL4_BDBB }, { "S4_BDBB", STREAMED_SOUND_CUTSCENE_SAL4_BDBB },
{ "S2_CTG2", STREAMED_SOUND_CUTSCENE_SAL2_CTG2 }, { "S2_CTG2", STREAMED_SOUND_CUTSCENE_SAL2_CTG2 },
{ "S4_BDBD", STREAMED_SOUND_CUTSCENE_SAL4_BDBD }, { "S4_BDBD", STREAMED_SOUND_CUTSCENE_SAL4_BDBD },
{ "S5_LRQB", STREAMED_SOUND_CUTSCENE_SAL5_LRQB }, { "S5_LRQB", STREAMED_SOUND_CUTSCENE_SAL5_LRQB },
{ "S5_LRQC", STREAMED_SOUND_CUTSCENE_SAL5_LRQC }, { "S5_LRQC", STREAMED_SOUND_CUTSCENE_SAL5_LRQC },
{ "A1_SS0", STREAMED_SOUND_CUTSCENE_ASUKA_1_SSO }, { "A1_SS0", STREAMED_SOUND_CUTSCENE_ASUKA_1_SSO },
{ "A2_PP", STREAMED_SOUND_CUTSCENE_ASUKA_2_PP }, { "A2_PP", STREAMED_SOUND_CUTSCENE_ASUKA_2_PP },
{ "A3_SS", STREAMED_SOUND_CUTSCENE_ASUKA_3_SS }, { "A3_SS", STREAMED_SOUND_CUTSCENE_ASUKA_3_SS },
{ "A4_PDR", STREAMED_SOUND_CUTSCENE_ASUKA_4_PDR }, { "A4_PDR", STREAMED_SOUND_CUTSCENE_ASUKA_4_PDR },
{ "A5_K2FT", STREAMED_SOUND_CUTSCENE_ASUKA_5_K2FT}, { "A5_K2FT", STREAMED_SOUND_CUTSCENE_ASUKA_5_K2FT},
{ "K1_KBO", STREAMED_SOUND_CUTSCENE_KENJI1_KBO }, { "K1_KBO", STREAMED_SOUND_CUTSCENE_KENJI1_KBO },
{ "K2_GIS", STREAMED_SOUND_CUTSCENE_KENJI2_GIS }, { "K2_GIS", STREAMED_SOUND_CUTSCENE_KENJI2_GIS },
{ "K3_DS", STREAMED_SOUND_CUTSCENE_KENJI3_DS }, { "K3_DS", STREAMED_SOUND_CUTSCENE_KENJI3_DS },
{ "K4_SHI", STREAMED_SOUND_CUTSCENE_KENJI4_SHI }, { "K4_SHI", STREAMED_SOUND_CUTSCENE_KENJI4_SHI },
{ "K5_SD", STREAMED_SOUND_CUTSCENE_KENJI5_SD }, { "K5_SD", STREAMED_SOUND_CUTSCENE_KENJI5_SD },
{ "R0_PDR2", STREAMED_SOUND_CUTSCENE_RAY0_PDR2 }, { "R0_PDR2", STREAMED_SOUND_CUTSCENE_RAY0_PDR2 },
{ "R1_SW", STREAMED_SOUND_CUTSCENE_RAY1_SW }, { "R1_SW", STREAMED_SOUND_CUTSCENE_RAY1_SW },
{ "R2_AP", STREAMED_SOUND_CUTSCENE_RAY2_AP }, { "R2_AP", STREAMED_SOUND_CUTSCENE_RAY2_AP },
{ "R3_ED", STREAMED_SOUND_CUTSCENE_RAY3_ED }, { "R3_ED", STREAMED_SOUND_CUTSCENE_RAY3_ED },
{ "R4_GF", STREAMED_SOUND_CUTSCENE_RAY4_GF }, { "R4_GF", STREAMED_SOUND_CUTSCENE_RAY4_GF },
{ "R5_PB", STREAMED_SOUND_CUTSCENE_RAY5_PB }, { "R5_PB", STREAMED_SOUND_CUTSCENE_RAY5_PB },
{ "R6_MM", STREAMED_SOUND_CUTSCENE_RAY6_MM }, { "R6_MM", STREAMED_SOUND_CUTSCENE_RAY6_MM },
{ "D1_STOG", STREAMED_SOUND_CUTSCENE_DONALD1_STOG }, { "D1_STOG", STREAMED_SOUND_CUTSCENE_DONALD1_STOG },
{ "D2_KK", STREAMED_SOUND_CUTSCENE_DONALD2_KK }, { "D2_KK", STREAMED_SOUND_CUTSCENE_DONALD2_KK },
{ "D3_ADO", STREAMED_SOUND_CUTSCENE_DONALD3_ADO }, { "D3_ADO", STREAMED_SOUND_CUTSCENE_DONALD3_ADO },
{ "D5_ES", STREAMED_SOUND_CUTSCENE_DONALD5_ES }, { "D5_ES", STREAMED_SOUND_CUTSCENE_DONALD5_ES },
{ "D7_MLD", STREAMED_SOUND_CUTSCENE_DONALD7_MLD }, { "D7_MLD", STREAMED_SOUND_CUTSCENE_DONALD7_MLD },
{ "D4_GTA", STREAMED_SOUND_CUTSCENE_DONALD4_GTA }, { "D4_GTA", STREAMED_SOUND_CUTSCENE_DONALD4_GTA },
{ "D4_GTA2", STREAMED_SOUND_CUTSCENE_DONALD4_GTA2 }, { "D4_GTA2", STREAMED_SOUND_CUTSCENE_DONALD4_GTA2 },
{ "D6_STS", STREAMED_SOUND_CUTSCENE_DONALD6_STS }, { "D6_STS", STREAMED_SOUND_CUTSCENE_DONALD6_STS },
{ "A6_BAIT", STREAMED_SOUND_CUTSCENE_ASUKA6_BAIT }, { "A6_BAIT", STREAMED_SOUND_CUTSCENE_ASUKA6_BAIT },
{ "A7_ETG", STREAMED_SOUND_CUTSCENE_ASUKA7_ETG }, { "A7_ETG", STREAMED_SOUND_CUTSCENE_ASUKA7_ETG },
{ "A8_PS", STREAMED_SOUND_CUTSCENE_ASUKA8_PS }, { "A8_PS", STREAMED_SOUND_CUTSCENE_ASUKA8_PS },
{ "A9_ASD", STREAMED_SOUND_CUTSCENE_ASUKA9_ASD }, { "A9_ASD", STREAMED_SOUND_CUTSCENE_ASUKA9_ASD },
{ "K4_SHI2", STREAMED_SOUND_CUTSCENE_KENJI4_SHI2 }, { "K4_SHI2", STREAMED_SOUND_CUTSCENE_KENJI4_SHI2 },
{ "C1_TEX", STREAMED_SOUND_CUTSCENE_CATALINA1_TEX }, { "C1_TEX", STREAMED_SOUND_CUTSCENE_CATALINA1_TEX },
{ "EL_PH1", STREAMED_SOUND_CUTSCENE_ELBURRO1_PH1 }, { "EL_PH1", STREAMED_SOUND_CUTSCENE_ELBURRO1_PH1 },
{ "EL_PH2", STREAMED_SOUND_CUTSCENE_ELBURRO2_PH2 }, { "EL_PH2", STREAMED_SOUND_CUTSCENE_ELBURRO2_PH2 },
{ "EL_PH3", STREAMED_SOUND_CUTSCENE_ELBURRO3_PH3 }, { "EL_PH3", STREAMED_SOUND_CUTSCENE_ELBURRO3_PH3 },
{ "EL_PH4", STREAMED_SOUND_CUTSCENE_ELBURRO4_PH4 }, { "EL_PH4", STREAMED_SOUND_CUTSCENE_ELBURRO4_PH4 },
{ "YD_PH1", STREAMED_SOUND_CUTSCENE_YARDIE_PH1 }, { "YD_PH1", STREAMED_SOUND_CUTSCENE_YARDIE_PH1 },
{ "YD_PH2", STREAMED_SOUND_CUTSCENE_YARDIE_PH2 }, { "YD_PH2", STREAMED_SOUND_CUTSCENE_YARDIE_PH2 },
{ "YD_PH3", STREAMED_SOUND_CUTSCENE_YARDIE_PH3 }, { "YD_PH3", STREAMED_SOUND_CUTSCENE_YARDIE_PH3 },
{ "YD_PH4", STREAMED_SOUND_CUTSCENE_YARDIE_PH4 }, { "YD_PH4", STREAMED_SOUND_CUTSCENE_YARDIE_PH4 },
{ "HD_PH1", STREAMED_SOUND_CUTSCENE_HOODS_PH1 }, { "HD_PH1", STREAMED_SOUND_CUTSCENE_HOODS_PH1 },
{ "HD_PH2", STREAMED_SOUND_CUTSCENE_HOODS_PH2 }, { "HD_PH2", STREAMED_SOUND_CUTSCENE_HOODS_PH2 },
{ "HD_PH3", STREAMED_SOUND_CUTSCENE_HOODS_PH3 }, { "HD_PH3", STREAMED_SOUND_CUTSCENE_HOODS_PH3 },
{ "HD_PH4", STREAMED_SOUND_CUTSCENE_HOODS_PH4 }, { "HD_PH4", STREAMED_SOUND_CUTSCENE_HOODS_PH4 },
{ "HD_PH5", STREAMED_SOUND_CUTSCENE_HOODS_PH5 }, { "HD_PH5", STREAMED_SOUND_CUTSCENE_HOODS_PH5 },
{ "MT_PH1", STREAMED_SOUND_CUTSCENE_MARTY_PH1 }, { "MT_PH1", STREAMED_SOUND_CUTSCENE_MARTY_PH1 },
{ "MT_PH2", STREAMED_SOUND_CUTSCENE_MARTY_PH2 }, { "MT_PH2", STREAMED_SOUND_CUTSCENE_MARTY_PH2 },
{ "MT_PH3", STREAMED_SOUND_CUTSCENE_MARTY_PH3 }, { "MT_PH3", STREAMED_SOUND_CUTSCENE_MARTY_PH3 },
{ "MT_PH4", STREAMED_SOUND_CUTSCENE_MARTY_PH4 }, { "MT_PH4", STREAMED_SOUND_CUTSCENE_MARTY_PH4 },
{ NULL, NULL } { NULL, NULL }
}; };
@ -128,135 +129,135 @@ CVector &CCutsceneMgr::ms_cutsceneOffset = *(CVector*)0x8F2C0C;
float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548; float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548;
uint32 &CCutsceneMgr::ms_cutsceneLoadStatus = *(uint32*)0x95CB40; uint32 &CCutsceneMgr::ms_cutsceneLoadStatus = *(uint32*)0x95CB40;
RpAtomic * RpAtomic *
CalculateBoundingSphereRadiusCB(RpAtomic *atomic, void *data) CalculateBoundingSphereRadiusCB(RpAtomic *atomic, void *data)
{ {
float radius = RpAtomicGetBoundingSphereMacro(atomic)->radius; float radius = RpAtomicGetBoundingSphereMacro(atomic)->radius;
RwV3d center = RpAtomicGetBoundingSphereMacro(atomic)->center; RwV3d center = RpAtomicGetBoundingSphereMacro(atomic)->center;
for (RwFrame *frame = RpAtomicGetFrame(atomic); RwFrameGetParent(frame); frame = RwFrameGetParent(frame)) for (RwFrame *frame = RpAtomicGetFrame(atomic); RwFrameGetParent(frame); frame = RwFrameGetParent(frame))
RwV3dTransformPoints(&center, &center, 1, RwFrameGetMatrix(frame)); RwV3dTransformPoints(&center, &center, 1, RwFrameGetMatrix(frame));
float size = RwV3dLength(&center) + radius; float size = RwV3dLength(&center) + radius;
if (size > *(float *)data) if (size > *(float *)data)
*(float *)data = size; *(float *)data = size;
return atomic; return atomic;
} }
void void
CCutsceneMgr::Initialise(void) CCutsceneMgr::Initialise(void)
{ {
ms_numCutsceneObjs = 0; ms_numCutsceneObjs = 0;
ms_loaded = false; ms_loaded = false;
ms_running = false; ms_running = false;
ms_animLoaded = false; ms_animLoaded = false;
ms_cutsceneProcessing = false; ms_cutsceneProcessing = false;
ms_useLodMultiplier = false; ms_useLodMultiplier = false;
ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE); ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE);
ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
} }
void void
CCutsceneMgr::Shutdown(void) CCutsceneMgr::Shutdown(void)
{ {
delete ms_pCutsceneDir; delete ms_pCutsceneDir;
} }
void void
CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName) CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
{ {
int file; int file;
uint32 size; uint32 size;
uint32 offset; uint32 offset;
CPlayerPed *pPlayerPed; CPlayerPed *pPlayerPed;
ms_cutsceneProcessing = true; ms_cutsceneProcessing = true;
if (!strcasecmp(szCutsceneName, "jb")) if (!strcasecmp(szCutsceneName, "jb"))
ms_useLodMultiplier = true; ms_useLodMultiplier = true;
CTimer::Stop(); CTimer::Stop();
ms_pCutsceneDir->numEntries = 0; ms_pCutsceneDir->numEntries = 0;
ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
CStreaming::RemoveUnusedModelsInLoadedList(); CStreaming::RemoveUnusedModelsInLoadedList();
CGame::DrasticTidyUpMemory(); CGame::DrasticTidyUpMemory();
strcpy(ms_cutsceneName, szCutsceneName); strcpy(ms_cutsceneName, szCutsceneName);
file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb"); file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb");
// Load animations // Load animations
sprintf(gString, "%s.IFP", szCutsceneName); sprintf(gString, "%s.IFP", szCutsceneName);
if (ms_pCutsceneDir->FindItem(gString, offset, size)) { if (ms_pCutsceneDir->FindItem(gString, offset, size)) {
CStreaming::MakeSpaceFor(size << 11); CStreaming::MakeSpaceFor(size << 11);
CStreaming::ImGonnaUseStreamingMemory(); CStreaming::ImGonnaUseStreamingMemory();
CFileMgr::Seek(file, offset << 11, SEEK_SET); CFileMgr::Seek(file, offset << 11, SEEK_SET);
CAnimManager::LoadAnimFile(file, false); CAnimManager::LoadAnimFile(file, false);
ms_cutsceneAssociations.CreateAssociations(szCutsceneName); ms_cutsceneAssociations.CreateAssociations(szCutsceneName);
CStreaming::IHaveUsedStreamingMemory(); CStreaming::IHaveUsedStreamingMemory();
ms_animLoaded = true; ms_animLoaded = true;
} else { } else {
ms_animLoaded = false; ms_animLoaded = false;
} }
// Load camera data // Load camera data
sprintf(gString, "%s.DAT", szCutsceneName); sprintf(gString, "%s.DAT", szCutsceneName);
if (ms_pCutsceneDir->FindItem(gString, offset, size)) { if (ms_pCutsceneDir->FindItem(gString, offset, size)) {
CFileMgr::Seek(file, offset << 11, SEEK_SET); CFileMgr::Seek(file, offset << 11, SEEK_SET);
TheCamera.LoadPathSplines(file); TheCamera.LoadPathSplines(file);
} }
CFileMgr::CloseFile(file); CFileMgr::CloseFile(file);
if (CGeneral::faststricmp(ms_cutsceneName, "end")) { if (CGeneral::faststricmp(ms_cutsceneName, "end")) {
DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE); DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE);
int trackId = FindCutsceneAudioTrackId(szCutsceneName); int trackId = FindCutsceneAudioTrackId(szCutsceneName);
if (trackId != -1) { if (trackId != -1) {
printf("Start preload audio %s\n", szCutsceneName); printf("Start preload audio %s\n", szCutsceneName);
DMAudio.PreloadCutSceneMusic(trackId); DMAudio.PreloadCutSceneMusic(trackId);
printf("End preload audio %s\n", szCutsceneName); printf("End preload audio %s\n", szCutsceneName);
} }
} }
ms_cutsceneTimer = 0.0f; ms_cutsceneTimer = 0.0f;
ms_loaded = true; ms_loaded = true;
ms_cutsceneOffset = CVector(0.0f, 0.0f, 0.0f); ms_cutsceneOffset = CVector(0.0f, 0.0f, 0.0f);
pPlayerPed = FindPlayerPed(); pPlayerPed = FindPlayerPed();
CTimer::Update(); CTimer::Update();
pPlayerPed->m_pWanted->ClearQdCrimes(); pPlayerPed->m_pWanted->ClearQdCrimes();
pPlayerPed->bIsVisible = false; pPlayerPed->bIsVisible = false;
pPlayerPed->m_fCurrentStamina = pPlayerPed->m_fMaxStamina; pPlayerPed->m_fCurrentStamina = pPlayerPed->m_fMaxStamina;
CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_80; CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_80;
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(true); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(true);
} }
void void
CCutsceneMgr::SetHeadAnim(const char *animName, CObject *pObject) CCutsceneMgr::SetHeadAnim(const char *animName, CObject *pObject)
{ {
CCutsceneHead *pCutsceneHead = (CCutsceneHead*)pObject; CCutsceneHead *pCutsceneHead = (CCutsceneHead*)pObject;
char szAnim[CUTSCENENAMESIZE * 2]; char szAnim[CUTSCENENAMESIZE * 2];
sprintf(szAnim, "%s_%s", ms_cutsceneName, animName); sprintf(szAnim, "%s_%s", ms_cutsceneName, animName);
pCutsceneHead->PlayAnimation(szAnim); pCutsceneHead->PlayAnimation(szAnim);
} }
void void
CCutsceneMgr::FinishCutscene() CCutsceneMgr::FinishCutscene()
{ {
CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f; CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f;
TheCamera.FinishCutscene(); TheCamera.FinishCutscene();
FindPlayerPed()->bIsVisible = true; FindPlayerPed()->bIsVisible = true;
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
} }
void void
CCutsceneMgr::SetupCutsceneToStart(void) CCutsceneMgr::SetupCutsceneToStart(void)
{ {
TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset); TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset);
TheCamera.TakeControlWithSpline(JUMP_CUT); TheCamera.TakeControlWithSpline(JUMP_CUT);
TheCamera.SetWideScreenOn(); TheCamera.SetWideScreenOn();
ms_cutsceneOffset.z++; ms_cutsceneOffset.z++;
@ -273,9 +274,9 @@ CCutsceneMgr::SetupCutsceneToStart(void)
} }
} }
CTimer::Update(); CTimer::Update();
CTimer::Update(); CTimer::Update();
ms_running = true; ms_running = true;
ms_cutsceneTimer = 0.0f; ms_cutsceneTimer = 0.0f;
} }
@ -297,14 +298,14 @@ CCutsceneMgr::SetCutsceneAnim(const char *animName, CObject *pObject)
pAnimBlendClumpData->link.Prepend(&pNewAnim->link); pAnimBlendClumpData->link.Prepend(&pNewAnim->link);
} }
CCutsceneHead * CCutsceneHead *
CCutsceneMgr::AddCutsceneHead(CObject *pObject, int modelId) CCutsceneMgr::AddCutsceneHead(CObject *pObject, int modelId)
{ {
CCutsceneHead *pHead = new CCutsceneHead(pObject); CCutsceneHead *pHead = new CCutsceneHead(pObject);
pHead->SetModelIndex(modelId); pHead->SetModelIndex(modelId);
CWorld::Add(pHead); CWorld::Add(pHead);
ms_pCutsceneObjects[ms_numCutsceneObjs++] = pHead; ms_pCutsceneObjects[ms_numCutsceneObjs++] = pHead;
return pHead; return pHead;
} }
CCutsceneObject * CCutsceneObject *
@ -333,89 +334,89 @@ CCutsceneMgr::CreateCutsceneObject(int modelId)
pCutsceneObject = new CCutsceneObject(); pCutsceneObject = new CCutsceneObject();
pCutsceneObject->SetModelIndex(modelId); pCutsceneObject->SetModelIndex(modelId);
ms_pCutsceneObjects[ms_numCutsceneObjs++] = pCutsceneObject; ms_pCutsceneObjects[ms_numCutsceneObjs++] = pCutsceneObject;
return pCutsceneObject; return pCutsceneObject;
} }
void void
CCutsceneMgr::DeleteCutsceneData(void) CCutsceneMgr::DeleteCutsceneData(void)
{ {
if (!ms_loaded) return; if (!ms_loaded) return;
ms_cutsceneProcessing = false; ms_cutsceneProcessing = false;
ms_useLodMultiplier = false; ms_useLodMultiplier = false;
for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) {
CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]);
ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject();
delete ms_pCutsceneObjects[ms_numCutsceneObjs]; delete ms_pCutsceneObjects[ms_numCutsceneObjs];
} }
ms_numCutsceneObjs = 0; ms_numCutsceneObjs = 0;
if (ms_animLoaded) if (ms_animLoaded)
CAnimManager::RemoveLastAnimFile(); CAnimManager::RemoveLastAnimFile();
ms_animLoaded = false; ms_animLoaded = false;
TheCamera.RestoreWithJumpCut(); TheCamera.RestoreWithJumpCut();
TheCamera.SetWideScreenOff(); TheCamera.SetWideScreenOff();
ms_running = false; ms_running = false;
ms_loaded = false; ms_loaded = false;
FindPlayerPed()->bIsVisible = true; FindPlayerPed()->bIsVisible = true;
CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80;
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
if (CGeneral::faststricmp(ms_cutsceneName, "end")) { if (CGeneral::faststricmp(ms_cutsceneName, "end")) {
DMAudio.StopCutSceneMusic(); DMAudio.StopCutSceneMusic();
if (CGeneral::faststricmp(ms_cutsceneName, "bet")) if (CGeneral::faststricmp(ms_cutsceneName, "bet"))
DMAudio.ChangeMusicMode(MUSICMODE_GAME); DMAudio.ChangeMusicMode(MUSICMODE_GAME);
} }
CTimer::Stop(); CTimer::Stop();
//TheCamera.GetScreenFadeStatus() == 2; // what for?? //TheCamera.GetScreenFadeStatus() == 2; // what for??
CGame::DrasticTidyUpMemory(); CGame::DrasticTidyUpMemory();
CTimer::Update(); CTimer::Update();
} }
void void
CCutsceneMgr::Update(void) CCutsceneMgr::Update(void)
{ {
enum { enum {
CUTSCENE_LOADING_0 = 0, CUTSCENE_LOADING_0 = 0,
CUTSCENE_LOADING_AUDIO, CUTSCENE_LOADING_AUDIO,
CUTSCENE_LOADING_2, CUTSCENE_LOADING_2,
CUTSCENE_LOADING_3, CUTSCENE_LOADING_3,
CUTSCENE_LOADING_4 CUTSCENE_LOADING_4
}; };
switch (ms_cutsceneLoadStatus) { switch (ms_cutsceneLoadStatus) {
case CUTSCENE_LOADING_AUDIO: case CUTSCENE_LOADING_AUDIO:
SetupCutsceneToStart(); SetupCutsceneToStart();
if (CGeneral::faststricmp(ms_cutsceneName, "end")) if (CGeneral::faststricmp(ms_cutsceneName, "end"))
DMAudio.PlayPreloadedCutSceneMusic(); DMAudio.PlayPreloadedCutSceneMusic();
ms_cutsceneLoadStatus++; ms_cutsceneLoadStatus++;
break; break;
case CUTSCENE_LOADING_2: case CUTSCENE_LOADING_2:
case CUTSCENE_LOADING_3: case CUTSCENE_LOADING_3:
ms_cutsceneLoadStatus++; ms_cutsceneLoadStatus++;
break; break;
case CUTSCENE_LOADING_4: case CUTSCENE_LOADING_4:
ms_cutsceneLoadStatus = CUTSCENE_LOADING_0; ms_cutsceneLoadStatus = CUTSCENE_LOADING_0;
break; break;
default: default:
break; break;
} }
if (!ms_running) return; if (!ms_running) return;
ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02f; 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 (CGeneral::faststricmp(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) {
if (CPad::GetPad(0)->GetCrossJustDown() if (CPad::GetPad(0)->GetCrossJustDown()
|| (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
|| CPad::GetPad(0)->GetLeftMouseJustDown() || CPad::GetPad(0)->GetLeftMouseJustDown()
|| CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown()
|| CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) || CPad::GetPad(0)->GetCharJustDown(VK_SPACE))
FinishCutscene(); FinishCutscene();
} }
} }
bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; } bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; }

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <ctype.h>
class CGeneral class CGeneral
{ {
public: public:

View file

@ -198,7 +198,7 @@ CStreaming::Init(void)
// PC only, figure out how much memory we got // PC only, figure out how much memory we got
#ifdef GTA_PC #ifdef GTA_PC
#define MB (1024*1024) #define MB (1024*1024)
extern DWORD &_dwMemAvailPhys; extern unsigned long &_dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2; ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2;
if(ms_memoryAvailable < 50*MB) if(ms_memoryAvailable < 50*MB)
ms_memoryAvailable = 50*MB; ms_memoryAvailable = 50*MB;

View file

@ -1,5 +1,6 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include <ctype.h>
#include "Zones.h" #include "Zones.h"

View file

@ -8,10 +8,15 @@
#pragma warning(disable: 4996) // POSIX names #pragma warning(disable: 4996) // POSIX names
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <math.h> #include <math.h>
//#include <assert.h> //#include <assert.h>
#include <new> #include <new>
#ifdef WITHWINDOWS
#include <Windows.h>
#endif
#ifdef WITHD3D #ifdef WITHD3D
#include <windows.h> #include <windows.h>
#include <d3d8types.h> #include <d3d8types.h>
@ -30,6 +35,16 @@
#undef near #undef near
#endif #endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef ARRAYSIZE
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
#endif
typedef uint8_t uint8; typedef uint8_t uint8;
typedef int8_t int8; typedef int8_t int8;
typedef uint16_t uint16; typedef uint16_t uint16;

View file

@ -6,13 +6,7 @@
#define VARJMP(a) { _asm jmp a } #define VARJMP(a) { _asm jmp a }
#define WRAPARG(a) UNREFERENCED_PARAMETER(a) #define WRAPARG(a) UNREFERENCED_PARAMETER(a)
#define NOVMT __declspec(novtable) #include <string.h> //memset
#define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a
#include <algorithm>
#include <vector>
#include "common.h"
enum enum
{ {
@ -103,72 +97,36 @@ isVC(void)
InjectHook(a, func); \ InjectHook(a, func); \
} }
void InjectHook_internal(uint32 address, uint32 hook, int type);
void Protect_internal(uint32 address, uint32 size);
void Unprotect_internal(void);
template<typename T, typename AT> inline void template<typename T, typename AT> inline void
Patch(AT address, T value) Patch(AT address, T value)
{ {
DWORD dwProtect[2]; Protect_internal((uint32)address, sizeof(T));
VirtualProtect((void*)address, sizeof(T), PAGE_EXECUTE_READWRITE, &dwProtect[0]);
*(T*)address = value; *(T*)address = value;
VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); Unprotect_internal();
} }
template<typename AT> inline void template<typename AT> inline void
Nop(AT address, unsigned int nCount) Nop(AT address, unsigned int nCount)
{ {
DWORD dwProtect[2]; Protect_internal((uint32)address, nCount);
VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
memset((void*)address, 0x90, nCount); memset((void*)address, 0x90, nCount);
VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]); Unprotect_internal();
} }
template<typename AT> inline void
ClearCC(AT address, unsigned int nCount)
{
DWORD dwProtect[2];
VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
memset((void*)address, 0xCC, nCount);
VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]);
}
extern std::vector<int32> usedAddresses;
template<typename AT, typename HT> inline void template<typename AT, typename HT> inline void
InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING) InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
{ {
if(std::any_of(usedAddresses.begin(), usedAddresses.end(), uint32 uiHook;
[address](AT value) { return (int32)value == address; })) {
debug("Used address %#06x twice when injecting hook\n", address);
}
usedAddresses.push_back((int32)address);
DWORD dwProtect[2];
switch ( nType )
{
case PATCH_JUMP:
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
*(BYTE*)address = 0xE9;
break;
case PATCH_CALL:
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
*(BYTE*)address = 0xE8;
break;
default:
VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
break;
}
DWORD dwHook;
_asm _asm
{ {
mov eax, hook mov eax, hook
mov dwHook, eax mov uiHook, eax
} }
InjectHook_internal((uint32)address, uiHook, nType);
*(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5;
if ( nType == PATCH_NOTHING )
VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]);
else
VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]);
} }
inline void ExtractCall(void *dst, uint32_t a) inline void ExtractCall(void *dst, uint32_t a)

View file

@ -22,11 +22,62 @@
#include "Console.h" #include "Console.h"
#include "Debug.h" #include "Debug.h"
#include <algorithm>
#include <vector> #include <vector>
#include <list> #include <list>
std::vector<int32> usedAddresses; std::vector<int32> usedAddresses;
static DWORD protect[2];
static uint32 protect_address;
static uint32 protect_size;
void
Protect_internal(uint32 address, uint32 size)
{
protect_address = address;
protect_size = size;
VirtualProtect((void*)address, size, PAGE_EXECUTE_READWRITE, &protect[0]);
}
void
Unprotect_internal(void)
{
VirtualProtect((void*)protect_address, protect_size, protect[0], &protect[1]);
}
void
InjectHook_internal(uint32 address, uint32 hook, int type)
{
if(std::any_of(usedAddresses.begin(), usedAddresses.end(),
[address](uint32 value) { return (int32)value == address; })) {
debug("Used address %#06x twice when injecting hook\n", address);
}
usedAddresses.push_back((int32)address);
switch(type){
case PATCH_JUMP:
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]);
*(uint8*)address = 0xE9;
break;
case PATCH_CALL:
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]);
*(uint8*)address = 0xE8;
break;
default:
VirtualProtect((void*)((uint32)address + 1), 4, PAGE_EXECUTE_READWRITE, &protect[0]);
break;
}
*(ptrdiff_t*)(address + 1) = hook - address - 5;
if(type == PATCH_NOTHING)
VirtualProtect((void*)(address + 1), 4, protect[0], &protect[1]);
else
VirtualProtect((void*)address, 5, protect[0], &protect[1]);
}
void **rwengine = *(void***)0x5A10E1; void **rwengine = *(void***)0x5A10E1;
DebugMenuAPI gDebugMenuAPI; DebugMenuAPI gDebugMenuAPI;

View file

@ -1,3 +1,4 @@
#define WITHWINDOWS
#include "common.h" #include "common.h"
#include "main.h" #include "main.h"
#include "patcher.h" #include "patcher.h"

View file

@ -1,3 +1,4 @@
#define WITHWINDOWS
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "FileMgr.h" #include "FileMgr.h"