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

Bug on ConfigNodeWithSteroids.from #23

Closed
Lisias opened this issue Jan 17, 2022 · 1 comment
Closed

Bug on ConfigNodeWithSteroids.from #23

Lisias opened this issue Jan 17, 2022 · 1 comment
Assignees
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@Lisias
Copy link
Collaborator

Lisias commented Jan 17, 2022

That's weird.

Let's say we have the following ConfigNode on the prefab:

[LOG 22:49:56.768] [KSP_Recall] INSTALLED
{
        Attached = false
        ChillingOut = false
        Driftless = true
        Refunding = false
        Resourceful = false
        AttachedOnEditor = false
        LetsStayTogether
        {
                PartModule = true
        }
}

The following code works fine:

				UrlDir.UrlConfig urlc = GameDatabase.Instance.GetConfigs("KSP-Recall")[0];
				ConfigNodeWithSteroids cn = ConfigNodeWithSteroids.from(urlc.config.GetNode("INSTALLED"));
				Log.force("{0}", cn.ToString());

and prints what's expected correctly. However, the following code:

				Log.force("{0}", cn.GetNode("LetsStayTogether").ToString());
				Log.force("{0}", ConfigNodeWithSteroids.from(cn.GetNode("LetsStayTogether").ToString()));

ends up printing what follows on the log:

[LOG 22:49:56.768] [KSP_Recall] LetsStayTogether
{
        PartModule = true
}

[LOG 22:49:56.769] [KSP_Recall] LetsStayTogether
{
}

what's clearly a bug, because both entries should be printing the same content!

By some reason, ConfigNodeWithSteroids.from is borking when being fed with a subnode!

Search and Destroy the bug!

@Lisias
Copy link
Collaborator Author

Lisias commented Jan 15, 2023

This issue is INVALID. There's an error on the reference code!!

This is wrong, the .ToString() is being applied on the wrong place:

	Log.force("{0}", ConfigNodeWithSteroids.from(cn.GetNode("LetsStayTogether").ToString()));

Is should be:

	Log.force("{0}", ConfigNodeWithSteroids.from(cn.GetNode("LetsStayTogether")).ToString());

And, now, this works fine, as I had proved while checking net-lisias-ksp/DistantObject#28:

[LOG 00:23:34.929] DOE *****
 source root
{
        debugMode = False
        useToolbar = True
        useAppLauncher = True
        onlyInSpaceCenter = False
        DistantFlare
        {
                flaresEnabled = False
                flareSaturation = 1
                flareSize = 1
                flareBrightness = 1
                ignoreDebrisFlare = False
                debrisBrightness = 0.150000006
                situations = ORBITING,SUB_ORBITAL,ESCAPING,DOCKED,FLYING
                showNames = True
        }
        DistantVessel
        {
                renderVessels = False
                maxDistance = 750000
                renderMode = 0
                ignoreDebris = False
        }
        SkyboxBrightness
        {
                changeSkybox = True
                maxBrightness = 0.25
                referenceBodySize = 1
                minimumSignificantBodySize = 1
                minimumTargetRelativeAngle = 100
        }
}

 target root
{
        debugMode = False
        useToolbar = True
        useAppLauncher = True
        onlyInSpaceCenter = False
        DistantFlare
        {
                flaresEnabled = False
                flareSaturation = 1
                flareSize = 1
                flareBrightness = 1
                ignoreDebrisFlare = False
                debrisBrightness = 0.150000006
                situations = ORBITING,SUB_ORBITAL,ESCAPING,DOCKED,FLYING
                showNames = True
        }
        DistantVessel
        {
                renderVessels = False
                maxDistance = 750000
                renderMode = 0
                ignoreDebris = False
        }
        SkyboxBrightness
        {
                changeSkybox = True
                maxBrightness = 0.25
                referenceBodySize = 1
                minimumSignificantBodySize = 1
                minimumTargetRelativeAngle = 100
        }
}

using this code:

			ConfigNodeWithSteroids settings = ConfigNodeWithSteroids.from(configNode);
			UnityEngine.Debug.LogFormat("DOE *****\n source {0}\n target {1}", configNode, settings);

@Lisias Lisias closed this as completed Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant