Migrating server to Neverwinter EE

Hi all,

I don’t know if there is any tutorial/help for the migration of a server to the Enhanced Edition but I found nothing. The lack of information is somewhat frustrating so I decided to share what I’ve already found just to help other people in the same situation.

(I’m Spanish, so please excuse my poor english)

Old server:

  • My good old server is running in a computer with Ubuntu 64 bits
  • NWNX plugins: chat, area, funcs, structs, weapon…
  • Chroot installed for the compilation of the NWNX plugins (32 bits)
  • Aurora toolset: I have a MacBook, so I’m running the toolset in a Parallels virtual machine (Windows XP)

New server, first decisions:

Since I want to first test the server on my laptop and then move it to the old PC, I decided to install it on a virtual machine: VMWare workstation (free on linux) So I can easily copy the machine from my Mac to my linux computer.

For the virtual machine I’ve installed Ubuntu Xenial (16.04 LTS) 32 bits, so less problems with the compilation of the new NWNX which is still 32 bits.

Aurora toolset:

The toolset of the EE, developed in Borland C++ if I remember well, it can only be run in windows and Beamdog is not planning to offer a new version for Linux or Mac. Then I will need another virtual machine. The questions are: ¿Windows 7? ¿Windows 10? ¿Parallels? ¿Vmware?

The choice between Parallels and VMWare is easy: OpenGL is very limited in Parallels, it only supports OpenGL 2.0. I tried to run the toolset on windows 7 and windows 10, and it crashes every time I tried to open an area.

So now I have a VMware virtual machine with Windows 10. However, there is still a big bug with the toolset: I can’t see the textures of the terrain :frowning: I don’t know yet if this is due to the haks, anyway… Now I’m focussed on the scripts migration and I’ve checked that the textures are shown when I load the module on my Mac client, I hope this bug will disappear in future versions of the toolset (or the VMWare player)

PS: I don’t have a lot of free time these days but the next post will be about the server install and the NWNX compilation.

3 Likes

Ok, so let’s start with server installation. I’m currently using the zip file you can found at: https://forums.beamdog.com/discussion/67157/server-download-packages-and-docker-support

It’s a 25MB zip with all the required files for running your server. You only have to uncompress it in your home directory, in my case in ~/server. Note that the server will use the files locate in the default directory ~/.local/share/Neverwinter Nights/ where the nwnplayer.ini file can be found with the server configuration.

The server can be started with the following command
~/server/bin/linux-x86/nwserver-linux -module “YourModuleName”

The module “YourModuleName.mod” must be located in the directory ~/.local/share/Neverwinter Nights/modules.

And next: NWNX

2 Likes

NWNX can be downloaded from here: https://github.com/nwnxee/unified . First install the git package on your linux server and then to clone the repository just type:

git clone https://github.com/nwnxee/unified.git

If your linux is the 32 bit version the compilation of NWNX is quite easy but it requires the gcc-6 package. In the case of Ubuntu 16.04 you’ll have to add the untrusted “Toolchain test builds PPA”:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6 g++-6

The cmake package is also required, and if like in my case you want to use MySQL databases for your persistent world, install also the MySQL dev package:

sudo apt-get install cmake libmysqlclient-dev

Now go to the Build directory of your NWNX repo and:

cmake -DCMAKE_BUILD_TYPE=Release ../
make -j 8

After that the compiled binaries are located in the Binaries directory of the NWNX repo. Now copy the binaries of core and the plugins you want to use to the same directory where the nwserver-linux is. In my case I copied NWNX_Core.so (the NWNX core) and the plugins NWNX_SQL.so , NWNX_Chat.so and NWNX_Creature.so to ~/server/bin/linux-x86/

IMPORTANT: At the time I’m writing this post, the NWNX log file (to debug NWNX) is not configurable. You have to create the directory logs.0 where you copied the NWNX_Core.so. So when you start your server, NWNX will create a file named nwnx.txt in it with all the debug information. If this directory does not exist, you will see nothing… I spent hours trying to find the damned log file! :sweat:

The default location where the neverwinter server store the logs is defined at the beginning of the ~/.local/share/Neverwinter Nights/nwn.ini file, since I don’t want to check the logs in two different directories I changed it to the previously created NWNX logs.0 directory.

Now I will suppose you have already created a user and a MySQL database for your server. For example: a user named “nwn”, with password “nwnpass” and a database named “mydb”.

The configuration of NWNX is done by shell environment variables, there is no config file. In order to configure the MySQL database you have to EXPORT (bash shell) some variables. In my case I use a script, nwnstartup.sh, in the same directory of the server binary, similar to this one:

#!/bin/sh
umask 002

export LD_PRELOAD=./NWNX_Core.so
export NWNX_SQL_USERNAME=nwn
export NWNX_SQL_PASSWORD=nwnpass
export NWNX_SQL_DATABASE=mydb

./nwserver-linux \
-module "MyModule" \
-quiet \
"$@"

If all is ok you will see the following:

