Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Today, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot, Google, Yahoo!

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » General Discussions » Key'd area format
Forum Rules | Mark all | Recent Posts

Key'd area format
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 21, 2013, 8:09 am
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

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.
       
Post is unread #2 Sep 21, 2013, 9:52 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

Well it does make adding stuff in the files manually easier also, same for removing it.
       
Post is unread #3 Sep 22, 2013, 6:41 am
Go to the top of the page
Go to the bottom of the page

Quixadhal
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.
       
Post is unread #4 Sep 22, 2013, 6:22 pm
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)


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.
       
Post is unread #5 Sep 22, 2013, 10:48 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
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:

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 >>