OpenAWE-Project / OpenAWE

A reimplementation of Remedy Entertainments Alan Wake Engine, in later iterations known as the Northlight Engine
GNU General Public License v3.0
159 stars 13 forks source link

Rework RMDPArchive class to remove redundancies #21

Closed maaxxaam closed 1 year ago

maaxxaam commented 1 year ago

This pull request is meant to (more or less) resolve #16. Most of the changes are contained within RMDPArchive class. Multiple new helper functions were created in order to minimize repeating code. loadHeaderVX() functions have been edited to use function pointers for reading variables to prevent typos. Regexes were replaced by simpler std::string::find() and std::string::replace() functions since they were needed for simple substring search/substitution. Note: I haven't been able to test those changes properly as I currently don't have AW installed.

maaxxaam commented 1 year ago

Ok, apparently, when I was moving out the loop for going over folders, I did not notice that loops in functions getResource() and getDirectoryResources() place the path.eof() check after different conditions. In one case, nameHash would save the hash of a resource file without processing it, while in the other one it would break from the loop after processing. That detail was not taken into account during the writing of findDirectory() function. I apologise that got revealed only during build checks - will fix soon, since it definitely breaks hasResource() function.

Nostritius commented 1 year ago

Merged, thanks :)