diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index ca6f5263..fd937a9d 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -405,17 +405,50 @@ GenericLoad() //ReadDataFromBlock("Loading AudioScript Objects \n", cAudioScriptObject::LoadAllAudioScriptObjects); //LoadSaveDataBlock(); //ReadDataFromBlock("Loading ScriptPaths \n", CScriptPaths::Load); + // MAZAHAKA!! IF UNCOMMENT SAVE BLOCK CHECK !load bool CGame::ReInitGameObjectVariables(bool load) prolem reinit after load (empty save data) LoadSaveDataBlock(); ReadDataFromBlock("Loading Player Info \n", CWorld::Players[CWorld::PlayerInFocus].LoadPlayerInfo); LoadSaveDataBlock(); ReadDataFromBlock("Loading Stats \n", CStats::LoadStats); - assert(*CStats::LastMissionPassedName); // reinit after load bug. After load CStats was empty Mazahaka - //LoadSaveDataBlock(); - //ReadDataFromBlock("Loading Set Pieces \n", CSetPieces::Load); - //LoadSaveDataBlock(); - //ReadDataFromBlock("Loading Streaming Stuff \n", CStreaming::MemoryCardLoad); - //LoadSaveDataBlock(); - //ReadDataFromBlock("Loading PedType Stuff \n", CPedType::Load); + //assert(*CStats::LastMissionPassedName); // init after load save vars!! mazahaka // tmp disabled + // debug("======================last mission: %s\n", CStats::LastMissionPassedName); + + // Загрузка блока данных + /*if(!ReadDataFromFile(file, (uint8 *)&size, 4)) { return false; } + size = align4bytes(size); + if(!ReadDataFromFile(file, work_buff, size)) { return false; } + buf = work_buff; + + // Чтение данных из блока "Loading Player Info \n" + debug("Loading Player Info \n"); + memcpy(&size, buf, sizeof(size)); + buf += align4bytes(sizeof(size)); + CWorld::Players[CWorld::PlayerInFocus].LoadPlayerInfo(buf, size); + size = align4bytes(size); + buf += size; + + + + // Загрузка следующего блока данных + if(!ReadDataFromFile(file, (uint8 *)&size, 4)) { return false; } + size = align4bytes(size); + if(!ReadDataFromFile(file, work_buff, size)) { return false; } + buf = work_buff; + + // Чтение данных из блока "Loading Stats \n" + debug("Loading Stats \n"); + memcpy(&size, buf, sizeof(size)); + buf += align4bytes(sizeof(size)); + CStats::LoadStats(buf, size); + size = align4bytes(size); + buf += size;*/ + + // LoadSaveDataBlock(); + // ReadDataFromBlock("Loading Set Pieces \n", CSetPieces::Load); + // LoadSaveDataBlock(); + // ReadDataFromBlock("Loading Streaming Stuff \n", CStreaming::MemoryCardLoad); + // LoadSaveDataBlock(); + // ReadDataFromBlock("Loading PedType Stuff \n", CPedType::Load); CStreaming::ReInit(); DMAudio.SetMusicMasterVolume(FrontEndMenuManager.m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(FrontEndMenuManager.m_PrefsSfxVolume); diff --git a/src/save/PCSave.cpp b/src/save/PCSave.cpp index a33e9d90..79965584 100644 --- a/src/save/PCSave.cpp +++ b/src/save/PCSave.cpp @@ -19,7 +19,7 @@ C_PcSave PcSaveHelper; void C_PcSave::SetSaveDirectory(const char *path) { - sprintf(DefaultPCSaveFileName, "%s\\%s", path, "GTAVCsf"); + sprintf(DefaultPCSaveFileName, "%s\\%s", path, "GTAVCSsf"); } bool diff --git a/src/skel/skeleton.cpp b/src/skel/skeleton.cpp index d5805681..80fb608f 100644 --- a/src/skel/skeleton.cpp +++ b/src/skel/skeleton.cpp @@ -397,7 +397,7 @@ RsInitialize(void) */ RwBool result; - RsGlobal.appName = RWSTRING("GTA: Liberty City Stories"); + RsGlobal.appName = RWSTRING("GTA: Vice City Stories"); RsGlobal.maximumWidth = DEFAULT_SCREEN_WIDTH; RsGlobal.maximumHeight = DEFAULT_SCREEN_HEIGHT; RsGlobal.width = DEFAULT_SCREEN_WIDTH; diff --git a/src/skel/win/gtavcs.ico b/src/skel/win/gtavcs.ico new file mode 100644 index 00000000..a4959fe7 Binary files /dev/null and b/src/skel/win/gtavcs.ico differ diff --git a/src/skel/win/win.aps b/src/skel/win/win.aps new file mode 100644 index 00000000..e8513675 Binary files /dev/null and b/src/skel/win/win.aps differ diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 639f6272..63651c91 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -50,6 +50,9 @@ #include "skeleton.h" #include "platform.h" #include "crossplatform.h" +#ifdef MAZAHAKA_PLUGIN_CODE +#include "../plugin/plugin.h" +#endif #define MAX_SUBSYSTEMS (16) @@ -67,7 +70,7 @@ static RwBool useDefault; /* Class name for the MS Window's window class. */ -static const RwChar *AppClassName = RWSTRING("Grand theft auto 3"); +static const RwChar *AppClassName = RWSTRING("Grand theft auto vcs"); static psGlobalType PsGlobal; @@ -148,6 +151,19 @@ void CJoySticks::ClearJoyInfo(int joyID) m_aJoys[joyID].m_bHasAxisR = false; } +#ifdef MAZAHAKA_FIX_BACKGROUND_APP_NO_HOLD_MOUSE +bool +CheckWindowStateIsOpenedMaZaHaKa() +{ + // HWND window = ((psGlobalType *)(RsGlobal.ps))->window; // PSGLOBAL(window) + HWND window = PSGLOBAL(window); + HWND activeWindow = GetForegroundWindow(); + + // bool IsMinimized = (IsIconic(window) != 0); // no used here + bool IsActive = (window == activeWindow); + return IsActive; +} +#endif /* @@ -194,7 +210,7 @@ const char *_psGetUserFilesFolder() &KeycbData) == ERROR_SUCCESS ) { RegCloseKey(hKey); - strcat(szUserFiles, "\\GTA Vice City User Files"); + strcat(szUserFiles, "\\GTA LCS User Files"); _psCreateFolder(szUserFiles); return szUserFiles; } @@ -1541,7 +1557,7 @@ psSelectDevice() } if(bestFsMode < 0){ - MessageBox(nil, "Cannot find desired video mode", "GTA: Vice City", MB_OK); + MessageBox(nil, "Cannot find desired video mode", "GTA: LCS", MB_OK); return FALSE; } GcurSelVM = bestFsMode; @@ -2006,6 +2022,11 @@ void HandleExit() /* ***************************************************************************** */ +//#include "Windows.h" +//#include +#include "../utils/SetCurrDir.h" // ++ MAZAHAKA +#include "../utils/ConsoleTools.h" // ++ MAZAHAKA +#include int PASCAL WinMain(HINSTANCE instance, HINSTANCE prevInstance __RWUNUSED__, @@ -2018,14 +2039,40 @@ WinMain(HINSTANCE instance, RwChar **argv; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -#ifndef MASTER - if (strstr(cmdLine, "-console")) + //#ifndef MASTER + // if (strstr(cmdLine, "-console")) { - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); +#ifdef MAZAHAKA_DEBUG // ++ MAZAHAKA + // AllocConsole(); + // freopen("CONIN$", "r", stdin); + // freopen("CONOUT$", "w", stdout); + // freopen("CONOUT$", "w", stderr); + OpenConsole(); +#else +#ifndef MAZAHAKA_RELEASE_NO_SHIFT_CONSOLE_AT_START + if((GetAsyncKeyState(VK_SHIFT) & 0x8000)) { OpenConsole(); } +#endif +#endif + + // mod by diktor SET CURRENT PATH + // char currentDir[MAX_PATH]; // STATIC PATH + // GetCurrentDirectory(MAX_PATH, currentDir); + // printf("DIR: %s\n", currentDir); + // memset(currentDir, 0, MAX_PATH); + // strncpy(currentDir, "C:\\_GTA_RE\\revc\\reVC_GAME", MAX_PATH); + // currentDir[MAX_PATH - 1] = '\0'; // Ensure null-termination + // SetCurrentDirectory(currentDir); + + // char currentDir[MAX_PATH]; // dynamic set curr dir to exe + // GetModuleFileName(NULL, currentDir, MAX_PATH); + // std::string::size_type pos = std::string(currentDir).find_last_of("\\/"); + // SetCurrentDirectory(std::string(currentDir).substr(0, pos).c_str()); + if(!gbIsSettedCurrDir) { U_SetCurrentDirectory(); } } + //#endif + +#ifdef MAZAHAKA_PLUGIN_CODE + PLG_Start(); // PLG PLUGIN MAZAHAKA // after setting no debug dir #endif #ifdef USE_CUSTOM_ALLOCATOR diff --git a/src/skel/win/win.h b/src/skel/win/win.h index be840898..53de668d 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -88,4 +88,14 @@ void CloseClip(void); } #endif /* __cplusplus */ -#endif /* (!defined(_PLATFORM_WIN_H)) */ + +//#include "config.h" // ifdef? +//#ifdef MAZAHAKA_FIX_BACKGROUND_APP_NO_HOLD_MOUSE +//#include "Windows.h" +// bool CheckWindowState(HWND window = PSGLOBAL(window)); +//#endif +#ifdef MAZAHAKA_FIX_BACKGROUND_APP_NO_HOLD_MOUSE +bool CheckWindowStateIsOpenedMaZaHaKa(); +#endif + +#endif /* (!defined(_PLATFORM_WIN_H)) */ \ No newline at end of file diff --git a/src/skel/win/win.rc b/src/skel/win/win.rc index 702c3de7..645ff1fb 100644 --- a/src/skel/win/win.rc +++ b/src/skel/win/win.rc @@ -42,6 +42,6 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_MAIN_ICON ICON DISCARDABLE "gtalcs.ico" +IDI_MAIN_ICON ICON DISCARDABLE "gtavcs.ico" ///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/text/Messages.h b/src/text/Messages.h index 15abaafe..bb5898bc 100644 --- a/src/text/Messages.h +++ b/src/text/Messages.h @@ -40,13 +40,13 @@ public: static bool WideStringCompare(wchar *str1, wchar *str2, uint16 size); static void Process(void); static void Display(void); - static void AddMessage(wchar *key, uint32 time, uint16 pos); - static void AddMessageJumpQ(wchar *key, uint32 time, uint16 pos); - static void AddMessageSoon(wchar *key, uint32 time, uint16 pos); + static void AddMessage(wchar *msg, uint32 time, uint16 pos); + static void AddMessageJumpQ(wchar *msg, uint32 time, uint16 pos); + static void AddMessageSoon(wchar *msg, uint32 time, uint16 pos); static void ClearMessages(void); static void ClearSmallMessagesOnly(void); - static void AddBigMessage(wchar *key, uint32 time, uint16 pos); - static void AddBigMessageQ(wchar *key, uint32 time, uint16 pos); + static void AddBigMessage(wchar *msg, uint32 time, uint16 pos); + static void AddBigMessageQ(wchar *msg, uint32 time, uint16 pos); static void AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string); static void InsertNumberInString(wchar *src, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *dst); static void InsertStringInString(wchar *str1, wchar *str2); diff --git a/src/utils/ConsoleTools.cpp b/src/utils/ConsoleTools.cpp new file mode 100644 index 00000000..0d7c5f48 --- /dev/null +++ b/src/utils/ConsoleTools.cpp @@ -0,0 +1,100 @@ +#pragma once +#include "ConsoleTools.h" +#include "Windows.h" +#include +#include + +//#define MY_ALLOC +HANDLE InitConsole(); + + +extern bool gbIsConsoleOpened = false; + + +void OpenConsole() +{ + if(!gbIsConsoleOpened) + { +#ifdef MY_ALLOC + InitConsole(); +#else + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + gbIsConsoleOpened = true; + } +} + + + +//------------------------------------------------------------------ +HANDLE InitConsole() // with proto +{ + AllocConsole(); + + //SetConsoleOutputCP(866); + setlocale(LC_ALL, "Russian"); + SetConsoleOutputCP(1251); + SetConsoleCP(1251); + + + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN); + + return hConsole; +} + +//void LeaveConsole(HANDLE hConsole = nullptr) +void LeaveConsole(HANDLE hConsole) // with proto +{ + if (hConsole != nullptr) { SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } // Reset to default color + FreeConsole(); +} + +//void Mbox(const char* msg, const char* title) +//{ +// MessageBoxA(HWND_DESKTOP, msg, title, MB_SYSTEMMODAL | MB_ICONWARNING); +//} +// +////void MboxSTD(const std::string& msg, const std::string& title = "title") +//void MboxSTD(std::string msg, std::string title) +//{ +// MessageBoxA(HWND_DESKTOP, msg.c_str(), title.c_str(), MB_SYSTEMMODAL | MB_ICONWARNING); +//} +//void EXIT_F() +//{ +// ExitProcess(EXIT_FAILURE); +//} +//void EXIT_S() +//{ +// ExitProcess(EXIT_SUCCESS); +//} +//void RaiseError(const char* fmt, ...) +//{ +// char buf[2048]; +// va_list args; +// va_start(args, fmt); +// vsprintf_s(buf, fmt, args); +// va_end(args); +// +// MessageBoxA(HWND_DESKTOP, buf, "Fatal Error", MB_SYSTEMMODAL | MB_ICONWARNING); +// ExitProcess(EXIT_FAILURE); +//} + + +//std::string ToUpper(std::string strToConvert) +//{ +// std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), std::toupper); //::toupper +// return strToConvert; +//} +//std::string ToLower(std::string strToConvert) +//{ +// std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), std::tolower); +// return strToConvert; +//} +//std::string CustomStringConcat(std::string str1, std::string str2) { return str1 + str2; } \ No newline at end of file diff --git a/src/utils/ConsoleTools.h b/src/utils/ConsoleTools.h new file mode 100644 index 00000000..a1a9f32c --- /dev/null +++ b/src/utils/ConsoleTools.h @@ -0,0 +1,11 @@ +#pragma once +#include "Windows.h" +//#include +//#include +#pragma warning(disable : 4996) // freopen unsafe + +//#define MY_ALLOC +extern bool gbIsConsoleOpened; +void OpenConsole(); +HANDLE InitConsole(); +void LeaveConsole(HANDLE); diff --git a/src/utils/SetCurrDir.cpp b/src/utils/SetCurrDir.cpp new file mode 100644 index 00000000..7056d25f --- /dev/null +++ b/src/utils/SetCurrDir.cpp @@ -0,0 +1,23 @@ +#pragma once +#include "Windows.h" +#include + +static bool gbIsSettedCurrDir = false; +void +U_SetCurrentDirectory() +{ + // mod by diktor SET CURRENT PATH + // char currentDir[MAX_PATH]; // STATIC PATH + // GetCurrentDirectory(MAX_PATH, currentDir); + // printf("DIR: %s\n", currentDir); + // memset(currentDir, 0, MAX_PATH); + // strncpy(currentDir, "C:\\_GTA_RE\\revc\\reVC_GAME", MAX_PATH); + // currentDir[MAX_PATH - 1] = '\0'; // Ensure null-termination + // SetCurrentDirectory(currentDir); + + char currentDir[MAX_PATH]; // dynamic set curr dir to exe + GetModuleFileName(NULL, currentDir, MAX_PATH); + std::string::size_type pos = std::string(currentDir).find_last_of("\\/"); + SetCurrentDirectory(std::string(currentDir).substr(0, pos).c_str()); + gbIsSettedCurrDir = true; +} \ No newline at end of file diff --git a/src/utils/SetCurrDir.h b/src/utils/SetCurrDir.h new file mode 100644 index 00000000..c6d67c13 --- /dev/null +++ b/src/utils/SetCurrDir.h @@ -0,0 +1,7 @@ +#pragma once +#include "Windows.h" +#include + +static bool gbIsSettedCurrDir; +void +U_SetCurrentDirectory(); \ No newline at end of file diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp new file mode 100644 index 00000000..4a56e281 --- /dev/null +++ b/src/utils/Utils.cpp @@ -0,0 +1,555 @@ +#pragma once +#include "Utils.h" +//#include "../core/config.h" +#include "../core/common.h" +#include "../core/General.h" +#include "../weapons/WeaponType.h" +#include "../weapons/WeaponInfo.h" +#include "../rw/TxdStore.h" +#include "../fakerw/rpworld.h" +#include "../entities/Entity.h" +#include "../peds/Ped.h" +#include "../vehicles/Vehicle.h" +#include "../core/PlayerInfo.h" +#include "../peds/Ped.h" +#include "../peds/PlayerPed.h" +#include "../peds/CivilianPed.h" +#include "../core/Wanted.h" +#include "../control/PathFind.h" +#include "../core/Camera.h" +#include "../control/Replay.h" +#include "../renderer/Hud.h" +#include "../renderer/Font.h" +#include "../text/Text.h" +#include "../core/World.h" +#include "../control/Script.h" +#include "../core/Frontend.h" +#ifdef MAZAHAKA_FIX_BACKGROUND_APP_NO_HOLD_MOUSE +#include "../skel/win/win.h" +#endif + +//class CEntity; +//class CPed; +//class CVehicle; +//class CPlayerPed; +//class CCivilianPed; + +#include "Windows.h" +#include + + +////------------------------------------------------------------------ +//HANDLE InitConsole() // with proto +//{ +// AllocConsole(); +// +// //SetConsoleOutputCP(866); +// setlocale(LC_ALL, "Russian"); +// SetConsoleOutputCP(1251); +// SetConsoleCP(1251); +// +// +// freopen("CONIN$", "r", stdin); +// freopen("CONOUT$", "w", stdout); +// +// HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); +// SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN); +// +// return hConsole; +//} +// +////void LeaveConsole(HANDLE hConsole = nullptr) +//void LeaveConsole(HANDLE hConsole) // with proto +//{ +// if (hConsole != nullptr) { SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } // Reset to default color +// FreeConsole(); +//} + + + + +void Mbox(const char* msg, const char* title) +{ + MessageBoxA(HWND_DESKTOP, msg, title, MB_SYSTEMMODAL | MB_ICONWARNING); +} +//void MboxSTD(const std::string& msg, const std::string& title = "title") +void MboxSTD(std::string msg, std::string title) +{ + MessageBoxA(HWND_DESKTOP, msg.c_str(), title.c_str(), MB_SYSTEMMODAL | MB_ICONWARNING); +} +void EXIT_F() +{ + ExitProcess(EXIT_FAILURE); +} +void EXIT_S() +{ + ExitProcess(EXIT_SUCCESS); +} +void RaiseError(const char* fmt, ...) +{ + char buf[2048]; + va_list args; + va_start(args, fmt); + vsprintf_s(buf, fmt, args); + va_end(args); + + MessageBoxA(HWND_DESKTOP, buf, "Fatal Error", MB_SYSTEMMODAL | MB_ICONWARNING); + ExitProcess(EXIT_FAILURE); +} + + + + +void DumpTexturesNames(RpAtomic* pRpAtomic, CEntity* pEntity, bool dump_error) +{ + if (pEntity) { pRpAtomic = pEntity->GetAtomic(); } + if (!pRpAtomic) { if (dump_error) { std::cout << "!rpAtomic\n"; } return; } + if (dump_error) { printf("Atomic: 0x%p\n", pRpAtomic); } + RpGeometry* geo = pRpAtomic->geometry; + if (!geo) { if (dump_error) { std::cout << "!geo\n"; } return; } + rw::MaterialList matList = geo->matList; + //if (!matList) { return; } + //std::cout << "\n\n"; + for (int i = 0; i < matList.numMaterials; ++i) + { + RpMaterial* mat = matList.materials[i]; + if (mat && mat->texture) { + const char* textureName = mat->texture->name; + if (dump_error) { printf("%d: %s \t 0x%p\n", i, textureName, mat->texture); } + else { printf("%d: %s\n", i, textureName); } + } + //else { debug("!Material %d .", i); } + } + std::cout << "\n\n"; +} + + + +int GetModelIndex(CEntity* pEntity) // lol +{ + if (!pEntity) { return -1; } + return (pEntity->GetModelIndex()); +} + +std::string GetModelName(CEntity* pEntity) +{ + if (!pEntity) { return ""; } + //return (CModelInfo::ms_modelInfoPtrs[pEntity->GetModelIndex()]->m_name); // +".txd" ? + return (CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetModelName()); // +".txd" ? +} + +std::string GetModelTxdSlotName(CEntity* pEntity) +{ + if (!pEntity) { return ""; } + //return (CTxdStore::GetTxdName(CModelInfo::ms_modelInfoPtrs[pEntity->GetModelIndex()]->GetTxdSlot())); // +".txd" ? + return (CTxdStore::GetTxdName(CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetTxdSlot())); // +".txd" ? +} + +// crash if entity is ped +void DumpEntityData(CEntity* pEntity, bool clear_console) +{ + if (!pEntity) { std::cout << "!pEntity" << "\n"; return; } + if(clear_console) { system("cls"); } + else {std::cout << "\n\n"; } + std::cout << "MI: " << GetModelIndex(pEntity) << " Entity: 0x" << pEntity << " Name: " << GetModelName(pEntity) << "\t TXD: " << GetModelTxdSlotName(pEntity) << "\n"; + std::cout << "\n" << "Tex List" << "\n"; + DumpTexturesNames(nullptr, pEntity, false); + std::cout << "\n\n"; +} + + +CWeaponInfo* GetPlayerCurrentWeaponInfo() +{ + if (!FindPlayerPed()) { return nullptr; } + CWeaponInfo* info = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType); + return info; +} + +int32_t GetPlayerCurrentWeaponType() +{ + //if (!FindPlayerPed()) { return eWeaponType::WEAPONTYPE_UNARMED; } + if (!FindPlayerPed()) { return eWeaponType::WEAPONTYPE_UNARMED; } + //int32_t WeaponType = FindPlayerPed()->m_aWeapons[FindPlayerPed()->m_nCurrentWeapon].m_eWeaponType; + return FindPlayerPed()->GetWeapon()->m_eWeaponType; +} + + +//----- +bool IsWeaponPistol() +{ + if (!FindPlayerPed()) { return false; } + return (GetPlayerCurrentWeaponType() == WEAPONTYPE_COLT45); +} + +bool IsWeaponUziPlayer() +{ + if (!FindPlayerPed()) { return false; } + return (GetPlayerCurrentWeaponType() == WEAPONTYPE_UZI); +} + +/*bool IsWeaponAK47Player() +{ + if (!FindPlayerPed()) { return false; } + return (GetPlayerCurrentWeaponType() == WEAPONTYPE_AK47); +} + +bool IsWeaponM16Player() +{ + if (!FindPlayerPed()) { return false; } + return (GetPlayerCurrentWeaponType() == WEAPONTYPE_M16); +}*/ + +bool IsUnArmedPlayer() +{ + if (!FindPlayerPed()) { return false; } + return (GetPlayerCurrentWeaponType() == WEAPONTYPE_UNARMED); +} +//----- + + +RpClump* GetPlayerClump() +{ + if(!FindPlayerPed()) { return nullptr; } + // CWeaponInfo::GetWeaponInfo(FindPlayerPed()->m_aWeapons[FindPlayerPed()->m_nCurrentWeapon] + return (RpClump*)FindPlayerPed()->GetClump(); +} + +bool IsPlayerDriveVehicle() +{ + if(!FindPlayerPed()) { return false; } + // return FindPlayerPed()->m_pVehicle != nullptr; // NOT WORK. тачка педа остаёться если он вышел + return FindPlayerPed()->InVehicle(); // work +} + +// if (!DKSleep(deltaTime.count(), gfMemingTimer, gfTimerBuffer)) { return; } // задержка прокрута +bool DKSleep(float deltaTime, float wait_time, float& sleepBuffer) +{ + sleepBuffer += deltaTime; // Накапливаем время + // Если накопленное время больше или равно времени ожидания + if (sleepBuffer >= wait_time) { + sleepBuffer = 0.0f; // Сбрасываем накопленное время + return true; // Время ожидания истекло, возвращаем true + } + return false; // Время ожидания не истекло, возвращаем false +} + + +bool +IsWindowActive(HWND hwnd) +{ + HWND activeWindow = GetForegroundWindow(); + return (hwnd == activeWindow); +} + +bool +IsWindowMinimized(HWND hwnd) +{ + return IsIconic(hwnd) != 0; +} + + +/*wchar strW[200]; +// char strA[250]; +// sprintf(strA, "TTS DAT Reloaded!"); +AsciiToUnicode(str, strW); +if(play_beep) { CHud::SetHelpMessage(strW, true); }*/ + +std::wstring +Utf8ToWide(const std::string &utf8Str) +{ + int wideStrLen = MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, NULL, 0); + wchar_t *wideStr = new wchar_t[wideStrLen]; + MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, wideStr, wideStrLen); + std::wstring result(wideStr); + delete[] wideStr; + return result; +} + +//inline +int +GetFrontendAudioPercentVolume(bool bSFX, bool crt_vol) +{ // FrontEndMenuManager MAX VOL 128 +#define FRONTEND_AUDIO_MAX 127 + // InitConsole(); + // std::cout << "FrontEndMenuManager.m_nPrefsSfxVolume: " << FrontEndMenuManager.m_nPrefsSfxVolume << "\n"; + // std::cout << "FrontEndMenuManager.m_nPrefsMusicVolume: " << FrontEndMenuManager.m_nPrefsMusicVolume << "\n\n"; + // return 20; + int res = bSFX ? (FrontEndMenuManager.m_PrefsSfxVolume * 100) / FRONTEND_AUDIO_MAX : (FrontEndMenuManager.m_PrefsMusicVolume * 100) / FRONTEND_AUDIO_MAX; + // std::cout << "bSFX:" << bSFX << " vol:" << res << "\n"; + return res; +#undef FRONTEND_AUDIO_MAX +} + + +void +UAsciiToUnicode(const char *src, wchar *dst) // font?cpp +{ + while((*dst++ = (unsigned char)*src++) != '\0') + ; +} + + +void +UUnicodeToAscii(wchar *src, char *dst) +{ + while((*dst++ = (char)*src++) != '\0') + ; +} + +bool +IsPlayerAsPassangerNow() +{ + CPlayerPed *pPlayer = FindPlayerPed(); + if(!pPlayer) { return false; } + if(pPlayer->InVehicle() && pPlayer->m_pMyVehicle->pDriver != pPlayer) { return true; } // passanger? + return false; +} + +bool +CheckWastedBustedPlayer() // return true if wasted/busted +{ + CPlayerInfo *pPlayerInfo = &CWorld::Players[CWorld::PlayerInFocus]; + if(!pPlayerInfo) { return false; } + //CPlayerInfo::IsRestartingAfterDeath + //CPlayerInfo::IsRestartingAfterArres + return (pPlayerInfo->m_WBState != WBSTATE_PLAYING); + //return ((pPlayerInfo->m_WBState == WBSTATE_WASTED) || (pPlayerInfo->m_WBState == WBSTATE_BUSTED)); +} + +bool +IsPlayerPlaying() +{ // CPlayerInfo::MakePlayerSafe(bool toggle) + CPlayerInfo *pPlayerInfo = &CWorld::Players[CWorld::PlayerInFocus]; + CPlayerPed *pPlayer = FindPlayerPed(); + + if(!pPlayerInfo) { return false; } + if(!pPlayer) { return false; } + + // if (CCutsceneMgr::ms_running) { return false; } + // if (IsPlayerOnMission()) { return false; } // desp rando wanted +#ifdef MAZAHAKA_FIX_BACKGROUND_APP_NO_HOLD_MOUSE + if(!CheckWindowStateIsOpenedMaZaHaKa()) { return false; } +#endif + if(FrontEndMenuManager.m_bMenuActive) { return false; } + if(TheCamera.m_bFading) { return false; } + if(FrontEndMenuManager.m_bGameNotLoaded) { return false; } + if(CheckWastedBustedPlayer()) { return false; } + if(FindPlayerVehicle() && (FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_TRAIN)) { return false; } + + //if(pPlayer->InVehicle() && pPlayer->m_pMyVehicle->pDriver != pPlayer) { return false; } // passanger? + if(IsPlayerAsPassangerNow()) { return false; } // passanger? + if(CReplay::IsPlayingBack()) { return false; } + + + bool defaultgamesafeped = + (true + && pPlayer->m_pWanted->m_bIgnoredByEveryone + && pPlayer->bBulletProof + && pPlayer->bFireProof + && pPlayer->bCollisionProof + && pPlayer->bMeleeProof + && pPlayer->bOnlyDamagedByPlayer + && pPlayer->bExplosionProof + && !(pPlayer->m_bCanBeDamaged)); + if(defaultgamesafeped) { return false; } + // on true safe + // 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; + return true; +} + + +CVector +Transform3DPoint2NearPathNode(CVector target) +{ + int node = ThePaths.FindNodeClosestToCoors(target, 0, 150.0f, true, true); + if(node < 0) { return target; } + CVector output = ThePaths.m_pathNodes[node].GetPosition(); + return output; +} + +int +GetRandomNumInclude(int start, int end) +{ + // Добавляем 1 к `end` в выражении, чтобы включить верхнюю границу + return start + CGeneral::GetRandomNumberInRange(0, end - start + 1); +} + +int +GetRandomNumUnInclude(int start, int end) +{ + // Здесь верхняя граница уже исключена, поэтому никакие изменения не требуются + return start + CGeneral::GetRandomNumberInRange(0, end - start); +} + + +bool +IsWithinRadius(const CVector &point1, const CVector &point2, float radius) // есть реализация в игре готовая? +{ + CVector diff = point1 - point2; + float distSquared = diff.x * diff.x + diff.y * diff.y + diff.z * diff.z; + float radiusSquared = radius * radius; + return distSquared <= radiusSquared; +} + + +void +Message(const char *str, bool play_beep) +{ + /*std::wstring wideStr = Utf8ToWide(str); +#ifdef MAZAHAKA_SILENT_CHUD_MESSAGE + if(play_beep) { CHud::SetHelpMessage((wchar *)wideStr.c_str(), true); } + else { CHud::SetHelpMessageNoSound((wchar *)wideStr.c_str(), true); } +#else + CHud::SetHelpMessage((wchar *)wideStr.c_str(), true); +#endif*/ + + wchar strW[200]; + // char strA[250]; + // sprintf(strA, "TTS DAT Reloaded!"); + AsciiToUnicode(str, strW); + +#ifdef MAZAHAKA_SILENT_CHUD_MESSAGE + if(play_beep) { + CHud::SetHelpMessage(strW, true); + } else { + CHud::SetHelpMessageNoSound(strW, true); + } +#else + CHud::SetHelpMessage(strW, true); +#endif +} + +//__declspec(noinline) +CVehicle * +GetRandomPoolVehicle(bool nodriver, bool all) +{ + CPlayerPed *pPlayer = FindPlayerPed(); + int j = CPools::GetVehiclePool()->GetSize(); + while(j-- > 0) { + //if(CVehicle *veh = CPools::GetVehiclePool()->GetSlot(j)) veh->BlowUpCar(nil); + CVehicle *veh = CPools::GetVehiclePool()->GetSlot(j); + if(!veh) {continue; } + if(pPlayer && pPlayer->InVehicle() && pPlayer->m_pMyVehicle == veh) { continue; } + if(all) { if(veh->IsCar()) { return veh; } } + else { + if(nodriver && (!veh->pDriver) && veh->IsCar()) { return veh; } + else if(!nodriver && veh->pDriver && veh->IsCar()) { return veh; } + } + + } + + /*while(1) + { + int i = _RandVUKL(0, CPools::GetVehiclePool()->GetSize()); + CVehicle *veh = CPools::GetVehiclePool()->GetSlot(i); + if(veh && veh->IsCar()) { return veh; } + Sleep(0); + }*/ + return nil; +} + +CVehicle* +GetVehicleNearPlayer() +{ + //CVehicle *veh = nil; + CPlayerPed *pPlayer = FindPlayerPed(); + CPlayerInfo *pPlayerInfo = &CWorld::Players[CWorld::PlayerInFocus]; + if(!pPlayer || !pPlayerInfo) { return false; } + //veh = pPlayer->m_pMyVehicle; // tmp dummy + + bool weAreOnBoat = false; + float lastCloseness = 0.0f; + CVehicle *carBelow = nil; + CEntity *surfaceBelow = pPlayer->m_pCurrentPhysSurface; + if(surfaceBelow && surfaceBelow->IsVehicle()) { + carBelow = (CVehicle *)surfaceBelow; + if(carBelow->IsBoat()) { + weAreOnBoat = true; + pPlayer->bOnBoat = true; +#ifdef VC_PED_PORTS + if(carBelow->GetStatus() != STATUS_WRECKED && carBelow->GetUp().z > 0.3f) +#else + if(carBelow->GetStatus() != STATUS_WRECKED) +#endif + pPlayer->SetSeekBoatPosition(carBelow); + } + } + // Find closest car + if(!weAreOnBoat) { + float minX = pPlayer->GetPosition().x - 10.0f; + float maxX = 10.0f + pPlayer->GetPosition().x; + float minY = pPlayer->GetPosition().y - 10.0f; + float maxY = 10.0f + pPlayer->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); + pPlayerInfo->FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES], pPlayer, minX, minY, maxX, maxY, &lastCloseness, + &carBelow); + pPlayerInfo->CPlayerInfo::FindClosestCarSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], pPlayer, minX, minY, maxX, + maxY, &lastCloseness, &carBelow); + } + } + } + + + return carBelow; +} + +void +DumpAllScriptsOffsets() +{ + // re3.cpp (no have re3.h) + static const char* missions[] = { + "initial: objects", "initial: hidden packages", "initial: car generators", "initial: pickups", "initial: unique stunt jumps", + "initial: player", "initial: general info", "initial: lods", "initial: weapons", "Home Sweet Home", "Taxi-Driver Sub-Mission", + "Paramedic Sub-Mission", "Vigilante Sub-Mission", "Karmageddon", "Firefighter Sub-Mission", "Trash Dash", "RC Triad Take-Down", + "Thrashin' RC", "Ragin' RC", "Chasin' RC", "GO GO Faggio", "Noodleboy", "Pizzaboy", "Wong Side Of The Tracks", "Bumps and Grinds: Course 1", + "Bumps and Grinds: Course 2", "Bumps and Grinds: Course 3", "Bumps and Grinds: Course 4", "Bumps and Grinds: Course 5", "Bumps and Grinds: Course 6", + "Bumps and Grinds: Course 7", "Bumps and Grinds: Course 8", "Bumps and Grinds: Course 9", "Bumps and Grinds: Course 10", "Car Salesman", "Bike Salesman", + "RACE: Low-Rider Rumble", "RACE: Deimos Dash", "RACE: Wi-Cheetah Run", "RACE: Red Light Racing", "RACE: Torrington TT", "RACE: Gangsta GP", + "Scooter Shooter", "AWOL Angel", "9mm Mayhem", "Scrapyard Challenge", "See the Sight Before your Flight", "SlashTV", "Slacker (Vincenzo)", + "Dealing Revenge (Vincenzo)", "Snuff (Vincenzo)", "Smash and Grab (Vincenzo)", "Hot Wheels (Vincenzo)", "The Portland Chainsaw Masquerade (Vincenzo)", + "The Offer (Salvatore)", "Ho Selecta! (Salvatore)", "Frighteners (Salvatore)", "Rollercoaster Ride (Salvatore)", "Contra-Banned (Salvatore)", + "Sindacco Sabotage (Salvatore)", "The Trouble with Triads (Salvatore)", "Driving Mr Leone (Salvatore)", "conversation (JD)", "Bone Voyeur! (JD)", + "Don in 60 Seconds (JD)", "A Volatile Situation (JD)", "Blow up 'Dolls' (JD)", "Salvatore's Salvation (JD)", "The Guns of Leone (JD)", + "Calm before the Storm (JD)", "The Made Man (JD)", "Snappy Dresser (Ma Cipriani)", "Big Rumble in Little China (Ma Cipriani)", "Grease Sucho (Ma Cipriani)", + "Dead Meat (Ma Cipriani)", "No Son of Mine (Ma Cipriani)", "Shop 'til you Strop (Maria)", "Taken for a Ride (Maria)", "Booby Prize (Maria)", + "Biker Heat (Maria)", "Overdose of Trouble (Maria)", "Making Toni (Salvatore)", "A Walk In The Park (Salvatore)", "Caught In The Act (Salvatore)", + "Search And Rescue (Salvatore)", "Taking The Peace (Salvatore)", "Shoot The Messenger (Salvatore)", "Sayonara Sindaccos (Leon McAffrey)", + "The Whole 9 Yardies (Leon McAffrey)", "Crazy '69' (Leon McAffrey)", "Night Of The Livid Dreads (Leon McAffrey)", "Munitions Dump (Leon McAffrey)", + "The Morgue Party Candidate (Donald Love)", "Steering The Vote (Donald Love)", "Cam-Pain (Donald Love)", "Friggin' The Riggin' (Donald Love)", + "Love & Bullets (Donald Love)", "Counterfeit Count (Donald Love)", "Love On The Rocks (Donald Love)", "L.C. Confidential (Church Confessional)", + "The Passion Of The Heist (Church Confessional)", "Karmageddon (Church Confessional)", "False Idols (Church Confessional)", "Rough Justice (Salvatore)", + "Dead Reckoning (Salvatore)", "Shogun Showdown (Salvatore)", "The Shoreside Redemption (Salvatore)", "The Sicilian Gambit (Salvatore)", + "Panlantic Land Grab (Donald Love)", "Stop the Press (Donald Love)", "Morgue Party Resurrection (Donald Love)", "No Money, Mo' Problems (Donald Love)", + "Bringing the House Down (Donald Love)", "Love on the Run (Donald Love)", "More Deadly than the Male (Toshiko Kasen)", "Cash Clash (Toshiko Kasen)", + "A Date with Death (Toshiko Kasen)", "Cash in Kazuki's Chips (Toshiko Kasen)" + }; + + CPlayerPed *pPlayer = FindPlayerPed(); + if(!pPlayer || FrontEndMenuManager.m_bGameNotLoaded) { return; } // if not loaded, scm offsets not inited, only in game + //void CTheScripts::ReadMultiScriptFileOffsetsFromScript() Script5.cpp + int NumberOfMissionScripts = CTheScripts::NumberOfMissionScripts; + for(int i = 0; i < NumberOfMissionScripts; i++) + { // todo refw auto labels? + std::cout << i << ": " << "0x" << std::hex << CTheScripts::MultiScriptArray[i] << std::dec << " " << missions[i] << "\n"; + } +} \ No newline at end of file diff --git a/src/utils/Utils.h b/src/utils/Utils.h new file mode 100644 index 00000000..c3600576 --- /dev/null +++ b/src/utils/Utils.h @@ -0,0 +1,115 @@ +#pragma once +#include "../core/common.h" + +class CEntity; +class CPed; +class CVehicle; +class CPlayerPed; +class CCivilianPed; +class CWeaponInfo; + +//struct RpAtomic; + +#include "Windows.h" +#include + +//HANDLE InitConsole(); +//void LeaveConsole(HANDLE hConsole); + + + + +void Mbox(const char* msg, const char* title); +//void MboxSTD(const std::string& msg, const std::string& title = "title") +void MboxSTD(std::string msg, std::string title = ""); +void EXIT_F(); +void EXIT_S(); +void RaiseError(const char* fmt, ...); + + + +void DumpTexturesNames(RpAtomic* pRpAtomic, CEntity* pEntity = nullptr, bool dump_error = true); + + + +int GetModelIndex(CEntity* pEntity); + +std::string GetModelName(CEntity* pEntity); + +std::string GetModelTxdSlotName(CEntity* pEntity); + +// crash if entity is ped +void DumpEntityData(CEntity* pEntity, bool clear_console = true); + +CWeaponInfo* GetPlayerCurrentWeaponInfo(); + +int32_t GetPlayerCurrentWeaponType(); + + +//----- +bool IsWeaponPistol(); +bool IsWeaponUziPlayer(); +bool IsWeaponAK47Player(); +bool IsWeaponM16Player(); +bool IsUnArmedPlayer(); +//----- + +RpClump* GetPlayerClump(); +bool IsPlayerDriveVehicle(); + +// if(!DKSleep(deltaTime.count(), gfMemingTimer, gfTimerBuffer)) { return; } // задержка прокрута +bool DKSleep(float deltaTime, float wait_time, float& sleepBuffer); + +bool +IsWindowActive(HWND hwnd); + +bool +IsWindowMinimized(HWND hwnd); + +// example in cpp +//std::wstring +//Utf8ToWide(const std::string &utf8Str); + +//inline +int +GetFrontendAudioPercentVolume(bool bSFX, bool crt_vol = true); + +void +UAsciiToUnicode(const char *src, wchar *dst); // font.cpp + +void +UUnicodeToAscii(wchar *src, char *dst); + + +bool +IsPlayerAsPassangerNow(); + +bool +CheckWastedBustedPlayer(); // return true if wasted/busted + +bool +IsPlayerPlaying(); + +CVector +Transform3DPoint2NearPathNode(CVector target); + +int +GetRandomNumInclude(int start, int end); + +int +GetRandomNumUnInclude(int start, int end); + +bool +IsWithinRadius(const CVector &point1, const CVector &point2, float radius); + +void +Message(const char *str, bool play_beep = true); + +CVehicle * +GetRandomPoolVehicle(bool nodriver = false, bool all = false); + +CVehicle * +GetVehicleNearPlayer(); + +void +DumpAllScriptsOffsets(); \ No newline at end of file diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index b0f21af7..4e906b3a 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -4893,8 +4893,10 @@ CAutomobile::BlowUpCar(CEntity *culprit) { RpAtomic *atomic; - if(!bCanBeDamaged) - return; + if(!bCanBeDamaged) { return; } +#ifdef MAZAHAKA_MISC + //if(bExplosionProof) { return; } // mazahaka // fire +#endif if(culprit == FindPlayerPed() || culprit == FindPlayerVehicle()){ CWorld::Players[CWorld::PlayerInFocus].m_nHavocLevel += 20; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index cf46f37b..19448b72 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -109,6 +109,9 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) m_boom.Init(-PI/10.0f, PI/10.0f, 0, 2); else m_boom.Init(-PI/5.0f, PI/5.0f, 0, 2); +#ifdef MAZAHAKA_MISC + //bool m_bIsBlowProof = false; +#endif } void @@ -840,8 +843,11 @@ CBoat::BlowUpCar(CEntity *culprit) RwMatrix *matrix; CObject *obj; - if(!bCanBeDamaged) - return; + if(!bCanBeDamaged) { return; } +#ifdef MAZAHAKA_MISC + //if(bExplosionProof) { return; } // mazahaka + //if(m_bIsBlowProof) { return; } // mazahaka can explode if fire and exproof but if fire and blow proof dont!! +#endif // explosion pushes vehicle up m_vecMoveSpeed.z += 0.13f; diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h index 5d866c48..6d63bcce 100644 --- a/src/vehicles/Boat.h +++ b/src/vehicles/Boat.h @@ -46,6 +46,9 @@ public: uint16 m_nNumWakePoints; CVector2D m_avec2dWakePoints[32]; float m_afWakePointLifeTime[32]; +#ifdef MAZAHAKA_MISC + //bool m_bIsBlowProof; // like explosion proof but if exproof and check in blow its fire but not blow and broke game logic +#endif static float MAX_WAKE_LENGTH; static float MIN_WAKE_INTERVAL; diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index d4b58f05..2b850c8a 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -68,6 +68,7 @@ void CCranes::InitCranes(void) } } // TODO(LCS) +#ifndef MAZAHAKA_MAPZONE_VC for (CPtrNode* pNode = CWorld::GetBigBuildingList(LEVEL_INDUSTRIAL).first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; if (MODELID_CRANE_1 == pEntity->GetModelIndex() || @@ -78,7 +79,18 @@ void CCranes::InitCranes(void) MODELID_CRANE_6 == pEntity->GetModelIndex()) AddThisOneCrane(pEntity); } - +#else + for (CPtrNode* pNode = CWorld::GetBigBuildingList(LEVEL_MAINLAND).first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + if (MODELID_CRANE_1 == pEntity->GetModelIndex() || + MODELID_CRANE_2 == pEntity->GetModelIndex() || + MODELID_CRANE_3 == pEntity->GetModelIndex() || + MODELID_CRANE_4 == pEntity->GetModelIndex() || + MODELID_CRANE_5 == pEntity->GetModelIndex() || + MODELID_CRANE_6 == pEntity->GetModelIndex()) + AddThisOneCrane(pEntity); + } +#endif } void CCranes::AddThisOneCrane(CEntity* pEntity) diff --git a/src/vehicles/Ferry.cpp b/src/vehicles/Ferry.cpp index 339c2819..bacdd2bf 100644 --- a/src/vehicles/Ferry.cpp +++ b/src/vehicles/Ferry.cpp @@ -21,9 +21,12 @@ CFerryInst* CFerry::mspInst; #define FERRY_SPEED (0.1f) #define FERRY_SLOWDOWN_DISTANCE (50.0f) #define FERRY_TIME_STOPPED_AT_STATION (10.0f) +#define FERRY_MODEL_INDEX MI_FERRY +//#define FERRY_MODEL_INDEX MI_BANSHEE CFerry::CFerry(int32 id, uint8 owner) : CVehicle(owner) { +#ifdef GTA_FERRY m_bPlayerArrivedHorn = false; m_nTimeAlongPath = 0; m_vehType = VEHICLE_TYPE_FERRY; @@ -51,10 +54,12 @@ CFerry::CFerry(int32 id, uint8 owner) : CVehicle(owner) m_nCollision = 0; m_pDefaultColModel = mi->GetColModel(); m_level = LEVEL_GENERIC; +#endif } void CFerry::Init(void* pInstancePtr) { +#ifdef GTA_FERRY mspInst = (CFerryInst*)pInstancePtr; if (mspInst) return; @@ -198,10 +203,12 @@ void CFerry::Init(void* pInstancePtr) // end pPath->aLineBits[j].time = pPath->TotalDurationOfTrack; } +#endif } void CFerry::InitFerrys(void) { +#ifdef GTA_FERRY printf("init ferrys\n"); #ifdef GTA_NETWORK if (gIsMultiplayerGame) @@ -212,12 +219,14 @@ void CFerry::InitFerrys(void) for (int i = 0; i < NUM_FERRIES; i++) mspInst->m_apFerries[i] = nil; CStreaming::LoadAllRequestedModels(false); - CStreaming::RequestModel(MI_FERRY, 0); + CStreaming::RequestModel(FERRY_MODEL_INDEX, 0); CStreaming::LoadAllRequestedModels(false); +#endif } void CFerry::SwitchFerryCollision(int type) { +#ifdef GTA_FERRY for (int i = 0; i < NUM_FERRIES; i++) { CFerry* pFerry = GetFerry(i); if (pFerry && pFerry->m_nCollision != type) { @@ -229,10 +238,12 @@ void CFerry::SwitchFerryCollision(int type) mi->SetColModel(pFerry->m_pDefaultColModel, true); } } +#endif } void CFerry::UpdateFerrys(void) { +#ifdef GTA_FERRY int i, j; float t, deltaT; if (mspInst->m_bFerriesDisabled) @@ -301,18 +312,22 @@ void CFerry::UpdateFerrys(void) } } } +#endif } void CFerry::SetModelIndex(uint32 mi) { +#ifdef GTA_FERRY CVehicle::SetModelIndex(mi); for (int i = 0; i < NUM_FERRY_NODES; i++) m_aFerryNodes[i] = nil; CClumpModelInfo::FillFrameArray(GetClump(), m_aFerryNodes); +#endif } void CFerry::PreRender(void) { +#ifdef GTA_FERRY CVehicleModelInfo* mi = GetModelInfo(); if (CGeneral::GetRandomTrueFalse()) CParticle::AddParticle(PARTICLE_FERRY_CHIM_SMOKE, GetMatrix() * mi->m_positions[FERRY_POS_CHIM_LEFT], CVector(0.0f, 0.0f, 0.2f)); @@ -344,16 +359,20 @@ void CFerry::PreRender(void) CVector vRearLightPosition2 = vRearLightPosition - 2 * mi->m_positions[FERRY_POS_LIGHT_REAR].x * GetRight(); CCoronas::RegisterCorona((uint32)(uintptr)this + 28, 255, 0, 0, 255, vRearLightPosition2, 1.0f, 80.0f, CCoronas::TYPE_NORMAL, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); CCoronas::RegisterCorona((uint32)(uintptr)this + 29, 255, 0, 0, 255, vRearLightPosition, 1.0f, 80.0f, CCoronas::TYPE_NORMAL, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); +#endif } void CFerry::Render(void) { +#ifdef GTA_FERRY m_bAlreadyRendered = true; CEntity::Render(); +#endif } void CFerry::RenderAllRemaning(void) { +#ifdef GTA_FERRY #ifdef GTA_NETWORK if (gIsMultiplayerGame) return; @@ -366,19 +385,23 @@ void CFerry::RenderAllRemaning(void) pFerry->m_bAlreadyRendered = false; } } +#endif } void CFerry::FerryHitStuff(CPtrList& lst) { +#ifdef GTA_FERRY for (CPtrNode* pNode = lst.first; pNode != nil; pNode = pNode->next) { CPhysical* pEntity = (CPhysical*)pNode->item; if (pEntity != this && Abs(GetPosition().x - pEntity->GetPosition().z) < 1.5f) pEntity->bHitByTrain = true; } +#endif } void CFerry::ProcessControl(void) { +#ifdef GTA_FERRY if (gbModelViewer) return; PruneWakeTrail(); @@ -564,15 +587,15 @@ void CFerry::ProcessControl(void) if (m_rwObject) DeleteRwObject(); } - else if (CStreaming::HasModelLoaded(MI_FERRY)) { + else if (CStreaming::HasModelLoaded(FERRY_MODEL_INDEX)) { if (m_rwObject == nil) { m_modelIndex = -1; - SetModelIndex(MI_FERRY); + SetModelIndex(FERRY_MODEL_INDEX); } } else { if (FindPlayerCoors().z * GetPosition().z >= 0.0f) - CStreaming::RequestModel(MI_FERRY, STREAMFLAGS_DEPENDENCY); + CStreaming::RequestModel(FERRY_MODEL_INDEX, STREAMFLAGS_DEPENDENCY); } // Hit stuff @@ -610,10 +633,12 @@ void CFerry::ProcessControl(void) FerryHitStuff(s->m_lists[ENTITYLIST_PEDS_OVERLAP]); } } +#endif } void CFerry::OpenFerryDoor(float ratio) { +#ifdef GTA_FERRY if (!m_rwObject) return; @@ -640,10 +665,12 @@ void CFerry::OpenFerryDoor(float ratio) doorL.UpdateRW(); doorR.UpdateRW(); +#endif } CVector CFerry::GetBoardingSpace(CFerry::eSpaceUse use, CFerry::eSpaceStyle style, uint8 position) { +#ifdef GTA_FERRY CVehicleModelInfo* pModelInfo = GetModelInfo(); CVector space; if (m_nFerryId & 1) { @@ -669,10 +696,14 @@ CVector CFerry::GetBoardingSpace(CFerry::eSpaceUse use, CFerry::eSpaceStyle styl break; } return space; +#else + return CVector(); +#endif } CFerry* CFerry::GetClosestFerry(float x, float y) { +#ifdef GTA_FERRY int closest = -1; float mindist = 9999.9f; for (int i = 0; i < NUM_FERRIES; i++) { @@ -688,15 +719,23 @@ CFerry* CFerry::GetClosestFerry(float x, float y) if (closest == -1) return nil; return GetFerry(closest); +#else + return nil; +#endif } bool CFerry::IsDocked(void) { +#ifdef GTA_FERRY return m_bFerryDocked; +#else + return false; +#endif } void CFerry::OpenDoor(void) { +#ifdef GTA_FERRY printf("opening the ferry door\n"); m_nDoorState = FERRY_DOOR_OPENING; m_nDoorTimer = CTimer::GetTimeInMilliseconds() + 10000; @@ -708,42 +747,58 @@ void CFerry::OpenDoor(void) if (fDistToCar4 < fDistToCar1) m_bUseFrontDoor = false; AudioManager.DirectlyEnqueueSample(SFX_GATE_START_CLU, SFX_BANK_0, 0, 1, 22050, 127, 20); +#endif } void CFerry::CloseDoor(void) { +#ifdef GTA_FERRY printf("closing the ferry door\n"); m_nDoorState = FERRY_DOOR_CLOSING; m_nDoorTimer = CTimer::GetTimeInMilliseconds() + 10000; AudioManager.DirectlyEnqueueSample(SFX_GATE_START_CLU, SFX_BANK_0, 0, 1, 22050, 127, 20); // shouldn't this be SFX_GATE_STOP_CLU? +#endif } bool CFerry::IsDoorOpen(void) { +#ifdef GTA_FERRY return m_nDoorState == FERRY_DOOR_OPEN; +#else + return false; +#endif } bool CFerry::IsDoorClosed(void) { +#ifdef GTA_FERRY return m_nDoorState == FERRY_DOOR_CLOSED; +#else + return false; +#endif } void CFerry::CompleteDorrMovement(void) { +#ifdef GTA_FERRY m_nDoorTimer = 0; +#endif } void CFerry::DissableFerryPath(int) { +#ifdef GTA_FERRY +#endif } void CFerry::EnableFerryPath(int path) { +#ifdef GTA_FERRY CStreaming::LoadAllRequestedModels(false); - CStreaming::RequestModel(MI_FERRY, 0); + CStreaming::RequestModel(FERRY_MODEL_INDEX, 0); CStreaming::LoadAllRequestedModels(false); for (int i = path * 2; i < path * 2 + 2; i++) { - CFerry* pFerry = new CFerry(MI_FERRY, PERMANENT_VEHICLE); + CFerry *pFerry = new CFerry(FERRY_MODEL_INDEX, PERMANENT_VEHICLE); bool bDirect = i & 1; mspInst->m_apFerries[i] = pFerry; pFerry->SetPosition(0.0f, 0.0f, 0.0f); @@ -754,15 +809,19 @@ void CFerry::EnableFerryPath(int path) pFerry->m_nCurTrackNode = 0; CWorld::Add(pFerry); } +#endif } void CFerry::SkipFerryToNextDock(void) { +#ifdef GTA_FERRY m_nSkipFerryStatus = 1; +#endif } void CFerry::PruneWakeTrail(void) { +#ifdef GTA_FERRY int16 num_remaining = 0; for (int i = 0; i < NUM_WAKE_POINTS; i++) { if (mspInst->m_afWakePointTimer[m_nFerryId][i] <= 0.0f) @@ -775,10 +834,12 @@ void CFerry::PruneWakeTrail(void) num_remaining++; } mspInst->m_anNumWakePoints[m_nFerryId] = num_remaining; +#endif } void CFerry::AddWakePoint(CVector point) { +#ifdef GTA_FERRY if (mspInst->m_afWakePointTimer[m_nFerryId][0] > 0.0f) { int nNewWakePoints = Min(NUM_WAKE_POINTS - 1, mspInst->m_anNumWakePoints[m_nFerryId]); for (int i = 0; i < nNewWakePoints; i++) { @@ -789,10 +850,12 @@ void CFerry::AddWakePoint(CVector point) mspInst->m_avWakePoints[m_nFerryId][0] = point; mspInst->m_afWakePointTimer[m_nFerryId][0] = 900.0f; // TODO: define mspInst->m_anNumWakePoints[m_nFerryId] += 1; +#endif } void CFerry::PlayArrivedHorn(void) { +#ifdef GTA_FERRY if (m_bPlayerArrivedHorn) return; m_bPlayerArrivedHorn = true; @@ -801,23 +864,31 @@ void CFerry::PlayArrivedHorn(void) uint8 volume = (200.0f - fDistToCamera) / 200.0f * 127; AudioManager.DirectlyEnqueueSample(SFX_CAR_HORN_TRUCK, SFX_BANK_0, 0, 1, 18000, volume, 50); } +#endif } CVector CFerry::GetNearestDoor(CVector) { +#ifdef GTA_FERRY return CVector(0.0f, 0.0f, 1.0f); +#else + return CVector(); +#endif } void CFerry::SetupForMultiplayer(void) { +#ifdef GTA_FERRY for (int i = 0; i < NUM_FERRIES; i++) mspInst->m_apFerries[i] = nil; printf("setting up the ferrys for multiplayer\n"); - CStreaming::SetModelIsDeletable(MI_FERRY); + CStreaming::SetModelIsDeletable(FERRY_MODEL_INDEX); +#endif } void CFerry::Write(base::cRelocatableChunkWriter& writer) { +#ifdef GTA_FERRY writer.AllocateRaw(mspInst, sizeof(*mspInst), 4); if (!mspInst) return; @@ -829,5 +900,6 @@ void CFerry::Write(base::cRelocatableChunkWriter& writer) writer.AllocateRaw(mspInst->pPathData[i]->aLineBits, (NUM_FERRY_STATIONS * 4 + 2) * sizeof(CFerryInterpolationLine), 4); writer.AddPatch(&mspInst->pPathData[i]->aTrackNodes); } +#endif } diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 7684d7dd..adc5df4c 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -693,6 +693,7 @@ CPlane::RenderAllRemaning(void) void CPlane::InitPlanes(void) { +#ifdef FLIGHT_PATH int i; CesnaMissionStatus = CESNA_STATUS_NONE; @@ -802,6 +803,7 @@ CPlane::InitPlanes(void) plane->m_nCurPathNode = 0; CWorld::Add(plane); } +#endif } void