Installer FGD entries, fixed copyfiles
authorTerri00 <thrustmediaproductions@gmail.com>
Sun, 17 Mar 2019 03:05:07 +0000 (03:05 +0000)
committerTerri00 <thrustmediaproductions@gmail.com>
Sun, 17 Mar 2019 03:05:07 +0000 (03:05 +0000)
AutoRadar_installer/AutoRadar_installer.vcxproj
AutoRadar_installer/main.cpp

index 4952a2b92657485275352d02a0d7e38c512cae2d..3b6a283c3ab7b4275adbe45e8ab6c4a2785ccce5 100644 (file)
@@ -81,6 +81,7 @@
       <Optimization>Disabled</Optimization>
       <SDLCheck>true</SDLCheck>
       <ConformanceMode>true</ConformanceMode>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
       <ConformanceMode>true</ConformanceMode>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
index 12ac9ba715f051bf83fb44d57d0af7ff1049636c..51ba4839fe0e5d8d790df2511d0aaf1e6768b710 100644 (file)
@@ -3,6 +3,7 @@
 #include "../MCDV/util.h"
 
 #include <windows.h>
+#include <ShlObj_core.h>
 #include <iostream>
 #include <io.h>
 #include <fstream>
@@ -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<char>(ifs_gameconfig)), std::istreambuf_iterator<char>());
+               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--) {