MegaMek / mekhq

MekHQ is a java helper program for the MegaMek game that allows users to load a list of entities from an XML file, perform repairs and customizations, and then save the new entities to another XML file that can be loaded into MegaMek.
http://megamek.org
131 stars 170 forks source link

Ammunition Reload issues (still?) #834

Closed Jesterr closed 4 years ago

Jesterr commented 6 years ago

Environment

mekhq-0.44.0-windows Windows 10 C:\Users\rjoiner>java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Description

Similar to "Ammunition Reload Issues #583" marked closed. Commented on that thread too. but couldn't "reopen."

Meks with artemis ammo or gauss ammo will infinitely consume ammunition in "repair bay" without ever "fixing" the repair. Ie, ammunition is consumed, the repair takes time to complete, there is a roll, but the ammunition counter on the vee/mek is not incremented up, so the vee/mek never clears out of the repair queue. Mass Repair in group mode, Mass repair selected on an individual mek, individually selecting the repair task, and GM Mode -> complete task, all act the same way described above. (Routine use of mass repair will drain ammo stores in the warehouse quickly.)

This week(end) I upgraded my mekhq from 0.42.2 to 0.44.0, and transported my current campaign into the new version when I noted the problems (several fights in when I wondered where my ammo stockpiles went.) Upgrade consisted of me of unzipping a the new version into its own directory, and copying over camo, custom meks, portraits, and ./campaigns/* I started the new mekhq, and loaded the last campaign file saved explicitly to import. had a complaint about an infantry unit. Deleted that in 0.42.2, re-imported campaign save without offending infantry, game loaded fine. When scenarios are launched, megamek gives a complaint about the unit, but I've deleted it. This info is included for full disclosure report.

The problem is not consistent across meks, in that some that utilize artemis or gauss ammo, can still be reloaded, but once a mek/vee is 'stuck' in this mode, there is no clearing it.

Each mek, as it comes out of a mission, becomes impossible to reload, but only for meks with Artemis or "advanced" gear like a gauss rifle. Standard gear only meks/vees seem to work fine. (Ie, my Von Luck tank, with SRM6 and SRM4s reload fine. My Battlemaster customer with SRM6 and artemis, will not reload the SRM6 ammo. My Highlander HGN-732b won't reload its LRM20 (std not artemis). )

So far, the actions have persisted across restarts of mekhq.

Screenshots: (Custom battlemaster has 2 tons of ammo for srm/6, but 3(5) reloads hasn't worked):

mekhqissue-start mekhqissue-post1

Steps to reproduce: Not sure if loading previous campaign is necessary. But load it. Play match. Go to reload ammo on meks. Ones with Artemis LRM/SRMs won't load. Mechs with normal LRMs won't load if they have a gauss equipped.

Files

mekhqlog.txt Jester's Fools30470530.zip

(custom infantry from 0.42.2 is not loading, deleted and removed from campaign and still seeing error...) Custom meks included: Jester's Fools customs.zip

Other customizations include portraits and camo. I can provide if needed, but they're the usuals (ALL-cammos.zip, Auscam.zip, Digital Camo, Dylans_camo, portraits_bw_ink and portraits_colour_ink, etc. Nothing not found on the megamek forums.)

sixlettervariables commented 6 years ago

You're missing a Jenner from the custom units (Janky), but I've removed it from the cpnx.

I can reproduce and will track this down.

Jesterr commented 6 years ago

For completeness sake here's the missing mek:

3051-J-lance-med.zip

I believe all of the meks involved were created either using 0.42.2 mekhq's customize tab, or through the megameklab bundled with 0.42.2 (as a standalone instance). Not sure if that's helpful info or not, but trying to over-communicate.

Thanks!

sixlettervariables commented 6 years ago

The bug appears to be in AmmoBin::loadBin:

    public void loadBin() {
        int shots = Math.min(getAmountAvailable(), getShotsNeeded());
        if(null != unit) {
            Mounted mounted = unit.getEntity().getEquipment(equipmentNum);
            if(null != mounted && mounted.getType() instanceof AmmoType) {
                if (!ammoTypeChanged()) {
                    //just a simple reload
                    mounted.setShotsLeft(mounted.getBaseShotsLeft() + shots);
                } else {
                    //loading a new type of ammo
                    unload();
                    mounted.changeAmmoType((AmmoType)type);
                    mounted.setShotsLeft(shots);
                }
            }
        }
        changeAmountAvailable(-1 * shots, (AmmoType)type);
        shotsNeeded -= shots;
    }

Basically, the instanceof fails but we still deduct the shots. Digging into the fix.

sixlettervariables commented 6 years ago

I don't know the fix yet, but I've narrowed it down:

  1. The mount comes back as ISCASE for that ammo bin.
  2. There are three ammo bins in your campaign file for the unit, but only two on the Mech.
  3. The third bin (SRM 6 Inferno) has the wrong equipment num, because it is unmatched.
  4. Removing one of the SRM 6 bins and replacing it with the SRM 6 Inferno bin in the CPNX fixes it.

Attached is a minimal repo campaign and the 'fixed' version of the minimal repo:

sixlettervariables commented 6 years ago

I did some more digging and it looks like you may have been bitten by refitting bugs in a prior version of MML/MHQ:

07:16:03,551 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Warhammer WHM-7D-J45 Mk II (Aegis-fang) d89e22d2-6f7a-467a-8308-b65c3062b9f8
Could not unscramble equipment number for PPC eq:7
Available (remaining) equipment:
 0: Standard Standard
 1: Standard Standard
 7: ER PPC ER PPC
 16: Double Heat Sink Double Heat Sink
 17: Double Heat Sink Double Heat Sink
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
 25: Double Heat Sink Double Heat Sink
 26: Double Heat Sink Double Heat Sink
07:16:03,553 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for BattleMaster BLR-1G-DC-J45 Mk II (BattleBot) 062b4b6e-5c44-4664-94b7-4c043b673891
Could not unscramble equipment number for SRM 6 Ammo Bin eq:11
Available (remaining) equipment:
 0: Standard Standard
 1: Endo Steel Endo Steel
 11: CASE CASE
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
 25: Double Heat Sink Double Heat Sink
 26: Double Heat Sink Double Heat Sink
 27: Double Heat Sink Double Heat Sink
 28: Double Heat Sink Double Heat Sink
 29: Double Heat Sink Double Heat Sink
 30: Double Heat Sink Double Heat Sink
07:16:03,554 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Griffin GRF-2N 82f091ec-8a8b-407b-bd70-92fdaae4b294
Could not unscramble equipment number for PPC eq:2
Available (remaining) equipment:
 0: Ferro-Fibrous Ferro-Fibrous
 1: Endo Steel Endo Steel
 2: ER PPC ER PPC
 12: CASE CASE
 14: Double Heat Sink Double Heat Sink
 15: Double Heat Sink Double Heat Sink
 16: Double Heat Sink Double Heat Sink
 17: Double Heat Sink Double Heat Sink
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
07:16:03,557 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Orion ON1-K2-J45 Mk II (Oniichan) #2 3173bed6-631b-48ba-8734-5d4dfacbcec3
Could not unscramble equipment number for LRM 15 eq:4
Available (remaining) equipment:
 0: Standard Standard
 1: Ferro-Fibrous Ferro-Fibrous
 4: ER PPC ER PPC
 8: CASE CASE
 11: Double Heat Sink Double Heat Sink
 12: Double Heat Sink Double Heat Sink
 13: Double Heat Sink Double Heat Sink
 14: Double Heat Sink Double Heat Sink
 15: Double Heat Sink Double Heat Sink
 16: Double Heat Sink Double Heat Sink
 17: Double Heat Sink Double Heat Sink
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
07:16:03,559 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Highlander HGN-732b 4e9a02b0-4f28-4ec2-a628-de38d668c9f8
Could not unscramble equipment number for LRM 20 Ammo Bin eq:11
Available (remaining) equipment:
 0: Standard Standard
 1: Ferro-Fibrous Ferro-Fibrous
 11: CASE CASE
 18: CASE CASE
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
 25: Double Heat Sink Double Heat Sink
 26: Double Heat Sink Double Heat Sink
 27: Double Heat Sink Double Heat Sink
 28: Double Heat Sink Double Heat Sink
 29: Double Heat Sink Double Heat Sink
07:16:03,573 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Longbow LGB-7Q d24cad90-cee5-4f90-8937-642db2823111
Could not unscramble equipment number for LRM 15 Artemis-capable Ammo Bin eq:13
Could not unscramble equipment number for LRM 15 Artemis-capable Ammo Bin eq:16
Could not unscramble equipment number for Double Heat Sink eq:11
Could not unscramble equipment number for LRM 15 Artemis-capable Ammo Bin eq:19
Could not unscramble equipment number for LRM 15 Artemis-capable Ammo Bin eq:20
Could not unscramble equipment number for Double Heat Sink eq:18
Could not unscramble equipment number for Artemis IV FCS eq:5
Could not unscramble equipment number for Artemis IV FCS eq:6
Could not unscramble equipment number for Artemis IV FCS eq:9
Could not unscramble equipment number for Artemis IV FCS eq:10
Could not unscramble equipment number for LRM 15 eq:7
Available (remaining) equipment:
 0: Standard Standard
 1: Standard Standard
 2: Heat Sink Heat Sink
 3: Heat Sink Heat Sink
 4: Heat Sink Heat Sink
 5: Heat Sink Heat Sink
 6: LRM 20 LRM 20
 7: LRM 20 LRM 20
 9: Heat Sink Heat Sink
 10: Heat Sink Heat Sink
 11: Heat Sink Heat Sink
 13: Medium Laser Medium Laser
 16: Heat Sink Heat Sink
 18: Heat Sink Heat Sink
 19: Heat Sink Heat Sink
 20: LRM 5 LRM 5
 25: Heat Sink Heat Sink
 26: Heat Sink Heat Sink
 27: Heat Sink Heat Sink
 28: Heat Sink Heat Sink
 29: Heat Sink Heat Sink
 30: Heat Sink Heat Sink
 31: Heat Sink Heat Sink
 32: Heat Sink Heat Sink
 33: Heat Sink Heat Sink
 34: Heat Sink Heat Sink
07:16:03,574 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Longbow LGB-7Q #2 6391097a-5f40-489e-a0c1-b65f6c7295f4
Could not unscramble equipment number for LRM 15 eq:3
Could not unscramble equipment number for Artemis IV FCS eq:5
Could not unscramble equipment number for LRM 15 eq:4
Could not unscramble equipment number for Artemis IV FCS eq:6
Could not unscramble equipment number for LRM 15 eq:7
Available (remaining) equipment:
 0: Standard Standard
 1: Standard Standard
 3: Heat Sink Heat Sink
 4: Heat Sink Heat Sink
 5: Heat Sink Heat Sink
 6: LRM 20 LRM 20
 7: LRM 20 LRM 20
 25: Heat Sink Heat Sink
 26: Heat Sink Heat Sink
 27: Heat Sink Heat Sink
 28: Heat Sink Heat Sink
 29: Heat Sink Heat Sink
 30: Heat Sink Heat Sink
 31: Heat Sink Heat Sink
 32: Heat Sink Heat Sink
 33: Heat Sink Heat Sink
 34: Heat Sink Heat Sink
07:16:03,575 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Griffin GRF-2N #3 cbf4ef68-bb14-4136-a811-e5bc6aff7ef1
Could not unscramble equipment number for SRM 6 Ammo Bin eq:12
Available (remaining) equipment:
 0: Ferro-Fibrous Ferro-Fibrous
 1: Endo Steel Endo Steel
 12: CASE CASE
 14: Double Heat Sink Double Heat Sink
 15: Double Heat Sink Double Heat Sink
 16: Double Heat Sink Double Heat Sink
 17: Double Heat Sink Double Heat Sink
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
07:16:03,575 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Archer ARC-2Rb #2 c37f5fed-7748-472c-a0c2-32bb6a44a5cc
Could not unscramble equipment number for LRM 20 Ammo Bin eq:9
Available (remaining) equipment:
 0: Standard Standard
 1: Medium Laser Medium Laser
 2: Endo Steel Endo Steel
 3: Medium Laser Medium Laser
 4: LRM 20 LRM 20
 9: CASE CASE
 14: CASE CASE
 16: Double Heat Sink Double Heat Sink
 17: Double Heat Sink Double Heat Sink
 18: Double Heat Sink Double Heat Sink
 19: Double Heat Sink Double Heat Sink
 20: Double Heat Sink Double Heat Sink
 21: Double Heat Sink Double Heat Sink
 22: Double Heat Sink Double Heat Sink
 23: Double Heat Sink Double Heat Sink
 24: Double Heat Sink Double Heat Sink
 25: Double Heat Sink Double Heat Sink
07:16:03,577 INFO [mekhq.Utilities] {SwingWorker-pool-2-thread-1} 
Could not unscramble equipment for Longbow LGB-7Q #3 08071220-d196-40c6-ac0b-ad7ee0e5e8e3
Could not unscramble equipment number for LRM 15 eq:7
Could not unscramble equipment number for LRM 15 Artemis-capable Ammo Bin eq:13
Could not unscramble equipment number for Double Heat Sink eq:11
Could not unscramble equipment number for Double Heat Sink eq:18
Could not unscramble equipment number for Artemis IV FCS eq:6
Available (remaining) equipment:
 0: Standard Standard
 1: Standard Standard
 6: LRM 20 LRM 20
 7: LRM 20 LRM 20
 11: Heat Sink Heat Sink
 13: Medium Laser Medium Laser
 18: Heat Sink Heat Sink
 25: Heat Sink Heat Sink
 26: Heat Sink Heat Sink
 27: Heat Sink Heat Sink
 28: Heat Sink Heat Sink
 29: Heat Sink Heat Sink
 30: Heat Sink Heat Sink
 31: Heat Sink Heat Sink
 32: Heat Sink Heat Sink
 33: Heat Sink Heat Sink
 34: Heat Sink Heat Sink

I've attempted to recreate the situation from a stock GFN-2N and am unable to do so.

NickAragua commented 6 years ago

Partial fix in the next dev release. For now, the best workaround is to gm-remove units that have trouble and gm-add a new one.

Jesterr commented 6 years ago

Thanks! I can work with that work-around.

Jesterr commented 6 years ago

TL;DR: Reproduced problem in minimal campaign. SRM6-artemis-enabled ammo in slot 12 of Left torso causes issue.

I tried the work around and it worked for the most part; however, I found a unit that persistently won't "fix" and spent some time narrowing down the case.

The unit in my campaign is the Battlemaster refit "Battlebot." The SRM6 artemis rounds will not load, even if I delete the unit and add one back. Specifically, I have to add a BLR-1G and refit it to the Battlebot.

Using the above minimal campaign, I could reliably reproduce the problem following these steps:

Fresh install/unzip of mekhq-0.44.0-windows. Copy and unzip Jester's Fools30470530-stripped-fixed.zip into mekhq-0.44.0-windows/campaigns/test/ Run mekhq, load campaign. Unit Purchase, BLR-1G BattleMaster, Add (GM) In Hanger tab-> Select Battlemaster ->Customize -> Customize in Mek Lab In Mek Lab tab: Structure/Armor tab: Change Tech Level from Introductory to Standard. Equipment tab: Select 2x (both) SRM 6 ammo, remove. Add 1x Artemis IV FCS (From Other Equipment drop down) Add 1x SRM 6 Artemis-capable Ammo ***Assign Critical tab: Add SRM 6 Artemis-capable Ammo to Left Torso, must be slot 12 (lowest slot, where top is slot 1). Add Artemis IV FCS to Left Torso. I don't believe slot matters, but I put in slot 11 (2nd lowest slot) Select Begin Refit. Select Tucker Inokene, Veteran Mech Tech, 105/420 minutes. (Only choice) Named as BLR-1G MkII test-artemis-and-ammo-only Hanger tab -> Select BLR, Customize-> Complete Refit (GM) Select repair bay. Battlemaster should be in there, with a reload requirement, and "do task" will perform as reported in the bug report.

I've done a number of tests, trying to isolate the issue. I've tested ammo in other slots, (7-8, 11, etc) and don't get the issue to trigger. If a refit does trigger the issue, customizing using the "refit kit" produced will cause new meks to have the issue. "Normal" srm ammo does not cause this issue. Only tested with Artemis-enabled. Does not need Artemis IV FCS installed to trigger issue. (Tested by removing the 2 tons of ammo, added 1 ton artemis srm ammo and a Medium Laser. If artemis srm ammon is in slot 12, issue happens. if in slot 11, even with ML in slot 12, did not trigger the issue)

I tested using inferno ammo and a medium laser, ammo in slot 12, and it also triggered the issue.

I tested dropping the MG ammo, SRM ammo, and adding an LRM5 into slot 11 and LRM5-artemis ammo into slot 12. No issue with this.

An observation that may, or may not, have anything to do with it: In the repair bay, meks that exhibit the issue are set to Standard SRM ammo for the task, not the appropriate ammo (artemis/inferno). Changing this doesn't seem to affect/fix the issue, but does update the repair task, and drains ammo from the new ammo type.

Campaign save before and after: Jester's Fools30470530-stripped-fixed-issue_found.zip

Mek customization file that induced issue saved in campaign: BattleMaster BLR-1G Mk II SRM6-artemis-ammo-in-slot12.zip

sixlettervariables commented 4 years ago

So whatever fixes we've done since 0.46 appear to have resolved this. I followed your very detailed steps @Jesterr (thank you by the way) on the latest version of MHQ and did not have the issue. I tried a few different slots and they all worked. Please reopen this if you see it on a more recent version of MHQ. My apologies for getting back to this so late!