[TOOL][Alpha] RimWorld Profile Manager

Started by theit8514, February 09, 2015, 09:43:41 AM

Previous topic - Next topic

theit8514

So I'm putting this out here in the tools category, since it doesn't directly affect any mods. I've designed a mechanism which will allow a user to create multiple Profiles of RimWorld for use with different sets of mods and/or configs. Currently, the RimWorld loads configuration files from a single configuration folder which is located in your user profile's AppData. This means that even if you have multiple RimWorld game folders with different mods, the game loads the same ModConfig.xml file for every one of those folders. Well, this program seeks to resolve that issue by allowing the user to create multiple profiles which separate out the AppData folder into multiple profile folders.

The profile manager does not modify the base game executable, nor does it modify anything in the data directory. It simply uses a feature of the Windows OS which allows the folders to be redirected.

Technical Details:
RimWorld Profile Manager hooks the low level API functions in Windows using EasyHook which RimWorld uses to read/write files or search directories. The hooks inspect the filenames that pass through them and filter them for only the files in the '%AppData%\..\LocalLow\Ludeon Studios\RimWorld' directory. Those filenames are modified so that they now point to a specific profile folder IE: '%AppData%\..\LocalLow\Ludeon Studios\Profiles\Profile 1'. This mechanism is akin to how Mod Organizer works for Bethesda style games, except much more simpler.

DISCLAIMER:
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
While I make the best attempt at redirecting only the files in the profile folder, I do rely upon libraries which may cause the game to crash. A backup is HIGHLY recommended before using this application (including RimWorld application directory and %AppData%\..\LocalLow\Ludeon Studios directory).


Downloads:
If you're still interested after the disclaimer, you can download the alpha pre-release at https://github.com/theit8514/RimWorldProfileManager/releases.
The source code is available under a partial GPL/partial LGPL license at https://github.com/theit8514/RimWorldProfileManager.

Install instructions:

  • Extract to any location.
  • Run ProfileManager.exe. On the form, there are four fields. Enter any profile name, then point the profile at a RimWorld install directory and executable. If Profile Directory is left blank, it will generate one for you from the name.
  • Click the run button at the top to launch the selected profile.
  • ???
  • PROFIT! (not really, it's FOSS)

Current Known Issues:

  • If the hook is applied too quickly, the game executable may crash on launch. This is due to how EasyHook won't allow CreateAndInject against .NET Framework code; the process must be started first, then injected. If the hook happens too late (which really should not happen), then the game could possibly be hooked in the middle of loading the base RimWorld directory and could crash as a result. If the error window loads after the game gets to the main menu, or if the HookLoader process reports that it could not inject into the game, please report that as an issue. Otherwise, please try restarting the profile again after closing down the game and HookLoader executable.
  • The Profile Manager currently has no mechanism for detecting if a profile is currently running. It is up to the user to not run the same profile at the same time. If the same profile is run, the game may crash.

Changelog:
0.3-alpha
Fixes:

  • Profiles folder not existing on first run. Creates it on first run of this version.
Features:

  • Options to open RimWorld folder and Profile folder of selected profile.
0.2-alpha
Resolve bug in graphical front end which prevented the grid from display any columns. Sorry about that.
0.1-alpha
Initial release.

Rock5

I'm finally getting sick of dealing with different Rimworld folders so I thought I'd give this a try after reading about it a few days ago.

Doesn't work. Error "Failed to initialize Grid: The type initializer for 'ProfileManager.ProfileManager' threw an exception".
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

theit8514

Quote from: Rock5 on February 22, 2015, 06:34:27 PM
I'm finally getting sick of dealing with different Rimworld folders so I thought I'd give this a try after reading about it a few days ago.

Doesn't work. Error "Failed to initialize Grid: The type initializer for 'ProfileManager.ProfileManager' threw an exception".

Meant to push out a fix earlier in the week, but didn't get around to it. You can fix this by creating the Profiles folder under '%AppData%\..\LocalLow\Ludeon Studios' or downloading v0.3 from the github page, which I will be posting shortly.

Rock5

Thanks. And I'm happy you answered right away and I didn't have to wait. :D
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

Rock5

It was able to launch the game the first time I tried it but then crashed the game every other time I tried, with a dialog asking me to send the crash report to the developers. The game still starts ok if I start it directly.
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

theit8514

When you launch the profile the HookLoader comes up, is there an error in that window? What OS version?

Rock5

I'm using Windows 7 64bit

[attachment deleted due to age]
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

theit8514

I'll take a look when I get back to my computer. Could be an issue with the hook applying too fast or too slow.

Rock5

I forgot to tell you something that happened when I got the error the first time. I didn't mention it because I don't think it's relevant but just in case...

This is what happened. I set up and started my version of 722 then closed it down. Then I set up and tried to run my version of 724 and I got an error saying I was missing the sub folder RimWorld724Win_Data. I had forgotten that I had renamed it to do a comparison with kdiff3. Anyway, I restored the name and tried again. That's when I got the error above for the first time.

Like I said, it doesn't seem relevant but just in case...
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

theit8514

#9
Just got back to my computer. I've checked out the newest version of RimWorld (only version I can get is 725, doesn't appear to be a link to 724). I cannot replicate the issue on Windows 8.1, so I'll be setting up a Windows 7 test bed, see if Unity is doing something funky with that OS version.

While I set that up, I've added the debug binaries to the github release (just the HookLoader and Hook). It will create a debug.txt file in the RimWorld folder, logging the functions and what they were modified to. If you could PM me that log and the crash report, it'll tell me what function call crashed it.

EDIT: So I just got the Windows 7 64bit environment up and running, but I still cannot replicate the problem. Have you tried with a fresh copy of the 724? Could you try with the 725?

Rock5

Looks like I didn't make 1 point clear. After successfully starting 722 once, I was never able to start it again. I get the error with every version of the game. 722, 724 and now 725. I'll pm you the debug file.
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport