diff --git a/README.md b/README.md index cb68a5a..938c3a4 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Let me know if you mind more. ## Things to do on crash 1. Delete the `CheatMenu/json/config.json` file and try again. -2. If it's happening after installing a recent mod try removing it. A list of incompatibile mods are [here](https://github.com/user-grinch/Cheat-Menu/issues/48). +2. If it's happening after installing a recent mod try removing it. 3. Try on a fresh installation of the game. 4. If still doesn't fix your issue, go ahead and report it. diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 2d1338f..db67e3d 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -82,7 +82,13 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { if (nReason == DLL_PROCESS_ATTACH) { - if (GetGameVersion() == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) + uint gameVer = GetGameVersion(); + +#ifdef GTASA + if (gameVer == GAME_10US_HOODLUM || gameVer == GAME_10US_COMPACT) +#else + if (gameVer == BY_GAME(NULL, GAME_10EN, GAME_10EN)) +#endif { CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); } diff --git a/src/filehandler.cpp b/src/filehandler.cpp index e3042b1..e0a1a4d 100644 --- a/src/filehandler.cpp +++ b/src/filehandler.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include "filehandler.h" -// TODO: Clean up this mess, use structures instead? +#ifdef GTASA void FileHandler::GenerateHandlingFile(tHandlingData *pHandling, std::map& storeMap) { FILE* fp = fopen("handling.txt", "w"); @@ -57,6 +57,58 @@ void FileHandler::GenerateHandlingFile(tHandlingData *pHandling, std::map& storeMap) +{ + std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); + if (!std::filesystem::exists(m_FilePath)) + { + gLog << "Vehicle.ide not found"; + return; + } + + std::ifstream file(m_FilePath); + std::string line; + while (getline(file, line)) + { + /* + Format: model, modelname, txdname, type, handlingId, ... + Skip if first thing isn't model id + */ + if (line[0] <= '0' || line[0] >= '9') + { + continue; + } + + // running inside try block to handle user errors, mostly commas + try + { + std::string temp; + std::stringstream ss(line); + + // get model + getline(ss, temp, ','); + int model = std::stoi(temp); + + // get modelname, txd, type, handlingId + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); + + temp.erase(std::remove_if(temp.begin(), temp.end(), isspace), temp.end()); + + storeMap[model] = temp; + } + catch (...) + { + gLog << "Error parsing vehicles.ide, " << line << std::endl; + } + } + + file.close(); +} +#endif + void FileHandler::FetchColorData(std::vector>& storeVec) { std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat"); @@ -130,54 +182,3 @@ void FileHandler::FetchColorData(std::vector>& storeVec) file.close(); } - -void FileHandler::FetchHandlingID(std::map& storeMap) -{ - std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); - if (!std::filesystem::exists(m_FilePath)) - { - gLog << "Vehicle.ide not found"; - return; - } - - std::ifstream file(m_FilePath); - std::string line; - while (getline(file, line)) - { - /* - Format: model, modelname, txdname, type, handlingId, ... - Skip if first thing isn't model id - */ - if (line[0] <= '0' || line[0] >= '9') - { - continue; - } - - // running inside try block to handle user errors, mostly commas - try - { - std::string temp; - std::stringstream ss(line); - - // get model - getline(ss, temp, ','); - int model = std::stoi(temp); - - // get modelname, txd, type, handlingId - getline(ss, temp, ','); - getline(ss, temp, ','); - getline(ss, temp, ','); - getline(ss, temp, ','); - - temp.erase(std::remove_if(temp.begin(), temp.end(), isspace), temp.end()); - - storeMap[model] = temp; - } - catch (...) - { - gLog << "Error parsing vehicles.ide, " << line << std::endl; - } - } - - file.close(); -} \ No newline at end of file diff --git a/src/filehandler.h b/src/filehandler.h index efb299e..5be0e21 100644 --- a/src/filehandler.h +++ b/src/filehandler.h @@ -17,11 +17,14 @@ public: TODO: Implement something that also parses modloader data */ static void FetchColorData(std::vector>& storeVec); + +#ifdef GTASA /* Parses data/vehicles.ide file and stores handingId in a map TODO: Implement something that also parses modloader data */ static void FetchHandlingID(std::map& storeMap); static void GenerateHandlingFile(tHandlingData *pHandling, std::map& storeMap); +#endif };