Jump to content

Run a dedicated Nolf2 v1.4M server in linux


Spawn

Recommended Posts

I decided to run a couple of Nolf2 dedicated servers and this lead into a little tutorial about how it can be setup easily for anyone, even with limited knowledge of linux. Figured I'd post it here as well :)

Linux distro used: Linux Mint 20.3 Cinnamon v5.2.7
Linux Kernel: 5.4.0-107-generic
Winetricks version: 20220411
Wine version: 7.0

 

1) Install Wine

Wine is an open-source compatibility layer that allows you to run Windows applications on Unix-like operating systems such as Linux. I will be installing the latest stable version from winehq.org in this setup.

Open up a terminal

If your system is 64 bit, enable 32 bit architecture:

sudo dpkg --add-architecture i386

Download and add the repository key:

wget -nc https://dl.winehq.org/wine-builds/winehq.key

 

sudo mv winehq.key /usr/share/keyrings/winehq-archive.key

Add the repository:

wget -nc https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
sudo mv winehq-focal.sources /etc/apt/sources.list.d/

Update packages:

sudo apt update
sudo apt install --install-recommends winehq-stable

 

2) Install Winetricks

The normal install is either through the software manager or command line:

sudo apt-get install winetricks

Update it:

sudo winetricks --self-update

 

3) Setup a wine Prefix for Nolf2

Just to explain this concept so that people who aren't used to dealing with this will understand how it works, a few programs such as NOLFSrv.exe for Nolf1 will run out of the box without any extra dependencies. Other software like Nolf2Srv.exe needs extra windows components in order to function.  

I have my custom wine prefixes (also refered to as wine bottles) in a directory named Wine in my user's home directory.
Each program should have its own prefix, unless they are somewhat related and runs with the same dependencies.

So in a nutshell:
wine1.png

Here are 3 examples who have their own separate registry, dll files, "C:\ drive" and other windows components.
This is where Winetricks becomes relevant. You use this program to choose what extra components the program needs to function.

Let's create a wine prefix for Nolf2

From this point forward, you won't need sudo rights to configure the rest. This means that you can create a user with limited privileges who will run the game server.

Nolf2 is a win32 application, so we specify that with WINEARCH=win32, we also want to create the wine prefix, and last we put in the wine command that will create this prefix. I also prefer short names on folders when dealing with terminal, less to write and less problems with spaces. So I'll name my prefix folder nolf2 rather than No-One-Lives-Forever-A-Spy-In-Harms-Way.

WINEARCH=win32 WINEPREFIX=~/Wine/nolf2 winecfg


(~ is short for /home/<your username>)

After running this command, this window will eventually appear:

wine2.png

I'll choose Windows 7 here because I am not sure how the 2015 C++ redistributables will react to for example Windows XP.

You can then close the window.

To make Nolf2Srv run in wine, you'll need a couple of dependencies
Back in your terminal change the last word to winetricks

WINEPREFIX=~/Wine/nolf2 winetricks

This window will magically appear

winetricks1.png

Select the default wine prefix

winetricks2.png

And choose to install a windows dll or component

winetricks3.png


vb6run - should take care of the original code for the game[/td][/tr]
vcrun2015 - or newer should work just fine for the modernizer code
vcrun6 - I suspect that I needed this in order to pass arguments to NOLF2Srv


Install these and most likely ignore a lot of errors, if they don't install all at once, try installing them one by one.

When you're back to the main windows in winetricks, you click cancel to exit.

Tada, the prefix is ready!

 

4) Copy over Nolf2

When you go into Wine --> nolf2 (your wineprefix) you will find a bunch of newly created stuff
This folder named drive_c is now your C:\ drive

bottle1.png

In there you will also find some familiar windows component that has a minimum of what Nolf2Srv needs to function

bottle2.png

This is where I make another folder named nolf2, and copy the game (in preinstalled form) into it.

To finally test if the whole thing even runs, type this into your terminal

WINEPREFIX=~/Wine/nolf2 wine ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe

nolf2srv.png

If everything works, you should see this, you may or may not be able to choose a profile to load. I could never get the dropdown menu for profiles show up in linux. ERROR - Unable to load resources simply means that it cannot find your profiles.

To load the server with a flag/argument you will need to alter the command slightly

WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn

This will load a profile named spawn, just replace this name with your own profile name.

 

5) Create a new profile

NOTE: Make sure that lithtech.exe runs with admin privledges

In order for the profile to work with modernizer v1.4M, it is a good idea to create a new profile from scratch, select:

profile1.png

Create a new profile and type in a profile name, hit ok and back

profile1a.png

Next step is to start a new server by clicking Multiplayer (internet),
then select the game type you want to host.

Select Host, and this screen appears

profile3.png

Click Campaign and create a new campaign

profile4.png

The name here can be anything, this is not the one you pass on to the server later
Next up is map selection, this explains itself pretty well.

profile5.png

Next you should set a network port and forward this port and the next one in your firewall.
In this case port:27892 and port:27893

Make sure Dedicated Server is set to Yes
and finally click Launch

profile6.png

This will create everything you need in your game folder in order to run dedicated with the stand alone NOLF2Srv.exe

 

6) Copy profile over to the linux server

Open your Profiles folder on the computer you used to configure your game server and copy your <profile.txt> and the folder with the same name over to the Profiles folder on the server.

Also make sure that your DMMissions.txt and DDMissions.txt from the game folder are the same as the ones you have on the computer where you configured the game server.

profile_spawn.png

Let's start this thing:

WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn

server_running.png

If the Running time counter starts to run, it should work  ?

 


7) Keep it alive

Nolf2 servers tend to crash from time to time, so a auto restart function could be a good idea.

My initial plan was to have Crontab running a check every minute to see if the server was alive or not, but Wine doesn't seem to be friends with Crontab. This is why I ended up creating a launcher that starts the server + a script that will guard it.

First of all, you would want to shut down any display of error messages after a crash, this will prevent the script from restarting Nolf2srv.exe. Launch Winetricks:

WINEPREFIX=~/Wine/nolf2 winetricks

Select the default wineprefix

winetricks1.png

This time choose "Change settings"

winetricks4.png

Then disable the crash dialog by selecting nocrashdialog

winetricks5.png

 

Open up your favorite text editor and copy/paste this:

#!/bin/bash
	while :
do
	(/bin/ps aux | /bin/grep -v 'grep' | /bin/grep 'nolf2srv' 2>&1 >/dev/null || WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn)
	sleep 60
done

 

You'll need to change profile and path to your likings.

This little script will search for the process nolf2srv and execute the start server command if the process doesn't exist. This function is packed into a while loop that will run every 60 seconds and will go on forever.

I saved it as nolf2dm.sh in my Wine folder and made it executable.

chmod +x ~/Wine/nolf2dm.sh

or go into the file's properties -> Permissions and check Executable : Allow executing file as program

executable.png

 

You can now start the server and script by command

sh ~/Wine/nolf2dm.sh

If you prefer a clickable button on your desktop, this can be done by right clicking the desktop and creating a new launcher with the command:

/home/<your username>/Wine/nolf2dm.sh

The launcher needs full path, ~ won't work here.

 

That should be it :)

 

 

 

Link to comment
Share on other sites

Nice work. 

Something I never got around to playing with. 

I've run servers for other games on linux though. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Guidelines Privacy Policy.