Jump to content


Photo

fixing kitlist.2da


9 replies to this topic

#1 subtledoctor

subtledoctor
  • Modders
  • 2145 posts
  • Gender:Male

Posted 04 August 2017 - 01:07 PM

BG2EE ships with one entry missing from kitlist.2da: the GRIZZLY_BEAR kit has no KITIDS value. If I do something like this:
FOR (row = 1; row < rows; ++row)
   READ_2DA_ENTRY row 9 1 value
END
...then the whole mod install craps out when it hits the row with nothing to READ in that column. But, I really need to read the values in that column (for other kits before and after GRIZZLY_BEAR). Also, I'm told that several mods are adding kits that leave that column blank.

So is there a way I can repair the table before doing my READ? I'm trying to wrap my head around how that could possibly be done, when even encountering the gap causes a "read out of bounds" error.

I've tried a simple SET_2DA_ENTRY on the known broken row, but that craps out too. And anyway there is the issue of other unknown mods causing more broken rows to be added before my mod is installed.

Edited by subtledoctor, 04 August 2017 - 01:08 PM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#2 subtledoctor

subtledoctor
  • Modders
  • 2145 posts
  • Gender:Male

Posted 04 August 2017 - 01:10 PM

It would be insane to just append a whole new column to the file... right?

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#3 Roxanne

Roxanne
  • Modders
  • 1576 posts
  • Gender:Not Telling

Posted 04 August 2017 - 01:40 PM

Repair would really mean something is broken here?

 

I would rather understand your text with these meanings

Fixing kitlist.2da >>> Enhancing kitlist.2da (for mod purpose)

Missing >>> optional column left blank

Broken rows >>>blank lines not suitable for your purpose


Edited by Roxanne, 04 August 2017 - 01:52 PM.

The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#4 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6210 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 04 August 2017 - 02:12 PM

Yeah, well it's is broken, Not that you can read this message, but anyways.

It would be insane to just append a whole new column to the file... right?

Well, depends if you do it correctly, then you can AND probably should even ... aka it will not leave markers to correct file, and it fixes only the erroneous/missing .ids. So the originally correct files won't get extended with another exact copy of the previous column.

You read the kit.ids file, and then read the kitlist.2da file and if the file fails to read, you insert the variable into it. As the first action ... and debug it as "checking kitlist.2da's validity" or what ever cheese you wish.

And then run what ever you intended to do.


Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#5 Mike1072

Mike1072
  • Gibberling Poobah
  • 2359 posts
  • Gender:Male
  • Location:Canada

Posted 04 August 2017 - 03:00 PM

READ_2DA_ENTRY value value value variable

The first value is the row, the second is the column and the third is the required column count. The variable specified is set to the entry on the given column of the given row, but only column with at least as many columns as the required column count are considered.


In your example, you're attempting to read the 10th column from rows that have at least 1 column. You should specify a required column count of at least 10 to skip rows that have fewer columns.

#6 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6210 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 04 August 2017 - 03:05 PM

Aka ?

FOR (row = 1; row < rows; ++row)
   READ_2DA_ENTRY row 9 10 value
END

And if that fails, just ...
WRITE_2DA_ENTRY row 9 10 ~kitnumberfromkitidsfileentry~

Edited by Jarno Mikkola, 04 August 2017 - 03:08 PM.

Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#7 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9222 posts
  • Gender:Not Telling

Posted 04 August 2017 - 03:30 PM

For missing table entries, I usually play around with REPLACE_TEXTUALLY Instead; this is how Fixpack deals with a few CLABs with missing columns. If you know the bad kits, it becomes even easier to find and replace the rows you're looking for. For GRIZZLY_BEAR in particular something like this should work:

REPLACE_TEXTUALLY ~\(^[0-9]+[ %TAB%]+GRIZZLY_BEAR[ %TAB%]+[0-9]+[ %TAB%]+[0-9]+[ %TAB%]+[0-9]+[ %TAB%]+[^ %TAB%]+[ %TAB%]+[0-9]+[ %TAB%]+0x[0-9A-F]+[ %TAB%]+[0-9]+[ %TAB%%LNL%%MNL%%WNL%]*\)$~ 
  ~\1 0x00004027~

I just wrote this on the fly, so you'll probably need to adjust the regexp a bit, but this should fix the line if it's missing the kitids entry and ignore it if it's already fixed.


Edited by CamDawg, 04 August 2017 - 03:31 PM.

I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#8 subtledoctor

subtledoctor
  • Modders
  • 2145 posts
  • Gender:Male

Posted 04 August 2017 - 06:07 PM

In your example, you're attempting to read the 10th column from rows that have at least 1 column. You should specify a required column count of at least 10 to skip rows that have fewer columns.

So, what I posted was a quick approximation. The actual code that was failing was more like
FOR (row=1; row<rows; ++row) BEGIN
   READ_2DA_ENTRY row 9 9 value
END
I forgot about the "0th" column - that one of those two 9s actually means "10." :p

For missing table entries, I usually play around with REPLACE_TEXTUALLY


That's what I'm doing for my quick-and-dirty fix right now, but only for the last two entries - regexp hurts more head too much to do without spending some real thinking me on it. But my "fix" is bad in that, if someone adds the entry before me, it will then add an 11th column for that one row.

Edited by subtledoctor, 04 August 2017 - 06:12 PM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#9 K4thos

K4thos
  • Modders
  • 1057 posts
  • Gender:Male

Posted 04 August 2017 - 06:47 PM

Already posted solution here. Both propsed approaches will do the job. subtledoctor, there is no way that weidu will fail installation during column reading, like you said in that topic, if you set minimum columns to correct number in READ_2DA_ENTRY (that's what this third argument is for). Keep in mind that column number (second argument) counting starts from 0 and minimum columns (third argument) counting starts from 1.

 

edit: code from second solution is now also available as patch and action functions: http://gibberlings3....e=3#entry255693


Edited by K4thos, 04 August 2017 - 08:31 PM.


#10 kjeron

kjeron
  • Members
  • 66 posts

Posted 04 August 2017 - 09:21 PM

You could also read the columns with READ_2DA_ENTRIES_NOW instead of READ_2DA_ENTRY, since it won't fail if the column entry is missing, and doesn't require altering the file.  The column is optional, only required by kits that are to be select-able at CHARGEN.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users