Closed EzraZebra closed 4 years ago
Btw, hope I'm not bothering you here. I'm reimplementing the Mdlx parser into C++. The MDX part is functional and pretty much done. If you're interested, source code is on GitLab.
getByteLength()
here is the total size of the chunk including the header, while the size the header needs is only of the data itself.
The former is used to calculate the final size of the MDX file when writing - https://github.com/flowtsohg/mdx-m3-viewer/blob/3c94d049d76ee6f15d938f3020ccd777b66ce83d/src/parsers/mdlx/model.ts#L617
Perhaps I should have used better naming.
I did actually write a C++ copy of the MDLX parser a while ago. Even had nearly the same syntax with block-reading iterators, but it was somewhat ugly so I changed to ye-olde normal while loops. Wouldn't care to share it if you're interested, it also includes BLP/TGA/INI/SLK/MPQ/CASC to some extent or another.
Ah right, of course. I got confused because you don't need the filesize when writing with std::ofstream
so I didn't add a getByteLength for the Model class, and IIRC unknownchunks are the only chunks which don't use their getByteLength for anything else.
Oh I would love to see your C++ code ^^ It's probably better than mine in a lot of ways. The other parsers might also come in handy in the future, but don't really need them now.
If you want the full working project I can send it to you on discord or something like that, the dependencies are a couple of tens of megabytes. I suggest you to glance at the binary stream class :P War.zip
Awesome, thanks! I looked up why it's better to buffer the whole file, and yeah it's much faster xD Thanks, I'll be able to improve my code a lot :D
Each has its positives, albeit when you are handling small files usually it makes sense to read it all in one go. Either way I was more looking at the fact you made separate read/write functions like I did in JS, even though C++ has the power of templates :D
Yeah, I'm stealing that wholesale ;') Other than that we seem to have mostly found the same solutions :D
As in the title, shouldn't this.getByteLength() be used here instead? As far as I can tell, this function isn't used anywhere right now.
https://github.com/flowtsohg/mdx-m3-viewer/blob/3c94d049d76ee6f15d938f3020ccd777b66ce83d/src/parsers/mdlx/unknownchunk.ts#L17