KeyValue formatter reader/writer

Grab your favourite IDE and tinker with the innards of game engines

KeyValue formatter reader/writer

Postby coder0xff on Thu Mar 04, 2010 12:02 am

I wrote an IFormatter (System.Runtime.Serialization.IFormatter) in C# called KeyValueFormatter. To use it, you simply make a class that describes the format of the file you want to read. For example, some pieces for .VMF

Code: Select all
    [Serializable]
    public class ValveMap
    {
        [Serializable]
        public class VersionInfoClass
        {
            public Int32 EditorVersion;
            public Int32 EditorBuild;
            public Int32 MapVersion;
            public Int32 FormatVersion;
            public Int32 Prefab;
        }

        public VersionInfoClass VersionInfo;

        [Serializable]
        public class EntityClass
        {
            public Int32 ID;
            public String Classname;
            public Int32? SpawnFlags;
            public List<KeyValuePair<String, String>> KeyValues;
            public VectorClass Origin;

            [Serializable]
            public class IOConnectionClass
            {
                public String TargetEntityNameOrClass;
                public String TargetEntityInput;
                public String ParameterOverride;
                public Int32 TriggerDelay;
                public Int32 NumberOfTimesToFire;
                public override string ToString()
                {
                    return TargetEntityNameOrClass + "," + TargetEntityInput + "," + ParameterOverride + "," + TriggerDelay + "," + NumberOfTimesToFire;
                }
                public static IOConnectionClass FromString(String text)
                {
                    IOConnectionClass temp = new IOConnectionClass();
                    String[] components = text.Split(',');
                    if (components.Length < 4 || components.Length > 5) throw new FormatException("IO Connection should have at least 4 parameters, and normally 5");
                    temp.TargetEntityNameOrClass = components[0];
                    temp.TargetEntityInput = components[1];
                    temp.ParameterOverride = components[2];
                    temp.TriggerDelay = Convert.ToInt32(components[3]);
                    if (components.Length == 5) temp.NumberOfTimesToFire = Convert.ToInt32(components[4]);
                    return temp;
                }
            }
            public List<KeyValuePair<String, IOConnectionClass>> Connections;
            public SolidClass Solid;
            public HiddenClass Hidden;
            public EditorClass Editor;
        }

        public List<EntityClass> Entity;
    }       


It uses reflection and generics, and supports user made classes marked with [Serializable], List<>, List<KeyValuePair<,>>, Nullable<>, and the built in types: int, single, string, and boolean.

When you have a KeyValues member in a class that is of type List<KeyValuePair<String, String>> it will not embed the list in it's own braces (like "connections" for entities in the VMF format) but will place them in the current scope, like keyvalue "renderfx" for entities. The example, renderfx, is a legitimate keyvalue, where as connections is a node of it's own. This special KeyValues member is used to distinguish it.

You may want to use this code (as seen in the complete code) to make a shortcut for List<KeyValuePair<String, String>>:

Code: Select all
using KeyValues = System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String, System.String>>;


So you can instead just type:
Code: Select all
public KeyValues KeyValues;


The functionality can be accessed by creating a formatter similar to how it is done with SoapFormatter or BinaryFormatter, except that instead of specifying the Type to serialize/deserialize in the constructor, it is specified as a generic argument and then using it normally:

Code: Select all
KeyValueFormatter<ValveMap> serializer = new KeyValueFormatter<ValveMap>();
ValveMap myMap = (ValveMap)serializer.Deserialize(myStream);


There is also a convenience option:
Code: Select all
ValveMap myMap = KeyValueFormatter<ValveMap>.ReadFromFile("C:\\foobar.vmf")


Unlike the other formatters, this one is trivial to instantiate and has a very small memory footprint, so it is safe to instantiate many wherever needed or convenient and allow garbage collection to dispose of them. There is also no run time code generation as is used in the other formatters, also keeping instantiation and debugging trivial. As it stands, output reflects the order of the data members of the class, though this is not guaranteed behavior as it is simply a result of the reflection provided by .Net. It is also not necessary to specify that other classes that will be serialized, as they will be identified and serialized automatically.

The code for the formatter and the VMF file definition have been provided as functional samples. They've had little testing, so be careful.

http://dl.dropbox.com/u/5105767/KeyValu ... xample.rar
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby Terr on Thu Mar 04, 2010 1:31 am

I'm curious how it handles some of the weirder stuff. Like places where the quoting rules are relaxed, and someone writes a block like:
Code: Select all
<dx80
{
}
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: KeyValue formatter reader/writer

Postby coder0xff on Thu Mar 04, 2010 1:35 am

Terr wrote:I'm curious how it handles some of the weirder stuff. Like places where the quoting rules are relaxed, and someone writes a block like:
Code: Select all
<dx80
{
}


user defined classes can implement ToString and FromString and handle the unusual stuff in their own manner. I've been thinking of adding an aliasing attribute where a variable can appear as a different symbol. Thoughts?
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby omnicoder on Thu Mar 04, 2010 11:55 pm

Looks very useful, gonna try it out.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: KeyValue formatter reader/writer

Postby Terr on Fri Mar 05, 2010 7:57 pm

I just know that that example tripped me up at one point due to how I was lexing everything. If it was quoted, it would work fine, but otherwise it wouldn't be seen as a "word".
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: KeyValue formatter reader/writer

Postby coder0xff on Fri Mar 05, 2010 9:44 pm

Yeah, but even still you can't have a variable named <80 so the aliasing thing should fix it... thing that'd work? I actually used an aliasing attribute when I made my mdl decompiler code. Now THAT was some crazy shit for C#. lol

And now to make a new thread for the FGD parser I just wrote. :-/
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby omnicoder on Thu Apr 29, 2010 11:41 pm

I'm having an issue with this using a hammer produced VMF (in fact, every hammer VMF I try fails...)
Can't figure out whats messing it up...
Code: Select all
A new line was encountered when looking for a value. Character index: 1776959

Stack output debug stuff:
key: "group"
dontcare: true


This is what it seems to take issue with: (character 1776959 is directly after the word group)
Code: Select all
group
   {
      "id" "3347"
      editor
      {
         "color" "197 214 0"
         "visgroupshown" "1"
         "visgroupautoshown" "1"
      }
   }
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: KeyValue formatter reader/writer

Postby coder0xff on Fri Apr 30, 2010 5:51 pm

Yeah, I think I encountered that bug myself. I've updated the download, but there still seems to be something not quite right. The output file is quite a bit smaller than the original. If someone decides to wade through the file and find what's missing please let me know.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby omnicoder on Thu Jul 22, 2010 8:57 pm

I'm noticing func_details disappearing from maps parsed with this. Which sucks because I just wrote a program that uses it and the output maps are missing func_details. It appears that multiple brushes tied to one entity aren't parsed correctly.

(oh and sorry to bump after 2 months but considering I know coder is still around and he responded to the last bug I thought it would be worth posting)
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: KeyValue formatter reader/writer

Postby Terr on Thu Jul 22, 2010 10:11 pm

Could you post some example text?

A while back I had a problem with my own code that sounds very similar: I was assuming that keys couldn't be duplicated, and that the later keyvalue would overwrite the former one.

But in reality, you can have duplicate key/value pairs.
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: KeyValue formatter reader/writer

Postby omnicoder on Thu Jul 22, 2010 10:25 pm

I'm using his ValveMap class as I'm reading VMF's, I'm 99.9% the issue is that in a brush entity consisting of multiple brushes, only the first (last?) one is kept when it loads.

Here's an example of a func_detail with multiple brushes.
Code: Select all
//Shortened layout- full copypaste below
entity
{
     solid
     {
            side
            side
            side
            side
            side
     }
     solid
     {
            side
            side
            side
            side
            side
     }
     solid
     {
            side
            side
            side
            side
            side
      }
}

