[StructLayout(LayoutKind.Explicit)] public struct MTEX { [FieldOffset(0)] public int magic; [FieldOffset(4)] public int size; [FieldOffset(8)] public int mtex; }
MTEX mtex = ByteToType<MTEX>(foo);
So let me get this straight, you want me to add aCode: [Select][StructLayout(LayoutKind.Explicit)] public struct MTEX { [FieldOffset(0)] public int magic; [FieldOffset(4)] public int size; [FieldOffset(8)] public int mtex; }correct?
And then from the main function, call it like I did with the other two?Code: [Select]MTEX mtex = ByteToType<MTEX>(foo);
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?
(uint32_t magic, uint32_t size)
((uint32_t magic, uint32_t size), uint32_t version | size == 4)
((uint32_t magic, uint32_t size), uint32_t flags, uint32_t offsets[size/sizeof (uint32_t) - 1] | size == 64)
((uint32_t magic, uint32_t size), char8_t data[size])
std::vector<std::string> texture_filenames (0);std::string temporary_string ("");for (size_t i (0); i < mtex.size; ++i){ if (mtex.data[i] == 0) { texture_filenames.push_back (temporary_string); } else { temporary_string += mtex.data[i]; }}
char* cur_pos = &mtex.data[0];char* end = cur_pos + mtex.size;while( cur_pos < end ){ texture_filenames.push_back (std::string (cur_pos)); cur_pos += strlen (cur_pos) + 1;}
Code: [Select]std::vector<std::string> texture_filenames (0);std::string temporary_string ("");for (size_t i (0); i < mtex.size; ++i){ if (mtex.data[i] == 0) { texture_filenames.push_back (temporary_string); } else { temporary_string += mtex.data[i]; }}
[StructLayout(LayoutKind.Explicit)] public struct MTEX { [FieldOffset(0)] public int magic; [FieldOffset(4)] public int size; [FieldOffset(8)] public char[] filenames; }
It gives me an error when I run the program. And its the same error, no matter whether I use string[] or char[].
QuoteIt gives me an error when I run the program. And its the same error, no matter whether I use string[] or char[].Ah, _that_ error. m(