Key'd area format
< Newer Topic
:: Older Topic >
Pages:<< prev 1 next >>
#1 Sep 21, 2013 10:09 am
Good Morning,
I am just wondering how people like the key'd area format. I know I could add it, by changing area version, making backups of my files first, and then putting in all the changes.
If you didn't have key'd area format now, would you do it again? I mean I know it makes the files easier to read, but when your used to them as they are would it still be something you would do again?
I am thinking of doing it, because upping area version anyway to add something for objects.
I am just wondering how people like the key'd area format. I know I could add it, by changing area version, making backups of my files first, and then putting in all the changes.
If you didn't have key'd area format now, would you do it again? I mean I know it makes the files easier to read, but when your used to them as they are would it still be something you would do again?
I am thinking of doing it, because upping area version anyway to add something for objects.
#2 Sep 21, 2013 11:52 am
Geomancer
GroupAdministrators
Posts1,946
JoinedJul 26, 2005
Well it does make adding stuff in the files manually easier also, same for removing it.
#3 Sep 22, 2013 8:41 am
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005
If you're adding such a thing from scratch, I'd suggest looking into JSON.
You can easily just use one of the man JSON libraries out there to handle reading and writing objects in that format, it's easy enough to edit by hand if you like, and it gets rid of the ugly code involved in reading files now.
You can easily just use one of the man JSON libraries out there to handle reading and writing objects in that format, it's easy enough to edit by hand if you like, and it gets rid of the ugly code involved in reading files now.
#4 Sep 22, 2013 8:22 pm
Thanks for the suggestion, I never heard about JSON, but I will look at it now.
I will likely not do a full key'd conversion, but just somethings that are easily mistaken on what they are in the file, namely integers.
#5 Sep 23, 2013 12:48 am
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005
Just as a note... C sucks for having self-documenting data types, but if you're willing to spend a little extra memory, you can still use a serialization library and not have to maintain seperate read/write code.
If your data structure looks like:
A serializer (like JSON) will output something like (for example):
This can be read or written, usually with a single line of code (the library will handle allocations). Nice. But, of course, the file itself has no hints about what each thing actually is.
You can waste a bit of memory to add documentation elements:
Since most Dikurivatives use bitflags all over the place (because they used to run on machines with 4M of RAM), you could also redo the code to expand all of those into first-class elements That, however, is a fairly tedius exercise since you have to find all the nasty bits of code that do stuff like if(bitflags & (BIT_FOO | BIT_BAR)) and change them to be like if(thing.foo || thing.bar).
If your data structure looks like:
struct { int foo; int bar; int pfft[2]; char *ack; } thingy;
A serializer (like JSON) will output something like (for example):
{ 3, 8182, [ 23, 90 ], "some element" }
This can be read or written, usually with a single line of code (the library will handle allocations). Nice. But, of course, the file itself has no hints about what each thing actually is.
You can waste a bit of memory to add documentation elements:
struct { const char *fdoc = "Foo is the user's hit points\nBar is their breath stink level\nPfft is their money in gold and silver\nAck is their name"; int foo; int bar; int pfft[2]; char *ack; } thingy;
Since most Dikurivatives use bitflags all over the place (because they used to run on machines with 4M of RAM), you could also redo the code to expand all of those into first-class elements That, however, is a fairly tedius exercise since you have to find all the nasty bits of code that do stuff like if(bitflags & (BIT_FOO | BIT_BAR)) and change them to be like if(thing.foo || thing.bar).
Pages:<< prev 1 next >>