• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

Major Directory and SVN Restructuring

EmperorFool

Deity
Joined
Mar 2, 2007
Messages
9,637
Location
Mountain View, California
Please bear with me as I am reorganizing how BUG lays outs its files a little. I really hope the payoff for modders outweighs the PITA factor of updating your code. In the end, I think it's worth it and will support modders that build off BUG better.

BUG Changes

First, here's what I'm changing as far as BUG's operation is concerned:

  • Splitting "BUG Mod" folder into "UserSettings" and "Info"
  • Several locations are checked for the "UserSettings" folder, and once one is found, its parent is used as the "data directory". No more searching is done from this point on for data files (INIs, help files, etc). Assets continue to be searched for in multiple directories as needed.
  • Major BugPath rewrite: all directories are exposed using functions to ensure they are setup correctly.
  • I think I've finally nailed down the random Vista breakage.
Mods that are installed to CustomAssets will still look for a folder named using CvModName.modName. This allows you to change the name of the folder easily as this is the only place that variable is used by BUG to find things. The only other place it's used is to display on the BUG Options Screen.

Mods installed to the Mods folder will look in their own directory for UserSettings. If they find it there, they use their own folder as "data directory".

To continue to allow multiple BUG Mod installations to share options, BUG will also look in "My Games" and "BTS" for this "data directory." In fact, the method it uses to find the folder is to look for "UserSettings" and use its parent.

Finally, "Info" and "UserSettings" are constants defined in BugPath and can be changed by modders if they wish. I think giving them generic names instead of "BUG Mod" will make this less desirable.

SVN Changes

To support the above, I will be rearranging the SVN repository.

  • Create "Info". Gets readme, license, help files, CvAltRoot.py
  • Create "UserSettings". Gets CustDomAdv and Adv Unit Naming.ini
  • Rename "CustomAssets" to "Assets" (to make dealing with BULL easier)
The major change is that you won't be able to as easily checkout SVN directly to the BTS folder to run in single-player mode. However, this wasn't entirely easy anyway, so I don't think it will matter much. Checking out to a mod folder should now be a piece of cake, however.

Why Now?

With BULL and other projects, it was becoming more difficult to deal with BUG's directory layout. As well, modders are always asking me how to rename the folder where INI files are kept. Having this tied to the display name of the mod was silly.

To top it off, the BugPath module was a hack on top of a hack, and it needed constant tweaking to deal with new installation issues. I got sick of propping up the dead weight and decided it would be better to nuke the site from orbit. It's the only way to be sure. :mischief:
 
is there any bull svn release yet? cannot find any bull gamecore files.
 
Would it be at all possible to have the altroot python file reference from the regkey instead of a hardcoded path? I'd like to include it as a download for the Legends of Revolution mod, but I can't expect the users of the mod to open up and edit python source files....
 
Would it be at all possible to have the altroot python file reference from the regkey instead of a hardcoded path?

Yes, that would be pretty easy. The purpose of the CvAltRoot module is really to solve the case where you actually use the /altroot command-line switch to have multiple user directories. By putting the directory name inside a Python file, it can be loaded automatically by BTS so that BugPath can find it.

I will likely be creating a new module to hold the various folder name constants that are in BugPath at the moment. I can put the registry key there so modders could change its root. In fact, I could allow each of the paths to be overridden here this way

Code:
HKEY_CURRENT_USER
  Software
    BUG Mod
      App Folder             contains Civ4BeyondSword.exe
      Data Folder            contains Info and Settigns folders
      Info Folder            contains readme, help files, etc.
      Mod Folder             contains mod when installed to Mods folder
      Root Folder            contains CivilizationIV.ini
      Settings Folder        contains INI files
      User Folder            "My Games", only used to find folders above

How would that work for you?
 
To be honest, I'm not quite sure. I may not be understanding this correctly. Basically a user asked me to include the alt root file so they could load saved games from an alternate directory.

Basically what I need is something that will install directly to the users computer using my standard install script, and doesn't require any work or computer knowledge from the user.

I don't entirely understand what the below is saying. Would the below be the code as it exists in the altered AltRoot file? What exactly would I need to adjust to get it to work with the Legends of Revolution mod, so that users can still just click and play?

