WeiDUorg / weidu

WeiDU is a program used to develop, distribute and install modifications for games based on the Infinity Engine.
http://www.weidu.org
GNU General Public License v2.0
87 stars 19 forks source link

Can't find Items.biff in GOG.com edition due to capitalisation #196

Closed arp242 closed 3 years ago

arp242 commented 3 years ago

Let's say I want to extract an item; it lists the file:

$ ~/WeiDU-Linux/weidu --list-files | grep AMUL09
AMUL09.ITM
IAMUL09.BAM

But extracting it fails:

$ ~/WeiDU-Linux/weidu --biff-get-list AMUL09.ITM
[/home/martin/WeiDU-Linux/weidu] WeiDU version 24700
[./chitin.key] 191 BIFFs, 62570 resources
ERROR: BIFF [./DATA/ITEMS.BIF] cannot be loaded: Unix.Unix_error(Unix.ENOENT, "stat", "./data/items.bif")
[AMUL09.ITM] --biff-get error: Unix.Unix_error(Unix.ENOENT, "stat", "./data/items.bif")

The file exists as ./data/Items.bif (with capital I); I can't rename the file as it will cause the game will segfault, although I can symlink it:

$ (cd data && ln -s Items.bif items.bif)

$ ~/WeiDU-Linux/weidu --biff-get-list AMUL09.ITM
[/home/martin/WeiDU-Linux/weidu] WeiDU version 24700
[./chitin.key] 191 BIFFs, 62570 resources
[./DATA/ITEMS.BIF] 801984 bytes, 2070 files, 0 tilesets
[./AMUL09.ITM] created from [./DATA/ITEMS.BIF]

The output of --list-biffs is always in full caps (and linking to ITEMS.BIFF doesn't work), so not sure for which other files this is an issue. Loading the file chitin.key with just a text editor it does list data/Items.bif, so somehow weidu isn't preserving this capitalisation doing an uppercase in the output, but a lowercase when loading, or something to this effect.

arp242 commented 3 years ago

To fix it for all files you can do something like for f in *.bif; do ln -s $f $(echo "$f" | tr '[:upper:]' '[:lower:]'); done btw.

suy commented 3 years ago

I've always thought that this kind of limitations are there "by design", or just too difficult to fix, hence the reason why the weidu package for Linux contains tolower and the like. I've always had to bend the file system to be case insensitive (via ciopfs or something like that).

arp242 commented 3 years ago

I don't know. I actually found out that WeiDu can't do what I wanted it to do and wrote some of my own tooling, and just using the filenames as they appear in the chitin.key seems to work fine. But this is just with BG1 & 2 EE on Linux, so I don't know about other games/variants/systems. I think Windows and macOS should be fairly easy as it's case-insensitive; I'd guess it's a legacy from "upper-case for stylistic reasons that worked just fine on Windows" (or, in the past all filenames were just upper-case).

FredrikLindgren commented 3 years ago

Case handling is a mess and I have no good solution for EE-type games. Cf. the remark about case-insensitive file systems.

jarnomikkola1 commented 1 month ago

Just use weidu's .tp2 commands: Either just: COPY_EXISTING ~AMUL09.ITM~ ~override~ Or if you have more ambision, just use the variable version: COPY_EXISTING ~*.itm$~ ~override~ etc, it will extract every item from the .bif's. You won't be able to extract the files from a .bif and make it unneeded. That's not how the game was programmed.

suy commented 1 month ago

Apologies, as sharing the link to this issue on Discord has brought Jarno into the conversation, which is never good. You rarely should trust what he says, as he tends to give advice that resembles what an LLM does (seems legit due to the use of jargon, but makes no sense).

Here is some example of why the above advice is not useful:

$ cat clueless/setup-clueless.tp2 
BACKUP "weidu_external/backup/clueless"
AUTHOR "JarnoGPT"
AUTO_EVAL_STRINGS

BEGIN "Test case" DESIGNATED 100
COPY_EXISTING ~AMUL09.ITM~ ~override~
$ weinstall clueless
weidu --log "setup-clueless.debug" "clueless/setup-clueless.tp2"
[weidu] WeiDU version 24900

ERROR: Unable to find DIALOG.TLK in:
        ./^dialog/.tlk$

Please run this program in your Infinity Engine game directory.

FATAL ERROR: Failure("Unable to find DIALOG.TLK")

Running that on a case insensitive file system works:

$ weinstall clueless/
weidu --log "setup-clueless.debug" "clueless/setup-clueless.tp2"
[weidu] WeiDU version 24900

Please choose the language in which you wish to play the game.
If you later wish to play the game in a different language you will need to edit the file weidu.conf and reinstall your mods.
 0 [Czech]
 1 [German]
 2 [English]
 3 [Spanish]
 4 [French]
 5 [hu_hu]
 6 [Italian]
 7 [Japanese]
 8 [Korean]
 9 [Polish]
10 [Portuguese]
11 [Russian]
12 [Turkish]
13 [Ukrainian]
14 [Simplified Chinese]
2

Using ./lang/en_us/dialog.tlk

Install Component [Test case]?
[I]nstall, or [N]ot Install or [Q]uit? i

Installing [Test case]
Copying 1 file ...

SUCCESSFULLY INSTALLED      Test case

Press ENTER to exit.
$ ls override/
amul09.itm