Page 1 of 1

H2Forge DLL

Posted: Wed Dec 12, 2007 4:52 pm
by XZodia
I started to right this several months ago to take the hassle out of writting a H2 modding program but I've recently decided that I don't like it that much any more :P
So I'm releasing the code because it is good code and if you understand c# it should help you understand the map structure better...

I may well rewrite this (only differently) but hopefully this will help people until I do that, or better yet a remnant project to be started to standardise H2 mod programming...
it covers lots of stuff...

there is 3 main classes:
Map Stream
Map Data
Plugin

Map Stream and Map Data both have sub classes the main map parts:
Header
Index
Strings
Sbsp
Tags

Map Stream as the name suggests is an halo 2 map oriented binary reader/writer
it has all the standard read/write functions plus read/write functions for bitmasks, unicode strings, null terminated strings, a read-then-goto-offset function for reflexives which returns the chunk count (doesn't go anywhere if the chunk count is 0)
there is also the beginnings of a completely proper chunk adder (adds chunks where they should be and recalculates any offsets that have changed for reflexives)
and of course a resign function :P

Map Data stores all important info about a map ie all the data in the header, index, sbsp, strings, and offsets etc for tags
the tags sub class has various functions for loading treenodes and string lists etc
and there is events to return progress and status

Plugin Reader does exactly what it says on the tin. it reads ent plugins from your chosen directory. however the way the data is returned could use some work....

Posted: Thu Dec 13, 2007 12:16 am
by OwnZ joO
Sounds good, I'll definitely have a look at it.

Posted: Fri Dec 21, 2007 10:36 pm
by Grimdoomer
so what does it actully cover, just like basic opening if map file adn structure or what? Sounds interesting.

Posted: Sat Dec 22, 2007 12:16 am
by XZodia
it covers lots of stuff...

there is 3 main classes:
Map Stream
Map Data
Plugin

Map Stream and Map Data both have sub classes the main map parts:
Header
Index
Strings
Sbsp
Tags

Map Stream as the name suggests is an halo 2 map oriented binary reader/writer
it has all the standard read/write functions plus read/write functions for bitmasks, unicode strings, null terminated strings, a read-then-goto-offset function for reflexives which returns the chunk count (doesnt go anywhere if the chunk count is 0)
there is also the beginnings of a completely proper chunk adder (adds chunks where they should be and recalculates any offsets that have changed for reflexives)
and of course a resign function :P

Map Data stores all important info about a map ie all the data in the header, index, sbsp, strings, and offsets etc for tags
the tags sub class has various functions for loading treenodes and string lists etc
and there is events to return progress and status

Plugin Reader does exactly wat it says on the tin. it reads ent plugins from your chosen directory. however the way the data is returned could use some work....

excuse my lack of punctuation im really fucking tired

Posted: Sat Dec 22, 2007 1:10 am
by Grimdoomer
cool I will have to take a look at this.

Re: H2Forge DLL

Posted: Fri Jan 11, 2008 5:46 pm
by XZodia
Download Is Up

Re: H2Forge DLL

Posted: Sat Jan 12, 2008 11:50 pm
by OwnZ joO
I like it, saw a few things where you did some weird stuff, but who doesn't when they code.

Re: H2Forge DLL

Posted: Sat Jan 12, 2008 11:55 pm
by Supermodder911
Me.
jk we all know that.

Re: H2Forge DLL

Posted: Sun Jan 13, 2008 12:09 am
by XZodia
OwnZ joO wrote:I like it, saw a few things where you did some weird stuff, but who doesn't when they code.
lol care to give an example?

Re: H2Forge DLL

Posted: Sun Jan 13, 2008 4:51 pm
by OwnZ joO
I didn't look through it thoroughly, and it wasn't weird stuff you did on the halo part of coding. Just the way you read the xml is a little bit different than what I have seen/used, and I saw you used the Array.Resize method a bunch instead of just using a generic list and returning the ToArray() of it. I'm not saying you did it wrong, I'm sure it all works, it's just different.

Re: H2Forge DLL

Posted: Sun Jan 13, 2008 5:14 pm
by Grimdoomer
thats it im takin some time to look at this right now :D

Re: H2Forge DLL

Posted: Sun Jan 13, 2008 10:07 pm
by Prey
OwnZ joO wrote:and I saw you used the Array.Resize method a bunch instead of just using a generic list and returning the ToArray() of it.
You know that an ArrayList/List<> is actually just keeps track of a normal array, and it resizes that array when needed. [/insight]

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 4:33 am
by OwnZ joO
Yes I do, but it doesn't start out with a size of 0 and add one to it every time it needs to.

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 12:41 pm
by XZodia
it does actually... unless you specify an initial capacity

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 3:48 pm
by OwnZ joO
I'm pretty sure it doubles it and copies the contents to the new array every time that you go over the capacity of the array, thats why it has a count and capacity, because the count stays the same and capacity doubles, or else the count and capacity would be the same and there wouldn't be a need for both. I don't know, it just seemed wierd to me.

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 4:44 pm
by XZodia
count is the number of items you have added
capacity is the number of items can be added before it has to resize

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 7:22 pm
by OwnZ joO
xzodia wrote:count is the number of items you have added
capacity is the number of items can be added before it has to resize
I know that, but when it resizes it doubles the size of the internal array, instead of just adding 1 to it, because as you know arrays are immutable it has to make a larger array of the specified size and copy the old contents to the new one. This would be pretty wasteful if you do that a bunch with the + 1 method on array resize, because you have to allocate a bunch of arrays and then copy them a bunch too, instead of letting the list double it for you and reducing the number of arrays created in memory and the number of times they have to be copied.

Re: H2Forge DLL

Posted: Mon Jan 14, 2008 7:27 pm
by Supermodder911
lol.
AIM mbmb?

H2Forge DLL

Posted: Mon Jan 14, 2008 9:42 pm
by XZodia
OwnZ joO wrote:
xzodia wrote:count is the number of items you have added
capacity is the number of items can be added before it has to resize
I know that, but when it resizes it doubles the size of the internal array, instead of just adding 1 to it, because as you know arrays are immutable it has to make a larger array of the specified size and copy the old contents to the new one. This would be pretty wasteful if you do that a bunch with the + 1 method on array resize, because you have to allocate a bunch of arrays and then copy them a bunch too, instead of letting the list double it for you and reducing the number of arrays created in memory and the number of times they have to be copied.
i dont understand what you mean by the list doubling it :? doubling wat?

H2Forge DLL

Posted: Mon Jan 14, 2008 11:29 pm
by Prey
If not set, the initial capacity for a List<> is 0. On adding an item the list is resized to allow for a count of 4 elements. On trying to add a fifth element, the capacity is doubled to 8.. then 16.. 32.. etc...

So yeah you were pretty much right OwnZ.. and xzodia was right in saying count is the number of items that have been Add()-ed, and capacity is the number of items the internal array can currently hold.. before it is resized (again)..

Back on topic?..