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!
A config file like the one below would be what a user expects to load from the absolute path specified here.
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
Kerbal-Konstructs/src/KerbalKonstructs.cs
Line 1048 in d792fcb
trying to load the model, where
model.pathis the path to the config file andmodel.meshis the literal name target defined formesh = ...in the KK STATIC config. As the config file here lies directly in GameData,model.pathbecomes a/, causing the odd//in the error message (which uses the same piece code as is passed intoGetModelPrefab).GetModelPrefabappears 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 inGameDatabase.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.muat the end would be truncated in the wrong spot by:Kerbal-Konstructs/src/KerbalKonstructs.cs
Lines 1043 to 1047 in d792fcb
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!