Code: Select all
entity
{
    "id" "7796"
    "classname" "func_detail"
    solid
    {
        "id" "7797"
        side
        {
            "id" "5192"
            "plane" "(1168 -62 254) (1168 62 254) (1152 62 254)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[-1 0 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5191"
            "plane" "(1168 62 256) (1168 -62 256) (1152 -62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5190"
            "plane" "(1168 62 254) (1168 -62 254) (1168 -62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5189"
            "plane" "(1152 -62 254) (1152 62 254) (1152 62 256)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5188"
            "plane" "(1152 62 254) (1168 62 254) (1168 62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5187"
            "plane" "(1168 -62 254) (1152 -62 254) (1152 -62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7798"
        side
        {
            "id" "5198"
            "plane" "(1168 62 128) (1168 64 128) (1152 64 128)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5197"
            "plane" "(1168 64 256) (1168 62 256) (1152 62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5196"
            "plane" "(1168 64 128) (1168 62 128) (1168 62 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5195"
            "plane" "(1152 62 128) (1152 64 128) (1152 64 256)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 0 1 0] 0.25"
            "vaxis" "[0 -1 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5194"
            "plane" "(1152 64 128) (1168 64 128) (1168 64 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5193"
            "plane" "(1168 62 128) (1152 62 128) (1152 62 256)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 0 1 0] 0.25"
            "vaxis" "[-1 0 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7799"
        side
        {
            "id" "5204"
            "plane" "(1153 -62 206) (1153 62 206) (1152 62 206)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5203"
            "plane" "(1153 62 208) (1153 -62 208) (1152 -62 208)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5202"
            "plane" "(1153 62 206) (1153 -62 206) (1153 -62 208)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5201"
            "plane" "(1152 -62 206) (1152 62 206) (1152 62 208)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5200"
            "plane" "(1152 62 206) (1153 62 206) (1153 62 208)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5199"
            "plane" "(1153 -62 206) (1152 -62 206) (1152 -62 208)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7800"
        side
        {
            "id" "5210"
            "plane" "(1168 -64 128) (1168 -62 128) (1152 -62 128)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5209"
            "plane" "(1168 -62 256) (1168 -64 256) (1152 -64 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5208"
            "plane" "(1168 -62 128) (1168 -64 128) (1168 -64 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5207"
            "plane" "(1152 -64 128) (1152 -62 128) (1152 -62 256)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 0 1 0] 0.25"
            "vaxis" "[0 -1 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5206"
            "plane" "(1152 -62 128) (1168 -62 128) (1168 -62 256)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 0 1 0] 0.25"
            "vaxis" "[-1 0 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5205"
            "plane" "(1168 -64 128) (1152 -64 128) (1152 -64 256)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7801"
        side
        {
            "id" "5216"
            "plane" "(1153 -62 180) (1153 62 180) (1152 62 180)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5215"
            "plane" "(1153 62 182) (1153 -62 182) (1152 -62 182)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5214"
            "plane" "(1153 62 180) (1153 -62 180) (1153 -62 182)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5213"
            "plane" "(1152 -62 180) (1152 62 180) (1152 62 182)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5212"
            "plane" "(1152 62 180) (1153 62 180) (1153 62 182)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5211"
            "plane" "(1153 -62 180) (1152 -62 180) (1152 -62 182)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7802"
        side
        {
            "id" "5222"
            "plane" "(1153 -62 154) (1153 62 154) (1152 62 154)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5221"
            "plane" "(1153 62 156) (1153 -62 156) (1152 -62 156)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5220"
            "plane" "(1153 62 154) (1153 -62 154) (1153 -62 156)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5219"
            "plane" "(1152 -62 154) (1152 62 154) (1152 62 156)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5218"
            "plane" "(1152 62 154) (1153 62 154) (1153 62 156)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5217"
            "plane" "(1153 -62 154) (1152 -62 154) (1152 -62 156)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    solid
    {
        "id" "7803"
        side
        {
            "id" "5228"
            "plane" "(1168 62 130) (1168 -62 130) (1152 -62 130)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[-1 0 0 0] 0.25"
            "rotation" "90"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5227"
            "plane" "(1168 -62 128) (1168 62 128) (1152 62 128)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 1 0 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5226"
            "plane" "(1168 62 128) (1168 -62 128) (1168 -62 130)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5225"
            "plane" "(1152 -62 128) (1152 62 128) (1152 62 130)"
            "material" "PLASTIC/PLASTICWALL004A"
            "uaxis" "[0 -1 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5224"
            "plane" "(1152 62 128) (1168 62 128) (1168 62 130)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        side
        {
            "id" "5223"
            "plane" "(1168 -62 128) (1152 -62 128) (1152 -62 130)"
            "material" "TOOLS/TOOLSNODRAW"
            "uaxis" "[-1 0 0 0] 0.25"
            "vaxis" "[0 0 -1 0] 0.25"
            "rotation" "0"
            "lightmapscale" "16"
            "smoothing_groups" "0"
        }
        editor
        {
            "color" "220 220 220"
            "visgroupshown" "1"
            "visgroupautoshown" "1"
        }
    }
    editor
    {
        "color" "220 220 220"
        "groupid" "7753"
        "visgroupshown" "1"
        "visgroupautoshown" "1"
        "logicalpos" "[0 13000]"
    }
}


I think the issue is that the entity class contains a single Solid class rather then a List<solid> or a Solid[].
Unfortunately, if I go into ValveMap and change SolidClass to List<SolidClass> or SolidClass[] I receive errors about an unexpected open brace.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: KeyValue formatter reader/writer

Postby coder0xff on Fri Jul 23, 2010 12:35 am

I've updated the download. There were indeed some serious problems (caused by the VDC documentation not fully describing the contents :/ ) and the speed has also been improved many fold. Thanks goes to z@c
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby omnicoder on Fri Jul 23, 2010 12:48 am

I can see that the new upload has an update ValveMap.cs but the entire KeyValueFormatter.cs file is commented out and it all appears to be tied into Ducktape (or something else). I tried removing all that but some of the functions seem to require a class called StringConversion.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: KeyValue formatter reader/writer

Postby coder0xff on Fri Jul 23, 2010 1:00 am

Yeah, Sorry. The KeyValueFormatter file isn't used anymore.

Code: Select all
CTokenReader ctr = new CTokenReader(sr, vmfLoader);
loadedMap = (ValveMap)ValveMap.FromTokenreader(ctr, "ValveMap");


The reader was rewritten basically, using the same concepts.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: KeyValue formatter reader/writer

Postby omnicoder on Fri Jul 23, 2010 5:41 pm

Where is the StringConversion class it uses coming from? I couldn't find it in higher .net framework versions, Ducttape or Google search.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am
Next

Return to Programming

Who is online

Users browsing this forum: No registered users

cron