Enhanced Edition User Directory Detection
bardez
Member Posts: 41
How is the user-space directory path determined? I'm thinking of cross-platform and cross-language scenarios here. Last week, I could safely assume on Windows 7 that my directory was "C:\Users\Bardez\Documents\Baldur's Gate - Enhanced Edition". I have no knowledge of OS X or possible Linux releases. Now that BG2:EE is out, it's a toss up between adding a " II" in the middle of the directory or not.
Determining if the install target is an Enhanced Edition is easy enough, but I'm curious how one could safely differentiate between BG2:EE and BG:EE, starting from chitin.key to find the user-space directory. Since the executables are running off of a code base maintained in parallel, the installs look a lot more similar than before. So how is the user directory determined? Is it hard-coded, registry written, etc.? Is there a 2DA file that defines it?
Working off of memory from when I did BGT, Near Infinity used the movies to differentiate the Infinity Engine installs. I recall from 2002 or so asking Jon Olav Hauglid to actually update the way he was doing it for NI due to BGT (I ran into trouble with NI thinking a BGT install was BG1), which he was kind enough to do. Using that same thinking, and applying it forward, what distinguishes the two games that no one would ever really want to copy between engine instances? Most media assets, creatures, etc. would be excluded from consideration due to the above concept. While snooping at the BG2:EE install, I see new resources of type 0x03FF that are not present in BG:EE, and those appear to be at least related to the tutorial videos in BG2:EE.
Is there a set way to determine, regardless of platform and language, what the related user-space directory for either game is going to be? Basically if you have, say a portrait pack mod or want to write something that detects assets available for a current user, how would one safely determine which user directory to use?
EDIT: Typo fixes, rewording for clarity.
Determining if the install target is an Enhanced Edition is easy enough, but I'm curious how one could safely differentiate between BG2:EE and BG:EE, starting from chitin.key to find the user-space directory. Since the executables are running off of a code base maintained in parallel, the installs look a lot more similar than before. So how is the user directory determined? Is it hard-coded, registry written, etc.? Is there a 2DA file that defines it?
Working off of memory from when I did BGT, Near Infinity used the movies to differentiate the Infinity Engine installs. I recall from 2002 or so asking Jon Olav Hauglid to actually update the way he was doing it for NI due to BGT (I ran into trouble with NI thinking a BGT install was BG1), which he was kind enough to do. Using that same thinking, and applying it forward, what distinguishes the two games that no one would ever really want to copy between engine instances? Most media assets, creatures, etc. would be excluded from consideration due to the above concept. While snooping at the BG2:EE install, I see new resources of type 0x03FF that are not present in BG:EE, and those appear to be at least related to the tutorial videos in BG2:EE.
Is there a set way to determine, regardless of platform and language, what the related user-space directory for either game is going to be? Basically if you have, say a portrait pack mod or want to write something that detects assets available for a current user, how would one safely determine which user directory to use?
EDIT: Typo fixes, rewording for clarity.
0
Comments
I'm sure the checks made by WeiDU to identify a game were made public somewhere but I can't remember where exactly.
Does the folder name change depending on native language? To what directory does the game installer use for user files (is it a documents subdirectory or something like that? I'm ignorant of OS X and its patterns).
That doesn't sound like what you are asking for though.
If you were making a WeiDU script, then I would suggest simply having a check for a file that you know is unique to the particular game; though even that would be unreliable given that someone could easily copy items and other resources to either game.
@Isaya WeiDU has the user folder hard-coded, so it just relies on which game was detected. And that appears to be based off of the containing folder in the case of enhanced editions. I don't think Overhaul allows you to install to any other directories than the default one, so that might be a safe assumption to mimic.
Something as simple as naming the executable baldur.exe or baldur2.exe would allow someone to make assumptions, but that is not currently the case. I'll nose around some more to see if I can't find information to satisfy my curiosity.
Unfortunately, the containing folder—for example, 00766 for BG:EE—is also unreliable given that the Steam version doesn't have such a directory (though I'm not sure on this exact point, it might have).
As I said, for installing to either game the best course right now would be to use FILE_EXISTS_IN_GAME in your TP2 file to determine which game is currently being installed for. Say, for instance, you have a mod that has modules that can be installed for either game, but uses something to detect which game and then skips the mods that are not compatible with the chosen game. For example,
FILE_EXISTS_IN_GAME ~SECRET05.itm~
. Since this item is exclusive to BG2, you could use it to determine the USER directory, Baldur's Gate - Enhanced Edition or Baldur's Gate II - Enhanced Edition. What you could do is find a script, perhaps, and use that instead. Items and spells can be extracted and copied to either game, but an area script would be somewhat useless if the area didn't exist and so it would limit the potential fault chance. (even though you can trust that someone out there will probably try.)That's about all I could suggest on that topic.
Something like :
%THAT_GLOBAL_VARIABLE%/games/Baldur's Gate : Enhanced Edition
%THAT_GLOBAL_VARIABLE%/games/Baldur's Gate 2 : Enhanced Edition
The "/games/Baldur's Gate : Enhanced Edition" parth is probably hardcoded, (if i'm not mistaken) and is in no way linked to the folder where the application has been installed.
No idea for Linux or MacOS, but there should be something comparable there.
As far as I know, WeiDU checks for the existence of files that are unique to each game to determine which game is installed in the current directory (from memory, mel01.cre for ToB, for instance). That is how the GAME_IS check is performed. I'm sure the list of these files was published in a discussion but I don't remember where that was. I may use other hints, such as the ini file name in order not to rely on a single test that could be deceived.
Regarding the user directory, it's safe to assume that Beamdog can't change it now without breaking everybody's games. So one can apply the follow what's done principle once the game is released.