Installing NWN on Linux

Moderator: Event DM

User avatar
Nighthawk4
Assist DM
Assist DM
Posts: 25898
Joined: Fri Feb 07, 2003 8:32 pm
Timezone: GMT
DM Avatar: DruEl
Location: The Home of the Bard of Avon
Contact:

Re: Installing NWN on Linux

Post by Nighthawk4 » Mon Oct 22, 2012 8:56 pm

It seems Linux now does not like USB devices on my laptop. I unplugged the USB mouse and it booted into Ubuntu. Never had any problems before on the laptop, even with Linux. Odd X:|

Unfortunately, the Wireless Connection does not work. I edited the settings and created a Wireless Connection and added the SSID and password, but it still doesn't connect. Still working on that. Didn't have any problem with that on PCLinuxOS either. It seems Ubuntu is not quite as wonderful and user-friendly as advertised :wink:
Life is never as bad as you think it is, although that doesn't help at the time.
Orleron wrote:I think it's a fun idea if you can idiot-proof it. Problem is God always builds a better idiot. :P
User avatar
Faeldridge
Scholar of Fools
Posts: 452
Joined: Tue May 24, 2005 11:47 pm
Contact:

Re: Installing NWN on Linux

Post by Faeldridge » Tue Oct 23, 2012 9:47 pm

What kind of wireless chip is it? Some of the odd ones (like broadcom or nvidia chips) require some linux firmware to run properly. It is just another package to install, basically, if it is required. Sounds worse than it is.
User avatar
Nighthawk4
Assist DM
Assist DM
Posts: 25898
Joined: Fri Feb 07, 2003 8:32 pm
Timezone: GMT
DM Avatar: DruEl
Location: The Home of the Bard of Avon
Contact:

Re: Installing NWN on Linux

Post by Nighthawk4 » Tue Oct 23, 2012 10:48 pm

Think it is this - Broadcom 802.11g BCM4318

I seem to recall using ndiswrapper before, but that was with PCLinuxOS long ago X:|
Life is never as bad as you think it is, although that doesn't help at the time.
Orleron wrote:I think it's a fun idea if you can idiot-proof it. Problem is God always builds a better idiot. :P
User avatar
S_N
Team Member; Retired with Honors
Posts: 452
Joined: Tue Feb 09, 2010 3:21 pm
Timezone: UTC+1
DM Avatar: Ingoren
Location: Scandinavia

Re: Installing NWN on Linux

Post by S_N » Sat Oct 27, 2012 8:04 pm

Linux tweaks? Well, that prompted me to clean up my nwn startup script, and it's got a log rotator even if you don't use any of the plugins.
Everything after a # is a comment, and if you look trough it, you can see some commented stuff I only use when testing freshly compiled drivers.

It might be a bit daunting if you are new to bash scripts, or not at all. Let me know which it is, and I'll tailor the explanation. :-)

Code: Select all

#!/bin/bash
# This script runs Neverwinter Nights from the current directory

#### This is afaik lecacy junk ####
#export SDL_VIDEO_X11_DGAMOUSE=0
###################################

#### Sound variables for SDL ######
#export SDL_AUDIODRIVER=alsa
export SDL_AUDIODRIVER=pulse
###################################

#### nwmouse.so specific ##########
export SDL_MOUSE_RELATIVE=0
export XCURSOR_PATH=`pwd`
export XCURSOR_THEME=nwmouse
###################################

#### Plugins to use ###############
#PLUGINS="nwmouse.so:vidmode.so:noshader.so" 
PLUGINS="nwmouse.so:vidmode.so"
###################################

#### Paths where to find stuff ####
#export DRIVER=/opt/projects/mesa/lib  # Testing drivers.
#export LD_LIBRARY_PATH=./miles:$DRIVER:$LD_LIBRARY_PATH  # Testing drivers
export LD_LIBRARY_PATH=./miles:$LD_LIBRARY_PATH # 
###################################

#### Date log rotator, part 1 #####
rm logs/nwclientLog*  # Temp. logs
touch logs/nwclientLog{1,2,3,4}.txt
###################################

#### Starting NWN #################
LD_PRELOAD=$PLUGINS force_s3tc_enable=true ./nwmain $@ &
#INTEL_HIZ=0 LIBGL_DRIVERS_PATH=$DRIVER LD_PRELOAD=$PLUGINS force_s3tc_enable=true ./nwmain $@ &
###################################

#### Date log rotator, part 2 #####
sleep 2  # Allow nwmain to start.
tail --pid=$(pidof nwmain) -f -q logs/nwclientLog{1,2,3,4}.txt | python logparse.py >> logs/$(date +%Y-%m-%d).log&
###################################
Basically, what's not included is
logparse.py A python script that prettifies the log output to my liking.

