binary reader jumper to random offset

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

binary reader jumper to random offset

Post by grimdoomer »

Ok I Delecare a new binaryreader, then set the position like so:

Code: Select all

BR.basestream.position = metaoffset + i
But no matter how I arange that the binaryreader always jumps a head by a cuple offsets, there is a pic of what im talking about:
Image

I know its choppy but look at the filetableoffset and where the BR is, the BR should be at the filetableoffset but its not!, how can I fix this?
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

That pictures tells us nothing if I'm not mistaken. Only if you step into the next line it will set the BR to the filetableoffset.
...left for good
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

yes but see the line highlighted in yello, thats where i got an exception because the BR was off. Then i just red the position from it.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

It's the .ReadChar() method - If at the current position there is not a valid character, the stream's position is incremented by one, and then the valid-char-check is done again.. and again...
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

because the BR is not where i tell it to go, i even set its position to 0 then set a breakpoint right after that. It wasent at 0 but at 25?????
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

grimdoomer wrote:because the BR is not where i tell it to go, i even set its position to 0 then set a breakpoint right after that. It wasent at 0 but at 25?????
Didn't you read what Prey said? Yes you can set it to 0 but if the offset doesn't have a valid character it loops until it finds one...in this case at offset 25.
...left for good
User avatar
Altimit01




Connoisseur Snitch! Literarian 500

Posts: 947
Joined: Sun Jun 04, 2006 12:10 pm

Post by Altimit01 »

Prey wrote:It's the .ReadChar() method - If at the current position there is not a valid character, the stream's position is incremented by one, and then the valid-char-check is done again.. and again...
That just seems screwy to me. Most readchar methods should just read the byte and interpret it as a character as best they can (defaulting to a certain encoding if it's outside the normal 128 range). But I guess if .net wants to be "smart" about it it can.
MSDN wrote:If the ReadChar method attempts to read a surrogate character in the stream an exception will be raised and the position in the stream will advance. The position is restored to the original location before ReadChar was called if the stream is seekable; however, if the stream is unseekable, the position will not be corrected. If surrogate characters can be expected in the stream, use the ReadChars method instead.
I don't remember offhand if H2 tags use the same naming convention of tag classes but it could be you're reading what should be rendered as
Image
Download Eschaton: Halomods | Filefront | Mediafire
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

I agree Altimit, it is pretty crap.. and not very clear either. Also we're on the FileTable here.. nowhere near Tag classes =P

Anyway, .ReadChars() would be more ideal.. faster too. Just get the string offsets in the FileTable from the FileIndex, then find the string lengths by doing a 'offsets[x + 1] - offsets[x]', using the FileTableSize for the last string.
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

Patrickssj6 wrote:
grimdoomer wrote:because the BR is not where i tell it to go, i even set its position to 0 then set a breakpoint right after that. It wasent at 0 but at 25?????
Didn't you read what Prey said? Yes you can set it to 0 but if the offset doesn't have a valid character it loops until it finds one...in this case at offset 25.
any way I have a bigger problem then that right now, My dependancys for halo 2 stoped working. Smae problem the BR keeps jumping.

Code: Select all

For i As Integer = 0 To MetaSize - 4 Step 4
                BR.BaseStream.Position = MetaOffset + i
                Dim temp As String = BR.ReadChars(4)
                temp = StrReverse(temp)
there is my code (that part that i get an exception) it worked befor but doesent any ore, all i did was stick it into a seperate class, I made sure i gave it the right info, I even copy and pasted right out of the old code to see if something was missing. Nothing, I get an exception right at

Code: Select all

temp = strreverse(temp)
and I checked the BR and its still 5-10 offsets ahaed. I dont think it keeps going till it finds readable Characters, cus then it would throw an exception right? mabey not, but the exception says that there is less then 4 readable characters.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

Perhaps try the reader and writer from HERE.. also I just remembered the .ReadChars() method has the same "fault" as the ReadChar() method... =x
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

thanks prey but me and hawaiian modder fixed it a cuple days ago. Poke sayed to read 4 bytes insetead of 4 characters and it worked perfect.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
Post Reply