{"id":225,"date":"2010-02-08T23:51:29","date_gmt":"2010-02-09T07:51:29","guid":{"rendered":"http:\/\/technofovea.com\/blog\/?p=225"},"modified":"2010-02-08T23:56:37","modified_gmt":"2010-02-09T07:56:37","slug":"valves-handling-of-fgd-files","status":"publish","type":"post","link":"http:\/\/technofovea.com\/blog\/archives\/225","title":{"rendered":"Valve&#8217;s handling of FGD files"},"content":{"rendered":"<p>One of the issues in PackBSP I want to improve is that it doesn&#8217;t &#8220;know&#8221; about dependencies (like a model used in a prop_static entity) stored in the <a href=\"http:\/\/developer.valvesoftware.com\/wiki\/Entity\">entity data<\/a> of a map. At least, not for other mods: PackBSP is currently hardcoded to the set that TF2 supports. The solution seems to be interpreting the <a href=\"http:\/\/developer.valvesoftware.com\/wiki\/FGD\">FGD files<\/a> that Hammer uses to determine all the places a user might insert a model or a texture while mapping. These definition files should be created by mod-makers for just about any &#8220;serious&#8221; Source Engine mod, so it seems safe to piggyback on their information. I&#8217;ve had a parser for the FGD files for a while now, but just parsing the file isn&#8217;t enough: You have to resolve and assemble all the dependencies into a final state.<\/p>\n<p><!--more--><\/p>\n<p>I&#8217;ve been spending some time trying to reverse-engineer the undocumented rules that Hammer uses for its FGD files. These include how one file can include or override another, and inheritance between the defined classes.<\/p>\n<p>Findings so far:<\/p>\n<ul>\n<li>Before paying any attention to the base(&#8230;) method of classes-inheritance, Hammer goes through and parses each item in a file.<\/li>\n<li>This initial parsing includes the @import statements, and the order of these statements matters. Imports act like the #include directives in C, and basically temporarily interrupt the parsing of the current file to go and handle the imported file first.<\/li>\n<li>The definition for a class found last within the file is the one that gets used. Since @import is like text insertion, this means the order of everything matters and affects how redefinitions of a class get resolved. (Last one wins.)<\/li>\n<li>If a class inherits (via the base(&#8230;) modifier) from multiple parents that conflict, the last parent specified has priority. An example of a conflict would be two identically-named properties.<\/li>\n<li>When referencing a superclass via the base(&#8230;) inheritance, the class <em>ought<\/em> to be already-defined in terms of how things are ordered within the FGD file. While Hammer complains about this, it will still work in the end.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>One of the issues in PackBSP I want to improve is that it doesn&#8217;t &#8220;know&#8221; about dependencies (like a model used in a prop_static entity) stored in the entity data of a map. At least, not for other mods: PackBSP is currently hardcoded to the set that TF2 supports. The solution seems to be interpreting [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,4],"tags":[6,9,11],"_links":{"self":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/225"}],"collection":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":8,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":233,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions\/233"}],"wp:attachment":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}