nwmouse.so Using a hardware accelerated mouse pointer was necessary to avoid lag at one point of time. http://home.roadrunner.com/~nwmovies/nwmouse/ for details. I suspect the computers are responsive enough to do the software pointers now, but it's still a nice addition.

noshader.so This started as a hack by me to disable shaders, and then David Greaves improved on it. I don't think it's needed anymore, but Intel drivers has(had?) a tendency to make stuff metallic without it.

vidmode.so This is my own, use-any-resolution, in windowed mode. Want to stretch it over two or more screen? Should work. (Don't remember who tested this) My preferred resolution at the moment is apparently 1202x1200.

There is also a plugin to get the in-game video for single player working, but I could never compile it correctly.
User avatar
S_N
Team Member; Retired with Honors
Posts: 452
Joined: Tue Feb 09, 2010 3:21 pm
Timezone: UTC+1
DM Avatar: Ingoren
Location: Scandinavia

Re: Installing NWN on Linux

Post by S_N » Sat Oct 27, 2012 8:28 pm

This is videomodes.c source to build vidmode.so plugin/hack to NWN.

Code: Select all

/* 
 * Linux LD_PRELOAD wrapper for Neverwinter Nights
 *
 * Allows custom windowsize of nwn when running in windowed mode.
 * Use at own risk, written by Joel Forsberg. Permission to spread
 * or modify as per GPLv3 or later. (as if anybody care about such a 
 * hack as this =)
 *
 * Contact email joelfo@kth.se or via nwn forums (SubspaceJeol).
 *
 * To compile: 
 *   gcc --shared  videomodes.c -lSDL $(pkg-config --cflags --libs glib-2.0) -o vidmode.so
 *
 * To use:
 *   Place the restulting vidmode.so in the same directory as nwmain,
 *   then modify how you call nwmain inside your script to use it with LD_PRELOAD.
 *
 *   Here's an example using both nwmouse and vidmode:
 *   LD_PRELOAD=nwmouse.so:vidmode.so ./nwmain $@
 *
 *   Then lastly, setup nwn.ini under the section Display Options so that:
 *   Fullscreen = 0
 *   AllowWindowedMode = 1
 *   Then modify the values for Heigt and Width to your liking, 1204 x 721 for instance.
 *
 * More info:
 *   Neverwinter night will not accept any resolution more narrow than 600 in heght,
 *   and going below 800 in width is possible, but will cause clipping of the GUI of 
 *   the game
 */

#define _GNU_SOURCE
#include <SDL/SDL.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <glib.h>


static SDL_Rect mymode;
static int windowmode = 0;

SDL_Rect** SDL_ListModes(SDL_PixelFormat* fmt, Uint32 flags) {
    void configparse(void);

    SDL_Rect** modes;
    static int firstrun = 1;

    if (firstrun == 1) {
        configparse();
        firstrun = 0;
    }

    mymode.x=0;
    mymode.y=0;

    static void * (*hooked_SDL_ListModes)();
    int i=0; // Override the first, setting any other relies on list being longer.

    hooked_SDL_ListModes = (void *(*)()) dlsym(RTLD_NEXT, "SDL_ListModes");

    if (!hooked_SDL_ListModes) {
        fprintf(stderr,"Whoops, this will not work at all. Exiting. \n");
        exit(1);
    }

    struct SDL_Rect* myptr;

    modes = hooked_SDL_ListModes(fmt, flags);
    if ((int) modes == -1 && windowmode == 1) {} 
    else {
        myptr = modes[i];
        myptr->h=mymode.h;
        myptr->w=mymode.w;
    }
    return modes;
}

void configparse()
 {
     int fullscreen, windowed;

  GKeyFile *keyfile;
  GKeyFileFlags flags;
  GError *error = NULL;
  gsize length;
  
  /* From tutorial */
  keyfile = g_key_file_new ();
  flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS ;
  
  if (!g_key_file_load_from_file (keyfile, "nwn.ini", flags, &error))
  {
    g_error (error->message);
    return;
  }
  
  /* Read in data */
  fullscreen = g_key_file_get_integer (keyfile, "Display Options", "Fullscreen", NULL);
  windowed   = g_key_file_get_integer (keyfile, "Display Options", "AllowWindowedMode", NULL);
  if (fullscreen == 0 && windowed == 1) {
      mymode.h = g_key_file_get_integer (keyfile, "Display Options", "Height", NULL);
      mymode.w = g_key_file_get_integer (keyfile, "Display Options", "Width", NULL);
      fprintf(stderr,"Vidmode active, and parsed: FS:%d WM:%d x:%d y:%d \n", fullscreen, windowed, mymode.w ,mymode.h);
      windowmode = 1;
  }
  return;
}
I even attempted to make a build script to it, but it's just two lines that compile the .so. I think the first is using a 64-bit build host. Note: you might need to install additional development packages to compile this.

Code: Select all

gcc -m32  --shared  videomodes.c -lSDL `pkg-config --cflags --libs glib-2.0` -o vidmode.so
gcc --shared  videomodes.c -lSDL $(pkg-config --cflags --libs glib-2.0) -o vidmode.so
User avatar
S_N
Team Member; Retired with Honors
Posts: 452
Joined: Tue Feb 09, 2010 3:21 pm
Timezone: UTC+1
DM Avatar: Ingoren
Location: Scandinavia

Re: Installing NWN on Linux

Post by S_N » Mon Oct 29, 2012 9:26 pm

For instant master server timeouts, add this line to your /etc/hosts

Code: Select all

0.0.0.1         nwmaster.bioware.com
The tip was originally for windows, setting it to 0.0.0.0, but that is a valid address on *nix (and guessing MacOS X too)

(a suitable iptables rule works too)
User avatar
Faeldridge
Scholar of Fools
Posts: 452
Joined: Tue May 24, 2005 11:47 pm
Contact:

Re: Installing NWN on Linux

Post by Faeldridge » Tue Oct 30, 2012 2:18 pm

S_N wrote:For instant master server timeouts, add this line to your /etc/hosts

Code: Select all

0.0.0.1         nwmaster.bioware.com
The tip was originally for windows, setting it to 0.0.0.0, but that is a valid address on *nix (and guessing MacOS X too)

(a suitable iptables rule works too)
What a great idea!, now I don't have to hack the Bioware DNS server :wink:
User avatar
Anomandari
Roleplayer of the Year 2011
Posts: 1891
Joined: Thu May 03, 2007 6:54 pm
Timezone: GMT+1/+2
Location: Warsaw

Re: Installing NWN on Linux

Post by Anomandari » Tue Apr 09, 2019 9:31 pm

*Casts Animate Dead on the thread.*


Since I drafted the following quick write-up as a PM already, I may as well leave it here.

If you have an old Linux NWN client backed up somewhere - like me - and don't want to start with a brand new shiny GOG version which comes with the NWN: EE these days - like me - and have little clue about how things work there - like me - maybe I'll save you some time.

I've returned to Avlis from a long hiatus recently, first by getting a backed up version of the client to work on an old laptop where it used to reside (after a couple of system upgrades), and then by moving the client from said laptop to a new Linux Mint machine. I had to do some tinkering to get it to work.

First: since I had a backed-up version of my old game client, with my old CD keys and all the log files of each and every game session stored neatly in the log directory, I didn't want to buy and download a GOG version outright. The GOG version has a a dedicated "walkthrough" for linux machines: https://wiki.dotslashplay.it/en/games/n ... ter-nights. The upside of the GOG version being that you get it with a NWN EE purchase. The downside being that you have to pay for the NWN EE purchase - not exactly a must for me if/until Avlis and the rest of CoPaP go all EE.

Once I've fixed the owner status of the files with CHUSER and made the relevant ones executable with CHMOD, my only problem was with the libraries required by the Linux client for the game to work. Back in the day it used to run just out of the box. Today we're all 64-bit and things are different.

Fortunately, all the required libraries are still out there in the official repositories - and you can easily check which ones are they by executing the LDD command from the linux client's main executable's directory:

Code: Select all

mm@sys:~/Neverwinter/old$ ldd nwmain
	linux-gate.so.1 (0xf7f5c000)
	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7e2e000)
	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7e0e000)
	libGL.so.1 => /usr/lib/i386-linux-gnu/libGL.so.1 (0xf7da6000)
	libGLU.so.1 => /usr/lib/i386-linux-gnu/libGLU.so.1 (0xf7d26000)
	libmss.so.6 => not found
	libSDL-1.2.so.0 => /usr/lib/i386-linux-gnu/libSDL-1.2.so.0 (0xf7c7e000)
	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7a9e000)
	/lib/ld-linux.so.2 (0xf7f5e000)
	libGLX.so.0 => /usr/lib/i386-linux-gnu/libGLX.so.0 (0xf7a76000)
	libGLdispatch.so.0 => /usr/lib/i386-linux-gnu/libGLdispatch.so.0 (0xf7a16000)
	libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf788e000)
	libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf786e000)
	libasound.so.2 => /usr/lib/i386-linux-gnu/libasound.so.2 (0xf7746000)
	libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf773e000)
	libpulse-simple.so.0 => /usr/lib/i386-linux-gnu/libpulse-simple.so.0 (0xf7736000)
	libpulse.so.0 => /usr/lib/i386-linux-gnu/libpulse.so.0 (0xf76d6000)
	libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xf7586000)
	libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xf756e000)
	libcaca.so.0 => /usr/lib/i386-linux-gnu/libcaca.so.0 (0xf749e000)
	librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf748e000)
	libpulsecommon-11.1.so => /usr/lib/i386-linux-gnu/pulseaudio/libpulsecommon-11.1.so (0xf73fe000)
	libdbus-1.so.3 => /lib/i386-linux-gnu/libdbus-1.so.3 (0xf739e000)
	libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xf736e000)
	libslang.so.2 => /lib/i386-linux-gnu/libslang.so.2 (0xf718e000)
	libncursesw.so.5 => /lib/i386-linux-gnu/libncursesw.so.5 (0xf7156000)
	libtinfo.so.5 => /lib/i386-linux-gnu/libtinfo.so.5 (0xf712e000)
	libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xf710e000)
	libsystemd.so.0 => /lib/i386-linux-gnu/libsystemd.so.0 (0xf707e000)
	libwrap.so.0 => /lib/i386-linux-gnu/libwrap.so.0 (0xf706e000)
	libsndfile.so.1 => /usr/lib/i386-linux-gnu/libsndfile.so.1 (0xf6fde000)
	libasyncns.so.0 => /usr/lib/i386-linux-gnu/libasyncns.so.0 (0xf6fd6000)
	libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xf6fce000)
	libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xf6fc6000)
	liblzma.so.5 => /lib/i386-linux-gnu/liblzma.so.5 (0xf6f96000)
	liblz4.so.1 => /usr/lib/i386-linux-gnu/liblz4.so.1 (0xf6f7e000)
	libgcrypt.so.20 => /lib/i386-linux-gnu/libgcrypt.so.20 (0xf6e96000)
	libnsl.so.1 => /lib/i386-linux-gnu/libnsl.so.1 (0xf6e76000)
	libFLAC.so.8 => /usr/lib/i386-linux-gnu/libFLAC.so.8 (0xf6e16000)
	libogg.so.0 => /usr/lib/i386-linux-gnu/libogg.so.0 (0xf6e06000)
	libvorbis.so.0 => /usr/lib/i386-linux-gnu/libvorbis.so.0 (0xf6dd6000)
	libvorbisenc.so.2 => /usr/lib/i386-linux-gnu/libvorbisenc.so.2 (0xf6d46000)
	libresolv.so.2 => /lib/i386-linux-gnu/libresolv.so.2 (0xf6d2e000)
	libbsd.so.0 => /lib/i386-linux-gnu/libbsd.so.0 (0xf6d0e000)
	libgpg-error.so.0 => /lib/i386-linux-gnu/libgpg-error.so.0 (0xf6cf6000)
