1264 GTD OPD Map Loading - #207
Conversation
stevewgr
left a comment
There was a problem hiding this comment.
Hi @UTengine, thanks for the PR.
I'd rather we don't just enforce map headers 12xx. We can make it load all formats by doing simple checks. Reason why, because tools rely on this implementation too, plus it would be nice having the ability to switch between map assets regardless of their versions.
We can try reading the map files header assuming they're 12xx and if the data doesn't make sense, jump back to the beginning of the file and try reading as 10xx.
This is far from complete. Also ideally we store the file version somewhere in CN3BaseFileAccess, so that we can then do this once to save CPU cycles.
|
That's what I did with the previous commits months ago, those were never merged too >.> |
| int TempVersion, TempIntStringLength; | ||
| ReadFile(hFile, &(TempVersion), sizeof(int), &dwRWC, NULL); // Read the map version | ||
| ReadFile(hFile, &(TempIntStringLength), sizeof(int), &dwRWC, NULL); // Read the map name char length | ||
| CHAR * TempGTDMapNamebuffer = new CHAR[TempIntStringLength / sizeof(char) + 1]{}; // Zero-initialized |
There was a problem hiding this comment.
Few things to point out here:
- Not sure why we're using Windows'
CHARhere instead of justchar - If this is to be allocated on the heap, it might as well just use std::string like everything else (or well, that aren't the silly
std::vector<char>implementations). As it is, it's just leaking memory. - The naming here is a bit strange. Why
TempVersionetc as opposed toMapVersionor some such, specifically: why are we referring to them as temporary vars?
On this note, the version is being thrown away here -- when it in fact needs to be used byCN3Pond, which leads me to my next point: - This is incomplete --
CN3Pondwill fail to read its portion of the file correctly, as it is the only other thing updated in this version. Specifically for versions 2+ (which 1.264 does support), which is why it needs to use the version from here.
1264 GTD and OPD Map loading.
1264 Patch.zip
💔Thank you!
This is currently a draft request so please review.