Skip to content

Commit

Permalink
Merge branch 'openttd'
Browse files Browse the repository at this point in the history
  • Loading branch information
ldpl committed Oct 17, 2021
2 parents 12cfb20 + ccd5309 commit 350b604
Show file tree
Hide file tree
Showing 65 changed files with 2,063 additions and 552 deletions.
14 changes: 14 additions & 0 deletions .changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
12.0 (2021-10-17)
------------------------------------------------------------------------
Add: [Network] Keep the refresh button in lowered state while refreshing (#9600)
Add: Console command to list search directories for various things (#9583)
Fix: Try all possible reverse directions when a ship reaches a dead end (#9610)
Fix: Incorrect Romanian own name (#9598)
Fix #9591: Update station docking tiles upon placing a water object on a docking tile (#9594)
Fix #9548: [Squirrel] Crash during engine cleanup after reaching memory limit on realloc (#9592)
Fix #9588: [Squirrel] Reaching memory limit during script registration could prevent further script detections (#9589)
Fix: Make ships more likely to find their destination at the cost of slightly worse paths (#9576)
Change: Reverse ship when leaving docks if a better path exists (#9610)
Change: Allow all tiles around docks to be docking tiles (#9578)


12.0-RC1 (2021-09-25)
------------------------------------------------------------------------
Feature: Display icon/text whether vehicle is lost in vehicle (list) window (#9543)
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-20.04
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:2.0.10
image: emscripten/emsdk:2.0.31

steps:
- name: Checkout
Expand All @@ -26,7 +26,12 @@ jobs:
uses: actions/cache@v2
with:
path: /emsdk/upstream/emscripten/cache
key: 2.0.10-${{ runner.os }}
key: 2.0.31-${{ runner.os }}

- name: Patch Emscripten to support LZMA
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
- name: Build (host tools)
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/preview_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:2.0.10
image: emscripten/emsdk:2.0.31
# uid=1001(runner) gid=121(docker)
options: -u 1001:121

Expand Down Expand Up @@ -46,7 +46,12 @@ jobs:
uses: actions/cache@v2
with:
path: /emsdk/upstream/emscripten/cache
key: 2.0.10-${{ runner.os }}
key: 2.0.31-${{ runner.os }}

- name: Patch Emscripten to support LZMA
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
- name: Build (host tools)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .ottdrev
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.0-RC1 20210925 0 79dc634d41d04f4b48e8e284f2986a9cdb288946 1 0 2021
12.0 20211017 0 33201896bfeae43ea5b0e381b7f834aa6b6287d2 1 1 2021
2 changes: 1 addition & 1 deletion .release_date
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021-09-25 14:00 UTC
2021-10-17 09:31 UTC
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.0-RC1
12.0
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ if(EMSCRIPTEN)
add_definitions(-s DISABLE_EXCEPTION_CATCHING=0)

# Export functions to Javascript.
target_link_libraries(WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\"_main\", \"_em_openttd_add_server\"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
target_link_libraries(WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\"_main\", \"_em_openttd_add_server\"]' -s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")

# Preload all the files we generate during build.
# As we do not compile with FreeType / FontConfig, we also have no way to
Expand Down
14 changes: 14 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
12.0 (2021-10-17)
------------------------------------------------------------------------
Add: [Network] Keep the refresh button in lowered state while refreshing (#9600)
Add: Console command to list search directories for various things (#9583)
Fix: Try all possible reverse directions when a ship reaches a dead end (#9610)
Fix: Incorrect Romanian own name (#9598)
Fix #9591: Update station docking tiles upon placing a water object on a docking tile (#9594)
Fix #9548: [Squirrel] Crash during engine cleanup after reaching memory limit on realloc (#9592)
Fix #9588: [Squirrel] Reaching memory limit during script registration could prevent further script detections (#9589)
Fix: Make ships more likely to find their destination at the cost of slightly worse paths (#9576)
Change: Reverse ship when leaving docks if a better path exists (#9610)
Change: Allow all tiles around docks to be docking tiles (#9578)


12.0-RC1 (2021-09-25)
------------------------------------------------------------------------
Feature: Display icon/text whether vehicle is lost in vehicle (list) window (#9543)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function(set_options)

option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
option(OPTION_INSTALL_FHS "Install with Filesystem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" OFF)
if(EMSCRIPTEN)
# Although pthreads is supported, it is not in a way yet that is
# useful for us.
Expand Down
Binary file modified media/baseset/opntitle.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion os/emscripten/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM emscripten/emsdk:2.0.10
FROM emscripten/emsdk:2.0.31

COPY emsdk-liblzma.patch /
RUN cd /emsdk/upstream/emscripten && patch -p1 < /emsdk-liblzma.patch
2 changes: 1 addition & 1 deletion os/emscripten/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## How to build with Emscripten

Building with Emscripten works with emsdk 2.0.10 and above.
Building with Emscripten works with emsdk 2.0.31 and above.

Currently there is no LibLZMA support upstream; for this we suggest to apply
the provided patch in this folder to your emsdk installation.
Expand Down
55 changes: 23 additions & 32 deletions os/emscripten/emsdk-liblzma.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,35 @@ Modifed by OpenTTD to have the bare minimum needed to work. Otherwise there
are constantly conflicts when trying to apply this patch to different versions
of emsdk.

diff --git a/embuilder.py b/embuilder.py
index 818262190ed..ab7d5adb7b2 100755
--- a/embuilder.py
+++ b/embuilder.py
@@ -60,6 +60,7 @@
'harfbuzz',
'icu',
'libjpeg',
+ 'liblzma',
'libpng',
'ogg',
'regal',
@@ -197,6 +198,8 @@ def main():
build_port('ogg', libname('libogg'))
elif what == 'libjpeg':
build_port('libjpeg', libname('libjpeg'))
+ elif what == 'liblzma':
+ build_port('liblzma', libname('liblzma'))
elif what == 'libpng':
build_port('libpng', libname('libpng'))
elif what == 'sdl2':
diff --git a/tools/settings.py b/tools/settings.py
--- a/tools/settings.py
+++ b/tools/settings.py
@@ -38,6 +38,7 @@
'USE_SDL_NET',
'USE_SDL_GFX',
'USE_LIBJPEG',
+ 'USE_LIBLZMA',
'USE_OGG',
'USE_REGAL',
'USE_BOOST_HEADERS',
diff --git a/src/settings.js b/src/settings.js
index 61cd98939ba..be6fcb678c6 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -1197,6 +1197,9 @@ var USE_BZIP2 = 0;
@@ -1382,8 +1382,12 @@ var USE_BZIP2 = 0;
// 1 = use libjpeg from emscripten-ports
// [link]
var USE_LIBJPEG = 0;

+// 1 = use liblzma from emscripten-ports
+// [link]
+var USE_LIBLZMA = 0;
+
// 1 = use libpng from emscripten-ports
// [link]
var USE_LIBPNG = 0;

diff --git a/tools/ports/liblzma.py b/tools/ports/liblzma.py
new file mode 100644
index 00000000000..e9567ef36ff
--- /dev/null
+++ b/tools/ports/liblzma.py
@@ -0,0 +1,160 @@
Expand All @@ -58,6 +49,8 @@ index 00000000000..e9567ef36ff
+
+import os
+import shutil
+import logging
+from pathlib import Path
+
+VERSION = '5.2.5'
+HASH = '7443674247deda2935220fbc4dfc7665e5bb5a260be8ad858c8bd7d7b9f0f868f04ea45e62eb17c0a5e6a2de7c7500ad2d201e2d668c48ca29bd9eea5a73a3ce'
Expand All @@ -68,10 +61,11 @@ index 00000000000..e9567ef36ff
+
+
+def get(ports, settings, shared):
+ libname = ports.get_lib_name('liblzma')
+ ports.fetch_project('liblzma', 'https://tukaani.org/xz/xz-' + VERSION + '.tar.gz', 'xz-' + VERSION, sha512hash=HASH)
+
+ def create():
+ def create(final):
+ logging.info('building port: liblzma')
+
+ ports.clear_project_build('liblzma')
+
+ source_path = os.path.join(ports.get_dir(), 'liblzma', 'xz-' + VERSION)
Expand All @@ -88,22 +82,19 @@ index 00000000000..e9567ef36ff
+ 'tuklib_exit.c', 'tuklib_mbstr_fw.c', 'tuklib_mbstr_width.c', 'tuklib_open_stdxxx.c', 'tuklib_progname.c']
+ include_dirs_rel = ['../common', 'api', 'common', 'check', 'lz', 'rangecoder', 'lzma', 'delta', 'simple']
+
+ open(os.path.join(dest_path, 'src', 'config.h'), 'w').write(config_h)
+ Path(dest_path, os.path.join('src', 'config.h')).write_text(config_h)
+
+ final = os.path.join(dest_path, libname)
+ include_dirs = [os.path.join(dest_path, 'src', 'liblzma', p) for p in include_dirs_rel]
+ ports.build_port(os.path.join(dest_path, 'src'), final, flags=build_flags, exclude_dirs=exclude_dirs, exclude_files=exclude_files, includes=include_dirs)
+
+ ports.install_headers(os.path.join(dest_path, 'src', 'liblzma', 'api'), 'lzma.h')
+ ports.install_headers(os.path.join(dest_path, 'src', 'liblzma', 'api', 'lzma'), '*.h', 'lzma')
+
+ return final
+
+ return [shared.Cache.get(libname, create, what='port')]
+ return [shared.Cache.get_lib('liblzma.a', create, what='port')]
+
+
+def clear(ports, settings, shared):
+ shared.Cache.erase_file(ports.get_lib_name('liblzma'))
+ shared.Cache.erase_lib('liblzma.a')
+
+
+def process_args(ports):
Expand Down
18 changes: 18 additions & 0 deletions src/3rdparty/squirrel/squirrel/sqobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ struct SQRefCounted
SQUnsignedInteger _uiRef;
struct SQWeakRef *_weakref;
virtual void Release()=0;

/* Placement new/delete to prevent memory leaks if constructor throws an exception. */
inline void *operator new(size_t size, SQRefCounted *place)
{
place->size = size;
return place;
}

inline void operator delete(void *ptr, SQRefCounted *place)
{
SQ_FREE(ptr, place->size);
}

/* Never used but required. */
inline void operator delete(void *ptr) { NOT_REACHED(); }

private:
size_t size;
};

struct SQWeakRef : SQRefCounted
Expand Down
66 changes: 66 additions & 0 deletions src/console_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,71 @@ DEF_CONSOLE_CMD(ConNewGRFReload)
return true;
}

DEF_CONSOLE_CMD(ConListDirs)
{
struct SubdirNameMap {
Subdirectory subdir; ///< Index of subdirectory type
const char *name; ///< UI name for the directory
bool default_only; ///< Whether only the default (first existing) directory for this is interesting
};
static const SubdirNameMap subdir_name_map[] = {
/* Game data directories */
{ BASESET_DIR, "baseset", false },
{ NEWGRF_DIR, "newgrf", false },
{ AI_DIR, "ai", false },
{ AI_LIBRARY_DIR, "ailib", false },
{ GAME_DIR, "gs", false },
{ GAME_LIBRARY_DIR, "gslib", false },
{ SCENARIO_DIR, "scenario", false },
{ HEIGHTMAP_DIR, "heightmap", false },
/* Default save locations for user data */
{ SAVE_DIR, "save", true },
{ AUTOSAVE_DIR, "autosave", true },
{ SCREENSHOT_DIR, "screenshot", true },
};

if (argc != 2) {
IConsolePrint(CC_HELP, "List all search paths or default directories for various categories.");
IConsolePrint(CC_HELP, "Usage: list_dirs <category>");
std::string cats = subdir_name_map[0].name;
bool first = true;
for (const SubdirNameMap &sdn : subdir_name_map) {
if (!first) cats = cats + ", " + sdn.name;
first = false;
}
IConsolePrint(CC_HELP, "Valid categories: {}", cats);
return true;
}

std::set<std::string> seen_dirs;
for (const SubdirNameMap &sdn : subdir_name_map) {
if (strcasecmp(argv[1], sdn.name) != 0) continue;
bool found = false;
for (Searchpath sp : _valid_searchpaths) {
/* Get the directory */
std::string path = FioGetDirectory(sp, sdn.subdir);
/* Check it hasn't already been listed */
if (seen_dirs.find(path) != seen_dirs.end()) continue;
seen_dirs.insert(path);
/* Check if exists and mark found */
bool exists = FileExists(path);
found |= exists;
/* Print */
if (!sdn.default_only || exists) {
IConsolePrint(exists ? CC_DEFAULT : CC_INFO, "{} {}", path, exists ? "[ok]" : "[not found]");
if (sdn.default_only) break;
}
}
if (!found) {
IConsolePrint(CC_ERROR, "No directories exist for category {}", argv[1]);
}
return true;
}

IConsolePrint(CC_ERROR, "Invalid category name: {}", argv[1]);
return false;
}

DEF_CONSOLE_CMD(ConNewGRFProfile)
{
if (argc == 0) {
Expand Down Expand Up @@ -2346,6 +2411,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("list_settings", ConListSettings);
IConsole::CmdRegister("gamelog", ConGamelogPrint);
IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF);
IConsole::CmdRegister("list_dirs", ConListDirs);

IConsole::AliasRegister("dir", "ls");
IConsole::AliasRegister("del", "rm %+");
Expand Down
4 changes: 2 additions & 2 deletions src/console_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/** Modes of the in-game console. */
enum IConsoleModes {
ICONSOLE_FULL, ///< In-game console is closed.
ICONSOLE_FULL, ///< In-game console is opened, whole screen.
ICONSOLE_OPENED, ///< In-game console is opened, upper 1/3 of the screen.
ICONSOLE_CLOSED, ///< In-game console is opened, whole screen.
ICONSOLE_CLOSED, ///< In-game console is closed.
};

/* Colours of the console messages. */
Expand Down
30 changes: 30 additions & 0 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ uint64 ottd_rdtsc()
# define RDTSC_AVAILABLE
#endif

/* rdtsc for MCST Elbrus 2000 */
#if defined(__e2k__) && !defined(RDTSC_AVAILABLE)
uint64 ottd_rdtsc()
{
uint64_t dst;
# pragma asm_inline
asm("rrd %%clkr, %0" : "=r" (dst));
return dst;
}
# define RDTSC_AVAILABLE
#endif

#if defined(__EMSCRIPTEN__) && !defined(RDTSC_AVAILABLE)
/* On emscripten doing TIC/TOC would be ill-advised */
uint64 ottd_rdtsc() {return 0;}
Expand Down Expand Up @@ -131,6 +143,24 @@ void ottd_cpuid(int info[4], int type)
);
#endif /* i386 PIC */
}
#elif defined(__e2k__) /* MCST Elbrus 2000*/
void ottd_cpuid(int info[4], int type)
{
info[0] = info[1] = info[2] = info[3] = 0;
if (type == 0) {
info[0] = 1;
} else if (type == 1) {
#if defined(__SSE4_1__)
info[2] |= (1<<19); /* HasCPUIDFlag(1, 2, 19) */
#endif
#if defined(__SSSE3__)
info[2] |= (1<<9); /* HasCPUIDFlag(1, 2, 9) */
#endif
#if defined(__SSE2__)
info[3] |= (1<<26); /* HasCPUIDFlag(1, 3, 26) */
#endif
}
}
#else
void ottd_cpuid(int info[4], int type)
{
Expand Down
Loading

0 comments on commit 350b604

Please sign in to comment.