If a library is missing, the command's output will tell you which one it is, and it's a single google search away to identify the packages you have to install. They all seem to be 32-bit versions you have to install on top of anything you may already have on your machine.

Since on a modern 64-bit system 32-bit libraries seem to reside in a different directory than the usual ones (in my instance it's /lib/i386-linux-gnu/), I had to fiddle with my NWN launch sequence a bit to find out how to get everything to work.

The way I managed to get it to work back in 2007...? 2008...?, it was with two files: "nwn.sh" and "nwn".
Yup, I sure could consolidate them into a single file, but I don't fix what's not yet broken.
Most importantly, I had to add a reference to the current directory for all the required libraries, and now the launch sequence looks like the following:

For ./nwn.sh:

Code: Select all

#!/bin/bash
LD_PRELOAD=no_nvvp.so:vidmode.so ./nwn
#EOF
For ./nwn:

Code: Select all

#!/bin/sh

# This script runs Neverwinter Nights from the current directory

export SDL_MOUSE_RELATIVE=0
export SDL_VIDEO_X11_DGAMOUSE=0

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/i386-linux-gnu/:./miles
export LD_LIBRARY_PATH

./nwmain $@
cat logs/nwclientLog1.txt >> logs/$(date +%Y-%m-%d).log
The LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/i386-linux-gnu/:./miles line followed by export LD_LIBRARY_PATH tells the client to go look for libraries to the /usr/lib/i386-linux-gnu/ directory as well as the miles directory where the NWN client resides (it contains some libraries, too). There's also a lib directory there, but it contained some outdated libraries which I have replaced by a current version from the repositories.
IRC #Avlis: Autumn. Player of: Null, a cannibal · Salamander, a sapper · Dust, a pilgrim.
· · · · ·
Ninjar: F* it dude, let's go crafting.
Post Reply