From 37f07c87c502aa34fb0f44fc6df2ab771c60ca66 Mon Sep 17 00:00:00 2001 From: Terri00 Date: Sun, 17 Mar 2019 03:05:07 +0000 Subject: [PATCH] Installer FGD entries, fixed copyfiles --- .../AutoRadar_installer.vcxproj | 2 + AutoRadar_installer/main.cpp | 50 +++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/AutoRadar_installer/AutoRadar_installer.vcxproj b/AutoRadar_installer/AutoRadar_installer.vcxproj index 4952a2b..3b6a283 100644 --- a/AutoRadar_installer/AutoRadar_installer.vcxproj +++ b/AutoRadar_installer/AutoRadar_installer.vcxproj @@ -81,6 +81,7 @@ Disabled true true + MultiThreadedDebug @@ -99,6 +100,7 @@ true true true + MultiThreaded true diff --git a/AutoRadar_installer/main.cpp b/AutoRadar_installer/main.cpp index 12ac9ba..51ba483 100644 --- a/AutoRadar_installer/main.cpp +++ b/AutoRadar_installer/main.cpp @@ -3,6 +3,7 @@ #include "../MCDV/util.h" #include +#include #include #include #include @@ -136,16 +137,16 @@ int main(){ if (_access_s(fDstFolder.c_str(), 0)) { std::cout << "mkdr " << fs::getDirName(f) << "\n"; - CreateDirectory(fDstFolder.c_str(), NULL); + SHCreateDirectoryExA(NULL, fDstFolder.c_str(), NULL); } std::cout << "copy " << f << "\n"; fs::copyFile(source_folder + f, target_folder + f); } - } - std::cout << "\n"; + std::cout << "\n"; + } // Install command sequences std::cout << "Installing command sequences\n________________________________________________________\n\n"; @@ -208,8 +209,47 @@ int main(){ } // Install custom entities - - cc::success(); std::cout << "Completed setup!\n"; + std::cout << "\nInstalling custom entity entries\n________________________________________________________\n\n"; + + std::ifstream ifs_gameconfig(csgo_sdk_bin_path + "GameConfig.txt"); + if (!ifs_gameconfig) { + cc::error(); + std::cout << "GameConfig.txt not found. custom entites will not be installed...\n" << std::endl; + } + else { + cc::info(); + std::cout << "Adding GameConfig.cfg FGD entries\n"; + fs::copyFile(csgo_sdk_bin_path + "GameConfig.txt", csgo_sdk_bin_path + "GameConfig.txt.bak"); + + std::string str_gameconfig((std::istreambuf_iterator(ifs_gameconfig)), std::istreambuf_iterator()); + kv::FileData gameConfig(str_gameconfig); + + kv::DataBlock* hammerBlock = gameConfig.headNode.SubBlocks[0].GetFirstByName("\"Games\"")->GetFirstByName("\"Counter-Strike: Global Offensive\"")->GetFirstByName("\"Hammer\""); + int freeIndex = -1; + + for (auto && newEntry : vinfodata.GetAllByName("HammerVGDRegistry")){ + // Check if entry exists + int i = -1; + bool matched = false; + while (hammerBlock->Values.count("GameData" + std::to_string(++i))) { + if (csgo_sdk_bin_path + newEntry.Values["source"] == hammerBlock->Values["GameData" + std::to_string(i)]) { + matched = true; + break; + } + } + + if (matched) continue; + + while (hammerBlock->Values.count("GameData" + std::to_string(++freeIndex))); + hammerBlock->Values.insert({ "GameData" + std::to_string(freeIndex), csgo_sdk_bin_path + newEntry.Values["source"]}); + } + + std::cout << "Saving GameConfig.cfg\n"; + std::ofstream out(std::string(csgo_sdk_bin_path + "GameConfig.txt").c_str()); + gameConfig.headNode.SubBlocks[0].Serialize(out); + } + + cc::success(); std::cout << "\nCompleted setup!\n"; /* Small wait to auto close */ for (int i = 10; i > 0; i--) { -- 2.25.1