Pidgeot / python-lnp

Cross-platform re-implementation of the Lazy Newb Pack launcher.
ISC License
64 stars 10 forks source link

Simple mod merging failure #158

Closed Pidgeot closed 4 years ago

Pidgeot commented 4 years ago

I have two incredibly basic mods that both edit entity_default to allow a reaction and add a simple reaction file that contains the contents. However, every time I try to merge them the second one fails because the merge lists empty out at the same time.

I'm more than a little out of date on my Python experience, but after adding in some (rather thorough...?) debug statements to mods.py and a bit of troubleshooting, I think the use of low_i2 in the three way merge should be instead pointing at mod_j2? The use of cur_v:low_i2 looks like it would always result in an empty changeset.

I've attached my changes as well as stderr and my changes to mod.py. I don't mind submitting a PR, either, but I figure this is more than a little messy with debug statements from my tracing through it and wasn't quite sure how that'd go.

stderr.txt:

Running PyLNP 0.12a (OS: win, Compiled: True)
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\Tkinter", line 1536, in __call__
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\tkgui.mods", line 81, in <lambda>
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\tkgui.mods", line 180, in add_to_installed
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\tkgui.mods", line 198, in perform_merge
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 154, in merge_all_mods
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 181, in merge_a_mod
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 209, in merge_folder
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 247, in merge_file
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 287, in merge_line_list
  File "C:\Users\Michael Madsen\Documents\LazyNewbPack\python_lnp\build\lnp\out00-PYZ.pyz\core.mods", line 300, in three_way_merge
IndexError: list index out of range

debug log:

DEBUG: In "Rock Bins": : Starting to merge mod: Rock Bins
DEBUG: In "Rock Bins": : file "objects\entity_default.txt": : merging...
DEBUG: In "Rock Bins": : file "objects\entity_default.txt": : no overlap with previous mods, replacing vanilla file
DEBUG: In "Rock Bins": : file "objects\entity_default.txt": : merged with status 0
DEBUG: In "Rock Bins": : file "objects\reaction_rockbins.txt": : merging...
DEBUG: In "Rock Bins": : file "objects\reaction_rockbins.txt": : .\LNP\Baselines\df_43_05\raw\objects\reaction_rockbins.txt cannot be read; merging other files
DEBUG: In "Rock Bins": : file "objects\reaction_rockbins.txt": : .\LNP\Baselines\temp\raw\objects\reaction_rockbins.txt cannot be read; merging other files
DEBUG: In "Rock Bins": : file "objects\reaction_rockbins.txt": : no overlap with previous mods, replacing vanilla file
DEBUG: In "Rock Bins": : file "objects\reaction_rockbins.txt": : merged with status 0
INFO: In "Rock Bins": : Finished merging
DEBUG: In "ExpandedGlassWorks": : Starting to merge mod: ExpandedGlassWorks
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : merging...
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : performing three-way merge
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : before pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 288), ('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 293), ('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod_i2: 1 gen_i2: 1 cur_v: 0
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : after pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 288), ('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 293), ('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : equal mod ops
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : equal gen tag
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : writing block
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : back from equal gen tag
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : before pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 288), ('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('equal', 0, 287, 0, 287), ('insert', 287, 287, 287, 293), ('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod_i2: 287 gen_i2: 287 cur_v: 287
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop mod
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop gen
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : after pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('insert', 287, 287, 287, 288), ('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('insert', 287, 287, 287, 293), ('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : yield mod text (cur_v: 287, mod_j2: 293): ['\t[PERMITTED_REACTION:CRAFT_GREEN_GLASS_SWORD]\n', '\t[PERMITTED_REACTION:CRAFT_CLEAR_GLASS_SWORD]\n', '\t[PERMITTED_REACTION:CRAFT_GREEN_GLASS_BED]\n', '\t[PERMITTED_REACTION:CRAFT_CLEAR_GLASS_BED]\n', '\t[PERMITTED_REACTION:CRAFT_GREEN_GLASS_BIN]\n', '\t[PERMITTED_REACTION:CRAFT_CLEAR_GLASS_BIN]\n']
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : writing block
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : back from yield mod text
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : before pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('insert', 287, 287, 287, 288), ('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('insert', 287, 287, 287, 293), ('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod_i2: 287 gen_i2: 287 cur_v: 287
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop mod
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop gen
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : after pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : equal mod ops
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : equal gen tag
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : writing block
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : back from equal gen tag
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : before pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: [('equal', 287, 1949, 288, 1950)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: [('equal', 287, 1949, 293, 1955)]
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod_i2: 1949 gen_i2: 1949 cur_v: 1949
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop mod
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : pop gen
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : after pop
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : gen ops: []
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : mod ops: []
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : out of entries
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : yield status
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : writing block
DEBUG: In "ExpandedGlassWorks": : file "objects\entity_default.txt": : merged with status 0
DEBUG: In "ExpandedGlassWorks": : file "objects\reaction_expandedglassworks.txt": : merging...
DEBUG: In "ExpandedGlassWorks": : file "objects\reaction_expandedglassworks.txt": : .\LNP\Baselines\df_43_05\raw\objects\reaction_expandedglassworks.txt cannot be read; merging other files
DEBUG: In "ExpandedGlassWorks": : file "objects\reaction_expandedglassworks.txt": : .\LNP\Baselines\temp\raw\objects\reaction_expandedglassworks.txt cannot be read; merging other files
DEBUG: In "ExpandedGlassWorks": : file "objects\reaction_expandedglassworks.txt": : no overlap with previous mods, replacing vanilla file
DEBUG: In "ExpandedGlassWorks": : file "objects\reaction_expandedglassworks.txt": : merged with status 0
INFO: In "ExpandedGlassWorks": : Finished merging

[Issue created by fournm: 2017-05-25] [Last updated on bitbucket: 2017-06-12]

[Comment created by Pidgeot: 2017-05-25] @PeridexisErrant Assigning to you since you know this code better...

[Comment created by fournm: 2017-06-12] @Pidgeot Credit as fournm would be fine.

Glad to help!

[Comment created by Pidgeot: 2017-06-12] Fixes to mod merging (contributed by fournm) (fixes #141)

→ <<cset 77b652d2b10f>>

[Comment created by PeridexisErrant: 2017-06-11] Looks good to me - thanks, @fournm !

[Comment created by Pidgeot: 2017-06-10] @fournm I've spent some time looking at the code, and I believe the modifications you have made are correct. The extra debug information might actually be quite helpful if more errors happen here, so I'd gladlly accept this file as-is.

If you want to be credited, please make a pull request and/or tell me which name to add to the about box. (If you create a PR, feel free to add the name there at the same time, tkgui/tkgui.py, function show_about.)

I need to get a release out very soon, and I feel like this bug should be fixed in that release. So, if I don't hear from you in the next 24-48 hours, I'll grab the file as-is, and then add you to the about dialog when I hear from you.

@PeridexisErrant If you believe this is wrong, I'd appreciate a comment - otherwise the change will be in the next release.