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

Engine simulation #145

Open
WarezCrawler opened this issue Feb 18, 2018 · 2 comments
Open

Engine simulation #145

WarezCrawler opened this issue Feb 18, 2018 · 2 comments

Comments

@WarezCrawler
Copy link

Suggestion for code change...

The current engine simulation is dependent on the stock multimode module. This makes KER calculate incorrect for my custom multimode modules. Therefore I've done some testing and think it can be made more general.

I rewrote "public void CreateEngineSims(..)", now relying on engine.isEndabled which it the same setting the stock multimode is manipulating to enable/disable engines.
This way the logic does the same thing for all engines, and does not rely on other modules for the logic.

I hope this helps.

my mod for reference

https://forum.kerbalspaceprogram.com/index.php?/topic/152667-131-gtindustries-updated-04-02-2018/#comment-2866210 <<<

--- CODE CHANGES ---
public void CreateEngineSims(List allEngines, double atmosphere, double mach, bool vectoredThrust, bool fullThrust, LogMsg log)
{
if (log != null) log.AppendLine("CreateEngineSims for ", this.name);
List cacheModuleEngines = part.FindModulesImplementing();

try
{
	if (cacheModuleEngines.Count > 0)
	{
		//Debug.Log("[KER-GTI Extension] Engine Exists " + cacheModuleEngines.Count + " " + this.part.ToString());
		//find first active engine, assuming that two are never active at the same time
		foreach (ModuleEngines engine in cacheModuleEngines)
		{
			//Debug.Log("[KER-GTI Extension] Engine Evaluated " + engine.isEnabled);
			if (engine.isEnabled)
			{
				//Debug.Log("[KER-GTI Extension] Engine Enabled");
				if (log != null) log.AppendLine("Module: ", engine.moduleName);
				EngineSim engineSim = EngineSim.New(
					this,
					engine,
					atmosphere,
					(float)mach,
					vectoredThrust,
					fullThrust,
					log);
				allEngines.Add(engineSim);
			}
		}
	}
}
catch
{
	Debug.Log("[KER-GTI Extension] Error Catch in CreateEngineSims");
}

}

@jrbudda
Copy link
Contributor

jrbudda commented Mar 22, 2018

Try this, looks ok based on your explanation and my 5 minutes of looking at it.

KerbalEngineer-1.1.4.2b.zip

@WarezCrawler
Copy link
Author

It looks like it is working as expected.

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

2 participants