Linux Tethealla Server

Theodis

Member
I've wanted to be able to run the Tethealla server on Linux since I found it many years ago. At the time I did manage to get it working with a slight modification to the source and using Wine. This however gets annoying if you're primarily a Linux user and have to boot into Windows anytime you want to make a change to the code. So after a few attempts, I've finally got the code building and running natively in Linux.

The source for the buildable Linux version is here https://gitlab.com/theodis3/tethealla

This is meant to be a drop in replacement for the current Tethealla server, as in you can copy an existing Windows install onto a Linux system, replace the binaries and it'll work identically to before, and can do so in a very minimal lightweight environment.

As such the installation process is virtually identical as the one found here https://www.pioneer2.net/community/threads/tethealla-server-setup-instructions.1/ and you'll need the data files that are part of the login and ship server downloads. Just replace the exes with the compiled binaries from the sources from my repo.

I haven't uploaded binaries anywhere yet, so if you want to use it you'll need to build your own from source. If anyone would like to build and distribute binaries of this or package it up for a distro, feel free to do so.

My version can be built as either 32 bit or 64 bit binaries using either gcc or clang. While porting the code I've used gcc 8.2 and clang 7.0, but I suspect older versions should work as well as I haven't used any C features beyond what's in C99.

Depending on your specific requirements you may want to make some modifications to these lines of the Makefile. Depending on the compiler you want to use, change the CC= line to either
  • CC=gcc
  • CC=clang
Modifications you may want to do to the CFLAGS line
  • If you want to build a 32 bit version, add -m32
  • If you want to compile a binary and use it on another machine remove -march=native , this option enables CPU specific optimizations that may not be available on machines other than the one you've build the binary on. If the binary will be run on the same machine as it's compiled on you'll probably want to leave it on for the performance boost.
  • If you're using GCC as the compiler you'll need to remove -O3 for now. The O3 flag enables aggressive optimizations, which at the moment cause buffer overflow crashes when building with GCC.
To keep this functionally identical to the original Tethealla server, I've tried to keep the number of changes I've made to a minimum, however I did make a few changes to how things work.
  • I've made the programs purely console programs, there is absolutely no dependency on X, so stuff like the system tray icon is gone.
  • I've removed all "Press [Enter]" prompts before exiting after an error.
  • The old MD5 code was thrown out in favor of just using OpenSSL's MD5 implementation. The old code was not working in 64 bit and with it removed there is less to maintain.
  • I've removed the mtwist library as I couldn't get it working and am just using the standard rand() function now
I've pretty much accomplished what I've wanted to do with this specific version of the server. If I do any changes that make it behave differently from the original Tethealla server I'll be doing it in a forked repo. That said there are a few things I may address with this one.
  • I'd like to figure out why -O3 isn't working for gcc. Since it happens when someone connects on any of the servers I suspect it has something to do with how connections are handled. Hopefully I'll get this fixed.
  • I'd like to get the server running on ARM. I haven't tested yet so it may already work, but if it doesn't I'd like to. I think it'd be kinda cool to have a tiny PSOBB server I could carry around with me. The requirements are very minimal so it should be doable on very cheap hardware.
  • Replace rand() with a fancier random number library. When looking up mtwist it appears it's not maintained anymore. It would be nice to get it replace something that is actively maintained.
 
Can confirm this compiles OK and runs on a Raspberry Pi 3b. I posted a bug/patch regarding the .BEAT time on gitlab, but in case anyone only sees about this project here:

This is for login_server.c @ line 1388. This will give the client the correct .BEAT time, though it still shows "00:00" before the beat time in the in-game menu and counts up from there. I think that 00:00 that shows before the internet beat time MIGHT be for current playtime this session, and not for "what time is it in normal time on the server". In which case, its working normally. If im wrong on that, would be happy if anyone corrects me :)

C++:
//FIXME: Dummied out time stuff
void SendB1 (BANANA* client)
{
//  SYSTEMTIME rawtime;
time_t rawtime;

if ((client->guildcard) && (client->slotnum != -1))
{
//    GetSystemTime (&rawtime);
rawtime = time(NULL);
struct tm tm = *localtime(&rawtime);

*(int64_t*) &client->encryptbuf[0] = *(int64_t*) &PacketB1[0];
memset (&client->encryptbuf[0x08], 0, 28);
//    sprintf (&client->encryptbuf[8], "%u:%02u:%02u: %02u:%02u:%02u.%03u", rawtime.wYear, rawtime.wMonth, rawtime.wDay,
//      rawtime.wHour, rawtime.wMinute, rawtime.wSecond, rawtime.wMilliseconds );
sprintf (&client->encryptbuf[8], "%u:%02u:%02u: %02u:%02u:%02u.%03u", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.t$
cipher_ptr = &client->server_cipher;
encryptcopy (client, &client->encryptbuf[0], 0x24 );
}
else
client->todc = 1;
}
 
Thanks for the patches, though I have to comment out this block since I don't see the ReloadAllQuests() function anywhere. Was part of the commit missing?

C:
      if ( ( !strcmp( myCommand, "reloadq" ) ) && ((client->isgm)) )
      {
        ReloadAllQuests();
      }
 
Alright, I just merged in all the commits from both your repos. It all builds for me but I haven't tested yet.
 
Thanks so much! Just got this running on ubuntu 20.04. Needed to install three packages to build it.
sudo apt-get install build-essential
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev
 
not to toot my own horn or anything, but i forked JTUU's repository to add some QoL chat commands to the game for showing/modifying name/materials, in case you wanted to use either the repository or just lift the code from the commits:
 
This may be a bit late, and maybe sounds noobish, I compiled the cherry-flavored tethealla, and while I had to modify my quest files (changing the \ for file path to /) the login server doesn't work for me, specifically because it says it cannot open the parameter files specified in e8send.txt, the windows version running on wine was working, but I wanted to move over to the linux native server.

I just can't for the life of me figure out why the login server cannot open the files listed in e8send.txt but it can read e8send.txt, so I know it isn't an issue of finding them.

EDIT: So I found another post mentioning the e8send, and dos2unix, after running it on tethealla.ini and e8send.txt everything looks like it works now, the tethealla.ini was kind of weird, because the error I was getting said it couldn't get into 'localh' and I was wondering if for some reason the character array wasn't setup to be long enough for localhost.
 
Last edited:
yeah, thats the difference between CR/LF and just LF for ending a line.

also of note, the welcome.txt is not standard ascii format, its a unicode encoded for 2 bytes per character i believe.
 
Back
Top