Working Directory For Game Install Is: /home/nwn/server
Working Directory For Your Resources Is: /home/nwn/.local/share/Neverwinter Nights
Neverwinter Nights Server
Build:8162
Copyright BioWare Corp 1998-2004
Registering crash signal handlers.

Server: Loading...
I [20:49:48] NWNX_Core: Server is running version 8162.
I [20:49:48] NWNX_Core: Loading plugins from: .
I [20:49:48] NWNX_Core: Loaded plugin 0 (Chat) v1 by Liareth.
I [20:49:48] NWNX_Core: Loaded plugin 1 (Creature) v1 by various / sherincall.
I [20:49:48] NWNX_SQL: Connecting to type MYSQL
I [20:49:48] NWNX_SQL: Connection info:  host=localhost username=nwn
I [20:49:48] NWNX_Core: Loaded plugin 2 (SQL) v1 by Liareth.
Server: Running...

Server: Loading module "MyModule"...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Server: Module loaded
2 Likes

Once the NWNX SQL is correctly loaded the database scripts of the module must be rewritten with the new syntax.

We started the server 12 years ago. At the beginning the server was running on Windows XP so the easy option for the database was the use of SQLite. For the toolset scripts I used the Avilis Persistent System (APS)… Hélas, the new NWNX does not support SQLITE :sob:

So I’ve changed the functions of the APS include file with the new NWNX_SQL syntax that can be found here: https://github.com/nwnxee/unified/blob/master/Plugins/SQL/Documentation/Migration_Guide.md

The result is here: https://drive.google.com/open?id=1qTTvbNTFbxXAPMiIWv7EZAuXAezHw4DK

If you want to use this file you will need to also download the file nwnx.nss: https://github.com/nwnxee/unified/blob/master/Core/NWScript/nwnx.nss

Please note that:

  1. This file replaces the original aps_include file
  2. I have only changed a small portion of the original file (only the things I needed)
  3. All the credits go to the original author of the APS (and the NWNX team for the new portion of the code)
  4. If somebody change the rest of the original include it would be nice to share the result to this community :wink:

If the changes are correct, in nwn.txt log file you will see something like:

I [13:59:36] NWNX_Core: Server is running version 8162.
I [13:59:36] NWNX_Core: Loading plugins from: .
I [13:59:36] NWNX_Core: Loaded plugin 0 (Chat) v1 by Liareth.
I [13:59:36] NWNX_Core: Loaded plugin 1 (Creature) v1 by various / sherincall.
I [13:59:36] NWNX_SQL: Connecting to type MYSQL
I [13:59:36] NWNX_SQL: Connection info:  host=localhost username=nwn
I [13:59:36] NWNX_Core: Loaded plugin 2 (SQL) v1 by Liareth.
I [14:00:02] NWNX_SQL: Successful SQL query. Query ID: '1', Query: 'SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_DAY'', Results Count: '1'.
I [14:00:02] NWNX_SQL: Successful SQL query. Query ID: '2', Query: 'SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_MONTH'', Results Count: '1'.
I [14:00:02] NWNX_SQL: Successful SQL query. Query ID: '3', Query: 'SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_YEAR'', Results Count: '1'.
I [14:00:02] NWNX_SQL: Successful SQL query. Query ID: '4', Query: 'SELECT val FROM cnr WHERE player='~' AND tag='' AND name='CNR_MINING_SKILL_PCNAME'', Results Count: '0'.

In my case, the "on module load" script executes some SQL queries for the persistent “date” system of the module, these are the first queries that are displayed at the beginning of the log.

Once you have tested the SQL functions you can set the log level of the SQL plugin to display only warnings and errors adding this line to the nwnstartup.sh script:

export NWNX_SQL_LOG_LEVEL=4
3 Likes

Script g_i_dbsql.nss updated, the SQL WHERE clause where missing in the UPDATE :flushed:

2 Likes

Buenas Bhaal, podrías hacer el tutorial en español para los españoles? un abrazo!

@El_Vara ¿Has probado el Traductor de Google? No sé de inglés a español, pero de español a inglés parece funcionar muy bien en estos días. Como puede suponer, mi español no existe y esto fue realmente compuesto en Google Translate.

TR

Hi Bhaal, ¿que tal?

Ok, that’s my knowledge of Spanish exhausted as well as Tarot’s ( but at least I didn’t need Google . . .) :innocent:

I also know nothing of servers but I do know about Macs. Not sure if this is relevant but if you’re just looking for a way to use the Toolset on a Mac, probably the easiest is to use WINE which does away with the need for any virtual machines like those you mention. It works very well for me.

There is also a tutorial on YouTube to show how to install it.

@El_Vara este tutorial está obsoleto, es de marzo de 2018!!!

Ahora mismo si quieres usar nwnx lo más sencillo es usar docker, incluso en windows, está todo hecho. Nunca me he puesto con docker, pero hay gente que lo usa sin tener apenas conocimientos técnicos.

Un saludo

@jimdad55 My problems with the aurora toolset were 1 year ago but thank you :stuck_out_tongue: