VDF parsing fix for stray '{', overlapping buyzone/bombsite support
authorTerri00 <thrustmediaproductions@gmail.com>
Sun, 24 Mar 2019 00:27:52 +0000 (00:27 +0000)
committerTerri00 <thrustmediaproductions@gmail.com>
Sun, 24 Mar 2019 00:27:52 +0000 (00:27 +0000)
MCDV/main.cpp
MCDV/shaders/ss_precomp_objectives.fs
MCDV/util.h
MCDV/vdf.hpp
MCDV/vmf.hpp

index 9749100355af1065ea85863e63ab94c04c49f6d7..74e028388239ef1f3e7286a8a7ca8519a3d50f34 100644 (file)
@@ -51,13 +51,30 @@ void save_to_dds(int x, int y, const char* filepath) {
        free(data);
 }
 
+/* Renders opengl in opaque mode (normal) */
+void opengl_render_opaque() {
+       glDisable(GL_BLEND);
+       glEnable(GL_DEPTH_TEST);
+       glDepthMask(GL_TRUE);
+}
+
+/* Renders opengl in addative mode */
+void opengl_render_additive() {
+       glDepthMask(GL_TRUE);
+       glEnable(GL_BLEND);
+
+       // I still do not fully understand OPENGL blend modes. However these equations looks nice for the grid floor.
+       glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
+       glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE);
+}
+
 /* Command line variables */
 #ifndef _DEBUG
 std::string m_mapfile_path;
 std::string m_game_path;
 #endif
 #ifdef _DEBUG
-std::string m_mapfile_path = "sample_stuff/de_tavr_test";
+std::string m_mapfile_path = "sample_stuff/de_crimson_v16";
 std::string m_game_path = "D:/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo";
 #endif
 
