H2Forge DLL

Post here basically any programming material that will help other programmers out.
Post Reply
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

H2Forge DLL

Post 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....
Attachments
H2Forge 2.zip
(346.29 KiB) Downloaded 812 times
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Post by OwnZ joO »

Sounds good, I'll definitely have a look at it.
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Post by Grimdoomer »

so what does it actully cover, just like basic opening if map file adn structure or what? Sounds interesting.
Don't snort the magic, we need it for the network.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Post 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
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Post by Grimdoomer »

cool I will have to take a look at this.
Don't snort the magic, we need it for the network.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2Forge DLL

Post by XZodia »

Download Is Up
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2Forge DLL

Post by OwnZ joO »

I like it, saw a few things where you did some weird stuff, but who doesn't when they code.
Supermodder911
Posts: 409
Joined: Sat Jan 12, 2008 11:42 pm
Location: Michigan
Contact:

Re: H2Forge DLL

Post by Supermodder911 »

Me.
jk we all know that.
Image
Chad Warden is Ballin'. No jk.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2Forge DLL

Post 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?
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2Forge DLL

Post 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.
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Re: H2Forge DLL

Post by Grimdoomer »

thats it im takin some time to look at this right now :D
Don't snort the magic, we need it for the network.
User avatar
Prey
Posts: 129
Joined: Sat Dec 29, 2007 5:06 pm
Location: UK

Re: H2Forge DLL

Post 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]
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2Forge DLL

Post 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.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2Forge DLL

Post by XZodia »

it does actually... unless you specify an initial capacity
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2Forge DLL

Post 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.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2Forge DLL

Post 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
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2Forge DLL

Post 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.
Supermodder911
Posts: 409
Joined: Sat Jan 12, 2008 11:42 pm
Location: Michigan
Contact:

Re: H2Forge DLL

Post by Supermodder911 »

lol.
AIM mbmb?
Image
Chad Warden is Ballin'. No jk.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

H2Forge DLL

Post 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?
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Prey
Posts: 129
Joined: Sat Dec 29, 2007 5:06 pm
Location: UK

H2Forge DLL

Post 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?..
Post Reply