Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Loading & SR2MM Compatibility #1

Closed
DaloLorn opened this issue Jul 20, 2020 · 6 comments
Closed

Optimized Loading & SR2MM Compatibility #1

DaloLorn opened this issue Jul 20, 2020 · 6 comments

Comments

@DaloLorn
Copy link
Contributor

DaloLorn commented Jul 20, 2020

To summarize DaloLorn/Rising-Stars#20 and the SR2MM documentation:

Most modern SR2 mods use a special file structure for two reasons:

  1. The mod editor (and possibly the rest of the game) runs through every file in your mod folder at least once. If the mod folder contains a fully-functioning Git repository, loading times will tend to increase over the lifetime of the repository as more changesets pile up. Physically separating the mod from irrelevant metadata such as Git repositories can negate this performance loss.
  2. The SR2 Mod Manager was originally developed as an installation tool for Rising Stars itself, so it'll obviously favor a certain file structure. Conveniently, Darloth's old mods and all of Soloriens' RS-derived work have turned this configuration into an unofficial standard among those modders who bother to make their mods available via Git repos in the first place. While SR2MM will understand your current repository structure, it will run more smoothly if the mod code isn't in the root directory.

The following migration guide is a mildly edited form of the Git preparation guide in the SR2MM readme (themselves a modification of Darloth's instructions at the bottom of the linked RS issue), adjusted to hopefully fit your use case a little more closely:

  1. Create a folder to keep the repository in. For example, C:\Projects\SourceControl\SR2-Colonization-Expansion
  2. Move all SR2 mod data (modinfo, logo, and the data, locales and scripts folders) into a subfolder of that folder - for example, Colonization Expansion.
  3. Move everything else (Git data, license, readme, screenshots folder) from your mod folder into the root folder. (In the example, that would be SR2-Colonization-Expansion.)
  4. Open a command prompt, preferably an admin command prompt (just in case either the source or destination folder are in Program Files). Navigate to your Star Ruler 2 mods directory. Example:
       cd "C:\Program Files (x86)\Steam\SteamApps\common\Star Ruler 2\mods"
    

Create a symbolic link (specifically, a directory junction) from the mod folder in your Git repository to your SR2 mods directory. Example:

   mklink /J "CE" "C:\Projects\SourceControl\SR2-Colonization-Expansion\Colonization Expansion"

After all of these steps have been performed, both SR2 and your Git client should see the mod exactly the way they're meant to see it, and the mod manager will be capable of cleanly downloading, installing, and updating it from GitHub.

On a tangentially related note, I can create a discussion channel for your mod in the SR2 Discord server, if you'd like one - and help you set up a webhook like the one used in #rs-dev-feed. (I can also list your repo in #mods-and-tools whenever you feel it's ready for people to play around with it.)

@Skeletonxf
Copy link
Owner

Thanks for the summary.

My current setup is perhaps a little odd due to using the open source SR2 setup, in that I have
~/Documents/Games/StarRuler2Source/mods/ce as the in progress version of my mod, where Star Ruler 2 scans the files, but this is not a git repository (as ~/Documents/Games/StarRuler2Source is a git repository and git doesn't like nested repositories) and then once I have something that's not crashing or incomplete I copypaste ~/Documents/Games/StarRuler2Source/mods/ce/* into ~/Documents/Games/star-ruler-2-mod-ce for committing.

After thinking about it for a moment I probably should take this as an opportunity to refactor the file structure as copypasting was introducing quite a bit of friction for each change.

I wasn't aware that there was a star ruler 2 discord, where is the invite link for it?

@Skeletonxf
Copy link
Owner

I have an interesting problem with the symlink. When Star Ruler 2 loads up it sees the files inside the symlink with their original filepath, and isAccessible(const std::string& filename) in bind_datafile.cpp is programmed to reject loading or saving files outside the star ruler 2 folder. I could make the function always return true but I'd have to recompile the game as its a C++ file and I'm not sure what side effects disabling this might cause.

Have all of you only been using this file structure on Windows?

@DaloLorn
Copy link
Contributor Author

DaloLorn commented Jul 21, 2020

We have, yes... though this Stack Overflow answer might be applicable.

Do tell what commands end up working, so I can include Linux instructions in the various guides.

Edit: I've actually had to use this for an unrelated task right now, so I can now specify the required command for the paths you've provided so far:

sudo mount --bind ~/Documents/Games/star-ruler-2-mod-ce/FOLDERNAME ~/Documents/Games/StarRuler2Source/mods/ce

Where FOLDERNAME is the name of the subfolder you've placed your mod data into. (Both origin and destination folders will have to exist, and the destination folder will probably have to be empty.)

@Skeletonxf
Copy link
Owner

Gotcha, that answer lead me to the solution

I had to do exactly that command you edited in that I didn't see till I fixed it myself 😆

For some reason Star Ruler 2 converts symlinks to their original paths, but a junction point works

As a side note, if you mess up and pick the wrong source or target the first time like I did, you can undo the junction with umount

@Skeletonxf
Copy link
Owner

Skeletonxf commented Jul 21, 2020

A good cross distro solution is to add a line to your root crontab

sudo crontab -e opens the crontab

Add in
@reboot mount --bind /home/skeletonxf/Documents/Games/star-ruler-2-mod-ce/colonisation-expansion/ /home/skeletonxf/Documents/Games/StarRuler2-Source/mods/ce/ (no sudo is used because this runs as root anyway)

If you get prompted to choose an editor pick nano and if that isn't available pick whatever isn't vim.

@DaloLorn
Copy link
Contributor Author

Looks done to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants