OpenMW-CS: FRMR subrecords are saved with the wrong MastIdx

OpenMW-cs fails to save FRMR MastIdx proper value bringing duplication of objects in game.

I attached a minimal example, in the zip archive are two esp files: bck_no_pit.esp is the original, ocs_no_pit.esp is the result of just opening and saving it with OpenMW-cs.

The mod is tiny, it replaces the tar pit of the Urshilaku camp with a bunch of rocks.

bck_no_pit.esp

Record: TES3 "()" Flags:0x0000 ()
  HEDR:   Version:1.3  Is_Master:False  Author:""
  Description:""
  N_Records:1
 *MAST: Master:morrowind.esm
  DATA: Length:79837557

Record: CELL "urshilaku camp (-4, 18)" Flags:0x0000 ()
  NAME: Name:Urshilaku Camp
  DATA: (Exterior) Coordinates: (-4, 18)  Flags:0x0046 (Has_Water, Illegal_To_Sleep_Here)
  RGNN: Region:Ashlands Region
  NAM5: Color:6333898
  NAM0: Reference_Count:1
 *FRMR: ObjIdx:129925  MastIdx:1
  NAME: Name:Terrain_rocks_WG_03
  DATA: X:-27380.828  Y:150868.656  Z:700.000  X_Angle:0.0000  Y_Angle:0.0000  Z_Angle:0.0000

after saving it becomes

Record: TES3 "()" Flags:0x0000 ()
  HEDR:   Version:1.3  Is_Master:False  Author:""
  Description:""
  N_Records:1
 *MAST: Master:Morrowind.esm
  DATA: Length:79837557

Record: CELL "urshilaku camp (-4, 18)" Flags:0x0000 ()
  NAME: Name:Urshilaku Camp
  DATA: (Exterior) Coordinates: (-4, 18)  Flags:0x0046 (Has_Water, Illegal_To_Sleep_Here)
  RGNN: Region:Ashlands Region
  NAM5: Color:6333898
  NAM0: Reference_Count:1
 *FRMR: ObjIdx:129925  MastIdx:0
  NAME: Name:Terrain_rocks_WG_03
  DATA: X:-27380.828  Y:150868.656  Z:700.000  X_Angle:0.0000  Y_Angle:0.0000  Z_Angle:0.0000

It is almost the same, but the different MastIdx breaks the effect in game. So that you'll see the rocks and the pit overlapping.

It is possible to have the same effect making a mod that moves existing objects. For example create a mod that just moves the Journal of Tarhiel (id bk_falljournal_unique) of few steps using the Bethesda editor. Open and save the mod with OpenMW-cs and you will get two copies of the book.

The bug is critical for it stops openmw-cs to be usable to edit a large class of mods.

no_pit.zip

Edited by Andrei Kortunov