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

Stop deleting other mods' files from GameData #29

Open
HebaruSan opened this issue Dec 3, 2024 · 0 comments
Open

Stop deleting other mods' files from GameData #29

HebaruSan opened this issue Dec 3, 2024 · 0 comments

Comments

@HebaruSan
Copy link

Problem

A user on the CKAN Discord reported that one of the files from KSC Extended was missing after playing the game:

image

Contents of that file (pre-deletion):

// Generated by Kerbal Konstructs


!KK_MapDecal[TSC]:NEEDS[KSRSS] {}
KK_MapDecal
{
	Name = TSC1
	CelestialBody = Earth
	Latitude = 34.447254364905213
	Longitude = -119.46136427492837
	Radius = 3995
	HeightMapName = TSCCoastal
	ColorMapName = Lava
	RemoveScatter = True
	UseAlphaHeightSmoothing = True
	UseAbsolut = True
	AbsolutOffset = 400
	CullBlack = True
	HeightMapDeformity = 0
	SmoothColor = 0
	SmoothHeight = 0.200000003
	Angle = 330
	Order = 100010
	Group = TSC
}

It appears that this code from Kerbal Konstructs deletes the file because its celestial body is Earth, and the user doesn't have RSS:

if (instance.CelestialBody == null)
{
Log.Normal("No valid CelestialBody found: removing MapDecal instance " + instance.configPath);
DecalsDatabase.DeleteMapDecalInstance(instance);
continue;
}

internal static void DeleteMapDecalInstance(MapDecalInstance instance)
{
if (_allMapDecalInstances.Contains(instance))
{
_allMapDecalInstances.Remove(instance);
allMapDecalInstances = _allMapDecalInstances.ToArray();
Log.Debug("MapDecal instace " + instance.Name + " removed from Database");
if (instance.configPath != null && System.IO.File.Exists(KSPUtil.ApplicationRootPath + "GameData/" + instance.configPath))
{
System.IO.File.Delete(KSPUtil.ApplicationRootPath + "GameData/" + instance.configPath);
}
}
}

This is a bit rude and makes a lot of assumptions about the contents of that file.

Scenario 1: Out of order mod installs

  1. Install KSC Extended with intention to install RSS
  2. Forget to install RSS temporarily
  3. Run the game (maybe start or load a save if needed to trigger this code, not important)
  4. Realize oops, no RSS, exit
  5. Install RSS
  6. Run the game
  7. Oops, RSS config was deleted by KK in step 3! Report a misleading support ticket to KSC Extended maintainer

Scenario 2: Developing a config by hand

  1. Create .cfg file containing a KK_MapDecal node
  2. Accidentally fat-finger the celestial body:
        CelestialBody = Kerblin
    
  3. Run game to test
  4. It deletes my code! Now I have to start over.

Scenario 3: It could be worse

  1. Make a long personal "big patch" .cfg file in GameData over a couple of years with all your favorite in-game personalizations
  2. Decide you want to add a KK_MapDecal node to it
  3. Repeat Scenario 2, except now you lose a lot more than just one small file

Suggestion

Remove the file deletion code and let standard mod coding and packaging practices handle what configs are present and loaded. KK can easily skip and ignore any files it doesn't like.

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

1 participant