Bug - Confirmed Can no longer use file_to_map to access a file contained in the KoLmafia jar

fronobulax

Developer
Staff member
See https://kolmafia.us/threads/wtf-relay-script-collection.15696/page-10#post-160450 and beyond.

Using the debugger shows the file fails the valid parent checking introduced 11/23.

Install my Currencies, run the relay script and observe the absence of all the data derived from coinmasters.txt to verify.

I'm not sure how to address. The changed code introduces a list of valid directories as parents, and will only open files in one of those directories. But it is not immediately clear to me how to create a pseudo parent that will behave as a file for the rest of the code but refers to an embedded file.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
We need to be really careful with this code because I was finding unending loopholes in my testing. Unfortunately the execution path is extremely circuitous and I am not confident enough that its unnecessarily circuitous to rip out the complication and make it work better.

If I have the time I will look into everything that uses FileUtils or whatever its called and try to do a codebase-wide refactor of that flow.
 

philmasterplus

Active member
I tried using data/coinmasters.txt instead of coinmasters.txt and it worked on r20552. @fronobulax Could you check if this works for you, too?

Code:
record CoinmasterInfo {
  string buyOrSell;
  int coinAmount;
  item it;
};
CoinmasterInfo [string] coin_masters;
file_to_map("data/coinmasters.txt", coin_masters);
foreach name, info in coin_masters {
  print(`{name} => {info.buyOrSell}, {info.coinAmount}, {info.it}`);
}
 

fronobulax

Developer
Staff member
data/coinmasters.txt seems to be working for me. I'll wait for other opinions but maybe this is a Bug - Won't Fix and the work around is files in the KoLmafia jar need to have their name appended to "data/" to be read.

Interesting question - if a user creates a file named coinmasters.txt in data/ which file would have been read previously and which one gets read now? Similarily, what happened/happens if a user tries to write coinmasters.txt or data/coinmasters.txt?
Rather than satisfy my curiosity I am content with declaring the file names in the source tree src/data are all reserved.

Thanks for trying that. I wasn't thinking in that direction.
 

Veracity

Developer
Staff member
We have an internal ASH script to decorate Valhalla to help you choose TCRS.
I just ascended for the first time in months. The script is running, but is not displaying item or consumption data at all.

src/relay/afterlife.php:

Code:
static {
    file_to_map( "TCRS.astral_pets.txt", pet_modifiers );
    file_to_map( "TCRS.astral_consumables.txt", consumable_modifiers );
}
Oops. Internal KoLmafia-supplied scripts were broken by this.

Revision 20595 fixes that.

Turns out that I need to generate those two data files, since we have updated the TCRS keys. Surely I have submitted a script, somewhere, to do that?
 
Top