Project

General

Profile

Bug #10247

IMassModifier/ICostModifier called before PartModule OnLoad/OnStart - being called on uninitialized modules.

Added by shadowmage45 over 7 years ago. Updated over 7 years ago.

Status:
Closed
Severity:
Normal
Assignee:
-
Category:
Parts
Target version:
Start date:
08/02/2016
% Done:

100%

Version:
Platform:
Windows
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

As per the title, IMassModifier/ICostModifier is often called before parts are fully initialized, resulting in inconsistent reporting of mass and/or cost for modules that rely on internal state for their modifications.

This is making it difficult to properly modify the mass for the editor display icon and results in improper mass for the first few physics ticks(perhaps only one tick) of flight for a craft.

Expected behavior: IMassModifier/ICostModifier methods are only called on fully initialized PartModules (e.g. they have had both OnLoad/OnStart called).

Actual behavior: IMassModifier/ICostModifier are called prior to PartModules having initialization methods called on them, resulting in those that rely on state data to have no information on how they are supposed to modify mass/cost.

History

#2 Updated by ShotgunNinja over 7 years ago

I don't know if is relevant, but OnLoad() is not called in the editor when you add a part.

Instead, the following happen:

  • at part compilation time (loading screen):
    - OnLoad() is called
    - GetInfo() is called, the result stored in part info
    - GetModuleCost()/GetModuleMass() are called, the result stored in part info (the total for the part)
  • when adding a part in the editor:
    - part is copied from prefab (by first serializing it to binary data, then deserializing it in the clone)
    - OnStart() is called
  • inside the editor, if GetModuleCostChangeWhen()/GetModuleMassChangeWhen() return ModifierChangeWhen.CONSTANTLY:
    - GetModuleCost()/GetModuleMass() are called every frame, the vessel cost and mass updated correctly

#3 Updated by Squelch over 7 years ago

  • Status changed from New to Ready to Test
  • Target version set to 1.2.0
  • % Done changed from 0 to 80

I understand that this has now been found to be working correctly in KSP 1.2

#4 Updated by shadowmage45 over 7 years ago

Squelch wrote:

I understand that this has now been found to be working correctly in KSP 1.2

Indeed, I was unable to replicate it in the latest pre, or 1.2 actual release.

#5 Updated by Squelch over 7 years ago

  • Status changed from Ready to Test to Resolved
  • % Done changed from 80 to 100

Thanks shadowmage45.

I'll mark this as resolved now.

#6 Updated by JPLRepo over 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF