Jump to content

Installing SCS on BG2EE Linux


vtazt

Recommended Posts

Now the final problem: running tolower causes the game to crash. This isn't mod-related per se. When I take a fresh unmodded bg2 install, run tolower on the game directory, make a trivial edit to start.sh lowercasing the executable to baldursgateii, then run start.sh, the result is:

 

$ ./start.sh
INFO: scanning:(7) /home/me/usr/stow/bg2ee/game/lang/en_US/movies
support/gog_com.shlib: line 94: 25529 Segmentation fault      (core dumped) ./"${bin_64}"
I gdb'd the core but that's not very helpful because there aren't any symbols included.

 

I can guess at a potential solution, but it'll require a small tool. I record every filename in the original install in its original case, and after installing SCS I restore the original casing. Do you think that'll work?

 

But is it really the case that nobody has tried SCS with BG2EE Linux until now?

 

Many people use Fixpack and SCS on Linux. The problem you see is not mod related as you said.

 

There are many "hardcoded" filenames in baldursgateii executable. The devs probably didn't think someone would try to run the game without the files being present and didn't code checks for them, so the executable tries to read from a file that wasn't opened and crashes.

 

a)

One directory that is being accessed using mixed-case is the language directory (eg en_US). Since you ran tolower, en_US doesn't exist and cannot be opened, so the game crashes with the following message:

INFO: LUA: UI string not found: Recent events text will go here.
INFO: LUA: Initializing Quests
zsh: segmentation fault  ./baldursgateii
This can be very easily fixed by a simple symlink.

 

% cd /tmp/bg2ee-v2.3.67.2

% ls lang 
de_de/  en_us/  es_es/  it_it/

% ln -snf en_us lang/en_US
% ls lang 
de_de/  en_us/  en_US@  es_es/  it_it/
b)

The other problem is the files that are mentioned in chitin.key. If you open chitin.key in a hex editor, you will read some files being mentioned in uppercase and others in mixed case (for example Patch2.Bif). This cannot be opened because the file is named patch2.bif due to tolower.

 

I asked Wisp in the thread given by agb1 if weidu can be changed to only use lowercase for files written in chitin.key but it is not so easy to be implemented. A workaround i use is to change every file in chitin.key to have lower case filenames. Because the file uses a structure you cannot lowercase every character of it, so i wrote a stupid c program that only lowercases what is necessary. You can get it here until there is a proper solution.

 

% cd /tmp/bg2ee-v2.3.67.2
% wget -O chitinlcase.c http://pastebin.com/raw/WDnp5sTr
Saving to: chitinlcase.c

% gcc -o chitinlcase chitinlcase.c  

% cp chitin.key chitin.key.bg2ee

% chitinlcase chitin.key
Processing chitin chitin.key - chitin.key
Found 187 BIF entries
Found 62160 resource entries
After that, chitin.key will reference files only using lowercase and the game will work correctly without causing segmentation fault. The only "problem" is you will have to rerun chitinlcase after some major mods (for example bg2tweaks / tweaks anthology).

 

Try it and tell me if you have any questions

Link to comment

@khelban12 I never ever understand why all linux BG players don't just create one extra partition with case-insensitive file system :undecided: Then, all those problems are gone. right?

Yes every problem will be gone but again it is a half-measure. Also, i don't think there is any case insensitive filesystem. One would have to use fat32/ntfs.

 

There was an older fuse-based "filesystem" that was more of an overlay/wrapper and permitted you to access a directory without case sensitivity. You would "mount" a directory to a new mount point and then run weidu and the game from that mount point. I don't remember why i abandoned it but it was nice and didn't need a dedicated partition just for 2-3 games.

 

Edit: I found it. It is called "ciopfs" and it should exist in every major distribution's package repository.

 

% cd /tmp/bg2ee
% md5sum BaldursGateII 
bbf2758d783a11d4a85e4cbf20a31745  BaldursGateII

% tolower           
% md5sum BaldursGateII
md5sum: BaldursGateII: No such file or directory
% md5sum baldursgateii 
bbf2758d783a11d4a85e4cbf20a31745  baldursgateii

% mkdir /tmp/case-ins 
% ciopfs /tmp/bg2ee /tmp/case-ins 
% df |grep cas
ciopfs               5242880    535656   4707224  11% /tmp/case-ins

% cd /tmp/case-ins 
% md5sum BaldursGateII
bbf2758d783a11d4a85e4cbf20a31745  BaldursGateII
% md5sum BaldursGateii
bbf2758d783a11d4a85e4cbf20a31745  BaldursGateii
% md5sum baldursgateii 
bbf2758d783a11d4a85e4cbf20a31745  baldursgateii

% cd ..  
% umount case-ins 
This is the easiest / more newbie-friedly way. The only requirements are that a) nothing accesses the files from the original directory and only from the mount point, b) the original files must have lowercase names (which they will have because we run tolower).
Link to comment

It's not half-measure because the problem is gone. Without spending 3 days for reinventing the wheel. Look here: http://forums.pocketplane.net/index.php/topic,29259.msg337421.html#msg337421 and notice "This is the shortest and less painful workaround." :wavey:

 

 

@khelban12 I never ever understand why all linux BG players don't just create one extra partition with case-insensitive file system :undecided: Then, all those problems are gone. right?


Yes every problem will be gone but again it is a half-measure. Also, i don't think there is any case insensitive filesystem. One would have to use fat32/ntfs.

There was an older fuse-based "filesystem" that was more of an overlay/wrapper and permitted you to access a directory without case sensitivity. You would "mount" a directory to a new mount point and then run weidu and the game from that mount point. I don't remember why i abandoned it but it was nice and didn't need a dedicated partition just for 2-3 games.

 

There is. If NTFS has option to do oposite (enable case sensitive) then linux filesystems could also disable case sensitive. Or just use NTFS.

Link to comment

Yes, ciopfs is the "right" solution here, thanks. With the last step of invoking start.sh from the case-insensitive directory, it looks like everything is working now. My weidu.log shows some installed mods, though I haven't formally checked for them in-game yet.

 

I edited my previous post to show which files need dos2unix.

 

Thanks so much to everyone for the help. No more stupid enemy mages for me!

 

P.S. I had already written tolower and untolower just because they are fun to write. I'll leave them here in case some future googler is looking for them. The bash version of untolower in one of the links given above looks wrong because it doesn't reverse the order. If you do A*B then undoing that is B^(-1)*A^(-1). In simple cases it's commutative but not in general.

 

tolower:

#!/usr/bin/env ruby

require 'find'
require 'fileutils'

RECORD_FILENAME = ENV["HOME"] + "/.tolower"

def another_pass record
  acted = false
  Find.find "." do |path|
    new_path = path.downcase
    unless path == new_path
      FileUtils.mv path, new_path
      record.puts path, new_path
      acted = true
    end
  end
  return acted
end

File.open RECORD_FILENAME, "w" do |record|
  # We must re-walk the tree after renaming a directory.
  while another_pass record
  end
end
untolower:

#!/usr/bin/env ruby

require 'fileutils'

RECORD_FILENAME = ENV["HOME"] + "/.tolower"

File.open RECORD_FILENAME do |record|
  record.readlines.reverse.map(&:chomp).each_slice 2 do |lower, orig|
    FileUtils.mv lower, orig
  end
end
I checked that this works correctly by verifying that the original 'find' output and the 'find' output after running tolower/untolower are identical.
Link to comment

One last issue: setup-stratagems_autoinstall.tp2 fails because it's looking for a setup-stratagems executable that isn't there. I ran 'find' to be sure. The OSX download has it but the Linux download doesn't. The Windows download is an exe so I didn't check.

Link to comment

I didn't think I needed autoinstall. It would appear its purpose is to make installation more convenient, allowing whole groups to be selected. It takes quite a long time waiting for components to install while pressing "i" each time one is completed.

 

I only mentioned it because the missing file on Linux looks like a simple mistake that somebody might wish to correct. If devs want to remove autoinstall then just remove it; don't include a broken version.

Link to comment

Technically, kreso is maintaining an active branch of SCS and I can certainly add a BWS Fixpack patch for this too.

BWS being a very important part of what's said... though you left it out. And subtledoctor won't be using it as he "can't" on his OS.
Link to comment

To summarize this thread, given the current releases this bash script will install SCS for Linux BG2EE.

## config

SCS=~/Downloads/lin-stratagems-v30.zip
BIG_WORLD=~/Downloads/BiG-World-Fixpack-master.zip
BG_DIR=~/usr/bg2ee
CASE_INSENSITIVE_BG_DIR=~/usr/ci-bg2ee
WEIDU_DIR=~/usr/weidu
PLATFORM=amd64 # or i386

## vars

BIG_WORLD_DIR=`basename $BIG_WORLD .zip`
GAME_DIR="$BG_DIR/game"
WEIDU="$WEIDU_DIR/bin/$PLATFORM/weidu"

## check tools

set -ex
"$WEIDU" --version
dos2unix --version
ciopfs --version
unzip -v

## run

cd "$GAME_DIR"

# unzip has no --strip-components; rm containing dir manually
unzip "$BIG_WORLD"
cd "$BIG_WORLD_DIR"
mv * ..
cd ..
rm -f "$BIG_WORLD_DIR/.gitattributes"
rmdir "$BIG_WORLD_DIR"

unzip "$SCS"

# weidu's tolower chokes on filenames with spaces
echo "Running tolower..."
find . -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;

cd stratagems

dos2unix ./tactical_bg1/c2end.tpa
dos2unix ./tactical_bg1/demoncult.tpa
dos2unix ./genai/genai.tpa
dos2unix ./lib/install.tph
dos2unix ./lib/stratagems_shared.tph
dos2unix ./lib/always.tph
dos2unix ./caster_shared/caster_shared.tph
dos2unix ./gameplay/npc_proficiencies.tpa
dos2unix ./gameplay/npc_separate.tpa
dos2unix ./gameplay/wk_early.tpa
dos2unix ./setup-stratagems_autoinstall.tp2
dos2unix ./initial/initial.tpa
dos2unix ./tactical_bg2/spawn.tpa
dos2unix ./sfo/install_sfo.tpa
dos2unix ./sfo/general/lib_macro.tpa
dos2unix ./sfo/general/lib_iterate.tpa
dos2unix ./spell/ironskins.tpa
dos2unix ./sarevok/sarevok.tpa
dos2unix ./setup-stratagems.tp2
dos2unix ./werewolf/werewolf.tpa
dos2unix ./item/elemental_arrows.tpa
dos2unix ./item/dispelling_arrows.tpa
dos2unix ./help/baf/shout.baf

cd ..
"$WEIDU" --log big.log _applypatches.tp2
"$WEIDU" --log scs.log stratagems/setup-stratagems.tp2

cd ..
echo "Creating the case-insensitive mount point..."
mkdir -p "$CASE_INSENSITIVE_BG_DIR"
ciopfs "$BG_DIR" "$CASE_INSENSITIVE_BG_DIR"

echo "Success! Launch the game with '$CASE_INSENSITIVE_BG_DIR/start.sh'"
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...