A Verge Struct Loader
Displaying 1-3 of 3 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
CrazyAznGamer

Well, seeing as a fully generic structloaderfromfile wouldn't be possible, I went and made this lil' utility to aid in the loadage of structs. I may have went too far though, and created another script... inside of Verge.
...
>_>
Yes, it's a script inside of a engine script designed specifically for loading files into structures. It takes a reference file, turns it into a dictionary, and runs off that dictionary on susceptible victim files, setting variables throughout verge, inside and out of structs.
....
I also thought it was a bit complicated and impractical to use. The test case:

# "defines"

MAX_STATS i:3
MAX_TEST i:5

# hammer time!

0 s:"pushstruct:test"
1 s:"setkey:i:0"

2 s:"string_1D:name:i"
3 s:"string_1D:zomg:i"
4 s:"int_1D:lala:i"
5 s:"int_1D:boogie:i"

6 s:"setkey:j:0"
7 s:"int_2D:stats:i:j:MAX_STATS"
8 s:"add:j:1"
9 s:"lessthan:j:MAX_STATS"
10 s:"goto:7"

11 s:"pushstruct:blarg"
12 s:"null"
13 s:"int_1D:holy:i"
14 s:"int_1D:moly:i"
15 s:"string_1D:ballsack:i"
16 s:"popstruct"

17 s:"add:i:1"
18 s:"lessthan:i:MAX_TEST"
19 s:"goto:2"

20 s:"popstruct"
21 s:"pushstruct:single"
22 s:"int:holy"
23 s:"int:moly"
24 s:"string:ballsack"

loads into these structs

struct _test_struct
{
string name;
string zomg;
int lala;
int boogie;
int stats[3];
_blarg blarg;
}
_test_struct test[5];

struct _blarg
{
int holy;
int moly;
string ballsack;
}
_blarg single;

with this data file:

# refer to test.dict for format
# or whatever

NAM1 OMG1 1 10
100, 101, 102
BLARG_STARTS_HERE
1000, 1001, BLARG1

NAM2 OMG2 2 20
200, 201, 202
BLARG_STARTS_HERE
2000, 2001, BLARG2

NAM3 OMG3 3 30
300, 301, 302
BLARG_STARTS_HERE
3000, 3001, BLARG3

NAM4 OMG4 4 40
400, 401, 402
BLARG_STARTS_HERE
4000, 4001, BLARG4

NAM5 OMG5 5 50
500, 501, 502
BLARG_STARTS_HERE
5000, 5001, BLARG5

1337
31337
lonelyface

END_OF_FILE

I have not tested all of the commands, too, so there may be debugging left still. But the point is, I think I have gone too far, and was wondering if the general opinion out there is that this would be useful or not.

Thoughts? Should I host it here? Will people actually use this monstrosity?

Posted on 2007-05-27 16:44:13

Omni

I'll be perfectly honest.

I bet the code you came up with for it was pretty special. You probably felt really awesome after figuring it out. I bet it took a lot of ingenuity and you're proud but concerned about the relevance of the finished product. And I'm not disagreeing with that -- it looks like it took genuine effort.

So let me tell you straight up: that entire post kinda frightens me :) Do you think you could show a simpler example?

Posted on 2007-05-28 10:18:15

CrazyAznGamer

Hehe, sure. I thought it was a bit too much too, but there's a lotta weird shit going on with that code anyways.
So, it's composed of two parts. One part loads a file into a dictionary, and another loads a dictionary into structs. The second part is *probably* useless and needlessly complicated, but meh, I did program it.
I probably (damn freudian slip) subconsciously intended for the post to frighten people from wondering what it does. But here it is, a comprehensive (snort) breakdown of what goes on:

# this is a dictionary datafile. it loads stuff into a dictionary
# key <whitespace> value

# below loads an integer into the key "yay"
yay i:4
# below loads a string into the key "nay"
nay s:"Lalala I am a string d00d"

Now that is all fine and simple, but when you're using a dictionary to script for a struct loader, it gets a bit weird.

# "scripts" always start at key zero and move up til it doesn't find a next index key.
# The executed scripts must be strings.
# The following line starts teh script by pushing a struct variable name onto a stack
# If you look in the above example, that's how you would have nested structs:
# pushing structs onto more structs
0 s:"pushstruct:lard"
# This assumes we have a global struct variable named... lard.

# We can also grap a token from the victim file and do stuff with it
# For example, the following line grabs a token, parses it as an int, and puts it in "lard.strength"
1 s:"int:strength"

# there are "local" variables that are actually key/value pairs in the very dictionary we're parsing
# Some commands, like setint, add, and lessthan, as well as the various 1D/2D crap
# use these keys for various things like
# "loops" which use lessthan to see if the parser should execute the next command
# index iterators, which, in combo with the above,
# goes thru arrays in the current structstack (1D/2D crap)
# the following lines grab tokens from teh victim data file as strings,
# and puts them into array indices 2 - 5 of an array called con
# note that you can set key values manually in a dictionary,
# and the parser will still recognize them: it's the same dictionary anyways.
max i:6
2 s:"setint:iter:2"
3 s:"string_1D:con:iter"
4 s:"add:iter:1"
5 s:"lessthan:iter:max"
# the following line will only execute if iter is less than max
# the goto command should be straightforward
6 s:"goto:3"

There's a couple (cough) more commands available, but anyways, that's the basic gist of a dictionary/script thingy. An example of the datafile the above script would load:

# <- more junk lines
# tokens are separated by lines and whitespace, as well as ,:;|

# strength
999
# con[2] thru con[5]
la I am goatse.cx

In retrospect, and conclusively, I wonder if it's easier just to copy/paste the stupid loader functions and not worry about this...

Posted on 2007-05-28 14:36:21


Displaying 1-3 of 3 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.