※ In this article, I have used OmniOS r151038 and JGRPP v0.52.0.
At the moment, r151038 is the latest LTS OmniOS release and JGRPP v0.52.0 is the latest version release.
OS Information
~$ uname -a
SunOS omnioslts 5.11 omnios-r151038-7bb369b3b5 i86pc i386 i86pc
~$ cat /etc/os-release
NAME="OmniOS"
PRETTY_NAME="OmniOS Community Edition v11 r151038cs"
CPE_NAME="cpe:/o:omniosce:omnios:11:151038:97"
ID=omnios
VERSION=r151038cs
VERSION_ID=r151038cs
BUILD_ID=151038.97.2023.03.11
HOME_URL="https://omnios.org/"
SUPPORT_URL="https://omnios.org/"
BUG_REPORT_URL="https://github.com/omniosorg/omnios-build/issues/new"
Install Requirements
~$ sudo pkg install gcc10 cmake gnu-make
설치할 패키지: 2
변경할 서비스: 1
부트 환경 만들기: 아니오
백업 부트 환경 만들기: 아니오
다운로드 패키지 파일 XFER(MB) 속도
완료됨 2/2 3199/3199 25.5/25.5 471k/s
단계 항목
새 작업 설치 3358/3358
패키지 상태 데이터베이스 업데이트 완료
패키지 캐시 업데이트 0/0
이미지 상태 업데이트 완료
빠른 조회 데이터베이스 만들기 완료
검색 색인 읽기 완료
검색 색인 업데이트 2/2
패키지 캐시 업데이트 2/2
~$ gcc --version
gcc (OmniOS 151038/10.4.0-il-1) 10.4.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~$ cmake --version
cmake version 3.25.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
~$ gmake --version
GNU Make 4.3
Built for x86_64-pc-solaris2.11
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Download and Extract JGRPP Source
~$ wget https://github.com/JGRennison/OpenTTD-patches/archive/refs/tags/jgrpp-0.52.0.tar.gz
--2023-03-24 15:02:55-- https://github.com/JGRennison/OpenTTD-patches/archive/refs/tags/jgrpp-0.52.0.tar.gz
Resolving github.com... 20.200.245.247
Connecting to github.com|20.200.245.247|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/JGRennison/OpenTTD-patches/tar.gz/refs/tags/jgrpp-0.52.0 [following]
--2023-03-24 15:02:56-- https://codeload.github.com/JGRennison/OpenTTD-patches/tar.gz/refs/tags/jgrpp-0.52.0
Resolving codeload.github.com... 20.200.245.246
Connecting to codeload.github.com|20.200.245.246|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘jgrpp-0.52.0.tar.gz’
jgrpp-0.52.0.tar.gz [ <=> ] 11.64M 6.13MB/s in 1.9s
2023-03-24 15:02:58 (6.13 MB/s) - ‘jgrpp-0.52.0.tar.gz’ saved [12207921]
~$ tar xzf jgrpp-0.52.0.tar.gz
Modify Source Files
Go to the source folder root.
~$ cd OpenTTD-patches-jgrpp-0.52.0
Open CMakeLists.txt
with an editor and add 3 lines in target_link_libraries
function located at line 313 and it should look like below.
${CMAKE_DL_LIBS}
-lsocket
-lnsl
⋮
add_dependencies(openttd
find_version)
target_link_libraries(openttd
openttd::languages
openttd::settings
openttd::media
openttd::basesets
openttd::script_api
openttd::binfiles
Threads::Threads
${CMAKE_DL_LIBS}
-lsocket
-lnsl
)
if(HAIKU)
target_link_libraries(openttd "be" "network" "midi")
endif()
⋮
Open build-dedicated.sh
with an editor and replace make
at line 7 with gmake
and it should look like below.
⋮
cd build
rm CMakeCache.txt
cmake .. -DOPTION_DEDICATED=true && gmake -j$(nproc 2>/dev/null || echo "1")
Open src/core/alloc_func.hpp
with an editor and add 3 lines at the beginning and it should look like below.
#ifdef __sun
#include <alloca.h>
#endif
#ifdef __sun
#include <alloca.h>
#endif
/*
* This file is part of OpenTTD.
⋮
Open src/string_func.h
comment out the line at line 279 and it should look like below.
⋮
# define DEFINE_STRCASESTR
// char *strcasestr(const char *haystack, const char *needle);
#endif /* strcasestr is available */
⋮
Open src/network/core/os_abstraction.cpp
with an editor and replace SO_REUSEPORT
at line 196 with SO_REUSEADDR
and it should look like below.
⋮
#else
int reuse_port = 1;
return setsockopt(d, SOL_SOCKET, SO_REUSEADDR, &reuse_port, sizeof(reuse_port)) == 0;
#endif
}
⋮
Open src/3rdparty/randombytes/randombytes.h
with an editor and replace a function randombytes
line at line 19 and it should look like below.
⋮
/*
* Write `n` bytes of high quality random bytes to `buf`
*/
int randombytes(unsigned char *buf, size_t n);
#ifdef __cplusplus
}
#endif
⋮
Open src/3rdparty/randombytes/randombytes.c
with an editor and delete all contents and then fill with below.
#include "randombytes.h"
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
int randombytes(unsigned char *x, size_t xlen)
{
int fd;
ssize_t bytes_read;
if (xlen == 0) return 0;
assert(x != NULL);
fd = open("/dev/urandom", O_RDONLY);
if (fd == -1) {
fd = open("/dev/random", O_RDONLY);
}
assert(fd != -1);
bytes_read = read(fd, x, xlen);
assert(bytes_read == xlen);
close(fd);
return 0;
}
Open src/os/unix/crashlog_unix.cpp
with an editor and add a line #include <ucontext.h>
right after #include <sys/mman.h>
at line 25 and it should look like below.
⋮
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <ucontext.h>
#if defined(WITH_DBG_GDB)
#include <sys/syscall.h>
#endif /* WITH_DBG_GDB */
⋮
And in the same file, replace two gregs[REG_EFL]
at line 400, 418 with gregs[REG_RFL]
and it should look like below.
⋮
gregs[REG_R14],
gregs[REG_R15],
gregs[REG_RIP],
gregs[REG_RFL]
);
#elif defined(__i386)
const gregset_t &gregs = ucontext->uc_mcontext.gregs;
buffer += seprintf(buffer, last,
⋮
gregs[REG_EBP],
gregs[REG_ESP],
gregs[REG_EIP],
gregs[REG_RFL]
);
#endif
#endif
⋮
Build
~$ ./build-dedicated.sh
Download and extract Base Graphics
~$ wget https://cdn.openttd.org/opengfx-releases/7.1/opengfx-7.1-all.zip
Resolving cdn.openttd.org... 54.230.167.118, 54.230.167.93, 54.230.167.82, ...
Connecting to cdn.openttd.org|54.230.167.118|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3547160 (3.4M) [application/zip]
Saving to: ‘opengfx-7.1-all.zip’
opengfx-7.1-all.zip 100%[=====================================================================>] 3.38M 9.53MB/s in 0.4s
2023-03-24 16:02:24 (9.53 MB/s) - ‘opengfx-7.1-all.zip’ saved [3547160/3547160]
~$ unzip opengfx-7.1-all.zip && mv opengfx-7.1.tar build/baseset/
Archive: opengfx-7.1-all.zip
inflating: opengfx-7.1.tar
Install
~$ cd build && sudo gmake install
Launch the dedicated server
~$ /usr/local/games/openttd -D