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

Add variable to store rmdp archive path prefix #43

Closed Jackkal closed 2 months ago

Jackkal commented 3 months ago

This proposal replaces the hardcoded prefix "d:/data/" with a prefix variable _pathPrefix that can be specified per game. The intention is to allow the use of "normalized" paths in the resource manager also for games like Control which use a /data/ folder in the rmdp archive instead of the "d:/data" prefix. Some high res textures are stored in "/data_pc/" instead. A reminder has been added in the comments to possibly take this into account in the future.

Nostritius commented 3 months ago

Hi, thanks for your proposal, however, I have thought about this problem and I think a better solution would be to put this logic inside the ressource manager. As long as there is no file which exists in data and data_pc with the same name and same folder, we could even extend this with multiple path prefix options which are tested through.

Jackkal commented 3 months ago

@Nostritius. Can you elaborate a bit on the solution you had in mind? The resource manager currently has no notion of what is the current game. Or do you mean a list with prefixes that is tested independent of what is the specific game? The latter seems less optimal from a performance point of view, especially for the games where the majority of the files reside in a directory that is at the end of the list. It means that almost every file would be checked several times extra before a match will be found (further impacted by the number of archives). The goal here was to introduce a prefix list per game - indeed only 1 path per game for now, but could indeed be a list in the future. Looking forward to your feedback.

Nostritius commented 3 months ago

@Jackkal The idea is, that you would add a setPathPrefix method to the RessourceManager. This path prefix will always be appended when a resource is requested over a path with ResMan.getResource paths. You could use it also multiple time to gset a specific prefix during the probing. Then you can set the path prefix permanently right after probing. For now I would prefer staying with one path prefix.

Jackkal commented 3 months ago

ok I understand what you mean now. This makes sense indeed. I'll take a look. Is it ok if I use git commit --amend and then force push to submit any changes?

Jackkal commented 2 months ago

@Nostritius I have changed the PR taking into account your suggestions. There is now a function in the resource manager to set the path prefix. After the probing, the final path prefix is set based on the game that was recognized...

Jackkal commented 2 months ago

Apart from this two comments, please fix also the rmdparchive unit tests

Rmdparchive unit tests have been fixed. Because the path prefix is now in the resource manager, the files accessed through the RMDPArchive class will now need to use the full "raw" path.

Nostritius commented 2 months ago

Merged, thanks :)