Forum > Miscellaneous

[QUESTION] [C# Dev] Parsing MTEX

(1/3) > >>

Keta:
Hello Modcraft

This question is mainly directed to all the people who knows about reading the ADT files with a scripting language. Its written in C# (C Sharp)
So my question is, Steff has helped me out with a code that works pretty fine so far, only I have encountered 2 problems. First problem is when I parse the MTEX paths, it also gives me a few lines of random stuff before the actual paths. This is however not the reason why I'm making this post. The reason is my second problem. You see, when I run the program, as I said before it gives me all the texture paths. However the last 2 texture paths are on the same line, apparently. And that is the same case in all of the ADTs I've tried. And yes, I have tested all ADTs in-game, and they do work.

So... Anyone that can help me out with telling me why that is? I am 99% sure you're gonna wanna see the source, and that is no problem :)
Pastebin: http://pastebin.com/EBdRpjRq

This is the output it gives me when I run the program:

As you can see, it posts the last 2 paths on the same path, even though (as visible in the source) I split up and make a new line after each path.

Any help would be appreciated! :)



Thanks
Keta

schlumpf:
You seem to not have realized, that mtex is a chunk as well. That's the "gibberish" bytes there.

On the last two always being on the same line: maybe string is not the right type, idk.

Keta:
If you are referring to the fact that I should make a "public struct" with the info of the MTEX, like I did with the 2 others, I can then tell you that I've already tried that, and it gave me an error every time I tried, and no matter how i tried.
But if your certain, please do tell me how you would accomplish that.

Thanks
Keta

schlumpf:
I would not tell you that you are wrong, if I don't know you are.

You are not caring about the magIc and size fields.

Keta:
So let me get this straight, you want me to add a

--- Code: ---[StructLayout(LayoutKind.Explicit)]
        public struct MTEX
        {
            [FieldOffset(0)]
            public int magic;
            [FieldOffset(4)]
            public int size;
            [FieldOffset(8)]
            public int mtex;
        }
--- End code ---
correct? And then from the main function, call it like I did with the other two?

--- Code: ---MTEX mtex = ByteToType<MTEX>(foo);
--- End code ---
Yes? Well, that gives me the following number: 1740
And you probably might say "sure, that's the number of the bytes you have to move forward to, to reach the part of the ADT that tells about texture paths. Well in that case, I already had that from the MHDR. So either, I'm like "da fuq?" or I still don't know what you mean? Cause I tried reading FROM THERE, didn't really return any positive result, and I've tried to read that many BYTES forward from the MHDR.mtex position, and that just gave me a VERY long string... So please, do explain.

Also, this is how the code ended up looking after you wanted me to try that out:
http://pastebin.com/udDcLQqu

Thanks
Keta

Navigation

[0] Message Index

[#] Next page

Go to full version