Code:
HKEY_CURRENT_USER
  Software
    BUG Mod
      App Folder             contains Civ4BeyondSword.exe
      Data Folder            contains Info and Settigns folders
      Info Folder            contains readme, help files, etc.
      Mod Folder             contains mod when installed to Mods folder
      Root Folder            contains CivilizationIV.ini
      Settings Folder        contains INI files
      User Folder            "My Games", only used to find folders above


Sorry, I realize this should be clear, but I'm just not getting it.
 
It's okay. I understood your post to mean that you wanted me to put change CvAltRoot to have a registry key instead of a folder in it. Then your install script would set the registry key to the folder the user would normally put into CvAltRoot themselves.

You install script could create the CvAltRoot file itself in the Python folder with the directory the user chose. All it needs is

Code:
rootDir = r"...path to dir..."

This is what BUG's installer does when they select the AltRoot install method. This module also comes in handy when BUG cannot find their My Games folder or the CivilizationIV.ini file. This was happening on some Vista installs because Vista had an empty Shell Folders registry entry (bah!), but I've fixed that now.

When you say the users want their saves going to a different folder, are you talking about the standard BTS saving mechanism? To do this, they should use the /AltRoot command-line parameter on their BTS/mod shortcut.

Maybe if you could describe exactly what's going on that you want to be different. What I was proposing was to have a file that listed all the registry keys that BUG would look for to override its paths. Your install script would then write to those fixed registry keys so the user wouldn't have to. Setting registry keys in NSIS is really simple. You can take a look at BUG's install script if you need some examples of more complex behavior.
 
Well, on second thought it might not be worth it. Everything works fine how it is now. It was just that I had a user request the ability to use the AltRoot thing from the BUG mod, so they could compartmentalize their save games. They made it sound like the AltRoot made the mod more of a seperate entity using the AltRoot file. Also I figured using it would just standardize things with BUG, and take care of any possible unforseen bugs, sort of a troublshooting measure for me to do.

I suppose I should start by asking what exactly AltRoot does (currently just have it removed from the mod, and there don't seem to be any problems).

When I looked at the AltRoot file, the key part is here:
Code:
rootDir = "C:/Documents and Settings/[UserName]/My Documents/My Games/Beyond the Sword"

Now for Legends of Revolution I have the install script install based on the registry key, so I can't use a hardcoded path like that. I was hoping it were possible to set up something like:
Code:
rootDir = "$INSTDIR1\Mods\LoR"
#where $INSTDIR1 refers to the NSIS script, basically where the mod installs to.  It uses the Regkey to locate this path
 
In BUG, the rootDir is the directory that contains CivilizationIV.ini. BUG looks in this directory for a common BUG user settings folder (so multiple BUG-based mods or BUG installations can share settings). It also uses it to find the Saves and CustomAssets directories.

Normally, this directory is found by first locating the user's "My Games" folder which is in their "My Documents" folder. It uses the Windows registry for the latter. Some users on Vista were having issues with this part. Their installs had both the XP and Vista registry keys, and it turns out the XP key was empty. CvAltRoot solved this problem by allowing the user to specify the directory manually. This problem should be solved, so this usage is deprecated.

Other players have multiple BTS folders--not the folder where the application is installed but the folder that holds CustomAssets, their saved games, profile, etc. They tell BTS about it using the /altroot command-line parameter on their BTS shortcut. Unfortunately, BUG cannot access this setting. In this case users must still use CvAltRoot.

BUG also uses rootDir to find the Mods folder if you install your BUG-based mod to the My Games folder instead of the BTS EXE folder. The directory containing your mod is exposed by BugPath in 3.6 as modDir and in this latest version via getModDir(). If it isn't finding the directory, the user will need to set up CvAltRoot. Since you have the install folder, your install script could create this file for them during installation.

Where exactly do you install your mod? Do you give the user an option between the two Mods folders (EXE vs. My Games)?
 
OK, sounds like AltRoot is just unnessesary then for my purposes.

Where exactly do you install your mod? Do you give the user an option between the two Mods folders (EXE vs. My Games)?

Legends installs to the Program files path, not My Games.
 
Legends installs to the Program files path, not My Games.

Okay, I get the path to this folder from BTS itself, and that has proven reliable so far. I am also able to get the name of the mod folder from the CvReplay oddly enough--even before the game starts! Thus you should never have a problem using BugPath.getModDir().
 
Back
Top Bottom