NickHugi / PyKotor

A Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.
GNU Lesser General Public License v3.0
11 stars 3 forks source link

HolocronToolset 3.1.0 - 2DA IndexErrors #108

Open SiraMirai opened 1 month ago

SiraMirai commented 1 month ago

Hi I've been getting various IndexErrors relating to 2DA files. It only seems to be happening for me when editing UTI files. I have had these happen with an entirely unmodded game. I do get more of them with a modded game, however.

Traceback (most recent call last):
  File "/home/minami/Downloads/PyKotor/Tools/HolocronToolset/src/toolset/gui/editors/uti.py", line 568, in paramName
    paramtable_twoda: TwoDA = installation.htGetCache2DA(paramtableList.get_cell(paramtable, "tableresref"))
                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/minami/Downloads/PyKotor/Libraries/PyKotor/src/pykotor/resource/formats/twoda/twoda_data.py", line 319, in get_cell
    return self._rows[row_index][column]
           ~~~~~~~~~~^^^^^^^^^^^
IndexError: list index out of range

----------------------------------------------------------------
 Exception 'list index out of range' of type '<class 'IndexError'>' occurred.
Stack Trace Variables:

Function 'paramName' at /home/minami/Downloads/PyKotor/Tools/HolocronToolset/src/toolset/gui/editors/uti.py:568:
  installation = HTInstallation(
    use_multithreading=False,
    _path=CaseAwarePath("//home/minami/Games/Heroic/Star Wars - KotOR"),
    _talktable=TalkTable(
        _path=CaseAwarePath("//home/minami/Games/Heroic/Star Wars - KotOR/dialog.tlk")
    ),
    _female_talktable=TalkTable(
        _path=CaseAwarePath("//home/minami/Games/Heroic/Star Wars - KotOR/dialogf.tlk")
    ),
    _modules={'unk_m44ac.rim': [FileResource(resname='m44ac', restype=ResourceType.ARE, size=2610, offset=224, filepath=CaseAwarePath("//home/min...<truncated>
  paramtable = 255
  param = 0
  paramtableList = TwoDA(headers=['name', 'label', 'tableresref'], labels=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'], rows=[{'name': '917', 'label': 'Type', 'tableresref': 'IPRP_DAMAGETYPE'}, {'name': '918', 'label': 'Duration', 'tableresref': 'IPRP_ONHITDUR'}, {'name': '919', 'label': 'Abilities', 'tableresref': 'IPRP_ABILITIES'}, {'name': '920', 'label': 'AlignmentGroup', 'tableresref': 'IPRP_ALIGNGRP'}, {'name': '921', 'label': 'Alignment', 'tableresref': 'IPRP_ALIGNMENT'}, {'name': '922', 'label': 'RacialType', 'tableresref': 'racialtypes'}, {'name': '923', 'label': 'Disease', 'tableresref': 'disease'}, {'name': '924', 'label': 'Amount', 'tableresref': 'IPRP_AMOUNT'}, {'name': '925', 'label': 'PoisonType', 'tableresref': 'poison'}, {'name': '926', 'label': 'Color', 'tableresref': 'IPRP_COLOR'}, {'name': '924', 'label': 'Amount', 'tableresref': 'POISON'}, {'name': '927', 'label': 'Weight', 'tableresref': 'IPRP_WEIGHTINC'}])

Function 'get_cell' at /home/minami/Downloads/PyKotor/Libraries/PyKotor/src/pykotor/resource/formats/twoda/twoda_data.py:319:
  self = TwoDA(headers=['name', 'label', 'tableresref'], labels=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'], rows=[{'name': '917', 'label': 'Type', 'tableresref': 'IPRP_DAMAGETYPE'}, {'name': '918', 'label': 'Duration', 'tableresref': 'IPRP_ONHITDUR'}, {'name': '919', 'label': 'Abilities', 'tableresref': 'IPRP_ABILITIES'}, {'name': '920', 'label': 'AlignmentGroup', 'tableresref': 'IPRP_ALIGNGRP'}, {'name': '921', 'label': 'Alignment', 'tableresref': 'IPRP_ALIGNMENT'}, {'name': '922', 'label': 'RacialType', 'tableresref': 'racialtypes'}, {'name': '923', 'label': 'Disease', 'tableresref': 'disease'}, {'name': '924', 'label': 'Amount', 'tableresref': 'IPRP_AMOUNT'}, {'name': '925', 'label': 'PoisonType', 'tableresref': 'poison'}, {'name': '926', 'label': 'Color', 'tableresref': 'IPRP_COLOR'}, {'name': '924', 'label': 'Amount', 'tableresref': 'POISON'}, {'name': '927', 'label': 'Weight', 'tableresref': 'IPRP_WEIGHTINC'}])
  row_index = 255
  column = 'tableresref'
Traceback (most recent call last):
  File "/home/minami/Downloads/PyKotor/Tools/HolocronToolset/src/toolset/gui/editors/uti.py", line 568, in paramName
    paramtable_twoda: TwoDA = installation.htGetCache2DA(paramtableList.get_cell(paramtable, "tableresref"))
                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/minami/Downloads/PyKotor/Libraries/PyKotor/src/pykotor/resource/formats/twoda/twoda_data.py", line 319, in get_cell
    return self._rows[row_index][column]
           ~~~~~~~~~~^^^^^^^^^^^
IndexError: list index out of range

----------------------------------------------------------------
th3w1zard1 commented 1 month ago

Sorry for the late reply. Could you explain how I can reproduce this error on my end?

th3w1zard1 commented 1 month ago

It seems to be that the UTI you're editing is referencing the iprp_paramtable.2da but with a nonexistent rowindex. Might end up needing to post here the exact UTI you're experiencing an issue with.

th3w1zard1 commented 5 days ago

Looked into this today, the issue is suppressed so the whole editor doesn't exception and a warning is outputted to the logs. This differs from v3.1.0's behavior which as you've explained would exception out of the whole function. I'll need to go through both paramtable 2da's in the base game and figure out if 'tableresref' is indeed the correct str to check or not.