@@ -129,14 +146,14 @@ int app(int argc, const char** argv) {
        auto result = options.parse(argc, argv);
 
        /* Check required parameters */
-       if (result.count("game")) m_game_path = result["game"].as<std::string>();
+       if (result.count("game")) m_game_path = sutil::ReplaceAll(result["game"].as<std::string>(), "\n", "");
        else throw cxxopts::option_required_exception("game");
        
        if(result.count("mapfile")) m_mapfile_path = result["mapfile"].as<std::string>();
        else if (result.count("positional")) {
                auto& positional = result["positional"].as<std::vector<std::string>>();
                
-               m_mapfile_path = positional[0];
+               m_mapfile_path = sutil::ReplaceAll(positional[0], "\n", "");
        }
        else throw cxxopts::option_required_exception("mapfile"); // We need a map file
 
@@ -547,6 +564,9 @@ int app(int argc, const char** argv) {
                s_solid->mesh->Draw();
        }
 
+       fb_comp_1.Bind();
+       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
        shader_unlit.setVec3("color", 1.0f, 0.0f, 0.0f);
 
        for (auto && s_solid : tavr_bombtargets) {
@@ -566,6 +586,9 @@ int app(int argc, const char** argv) {
        fb_comp.BindRTtoTexSlot(0);
        shader_precomp_objectives.setInt("tex_in", 0);
 
+       fb_comp_1.BindRTtoTexSlot(1);
+       shader_precomp_objectives.setInt("tex_in_1", 1);
+
        mesh_screen_quad->Draw();
 
        if (m_outputMasks)
index 7edeb08bdc0e3c5ff840c840e148c68e03f0b789..ece1763297fd8e5db6499ecacd52d95764130ab3 100644 (file)
@@ -6,7 +6,8 @@ out vec4 FragColor;
 
 //                                     SAMPLER UNIFORMS
 // Image Inputs _______________________________________________________________________________
-uniform sampler2D tex_in;      // Background texture
+uniform sampler2D tex_in;      // Buyzones
+uniform sampler2D tex_in_1;    // Bombtargets
 
 //                                       SHADER PROGRAM
 // ____________________________________________________________________________________________
@@ -15,5 +16,7 @@ uniform sampler2D tex_in;     // Background texture
 void main()
 {
        vec4 sample = vec4(texture(tex_in, TexCoords));
-       FragColor = vec4(sample.r, sample.g, 0, sample.r + sample.g);
+       vec4 sample1 = vec4(texture(tex_in_1, TexCoords));
+       vec4 o = sample + sample1;
+       FragColor = vec4(o.r, o.g, 0, o.r + o.g);
 }
\ No newline at end of file
index 77bf9552e3d97830c797d14758ecb7741f79742e..368ac94b9a21cac92d81427ed7ec7456d0355b18 100644 (file)
@@ -73,6 +73,17 @@ std::vector<std::string> split(std::string s, std::string delimiter)
 
 namespace sutil
 {
+       std::string get_unquoted_material(std::string in) {
+               std::vector<std::string> sgts = split(in, '\"');
+               std::string u = "";
+               int i = 0;
+               for (auto && s : sgts) {
+                       if (i++ % 2 != 0) continue;
+                       u += s;
+               }
+               return u;
+       }
+
        std::string pad0(std::string in, int count) {
                int zerosNeeded = count - in.size();
                std::string out = "";
index 10530015249a7ba4cdf20fd7701dba500da9cf71..a4bc875a8144286a886bdea77db8220042155ec2 100644 (file)
@@ -45,13 +45,13 @@ namespace kv
 
                                line = split(line, "//")[0];
 
-                               if (line.find("{") != std::string::npos) {
+                               if (sutil::get_unquoted_material(line).find("{") != std::string::npos) {
                                        std::string pname = prev;
                                        prev.erase(std::remove(prev.begin(), prev.end(), '"'), prev.end());
                                        this->SubBlocks.push_back(DataBlock(stream, pname, progress_callback));
                                        continue;
                                }
-                               if (line.find("}") != std::string::npos) {
+                               if (sutil::get_unquoted_material(line).find("}") != std::string::npos) {
                                        return;
                                }
 
index e2f39622b5587467acf597ee37ea9e93665df459..beba806b1e73229ddf8452ea1097c9ab9d48a26e 100644 (file)
@@ -238,6 +238,10 @@ namespace vmf {
                        for (int i = 0; i < SolidList.size(); i++){
                                std::cout << "Solid " << i + 1 << "/" << total << "\r";
 
+                               if (i >= SolidList.size() - 1)
+                               {
+                                       std::cout << "last\n";
+                               }
                                kv::DataBlock cBlock = SolidList[i];
 
                                Solid solid;
@@ -308,16 +312,21 @@ namespace vmf {
 
                                kv::DataBlock* editorValues = cBlock.GetFirstByName("editor");
 
-                               //Gather up the visgroups
-                               int viscount = -1;
-                               while (editorValues->Values.count("visgroupid" + (++viscount > 0 ? std::to_string(viscount) : "")))
-                                       solid.visgroupids.push_back(std::stoi(editorValues->Values["visgroupid" + (viscount > 0 ? std::to_string(viscount) : "")]));
+                               if (editorValues != NULL) {
+                                       //Gather up the visgroups
+                                       int viscount = -1;
+                                       while (editorValues->Values.count("visgroupid" + (++viscount > 0 ? std::to_string(viscount) : "")))
+                                               solid.visgroupids.push_back(std::stoi(editorValues->Values["visgroupid" + (viscount > 0 ? std::to_string(viscount) : "")]));
 
-                               glm::vec3 color;
-                               if (vmf_parse::Vector3f(editorValues->Values["color"], &color))
-                                       solid.color = glm::vec3(color.x / 255.0f, color.y / 255.0f, color.z / 255.0f);
-                               else
+                                       glm::vec3 color;
+                                       if (vmf_parse::Vector3f(editorValues->Values["color"], &color))
+                                               solid.color = glm::vec3(color.x / 255.0f, color.y / 255.0f, color.z / 255.0f);
+                                       else
                                        solid.color = glm::vec3(1, 0, 0);
+                               }
+                               else {
+                                       std::cout << "Editor values was null!\n";
+                               }
 
                                this->solids.push_back(solid);
                        }