juk0de / mtf2json

Convert MegaMek's MTF format to JSON.
GNU General Public License v3.0
2 stars 0 forks source link

Fluff lines without key result in wrong critical slot entries #14

Closed juk0de closed 1 week ago

juk0de commented 1 week ago

As reported in #12, there are MTF files that contain lines without a key in the fluff section.

Example: ThunderHawk TDK-7S

overview:The Thunder Hawk, developed by Norse Technologies for the Amaris-Terran Hegemony invasion, became a staple in General Aleksandr Kerensky's forces. Surviving 'Mechs were taken into Exodus, symbolizing their significance. In the 3050s, Norse-Storm BattleMechs revived the Thunder Hawk among other Star League-era designs.
capabilities:Dominating the Thunder Hawk's arsenal are three Norse Gauss rifles, accounting for over half its weight. These long-range weapons can incapacitate most foes with a single barrage. Ammunition is distributed throughout the torso to mitigate critical damage risks. However, its Achilles' heel lies in the extra-light Vlar fusion engine. While heavily armored, any breach in the torso significantly compromises the BattleMech’s structural integrity, rendering it inoperable.
deployment:The Thunder Hawk TDK-7S variant emerged towards the end of the FedCom Civil War, marking Norse-Storm's innovative approach to modernizing the venerable design. This variant was developed to enhance survivability in close combat situations while retaining the Thunder Hawk's signature firepower and speed.<p>In the TDK-7S, Norse designers made a significant modification by replacing the extra-light engine with a more robust 300 Light Engine. This change aimed to increase the 'Mech's longevity in the heat of battle without compromising its main armaments or mobility. To accommodate this heavier engine, the 7S sacrifices two medium lasers, two tons of ammunition for the Gauss Rifles, and a ton of armor.</p><p>Armed with three Gauss Rifles, one each in the right arm, left torso, and right torso, the TDK-7S maintains the Thunder Hawk's capability for delivering devastating long-range strikes. Complementing this are two Medium Lasers, one in the right arm and one in the head, providing effective secondary weaponry for closer engagements.</p><p>As of now, only a dozen TDK-7S models have been produced. Norse-Storm is cautiously monitoring the reception of this variant before committing to full-scale production. This caution stems from the variant's experimental nature and the significant changes made to the original design.</p>
<p>Despite these alterations, the TDK-7S retains the Thunder Hawk's iconic status as a command 'Mech with a good reputation. It presents a unique blend of traditional firepower with an experimental approach to durability, making it a potential game-changer on the battlefield for units that can adapt to its strengths and limitations.</p>
history:The Thunder Hawk became a hallmark of the Lyran Alliance, extensively utilized during the FedCom Civil War. Contrary to its design as a support 'Mech, Loyalists deployed it in direct combat, leveraging its heavy armor. Post-war, Archon Peter Steiner Davion allocated new Thunder Hawks to units loyal to Allied forces. Plans for export are pending until the completion of military restructuring.

The line starting with <p>Despite these alterations contains no key and this is not correctly handled. Currently, this results in wrong entries to the right leg slots:

    "right_leg": {
      "1": "Hip",
      "2": "Upper Leg Actuator",
      "3": "Lower Leg Actuator",
      "4": "Foot Actuator",
      "5": null,
      "6": null,
      "7": null,
      "8": null,
      "9": null,
      "10": null,
      "11": null,
      "12": null,
      "13": "<p>Despite these alterations, the TDK-7S retains the Thunder Hawk's iconic status as a command 'Mech with a good reputation. It presents a unique blend of traditional firepower with an experimental approach to durability, making it a potential game-changer on the battlefield for units that can adapt to its strengths and limitations.</p>"
    }

However, I'm not sure if these MTF files are actually valid or legal. Although there's no MTF specification, the code seems to only parse the line content after the key, ignoring the following line (see here and here)

juk0de commented 1 week ago

After verifying that those lines are actually ignored by the MegaMek MTF parser, I've reported the issue to MegaMek (https://github.com/MegaMek/megamek/issues/6022). I'm going to implement a workaround to mtf2json that also ignores those lines.