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

Loading of STATIC assumes .cfg file and .mu file location to match, making it impossible to load .mu from GameData/Squad #19

Open
HB-Stratos opened this issue Jul 19, 2024 · 0 comments

Comments

@HB-Stratos
Copy link

A config file like the one below would be what a user expects to load from the absolute path specified here.

STATIC
{
	mesh = Squad/Parts/Utility/Lights/Assets/light_04.mu
	module = Part
	static = true
	animationName = 
	DefaultLaunchPadTransform = 
	author = Lack
	title = Real Runway Light
	category = Airbases
	cost = 0
	manufacturer = Meowdy
	description = it's a light?
	name = light_04
	DefaultFacilityType = None
	Instances
}

However, instead the error [ERR 16:45:05.635] KK: LoadModels: Could not find //Squad/Parts/Utility/Lights/Assets/light_04.mu! is thrown and no model is loaded. Note the strange double slashes at the start of the path.
@JonnyOThan and I have traced this issue to likely stem from

model.prefab = GameDatabase.Instance.GetModelPrefab(model.path + "/" + model.mesh);

trying to load the model, where model.path is the path to the config file and model.mesh is the literal name target defined for mesh = ... in the KK STATIC config. As the config file here lies directly in GameData, model.path becomes a /, causing the odd // in the error message (which uses the same piece code as is passed into GetModelPrefab). GetModelPrefab appears to be incapable of ignoring extraneous slashes and fails to find the model.

A workaround of putting the config file into it's own folder and using mesh = ../Squad/Parts/... also does not work as relative path traversal does not seem to be implemented in GameDatabase.GetModelPrefab.

As such, it is not possible to load any model not within the same folder tree as the .cfg file, or any folder if the .cfg file lies directly in GameData.

There also is another minor implementation oddity where a path that contains a ., but no .mu at the end would be truncated in the wrong spot by:

if (model.mesh.Contains('.'))
{
model.mesh = model.mesh.Substring(0, model.mesh.LastIndexOf('.'));
// model.settings = KKAPI.loadConfig(conf.config, KKAPI.getModelSettings());
}

I would appreciate a fix, as being able to load Squads or other mods .mu files as Statics can be quite helpful, and doing so currently requires the .mu file to be copied, which would violate Squads license. Thanks for giving this a look!

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