is a C++11 extension
+ flags="$flags -Wno-c++11-extensions"
+
if [ "$cc_version" -lt "300" ]; then
# warning: equality comparison with extraneous parentheses
flags="$flags -Wno-parentheses"
@@ -1541,10 +1512,6 @@ make_cflags_and_ldflags() {
if [ "$enable_debug" = "0" ]; then
# No debug, add default stuff
OBJS_SUBDIR="release"
- if [ "$os" = "MORPHOS" ]; then
- CFLAGS="-I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations -mcpu=604 -fno-inline -mstring -mmultiple $CFLAGS"
- LDFLAGS="$LDFLAGS -noixemul"
- fi
if [ "$enable_profiling" = "0" ]; then
# -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible)
@@ -1633,19 +1600,14 @@ make_cflags_and_ldflags() {
fi
fi
- if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "OS2" ]; then
+ if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "OSX" ] && [ "$os" != "OS2" ]; then
LIBS="$LIBS -lpthread"
fi
- if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ]; then
+ if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ]; then
LIBS="$LIBS -lc"
fi
- if [ "$os" = "MORPHOS" ]; then
- # -Wstrict-prototypes generates much noise because of system headers
- CFLAGS="$CFLAGS -Wno-strict-prototypes"
- fi
-
if [ "$os" = "OPENBSD" ]; then
LIBS="$LIBS -pthread"
fi
@@ -1669,12 +1631,12 @@ make_cflags_and_ldflags() {
fi
fi
- if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
+ if [ "$os" = "HAIKU" ]; then
LIBS="$LIBS -lmidi -lbe"
fi
# Most targets act like UNIX, just with some additions
- if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
+ if [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
CFLAGS="$CFLAGS -DUNIX"
fi
# And others like Windows
@@ -1698,12 +1660,10 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DWITH_SDL"
# SDL must not add _GNU_SOURCE as it breaks many platforms
CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
- if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
- if [ "$enable_static" != "0" ]; then
- LIBS="$LIBS `$sdl_config --static-libs`"
- else
- LIBS="$LIBS `$sdl_config --libs`"
- fi
+ if [ "$enable_static" != "0" ]; then
+ LIBS="$LIBS `$sdl_config --static --libs`"
+ else
+ LIBS="$LIBS `$sdl_config --libs`"
fi
fi
@@ -1731,7 +1691,7 @@ make_cflags_and_ldflags() {
fi
if [ -n "$lzma_config" ]; then
- CFLAGS="$CFLAGS -DWITH_LZMA"
+ CFLAGS="$CFLAGS -DWITH_LIBLZMA"
CFLAGS="$CFLAGS `$lzma_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
@@ -1802,7 +1762,7 @@ make_cflags_and_ldflags() {
fi
if [ -n "$icu_layout_config" ]; then
- CFLAGS="$CFLAGS -DWITH_ICU_LAYOUT"
+ CFLAGS="$CFLAGS -DWITH_ICU_LX"
CFLAGS="$CFLAGS `$icu_layout_config --cflags | tr '\n\r' ' '`"
if [ "$static_icu" != "0" ]; then
@@ -1813,7 +1773,7 @@ make_cflags_and_ldflags() {
fi
if [ -n "$icu_sort_config" ]; then
- CFLAGS="$CFLAGS -DWITH_ICU_SORT"
+ CFLAGS="$CFLAGS -DWITH_ICU_I18N"
CFLAGS="$CFLAGS `$icu_sort_config --cflags | tr '\n\r' ' '`"
if [ "$static_icu" != "0" ]; then
@@ -1842,17 +1802,6 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DWITH_XAUDIO2"
fi
- if [ -n "$libtimidity_config" ]; then
- CFLAGS="$CFLAGS -DLIBTIMIDITY"
- CFLAGS="$CFLAGS `$libtimidity_config --cflags | tr '\n\r' ' '`"
-
- if [ "$enable_static" != "0" ]; then
- LIBS="$LIBS `$libtimidity_config --libs --static | tr '\n\r' ' '`"
- else
- LIBS="$LIBS `$libtimidity_config --libs | tr '\n\r' ' '`"
- fi
- fi
-
if [ -n "$fluidsynth" ]; then
LIBS="$LIBS -lfluidsynth"
CFLAGS="$CFLAGS -DFLUIDSYNTH"
@@ -1888,20 +1837,12 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
fi
- if [ "$enable_network" != "0" ]; then
- CFLAGS="$CFLAGS -DENABLE_NETWORK"
-
- if [ "$os" = "BEOS" ]; then
- LDFLAGS="$LDFLAGS -lbind -lsocket"
- fi
-
- if [ "$os" = "HAIKU" ]; then
- LDFLAGS="$LDFLAGS -lnetwork"
- fi
+ if [ "$os" = "HAIKU" ]; then
+ LDFLAGS="$LDFLAGS -lnetwork"
+ fi
- if [ "$os" = "SUNOS" ]; then
- LDFLAGS="$LDFLAGS -lnsl -lsocket"
- fi
+ if [ "$os" = "SUNOS" ]; then
+ LDFLAGS="$LDFLAGS -lnsl -lsocket"
fi
if [ "$enable_static" != "0" ]; then
@@ -2380,7 +2321,7 @@ detect_awk() {
detect_os() {
if [ "$os" = "DETECT" ]; then
- # Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, and DOS
+ # Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, SUNOS, CYGWIN, MINGW, and OS2
# Try first via dumpmachine, then via uname
os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
@@ -2391,15 +2332,12 @@ detect_os() {
/openbsd/ { print "OPENBSD"; exit}
/netbsd/ { print "NETBSD"; exit}
/hp-ux/ { print "HPUX"; exit}
- /morphos/ { print "MORPHOS"; exit}
- /beos/ { print "BEOS"; exit}
/haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/solaris/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
/mingw/ { print "MINGW"; exit}
/os2/ { print "OS2"; exit}
- /dos/ { print "DOS"; exit}
'`
if [ -z "$os" ]; then
@@ -2411,8 +2349,6 @@ detect_os() {
/openbsd/ { print "OPENBSD"; exit}
/netbsd/ { print "NETBSD"; exit}
/hp-ux/ { print "HPUX"; exit}
- /morphos/ { print "MORPHOS"; exit}
- /beos/ { print "BEOS"; exit}
/haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
@@ -2425,7 +2361,7 @@ detect_os() {
if [ -z "$os" ]; then
log 1 "detecting OS... none detected"
log 1 "I couldn't detect your OS. Please use --os=OS to force one"
- log 1 "Allowed values are: UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, and DOS"
+ log 1 "Allowed values are: UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, HAIKU, SUNOS, CYGWIN, MINGW, and OS2"
exit 1
fi
@@ -2790,10 +2726,6 @@ detect_lzo2() {
detect_library "$with_lzo2" "lzo2" "liblzo2.a" "lzo/" "lzo1x.h"
}
-detect_libtimidity() {
- detect_pkg_config "$with_libtimidity" "libtimidity" "libtimidity_config" "0.1" "1"
-}
-
detect_fluidsynth() {
detect_library "$with_fluidsynth" "fluidsynth" "" "" "fluidsynth.h"
}
@@ -3528,8 +3460,8 @@ showhelp() {
echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]"
echo " --os=OS the OS we are compiling for [DETECT]"
echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/"
- echo " NETBSD/MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/"
- echo " MINGW/OS2/DOS/HAIKU"
+ echo " NETBSD/HPUX/SUNOS/CYGWIN/"
+ echo " MINGW/OS2/HAIKU"
echo ""
echo "Paths:"
echo " --prefix-dir=dir specifies the prefix for all installed"
@@ -3583,7 +3515,6 @@ showhelp() {
echo " --enable-console compile as a console application instead of as a GUI application."
echo " If this setting is active, debug output will appear in the same"
echo " console instead of opening a new window. (Win32 ONLY)"
- echo " --disable-network disable network support"
echo " --disable-assert disable asserts (continue on errors)"
echo " --enable-strip enable any possible stripping"
echo " --without-osx-sysroot disable the automatic adding of sysroot "
@@ -3598,8 +3529,6 @@ showhelp() {
echo " --with-midi=midi define which midi-player to use"
echo " --with-midi-arg=arg define which args to use for the"
echo " midi-player"
- echo " --with-libtimidity[=\"pkg-config libtimidity\"]"
- echo " enables libtimidity support"
echo " --with-fluidsynth enables fluidsynth support"
echo " --with-allegro[=\"pkg-config allegro\"]"
echo " enables Allegro video driver support"
diff --git a/configure b/configure
index afc1de51b4..7a13a96c88 100755
--- a/configure
+++ b/configure
@@ -75,7 +75,7 @@ save_params
make_cflags_and_ldflags
EXE=""
-if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ] || [ "$os" = "DOS" ]; then
+if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ]; then
EXE=".exe"
fi
@@ -116,18 +116,15 @@ AWKCOMMAND='
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
- if ($0 == "DOS" && "'$os'" != "DOS") { next; }
- if ($0 == "BEOS" && "'$os'" != "BEOS" &&
- "'$os'" != "HAIKU") { next; }
+ if ($0 == "HAIKU" && "'$os'" != "HAIKU") { next; }
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
"'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
- if ($0 == "MORPHOS" && "'$os'" != "MORPHOS") { next; }
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0") { next; }
- if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
if ($0 == "FLUIDSYNTH" && "'$fluidsynth'" == "" ) { next; }
- if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
- if ($0 == "SSE" && "'$with_sse'" != "1") { next; }
+ if ($0 == "USE_XAUDIO2" && "'$with_xaudio2'" == "0") { next; }
+ if ($0 == "USE_THREADS" && "'$with_threads'" == "0") { next; }
+ if ($0 == "USE_SSE" && "'$with_sse'" != "1") { next; }
skip += 1;
diff --git a/docs/landscape.html b/docs/landscape.html
index a345128ea4..d4d8f7efeb 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -759,6 +759,7 @@
|
+ - m1 bits 6..5: water class (sea or land)
- m1 bits 4..0: owner (normally 10)
- m2 bits 8..6: ground
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index 8519fa990a..4948366e65 100644
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -194,7 +194,7 @@ the array so you can quickly see what is used and what is not.
trees |
XXXX XXXX |
XXXX XXXX |
- OOO~ ~~~~ |
+ OXX~ ~~~~ |
OOOO OOOX XXXX XXXX |
~~XX XXXX |
OOOO OOOO |
diff --git a/findversion.sh b/findversion.sh
index 37e483cae3..95a041bac0 100755
--- a/findversion.sh
+++ b/findversion.sh
@@ -83,9 +83,15 @@ if [ -d "$ROOT_DIR/.git" ]; then
if [ -n "$TAG" ]; then
VERSION="${TAG}"
ISTAG="1"
+ if [ -n "`echo \"${TAG}\" | grep \"^[0-9.]*$\"`" ]; then
+ ISSTABLETAG="1"
+ else
+ ISSTABLETAG="0"
+ fi
else
VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
ISTAG="0"
+ ISSTABLETAG="0"
fi
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
@@ -102,6 +108,7 @@ else
TAG=""
VERSION=""
ISTAG="0"
+ ISSTABLETAG="0"
fi
-echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG"
+echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG"
diff --git a/known-bugs.txt b/known-bugs.txt
index bcb9c354a9..c02897e501 100644
--- a/known-bugs.txt
+++ b/known-bugs.txt
@@ -1,6 +1,6 @@
OpenTTD's known bugs
-Last updated: 2019-02-09
-Release version: 1.9.0-beta2
+Last updated: 2019-02-24
+Release version: 1.9.0-beta3
------------------------------------------------------------------------
diff --git a/os/debian/changelog b/os/debian/changelog
index e429487ec0..8c3b0cbf90 100644
--- a/os/debian/changelog
+++ b/os/debian/changelog
@@ -1,3 +1,27 @@
+openttd (1.9.0-0) unstable; urgency=low
+
+ * New upstream release 1.9.0
+
+ -- OpenTTD Mon, 01 Apr 2019 00:00:00 +0200
+
+openttd (1.9.0~RC2-0) unstable; urgency=low
+
+ * New upstream release 1.9.0-RC2
+
+ -- OpenTTD Sun, 24 Mar 2019 23:00:00 +0000
+
+openttd (1.9.0~RC1-0) unstable; urgency=low
+
+ * New upstream release 1.9.0-RC1
+
+ -- OpenTTD Sun, 3 Mar 2019 23:00:00 +0000
+
+openttd (1.9.0~beta3-0) unstable; urgency=low
+
+ * New upstream release 1.9.0-beta3
+
+ -- OpenTTD Sun, 24 Feb 2019 23:00:00 +0000
+
openttd (1.9.0~beta2-0) unstable; urgency=low
* New upstream release 1.9.0-beta2
diff --git a/os/dos/cwsdpmi/README.licensing b/os/dos/cwsdpmi/README.licensing
deleted file mode 100644
index 112b02a087..0000000000
--- a/os/dos/cwsdpmi/README.licensing
+++ /dev/null
@@ -1,3 +0,0 @@
-The files in this directory are not licensed under the same terms as the
-rest of OpenTTD. Licensing details can be found in OpenTTD's readme.txt
-and in this directory or subdirectories as well.
diff --git a/os/dos/cwsdpmi/cwsdpmi.exe b/os/dos/cwsdpmi/cwsdpmi.exe
deleted file mode 100644
index 17e3220023..0000000000
Binary files a/os/dos/cwsdpmi/cwsdpmi.exe and /dev/null differ
diff --git a/os/dos/cwsdpmi/cwsdpmi.txt b/os/dos/cwsdpmi/cwsdpmi.txt
deleted file mode 100644
index 14b09c4d76..0000000000
--- a/os/dos/cwsdpmi/cwsdpmi.txt
+++ /dev/null
@@ -1,173 +0,0 @@
-CWSDPMI is Copyright (C) 1995-2000 Charles W Sandmann (sandmann@clio.rice.edu)
- 1206 Braelinn, Sugar Land, TX 77479
-
-This is release 5. The files in this binary distribution may be redistributed
-under the GPL (with source) or without the source code provided:
-
-* CWSDPMI.EXE or CWSDPR0.EXE are not modified in any way except via CWSPARAM.
-
-* CWSDSTUB.EXE internal contents are not modified in any way except via
- CWSPARAM or STUBEDIT. It may have a COFF image plus data appended to it.
-
-* Notice to users that they have the right to receive the source code and/or
- binary updates for CWSDPMI. Distributors should indicate a site for the
- source in their documentation.
-
--------------------------------------------------------------------------------
-
-CWSDPMI was written to provide DPMI services for V2 of DJGPP. It currently
-does not support 16-bit DPMI applications, or DPMI applications requiring a
-built in extender. It does support virtual memory and hardware interrupt
-reflection from real mode to protected mode. DJGPP V1.1x and RSX applications
-will also run using this server, which can be used to provide enhanced control
-over hardware interrupts. Some DPMI 1.0 extensions (0x506, 0x507, 0x508) have
-been implemented.
-
-CWSDPR0.EXE is an alternate version which runs at ring 0 with virtual memory
-disabled. It may be used if access to ring-0 features are desired. It
-currently does not switch stacks on HW interrupts, so some DJGPP features
-such as SIGINT and SIGFPE are not supported and will generate a double fault
-or stack fault error (to be fixed someday).
-
-CWSDSTUB.EXE is a stub loader image for DJGPP which includes CWSDPMI. This
-allows single executable image distributions. You can use the EXE2COFF
-program and COPY /B CWSDSTUB.EXE+yourimage yourimage.exe to create a
-standalone executable image.
-
-Some of the internal tuning and configuration parameters may be modified
-in the image using CWSPARAM.EXE (see CWSPARAM.DOC).
-
-If you want to use CWSDPMI with DJGPP, you expand the distribution into the
-DJGPP directory tree. CWSDPMI.EXE will be put in the BIN directory with your
-DJGPP images and it will automatically be loaded when they run.
-
-Directions for use (server can be used in either of two different ways):
-
-1) "cwsdpmi" alone with no parameters will terminate and stay resident
- FOR A SINGLE DPMI PROCESS. This means it unloads itself when your
- DPMI application exits. This mode is useful in software which needs
- DPMI services, since CWSDPMI can be exec'ed and then will unload on exit.
-
-2) "cwsdpmi -p" will terminate and stay resident until you remove it.
- It can be loaded into UMBs with LH. "cwsdpmi -u" will unload the TSR.
-
-3) The file used for virtual memory swapping, if desired, is controlled
- by the "-sc:\cwsdpmi.swp" syntax on the command line. You must specify
- either a file with full disk/directory syntax, or "-s-" which disables
- virtual memory.
-
-4) The default swap file name is c:\cwsdpmi.swp, but this can be changed
- with the CWSPARAM image, as can some other parameters.
-
-5) You can disable the DPMI 1.0 extensions by starting the image with the
- "cwsdpmi -x" syntax. This feature allows you to run programs developed
- under other DPMI providers which do not behave properly with these
- extensions enabled (typically use of NULL pointers).
-
-I would like to give special thanks to DJ Delorie who wrote the original
-GO32 code on which CWSDPMI is based. Morten Welinder also provided and
-improved much of the code in this program.
-
--------------------------------------------------------------------------------
-
-This section contains a list of the error messages you might see out of
-CWSDPMI and some details on what they mean.
-
-Exceptions are only handled by CWSDPMI if the application does not establish
-an exception handler, exceptions nest 5 deep, or the error is particularly bad:
-
-"Page fault" -
- 1) an illegal page fault happens in a RMCB or HW interrupt, (lock all pages!)
- 2) all available pages have been locked,
- 3) the application is using non-committed pages for null pointer protection.
-"Double Fault" - multiple exceptions occurred
-"Invalid TSS" - typically due to RMCB or HW interrupt being called after the
- selectors/memory have been deallocated (remember to reset the mouse)
-"General Protection Fault" - bad parameter sent to a DPMI call
-
-"80386 required."
-
-Since 80286 and lesser processors don't have the hardware necessary to
-run CWSDPMI. No workaround, upgrade.
-
-"DOS 3 required."
-
-A few interrupts are used which need DOS 3.0 or higher. I don't expect to
-ever see this message, since 80386 machines were introduced after DOS 3.0
-and that check is made first.
-
-"CWSDPMI V0.90+ (r5) Copyright (C) 2000 CW Sandmann ABSOLUTELY NO WARRANTY"
-
-An informational message displayed if the program is not run in one-pass mode.
-
-"Protected mode not accessible."
-
-This message should only be displayed if running CWSDPMI in a protected
-environment with no access to protected mode. In this case, DPMI should
-already be available and CWSDPMI would not be needed. This might happen if
-a 16-bit DPMI client is loaded and a DJGPP image attempts to load CWSDPMI
-to provide 32-bit DPMI services under Windows.
-
-"Warning: cannot open swap file c:\cwsdpmi.swp"
-
-Maybe you are out of file handles, or the swap file name is incorrectly
-specified in the image (change the name with cwsparam).
-
-"No swap space!"
-
-This message means you tried to use more paging file than CWSDPMI was
-configured to handle. Since this is protected against in the memory
-allocation code, you should never see this message.
-
-"Swap disk full!"
-
-This means the paging file could not be expanded when trying to page
-memory out to disk. This would normally not be seen, unless you are
-writing output to the same disk which holds the paging file. Decrease
-the amount of memory your DPMI application is using or free up disk space.
-
-"Interrupt 0x??"
-
-Your application tried to call an interrupt from protected mode which
-normally shouldn't be called (something like a data pointer). If the
-request was allowed to continue it would likely hang your machine. If you
-see this message and think the interrupt should be allowed to continue, let
-me know.
-
-"Error: Using XMS switched CPU into V86 mode."
-
-This message might be seen if you have your memory manager in AUTO mode. The
-only workaround in this case is to stop using AUTO mode.
-
-"Error: could not allocate page table memory"
-
-The page table memory (a minimum of 16Kb) is allocated from conventional
-memory (either in the 640Kb region or UMBs). If CWSDPMI cannot allocate the
-minimum necessary memory, you would see this message. Free up some
-conventional memory. You may also see this message if a page directory needs
-to be faulted in, and there are no available pages. This means too many pages
-have been locked for the allocated page tables available. While CWSDPMI
-tries to dynamically allocate these if needed, this effort failed. You need
-to increase the number of page tables with CWSPARAM, or increase the amount
-of free conventional memory if it is low. If the application which calls
-CWSDPMI internally manages all the DOS memory, the page tables may need to
-be pre-allocated at DPMI startup time (if this is needed, try using the
-run option flag 2 in cwsparam).
-
-"16-bit DPMI unsupported."
-
-CWSDPMI is a 32-bit only DPMI server. Ideally, on the request to enter DPMI's
-PM with a 16-bit request, we would just fail the call setting the carry bit
-like the DPMI specification describes. Some buggy 16-bit compiler tools don't
-check the return status and will hang the machine in this case. So, I issue
-an error message and exit the image instead.
-
-"Descriptors exhausted."
-
-An attempt to nest a DPMI client failed in the setup phase due to insufficient
-free selectors in the LDT.
-
-"CWSDPMI not removed"
-
-When the -u parameter is specified, if DPMI is not detected this message is
-printed. Informational.
diff --git a/os/dos/cwsdpmi/cwsdstub.exe b/os/dos/cwsdpmi/cwsdstub.exe
deleted file mode 100644
index fabaf3bf4f..0000000000
Binary files a/os/dos/cwsdpmi/cwsdstub.exe and /dev/null differ
diff --git a/os/dos/exe2coff/README.licensing b/os/dos/exe2coff/README.licensing
deleted file mode 100644
index 112b02a087..0000000000
--- a/os/dos/exe2coff/README.licensing
+++ /dev/null
@@ -1,3 +0,0 @@
-The files in this directory are not licensed under the same terms as the
-rest of OpenTTD. Licensing details can be found in OpenTTD's readme.txt
-and in this directory or subdirectories as well.
diff --git a/os/dos/exe2coff/copying b/os/dos/exe2coff/copying
deleted file mode 100644
index a43ea2126f..0000000000
--- a/os/dos/exe2coff/copying
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C) 19yy
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/os/dos/exe2coff/copying.dj b/os/dos/exe2coff/copying.dj
deleted file mode 100644
index 8a55047845..0000000000
--- a/os/dos/exe2coff/copying.dj
+++ /dev/null
@@ -1,48 +0,0 @@
-This is the file "copying.dj". It does NOT apply to any sources or
-binaries copyrighted by UCB Berkeley, the Free Software Foundation, or
-any other agency besides DJ Delorie and others who have agreed to
-allow their sources to be distributed under these terms.
-
- Copyright Information for sources and executables that are marked
- Copyright (C) DJ Delorie
- 7 Kim Lane
- Rochester NH 03867-2954
-
-This document is Copyright (C) DJ Delorie and may be distributed
-verbatim, but changing it is not allowed.
-
-Source code copyright DJ Delorie is distributed under the terms of the
-GNU General Public Licence, with the following exceptions:
-
-* Sources used to build crt0.o, gcrt0.o, libc.a, libdbg.a, and
- libemu.a are distributed under the terms of the GNU Library General
- Public License, rather than the GNU GPL.
-
-* Any existing copyright or authorship information in any given source
- file must remain intact. If you modify a source file, a notice to that
- effect must be added to the authorship information in the source file.
-
-* Runtime binaries, as provided by DJ in DJGPP, may be distributed
- without sources ONLY if the recipient is given sufficient information
- to obtain a copy of djgpp themselves. This primarily applies to
- go32-v2.exe, emu387.dxe, and stubedit.exe.
-
-* Runtime objects and libraries, as provided by DJ in DJGPP, when
- linked into an application, may be distributed without sources ONLY
- if the recipient is given sufficient information to obtain a copy of
- djgpp themselves. This primarily applies to crt0.o and libc.a.
-
------
-
-Changes to source code copyright BSD, FSF, or others, by DJ Delorie
-fall under the terms of the original copyright. Such files usually
-have multiple copyright notices in them.
-
-A copy of the files "COPYING" and "COPYING.LIB" are included with this
-document. If you did not receive a copy of these files, you may
-obtain one from whence this document was obtained, or by writing:
-
- Free Software Foundation
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307
- USA
diff --git a/os/dos/exe2coff/copying.lib b/os/dos/exe2coff/copying.lib
deleted file mode 100644
index bbe3fe1987..0000000000
--- a/os/dos/exe2coff/copying.lib
+++ /dev/null
@@ -1,481 +0,0 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/os/dos/exe2coff/exe2coff.c b/os/dos/exe2coff/exe2coff.c
deleted file mode 100644
index aa072e8e41..0000000000
--- a/os/dos/exe2coff/exe2coff.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
-/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-/* Updated 2008 to use fread/fopen and friends instead of read/open so it compiles with GCC on Unix (Rubidium) */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-static void
-exe2aout(char *fname)
-{
- unsigned short header[3];
- FILE *ifile;
- FILE *ofile;
- char buf[4096];
- int rbytes;
- char *dot = strrchr(fname, '.');
- if (!dot || strlen(dot) != 4
- || tolower(dot[1]) != 'e'
- || tolower(dot[2]) != 'x'
- || tolower(dot[3]) != 'e')
- {
- fprintf(stderr, "%s: Arguments MUST end with a .exe extension\n", fname);
- return;
- }
-
- ifile = fopen(fname, "rb");
- if (!ifile)
- {
- perror(fname);
- return;
- }
- fread(header, sizeof(header), 1, ifile);
- if (header[0] == 0x5a4d)
- {
- long header_offset = (long)header[2]*512L;
- if (header[1])
- header_offset += (long)header[1] - 512L;
- fseek(ifile, header_offset, SEEK_SET);
- header[0] = 0;
- fread(header, sizeof(header), 1, ifile);
- if ((header[0] != 0x010b) && (header[0] != 0x014c))
- {
- fprintf(stderr, "`%s' does not have a COFF/AOUT program appended to it\n", fname);
- return;
- }
- fseek(ifile, header_offset, SEEK_SET);
- }
- else
- {
- fprintf(stderr, "`%s' is not an .EXE file\n", fname);
- return;
- }
-
- *dot = 0;
- ofile = fopen(fname, "w+b");
- if (!ofile)
- {
- perror(fname);
- return;
- }
-
- while ((rbytes=fread(buf, 1, 4096, ifile)) > 0)
- {
- int wb = fwrite(buf, 1, rbytes, ofile);
- if (wb < 0)
- {
- perror(fname);
- break;
- }
- if (wb < rbytes)
- {
- fprintf(stderr, "`%s': disk full\n", fname);
- exit(1);
- }
- }
- fclose(ifile);
- fclose(ofile);
-}
-
-int
-main(int argc, char **argv)
-{
- int i;
- if (argc == 1) printf("Usage: %s ", argv[0]);
- for (i=1; i binary.exe || exit
-mv binary.exe $1
-rm binary exe2coff/exe2coff
diff --git a/os/os2/installer/make_installer.cmd b/os/os2/installer/make_installer.cmd
index a15198b5f1..3addeca1ae 100644
--- a/os/os2/installer/make_installer.cmd
+++ b/os/os2/installer/make_installer.cmd
@@ -1,6 +1,6 @@
@echo off
-set OPENTTD_VERSION=1.9.0
+set OPENTTD_VERSION=1.10.0
set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0
diff --git a/os/rpm/openttd.spec b/os/rpm/openttd.spec
index d16230f312..09d19621fe 100644
--- a/os/rpm/openttd.spec
+++ b/os/rpm/openttd.spec
@@ -17,9 +17,9 @@
#
Name: openttd
-Version: 1.9.beta2
+Version: 1.10.beta1
Release: 0
-%define srcver 1.9.0-beta2
+%define srcver 1.10.0-beta1
Summary: An open source reimplementation of Chris Sawyer's Transport Tycoon Deluxe
License: GPL-2.0
Group: Amusements/Games/Strategy/Other
diff --git a/os/windows/installer/install.nsi b/os/windows/installer/install.nsi
index d0c933ca21..a0ca6ee6be 100644
--- a/os/windows/installer/install.nsi
+++ b/os/windows/installer/install.nsi
@@ -1,9 +1,9 @@
# Version numbers to update
!define APPV_MAJOR 1
-!define APPV_MINOR 9
+!define APPV_MINOR 10
!define APPV_MAINT 0
-!define APPV_BUILD 1
-!define APPV_EXTRA "-beta2"
+!define APPV_BUILD 0
+!define APPV_EXTRA "-beta1"
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
@@ -24,6 +24,7 @@
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "top.bmp"
+ManifestDPIAware true
BrandingText "OpenTTD Installer"
SetCompressor LZMA
diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs
index a2f348faf0..10b38d35a1 100755
--- a/projects/determineversion.vbs
+++ b/projects/determineversion.vbs
@@ -21,7 +21,7 @@ Sub FindReplaceInFile(filename, to_find, replacement)
file.Close
End Sub
-Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, filename)
+Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, isstabletag, filename)
FSO.CopyFile filename & ".in", filename
FindReplaceInFile filename, "!!MODIFIED!!", modified
FindReplaceInFile filename, "!!ISODATE!!", isodate
@@ -29,10 +29,11 @@ Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, filename)
FindReplaceInFile filename, "!!DATE!!", cur_date
FindReplaceInFile filename, "!!GITHASH!!", githash
FindReplaceInFile filename, "!!ISTAG!!", istag
+ FindReplaceInFile filename, "!!ISSTABLETAG!!", isstabletag
End Sub
Sub UpdateFiles(version)
- Dim modified, isodate, cur_date, githash, istag
+ Dim modified, isodate, cur_date, githash, istag, isstabletag
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
If InStr(version, Chr(9)) Then
@@ -41,20 +42,23 @@ Sub UpdateFiles(version)
modified = Mid(isodate, InStr(isodate, Chr(9)) + 1)
githash = Mid(modified, InStr(modified, Chr(9)) + 1)
istag = Mid(githash, InStr(githash, Chr(9)) + 1)
+ isstabletag = Mid(istag, InStr(istag, Chr(9)) + 1)
' Remove tails from fields
version = Mid(version, 1, InStr(version, Chr(9)) - 1)
isodate = Mid(isodate, 1, InStr(isodate, Chr(9)) - 1)
modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1)
githash = Mid(githash, 1, InStr(githash, Chr(9)) - 1)
+ istag = Mid(istag, 1, InStr(istag, Chr(9)) - 1)
Else
isodate = 0
modified = 1
githash = ""
istag = 0
+ isstabletag = 0
End If
- UpdateFile modified, isodate, version, cur_date, githash, istag, "../src/rev.cpp"
- UpdateFile modified, isodate, version, cur_date, githash, istag, "../src/os/windows/ottdres.rc"
+ UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, "../src/rev.cpp"
+ UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, "../src/os/windows/ottdres.rc"
End Sub
Function DetermineVersion()
@@ -143,7 +147,7 @@ Function DetermineVersion()
DetermineVersion = "norev000"
modified = 1
Else
- Dim version, hashprefix, istag
+ Dim version, hashprefix, istag, isstabletag
If modified = 0 Then
hashprefix = "-g"
ElseIf modified = 2 Then
@@ -155,12 +159,21 @@ Function DetermineVersion()
If tag <> "" Then
version = tag
istag = 1
+
+ Set stable_regexp = New RegExp
+ stable_regexp.Pattern = "^[0-9.]*$"
+ If stable_regexp.Test(tag) Then
+ isstabletag = 1
+ Else
+ isstabletag = 0
+ End If
Else
version = isodate & "-" & branch & hashprefix & shorthash
istag = 0
+ isstabletag = 0
End If
- DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash & Chr(9) & istag
+ DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash & Chr(9) & istag & Chr(9) & isstabletag
End If
End Function
diff --git a/projects/generate b/projects/generate
index cfedc8b32d..2ab89e8f1b 100755
--- a/projects/generate
+++ b/projects/generate
@@ -132,14 +132,14 @@ load_main_data() {
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
- if ($0 == "BEOS" && "'$os'" != "BEOS") { next; }
+ if ($0 == "HAIKU" && "'$os'" != "HAIKU") { next; }
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
"'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }
if ($0 == "FLUIDSYNTH" && "'$enable_fluidsynth'" != "1") { next; }
- if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
- if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
+ if ($0 == "USE_XAUDIO2" && "'$with_xaudio2'" == "0") { next; }
+ if ($0 == "USE_THREADS" && "'$with_threads'" == "0") { next; }
skip += 1;
diff --git a/projects/generate.vbs b/projects/generate.vbs
index aa91bd3164..06e037c4cd 100644
--- a/projects/generate.vbs
+++ b/projects/generate.vbs
@@ -179,8 +179,9 @@ Sub load_main_data(filename, ByRef vcxproj, ByRef filters, ByRef files)
line = "MSVC" Or _
line = "DIRECTMUSIC" Or _
line = "AI" Or _
- line = "SSE" Or _
- line = "HAVE_THREAD" _
+ line = "USE_SSE" Or _
+ line = "USE_XAUDIO2" Or _
+ line = "USE_THREADS" _
) Then skip = skip + 1
deep = deep + 1
Case "#"
diff --git a/projects/generate_vs142.vcxproj b/projects/generate_vs142.vcxproj
index 3e55d7a1d4..7230676cb5 100644
--- a/projects/generate_vs142.vcxproj
+++ b/projects/generate_vs142.vcxproj
@@ -10,7 +10,6 @@
generate
{2F31FD79-D1AC-43C4-89F3-B0D5E4E53E34}
generate
- 8.1
diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj
index 44d8cd4352..720a704490 100644
--- a/projects/openttd_vs140.vcxproj
+++ b/projects/openttd_vs140.vcxproj
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -410,7 +410,6 @@
-
@@ -449,6 +448,7 @@
+
@@ -624,7 +624,6 @@
-
@@ -648,6 +647,7 @@
+
@@ -682,6 +682,7 @@
+
@@ -698,6 +699,7 @@
+
@@ -728,6 +730,7 @@
+
@@ -1291,8 +1294,6 @@
-
-
@@ -1336,8 +1337,7 @@
-
-
+
diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters
index 65919e69dc..6bbd8a517a 100644
--- a/projects/openttd_vs140.vcxproj.filters
+++ b/projects/openttd_vs140.vcxproj.filters
@@ -318,9 +318,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -435,6 +432,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -960,9 +960,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -1032,6 +1029,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1134,6 +1134,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1182,6 +1185,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1272,6 +1278,9 @@
Core Source Code
+
+ Core Source Code
+
Core Source Code
@@ -2961,12 +2970,6 @@
Pathfinder
-
- Pathfinder
-
-
- Pathfinder
-
Pathfinder
@@ -3096,12 +3099,9 @@
Windows files
-
+
Threading
-
- Threading
-
diff --git a/projects/openttd_vs140.vcxproj.in b/projects/openttd_vs140.vcxproj.in
index 951f8b6048..17b4356cc2 100644
--- a/projects/openttd_vs140.vcxproj.in
+++ b/projects/openttd_vs140.vcxproj.in
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
diff --git a/projects/openttd_vs141.vcxproj b/projects/openttd_vs141.vcxproj
index 9c06bf94cb..95743cdb89 100644
--- a/projects/openttd_vs141.vcxproj
+++ b/projects/openttd_vs141.vcxproj
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -410,7 +410,6 @@
-
@@ -449,6 +448,7 @@
+
@@ -624,7 +624,6 @@
-
@@ -648,6 +647,7 @@
+
@@ -682,6 +682,7 @@
+
@@ -698,6 +699,7 @@
+
@@ -728,6 +730,7 @@
+
@@ -1291,8 +1294,6 @@
-
-
@@ -1336,8 +1337,7 @@
-
-
+
diff --git a/projects/openttd_vs141.vcxproj.filters b/projects/openttd_vs141.vcxproj.filters
index 65919e69dc..6bbd8a517a 100644
--- a/projects/openttd_vs141.vcxproj.filters
+++ b/projects/openttd_vs141.vcxproj.filters
@@ -318,9 +318,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -435,6 +432,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -960,9 +960,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -1032,6 +1029,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1134,6 +1134,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1182,6 +1185,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1272,6 +1278,9 @@
Core Source Code
+
+ Core Source Code
+
Core Source Code
@@ -2961,12 +2970,6 @@
Pathfinder
-
- Pathfinder
-
-
- Pathfinder
-
Pathfinder
@@ -3096,12 +3099,9 @@
Windows files
-
+
Threading
-
- Threading
-
diff --git a/projects/openttd_vs141.vcxproj.in b/projects/openttd_vs141.vcxproj.in
index d28f500f1c..0b04ebacce 100644
--- a/projects/openttd_vs141.vcxproj.in
+++ b/projects/openttd_vs141.vcxproj.in
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
diff --git a/projects/openttd_vs142.vcxproj b/projects/openttd_vs142.vcxproj
index 34f7c5f280..99b4f9ce3c 100644
--- a/projects/openttd_vs142.vcxproj
+++ b/projects/openttd_vs142.vcxproj
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -410,7 +410,6 @@
-
@@ -449,6 +448,7 @@
+
@@ -622,8 +622,8 @@
+
-
@@ -647,6 +647,7 @@
+
@@ -681,6 +682,7 @@
+
@@ -697,6 +699,7 @@
+
@@ -719,12 +722,15 @@
+
+
+
@@ -1288,8 +1294,6 @@
-
-
@@ -1333,8 +1337,7 @@
-
-
+
diff --git a/projects/openttd_vs142.vcxproj.filters b/projects/openttd_vs142.vcxproj.filters
index e93c94f1f7..6bbd8a517a 100644
--- a/projects/openttd_vs142.vcxproj.filters
+++ b/projects/openttd_vs142.vcxproj.filters
@@ -318,9 +318,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -435,6 +432,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -954,10 +954,10 @@
Header Files
-
+
Header Files
-
+
Header Files
@@ -1029,6 +1029,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1131,6 +1134,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1179,6 +1185,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -1245,6 +1254,12 @@
Core Source Code
+
+ Core Source Code
+
+
+ Core Source Code
+
Core Source Code
@@ -1263,6 +1278,9 @@
Core Source Code
+
+ Core Source Code
+
Core Source Code
@@ -2952,12 +2970,6 @@
Pathfinder
-
- Pathfinder
-
-
- Pathfinder
-
Pathfinder
@@ -3087,12 +3099,9 @@
Windows files
-
+
Threading
-
- Threading
-
diff --git a/projects/openttd_vs142.vcxproj.in b/projects/openttd_vs142.vcxproj.in
index 91689e8bde..37f0d6cf92 100644
--- a/projects/openttd_vs142.vcxproj.in
+++ b/projects/openttd_vs142.vcxproj.in
@@ -107,7 +107,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -172,7 +172,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
@@ -230,7 +230,7 @@
Size
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
+ NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)
true
Sync
MultiThreaded
@@ -293,7 +293,7 @@
Disabled
true
..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)
- _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
+ _DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LIBLZMA;WITH_PNG;WITH_FREETYPE;WITH_UNISCRIBE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
diff --git a/projects/settingsgen_vs142.vcxproj b/projects/settingsgen_vs142.vcxproj
index ca0418c15c..23a4e18562 100644
--- a/projects/settingsgen_vs142.vcxproj
+++ b/projects/settingsgen_vs142.vcxproj
@@ -10,7 +10,6 @@
settingsgen
{E9548DE9-F089-49B7-93A6-30BE2CC311C7}
settings
- 8.1
diff --git a/projects/strgen_vs142.vcxproj b/projects/strgen_vs142.vcxproj
index 5329d68daa..eb0657a30b 100644
--- a/projects/strgen_vs142.vcxproj
+++ b/projects/strgen_vs142.vcxproj
@@ -10,7 +10,6 @@
strgen
{A133A442-BD0A-4ADE-B117-AD7545E4BDD1}
strgen
- 8.1
diff --git a/source.list b/source.list
index de1504a9c3..ad98c0c2f8 100644
--- a/source.list
+++ b/source.list
@@ -71,9 +71,6 @@ rev.cpp
road.cpp
roadstop.cpp
screenshot.cpp
-#if SDL
- sdl.cpp
-#end
settings.cpp
signal.cpp
signs.cpp
@@ -113,8 +110,8 @@ townname.cpp
vehicle.cpp
vehiclelist.cpp
viewport.cpp
-#if SSE
-viewport_sprite_sorter_sse4.cpp
+#if USE_SSE
+ viewport_sprite_sorter_sse4.cpp
#end
waypoint.cpp
widget.cpp
@@ -138,6 +135,7 @@ autoslope.h
base_media_base.h
base_media_func.h
base_station_base.h
+bitmap_type.h
bmp.h
bridge.h
cargo_type.h
@@ -313,7 +311,6 @@ roadveh.h
safeguards.h
scope.h
screenshot.h
-sdl.h
sound/sdl_s.h
video/sdl_v.h
settings_func.h
@@ -337,6 +334,7 @@ spritecache.h
station_base.h
station_func.h
station_gui.h
+station_kdtree.h
station_type.h
statusbar_gui.h
stdafx.h
@@ -371,6 +369,7 @@ timetable.h
toolbar_gui.h
town.h
town_type.h
+town_kdtree.h
townname_func.h
townname_type.h
track_func.h
@@ -387,6 +386,7 @@ vehicle_gui_base.h
vehicle_type.h
vehiclelist.h
viewport_func.h
+viewport_kdtree.h
viewport_sprite_sorter.h
viewport_type.h
water.h
@@ -405,20 +405,19 @@ zoom_func.h
zoom_type.h
#if WIN32
#else
-music/bemidi.h
-music/cocoa_m.h
-music/extmidi.h
-music/libtimidity.h
-music/fluidsynth.h
-music/os2_m.h
-music/qtmidi.h
-os/macosx/macos.h
-os/macosx/osx_stdafx.h
-os/macosx/splash.h
-os/macosx/string_osx.h
-sound/cocoa_s.h
-video/cocoa/cocoa_keys.h
-video/cocoa/cocoa_v.h
+ music/bemidi.h
+ music/cocoa_m.h
+ music/extmidi.h
+ music/fluidsynth.h
+ music/os2_m.h
+ music/qtmidi.h
+ os/macosx/macos.h
+ os/macosx/osx_stdafx.h
+ os/macosx/splash.h
+ os/macosx/string_osx.h
+ sound/cocoa_s.h
+ video/cocoa/cocoa_keys.h
+ video/cocoa/cocoa_v.h
#end
# Core Source Code
@@ -436,6 +435,7 @@ core/enum_type.hpp
core/geometry_func.cpp
core/geometry_func.hpp
core/geometry_type.hpp
+core/kdtree.hpp
core/math_func.cpp
core/math_func.hpp
core/mem_func.hpp
@@ -920,36 +920,36 @@ script/api/script_window.cpp
# Blitters
#if DEDICATED
#else
-blitter/32bpp_anim.cpp
-blitter/32bpp_anim.hpp
-#if SSE
-blitter/32bpp_anim_sse2.cpp
-blitter/32bpp_anim_sse2.hpp
-blitter/32bpp_anim_sse4.cpp
-blitter/32bpp_anim_sse4.hpp
-#end
-blitter/32bpp_base.cpp
-blitter/32bpp_base.hpp
-blitter/32bpp_optimized.cpp
-blitter/32bpp_optimized.hpp
-blitter/32bpp_simple.cpp
-blitter/32bpp_simple.hpp
-#if SSE
-blitter/32bpp_sse_func.hpp
-blitter/32bpp_sse_type.h
-blitter/32bpp_sse2.cpp
-blitter/32bpp_sse2.hpp
-blitter/32bpp_sse4.cpp
-blitter/32bpp_sse4.hpp
-blitter/32bpp_ssse3.cpp
-blitter/32bpp_ssse3.hpp
-#end
-blitter/8bpp_base.cpp
-blitter/8bpp_base.hpp
-blitter/8bpp_optimized.cpp
-blitter/8bpp_optimized.hpp
-blitter/8bpp_simple.cpp
-blitter/8bpp_simple.hpp
+ blitter/32bpp_anim.cpp
+ blitter/32bpp_anim.hpp
+ #if USE_SSE
+ blitter/32bpp_anim_sse2.cpp
+ blitter/32bpp_anim_sse2.hpp
+ blitter/32bpp_anim_sse4.cpp
+ blitter/32bpp_anim_sse4.hpp
+ #end
+ blitter/32bpp_base.cpp
+ blitter/32bpp_base.hpp
+ blitter/32bpp_optimized.cpp
+ blitter/32bpp_optimized.hpp
+ blitter/32bpp_simple.cpp
+ blitter/32bpp_simple.hpp
+ #if USE_SSE
+ blitter/32bpp_sse_func.hpp
+ blitter/32bpp_sse_type.h
+ blitter/32bpp_sse2.cpp
+ blitter/32bpp_sse2.hpp
+ blitter/32bpp_sse4.cpp
+ blitter/32bpp_sse4.hpp
+ blitter/32bpp_ssse3.cpp
+ blitter/32bpp_ssse3.hpp
+ #end
+ blitter/8bpp_base.cpp
+ blitter/8bpp_base.hpp
+ blitter/8bpp_optimized.cpp
+ blitter/8bpp_optimized.hpp
+ blitter/8bpp_simple.cpp
+ blitter/8bpp_simple.hpp
#end
blitter/base.hpp
blitter/common.hpp
@@ -1052,8 +1052,6 @@ network/core/udp.h
# Pathfinder
pathfinder/follow_track.hpp
-pathfinder/opf/opf_ship.cpp
-pathfinder/opf/opf_ship.h
pathfinder/pathfinder_func.h
pathfinder/pathfinder_type.h
pathfinder/pf_performance_timer.hpp
@@ -1091,67 +1089,60 @@ video/dedicated_v.cpp
video/null_v.cpp
#if DEDICATED
#else
-#if ALLEGRO
- video/allegro_v.cpp
-#end
-#if SDL
- video/sdl_v.cpp
-#end
-#if WIN32
- video/win32_v.cpp
-#end
+ #if ALLEGRO
+ video/allegro_v.cpp
+ #end
+ #if SDL
+ video/sdl_v.cpp
+ #end
+ #if WIN32
+ video/win32_v.cpp
+ #end
#end
# Music
#if DEDICATED
#else
-#if ALLEGRO
- music/allegro_m.cpp
-#end
-#if DIRECTMUSIC
- music/dmusic.cpp
-#end
+ #if ALLEGRO
+ music/allegro_m.cpp
+ #end
+ #if DIRECTMUSIC
+ music/dmusic.cpp
+ #end
#end
music/null_m.cpp
music/midifile.cpp
#if DEDICATED
#else
-#if WIN32
- music/win32_m.cpp
-#else
- #if DOS
+ #if WIN32
+ music/win32_m.cpp
#else
- #if MORPHOS
- #else
- music/extmidi.cpp
- #end
+ music/extmidi.cpp
+ #end
+ #if HAIKU
+ music/bemidi.cpp
+ #end
+ #if FLUIDSYNTH
+ music/fluidsynth.cpp
#end
-#end
-#if BEOS
- music/bemidi.cpp
-#end
-#if LIBTIMIDITY
- music/libtimidity.cpp
-#end
-#if FLUIDSYNTH
- music/fluidsynth.cpp
-#end
#end
# Sound
sound/null_s.cpp
#if DEDICATED
#else
-#if ALLEGRO
- sound/allegro_s.cpp
-#end
-#if SDL
- sound/sdl_s.cpp
-#end
-#if WIN32
- sound/win32_s.cpp
- sound/xaudio2_s.cpp
-#end
+ #if ALLEGRO
+ sound/allegro_s.cpp
+ #end
+ #if SDL
+ sound/sdl_s.cpp
+ #end
+ #if WIN32
+ sound/win32_s.cpp
+ #if USE_XAUDIO2
+ sound/xaudio2_s.cpp
+ #end
+ #end
#end
#if OSX
@@ -1185,21 +1176,4 @@ sound/null_s.cpp
#end
# Threading
-thread/thread.h
-#if HAVE_THREAD
- #if WIN32
- thread/thread_win32.cpp
- #else
- #if OS2
- thread/thread_os2.cpp
- #else
- #if MORPHOS
- thread/thread_morphos.cpp
- #else
- thread/thread_pthread.cpp
- #end
- #end
- #end
-#else
- thread/thread_none.cpp
-#end
+thread.h
diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp
index 1b5b6c07da..bd9544b9f3 100644
--- a/src/ai/ai.hpp
+++ b/src/ai/ai.hpp
@@ -164,11 +164,9 @@ public:
/** Gets the ScriptScanner instance that is used to find AI Libraries */
static AIScannerLibrary *GetScannerLibrary();
-#if defined(ENABLE_NETWORK)
/** Wrapper function for AIScanner::HasAI */
static bool HasAI(const struct ContentInfo *ci, bool md5sum);
static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
-#endif
private:
static uint frame_counter; ///< Tick counter for the AI code
static class AIScannerInfo *scanner_info; ///< ScriptScanner instance that is used to find AIs
diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp
index 30c6f84bbd..9f667a6127 100644
--- a/src/ai/ai_config.hpp
+++ b/src/ai/ai_config.hpp
@@ -30,9 +30,9 @@ public:
class AIInfo *GetInfo() const;
- /* virtual */ int GetSetting(const char *name) const;
- /* virtual */ void SetSetting(const char *name, int value);
- /* virtual */ void AddRandomDeviation();
+ int GetSetting(const char *name) const override;
+ void SetSetting(const char *name, int value) override;
+ void AddRandomDeviation() override;
/**
* When ever the AI Scanner is reloaded, all infos become invalid. This
@@ -45,9 +45,9 @@ public:
bool ResetInfo(bool force_exact_match);
protected:
- /* virtual */ void PushExtraConfigList();
- /* virtual */ void ClearConfigList();
- /* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match);
+ void PushExtraConfigList() override;
+ void ClearConfigList() override;
+ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override;
};
#endif /* AI_CONFIG_HPP */
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index d4ff233116..ff2fc286a0 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -16,6 +16,7 @@
#include "../company_func.h"
#include "../network/network.h"
#include "../window_func.h"
+#include "../framerate_type.h"
#include "ai_scanner.hpp"
#include "ai_instance.hpp"
#include "ai_config.hpp"
@@ -79,8 +80,11 @@
const Company *c;
FOR_ALL_COMPANIES(c) {
if (c->is_ai) {
+ PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
cur_company.Change(c->index);
c->ai_instance->GameLoop();
+ } else {
+ PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + c->index));
}
}
cur_company.Restore();
@@ -101,6 +105,7 @@
/* static */ void AI::Stop(CompanyID company)
{
if (_networking && !_network_server) return;
+ PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
Backup cur_company(_current_company, company, FILE_LINE);
Company *c = Company::Get(company);
@@ -357,8 +362,6 @@
InvalidateWindowClassesData(WC_AI_SETTINGS);
}
-#if defined(ENABLE_NETWORK)
-
/**
* Check whether we have an AI (library) with the exact characteristics as ci.
* @param ci the characteristics to search on (shortname and md5sum)
@@ -375,8 +378,6 @@
return AI::scanner_library->HasScript(ci, md5sum);
}
-#endif /* defined(ENABLE_NETWORK) */
-
/* static */ AIScannerInfo *AI::GetScannerInfo()
{
return AI::scanner_info;
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index dbdd772452..2730070c32 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -98,7 +98,7 @@ struct AIListWindow : public Window {
}
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_AIL_CAPTION:
@@ -107,7 +107,7 @@ struct AIListWindow : public Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_AIL_LIST) {
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
@@ -118,7 +118,7 @@ struct AIListWindow : public Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_AIL_LIST: {
@@ -183,7 +183,7 @@ struct AIListWindow : public Window {
DeleteWindowByClass(WC_QUERY_STRING);
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_AIL_LIST: { // Select one of the AIs
@@ -211,7 +211,7 @@ struct AIListWindow : public Window {
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_AIL_LIST);
}
@@ -221,7 +221,7 @@ struct AIListWindow : public Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
delete this;
@@ -317,7 +317,7 @@ struct AISettingsWindow : public Window {
this->RebuildVisibleSettings();
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_AIS_CAPTION:
@@ -346,7 +346,7 @@ struct AISettingsWindow : public Window {
this->vscroll->SetCount((int)this->visible_settings.size());
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_AIS_BACKGROUND) {
this->line_height = max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
@@ -357,7 +357,7 @@ struct AISettingsWindow : public Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_AIS_BACKGROUND) return;
@@ -421,7 +421,7 @@ struct AISettingsWindow : public Window {
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
if (this->closing_dropdown) {
this->closing_dropdown = false;
@@ -430,7 +430,7 @@ struct AISettingsWindow : public Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_AIS_BACKGROUND: {
@@ -481,7 +481,7 @@ struct AISettingsWindow : public Window {
DropDownList *list = new DropDownList();
for (int i = config_item.min_value; i <= config_item.max_value; i++) {
- *list->Append() = new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false);
+ list->push_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false));
}
ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true);
@@ -530,7 +530,7 @@ struct AISettingsWindow : public Window {
}
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (StrEmpty(str)) return;
VisibleSettingsList::const_iterator it = this->visible_settings.begin();
@@ -542,7 +542,7 @@ struct AISettingsWindow : public Window {
this->SetDirty();
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
assert(this->clicked_dropdown);
VisibleSettingsList::const_iterator it = this->visible_settings.begin();
@@ -553,7 +553,7 @@ struct AISettingsWindow : public Window {
this->SetDirty();
}
- virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
+ void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
{
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
@@ -564,12 +564,12 @@ struct AISettingsWindow : public Window {
this->SetDirty();
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_AIS_BACKGROUND);
}
- virtual void OnRealtimeTick(uint delta_ms)
+ void OnRealtimeTick(uint delta_ms) override
{
if (this->timeout.Elapsed(delta_ms)) {
this->clicked_button = -1;
@@ -582,9 +582,11 @@ struct AISettingsWindow : public Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
this->RebuildVisibleSettings();
+ HideDropDownMenu(this);
+ DeleteChildWindows(WC_QUERY_STRING);
}
private:
@@ -644,7 +646,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
}
- /* virtual */ void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
if (widget == WID_TF_CAPTION) {
SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI);
@@ -741,7 +743,7 @@ struct AIConfigWindow : public Window {
DeleteWindowByClass(WC_AI_SETTINGS);
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_AIC_NUMBER:
@@ -765,7 +767,7 @@ struct AIConfigWindow : public Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_AIC_GAMELIST:
@@ -817,7 +819,7 @@ struct AIConfigWindow : public Window {
return slot < max_slot;
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_AIC_GAMELIST: {
@@ -856,7 +858,7 @@ struct AIConfigWindow : public Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_END) {
if (this->selected_slot == INVALID_COMPANY || GetConfig(this->selected_slot) == NULL) return;
@@ -926,9 +928,7 @@ struct AIConfigWindow : public Window {
if (!_network_available) {
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
} else {
-#if defined(ENABLE_NETWORK)
ShowNetworkContentListWindow(NULL, CONTENT_TYPE_AI, CONTENT_TYPE_GAME);
-#endif
}
break;
}
@@ -939,7 +939,7 @@ struct AIConfigWindow : public Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!IsEditable(this->selected_slot)) {
this->selected_slot = INVALID_COMPANY;
@@ -1096,7 +1096,7 @@ struct AIDebugWindow : public Window {
this->InvalidateData(-1);
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_AID_LOG_PANEL) {
resize->height = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
@@ -1104,7 +1104,7 @@ struct AIDebugWindow : public Window {
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
this->SelectValidDebugCompany();
@@ -1182,7 +1182,7 @@ struct AIDebugWindow : public Window {
this->last_vscroll_pos = this->vscroll->GetPosition();
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_AID_NAME_TEXT:
@@ -1205,7 +1205,7 @@ struct AIDebugWindow : public Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (ai_debug_company == INVALID_COMPANY) return;
@@ -1264,7 +1264,7 @@ struct AIDebugWindow : public Window {
this->last_vscroll_pos = this->vscroll->GetPosition();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
/* Also called for hotkeys, so check for disabledness */
if (this->IsWidgetDisabled(widget)) return;
@@ -1282,7 +1282,7 @@ struct AIDebugWindow : public Window {
case WID_AID_RELOAD_TOGGLE:
if (ai_debug_company == OWNER_DEITY) break;
/* First kill the company of the AI, then start a new one. This should start the current AI again */
- DoCommandP(0, CCA_DELETE | ai_debug_company << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | ai_debug_company << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
DoCommandP(0, CCA_NEW_AI | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
break;
@@ -1334,7 +1334,7 @@ struct AIDebugWindow : public Window {
}
}
- virtual void OnEditboxChanged(int wid)
+ void OnEditboxChanged(int wid) override
{
if (wid == WID_AID_BREAK_STR_EDIT_BOX) {
/* Save the current string to static member so it can be restored next time the window is opened. */
@@ -1349,7 +1349,7 @@ struct AIDebugWindow : public Window {
* This is the company ID of the AI/GS which wrote a new log message, or -1 in other cases.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
/* If the log message is related to the active company tab, check the break string.
* This needs to be done in gameloop-scope, so the AI is suspended immediately. */
@@ -1406,7 +1406,7 @@ struct AIDebugWindow : public Window {
(ai_debug_company == OWNER_DEITY ? !Game::IsPaused() : !AI::IsPaused(ai_debug_company)));
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_AID_LOG_PANEL);
}
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index 43a4345460..62ddb2344f 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -29,7 +29,7 @@ static bool CheckAPIVersion(const char *api_version)
return strcmp(api_version, "0.7") == 0 || strcmp(api_version, "1.0") == 0 || strcmp(api_version, "1.1") == 0 ||
strcmp(api_version, "1.2") == 0 || strcmp(api_version, "1.3") == 0 || strcmp(api_version, "1.4") == 0 ||
strcmp(api_version, "1.5") == 0 || strcmp(api_version, "1.6") == 0 || strcmp(api_version, "1.7") == 0 ||
- strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0;
+ strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0 || strcmp(api_version, "1.10") == 0;
}
#if defined(_WIN32)
diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp
index 204bf9712a..06998558b3 100644
--- a/src/ai/ai_instance.hpp
+++ b/src/ai/ai_instance.hpp
@@ -25,14 +25,14 @@ public:
*/
void Initialize(class AIInfo *info);
- /* virtual */ int GetSetting(const char *name);
- /* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
+ int GetSetting(const char *name) override;
+ ScriptInfo *FindLibrary(const char *library, int version) override;
private:
- /* virtual */ void RegisterAPI();
- /* virtual */ void Died();
- /* virtual */ CommandCallback *GetDoCommandCallback();
- /* virtual */ void LoadDummyScript();
+ void RegisterAPI() override;
+ void Died() override;
+ CommandCallback *GetDoCommandCallback() override;
+ void LoadDummyScript() override;
};
#endif /* AI_INSTANCE_HPP */
diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp
index d8e8a6993d..dafc340beb 100644
--- a/src/ai/ai_scanner.hpp
+++ b/src/ai/ai_scanner.hpp
@@ -19,7 +19,7 @@ public:
AIScannerInfo();
~AIScannerInfo();
- /* virtual */ void Initialize();
+ void Initialize() override;
/**
* Select a random AI.
@@ -42,11 +42,11 @@ public:
void SetDummyAI(class AIInfo *info);
protected:
- /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
- /* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
- /* virtual */ Subdirectory GetDirectory() const { return AI_DIR; }
- /* virtual */ const char *GetScannerName() const { return "AIs"; }
- /* virtual */ void RegisterAPI(class Squirrel *engine);
+ void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
+ const char *GetFileName() const override { return PATHSEP "info.nut"; }
+ Subdirectory GetDirectory() const override { return AI_DIR; }
+ const char *GetScannerName() const override { return "AIs"; }
+ void RegisterAPI(class Squirrel *engine) override;
private:
AIInfo *info_dummy; ///< The dummy AI.
@@ -54,7 +54,7 @@ private:
class AIScannerLibrary : public ScriptScanner {
public:
- /* virtual */ void Initialize();
+ void Initialize() override;
/**
* Find a library in the pool.
@@ -65,11 +65,11 @@ public:
class AILibrary *FindLibrary(const char *library, int version);
protected:
- /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
- /* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
- /* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; }
- /* virtual */ const char *GetScannerName() const { return "AI Libraries"; }
- /* virtual */ void RegisterAPI(class Squirrel *engine);
+ void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
+ const char *GetFileName() const override { return PATHSEP "library.nut"; }
+ Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
+ const char *GetScannerName() const override { return "AI Libraries"; }
+ void RegisterAPI(class Squirrel *engine) override;
};
#endif /* AI_SCANNER_HPP */
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index d6d99ae242..99c86d6e17 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -783,6 +783,7 @@ int GetAircraftFlightLevel(T *v, bool takeoff)
}
template int GetAircraftFlightLevel(DisasterVehicle *v, bool takeoff);
+template int GetAircraftFlightLevel(Aircraft *v, bool takeoff);
/**
* Find the entry point to an airport depending on direction which
@@ -1309,18 +1310,17 @@ static void CrashAirplane(Aircraft *v)
*/
static void MaybeCrashAirplane(Aircraft *v)
{
- if (_settings_game.vehicle.plane_crashes == 0) return;
Station *st = Station::Get(v->targetairport);
- /* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
- uint32 prob = (0x4000 << _settings_game.vehicle.plane_crashes);
+ uint32 prob;
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
!_cheats.no_jetcrash.value) {
- prob /= 20;
+ prob = 3276;
} else {
- prob /= 1500;
+ if (_settings_game.vehicle.plane_crashes == 0) return;
+ prob = (0x4000 << _settings_game.vehicle.plane_crashes) / 1500;
}
if (GB(Random(), 0, 22) > prob) return;
@@ -2103,7 +2103,19 @@ void UpdateAirplanesOnNewStation(const Station *st)
FOR_ALL_AIRCRAFT(v) {
if (!v->IsNormalAircraft() || v->targetairport != st->index) continue;
assert(v->state == FLYING);
+
+ Order *o = &v->current_order;
+ /* The aircraft is heading to a hangar, but the new station doesn't have one,
+ * or the aircraft can't land on the new station. Cancel current order. */
+ if (o->IsType(OT_GOTO_DEPOT) && !(o->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) && o->GetDestination() == st->index &&
+ (!st->airport.HasHangar() || !CanVehicleUseStation(v, st))) {
+ o->MakeDummy();
+ SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
+ }
v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation);
UpdateAircraftCache(v);
}
+
+ /* Heliports don't have a hangar. Invalidate all go to hangar orders from all aircraft. */
+ if (!st->airport.HasHangar()) RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, st->index, true);
}
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 243f91b247..7e16717894 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -87,14 +87,14 @@ struct BuildAirToolbarWindow : Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this;
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_AT_AIRPORT:
@@ -114,7 +114,7 @@ struct BuildAirToolbarWindow : Window {
}
- virtual void OnPlaceObject(Point pt, TileIndex tile)
+ void OnPlaceObject(Point pt, TileIndex tile) override
{
switch (this->last_user_action) {
case WID_AT_AIRPORT:
@@ -129,19 +129,19 @@ struct BuildAirToolbarWindow : Window {
}
}
- virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
+ void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
- virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
+ void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
}
}
- virtual void OnPlaceObjectAbort()
+ void OnPlaceObjectAbort() override
{
this->RaiseButtons();
@@ -219,7 +219,7 @@ class BuildAirportWindow : public PickerWindowBase {
DropDownList *list = new DropDownList();
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
- *list->Append() = new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false);
+ list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
}
return list;
@@ -268,7 +268,7 @@ public:
DeleteWindowById(WC_SELECT_STATION, 0);
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_AP_CLASS_DROPDOWN:
@@ -293,7 +293,7 @@ public:
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_AP_CLASS_DROPDOWN: {
@@ -357,7 +357,7 @@ public:
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_AP_AIRPORT_LIST: {
@@ -394,7 +394,7 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
this->DrawWidgets();
@@ -462,7 +462,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_AP_CLASS_DROPDOWN:
@@ -535,7 +535,7 @@ public:
this->SelectOtherAirport(-1);
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
assert(widget == WID_AP_CLASS_DROPDOWN);
_selected_airport_class = (AirportClassID)index;
@@ -543,7 +543,7 @@ public:
this->SelectFirstAvailableAirport(false);
}
- virtual void OnRealtimeTick(uint delta_ms)
+ void OnRealtimeTick(uint delta_ms) override
{
CheckRedrawStationCoverage(this);
}
diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp
index 2a4cd89583..24543529df 100644
--- a/src/animated_tile.cpp
+++ b/src/animated_tile.cpp
@@ -19,7 +19,7 @@
#include "safeguards.h"
/** The table/list with animated tiles. */
-SmallVector _animated_tiles;
+std::vector _animated_tiles;
/**
* Removes the given tile from the animated tile table.
@@ -27,10 +27,10 @@ SmallVector _animated_tiles;
*/
void DeleteAnimatedTile(TileIndex tile)
{
- TileIndex *to_remove = _animated_tiles.Find(tile);
- if (to_remove != _animated_tiles.End()) {
+ auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile);
+ if (to_remove != _animated_tiles.end()) {
/* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */
- _animated_tiles.ErasePreservingOrder(to_remove);
+ _animated_tiles.erase(to_remove);
MarkTileDirtyByTile(tile);
}
}
@@ -43,7 +43,7 @@ void DeleteAnimatedTile(TileIndex tile)
void AddAnimatedTile(TileIndex tile)
{
MarkTileDirtyByTile(tile);
- _animated_tiles.Include(tile);
+ include(_animated_tiles, tile);
}
/**
@@ -53,8 +53,8 @@ void AnimateAnimatedTiles()
{
PerformanceAccumulator framerate(PFE_GL_LANDSCAPE);
- const TileIndex *ti = _animated_tiles.Begin();
- while (ti < _animated_tiles.End()) {
+ const TileIndex *ti = _animated_tiles.data();
+ while (ti < _animated_tiles.data() + _animated_tiles.size()) {
const TileIndex curr = *ti;
AnimateTile(curr);
/* During the AnimateTile call, DeleteAnimatedTile could have been called,
@@ -75,5 +75,5 @@ void AnimateAnimatedTiles()
*/
void InitializeAnimatedTiles()
{
- _animated_tiles.Clear();
+ _animated_tiles.clear();
}
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 44ad587895..62ab5b0961 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -168,16 +168,16 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
* @param engine Model to investigate.
* @param[out] cargoes Total amount of units that can be transported, summed by cargo.
* @param[out] refits Whether a (possibly partial) refit for each cargo is possible.
+ * @param cargo_type Selected refitted cargo type
+ * @param cargo_capacity Capacity of selected refitted cargo type
*/
-void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits)
+void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits, CargoID cargo_type, uint16 cargo_capacity)
{
cargoes->Clear();
*refits = 0;
const Engine *e = Engine::Get(engine);
- CargoID cargo_type;
- uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
if (cargo_type < NUM_CARGO && cargo_capacity > 0) {
(*cargoes)[cargo_type] += cargo_capacity;
if (IsEngineRefittable(engine)) SetBit(*refits, cargo_type);
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 95568e3811..7a8a7fefd8 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -294,7 +294,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
if (refit_cargo == CT_INVALID) return CommandCost(); // incompatible cargoes
/* Build the new vehicle */
- cost = DoCommand(old_veh->tile, e, 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh));
+ cost = DoCommand(old_veh->tile, e | (CT_INVALID << 24), 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh));
if (cost.Failed()) return cost;
Vehicle *new_veh = Vehicle::Get(_new_vehicle_id);
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index eae0a378eb..78c2fdc31c 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -123,7 +123,7 @@ class ReplaceVehicleWindow : public Window {
byte side = draw_left ? 0 : 1;
GUIEngineList *list = &this->engines[side];
- list->Clear();
+ list->clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) {
@@ -140,7 +140,7 @@ class ReplaceVehicleWindow : public Window {
if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
}
- *list->Append() = eid;
+ list->push_back(eid);
if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
}
this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
@@ -160,8 +160,8 @@ class ReplaceVehicleWindow : public Window {
if (this->engines[0].NeedRebuild()) {
/* We need to rebuild the left engines list */
this->GenerateReplaceVehList(true);
- this->vscroll[0]->SetCount(this->engines[0].Length());
- if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
+ this->vscroll[0]->SetCount((uint)this->engines[0].size());
+ if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
this->sel_engine[0] = this->engines[0][0];
}
}
@@ -170,7 +170,7 @@ class ReplaceVehicleWindow : public Window {
/* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
if (this->sel_engine[0] == INVALID_ENGINE) {
/* Always empty the right engines list when nothing is selected in the left engines list */
- this->engines[1].Clear();
+ this->engines[1].clear();
this->sel_engine[1] = INVALID_ENGINE;
} else {
if (this->reset_sel_engine && this->sel_engine[0] != INVALID_ENGINE) {
@@ -180,11 +180,11 @@ class ReplaceVehicleWindow : public Window {
}
/* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
this->GenerateReplaceVehList(false);
- this->vscroll[1]->SetCount(this->engines[1].Length());
+ this->vscroll[1]->SetCount((uint)this->engines[1].size());
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
int position = 0;
- for (EngineID *it = this->engines[1].Begin(); it != this->engines[1].End(); ++it) {
- if (*it == this->sel_engine[1]) break;
+ for (EngineID &eid : this->engines[1]) {
+ if (eid == this->sel_engine[1]) break;
++position;
}
this->vscroll[1]->ScrollTowards(position);
@@ -237,7 +237,7 @@ public:
this->sel_group = id_g;
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_RV_SORT_ASCENDING_DESCENDING: {
@@ -316,7 +316,7 @@ public:
}
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_RV_CAPTION:
@@ -353,7 +353,7 @@ public:
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_RV_SORT_ASCENDING_DESCENDING:
@@ -384,7 +384,7 @@ public:
case WID_RV_RIGHT_MATRIX: {
int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
EngineID start = this->vscroll[side]->GetPosition(); // what is the offset for the start (scrolling)
- EngineID end = min(this->vscroll[side]->GetCapacity() + start, this->engines[side].Length());
+ EngineID end = min(this->vscroll[side]->GetCapacity() + start, (uint)this->engines[side].size());
/* Do the actual drawing */
DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
@@ -394,7 +394,7 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
@@ -423,9 +423,16 @@ public:
/* Draw details panels. */
for (int side = 0; side < 2; side++) {
if (this->sel_engine[side] != INVALID_ENGINE) {
+ /* Use default engine details without refitting */
+ const Engine *e = Engine::Get(this->sel_engine[side]);
+ TestedEngineDetails ted;
+ ted.cost = 0;
+ ted.cargo = e->GetDefaultCargoType();
+ ted.capacity = e->GetDisplayDefaultCapacity(&ted.mail_capacity);
+
NWidgetBase *nwi = this->GetWidget(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS);
int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
- nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side]);
+ nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side], ted);
needed_height = max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM);
}
}
@@ -437,7 +444,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_RV_SORT_ASCENDING_DESCENDING:
@@ -461,8 +468,8 @@ public:
case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
DropDownList *list = new DropDownList();
- *list->Append() = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false);
- *list->Append() = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false);
+ list->push_back(new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false));
+ list->push_back(new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false));
ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
break;
}
@@ -501,7 +508,7 @@ public:
click_side = 1;
}
uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
- size_t engine_count = this->engines[click_side].Length();
+ size_t engine_count = this->engines[click_side].size();
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
@@ -516,7 +523,7 @@ public:
}
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_RV_SORT_DROPDOWN:
@@ -557,7 +564,7 @@ public:
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX);
this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX);
@@ -568,7 +575,7 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (data != 0) {
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
diff --git a/src/base_media_base.h b/src/base_media_base.h
index b040abcf9d..5655401558 100644
--- a/src/base_media_base.h
+++ b/src/base_media_base.h
@@ -76,9 +76,9 @@ struct BaseSet {
{
free(this->name);
- for (TranslatedStrings::iterator iter = this->description.Begin(); iter != this->description.End(); iter++) {
- free(iter->first);
- free(iter->second);
+ for (auto &pair : this->description) {
+ free(pair.first);
+ free(pair.second);
}
for (uint i = 0; i < NUM_FILES; i++) {
@@ -122,16 +122,16 @@ struct BaseSet {
{
if (isocode != NULL) {
/* First the full ISO code */
- for (TranslatedStrings::const_iterator iter = this->description.Begin(); iter != this->description.End(); iter++) {
- if (strcmp(iter->first, isocode) == 0) return iter->second;
+ for (const auto &pair : this->description) {
+ if (strcmp(pair.first, isocode) == 0) return pair.second;
}
/* Then the first two characters */
- for (TranslatedStrings::const_iterator iter = this->description.Begin(); iter != this->description.End(); iter++) {
- if (strncmp(iter->first, isocode, 2) == 0) return iter->second;
+ for (const auto &pair : this->description) {
+ if (strncmp(pair.first, isocode, 2) == 0) return pair.second;
}
}
/* Then fall back */
- return this->description.Begin()->second;
+ return this->description.front().second;
}
/**
@@ -176,7 +176,7 @@ protected:
static Tbase_set *duplicate_sets; ///< All sets that aren't available, but needed for not downloading base sets when a newer version than the one on BaNaNaS is loaded.
static const Tbase_set *used_set; ///< The currently used set
- /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
+ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
/**
* Get the extension that is used to identify this set.
diff --git a/src/base_media_func.h b/src/base_media_func.h
index f7afca0edb..ed954360a0 100644
--- a/src/base_media_func.h
+++ b/src/base_media_func.h
@@ -277,7 +277,6 @@ template
return p;
}
-#if defined(ENABLE_NETWORK)
#include "network/network_content.h"
template const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
@@ -307,22 +306,6 @@ template
(TryGetBaseSetFile(ci, md5sum, BaseMedia::duplicate_sets) != NULL);
}
-#else
-
-template
-const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
-{
- return NULL;
-}
-
-template
-/* static */ bool BaseMedia::HasSet(const ContentInfo *ci, bool md5sum)
-{
- return false;
-}
-
-#endif /* ENABLE_NETWORK */
-
/**
* Count the number of available graphics sets.
* @return the number of sets
diff --git a/src/base_station_base.h b/src/base_station_base.h
index cd512c5177..8af01f8a70 100644
--- a/src/base_station_base.h
+++ b/src/base_station_base.h
@@ -110,6 +110,12 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
*/
virtual void UpdateVirtCoord() = 0;
+ virtual void MoveSign(TileIndex new_xy)
+ {
+ this->xy = new_xy;
+ this->UpdateVirtCoord();
+ }
+
/**
* Get the tile area for a given station type.
* @param ta tile area to fill.
diff --git a/src/bitmap_type.h b/src/bitmap_type.h
new file mode 100644
index 0000000000..11a4190938
--- /dev/null
+++ b/src/bitmap_type.h
@@ -0,0 +1,120 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file bitmap_type.hpp Bitmap functions. */
+
+#ifndef BITMAP_TYPE_HPP
+#define BITMAP_TYPE_HPP
+
+#include
+
+/** Represents a tile area containing containing individually set tiles.
+ * Each tile must be contained within the preallocated area.
+ * A std::vector is used to mark which tiles are contained.
+ */
+class BitmapTileArea : public TileArea {
+protected:
+ std::vector data;
+
+ inline uint Index(uint x, uint y) const { return y * this->w + x; }
+
+ inline uint Index(TileIndex tile) const { return Index(TileX(tile) - TileX(this->tile), TileY(tile) - TileY(this->tile)); }
+
+public:
+ BitmapTileArea()
+ {
+ this->tile = INVALID_TILE;
+ this->w = 0;
+ this->h = 0;
+ }
+
+ /**
+ * Reset and clear the BitmapTileArea.
+ */
+ void Reset()
+ {
+ this->tile = INVALID_TILE;
+ this->w = 0;
+ this->h = 0;
+ this->data.clear();
+ }
+
+ /**
+ * Initialize the BitmapTileArea with the specified Rect.
+ * @param rect Rect to use.
+ */
+ void Initialize(Rect r)
+ {
+ this->tile = TileXY(r.left, r.top);
+ this->w = r.right - r.left + 1;
+ this->h = r.bottom - r.top + 1;
+ this->data.clear();
+ this->data.resize(Index(w, h));
+ }
+
+ /**
+ * Add a tile as part of the tile area.
+ * @param tile Tile to add.
+ */
+ inline void SetTile(TileIndex tile)
+ {
+ assert(this->Contains(tile));
+ this->data[Index(tile)] = true;
+ }
+
+ /**
+ * Clear a tile from the tile area.
+ * @param tile Tile to clear
+ */
+ inline void ClrTile(TileIndex tile)
+ {
+ assert(this->Contains(tile));
+ this->data[Index(tile)] = false;
+ }
+
+ /**
+ * Test if a tile is part of the tile area.
+ * @param tile Tile to check
+ */
+ inline bool HasTile(TileIndex tile) const
+ {
+ return this->Contains(tile) && this->data[Index(tile)];
+ }
+};
+
+/** Iterator to iterate over all tiles belonging to a bitmaptilearea. */
+class BitmapTileIterator : public OrthogonalTileIterator {
+protected:
+ const BitmapTileArea *bitmap;
+public:
+ /**
+ * Construct the iterator.
+ * @param bitmap BitmapTileArea to iterate.
+ */
+ BitmapTileIterator(const BitmapTileArea &bitmap) : OrthogonalTileIterator(bitmap), bitmap(&bitmap)
+ {
+ if (!this->bitmap->HasTile(TileIndex(this->tile))) ++(*this);
+ }
+
+ inline TileIterator& operator ++()
+ {
+ (*this).OrthogonalTileIterator::operator++();
+ while (this->tile != INVALID_TILE && !this->bitmap->HasTile(TileIndex(this->tile))) {
+ (*this).OrthogonalTileIterator::operator++();
+ }
+ return *this;
+ }
+
+ virtual TileIterator *Clone() const
+ {
+ return new BitmapTileIterator(*this);
+ }
+};
+
+#endif /* BITMAP_TYPE_HPP */
diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp
index ecf6dcfca0..f8fd892813 100644
--- a/src/blitter/32bpp_anim.hpp
+++ b/src/blitter/32bpp_anim.hpp
@@ -37,21 +37,21 @@ public:
~Blitter_32bppAnim();
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
- /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
- /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
- /* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
- /* virtual */ int BufferSize(int width, int height);
- /* virtual */ void PaletteAnimate(const Palette &palette);
- /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
+ void SetPixel(void *video, int x, int y, uint8 colour) override;
+ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
+ void DrawRect(void *video, int width, int height, uint8 colour) override;
+ void CopyFromBuffer(void *video, const void *src, int width, int height) override;
+ void CopyToBuffer(const void *video, void *dst, int width, int height) override;
+ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
+ int BufferSize(int width, int height) override;
+ void PaletteAnimate(const Palette &palette) override;
+ Blitter::PaletteAnimation UsePaletteAnimation() override;
- /* virtual */ const char *GetName() { return "32bpp-anim"; }
- /* virtual */ int GetBytesPerPixel() { return 6; }
- /* virtual */ void PostResize();
+ const char *GetName() override { return "32bpp-anim"; }
+ int GetBytesPerPixel() override { return 6; }
+ void PostResize() override;
/**
* Look up the colour in the current palette.
@@ -77,7 +77,7 @@ public:
class FBlitter_32bppAnim : public BlitterFactory {
public:
FBlitter_32bppAnim() : BlitterFactory("32bpp-anim", "32bpp Animation Blitter (palette animation)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppAnim(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppAnim(); }
};
#endif /* BLITTER_32BPP_ANIM_HPP */
diff --git a/src/blitter/32bpp_anim_sse2.hpp b/src/blitter/32bpp_anim_sse2.hpp
index 0d4a5f1e65..aed11026c0 100644
--- a/src/blitter/32bpp_anim_sse2.hpp
+++ b/src/blitter/32bpp_anim_sse2.hpp
@@ -28,15 +28,15 @@
/** A partially 32 bpp blitter with palette animation. */
class Blitter_32bppSSE2_Anim : public Blitter_32bppAnim {
public:
- /* virtual */ void PaletteAnimate(const Palette &palette);
- /* virtual */ const char *GetName() { return "32bpp-sse2-anim"; }
+ void PaletteAnimate(const Palette &palette) override;
+ const char *GetName() override { return "32bpp-sse2-anim"; }
};
/** Factory for the partially 32bpp blitter with animation. */
class FBlitter_32bppSSE2_Anim : public BlitterFactory {
public:
FBlitter_32bppSSE2_Anim() : BlitterFactory("32bpp-sse2-anim", "32bpp partially SSE2 Animation Blitter (palette animation)", HasCPUIDFlag(1, 3, 26)) {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2_Anim(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSSE2_Anim(); }
};
#endif /* WITH_SSE */
diff --git a/src/blitter/32bpp_anim_sse4.hpp b/src/blitter/32bpp_anim_sse4.hpp
index 5ff1fb01be..2fefd3001f 100644
--- a/src/blitter/32bpp_anim_sse4.hpp
+++ b/src/blitter/32bpp_anim_sse4.hpp
@@ -35,19 +35,19 @@ private:
public:
template
- /* virtual */ void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
+ void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override {
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
}
- /* virtual */ const char *GetName() { return "32bpp-sse4-anim"; }
+ const char *GetName() override { return "32bpp-sse4-anim"; }
};
/** Factory for the SSE4 32 bpp blitter (with palette animation). */
class FBlitter_32bppSSE4_Anim: public BlitterFactory {
public:
FBlitter_32bppSSE4_Anim() : BlitterFactory("32bpp-sse4-anim", "SSE4 Blitter (palette animation)", HasCPUIDFlag(1, 2, 19)) {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4_Anim(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSSE4_Anim(); }
};
#endif /* WITH_SSE */
diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp
index 697593da6a..e481c15ccb 100644
--- a/src/blitter/32bpp_base.hpp
+++ b/src/blitter/32bpp_base.hpp
@@ -20,19 +20,19 @@
/** Base for all 32bpp blitters. */
class Blitter_32bppBase : public Blitter {
public:
- /* virtual */ uint8 GetScreenDepth() { return 32; }
- /* virtual */ void *MoveTo(void *video, int x, int y);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
- /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
- /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
- /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
- /* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
- /* virtual */ int BufferSize(int width, int height);
- /* virtual */ void PaletteAnimate(const Palette &palette);
- /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
- /* virtual */ int GetBytesPerPixel() { return 4; }
+ uint8 GetScreenDepth() override { return 32; }
+ void *MoveTo(void *video, int x, int y) override;
+ void SetPixel(void *video, int x, int y, uint8 colour) override;
+ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
+ void DrawRect(void *video, int width, int height, uint8 colour) override;
+ void CopyFromBuffer(void *video, const void *src, int width, int height) override;
+ void CopyToBuffer(const void *video, void *dst, int width, int height) override;
+ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
+ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
+ int BufferSize(int width, int height) override;
+ void PaletteAnimate(const Palette &palette) override;
+ Blitter::PaletteAnimation UsePaletteAnimation() override;
+ int GetBytesPerPixel() override { return 4; }
/**
* Look up the colour in the current palette.
diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp
index c261aa33d6..fc8a406537 100644
--- a/src/blitter/32bpp_optimized.hpp
+++ b/src/blitter/32bpp_optimized.hpp
@@ -23,10 +23,10 @@ public:
byte data[]; ///< Data, all zoomlevels.
};
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
- /* virtual */ const char *GetName() { return "32bpp-optimized"; }
+ const char *GetName() override { return "32bpp-optimized"; }
template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
};
@@ -35,7 +35,7 @@ public:
class FBlitter_32bppOptimized : public BlitterFactory {
public:
FBlitter_32bppOptimized() : BlitterFactory("32bpp-optimized", "32bpp Optimized Blitter (no palette animation)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppOptimized(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppOptimized(); }
};
#endif /* BLITTER_32BPP_OPTIMIZED_HPP */
diff --git a/src/blitter/32bpp_simple.hpp b/src/blitter/32bpp_simple.hpp
index 0751f6f753..3d43971e9e 100644
--- a/src/blitter/32bpp_simple.hpp
+++ b/src/blitter/32bpp_simple.hpp
@@ -26,18 +26,18 @@ class Blitter_32bppSimple : public Blitter_32bppBase {
uint8 v; ///< Brightness-channel
};
public:
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
- /* virtual */ const char *GetName() { return "32bpp-simple"; }
+ const char *GetName() override { return "32bpp-simple"; }
};
/** Factory for the simple 32 bpp blitter. */
class FBlitter_32bppSimple : public BlitterFactory {
public:
FBlitter_32bppSimple() : BlitterFactory("32bpp-simple", "32bpp Simple Blitter (no palette animation)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSimple(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSimple(); }
};
#endif /* BLITTER_32BPP_SIMPLE_HPP */
diff --git a/src/blitter/32bpp_sse2.hpp b/src/blitter/32bpp_sse2.hpp
index d6b17f679c..1628f1fa26 100644
--- a/src/blitter/32bpp_sse2.hpp
+++ b/src/blitter/32bpp_sse2.hpp
@@ -82,22 +82,22 @@ DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
/** The SSE2 32 bpp blitter (without palette animation). */
class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
public:
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
template
void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override {
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
}
- /* virtual */ const char *GetName() { return "32bpp-sse2"; }
+ const char *GetName() override { return "32bpp-sse2"; }
};
/** Factory for the SSE2 32 bpp blitter (without palette animation). */
class FBlitter_32bppSSE2 : public BlitterFactory {
public:
FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSSE2(); }
};
#endif /* WITH_SSE */
diff --git a/src/blitter/32bpp_sse4.hpp b/src/blitter/32bpp_sse4.hpp
index 9c59d253f5..36b5b16d4c 100644
--- a/src/blitter/32bpp_sse4.hpp
+++ b/src/blitter/32bpp_sse4.hpp
@@ -27,17 +27,17 @@
/** The SSE4 32 bpp blitter (without palette animation). */
class Blitter_32bppSSE4 : public Blitter_32bppSSSE3 {
public:
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
template
void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
- /* virtual */ const char *GetName() { return "32bpp-sse4"; }
+ const char *GetName() override { return "32bpp-sse4"; }
};
/** Factory for the SSE4 32 bpp blitter (without palette animation). */
class FBlitter_32bppSSE4: public BlitterFactory {
public:
FBlitter_32bppSSE4() : BlitterFactory("32bpp-sse4", "32bpp SSE4 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 19)) {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSSE4(); }
};
#endif /* WITH_SSE */
diff --git a/src/blitter/32bpp_ssse3.hpp b/src/blitter/32bpp_ssse3.hpp
index e9cac8ff0b..3d6152e9e7 100644
--- a/src/blitter/32bpp_ssse3.hpp
+++ b/src/blitter/32bpp_ssse3.hpp
@@ -27,17 +27,17 @@
/** The SSSE3 32 bpp blitter (without palette animation). */
class Blitter_32bppSSSE3 : public Blitter_32bppSSE2 {
public:
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
template
void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
- /* virtual */ const char *GetName() { return "32bpp-ssse3"; }
+ const char *GetName() override { return "32bpp-ssse3"; }
};
/** Factory for the SSSE3 32 bpp blitter (without palette animation). */
class FBlitter_32bppSSSE3: public BlitterFactory {
public:
FBlitter_32bppSSSE3() : BlitterFactory("32bpp-ssse3", "32bpp SSSE3 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 9)) {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSSE3(); }
+ Blitter *CreateInstance() override { return new Blitter_32bppSSSE3(); }
};
#endif /* WITH_SSE */
diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp
index 8f75dda5d3..7ab3f6378a 100644
--- a/src/blitter/8bpp_base.hpp
+++ b/src/blitter/8bpp_base.hpp
@@ -17,20 +17,20 @@
/** Base for all 8bpp blitters. */
class Blitter_8bppBase : public Blitter {
public:
- /* virtual */ uint8 GetScreenDepth() { return 8; }
- /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
- /* virtual */ void *MoveTo(void *video, int x, int y);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
- /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
- /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
- /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
- /* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
- /* virtual */ int BufferSize(int width, int height);
- /* virtual */ void PaletteAnimate(const Palette &palette);
- /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
- /* virtual */ int GetBytesPerPixel() { return 1; }
+ uint8 GetScreenDepth() override { return 8; }
+ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
+ void *MoveTo(void *video, int x, int y) override;
+ void SetPixel(void *video, int x, int y, uint8 colour) override;
+ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
+ void DrawRect(void *video, int width, int height, uint8 colour) override;
+ void CopyFromBuffer(void *video, const void *src, int width, int height) override;
+ void CopyToBuffer(const void *video, void *dst, int width, int height) override;
+ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
+ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
+ int BufferSize(int width, int height) override;
+ void PaletteAnimate(const Palette &palette) override;
+ Blitter::PaletteAnimation UsePaletteAnimation() override;
+ int GetBytesPerPixel() override { return 1; }
};
#endif /* BLITTER_8BPP_BASE_HPP */
diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp
index b5b5324b91..509edb8c40 100644
--- a/src/blitter/8bpp_optimized.hpp
+++ b/src/blitter/8bpp_optimized.hpp
@@ -24,17 +24,17 @@ public:
byte data[]; ///< Data, all zoomlevels.
};
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
- /* virtual */ const char *GetName() { return "8bpp-optimized"; }
+ const char *GetName() override { return "8bpp-optimized"; }
};
/** Factory for the 8bpp blitter optimised for speed. */
class FBlitter_8bppOptimized : public BlitterFactory {
public:
FBlitter_8bppOptimized() : BlitterFactory("8bpp-optimized", "8bpp Optimized Blitter (compression + all-ZoomLevel cache)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppOptimized(); }
+ Blitter *CreateInstance() override { return new Blitter_8bppOptimized(); }
};
#endif /* BLITTER_8BPP_OPTIMIZED_HPP */
diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp
index c00c75ac04..e48bc37585 100644
--- a/src/blitter/8bpp_simple.hpp
+++ b/src/blitter/8bpp_simple.hpp
@@ -18,17 +18,17 @@
/** Most trivial 8bpp blitter. */
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
public:
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
- /* virtual */ const char *GetName() { return "8bpp-simple"; }
+ const char *GetName() override { return "8bpp-simple"; }
};
/** Factory for the most trivial 8bpp blitter. */
class FBlitter_8bppSimple : public BlitterFactory {
public:
FBlitter_8bppSimple() : BlitterFactory("8bpp-simple", "8bpp Simple Blitter (relative slow, but never wrong)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppSimple(); }
+ Blitter *CreateInstance() override { return new Blitter_8bppSimple(); }
};
#endif /* BLITTER_8BPP_SIMPLE_HPP */
diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp
index a6fed2ebca..8dc98646c2 100644
--- a/src/blitter/null.hpp
+++ b/src/blitter/null.hpp
@@ -17,31 +17,31 @@
/** Blitter that does nothing. */
class Blitter_Null : public Blitter {
public:
- /* virtual */ uint8 GetScreenDepth() { return 0; }
- /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {};
- /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {};
- /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
- /* virtual */ void *MoveTo(void *video, int x, int y) { return NULL; };
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {};
- /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {};
- /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) {};
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height) {};
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height) {};
- /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) {};
- /* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) {};
- /* virtual */ int BufferSize(int width, int height) { return 0; };
- /* virtual */ void PaletteAnimate(const Palette &palette) { };
- /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation() { return Blitter::PALETTE_ANIMATION_NONE; };
-
- /* virtual */ const char *GetName() { return "null"; }
- /* virtual */ int GetBytesPerPixel() { return 0; }
+ uint8 GetScreenDepth() override { return 0; }
+ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
+ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
+ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
+ void *MoveTo(void *video, int x, int y) override { return NULL; };
+ void SetPixel(void *video, int x, int y, uint8 colour) override {};
+ void DrawRect(void *video, int width, int height, uint8 colour) override {};
+ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
+ void CopyFromBuffer(void *video, const void *src, int width, int height) override {};
+ void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
+ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};
+ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override {};
+ int BufferSize(int width, int height) override { return 0; };
+ void PaletteAnimate(const Palette &palette) override { };
+ Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; };
+
+ const char *GetName() override { return "null"; }
+ int GetBytesPerPixel() override { return 0; }
};
/** Factory for the blitter that does nothing. */
class FBlitter_Null : public BlitterFactory {
public:
FBlitter_Null() : BlitterFactory("null", "Null Blitter (does nothing)") {}
- /* virtual */ Blitter *CreateInstance() { return new Blitter_Null(); }
+ Blitter *CreateInstance() override { return new Blitter_Null(); }
};
#endif /* BLITTER_NULL_HPP */
diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp
index 3fb52a1f9e..b6fb35bffd 100644
--- a/src/bootstrap_gui.cpp
+++ b/src/bootstrap_gui.cpp
@@ -13,7 +13,7 @@
#include "base_media_base.h"
#include "blitter/factory.hpp"
-#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE)
+#if defined(WITH_FREETYPE)
#include "core/geometry_func.hpp"
#include "fontcache.h"
@@ -56,7 +56,7 @@ public:
ResizeWindow(this, _screen.width, _screen.height);
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE);
GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER);
@@ -88,7 +88,7 @@ public:
{
}
- virtual void OnDownloadComplete(ContentID cid)
+ void OnDownloadComplete(ContentID cid) override
{
/* We have completed downloading. We can trigger finding the right set now. */
BaseGraphics::FindSets();
@@ -142,7 +142,7 @@ public:
_network_content_client.RemoveCallback(this);
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
/* We cache the button size. This is safe as no reinit can happen here. */
if (this->button_size.width == 0) {
@@ -165,14 +165,14 @@ public:
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != 0) return;
DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_BAFD_YES:
@@ -189,13 +189,13 @@ public:
}
}
- virtual void OnConnect(bool success)
+ void OnConnect(bool success) override
{
/* Once connected, request the metadata. */
_network_content_client.RequestContentList(CONTENT_TYPE_BASE_GRAPHICS);
}
- virtual void OnReceiveContentInfo(const ContentInfo *ci)
+ void OnReceiveContentInfo(const ContentInfo *ci) override
{
/* And once the meta data is received, start downloading it. */
_network_content_client.Select(ci->id);
@@ -204,7 +204,7 @@ public:
}
};
-#endif /* defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) */
+#endif /* defined(WITH_FREETYPE) */
/**
* Handle all procedures for bootstrapping OpenTTD without a base graphics set.
@@ -220,7 +220,7 @@ bool HandleBootstrap()
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure;
/* If there is no network or no freetype, then there is nothing we can do. Go straight to failure. */
-#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__))
+#if defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__))
if (!_network_available) goto failure;
/* First tell the game we're bootstrapping. */
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 768691f080..f6f47276c0 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -113,11 +113,11 @@ private:
void BuildBridge(uint8 i)
{
switch ((TransportType)(this->type >> 15)) {
- case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->Get(i)->index; break;
- case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->Get(i)->index; break;
+ case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->at(i).index; break;
+ case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break;
default: break;
}
- DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index,
+ DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->at(i).index,
CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
}
@@ -153,7 +153,7 @@ public:
this->bridges->NeedResort();
this->SortBridgeList();
- this->vscroll->SetCount(bl->Length());
+ this->vscroll->SetCount((uint)bl->size());
}
~BuildBridgeWindow()
@@ -163,7 +163,7 @@ public:
delete bridges;
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_BBS_DROPDOWN_ORDER: {
@@ -186,11 +186,11 @@ public:
case WID_BBS_BRIDGE_LIST: {
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
Dimension text_dim = {0, 0}; // Biggest text dimension
- for (int i = 0; i < (int)this->bridges->Length(); i++) {
- const BridgeSpec *b = this->bridges->Get(i)->spec;
+ for (int i = 0; i < (int)this->bridges->size(); i++) {
+ const BridgeSpec *b = this->bridges->at(i).spec;
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
- SetDParam(2, this->bridges->Get(i)->cost);
+ SetDParam(2, this->bridges->at(i).cost);
SetDParam(1, b->speed);
SetDParam(0, b->material);
text_dim = maxdim(text_dim, GetStringBoundingBox(_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO));
@@ -207,7 +207,7 @@ public:
}
}
- virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
+ Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
{
/* Position the window so hopefully the first bridge from the list is under the mouse pointer. */
NWidgetBase *list = this->GetWidget(WID_BBS_BRIDGE_LIST);
@@ -217,7 +217,7 @@ public:
return corner;
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_BBS_DROPDOWN_ORDER:
@@ -226,10 +226,10 @@ public:
case WID_BBS_BRIDGE_LIST: {
uint y = r.top;
- for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->Length(); i++) {
- const BridgeSpec *b = this->bridges->Get(i)->spec;
+ for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
+ const BridgeSpec *b = this->bridges->at(i).spec;
- SetDParam(2, this->bridges->Get(i)->cost);
+ SetDParam(2, this->bridges->at(i).cost);
SetDParam(1, b->speed);
SetDParam(0, b->material);
@@ -243,10 +243,10 @@ public:
}
}
- virtual EventState OnKeyPress(WChar key, uint16 keycode)
+ EventState OnKeyPress(WChar key, uint16 keycode) override
{
const uint8 i = keycode - '1';
- if (i < 9 && i < this->bridges->Length()) {
+ if (i < 9 && i < this->bridges->size()) {
/* Build the requested bridge */
this->BuildBridge(i);
delete this;
@@ -255,13 +255,13 @@ public:
return ES_NOT_HANDLED;
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
default: break;
case WID_BBS_BRIDGE_LIST: {
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BBS_BRIDGE_LIST);
- if (i < this->bridges->Length()) {
+ if (i < this->bridges->size()) {
this->BuildBridge(i);
delete this;
}
@@ -279,7 +279,7 @@ public:
}
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
if (widget == WID_BBS_DROPDOWN_CRITERIA && this->bridges->SortType() != index) {
this->bridges->SetSortType(index);
@@ -288,7 +288,7 @@ public:
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_BBS_BRIDGE_LIST);
}
@@ -416,17 +416,18 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
/* bridge is accepted, add to list */
- BuildBridgeData *item = bl->Append();
- item->index = brd_type;
- item->spec = GetBridgeSpec(brd_type);
+ /*C++17: BuildBridgeData &item = */ bl->emplace_back();
+ BuildBridgeData &item = bl->back();
+ item.index = brd_type;
+ item.spec = GetBridgeSpec(brd_type);
/* Add to terraforming & bulldozing costs the cost of the
* bridge itself (not computed with DC_QUERY_COST) */
- item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8) + infra_cost;
+ item.cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
}
}
}
- if (bl != NULL && bl->Length() != 0) {
+ if (bl != NULL && bl->size() != 0) {
new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
} else {
delete bl;
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 713cc5bbe4..b671efde74 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -532,11 +532,11 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = {
&CargoFilter,
};
-static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine)
+static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, TestedEngineDetails &te)
{
CargoArray cap;
CargoTypes refits;
- GetArticulatedVehicleCargoesAndRefits(engine, &cap, &refits);
+ GetArticulatedVehicleCargoesAndRefits(engine, &cap, &refits, te.cargo, te.capacity);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (cap[c] == 0) continue;
@@ -552,19 +552,25 @@ static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine)
}
/* Draw rail wagon specific details */
-static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
+static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
/* Purchase cost */
- SetDParam(0, e->GetCost());
- DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
+ } else {
+ SetDParam(0, e->GetCost());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ }
y += FONT_HEIGHT_NORMAL;
/* Wagon weight - (including cargo) */
uint weight = e->GetDisplayWeight();
SetDParam(0, weight);
- uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(e->GetDefaultCargoType())->weight * GetTotalCapacityOfArticulatedParts(engine_number) / 16 : 0);
+ uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(te.cargo)->weight * te.capacity / 16 : 0);
SetDParam(1, cargo_weight + weight);
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
y += FONT_HEIGHT_NORMAL;
@@ -590,14 +596,21 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
}
/* Draw locomotive specific details */
-static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
+static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
/* Purchase Cost - Engine weight */
- SetDParam(0, e->GetCost());
- SetDParam(1, e->GetDisplayWeight());
- DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ SetDParam(2, e->GetDisplayWeight());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_WEIGHT);
+ } else {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, e->GetDisplayWeight());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT);
+ }
y += FONT_HEIGHT_NORMAL;
/* Max speed - Engine power */
@@ -632,20 +645,26 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
}
/* Draw road vehicle specific details */
-static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_number)
+static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
/* Purchase Cost */
- SetDParam(0, e->GetCost());
- DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
+ } else {
+ SetDParam(0, e->GetCost());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ }
y += FONT_HEIGHT_NORMAL;
/* Road vehicle weight - (including cargo) */
int16 weight = e->GetDisplayWeight();
SetDParam(0, weight);
- uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(e->GetDefaultCargoType())->weight * GetTotalCapacityOfArticulatedParts(engine_number) / 16 : 0);
+ uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(te.cargo)->weight * te.capacity / 16 : 0);
SetDParam(1, cargo_weight + weight);
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
y += FONT_HEIGHT_NORMAL;
@@ -662,9 +681,16 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
y += FONT_HEIGHT_NORMAL;
} else {
/* Purchase cost - Max speed */
- SetDParam(0, e->GetCost());
- SetDParam(1, e->GetDisplayMaxSpeed());
- DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ SetDParam(2, e->GetDisplayMaxSpeed());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
+ } else {
+ SetDParam(0, e->GetCost());
+ SetDParam(2, e->GetDisplayMaxSpeed());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ }
y += FONT_HEIGHT_NORMAL;
}
@@ -677,7 +703,7 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
}
/* Draw ship specific details */
-static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable)
+static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
@@ -686,13 +712,27 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
uint ocean_speed = e->u.ship.ApplyWaterClassSpeedFrac(raw_speed, true);
uint canal_speed = e->u.ship.ApplyWaterClassSpeedFrac(raw_speed, false);
- SetDParam(0, e->GetCost());
if (ocean_speed == canal_speed) {
- SetDParam(1, ocean_speed);
- DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ SetDParam(2, ocean_speed);
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
+ } else {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, ocean_speed);
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ }
y += FONT_HEIGHT_NORMAL;
} else {
- DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
+ } else {
+ SetDParam(0, e->GetCost());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST);
+ }
y += FONT_HEIGHT_NORMAL;
SetDParam(0, ocean_speed);
@@ -705,8 +745,8 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
}
/* Cargo type + capacity */
- SetDParam(0, e->GetDefaultCargoType());
- SetDParam(1, e->GetDisplayDefaultCapacity());
+ SetDParam(0, te.cargo);
+ SetDParam(1, te.capacity);
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
@@ -728,31 +768,35 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
* @param refittable If set, the aircraft can be refitted.
* @return Bottom of the used area.
*/
-static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable)
+static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
- CargoID cargo = e->GetDefaultCargoType();
/* Purchase cost - Max speed */
- SetDParam(0, e->GetCost());
- SetDParam(1, e->GetDisplayMaxSpeed());
- DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ if (te.cost != 0) {
+ SetDParam(0, e->GetCost() + te.cost);
+ SetDParam(1, te.cost);
+ SetDParam(2, e->GetDisplayMaxSpeed());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
+ } else {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, e->GetDisplayMaxSpeed());
+ DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
+ }
y += FONT_HEIGHT_NORMAL;
/* Cargo capacity */
- uint16 mail_capacity;
- uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
- if (mail_capacity > 0) {
- SetDParam(0, cargo);
- SetDParam(1, capacity);
+ if (te.mail_capacity > 0) {
+ SetDParam(0, te.cargo);
+ SetDParam(1, te.capacity);
SetDParam(2, CT_MAIL);
- SetDParam(3, mail_capacity);
+ SetDParam(3, te.mail_capacity);
DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY);
} else {
/* Note, if the default capacity is selected by the refit capacity
* callback, then the capacity shown is likely to be incorrect. */
- SetDParam(0, cargo);
- SetDParam(1, capacity);
+ SetDParam(0, te.cargo);
+ SetDParam(1, te.capacity);
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
}
@@ -809,7 +853,7 @@ static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
* @param engine_number the engine of which to draw the info of
* @return y after drawing all the text
*/
-int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
+int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
{
const Engine *e = Engine::Get(engine_number);
YearMonthDay ymd;
@@ -821,30 +865,30 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
default: NOT_REACHED();
case VEH_TRAIN:
if (e->u.rail.railveh_type == RAILVEH_WAGON) {
- y = DrawRailWagonPurchaseInfo(left, right, y, engine_number, &e->u.rail);
+ y = DrawRailWagonPurchaseInfo(left, right, y, engine_number, &e->u.rail, te);
} else {
- y = DrawRailEnginePurchaseInfo(left, right, y, engine_number, &e->u.rail);
+ y = DrawRailEnginePurchaseInfo(left, right, y, engine_number, &e->u.rail, te);
}
articulated_cargo = true;
break;
case VEH_ROAD:
- y = DrawRoadVehPurchaseInfo(left, right, y, engine_number);
+ y = DrawRoadVehPurchaseInfo(left, right, y, engine_number, te);
articulated_cargo = true;
break;
case VEH_SHIP:
- y = DrawShipPurchaseInfo(left, right, y, engine_number, refittable);
+ y = DrawShipPurchaseInfo(left, right, y, engine_number, refittable, te);
break;
case VEH_AIRCRAFT:
- y = DrawAircraftPurchaseInfo(left, right, y, engine_number, refittable);
+ y = DrawAircraftPurchaseInfo(left, right, y, engine_number, refittable, te);
break;
}
if (articulated_cargo) {
/* Cargo type + capacity, or N/A */
- int new_y = DrawCargoCapacityInfo(left, right, y, engine_number);
+ int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, te);
if (new_y == y) {
SetDParam(0, CT_INVALID);
@@ -896,7 +940,7 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
/* Obligatory sanity checks! */
- assert(max <= eng_list->Length());
+ assert(max <= eng_list->size());
bool rtl = _current_text_dir == TD_RTL;
int step_size = GetEngineListHeight(type);
@@ -988,6 +1032,23 @@ struct BuildVehicleWindow : Window {
byte cargo_filter_criteria; ///< Selected cargo filter
int details_height; ///< Minimal needed height of the details panels (found so far).
Scrollbar *vscroll;
+ TestedEngineDetails te; ///< Tested cost and capacity after refit.
+
+ void SetBuyVehicleText()
+ {
+ NWidgetCore *widget = this->GetWidget(WID_BV_BUILD);
+
+ bool refit = this->sel_engine != INVALID_ENGINE && this->cargo_filter[this->cargo_filter_criteria] != CF_ANY && this->cargo_filter[this->cargo_filter_criteria] != CF_NONE;
+ if (refit) refit = Engine::Get(this->sel_engine)->GetDefaultCargoType() != this->cargo_filter[this->cargo_filter_criteria];
+
+ if (refit) {
+ widget->widget_data = STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type;
+ widget->tool_tip = STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP + this->vehicle_type;
+ } else {
+ widget->widget_data = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type;
+ widget->tool_tip = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP + this->vehicle_type;
+ }
+ }
BuildVehicleWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc)
{
@@ -1031,10 +1092,6 @@ struct BuildVehicleWindow : Window {
widget = this->GetWidget(WID_BV_SHOW_HIDE);
widget->tool_tip = STR_BUY_VEHICLE_TRAIN_HIDE_SHOW_TOGGLE_TOOLTIP + type;
- widget = this->GetWidget(WID_BV_BUILD);
- widget->widget_data = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + type;
- widget->tool_tip = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP + type;
-
widget = this->GetWidget(WID_BV_RENAME);
widget->widget_data = STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON + type;
widget->tool_tip = STR_BUY_VEHICLE_TRAIN_RENAME_TOOLTIP + type;
@@ -1053,7 +1110,11 @@ struct BuildVehicleWindow : Window {
this->eng_list.ForceRebuild();
this->GenerateBuildList(); // generate the list, since we need it in the next line
/* Select the first engine in the list as default when opening the window */
- if (this->eng_list.Length() > 0) this->sel_engine = this->eng_list[0];
+ if (this->eng_list.size() > 0) {
+ this->SelectEngine(this->eng_list[0]);
+ } else {
+ this->SelectEngine(INVALID_ENGINE);
+ }
}
/** Populate the filter list and set the cargo filter criteria. */
@@ -1100,7 +1161,42 @@ struct BuildVehicleWindow : Window {
this->eng_list.SetFilterState(this->cargo_filter[this->cargo_filter_criteria] != CF_ANY);
}
- void OnInit()
+ void SelectEngine(EngineID engine)
+ {
+ CargoID cargo = this->cargo_filter[this->cargo_filter_criteria];
+ if (cargo == CF_ANY) cargo = CF_NONE;
+
+ this->sel_engine = engine;
+ this->SetBuyVehicleText();
+
+ if (this->sel_engine == INVALID_ENGINE) return;
+
+ const Engine *e = Engine::Get(this->sel_engine);
+ if (!e->CanCarryCargo()) {
+ this->te.cost = 0;
+ this->te.cargo = CT_INVALID;
+ return;
+ }
+
+ if (!this->listview_mode) {
+ /* Query for cost and refitted capacity */
+ CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), NULL);
+ if (ret.Succeeded()) {
+ this->te.cost = ret.GetCost() - e->GetCost();
+ this->te.capacity = _returned_refit_capacity;
+ this->te.mail_capacity = _returned_mail_refit_capacity;
+ this->te.cargo = (cargo == CT_INVALID) ? e->GetDefaultCargoType() : cargo;
+ return;
+ }
+ }
+
+ /* Purchase test was not possible or failed, fill in the defaults instead. */
+ this->te.cost = 0;
+ this->te.capacity = e->GetDisplayDefaultCapacity(&this->te.mail_capacity);
+ this->te.cargo = e->GetDefaultCargoType();
+ }
+
+ void OnInit() override
{
this->SetCargoFilterArray();
}
@@ -1109,10 +1205,10 @@ struct BuildVehicleWindow : Window {
void FilterEngineList()
{
this->eng_list.Filter(this->cargo_filter[this->cargo_filter_criteria]);
- if (0 == this->eng_list.Length()) { // no engine passed through the filter, invalidate the previously selected engine
- this->sel_engine = INVALID_ENGINE;
- } else if (!this->eng_list.Contains(this->sel_engine)) { // previously selected engine didn't pass the filter, select the first engine of the list
- this->sel_engine = this->eng_list[0];
+ if (0 == this->eng_list.size()) { // no engine passed through the filter, invalidate the previously selected engine
+ this->SelectEngine(INVALID_ENGINE);
+ } else if (std::find(this->eng_list.begin(), this->eng_list.end(), this->sel_engine) == this->eng_list.end()) { // previously selected engine didn't pass the filter, select the first engine of the list
+ this->SelectEngine(this->eng_list[0]);
}
}
@@ -1132,7 +1228,7 @@ struct BuildVehicleWindow : Window {
this->filter.railtype = (this->listview_mode) ? RAILTYPE_END : GetRailType(this->window_number);
- this->eng_list.Clear();
+ this->eng_list.clear();
/* Make list of all available train engines and wagons.
* Also check to see if the previously selected engine is still available,
@@ -1150,7 +1246,7 @@ struct BuildVehicleWindow : Window {
/* Filter now! So num_engines and num_wagons is valid */
if (!FilterSingleEngine(eid)) continue;
- *this->eng_list.Append() = eid;
+ this->eng_list.push_back(eid);
if (rvi->railveh_type != RAILVEH_WAGON) {
num_engines++;
@@ -1161,7 +1257,7 @@ struct BuildVehicleWindow : Window {
if (eid == this->sel_engine) sel_id = eid;
}
- this->sel_engine = sel_id;
+ this->SelectEngine(sel_id);
/* make engines first, and then wagons, sorted by selected sort_criteria */
_engine_sort_direction = false;
@@ -1180,7 +1276,7 @@ struct BuildVehicleWindow : Window {
{
EngineID sel_id = INVALID_ENGINE;
- this->eng_list.Clear();
+ this->eng_list.clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
@@ -1188,29 +1284,29 @@ struct BuildVehicleWindow : Window {
EngineID eid = e->index;
if (!IsEngineBuildable(eid, VEH_ROAD, _local_company)) continue;
if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
- *this->eng_list.Append() = eid;
+ this->eng_list.push_back(eid);
if (eid == this->sel_engine) sel_id = eid;
}
- this->sel_engine = sel_id;
+ this->SelectEngine(sel_id);
}
/* Figure out what ship EngineIDs to put in the list */
void GenerateBuildShipList()
{
EngineID sel_id = INVALID_ENGINE;
- this->eng_list.Clear();
+ this->eng_list.clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) {
if (!this->show_hidden_engines && e->IsHidden(_local_company)) continue;
EngineID eid = e->index;
if (!IsEngineBuildable(eid, VEH_SHIP, _local_company)) continue;
- *this->eng_list.Append() = eid;
+ this->eng_list.push_back(eid);
if (eid == this->sel_engine) sel_id = eid;
}
- this->sel_engine = sel_id;
+ this->SelectEngine(sel_id);
}
/* Figure out what aircraft EngineIDs to put in the list */
@@ -1218,7 +1314,7 @@ struct BuildVehicleWindow : Window {
{
EngineID sel_id = INVALID_ENGINE;
- this->eng_list.Clear();
+ this->eng_list.clear();
const Station *st = this->listview_mode ? NULL : Station::GetByTile(this->window_number);
@@ -1234,11 +1330,11 @@ struct BuildVehicleWindow : Window {
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
if (!this->listview_mode && !CanVehicleUseStation(eid, st)) continue;
- *this->eng_list.Append() = eid;
+ this->eng_list.push_back(eid);
if (eid == this->sel_engine) sel_id = eid;
}
- this->sel_engine = sel_id;
+ this->SelectEngine(sel_id);
}
/* Generate the list of vehicles */
@@ -1249,7 +1345,7 @@ struct BuildVehicleWindow : Window {
default: NOT_REACHED();
case VEH_TRAIN:
this->GenerateBuildTrainList();
- this->eng_list.Compact();
+ this->eng_list.shrink_to_fit();
this->eng_list.RebuildDone();
return; // trains should not reach the last sorting
case VEH_ROAD:
@@ -1268,11 +1364,11 @@ struct BuildVehicleWindow : Window {
_engine_sort_direction = this->descending_sort_order;
EngList_Sort(&this->eng_list, _engine_sort_functions[this->vehicle_type][this->sort_criteria]);
- this->eng_list.Compact();
+ this->eng_list.shrink_to_fit();
this->eng_list.RebuildDone();
}
- void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_BV_SORT_ASCENDING_DESCENDING:
@@ -1292,8 +1388,8 @@ struct BuildVehicleWindow : Window {
case WID_BV_LIST: {
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST);
- size_t num_items = this->eng_list.Length();
- this->sel_engine = (i < num_items) ? this->eng_list[i] : INVALID_ENGINE;
+ size_t num_items = this->eng_list.size();
+ this->SelectEngine((i < num_items) ? this->eng_list[i] : INVALID_ENGINE);
this->SetDirty();
if (_ctrl_pressed) {
this->OnClick(pt, WID_BV_SHOW_HIDE, 1);
@@ -1323,7 +1419,9 @@ struct BuildVehicleWindow : Window {
EngineID sel_eng = this->sel_engine;
if (sel_eng != INVALID_ENGINE) {
CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle;
- DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
+ CargoID cargo = this->cargo_filter[this->cargo_filter_criteria];
+ if (cargo == CF_ANY) cargo = CF_NONE;
+ DoCommandP(this->window_number, sel_eng | (cargo << 24), 0, GetCmdBuildVeh(this->vehicle_type), callback);
}
break;
}
@@ -1345,7 +1443,7 @@ struct BuildVehicleWindow : Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
/* When switching to original acceleration model for road vehicles, clear the selected sort criteria if it is not available now. */
@@ -1358,7 +1456,7 @@ struct BuildVehicleWindow : Window {
this->eng_list.ForceRebuild();
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_BV_CAPTION:
@@ -1390,7 +1488,7 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_BV_LIST:
@@ -1411,6 +1509,13 @@ struct BuildVehicleWindow : Window {
break;
}
+ case WID_BV_BUILD:
+ *size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type);
+ *size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type));
+ size->width += padding.width;
+ size->height += padding.height;
+ break;
+
case WID_BV_SHOW_HIDE:
*size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
*size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type));
@@ -1420,11 +1525,11 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_BV_LIST:
- DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.Length()), this->sel_engine, false, DEFAULT_GROUP);
+ DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->eng_list.size()), this->sel_engine, false, DEFAULT_GROUP);
break;
case WID_BV_SORT_ASCENDING_DESCENDING:
@@ -1433,12 +1538,12 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
this->GenerateBuildList();
- this->vscroll->SetCount(this->eng_list.Length());
+ this->vscroll->SetCount((uint)this->eng_list.size());
- this->SetWidgetDisabledState(WID_BV_SHOW_HIDE, this->sel_engine == INVALID_ENGINE);
+ this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
this->DrawWidgets();
@@ -1448,7 +1553,7 @@ struct BuildVehicleWindow : Window {
if (this->sel_engine != INVALID_ENGINE) {
NWidgetBase *nwi = this->GetWidget(WID_BV_PANEL);
int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
- nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine);
+ nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine, this->te);
needed_height = max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM);
}
if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
@@ -1460,14 +1565,14 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (str == NULL) return;
DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), NULL, str);
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_BV_SORT_DROPDOWN:
@@ -1485,13 +1590,14 @@ struct BuildVehicleWindow : Window {
/* deactivate filter if criteria is 'Show All', activate it otherwise */
this->eng_list.SetFilterState(this->cargo_filter[this->cargo_filter_criteria] != CF_ANY);
this->eng_list.ForceRebuild();
+ this->SelectEngine(this->sel_engine);
}
break;
}
this->SetDirty();
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_BV_LIST);
}
diff --git a/src/cargomonitor.cpp b/src/cargomonitor.cpp
index b1d52d6b18..82f8d8e4cb 100644
--- a/src/cargomonitor.cpp
+++ b/src/cargomonitor.cpp
@@ -117,8 +117,9 @@ int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
* @param src_type type of \a src.
* @param src index of source.
* @param st station where the cargo is delivered to.
+ * @param dest industry index where the cargo is delivered to.
*/
-void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st)
+void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest)
{
if (amount == 0) return;
@@ -150,8 +151,9 @@ void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, Sour
if (iter != _cargo_deliveries.end()) iter->second += amount;
/* Industry delivery. */
- for (const Industry * const *ip = st->industries_near.Begin(); ip != st->industries_near.End(); ip++) {
- CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, (*ip)->index);
+ for (Industry *ind : st->industries_near) {
+ if (ind->index != dest) continue;
+ CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, ind->index);
CargoMonitorMap::iterator iter = _cargo_deliveries.find(num);
if (iter != _cargo_deliveries.end()) iter->second += amount;
}
diff --git a/src/cargomonitor.h b/src/cargomonitor.h
index e74f717e05..c7e5da135b 100644
--- a/src/cargomonitor.h
+++ b/src/cargomonitor.h
@@ -149,6 +149,6 @@ void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER);
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
-void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st);
+void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest = INVALID_INDUSTRY);
#endif /* CARGOMONITOR_H */
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index fda2b246e4..e6bfc8c0a2 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -221,7 +221,7 @@ struct CheatWindow : Window {
this->InitNested();
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_C_PANEL) return;
@@ -283,7 +283,7 @@ struct CheatWindow : Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget != WID_C_PANEL) return;
@@ -330,7 +330,7 @@ struct CheatWindow : Window {
size->height = this->header_height + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui);
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
const NWidgetBase *wid = this->GetWidget(WID_C_PANEL);
uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / this->line_height;
@@ -384,13 +384,13 @@ struct CheatWindow : Window {
this->SetDirty();
}
- virtual void OnTimeout()
+ void OnTimeout() override
{
this->clicked = 0;
this->SetDirty();
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
/* Was 'cancel' pressed or nothing entered? */
if (str == NULL || StrEmpty(str)) return;
diff --git a/src/command.cpp b/src/command.cpp
index 72b3f4302e..b914563fc4 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -469,7 +469,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
/* only execute the test call if it's toplevel, or we're not execing. */
if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
- if (_docommand_recursive == 1) _cleared_object_areas.Clear();
+ if (_docommand_recursive == 1) _cleared_object_areas.clear();
SetTownRatingTestMode(true);
res = proc(tile, flags & ~DC_EXEC, p1, p2, text);
SetTownRatingTestMode(false);
@@ -492,7 +492,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
/* Execute the command here. All cost-relevant functions set the expenses type
* themselves to the cost object at some point */
- if (_docommand_recursive == 1) _cleared_object_areas.Clear();
+ if (_docommand_recursive == 1) _cleared_object_areas.clear();
res = proc(tile, flags, p1, p2, text);
if (res.Failed()) {
error:
@@ -573,10 +573,8 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
return false;
}
-#ifdef ENABLE_NETWORK
/* Only set p2 when the command does not come from the network. */
if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
-#endif
CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
if (res.Failed()) {
@@ -646,10 +644,8 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
/* Flags get send to the DoCommand */
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
-#ifdef ENABLE_NETWORK
/* Make sure p2 is properly set to a ClientID. */
assert(!(cmd_flags & CMD_CLIENT_ID) || p2 != 0);
-#endif
/* Do not even think about executing out-of-bounds tile-commands */
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR);
@@ -670,7 +666,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
/* Test the command. */
- _cleared_object_areas.Clear();
+ _cleared_object_areas.clear();
SetTownRatingTestMode(true);
BasePersistentStorageArray::SwitchMode(PSM_ENTER_TESTMODE);
CommandCost res = proc(tile, flags, p1, p2, text);
@@ -696,7 +692,6 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
return_dcpi(res);
}
-#ifdef ENABLE_NETWORK
/*
* If we are in network, and the command is not from the network
* send it to the command-queue and abort execution
@@ -711,12 +706,11 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
* reset the storages as we've not executed the command. */
return_dcpi(CommandCost());
}
-#endif /* ENABLE_NETWORK */
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
/* Actually try and execute the command. If no cost-type is given
* use the construction one */
- _cleared_object_areas.Clear();
+ _cleared_object_areas.clear();
BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
diff --git a/src/command_func.h b/src/command_func.h
index 3369475675..ea42f25d35 100644
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -42,9 +42,7 @@ bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
-#ifdef ENABLE_NETWORK
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
-#endif /* ENABLE_NETWORK */
extern Money _additional_cash_required;
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 8cc876751c..df0588f919 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -104,10 +104,8 @@ void SetLocalCompany(CompanyID new_company)
/* company could also be COMPANY_SPECTATOR or OWNER_NONE */
assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
-#ifdef ENABLE_NETWORK
/* Delete the chat window, if you were team chatting. */
InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_TEAM, _local_company);
-#endif
assert(IsLocalCompany());
@@ -597,9 +595,7 @@ void StartupCompanies()
/** Start a new competitor company if possible. */
static bool MaybeStartNewCompany()
{
-#ifdef ENABLE_NETWORK
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return false;
-#endif /* ENABLE_NETWORK */
Company *c;
@@ -792,9 +788,7 @@ void CompanyNewsInformation::FillData(const Company *c, const Company *other)
*/
void CompanyAdminUpdate(const Company *company)
{
-#ifdef ENABLE_NETWORK
if (_network_server) NetworkAdminCompanyUpdate(company);
-#endif /* ENABLE_NETWORK */
}
/**
@@ -804,9 +798,7 @@ void CompanyAdminUpdate(const Company *company)
*/
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
{
-#ifdef ENABLE_NETWORK
if (_network_server) NetworkAdminCompanyRemove(company_id, (AdminCompanyRemoveReason)reason);
-#endif /* ENABLE_NETWORK */
}
/**
@@ -815,10 +807,9 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
* @param flags operation to perform
* @param p1 various functionality
* - bits 0..15: CompanyCtrlAction
- * - bits 16..24: CompanyID
- * @param p2 various depending on CompanyCtrlAction
- * - bits 0..31: ClientID (with CCA_NEW)
- * - bits 0..1: CompanyRemoveReason (with CCA_DELETE)
+ * - bits 16..23: CompanyID
+ * - bits 24..31: CompanyRemoveReason (with CCA_DELETE)
+ * @param p2 ClientID
* @param text unused
* @return the cost of this operation or an error
*/
@@ -832,7 +823,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* This command is only executed in a multiplayer game */
if (!_networking) return CMD_ERROR;
-#ifdef ENABLE_NETWORK
/* Has the network client a correct ClientIndex? */
if (!(flags & DC_EXEC)) return CommandCost();
@@ -876,7 +866,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
NetworkServerNewCompany(c, ci);
-#endif /* ENABLE_NETWORK */
break;
}
@@ -885,14 +874,12 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
Company *c = DoStartupNewCompany(true, company_id);
-#ifdef ENABLE_NETWORK
if (c != NULL) NetworkServerNewCompany(c, NULL);
-#endif /* ENABLE_NETWORK */
break;
}
case CCA_DELETE: { // Delete a company
- CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
+ CompanyRemoveReason reason = (CompanyRemoveReason)GB(p1, 24, 8);
if (reason >= CRR_END) return CMD_ERROR;
Company *c = Company::GetIfValid(company_id);
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 5a751a3635..a3f8a24b6c 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -284,7 +284,7 @@ struct CompanyFinancesWindow : Window {
this->owner = (Owner)this->window_number;
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_CF_CAPTION:
@@ -303,7 +303,7 @@ struct CompanyFinancesWindow : Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
int type = _settings_client.gui.expenses_layout;
switch (widget) {
@@ -331,7 +331,7 @@ struct CompanyFinancesWindow : Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_CF_EXPS_CATEGORY:
@@ -392,7 +392,7 @@ struct CompanyFinancesWindow : Window {
this->GetWidget(WID_CF_SEL_BUTTONS)->SetDisplayedPlane(plane);
}
- virtual void OnPaint()
+ void OnPaint() override
{
if (!this->IsShaded()) {
if (!this->small) {
@@ -422,7 +422,7 @@ struct CompanyFinancesWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_CF_TOGGLE_SIZE: // toggle size
@@ -451,7 +451,7 @@ struct CompanyFinancesWindow : Window {
}
}
- virtual void OnHundredthTick()
+ void OnHundredthTick() override
{
const Company *c = Company::Get((CompanyID)this->window_number);
if (c->money > CompanyFinancesWindow::max_money) {
@@ -519,24 +519,22 @@ class DropDownListColourItem : public DropDownListItem {
public:
DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
- virtual ~DropDownListColourItem() {}
-
StringID String() const
{
return this->result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[this->result];
}
- uint Height(uint width) const
+ uint Height(uint width) const override
{
return max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + 2);
}
- bool Selectable() const
+ bool Selectable() const override
{
return true;
}
- void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
+ void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override
{
bool rtl = _current_text_dir == TD_RTL;
int height = bottom - top;
@@ -564,7 +562,7 @@ private:
uint rows;
uint line_height;
GUIGroupList groups;
- SmallVector indents;
+ std::vector indents;
Scrollbar *vscroll;
void ShowColourDropDownMenu(uint32 widget)
@@ -608,10 +606,10 @@ private:
if (default_livery != NULL) {
/* Add COLOUR_END to put the colour out of range, but also allow us to show what the default is */
default_col = (primary ? default_livery->colour1 : default_livery->colour2) + COLOUR_END;
- *list->Append() = new DropDownListColourItem(default_col, false);
+ list->push_back(new DropDownListColourItem(default_col, false));
}
for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
- *list->Append() = new DropDownListColourItem(i, HasBit(used_colours, i));
+ list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
}
byte sel = (default_livery == NULL || HasBit(livery->in_use, primary ? 0 : 1)) ? (primary ? livery->colour1 : livery->colour2) : default_col;
@@ -642,11 +640,11 @@ private:
void AddChildren(GUIGroupList *source, GroupID parent, int indent)
{
- for (const Group **g = source->Begin(); g != source->End(); g++) {
- if ((*g)->parent != parent) continue;
- *this->groups.Append() = *g;
- *this->indents.Append() = indent;
- AddChildren(source, (*g)->index, indent + 1);
+ for (const Group *g : *source) {
+ if (g->parent != parent) continue;
+ this->groups.push_back(g);
+ this->indents.push_back(indent);
+ AddChildren(source, g->index, indent + 1);
}
}
@@ -654,8 +652,8 @@ private:
{
if (!this->groups.NeedRebuild()) return;
- this->groups.Clear();
- this->indents.Clear();
+ this->groups.clear();
+ this->indents.clear();
if (this->livery_class >= LC_GROUP_RAIL) {
GUIGroupList list;
@@ -664,7 +662,7 @@ private:
const Group *g;
FOR_ALL_GROUPS(g) {
if (g->owner == owner && g->vehicle_type == vtype) {
- *list.Append() = g;
+ list.push_back(g);
}
}
@@ -674,7 +672,7 @@ private:
AddChildren(&list, INVALID_GROUP, 0);
}
- this->groups.Compact();
+ this->groups.shrink_to_fit();
this->groups.RebuildDone();
}
@@ -688,7 +686,7 @@ private:
}
}
} else {
- this->rows = this->groups.Length();
+ this->rows = (uint)this->groups.size();
}
this->vscroll->SetCount(this->rows);
@@ -707,7 +705,7 @@ public:
this->BuildGroupList(company);
this->SetRows();
} else {
- this->SetSelectedGroup(group);
+ this->SetSelectedGroup(company, group);
}
this->FinishInitNested(company);
@@ -715,7 +713,7 @@ public:
this->InvalidateData(1);
}
- void SetSelectedGroup(GroupID group)
+ void SetSelectedGroup(CompanyID company, GroupID group)
{
this->RaiseWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
const Group *g = Group::Get(group);
@@ -730,7 +728,7 @@ public:
this->LowerWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
this->groups.ForceRebuild();
- this->BuildGroupList((CompanyID)this->window_number);
+ this->BuildGroupList(company);
this->SetRows();
/* Position scrollbar to selected group */
@@ -742,7 +740,7 @@ public:
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_SCL_SPACER_DROPDOWN: {
@@ -795,7 +793,7 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
bool local = (CompanyID)this->window_number == _local_company;
@@ -809,7 +807,7 @@ public:
this->DrawWidgets();
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_SCL_CAPTION:
@@ -849,7 +847,7 @@ public:
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_SCL_MATRIX) return;
@@ -904,7 +902,7 @@ public:
}
}
} else {
- uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.Length());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->groups.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Group *g = this->groups[i];
SetDParam(0, g->index);
@@ -913,7 +911,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
/* Livery Class buttons */
@@ -944,7 +942,7 @@ public:
this->groups.ForceRebuild();
this->BuildGroupList((CompanyID)this->window_number);
- if (this->groups.Length() > 0) {
+ if (this->groups.size() > 0) {
this->sel = this->groups[0]->index;
}
}
@@ -987,12 +985,12 @@ public:
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_SCL_MATRIX);
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
bool local = (CompanyID)this->window_number == _local_company;
if (!local) return;
@@ -1018,16 +1016,22 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
if (data != -1) {
/* data contains a VehicleType, rebuild list if it displayed */
if (this->livery_class == data + LC_GROUP_RAIL) {
- if (!Group::IsValidID(this->sel)) this->sel = INVALID_GROUP;
this->groups.ForceRebuild();
this->BuildGroupList((CompanyID)this->window_number);
+ this->SetRows();
+
+ if (!Group::IsValidID(this->sel)) {
+ this->sel = INVALID_GROUP;
+ if (this->groups.size() > 0) this->sel = this->groups[0]->index;
+ }
+
this->SetDirty();
}
return;
@@ -1099,7 +1103,7 @@ void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
if (w == NULL) {
new SelectCompanyLiveryWindow(&_select_company_livery_desc, company, group);
} else if (group != INVALID_GROUP) {
- w->SetSelectedGroup(group);
+ w->SetSelectedGroup(company, group);
}
}
@@ -1364,7 +1368,7 @@ public:
}
}
- virtual void OnInit()
+ void OnInit() override
{
/* Size of the boolean yes/no button. */
Dimension yesno_dim = maxdim(GetStringBoundingBox(STR_FACE_YES), GetStringBoundingBox(STR_FACE_NO));
@@ -1387,7 +1391,7 @@ public:
this->number_dim = number_dim;
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_SCMF_FACE: {
@@ -1446,7 +1450,7 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
/* lower the non-selected gender button */
this->SetWidgetsLoweredState(!this->is_female, WID_SCMF_MALE, WID_SCMF_MALE2, WIDGET_LIST_END);
@@ -1507,7 +1511,7 @@ public:
this->DrawWidgets();
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
@@ -1596,7 +1600,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
/* Toggle size, advanced/simple face selection */
@@ -1705,7 +1709,7 @@ public:
}
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (str == NULL) return;
/* Set a new company manager face number */
@@ -1860,7 +1864,7 @@ struct CompanyInfrastructureWindow : Window
return total;
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_CI_CAPTION:
@@ -1869,7 +1873,7 @@ struct CompanyInfrastructureWindow : Window
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
const Company *c = Company::Get((CompanyID)this->window_number);
@@ -1992,7 +1996,7 @@ struct CompanyInfrastructureWindow : Window
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
const Company *c = Company::Get((CompanyID)this->window_number);
int y = r.top;
@@ -2095,7 +2099,7 @@ struct CompanyInfrastructureWindow : Window
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
@@ -2261,7 +2265,7 @@ struct CompanyWindow : Window
this->OnInvalidateData();
}
- virtual void OnPaint()
+ void OnPaint() override
{
const Company *c = Company::Get((CompanyID)this->window_number);
bool local = this->window_number == _local_company;
@@ -2330,7 +2334,7 @@ struct CompanyWindow : Window
this->DrawWidgets();
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_C_FACE: {
@@ -2383,15 +2387,13 @@ struct CompanyWindow : Window
break;
}
-#ifdef ENABLE_NETWORK
case WID_C_HAS_PASSWORD:
*size = maxdim(*size, GetSpriteSize(SPR_LOCK));
break;
-#endif /* ENABLE_NETWORK */
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
const Company *c = Company::Get((CompanyID)this->window_number);
switch (widget) {
@@ -2494,17 +2496,15 @@ struct CompanyWindow : Window
break;
}
-#ifdef ENABLE_NETWORK
case WID_C_HAS_PASSWORD:
if (_networking && NetworkCompanyIsPassworded(c->index)) {
DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
}
break;
-#endif /* ENABLE_NETWORK */
}
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_C_CAPTION:
@@ -2522,7 +2522,7 @@ struct CompanyWindow : Window
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_C_NEW_FACE: DoSelectCompanyManagerFace(this); break;
@@ -2590,7 +2590,6 @@ struct CompanyWindow : Window
DoCommandP(0, this->window_number, 0, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_SELL_25_SHARE_IN));
break;
-#ifdef ENABLE_NETWORK
case WID_C_COMPANY_PASSWORD:
if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
break;
@@ -2610,17 +2609,16 @@ struct CompanyWindow : Window
}
break;
}
-#endif /* ENABLE_NETWORK */
}
}
- virtual void OnHundredthTick()
+ void OnHundredthTick() override
{
/* redraw the window every now and then */
this->SetDirty();
}
- virtual void OnPlaceObject(Point pt, TileIndex tile)
+ void OnPlaceObject(Point pt, TileIndex tile) override
{
if (DoCommandP(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS)) && !_shift_pressed) {
ResetObjectToPlace();
@@ -2628,12 +2626,12 @@ struct CompanyWindow : Window
}
}
- virtual void OnPlaceObjectAbort()
+ void OnPlaceObjectAbort() override
{
this->RaiseButtons();
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (str == NULL) return;
@@ -2648,11 +2646,9 @@ struct CompanyWindow : Window
DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), NULL, str);
break;
-#ifdef ENABLE_NETWORK
case WID_C_COMPANY_JOIN:
NetworkClientRequestMove((CompanyID)this->window_number, str);
break;
-#endif /* ENABLE_NETWORK */
}
}
@@ -2662,7 +2658,7 @@ struct CompanyWindow : Window
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (this->window_number == _local_company) return;
@@ -2721,7 +2717,7 @@ struct BuyCompanyWindow : Window {
this->InitNested(window_number);
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_BC_FACE:
@@ -2737,7 +2733,7 @@ struct BuyCompanyWindow : Window {
}
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_BC_CAPTION:
@@ -2747,7 +2743,7 @@ struct BuyCompanyWindow : Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_BC_FACE: {
@@ -2766,7 +2762,7 @@ struct BuyCompanyWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_BC_NO:
diff --git a/src/console.cpp b/src/console.cpp
index 2cf9d96958..c7f24a9dc5 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -33,10 +33,8 @@ FILE *_iconsole_output_file;
void IConsoleInit()
{
_iconsole_output_file = NULL;
-#ifdef ENABLE_NETWORK /* Initialize network only variables */
_redirect_console_to_client = INVALID_CLIENT_ID;
_redirect_console_to_admin = INVALID_ADMIN_ID;
-#endif
IConsoleGUIInit();
@@ -90,7 +88,6 @@ void IConsolePrint(TextColour colour_code, const char *string)
assert(IsValidConsoleColour(colour_code));
char *str;
-#ifdef ENABLE_NETWORK
if (_redirect_console_to_client != INVALID_CLIENT_ID) {
/* Redirect the string to the client */
NetworkServerSendRcon(_redirect_console_to_client, colour_code, string);
@@ -101,7 +98,6 @@ void IConsolePrint(TextColour colour_code, const char *string)
NetworkServerSendAdminRcon(_redirect_console_to_admin, colour_code, string);
return;
}
-#endif
/* Create a copy of the string, strip if of colours and invalid
* characters and (when applicable) assign it to the console buffer */
@@ -110,9 +106,7 @@ void IConsolePrint(TextColour colour_code, const char *string)
str_validate(str, str + strlen(str));
if (_network_dedicated) {
-#ifdef ENABLE_NETWORK
NetworkAdminConsole("console", str);
-#endif /* ENABLE_NETWORK */
fprintf(stdout, "%s%s\n", GetLogPrefix(), str);
fflush(stdout);
IConsoleWriteToLogFile(str);
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 732ace6a2b..00b9536946 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -86,8 +86,6 @@ static ConsoleFileList _console_file_list; ///< File storage cache for the conso
* command hooks
****************/
-#ifdef ENABLE_NETWORK
-
/**
* Check network availability and inform in console about failure of detection.
* @return Network availability.
@@ -159,10 +157,6 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork)
return CHR_ALLOW;
}
-#else
-# define ConHookNoNetwork NULL
-#endif /* ENABLE_NETWORK */
-
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
{
if (_settings_client.gui.newgrf_developer_tools) {
@@ -170,11 +164,7 @@ DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
if (echo) IConsoleError("This command is only available in game and editor.");
return CHR_DISALLOW;
}
-#ifdef ENABLE_NETWORK
return ConHookNoNetwork(echo);
-#else
- return CHR_ALLOW;
-#endif
}
return CHR_HIDE;
}
@@ -479,7 +469,6 @@ DEF_CONSOLE_CMD(ConClearBuffer)
/**********************************
* Network Core Console Commands
**********************************/
-#ifdef ENABLE_NETWORK
static bool ConKickOrBan(const char *argv, bool ban)
{
@@ -563,21 +552,21 @@ DEF_CONSOLE_CMD(ConUnBan)
/* Try by IP. */
uint index;
- for (index = 0; index < _network_ban_list.Length(); index++) {
+ for (index = 0; index < _network_ban_list.size(); index++) {
if (strcmp(_network_ban_list[index], argv[1]) == 0) break;
}
/* Try by index. */
- if (index >= _network_ban_list.Length()) {
+ if (index >= _network_ban_list.size()) {
index = atoi(argv[1]) - 1U; // let it wrap
}
- if (index < _network_ban_list.Length()) {
+ if (index < _network_ban_list.size()) {
char msg[64];
seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
IConsolePrint(CC_DEFAULT, msg);
free(_network_ban_list[index]);
- _network_ban_list.Erase(_network_ban_list.Get(index));
+ _network_ban_list.erase(_network_ban_list.begin() + index);
} else {
IConsolePrint(CC_DEFAULT, "Invalid list index or IP not in ban-list.");
IConsolePrint(CC_DEFAULT, "For a list of banned IP's, see the command 'banlist'");
@@ -596,8 +585,8 @@ DEF_CONSOLE_CMD(ConBanList)
IConsolePrint(CC_DEFAULT, "Banlist: ");
uint i = 1;
- for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
- IConsolePrintF(CC_DEFAULT, " %d) %s", i, *iter);
+ for (char *entry : _network_ban_list) {
+ IConsolePrintF(CC_DEFAULT, " %d) %s", i, entry);
}
return true;
@@ -836,7 +825,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
}
/* It is safe to remove this company */
- DoCommandP(0, CCA_DELETE | index << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | index << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "Company deleted.");
return true;
@@ -930,8 +919,6 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
return true;
}
-#endif /* ENABLE_NETWORK */
-
/*********************************
* script file console commands
*********************************/
@@ -1213,7 +1200,7 @@ DEF_CONSOLE_CMD(ConReloadAI)
}
/* First kill the company of the AI, then start a new one. This should start the current AI again */
- DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0,CMD_COMPANY_CTRL);
DoCommandP(0, CCA_NEW_AI | company_id << 16, 0, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI reloaded.");
@@ -1250,7 +1237,7 @@ DEF_CONSOLE_CMD(ConStopAI)
}
/* Now kill the company of the AI. */
- DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
return true;
@@ -1547,12 +1534,9 @@ DEF_CONSOLE_CMD(ConCompanies)
const char *password_state = "";
if (c->is_ai) {
password_state = "AI";
- }
-#ifdef ENABLE_NETWORK
- else if (_network_server) {
+ } else if (_network_server) {
password_state = StrEmpty(_network_company_states[c->index].password) ? "unprotected" : "protected";
}
-#endif
char colour[512];
GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
@@ -1569,8 +1553,6 @@ DEF_CONSOLE_CMD(ConCompanies)
return true;
}
-#ifdef ENABLE_NETWORK
-
DEF_CONSOLE_CMD(ConSay)
{
if (argc == 0) {
@@ -1812,7 +1794,6 @@ DEF_CONSOLE_CMD(ConContent)
return false;
}
#endif /* defined(WITH_ZLIB) */
-#endif /* ENABLE_NETWORK */
DEF_CONSOLE_CMD(ConSetting)
{
@@ -1992,7 +1973,7 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("players", "companies");
/* networking functions */
-#ifdef ENABLE_NETWORK
+
/* Content downloading is only available with ZLIB */
#if defined(WITH_ZLIB)
IConsoleCmdRegister("content", ConContent);
@@ -2050,7 +2031,6 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("restart_game_year", "setting restart_game_year %+");
IConsoleAliasRegister("min_players", "setting min_active_clients %+");
IConsoleAliasRegister("reload_cfg", "setting reload_cfg %+");
-#endif /* ENABLE_NETWORK */
/* debugging stuff */
#ifdef _DEBUG
diff --git a/src/console_gui.cpp b/src/console_gui.cpp
index ed46938cd5..3ee13946f2 100644
--- a/src/console_gui.cpp
+++ b/src/console_gui.cpp
@@ -201,7 +201,7 @@ struct IConsoleWindow : Window
this->SetDirty();
}
- virtual void OnPaint()
+ void OnPaint() override
{
const int right = this->width - 5;
@@ -229,7 +229,7 @@ struct IConsoleWindow : Window
}
}
- virtual void OnHundredthTick()
+ void OnHundredthTick() override
{
if (IConsoleLine::Truncate() &&
(IConsoleWindow::scroll > IConsoleLine::size)) {
@@ -238,12 +238,12 @@ struct IConsoleWindow : Window
}
}
- virtual void OnMouseLoop()
+ void OnMouseLoop() override
{
if (_iconsole_cmdline.HandleCaret()) this->SetDirty();
}
- virtual EventState OnKeyPress(WChar key, uint16 keycode)
+ EventState OnKeyPress(WChar key, uint16 keycode) override
{
if (_focused_window != this) return ES_NOT_HANDLED;
@@ -314,7 +314,7 @@ struct IConsoleWindow : Window
return ES_HANDLED;
}
- virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
+ void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override
{
if (_iconsole_cmdline.InsertString(str, marked, caret, insert_location, replacement_end)) {
IConsoleWindow::scroll = 0;
@@ -323,17 +323,17 @@ struct IConsoleWindow : Window
}
}
- virtual const char *GetFocusedText() const
+ const char *GetFocusedText() const override
{
return _iconsole_cmdline.buf;
}
- virtual const char *GetCaret() const
+ const char *GetCaret() const override
{
return _iconsole_cmdline.buf + _iconsole_cmdline.caretpos;
}
- virtual const char *GetMarkedText(size_t *length) const
+ const char *GetMarkedText(size_t *length) const override
{
if (_iconsole_cmdline.markend == 0) return NULL;
@@ -341,7 +341,7 @@ struct IConsoleWindow : Window
return _iconsole_cmdline.buf + _iconsole_cmdline.markpos;
}
- virtual Point GetCaretPosition() const
+ Point GetCaretPosition() const override
{
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
Point pt = {this->line_offset + delta + _iconsole_cmdline.caretxoffs, this->height - this->line_height};
@@ -349,7 +349,7 @@ struct IConsoleWindow : Window
return pt;
}
- virtual Rect GetTextBoundingRect(const char *from, const char *to) const
+ Rect GetTextBoundingRect(const char *from, const char *to) const override
{
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
@@ -360,7 +360,7 @@ struct IConsoleWindow : Window
return r;
}
- virtual const char *GetTextCharacterAtPosition(const Point &pt) const
+ const char *GetTextCharacterAtPosition(const Point &pt) const override
{
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
@@ -369,12 +369,12 @@ struct IConsoleWindow : Window
return GetCharAtPosition(_iconsole_cmdline.buf, pt.x - delta);
}
- virtual void OnMouseWheel(int wheel)
+ void OnMouseWheel(int wheel) override
{
this->Scroll(-wheel);
}
- virtual void OnFocusLost()
+ void OnFocusLost() override
{
VideoDriver::GetInstance()->EditBoxLostFocus();
}
diff --git a/src/core/alloc_type.hpp b/src/core/alloc_type.hpp
index 9c25cc9e3f..5ea812b0e5 100644
--- a/src/core/alloc_type.hpp
+++ b/src/core/alloc_type.hpp
@@ -25,24 +25,8 @@
*/
template
struct SmallStackSafeStackAlloc {
-#if !defined(__NDS__)
/** Storing the data on the stack */
T data[length];
-#else
- /** Storing it on the heap */
- T *data;
- /** The length (in elements) of data in this allocator. */
- size_t len;
-
- /** Allocating the memory */
- SmallStackSafeStackAlloc() : data(MallocT(length)), len(length) {}
-
- /** And freeing when it goes out of scope */
- ~SmallStackSafeStackAlloc()
- {
- free(data);
- }
-#endif
/**
* Gets a pointer to the data stored in this wrapper.
@@ -69,11 +53,7 @@ struct SmallStackSafeStackAlloc {
*/
inline T *EndOf()
{
-#if !defined(__NDS__)
return endof(data);
-#else
- return &data[len];
-#endif
}
};
diff --git a/src/core/endian_type.hpp b/src/core/endian_type.hpp
index 4058c5c19a..1cacf6c0cb 100644
--- a/src/core/endian_type.hpp
+++ b/src/core/endian_type.hpp
@@ -26,7 +26,7 @@
#define TTD_BIG_ENDIAN 1
/* Windows has always LITTLE_ENDIAN */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__)
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
#elif defined(OSX)
# include
diff --git a/src/core/geometry_type.hpp b/src/core/geometry_type.hpp
index 2bd8ffbade..d1f363127b 100644
--- a/src/core/geometry_type.hpp
+++ b/src/core/geometry_type.hpp
@@ -12,11 +12,6 @@
#ifndef GEOMETRY_TYPE_HPP
#define GEOMETRY_TYPE_HPP
-#if defined(__AMIGA__)
- /* AmigaOS already has a Point declared */
- #define Point OTTD_Point
-#endif /* __AMIGA__ */
-
#if defined(__APPLE__)
/* Mac OS X already has both Rect and Point declared */
#define Rect OTTD_Rect
diff --git a/src/core/kdtree.hpp b/src/core/kdtree.hpp
new file mode 100644
index 0000000000..154f27fc5b
--- /dev/null
+++ b/src/core/kdtree.hpp
@@ -0,0 +1,473 @@
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file kdtree.hpp K-d tree template specialised for 2-dimensional Manhattan geometry */
+
+#ifndef KDTREE_HPP
+#define KDTREE_HPP
+
+#include "../stdafx.h"
+#include
+#include
+#include
+
+/**
+ * K-dimensional tree, specialised for 2-dimensional space.
+ * This is not intended as a primary storage of data, but as an index into existing data.
+ * Usually the type stored by this tree should be an index into an existing array.
+ *
+ * This implementation assumes Manhattan distances are used.
+ *
+ * Be careful when using this in game code, depending on usage pattern, the tree shape may
+ * end up different for different clients in multiplayer, causing iteration order to differ
+ * and possibly having elements returned in different order. The using code should be designed
+ * to produce the same result regardless of iteration order.
+ *
+ * The element type T must be less-than comparable for FindNearest to work.
+ *
+ * @tparam T Type stored in the tree, should be cheap to copy.
+ * @tparam TxyFunc Functor type to extract coordinate from a T value and dimension index (0 or 1).
+ * @tparam CoordT Type of coordinate values extracted via TxyFunc.
+ * @tparam DistT Type to use for representing distance values.
+ */
+template
+class Kdtree {
+ /** Type of a node in the tree */
+ struct node {
+ T element; ///< Element stored at node
+ size_t left; ///< Index of node to the left, INVALID_NODE if none
+ size_t right; ///< Index of node to the right, INVALID_NODE if none
+
+ node(T element) : element(element), left(INVALID_NODE), right(INVALID_NODE) { }
+ };
+
+ static const size_t INVALID_NODE = SIZE_MAX; ///< Index value indicating no-such-node
+
+ std::vector nodes; ///< Pool of all nodes in the tree
+ std::vector free_list; ///< List of dead indices in the nodes vector
+ size_t root; ///< Index of root node
+ TxyFunc xyfunc; ///< Functor to extract a coordinate from an element
+ size_t unbalanced; ///< Number approximating how unbalanced the tree might be
+
+ /** Create one new node in the tree, return its index in the pool */
+ size_t AddNode(const T &element)
+ {
+ if (this->free_list.size() == 0) {
+ this->nodes.emplace_back(element);
+ return this->nodes.size() - 1;
+ } else {
+ size_t newidx = this->free_list.back();
+ this->free_list.pop_back();
+ this->nodes[newidx] = node{ element };
+ return newidx;
+ }
+ }
+
+ /** Find a coordinate value to split a range of elements at */
+ template
+ CoordT SelectSplitCoord(It begin, It end, int level)
+ {
+ It mid = begin + (end - begin) / 2;
+ std::nth_element(begin, mid, end, [&](T a, T b) { return this->xyfunc(a, level % 2) < this->xyfunc(b, level % 2); });
+ return this->xyfunc(*mid, level % 2);
+ }
+
+ /** Construct a subtree from elements between begin and end iterators, return index of root */
+ template
+ size_t BuildSubtree(It begin, It end, int level)
+ {
+ ptrdiff_t count = end - begin;
+
+ if (count == 0) {
+ return INVALID_NODE;
+ } else if (count == 1) {
+ return this->AddNode(*begin);
+ } else if (count > 1) {
+ CoordT split_coord = SelectSplitCoord(begin, end, level);
+ It split = std::partition(begin, end, [&](T v) { return this->xyfunc(v, level % 2) < split_coord; });
+ size_t newidx = this->AddNode(*split);
+ this->nodes[newidx].left = this->BuildSubtree(begin, split, level + 1);
+ this->nodes[newidx].right = this->BuildSubtree(split + 1, end, level + 1);
+ return newidx;
+ } else {
+ NOT_REACHED();
+ }
+ }
+
+ /** Rebuild the tree with all existing elements, optionally adding or removing one more */
+ bool Rebuild(const T *include_element, const T *exclude_element)
+ {
+ size_t initial_count = this->Count();
+ if (initial_count < 8) return false; // arbitrary value for "not worth rebalancing"
+
+ T root_element = this->nodes[this->root].element;
+ std::vector elements = this->FreeSubtree(this->root);
+ elements.push_back(root_element);
+
+ if (include_element != NULL) {
+ elements.push_back(*include_element);
+ initial_count++;
+ }
+ if (exclude_element != NULL) {
+ typename std::vector::iterator removed = std::remove(elements.begin(), elements.end(), *exclude_element);
+ elements.erase(removed, elements.end());
+ initial_count--;
+ }
+
+ this->Build(elements.begin(), elements.end());
+ assert(initial_count == this->Count());
+ return true;
+ }
+
+ /** Insert one element in the tree somewhere below node_idx */
+ void InsertRecursive(const T &element, size_t node_idx, int level)
+ {
+ /* Dimension index of current level */
+ int dim = level % 2;
+ /* Node reference */
+ node &n = this->nodes[node_idx];
+
+ /* Coordinate of element splitting at this node */
+ CoordT nc = this->xyfunc(n.element, dim);
+ /* Coordinate of the new element */
+ CoordT ec = this->xyfunc(element, dim);
+ /* Which side to insert on */
+ size_t &next = (ec < nc) ? n.left : n.right;
+
+ if (next == INVALID_NODE) {
+ /* New leaf */
+ size_t newidx = this->AddNode(element);
+ /* Vector may have been reallocated at this point, n and next are invalid */
+ node &nn = this->nodes[node_idx];
+ if (ec < nc) nn.left = newidx; else nn.right = newidx;
+ } else {
+ this->InsertRecursive(element, next, level + 1);
+ }
+ }
+
+ /**
+ * Free all children of the given node
+ * @return Collection of elements that were removed from tree.
+ */
+ std::vector FreeSubtree(size_t node_idx)
+ {
+ std::vector subtree_elements;
+ node &n = this->nodes[node_idx];
+
+ /* We'll be appending items to the free_list, get index of our first item */
+ size_t first_free = this->free_list.size();
+ /* Prepare the descent with our children */
+ if (n.left != INVALID_NODE) this->free_list.push_back(n.left);
+ if (n.right != INVALID_NODE) this->free_list.push_back(n.right);
+ n.left = n.right = INVALID_NODE;
+
+ /* Recursively free the nodes being collected */
+ for (size_t i = first_free; i < this->free_list.size(); i++) {
+ node &fn = this->nodes[this->free_list[i]];
+ subtree_elements.push_back(fn.element);
+ if (fn.left != INVALID_NODE) this->free_list.push_back(fn.left);
+ if (fn.right != INVALID_NODE) this->free_list.push_back(fn.right);
+ fn.left = fn.right = INVALID_NODE;
+ }
+
+ return subtree_elements;
+ }
+
+ /**
+ * Find and remove one element from the tree.
+ * @param element The element to search for
+ * @param node_idx Sub-tree to search in
+ * @param level Current depth in the tree
+ * @return New root node index of the sub-tree processed
+ */
+ size_t RemoveRecursive(const T &element, size_t node_idx, int level)
+ {
+ /* Node reference */
+ node &n = this->nodes[node_idx];
+
+ if (n.element == element) {
+ /* Remove this one */
+ this->free_list.push_back(node_idx);
+ if (n.left == INVALID_NODE && n.right == INVALID_NODE) {
+ /* Simple case, leaf, new child node for parent is "none" */
+ return INVALID_NODE;
+ } else {
+ /* Complex case, rebuild the sub-tree */
+ std::vector subtree_elements = this->FreeSubtree(node_idx);
+ return this->BuildSubtree(subtree_elements.begin(), subtree_elements.end(), level);;
+ }
+ } else {
+ /* Search in a sub-tree */
+ /* Dimension index of current level */
+ int dim = level % 2;
+ /* Coordinate of element splitting at this node */
+ CoordT nc = this->xyfunc(n.element, dim);
+ /* Coordinate of the element being removed */
+ CoordT ec = this->xyfunc(element, dim);
+ /* Which side to remove from */
+ size_t next = (ec < nc) ? n.left : n.right;
+ assert(next != INVALID_NODE); // node must exist somewhere and must be found before a leaf is reached
+ /* Descend */
+ size_t new_branch = this->RemoveRecursive(element, next, level + 1);
+ if (new_branch != next) {
+ /* Vector may have been reallocated at this point, n and next are invalid */
+ node &nn = this->nodes[node_idx];
+ if (ec < nc) nn.left = new_branch; else nn.right = new_branch;
+ }
+ return node_idx;
+ }
+ }
+
+
+ DistT ManhattanDistance(const T &element, CoordT x, CoordT y) const
+ {
+ return abs((DistT)this->xyfunc(element, 0) - (DistT)x) + abs((DistT)this->xyfunc(element, 1) - (DistT)y);
+ }
+
+ /** A data element and its distance to a searched-for point */
+ using node_distance = std::pair;
+ /** Ordering function for node_distance objects, elements with equal distance are ordered by less-than comparison */
+ static node_distance SelectNearestNodeDistance(const node_distance &a, const node_distance &b)
+ {
+ if (a.second < b.second) return a;
+ if (b.second < a.second) return b;
+ if (a.first < b.first) return a;
+ if (b.first < a.first) return b;
+ NOT_REACHED(); // a.first == b.first: same element must not be inserted twice
+ }
+ /** Search a sub-tree for the element nearest to a given point */
+ node_distance FindNearestRecursive(CoordT xy[2], size_t node_idx, int level) const
+ {
+ /* Dimension index of current level */
+ int dim = level % 2;
+ /* Node reference */
+ const node &n = this->nodes[node_idx];
+
+ /* Coordinate of element splitting at this node */
+ CoordT c = this->xyfunc(n.element, dim);
+ /* This node's distance to target */
+ DistT thisdist = ManhattanDistance(n.element, xy[0], xy[1]);
+ /* Assume this node is the best choice for now */
+ node_distance best = std::make_pair(n.element, thisdist);
+
+ /* Next node to visit */
+ size_t next = (xy[dim] < c) ? n.left : n.right;
+ if (next != INVALID_NODE) {
+ /* Check if there is a better node down the tree */
+ best = SelectNearestNodeDistance(best, this->FindNearestRecursive(xy, next, level + 1));
+ }
+
+ /* Check if the distance from current best is worse than distance from target to splitting line,
+ * if it is we also need to check the other side of the split. */
+ size_t opposite = (xy[dim] >= c) ? n.left : n.right; // reverse of above
+ if (opposite != INVALID_NODE && best.second >= abs((int)xy[dim] - (int)c)) {
+ node_distance other_candidate = this->FindNearestRecursive(xy, opposite, level + 1);
+ best = SelectNearestNodeDistance(best, other_candidate);
+ }
+
+ return best;
+ }
+
+ template
+ void FindContainedRecursive(CoordT p1[2], CoordT p2[2], size_t node_idx, int level, Outputter outputter) const
+ {
+ /* Dimension index of current level */
+ int dim = level % 2;
+ /* Node reference */
+ const node &n = this->nodes[node_idx];
+
+ /* Coordinate of element splitting at this node */
+ CoordT ec = this->xyfunc(n.element, dim);
+ /* Opposite coordinate of element */
+ CoordT oc = this->xyfunc(n.element, 1 - dim);
+
+ /* Test if this element is within rectangle */
+ if (ec >= p1[dim] && ec < p2[dim] && oc >= p1[1 - dim] && oc < p2[1 - dim]) outputter(n.element);
+
+ /* Recurse left if part of rectangle is left of split */
+ if (p1[dim] < ec && n.left != INVALID_NODE) this->FindContainedRecursive(p1, p2, n.left, level + 1, outputter);
+
+ /* Recurse right if part of rectangle is right of split */
+ if (p2[dim] > ec && n.right != INVALID_NODE) this->FindContainedRecursive(p1, p2, n.right, level + 1, outputter);
+ }
+
+ /** Debugging function, counts number of occurrences of an element regardless of its correct position in the tree */
+ size_t CountValue(const T &element, size_t node_idx) const
+ {
+ if (node_idx == INVALID_NODE) return 0;
+ const node &n = this->nodes[node_idx];
+ return CountValue(element, n.left) + CountValue(element, n.right) + ((n.element == element) ? 1 : 0);
+ }
+
+ void IncrementUnbalanced(size_t amount = 1)
+ {
+ this->unbalanced += amount;
+ }
+
+ /** Check if the entire tree is in need of rebuilding */
+ bool IsUnbalanced()
+ {
+ size_t count = this->Count();
+ if (count < 8) return false;
+ return this->unbalanced > this->Count() / 4;
+ }
+
+ /** Verify that the invariant is true for a sub-tree, assert if not */
+ void CheckInvariant(size_t node_idx, int level, CoordT min_x, CoordT max_x, CoordT min_y, CoordT max_y)
+ {
+ if (node_idx == INVALID_NODE) return;
+
+ const node &n = this->nodes[node_idx];
+ CoordT cx = this->xyfunc(n.element, 0);
+ CoordT cy = this->xyfunc(n.element, 1);
+
+ assert(cx >= min_x);
+ assert(cx < max_x);
+ assert(cy >= min_y);
+ assert(cy < max_y);
+
+ if (level % 2 == 0) {
+ // split in dimension 0 = x
+ CheckInvariant(n.left, level + 1, min_x, cx, min_y, max_y);
+ CheckInvariant(n.right, level + 1, cx, max_x, min_y, max_y);
+ } else {
+ // split in dimension 1 = y
+ CheckInvariant(n.left, level + 1, min_x, max_x, min_y, cy);
+ CheckInvariant(n.right, level + 1, min_x, max_x, cy, max_y);
+ }
+ }
+
+ /** Verify the invariant for the entire tree, does nothing unless KDTREE_DEBUG is defined */
+ void CheckInvariant()
+ {
+#ifdef KDTREE_DEBUG
+ CheckInvariant(this->root, 0, std::numeric_limits::min(), std::numeric_limits::max(), std::numeric_limits::min(), std::numeric_limits::max());
+#endif
+ }
+
+public:
+ /** Construct a new Kdtree with the given xyfunc */
+ Kdtree(TxyFunc xyfunc) : root(INVALID_NODE), xyfunc(xyfunc), unbalanced(0) { }
+
+ /**
+ * Clear and rebuild the tree from a new sequence of elements,
+ * @tparam It Iterator type for element sequence.
+ * @param begin First element in sequence.
+ * @param end One past last element in sequence.
+ */
+ template
+ void Build(It begin, It end)
+ {
+ this->nodes.clear();
+ this->free_list.clear();
+ this->unbalanced = 0;
+ if (begin == end) return;
+ this->nodes.reserve(end - begin);
+
+ this->root = this->BuildSubtree(begin, end, 0);
+ CheckInvariant();
+ }
+
+ /**
+ * Reconstruct the tree with the same elements, letting it be fully balanced.
+ */
+ void Rebuild()
+ {
+ this->Rebuild(NULL, NULL);
+ }
+
+ /**
+ * Insert a single element in the tree.
+ * Repeatedly inserting single elements may cause the tree to become unbalanced.
+ * Undefined behaviour if the element already exists in the tree.
+ */
+ void Insert(const T &element)
+ {
+ if (this->Count() == 0) {
+ this->root = this->AddNode(element);
+ } else {
+ if (!this->IsUnbalanced() || !this->Rebuild(&element, NULL)) {
+ this->InsertRecursive(element, this->root, 0);
+ this->IncrementUnbalanced();
+ }
+ CheckInvariant();
+ }
+ }
+
+ /**
+ * Remove a single element from the tree, if it exists.
+ * Since elements are stored in interior nodes as well as leaf nodes, removing one may
+ * require a larger sub-tree to be re-built. Because of this, worst case run time is
+ * as bad as a full tree rebuild.
+ */
+ void Remove(const T &element)
+ {
+ size_t count = this->Count();
+ if (count == 0) return;
+ if (!this->IsUnbalanced() || !this->Rebuild(NULL, &element)) {
+ /* If the removed element is the root node, this modifies this->root */
+ this->root = this->RemoveRecursive(element, this->root, 0);
+ this->IncrementUnbalanced();
+ }
+ CheckInvariant();
+ }
+
+ /** Get number of elements stored in tree */
+ size_t Count() const
+ {
+ assert(this->free_list.size() <= this->nodes.size());
+ return this->nodes.size() - this->free_list.size();
+ }
+
+ /**
+ * Find the element closest to given coordinate, in Manhattan distance.
+ * For multiple elements with the same distance, the one comparing smaller with
+ * a less-than comparison is chosen.
+ */
+ T FindNearest(CoordT x, CoordT y) const
+ {
+ assert(this->Count() > 0);
+
+ CoordT xy[2] = { x, y };
+ return this->FindNearestRecursive(xy, this->root, 0).first;
+ }
+
+ /**
+ * Find all items contained within the given rectangle.
+ * @note Start coordinates are inclusive, end coordinates are exclusive. x1
+ void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, Outputter outputter) const
+ {
+ assert(x1 < x2);
+ assert(y1 < y2);
+
+ if (this->Count() == 0) return;
+
+ CoordT p1[2] = { x1, y1 };
+ CoordT p2[2] = { x2, y2 };
+ this->FindContainedRecursive(p1, p2, this->root, 0, outputter);
+ }
+
+ /**
+ * Find all items contained within the given rectangle.
+ * @note End coordinates are exclusive, x1 FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2) const
+ {
+ std::vector result;
+ this->FindContained(x1, y1, x2, y2, [&result](T e) {result.push_back(e); });
+ return result;
+ }
+};
+
+#endif
diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp
index 81237e4245..8e58bd380e 100644
--- a/src/core/math_func.hpp
+++ b/src/core/math_func.hpp
@@ -247,9 +247,9 @@ static inline T Delta(const T a, const T b)
* @return True if the value is in the interval, false else.
*/
template
-static inline bool IsInsideBS(const T x, const uint base, const uint size)
+static inline bool IsInsideBS(const T x, const size_t base, const size_t size)
{
- return (uint)(x - base) < size;
+ return (size_t)(x - base) < size;
}
/**
@@ -263,9 +263,9 @@ static inline bool IsInsideBS(const T x, const uint base, const uint size)
* @see IsInsideBS()
*/
template
-static inline bool IsInsideMM(const T x, const uint min, const uint max)
+static inline bool IsInsideMM(const T x, const size_t min, const size_t max)
{
- return (uint)(x - min) < (max - min);
+ return (size_t)(x - min) < (max - min);
}
/**
diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp
index f8ff93cecc..7a65bf77a4 100644
--- a/src/core/pool_func.cpp
+++ b/src/core/pool_func.cpp
@@ -21,8 +21,8 @@
/* virtual */ PoolBase::~PoolBase()
{
PoolVector *pools = PoolBase::GetPools();
- pools->Erase(pools->Find(this));
- if (pools->Length() == 0) delete pools;
+ pools->erase(std::find(pools->begin(), pools->end(), this));
+ if (pools->size() == 0) delete pools;
}
/**
@@ -31,10 +31,7 @@
*/
/* static */ void PoolBase::Clean(PoolType pt)
{
- PoolVector *pools = PoolBase::GetPools();
- PoolBase **end = pools->End();
- for (PoolBase **ppool = pools->Begin(); ppool != end; ppool++) {
- PoolBase *pool = *ppool;
+ for (PoolBase *pool : *PoolBase::GetPools()) {
if (pool->type & pt) pool->CleanPool();
}
}
diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp
index 70f6480103..ef630ef9b0 100644
--- a/src/core/pool_type.hpp
+++ b/src/core/pool_type.hpp
@@ -26,7 +26,7 @@ enum PoolType {
};
DECLARE_ENUM_AS_BIT_SET(PoolType)
-typedef SmallVector PoolVector; ///< Vector of pointers to PoolBase
+typedef std::vector PoolVector; ///< Vector of pointers to PoolBase
/** Base class for base of all pools. */
struct PoolBase {
@@ -50,7 +50,7 @@ struct PoolBase {
*/
PoolBase(PoolType pt) : type(pt)
{
- *PoolBase::GetPools()->Append() = this;
+ PoolBase::GetPools()->push_back(this);
}
virtual ~PoolBase();
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp
index dda0fc2a1e..bdb6ed475b 100644
--- a/src/core/smallmap_type.hpp
+++ b/src/core/smallmap_type.hpp
@@ -27,6 +27,7 @@ struct SmallPair {
/** Initializes this Pair with data */
inline SmallPair(const T &first, const U &second) : first(first), second(second) { }
+ SmallPair() = default;
};
/**
@@ -38,8 +39,8 @@ struct SmallPair {
*
* @see SmallVector
*/
-template
-struct SmallMap : SmallVector, S> {
+template
+struct SmallMap : std::vector > {
typedef ::SmallPair Pair;
typedef Pair *iterator;
typedef const Pair *const_iterator;
@@ -54,12 +55,13 @@ struct SmallMap : SmallVector, S> {
* @param key key to find
* @return &Pair(key, data) if found, this->End() if not
*/
- inline const Pair *Find(const T &key) const
+ inline typename std::vector::const_iterator Find(const T &key) const
{
- for (uint i = 0; i < this->items; i++) {
- if (key == this->data[i].first) return &this->data[i];
+ typename std::vector::const_iterator it;
+ for (it = std::vector::begin(); it != std::vector::end(); it++) {
+ if (key == it->first) return it;
}
- return this->End();
+ return it;
}
/**
@@ -69,18 +71,39 @@ struct SmallMap : SmallVector, S> {
*/
inline Pair *Find(const T &key)
{
- for (uint i = 0; i < this->items; i++) {
- if (key == this->data[i].first) return &this->data[i];
+ for (uint i = 0; i < std::vector::size(); i++) {
+ if (key == std::vector::operator[](i).first) return &std::vector::operator[](i);
}
return this->End();
}
+ inline const Pair *End() const
+ {
+ return std::vector::data() + std::vector::size();
+ }
+
+ inline Pair *End()
+ {
+ return std::vector::data() + std::vector::size();
+ }
+
+
/**
* Tests whether a key is assigned in this map.
* @param key key to test
* @return true iff the item is present
*/
inline bool Contains(const T &key) const
+ {
+ return this->Find(key) != std::vector::end();
+ }
+
+ /**
+ * Tests whether a key is assigned in this map.
+ * @param key key to test
+ * @return true iff the item is present
+ */
+ inline bool Contains(const T &key)
{
return this->Find(key) != this->End();
}
@@ -92,8 +115,9 @@ struct SmallMap : SmallVector, S> {
*/
inline void Erase(Pair *pair)
{
- assert(pair >= this->Begin() && pair < this->End());
- *pair = this->data[--this->items];
+ assert(pair >= std::vector::data() && pair < this->End());
+ auto distance = pair - std::vector::data();
+ std::vector::erase(std::vector::begin() + distance);
}
/**
@@ -104,13 +128,11 @@ struct SmallMap : SmallVector, S> {
*/
inline bool Erase(const T &key)
{
- for (uint i = 0; i < this->items; i++) {
- if (key == this->data[i].first) {
- this->data[i] = this->data[--this->items];
- return true;
- }
- }
- return false;
+ auto *pair = this->Find(key);
+ if (pair == this->End()) return false;
+
+ this->Erase(pair);
+ return true;
}
/**
@@ -122,9 +144,7 @@ struct SmallMap : SmallVector, S> {
inline bool Insert(const T &key, const U &data)
{
if (this->Contains(key)) return false;
- Pair *n = this->Append();
- n->first = key;
- n->second = data;
+ std::vector::emplace_back(key, data);
return true;
}
@@ -136,17 +156,18 @@ struct SmallMap : SmallVector, S> {
*/
inline U &operator[](const T &key)
{
- for (uint i = 0; i < this->items; i++) {
- if (key == this->data[i].first) return this->data[i].second;
+ for (uint i = 0; i < std::vector::size(); i++) {
+ if (key == std::vector::operator[](i).first) return std::vector::operator[](i).second;
}
- Pair *n = this->Append();
- n->first = key;
- return n->second;
+ /*C++17: Pair &n = */ std::vector::emplace_back();
+ Pair &n = std::vector::back();
+ n.first = key;
+ return n.second;
}
inline void SortByKey()
{
- QSortT(this->Begin(), this->items, KeySorter);
+ QSortT(std::vector::data(), std::vector::size(), KeySorter);
}
static int CDECL KeySorter(const Pair *a, const Pair *b)
diff --git a/src/core/smallstack_type.hpp b/src/core/smallstack_type.hpp
index 06b5aaafa6..6aded5a759 100644
--- a/src/core/smallstack_type.hpp
+++ b/src/core/smallstack_type.hpp
@@ -13,7 +13,7 @@
#define SMALLSTACK_TYPE_HPP
#include "smallvec_type.hpp"
-#include "../thread/thread.h"
+#include
/**
* A simplified pool which stores values instead of pointers and doesn't
@@ -23,15 +23,14 @@
template
class SimplePool {
public:
- inline SimplePool() : first_unused(0), first_free(0), mutex(ThreadMutex::New()) {}
- inline ~SimplePool() { delete this->mutex; }
+ inline SimplePool() : first_unused(0), first_free(0) {}
/**
* Get the mutex. We don't lock the mutex in the pool methods as the
* SmallStack isn't necessarily in a consistent state after each method.
* @return Mutex.
*/
- inline ThreadMutex *GetMutex() { return this->mutex; }
+ inline std::mutex &GetMutex() { return this->mutex; }
/**
* Get the item at position index.
@@ -73,8 +72,8 @@ private:
if (!this->data[index].valid) return index;
}
- if (index >= this->data.Length() && index < Tmax_size) {
- this->data.Resize(index + 1);
+ if (index >= this->data.size() && index < Tmax_size) {
+ this->data.resize(index + 1);
}
return index;
}
@@ -86,8 +85,8 @@ private:
Tindex first_unused;
Tindex first_free;
- ThreadMutex *mutex;
- SmallVector data;
+ std::mutex mutex;
+ std::vector data;
};
/**
@@ -106,6 +105,7 @@ struct SmallStackItem {
*/
inline SmallStackItem(const Titem &value, Tindex next) :
next(next), value(value) {}
+ SmallStackItem() = default;
};
/**
@@ -195,7 +195,7 @@ public:
inline void Push(const Titem &item)
{
if (this->value != Tinvalid) {
- ThreadMutexLocker lock(SmallStack::GetPool().GetMutex());
+ std::lock_guard lock(SmallStack::GetPool().GetMutex());
Tindex new_item = SmallStack::GetPool().Create();
if (new_item != Tmax_size) {
PooledSmallStack &pushed = SmallStack::GetPool().Get(new_item);
@@ -218,7 +218,7 @@ public:
if (this->next == Tmax_size) {
this->value = Tinvalid;
} else {
- ThreadMutexLocker lock(SmallStack::GetPool().GetMutex());
+ std::lock_guard lock(SmallStack::GetPool().GetMutex());
PooledSmallStack &popped = SmallStack::GetPool().Get(this->next);
this->value = popped.value;
if (popped.branch_count == 0) {
@@ -257,7 +257,7 @@ public:
{
if (item == Tinvalid || item == this->value) return true;
if (this->next != Tmax_size) {
- ThreadMutexLocker lock(SmallStack::GetPool().GetMutex());
+ std::lock_guard lock(SmallStack::GetPool().GetMutex());
const SmallStack *in_list = this;
do {
in_list = static_cast(
@@ -281,7 +281,7 @@ protected:
inline void Branch()
{
if (this->next != Tmax_size) {
- ThreadMutexLocker lock(SmallStack::GetPool().GetMutex());
+ std::lock_guard lock(SmallStack::GetPool().GetMutex());
++(SmallStack::GetPool().Get(this->next).branch_count);
}
}
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index 588dd599dc..f43265ebe8 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -14,375 +14,60 @@
#include "alloc_func.hpp"
#include "mem_func.hpp"
+#include
+#include
/**
- * Simple vector template class.
+ * Helper function to append an item to a vector if it is not already contained
+ * Consider using std::set, std::unordered_set or std::flat_set in new code
*
- * @note There are no asserts in the class so you have
- * to care about that you grab an item which is
- * inside the list.
+ * @param vec A reference to the vector to be extended
+ * @param item Reference to the item to be copy-constructed if not found
*
- * @tparam T The type of the items stored
- * @tparam S The steps of allocation
+ * @return Whether the item was already present
*/
-template
-class SmallVector {
-protected:
- T *data; ///< The pointer to the first item
- uint items; ///< The number of items stored
- uint capacity; ///< The available space for storing items
-
-public:
- SmallVector() : data(NULL), items(0), capacity(0) { }
-
- /**
- * Copy constructor.
- * @param other The other vector to copy.
- */
- SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0)
- {
- this->Assign(other);
- }
-
- /**
- * Generic copy constructor.
- * @param other The other vector to copy.
- */
- template
- SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0)
- {
- this->Assign(other);
- }
-
- /**
- * Assignment.
- * @param other The other vector to assign.
- */
- SmallVector &operator=(const SmallVector &other)
- {
- this->Assign(other);
- return *this;
- }
-
- /**
- * Generic assignment.
- * @param other The other vector to assign.
- */
- template
- SmallVector &operator=(const SmallVector &other)
- {
- this->Assign(other);
- return *this;
- }
-
- ~SmallVector()
- {
- free(this->data);
- }
-
- /**
- * Assign items from other vector.
- */
- template
- inline void Assign(const SmallVector &other)
- {
- if ((const void *)&other == (void *)this) return;
-
- this->Clear();
- if (other.Length() > 0) MemCpyT(this->Append(other.Length()), other.Begin(), other.Length());
- }
-
- /**
- * Remove all items from the list.
- */
- inline void Clear()
- {
- /* In fact we just reset the item counter avoiding the need to
- * probably reallocate the same amount of memory the list was
- * previously using. */
- this->items = 0;
- }
-
- /**
- * Remove all items from the list and free allocated memory.
- */
- inline void Reset()
- {
- this->items = 0;
- this->capacity = 0;
- free(data);
- data = NULL;
- }
-
- /**
- * Compact the list down to the smallest block size boundary.
- */
- inline void Compact()
- {
- uint capacity = Align(this->items, S);
- if (capacity >= this->capacity) return;
-
- this->capacity = capacity;
- this->data = ReallocT(this->data, this->capacity);
- }
-
- /**
- * Append an item and return it.
- * @param to_add the number of items to append
- * @return pointer to newly allocated item
- */
- inline T *Append(uint to_add = 1)
- {
- uint begin = this->items;
- this->items += to_add;
-
- if (this->items > this->capacity) {
- this->capacity = Align(this->items, S);
- this->data = ReallocT(this->data, this->capacity);
- }
-
- return &this->data[begin];
- }
-
- /**
- * Set the size of the vector, effectively truncating items from the end or appending uninitialised ones.
- * @param num_items Target size.
- */
- inline void Resize(uint num_items)
- {
- this->items = num_items;
-
- if (this->items > this->capacity) {
- this->capacity = Align(this->items, S);
- this->data = ReallocT(this->data, this->capacity);
- }
- }
-
- /**
- * Insert a new item at a specific position into the vector, moving all following items.
- * @param item Position at which the new item should be inserted
- * @return pointer to the new item
- */
- inline T *Insert(T *item)
- {
- assert(item >= this->Begin() && item <= this->End());
-
- size_t to_move = this->End() - item;
- size_t start = item - this->Begin();
-
- this->Append();
- if (to_move > 0) MemMoveT(this->Begin() + start + 1, this->Begin() + start, to_move);
- return this->Begin() + start;
- }
-
- /**
- * Search for the first occurrence of an item.
- * The '!=' operator of T is used for comparison.
- * @param item Item to search for
- * @return The position of the item, or End() when not present
- */
- inline const T *Find(const T &item) const
- {
- const T *pos = this->Begin();
- const T *end = this->End();
- while (pos != end && *pos != item) pos++;
- return pos;
- }
-
- /**
- * Search for the first occurrence of an item.
- * The '!=' operator of T is used for comparison.
- * @param item Item to search for
- * @return The position of the item, or End() when not present
- */
- inline T *Find(const T &item)
- {
- T *pos = this->Begin();
- const T *end = this->End();
- while (pos != end && *pos != item) pos++;
- return pos;
- }
+template
+inline bool include(std::vector& vec, const T &item)
+{
+ const bool is_member = std::find(vec.begin(), vec.end(), item) != vec.end();
+ if (!is_member) vec.emplace_back(item);
+ return is_member;
+}
- /**
- * Search for the first occurrence of an item.
- * The '!=' operator of T is used for comparison.
- * @param item Item to search for
- * @return The position of the item, or -1 when not present
- */
- inline int FindIndex(const T &item) const
- {
- int index = 0;
- const T *pos = this->Begin();
- const T *end = this->End();
- while (pos != end && *pos != item) {
- pos++;
- index++;
- }
- return pos == end ? -1 : index;
- }
-
- /**
- * Tests whether a item is present in the vector.
- * The '!=' operator of T is used for comparison.
- * @param item Item to test for
- * @return true iff the item is present
- */
- inline bool Contains(const T &item) const
- {
- return this->Find(item) != this->End();
- }
-
- /**
- * Removes given item from this vector
- * @param item item to remove
- * @note it has to be pointer to item in this map. It is overwritten by the last item.
- */
- inline void Erase(T *item)
- {
- assert(item >= this->Begin() && item < this->End());
- *item = this->data[--this->items];
- }
-
- /**
- * Remove items from the vector while preserving the order of other items.
- * @param pos First item to remove.
- * @param count Number of consecutive items to remove.
- */
- void ErasePreservingOrder(uint pos, uint count = 1)
- {
- ErasePreservingOrder(this->data + pos, count);
- }
-
- /**
- * Remove items from the vector while preserving the order of other items.
- * @param item First item to remove.
- * @param count Number of consecutive items to remove.
- */
- inline void ErasePreservingOrder(T *item, uint count = 1)
- {
- if (count == 0) return;
- assert(item >= this->Begin());
- assert(item + count <= this->End());
-
- this->items -= count;
- ptrdiff_t to_move = this->End() - item;
- if (to_move > 0) MemMoveT(item, item + count, to_move);
- }
-
- /**
- * Tests whether a item is present in the vector, and appends it to the end if not.
- * The '!=' operator of T is used for comparison.
- * @param item Item to test for
- * @return true iff the item is was already present
- */
- inline bool Include(const T &item)
- {
- bool is_member = this->Contains(item);
- if (!is_member) *this->Append() = item;
- return is_member;
- }
-
- /**
- * Get the number of items in the list.
- *
- * @return The number of items in the list.
- */
- inline uint Length() const
- {
- return this->items;
- }
-
- /**
- * Get the pointer to the first item (const)
- *
- * @return the pointer to the first item
- */
- inline const T *Begin() const
- {
- return this->data;
- }
-
- /**
- * Get the pointer to the first item
- *
- * @return the pointer to the first item
- */
- inline T *Begin()
- {
- return this->data;
- }
-
- /**
- * Get the pointer behind the last valid item (const)
- *
- * @return the pointer behind the last valid item
- */
- inline const T *End() const
- {
- return &this->data[this->items];
- }
-
- /**
- * Get the pointer behind the last valid item
- *
- * @return the pointer behind the last valid item
- */
- inline T *End()
- {
- return &this->data[this->items];
- }
-
- /**
- * Get the pointer to item "number" (const)
- *
- * @param index the position of the item
- * @return the pointer to the item
- */
- inline const T *Get(uint index) const
- {
- /* Allow access to the 'first invalid' item */
- assert(index <= this->items);
- return &this->data[index];
- }
-
- /**
- * Get the pointer to item "number"
- *
- * @param index the position of the item
- * @return the pointer to the item
- */
- inline T *Get(uint index)
- {
- /* Allow access to the 'first invalid' item */
- assert(index <= this->items);
- return &this->data[index];
- }
-
- /**
- * Get item "number" (const)
- *
- * @param index the position of the item
- * @return the item
- */
- inline const T &operator[](uint index) const
- {
- assert(index < this->items);
- return this->data[index];
- }
+/**
+ * Helper function to get the index of an item
+ * Consider using std::set, std::unordered_set or std::flat_set in new code
+ *
+ * @param vec A reference to the vector to be extended
+ * @param item Reference to the item to be search for
+ *
+ * @return Index of element if found, otherwise -1
+ */
+template
+int find_index(std::vector const& vec, T const& item)
+{
+ auto const it = std::find(vec.begin(), vec.end(), item);
+ if (it != vec.end()) return it - vec.begin();
- /**
- * Get item "number"
- *
- * @param index the position of the item
- * @return the item
- */
- inline T &operator[](uint index)
- {
- assert(index < this->items);
- return this->data[index];
- }
-};
+ return -1;
+}
+/**
+ * Helper function to append N default-constructed elements and get a pointer to the first new element
+ * Consider using std::back_inserter in new code
+ *
+ * @param vec A reference to the vector to be extended
+ * @param num Number of elements to be default-constructed
+ *
+ * @return Pointer to the first new element
+ */
+template
+T* grow(std::vector& vec, std::size_t num)
+{
+ std::size_t const pos = vec.size();
+ vec.resize(pos + num);
+ return vec.data() + pos;
+}
/**
* Simple vector template class, with automatic free.
@@ -392,10 +77,9 @@ public:
* inside the list.
*
* @param T The type of the items stored, must be a pointer
- * @param S The steps of allocation
*/
-template
-class AutoFreeSmallVector : public SmallVector {
+template
+class AutoFreeSmallVector : public std::vector {
public:
~AutoFreeSmallVector()
{
@@ -407,11 +91,11 @@ public:
*/
inline void Clear()
{
- for (uint i = 0; i < this->items; i++) {
- free(this->data[i]);
+ for (T p : *this) {
+ free(p);
}
- this->items = 0;
+ std::vector::clear();
}
};
@@ -423,10 +107,9 @@ public:
* inside the list.
*
* @param T The type of the items stored, must be a pointer
- * @param S The steps of allocation
*/
-template
-class AutoDeleteSmallVector : public SmallVector {
+template
+class AutoDeleteSmallVector : public std::vector {
public:
~AutoDeleteSmallVector()
{
@@ -438,14 +121,14 @@ public:
*/
inline void Clear()
{
- for (uint i = 0; i < this->items; i++) {
- delete this->data[i];
+ for (T p : *this) {
+ delete p;
}
- this->items = 0;
+ std::vector::clear();
}
};
-typedef AutoFreeSmallVector StringList; ///< Type for a list of strings.
+typedef AutoFreeSmallVector StringList; ///< Type for a list of strings.
#endif /* SMALLVEC_TYPE_HPP */
diff --git a/src/core/sort_func.hpp b/src/core/sort_func.hpp
index 470a0ccf4d..f3ac73a666 100644
--- a/src/core/sort_func.hpp
+++ b/src/core/sort_func.hpp
@@ -25,7 +25,7 @@
* @param desc Sort descending.
*/
template
-static inline void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
+static inline void QSortT(T *base, size_t num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
{
if (num < 2) return;
@@ -49,7 +49,7 @@ static inline void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, c
* @param desc Sort descending.
*/
template
-static inline void GSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
+static inline void GSortT(T *base, size_t num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
{
if (num < 2) return;
diff --git a/src/cpu.cpp b/src/cpu.cpp
index 9393ea0613..8d5eb5e5e7 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -35,7 +35,7 @@ unsigned __int64 ottd_rdtsc();
#endif
/* rdtsc for all other *nix-en (hopefully). Use GCC syntax */
-#if (defined(__i386__) || defined(__x86_64__)) && !defined(__DJGPP__) && !defined(RDTSC_AVAILABLE)
+#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE)
uint64 ottd_rdtsc()
{
uint32 high, low;
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index 78d9b1465b..add5c52040 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -52,17 +52,16 @@
# include
# include FT_FREETYPE_H
#endif /* WITH_FREETYPE */
-#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT)
+#if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
# include
-#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */
-#ifdef WITH_LZMA
+#endif /* WITH_ICU_LX || WITH_ICU_I18N */
+#ifdef WITH_LIBLZMA
# include
#endif
#ifdef WITH_LZO
#include
#endif
#ifdef WITH_SDL
-# include "sdl.h"
# include
#endif /* WITH_SDL */
#ifdef WITH_ZLIB
@@ -195,7 +194,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
FontCache::Get(FS_MONO)->GetFontName()
);
- buffer += seprintf(buffer, last, "AI Configuration (local: %i):\n", (int)_local_company);
+ buffer += seprintf(buffer, last, "AI Configuration (local: %i) (current: %i):\n", (int)_local_company, (int)_current_company);
const Company *c;
FOR_ALL_COMPANIES(c) {
if (c->ai_info == NULL) {
@@ -241,21 +240,21 @@ char *CrashLog::LogLibraries(char *buffer, const char *last) const
buffer += seprintf(buffer, last, " FreeType: %d.%d.%d\n", major, minor, patch);
#endif /* WITH_FREETYPE */
-#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT)
+#if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
/* 4 times 0-255, separated by dots (.) and a trailing '\0' */
char buf[4 * 3 + 3 + 1];
UVersionInfo ver;
u_getVersion(ver);
u_versionToString(ver, buf);
-#ifdef WITH_ICU_SORT
+#ifdef WITH_ICU_I18N
buffer += seprintf(buffer, last, " ICU i18n: %s\n", buf);
#endif
-#ifdef WITH_ICU_LAYOUT
+#ifdef WITH_ICU_LX
buffer += seprintf(buffer, last, " ICU lx: %s\n", buf);
#endif
-#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */
+#endif /* WITH_ICU_LX || WITH_ICU_I18N */
-#ifdef WITH_LZMA
+#ifdef WITH_LIBLZMA
buffer += seprintf(buffer, last, " LZMA: %s\n", lzma_version_string());
#endif
@@ -268,14 +267,8 @@ char *CrashLog::LogLibraries(char *buffer, const char *last) const
#endif /* WITH_PNG */
#ifdef WITH_SDL
-#ifdef DYNAMICALLY_LOADED_SDL
- if (SDL_CALL SDL_Linked_Version != NULL) {
-#else
- {
-#endif
- const SDL_version *v = SDL_CALL SDL_Linked_Version();
- buffer += seprintf(buffer, last, " SDL: %d.%d.%d\n", v->major, v->minor, v->patch);
- }
+ const SDL_version *v = SDL_Linked_Version();
+ buffer += seprintf(buffer, last, " SDL: %d.%d.%d\n", v->major, v->minor, v->patch);
#endif /* WITH_SDL */
#ifdef WITH_ZLIB
diff --git a/src/date.cpp b/src/date.cpp
index 9c25af40ee..8b8fab5b0a 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -195,9 +195,7 @@ static void OnNewYear()
VehiclesYearlyLoop();
TownsYearlyLoop();
InvalidateWindowClassesData(WC_BUILD_STATION);
-#ifdef ENABLE_NETWORK
if (_network_server) NetworkServerYearlyLoop();
-#endif /* ENABLE_NETWORK */
if (_cur_year == _settings_client.gui.semaphore_build_before) ResetSignalVariant();
@@ -217,11 +215,9 @@ static void OnNewYear()
LinkGraph *lg;
FOR_ALL_LINK_GRAPHS(lg) lg->ShiftDates(-days_this_year);
-#ifdef ENABLE_NETWORK
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
* all of them if the date is set back, else those messages will hang for ever */
NetworkInitChatMessage();
-#endif /* ENABLE_NETWORK */
}
if (_settings_client.gui.auto_euro) CheckSwitchToEuro();
@@ -244,9 +240,7 @@ static void OnNewMonth()
IndustryMonthlyLoop();
SubsidyMonthlyLoop();
StationMonthlyLoop();
-#ifdef ENABLE_NETWORK
if (_network_server) NetworkServerMonthlyLoop();
-#endif /* ENABLE_NETWORK */
}
/**
@@ -254,9 +248,7 @@ static void OnNewMonth()
*/
static void OnNewDay()
{
-#ifdef ENABLE_NETWORK
if (_network_server) NetworkServerDailyLoop();
-#endif /* ENABLE_NETWORK */
DisasterDailyLoop();
IndustryDailyLoop();
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index 468a74db99..d55e7e2b34 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -55,7 +55,7 @@ struct SetDateWindow : Window {
this->date.year = Clamp(this->date.year, min_year, max_year);
}
- virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
+ Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
{
Point pt = { this->parent->left + this->parent->width / 2 - sm_width / 2, this->parent->top + this->parent->height / 2 - sm_height / 2 };
return pt;
@@ -75,14 +75,14 @@ struct SetDateWindow : Window {
case WID_SD_DAY:
for (uint i = 0; i < 31; i++) {
- *list->Append() = new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false);
+ list->push_back(new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false));
}
selected = this->date.day;
break;
case WID_SD_MONTH:
for (uint i = 0; i < 12; i++) {
- *list->Append() = new DropDownListStringItem(STR_MONTH_JAN + i, i, false);
+ list->push_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
}
selected = this->date.month;
break;
@@ -91,7 +91,7 @@ struct SetDateWindow : Window {
for (Year i = this->min_year; i <= this->max_year; i++) {
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
item->SetParam(0, i);
- *list->Append() = item;
+ list->push_back(item);
}
selected = this->date.year;
break;
@@ -100,7 +100,7 @@ struct SetDateWindow : Window {
ShowDropDownList(this, list, selected, widget);
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
Dimension d = {0, 0};
switch (widget) {
@@ -129,7 +129,7 @@ struct SetDateWindow : Window {
*size = d;
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_SD_DAY: SetDParam(0, this->date.day - 1 + STR_DAY_NUMBER_1ST); break;
@@ -138,7 +138,7 @@ struct SetDateWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_SD_DAY:
@@ -154,7 +154,7 @@ struct SetDateWindow : Window {
}
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_SD_DAY:
diff --git a/src/debug.cpp b/src/debug.cpp
index 13df98db34..422f730389 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -23,10 +23,8 @@
#include
-#if defined(ENABLE_NETWORK)
#include "network/network_admin.h"
SOCKET _debug_socket = INVALID_SOCKET;
-#endif /* ENABLE_NETWORK */
#include "safeguards.h"
@@ -111,7 +109,6 @@ char *DumpDebugFacilityNames(char *buf, char *last)
*/
static void debug_print(const char *dbg, const char *buf)
{
-#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];
@@ -121,7 +118,6 @@ static void debug_print(const char *dbg, const char *buf)
send(_debug_socket, buf2, (int)strlen(buf2), 0);
return;
}
-#endif /* ENABLE_NETWORK */
if (strcmp(dbg, "desync") == 0) {
static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
if (f == NULL) return;
@@ -146,9 +142,7 @@ static void debug_print(const char *dbg, const char *buf)
#else
fputs(buffer, stderr);
#endif
-#ifdef ENABLE_NETWORK
NetworkAdminConsole(dbg, buf);
-#endif /* ENABLE_NETWORK */
IConsoleDebug(dbg, buf);
}
}
diff --git a/src/debug.h b/src/debug.h
index ce454c962e..3faefffaf3 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -13,6 +13,7 @@
#define DEBUG_H
#include "cpu.h"
+#include
/* Debugging messages policy:
* These should be the severities used for direct DEBUG() calls
@@ -83,21 +84,40 @@ const char *GetDebugString();
*
* TIC() / TOC() creates its own block, so make sure not the mangle
* it with another block.
+ *
+ * The output is counted in CPU cycles, and not comparable accross
+ * machines. Mainly useful for local optimisations.
**/
#define TIC() {\
uint64 _xxx_ = ottd_rdtsc();\
- static uint64 __sum__ = 0;\
- static uint32 __i__ = 0;
+ static uint64 _sum_ = 0;\
+ static uint32 _i_ = 0;
#define TOC(str, count)\
- __sum__ += ottd_rdtsc() - _xxx_;\
- if (++__i__ == count) {\
- DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, __sum__, __sum__/(double)__i__);\
- __i__ = 0;\
- __sum__ = 0;\
+ _sum_ += ottd_rdtsc() - _xxx_;\
+ if (++_i_ == count) {\
+ DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, _sum_, _sum_/(double)_i_);\
+ _i_ = 0;\
+ _sum_ = 0;\
}\
}
+/* Chrono based version. The output is in microseconds. */
+#define TICC() {\
+ auto _start_ = std::chrono::high_resolution_clock::now();\
+ static uint64 _sum_ = 0;\
+ static uint32 _i_ = 0;
+
+#define TOCC(str, _count_)\
+ _sum_ += (std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - _start_)).count();\
+ if (++_i_ == _count_) {\
+ DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " us [avg: %.1f us]", str, _sum_, _sum_/(double)_i_);\
+ _i_ = 0;\
+ _sum_ = 0;\
+ }\
+}
+
+
void ShowInfo(const char *str);
void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2);
diff --git a/src/dedicated.cpp b/src/dedicated.cpp
index ce383ee4a5..141a917208 100644
--- a/src/dedicated.cpp
+++ b/src/dedicated.cpp
@@ -11,21 +11,18 @@
#include "stdafx.h"
-#ifdef ENABLE_NETWORK
-
char *_log_file = NULL; ///< File to reroute output of a forked OpenTTD to
FILE *_log_fd = NULL; ///< File to reroute output of a forked OpenTTD to
-#if defined(UNIX) && !defined(__MORPHOS__)
+#if defined(UNIX)
#include
#include "safeguards.h"
-#if (defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)) || defined(__HAIKU__)
+#if defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)
/* Solaris has, in certain situation, pid_t defined as long, while in other
* cases it has it defined as int... this handles all cases nicely.
- * Haiku has also defined pid_t as a long.
*/
# define PRINTF_PID_T "%ld"
#else
@@ -68,10 +65,3 @@ void DedicatedFork()
}
}
#endif
-
-#else
-
-/** Empty helper function call for NOT(UNIX and not MORPHOS) systems */
-void DedicatedFork() {}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 39accd65f1..ffab68536e 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -364,7 +364,7 @@ struct DepotWindow : Window {
}
}
- void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_D_MATRIX) return;
@@ -398,7 +398,7 @@ struct DepotWindow : Window {
uint16 rows_in_display = wid->current_y / wid->resize_y;
uint16 num = this->vscroll->GetPosition() * this->num_columns;
- int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * this->num_columns));
+ int maxval = min((uint)this->vehicle_list.size(), num + (rows_in_display * this->num_columns));
int y;
for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
@@ -413,16 +413,16 @@ struct DepotWindow : Window {
}
}
- maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
+ maxval = min((uint)this->vehicle_list.size() + (uint)this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
/* Draw the train wagons without an engine in front. */
for (; num < maxval; num++, y += this->resize.step_height) {
- const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
+ const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
this->DrawVehicleInDepot(v, r.left, r.right, y);
}
}
- void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
if (widget != WID_D_CAPTION) return;
@@ -465,7 +465,7 @@ struct DepotWindow : Window {
uint pos = ((row + this->vscroll->GetPosition()) * this->num_columns) + xt;
- if (this->vehicle_list.Length() + this->wagon_list.Length() <= pos) {
+ if (this->vehicle_list.size() + this->wagon_list.size() <= pos) {
/* Clicking on 'line' / 'block' without a vehicle */
if (this->type == VEH_TRAIN) {
/* End the dragging */
@@ -478,12 +478,12 @@ struct DepotWindow : Window {
}
bool wagon = false;
- if (this->vehicle_list.Length() > pos) {
+ if (this->vehicle_list.size() > pos) {
*veh = this->vehicle_list[pos];
/* Skip vehicles that are scrolled off the list */
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
} else {
- pos -= this->vehicle_list.Length();
+ pos -= (uint)this->vehicle_list.size();
*veh = this->wagon_list[pos];
/* free wagons don't have an initial loco. */
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
@@ -650,7 +650,7 @@ struct DepotWindow : Window {
uint flag_width;
uint flag_height;
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_D_MATRIX: {
@@ -701,12 +701,12 @@ struct DepotWindow : Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
this->generate_list = true;
}
- virtual void OnPaint()
+ void OnPaint() override
{
if (this->generate_list) {
/* Generate the vehicle list
@@ -726,7 +726,7 @@ struct DepotWindow : Window {
/* determine amount of items for scroller */
if (this->type == VEH_TRAIN) {
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
- for (uint num = 0; num < this->vehicle_list.Length(); num++) {
+ for (uint num = 0; num < this->vehicle_list.size(); num++) {
uint width = 0;
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
width += v->GetDisplayImageWidth();
@@ -734,11 +734,11 @@ struct DepotWindow : Window {
max_width = max(max_width, width);
}
/* Always have 1 empty row, so people can change the setting of the train */
- this->vscroll->SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
+ this->vscroll->SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
} else {
- this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->num_columns));
+ this->vscroll->SetCount(CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
}
/* Setup disabled buttons. */
@@ -758,7 +758,7 @@ struct DepotWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_D_MATRIX: { // List
@@ -811,7 +811,7 @@ struct DepotWindow : Window {
case WID_D_SELL_ALL:
/* Only open the confirmation window if there are anything to sell */
- if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
+ if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) {
TileIndex tile = this->window_number;
byte vehtype = this->type;
@@ -837,7 +837,7 @@ struct DepotWindow : Window {
}
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (str == NULL) return;
@@ -845,7 +845,7 @@ struct DepotWindow : Window {
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str);
}
- virtual bool OnRightClick(Point pt, int widget)
+ bool OnRightClick(Point pt, int widget) override
{
if (widget != WID_D_MATRIX) return false;
@@ -906,7 +906,7 @@ struct DepotWindow : Window {
* @param v the original vehicle to clone
* @return Always true.
*/
- virtual bool OnVehicleSelect(const Vehicle *v)
+ bool OnVehicleSelect(const Vehicle *v) override
{
if (_ctrl_pressed) {
/* Share-clone, do not open new viewport, and keep tool active */
@@ -921,7 +921,7 @@ struct DepotWindow : Window {
return true;
}
- virtual void OnPlaceObjectAbort()
+ void OnPlaceObjectAbort() override
{
/* abort clone */
this->RaiseWidget(WID_D_CLONE);
@@ -939,7 +939,7 @@ struct DepotWindow : Window {
}
}
- virtual void OnMouseDrag(Point pt, int widget)
+ void OnMouseDrag(Point pt, int widget) override
{
if (this->sel == INVALID_VEHICLE) return;
if (widget != this->hovered_widget) {
@@ -991,7 +991,7 @@ struct DepotWindow : Window {
this->SetWidgetDirty(widget);
}
- virtual void OnDragDrop(Point pt, int widget)
+ void OnDragDrop(Point pt, int widget) override
{
switch (widget) {
case WID_D_MATRIX: {
@@ -1046,7 +1046,7 @@ struct DepotWindow : Window {
_cursor.vehchain = false;
}
- virtual void OnTimeout()
+ void OnTimeout() override
{
if (!this->IsWidgetDisabled(WID_D_SELL)) {
this->RaiseWidget(WID_D_SELL);
@@ -1058,7 +1058,7 @@ struct DepotWindow : Window {
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_D_MATRIX);
NWidgetCore *nwi = this->GetWidget(WID_D_MATRIX);
@@ -1069,7 +1069,7 @@ struct DepotWindow : Window {
}
}
- virtual EventState OnCTRLStateChange()
+ EventState OnCTRLStateChange() override
{
if (this->sel != INVALID_VEHICLE) {
_cursor.vehchain = _ctrl_pressed;
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index e2224dfa28..f5ebd1f7f0 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -113,7 +113,7 @@ struct BuildDocksToolbarWindow : Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
@@ -129,7 +129,7 @@ struct BuildDocksToolbarWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_DT_CANAL: // Build canal button
@@ -173,7 +173,7 @@ struct BuildDocksToolbarWindow : Window {
this->last_clicked_widget = (DockToolbarWidgets)widget;
}
- virtual void OnPlaceObject(Point pt, TileIndex tile)
+ void OnPlaceObject(Point pt, TileIndex tile) override
{
switch (this->last_clicked_widget) {
case WID_DT_CANAL: // Build canal button
@@ -222,12 +222,12 @@ struct BuildDocksToolbarWindow : Window {
}
}
- virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
+ void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
- virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
+ void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x != -1) {
switch (select_proc) {
@@ -246,7 +246,7 @@ struct BuildDocksToolbarWindow : Window {
}
}
- virtual void OnPlaceObjectAbort()
+ void OnPlaceObjectAbort() override
{
this->RaiseButtons();
@@ -256,7 +256,7 @@ struct BuildDocksToolbarWindow : Window {
DeleteWindowByClass(WC_BUILD_BRIDGE);
}
- virtual void OnPlacePresize(Point pt, TileIndex tile_from)
+ void OnPlacePresize(Point pt, TileIndex tile_from) override
{
TileIndex tile_to = tile_from;
@@ -410,7 +410,7 @@ public:
DeleteWindowById(WC_SELECT_STATION, 0);
}
- virtual void OnPaint()
+ void OnPaint() override
{
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
@@ -437,7 +437,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case BDSW_LT_OFF:
@@ -451,7 +451,7 @@ public:
}
}
- virtual void OnRealtimeTick(uint delta_ms)
+ void OnRealtimeTick(uint delta_ms) override
{
CheckRedrawStationCoverage(this);
}
@@ -505,7 +505,7 @@ public:
UpdateDocksDirection();
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_BDD_X:
@@ -516,7 +516,7 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
this->DrawWidgets();
@@ -531,7 +531,7 @@ public:
DrawShipDepotSprite(this->GetWidget(WID_BDD_Y)->pos_x + x1, this->GetWidget(WID_BDD_Y)->pos_y + y2, AXIS_Y, DEPOT_PART_SOUTH);
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_BDD_X:
diff --git a/src/economy.cpp b/src/economy.cpp
index 97283ae448..07dec815a6 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -77,7 +77,7 @@ static inline int32 BigMulS(const int32 a, const int32 b, const uint8 shift)
return (int32)((int64)a * (int64)b >> shift);
}
-typedef SmallVector SmallIndustryList;
+typedef std::vector SmallIndustryList;
/**
* Score info, values used for computing the detailed performance rating.
@@ -260,7 +260,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
/* Skip the total */
if (i == SCORE_TOTAL) continue;
/* Check the score */
- s = Clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
+ s = Clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
score += s;
total_score += _score_info[i].score;
}
@@ -292,10 +292,8 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
* the client. This is needed as it needs to know whether "you" really
* are the current local company. */
Backup cur_company(_current_company, old_owner, FILE_LINE);
-#ifdef ENABLE_NETWORK
/* In all cases, make spectators of clients connected to that company */
if (_networking) NetworkClientsToSpectators(old_owner);
-#endif /* ENABLE_NETWORK */
if (old_owner == _local_company) {
/* Single player cheated to AI company.
* There are no spectators in single player, so we must pick some other company. */
@@ -642,7 +640,7 @@ static void CompanyCheckBankrupt(Company *c)
* that changing the current company is okay. In case of single
* player we are sure (the above check) that we are not the local
* company and thus we won't be moved. */
- if (!_networking || _network_server) DoCommandP(0, CCA_DELETE | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
+ if (!_networking || _network_server) DoCommandP(0, CCA_DELETE | (c->index << 16) | (CRR_BANKRUPT << 24), 0, CMD_COMPANY_CTRL);
break;
}
}
@@ -1030,9 +1028,10 @@ static SmallIndustryList _cargo_delivery_destinations;
* @param cargo_type Type of cargo delivered
* @param num_pieces Amount of cargo delivered
* @param source The source of the cargo
+ * @param company The company delivering the cargo
* @return actually accepted pieces of cargo
*/
-static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source)
+static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source, CompanyID company)
{
/* Find the nearest industrytile to the station sign inside the catchment area, whose industry accepts the cargo.
* This fails in three cases:
@@ -1043,8 +1042,9 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
uint accepted = 0;
- for (uint i = 0; i < st->industries_near.Length() && num_pieces != 0; i++) {
- Industry *ind = st->industries_near[i];
+ for (Industry *ind : st->industries_near) {
+ if (num_pieces == 0) break;
+
if (ind->index == source) continue;
uint cargo_index;
@@ -1058,13 +1058,16 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
if (IndustryTemporarilyRefusesCargo(ind, cargo_type)) continue;
/* Insert the industry into _cargo_delivery_destinations, if not yet contained */
- _cargo_delivery_destinations.Include(ind);
+ include(_cargo_delivery_destinations, ind);
uint amount = min(num_pieces, 0xFFFFU - ind->incoming_cargo_waiting[cargo_index]);
ind->incoming_cargo_waiting[cargo_index] += amount;
ind->last_cargo_accepted_at[cargo_index] = _date;
num_pieces -= amount;
accepted += amount;
+
+ /* Update the cargo monitor. */
+ AddCargoDelivery(cargo_type, company, amount, ST_INDUSTRY, source, st, ind->index);
}
return accepted;
@@ -1090,30 +1093,30 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
Station *st = Station::Get(dest);
/* Give the goods to the industry. */
- uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
+ uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY, company->index);
/* If this cargo type is always accepted, accept all */
- if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
+ uint accepted_total = HasBit(st->always_accepted, cargo_type) ? num_pieces : accepted_ind;
/* Update station statistics */
- if (accepted > 0) {
+ if (accepted_total > 0) {
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
}
/* Update company statistics */
- company->cur_economy.delivered_cargo[cargo_type] += accepted;
+ company->cur_economy.delivered_cargo[cargo_type] += accepted_total;
/* Increase town's counter for town effects */
const CargoSpec *cs = CargoSpec::Get(cargo_type);
- st->town->received[cs->town_effect].new_act += accepted;
+ st->town->received[cs->town_effect].new_act += accepted_total;
/* Determine profit */
- Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
+ Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
/* Update the cargo monitor. */
- AddCargoDelivery(cargo_type, company->index, accepted, src_type, src, st);
+ AddCargoDelivery(cargo_type, company->index, accepted_total - accepted_ind, src_type, src, st);
/* Modify profit if a subsidy is in effect */
if (CheckSubsidised(cargo_type, company->index, src_type, src, st)) {
@@ -1518,6 +1521,17 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
cur_company.Restore();
}
+/**
+ * Test whether a vehicle can load cargo at a station even if exclusive transport rights are present.
+ * @param st Station with cargo waiting to be loaded.
+ * @param v Vehicle loading the cargo.
+ * @return true when a vehicle can load the cargo.
+ */
+static bool MayLoadUnderExclusiveRights(const Station *st, const Vehicle *v)
+{
+ return st->owner != OWNER_NONE || st->town->exclusive_counter == 0 || st->town->exclusivity == v->owner;
+}
+
struct ReserveCargoAction {
Station *st;
StationIDStack *next_station;
@@ -1527,7 +1541,7 @@ struct ReserveCargoAction {
bool operator()(Vehicle *v)
{
- if (v->cargo_cap > v->cargo.RemainingCount()) {
+ if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
&v->cargo, st->xy, *next_station);
}
@@ -1751,7 +1765,7 @@ static void LoadUnloadVehicle(Vehicle *front)
/* If there's goods waiting at the station, and the vehicle
* has capacity for it, load it on the vehicle. */
uint cap_left = v->cargo_cap - v->cargo.StoredCount();
- if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0)) {
+ if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0) && MayLoadUnderExclusiveRights(st, v)) {
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
if (_settings_game.order.gradual_loading) cap_left = min(cap_left, GetLoadAmount(v));
@@ -1931,11 +1945,10 @@ void LoadUnloadStation(Station *st)
}
/* Call the production machinery of industries */
- const Industry * const *isend = _cargo_delivery_destinations.End();
- for (Industry **iid = _cargo_delivery_destinations.Begin(); iid != isend; iid++) {
- TriggerIndustryProduction(*iid);
+ for (Industry *iid : _cargo_delivery_destinations) {
+ TriggerIndustryProduction(iid);
}
- _cargo_delivery_destinations.Clear();
+ _cargo_delivery_destinations.clear();
}
/**
diff --git a/src/engine.cpp b/src/engine.cpp
index 9f500e1cdf..044faa5713 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -487,14 +487,15 @@ StringID Engine::GetAircraftTypeText() const
*/
void EngineOverrideManager::ResetToDefaultMapping()
{
- this->Clear();
+ this->clear();
for (VehicleType type = VEH_TRAIN; type <= VEH_AIRCRAFT; type++) {
for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
- EngineIDMapping *eid = this->Append();
- eid->type = type;
- eid->grfid = INVALID_GRFID;
- eid->internal_id = internal_id;
- eid->substitute_id = internal_id;
+ /*C++17: EngineIDMapping &eid = */ this->emplace_back();
+ EngineIDMapping &eid = this->back();
+ eid.type = type;
+ eid.grfid = INVALID_GRFID;
+ eid.internal_id = internal_id;
+ eid.substitute_id = internal_id;
}
}
}
@@ -510,12 +511,12 @@ void EngineOverrideManager::ResetToDefaultMapping()
*/
EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uint32 grfid)
{
- const EngineIDMapping *end = this->End();
EngineID index = 0;
- for (const EngineIDMapping *eid = this->Begin(); eid != end; eid++, index++) {
- if (eid->type == type && eid->grfid == grfid && eid->internal_id == grf_local_id) {
+ for (const EngineIDMapping &eid : *this) {
+ if (eid.type == type && eid.grfid == grfid && eid.internal_id == grf_local_id) {
return index;
}
+ index++;
}
return INVALID_ENGINE;
}
@@ -547,15 +548,15 @@ void SetupEngines()
DeleteWindowByClass(WC_ENGINE_PREVIEW);
_engine_pool.CleanPool();
- assert(_engine_mngr.Length() >= _engine_mngr.NUM_DEFAULT_ENGINES);
- const EngineIDMapping *end = _engine_mngr.End();
+ assert(_engine_mngr.size() >= _engine_mngr.NUM_DEFAULT_ENGINES);
uint index = 0;
- for (const EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) {
+ for (const EngineIDMapping &eid : _engine_mngr) {
/* Assert is safe; there won't be more than 256 original vehicles
* in any case, and we just cleaned the pool. */
assert(Engine::CanAllocateItem());
- const Engine *e = new Engine(eid->type, eid->internal_id);
+ const Engine *e = new Engine(eid.type, eid.internal_id);
assert(e->index == index);
+ index++;
}
}
@@ -652,7 +653,14 @@ void StartupOneEngine(Engine *e, Date aging_date)
/* Don't randomise the start-date in the first two years after gamestart to ensure availability
* of engines in early starting games.
* Note: TTDP uses fixed 1922 */
+ SavedRandomSeeds saved_seeds;
+ SaveRandomSeeds(&saved_seeds);
+ SetRandomSeed(_settings_game.game_creation.generation_seed ^
+ ei->base_intro ^
+ e->type ^
+ e->GetGRFID());
uint32 r = Random();
+
e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
if (e->intro_date <= _date) {
e->age = (aging_date - e->intro_date) >> 5;
@@ -672,6 +680,7 @@ void StartupOneEngine(Engine *e, Date aging_date)
e->reliability_spd_dec = ei->decay_speed << 2;
+ RestoreRandomSeeds(saved_seeds);
CalcEngineReliability(e);
/* prevent certain engines from ever appearing. */
diff --git a/src/engine_base.h b/src/engine_base.h
index 25c6bfbeb9..aaf88d9453 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -156,7 +156,7 @@ struct EngineIDMapping {
* Stores the mapping of EngineID to the internal id of newgrfs.
* Note: This is not part of Engine, as the data in the EngineOverrideManager and the engine pool get resetted in different cases.
*/
-struct EngineOverrideManager : SmallVector {
+struct EngineOverrideManager : std::vector {
static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries
void ResetToDefaultMapping();
diff --git a/src/engine_func.h b/src/engine_func.h
index 37fb005092..79dad18c72 100644
--- a/src/engine_func.h
+++ b/src/engine_func.h
@@ -26,7 +26,7 @@ extern const uint8 _engine_offsets[4];
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
bool IsEngineRefittable(EngineID engine);
-void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits);
+void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits, CargoID cargo_type, uint16 cargo_capacity);
void SetYearEngineAgingStops();
void StartupOneEngine(Engine *e, Date aging_date);
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 51c7e14836..4e9dc30d96 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -75,7 +75,7 @@ struct EnginePreviewWindow : Window {
this->flags |= WF_STICKY;
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget != WID_EP_QUESTION) return;
@@ -102,7 +102,7 @@ struct EnginePreviewWindow : Window {
size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_EP_QUESTION) return;
@@ -121,7 +121,7 @@ struct EnginePreviewWindow : Window {
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_EP_YES:
@@ -133,7 +133,7 @@ struct EnginePreviewWindow : Window {
}
}
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
@@ -325,11 +325,11 @@ void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID eng
*/
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
{
- uint size = el->Length();
+ size_t size = el->size();
/* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems)
* generally, do not sort if there are less than 2 items */
if (size < 2) return;
- QSortT(el->Begin(), size, compare);
+ QSortT(el->data(), size, compare);
}
/**
@@ -342,8 +342,8 @@ void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
{
if (num_items < 2) return;
- assert(begin < el->Length());
- assert(begin + num_items <= el->Length());
- QSortT(el->Get(begin), num_items, compare);
+ assert(begin < el->size());
+ assert(begin + num_items <= el->size());
+ QSortT(el->data() + begin, num_items, compare);
}
diff --git a/src/error_gui.cpp b/src/error_gui.cpp
index 1c59b7e8d0..47bca2638b 100644
--- a/src/error_gui.cpp
+++ b/src/error_gui.cpp
@@ -180,7 +180,7 @@ public:
this->InitNested();
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_EM_MESSAGE: {
@@ -208,7 +208,7 @@ public:
}
}
- virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
+ Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
{
/* Position (0, 0) given, center the window. */
if (this->position.x == 0 && this->position.y == 0) {
@@ -244,18 +244,18 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
/* If company gets shut down, while displaying an error about it, remove the error message. */
if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) delete this;
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
if (widget == WID_EM_CAPTION) CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_EM_FACE: {
@@ -292,13 +292,13 @@ public:
}
}
- virtual void OnMouseLoop()
+ void OnMouseLoop() override
{
/* Disallow closing the window too easily, if timeout is disabled */
if (_right_button_down && this->duration != 0) delete this;
}
- virtual void OnHundredthTick()
+ void OnHundredthTick() override
{
/* Timeout enabled? */
if (this->duration != 0) {
@@ -313,7 +313,7 @@ public:
if (_window_system_initialized) ShowFirstError();
}
- virtual EventState OnKeyPress(WChar key, uint16 keycode)
+ EventState OnKeyPress(WChar key, uint16 keycode) override
{
if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
delete this;
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 0e6d86e3c7..caaa0fed53 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -29,7 +29,7 @@
#include
#ifdef WITH_XDG_BASEDIR
-#include "basedir.h"
+#include
#endif
#include "safeguards.h"
@@ -539,16 +539,6 @@ void FioCreateDirectory(const char *name)
CreateDirectory(OTTD2FS(name), NULL);
#elif defined(OS2) && !defined(__INNOTEK_LIBC__)
mkdir(OTTD2FS(name));
-#elif defined(__MORPHOS__) || defined(__AMIGAOS__)
- char buf[MAX_PATH];
- strecpy(buf, name, lastof(buf));
-
- size_t len = strlen(name) - 1;
- if (buf[len] == '/') {
- buf[len] = '\0'; // Kill pathsep, so mkdir() will not fail
- }
-
- mkdir(OTTD2FS(buf), 0755);
#else
mkdir(OTTD2FS(name), 0755);
#endif
@@ -1010,10 +1000,6 @@ static bool ChangeWorkingDirectoryToExecutable(const char *exe)
char *s = strrchr(tmp, PATHSEPCHAR);
if (s != NULL) {
*s = '\0';
-#if defined(__DJGPP__)
- /* If we want to go to the root, we can't use cd C:, but we must use '/' */
- if (s > tmp && *(s - 1) == ':') chdir("/");
-#endif
if (chdir(tmp) != 0) {
DEBUG(misc, 0, "Directory with the binary does not exist?");
} else {
@@ -1066,7 +1052,7 @@ void DetermineBasePaths(const char *exe)
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_PERSONAL_DIR_XDG] = stredup(tmp);
#endif
-#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) || defined(OS2) || !defined(WITH_PERSONAL_DIR)
+#if defined(OS2) || !defined(WITH_PERSONAL_DIR)
_searchpaths[SP_PERSONAL_DIR] = NULL;
#else
#ifdef __HAIKU__
@@ -1109,13 +1095,9 @@ void DetermineBasePaths(const char *exe)
_searchpaths[SP_SHARED_DIR] = NULL;
#endif
-#if defined(__MORPHOS__) || defined(__AMIGA__)
- _searchpaths[SP_WORKING_DIR] = NULL;
-#else
if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_WORKING_DIR] = stredup(tmp);
-#endif
_do_scan_working_directory = DoScanWorkingDirectory();
@@ -1135,7 +1117,7 @@ void DetermineBasePaths(const char *exe)
}
}
-#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) || defined(OS2)
+#if !defined(GLOBAL_DATA_DIR)
_searchpaths[SP_INSTALLATION_DIR] = NULL;
#else
seprintf(tmp, lastof(tmp), "%s", GLOBAL_DATA_DIR);
@@ -1239,7 +1221,7 @@ void DeterminePaths(const char *exe)
}
/* Make the necessary folders */
-#if !defined(__MORPHOS__) && !defined(__AMIGA__) && defined(WITH_PERSONAL_DIR)
+#if defined(WITH_PERSONAL_DIR)
FioCreateDirectory(config_dir);
if (config_dir != _personal_dir) FioCreateDirectory(_personal_dir);
#endif
@@ -1258,7 +1240,6 @@ void DeterminePaths(const char *exe)
/* If we have network we make a directory for the autodownloading of content */
_searchpaths[SP_AUTODOWNLOAD_DIR] = str_fmt("%s%s", _personal_dir, "content_download" PATHSEP);
-#ifdef ENABLE_NETWORK
FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
/* Create the directory for each of the types of content */
@@ -1271,14 +1252,6 @@ void DeterminePaths(const char *exe)
extern char *_log_file;
_log_file = str_fmt("%sopenttd.log", _personal_dir);
-#else /* ENABLE_NETWORK */
- /* If we don't have networking, we don't need to make the directory. But
- * if it exists we keep it, otherwise remove it from the search paths. */
- if (!FileExists(_searchpaths[SP_AUTODOWNLOAD_DIR])) {
- free(_searchpaths[SP_AUTODOWNLOAD_DIR]);
- _searchpaths[SP_AUTODOWNLOAD_DIR] = NULL;
- }
-#endif /* ENABLE_NETWORK */
}
/**
diff --git a/src/fileio_func.h b/src/fileio_func.h
index f5ef58ac06..8263b7872c 100644
--- a/src/fileio_func.h
+++ b/src/fileio_func.h
@@ -107,7 +107,7 @@ public:
ALL = BASESET | NEWGRF | AI | SCENARIO | GAME, ///< Scan for everything.
};
- /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL);
+ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL) override;
bool AddFile(Subdirectory sd, const char *filename);
diff --git a/src/fios.cpp b/src/fios.cpp
index 73365ddc29..54ad54b112 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -13,11 +13,13 @@
*/
#include "stdafx.h"
-#include "fios.h"
+#include "3rdparty/md5/md5.h"
#include "fileio_func.h"
-#include "tar_type.h"
+#include "fios.h"
+#include "network/network_content.h"
#include "screenshot.h"
#include "string_func.h"
+#include "tar_type.h"
#include
#ifndef _WIN32
@@ -162,7 +164,7 @@ const char *FiosBrowseTo(const FiosItem *item)
break;
case FIOS_TYPE_PARENT: {
- /* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */
+ /* Check for possible NULL ptr */
char *s = strrchr(_fios_path, PATHSEPCHAR);
if (s != NULL && s != _fios_path) {
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
@@ -170,11 +172,6 @@ const char *FiosBrowseTo(const FiosItem *item)
s = strrchr(_fios_path, PATHSEPCHAR);
if (s != NULL) {
s[1] = '\0'; // go up a directory
-#if defined(__MORPHOS__) || defined(__AMIGAOS__)
- /* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
- } else if ((s = strrchr(_fios_path, ':')) != NULL) {
- s[1] = '\0';
-#endif
}
break;
}
@@ -215,21 +212,7 @@ static void FiosMakeFilename(char *buf, const char *path, const char *name, cons
/* Don't append the extension if it is already there */
period = strrchr(name, '.');
if (period != NULL && strcasecmp(period, ext) == 0) ext = "";
-#if defined(__MORPHOS__) || defined(__AMIGAOS__)
- if (path != NULL) {
- unsigned char sepchar = path[(strlen(path) - 1)];
-
- if (sepchar != ':' && sepchar != '/') {
- seprintf(buf, last, "%s" PATHSEP "%s%s", path, name, ext);
- } else {
- seprintf(buf, last, "%s%s%s", path, name, ext);
- }
- } else {
- seprintf(buf, last, "%s%s", name, ext);
- }
-#else
seprintf(buf, last, "%s" PATHSEP "%s%s", path, name, ext);
-#endif
}
/**
@@ -293,7 +276,7 @@ public:
fop(fop), callback_proc(callback_proc), file_list(file_list)
{}
- /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
+ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
};
/**
@@ -359,7 +342,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
struct dirent *dirent;
DIR *dir;
FiosItem *fios;
- int sort_start;
+ size_t sort_start;
char d_name[sizeof(fios->name)];
file_list.Clear();
@@ -397,7 +380,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
{
SortingBits order = _savegame_sort_order;
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
- QSortT(file_list.files.Begin(), file_list.files.Length(), CompareFiosItems);
+ QSortT(file_list.files.data(), file_list.files.size(), CompareFiosItems);
_savegame_sort_order = order;
}
@@ -651,10 +634,6 @@ const char *FiosGetScreenshotDir()
return fios_screenshot_path;
}
-#if defined(ENABLE_NETWORK)
-#include "network/network_content.h"
-#include "3rdparty/md5/md5.h"
-
/** Basic data to distinguish a scenario. Used in the server list window */
struct ScenarioIdentifier {
uint32 scenid; ///< ID for the scenario (generated by content).
@@ -676,7 +655,7 @@ struct ScenarioIdentifier {
/**
* Scanner to find the unique IDs of scenarios
*/
-class ScenarioScanner : protected FileScanner, public SmallVector {
+class ScenarioScanner : protected FileScanner, public std::vector {
bool scanned; ///< Whether we've already scanned
public:
/** Initialise */
@@ -694,7 +673,7 @@ public:
this->scanned = true;
}
- /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
+ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
{
FILE *f = FioFOpenFile(filename, "r", SCENARIO_DIR);
if (f == NULL) return false;
@@ -727,7 +706,7 @@ public:
FioFCloseFile(f);
- this->Include(id);
+ include(*this, id);
return true;
}
};
@@ -745,10 +724,10 @@ const char *FindScenario(const ContentInfo *ci, bool md5sum)
{
_scanner.Scan(false);
- for (ScenarioIdentifier *id = _scanner.Begin(); id != _scanner.End(); id++) {
- if (md5sum ? (memcmp(id->md5sum, ci->md5sum, sizeof(id->md5sum)) == 0)
- : (id->scenid == ci->unique_id)) {
- return id->filename;
+ for (ScenarioIdentifier &id : _scanner) {
+ if (md5sum ? (memcmp(id.md5sum, ci->md5sum, sizeof(id.md5sum)) == 0)
+ : (id.scenid == ci->unique_id)) {
+ return id.filename;
}
}
@@ -773,5 +752,3 @@ void ScanScenarios()
{
_scanner.Scan(true);
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/fios.h b/src/fios.h
index 24c9f370eb..6ae0550d11 100644
--- a/src/fios.h
+++ b/src/fios.h
@@ -120,16 +120,17 @@ public:
*/
inline FiosItem *Append()
{
- return this->files.Append();
+ /*C++17: return &*/ this->files.emplace_back();
+ return &this->files.back();
}
/**
* Get the number of files in the list.
* @return The number of files stored in the list.
*/
- inline uint Length() const
+ inline size_t Length() const
{
- return this->files.Length();
+ return this->files.size();
}
/**
@@ -138,7 +139,7 @@ public:
*/
inline const FiosItem *Begin() const
{
- return this->files.Begin();
+ return this->files.data();
}
/**
@@ -147,28 +148,28 @@ public:
*/
inline const FiosItem *End() const
{
- return this->files.End();
+ return this->Begin() + this->Length();
}
/**
* Get a pointer to the indicated file information. File information must exist.
* @return Address of the indicated existing file information.
*/
- inline const FiosItem *Get(uint index) const
+ inline const FiosItem *Get(size_t index) const
{
- return this->files.Get(index);
+ return this->files.data() + index;
}
/**
* Get a pointer to the indicated file information. File information must exist.
* @return Address of the indicated existing file information.
*/
- inline FiosItem *Get(uint index)
+ inline FiosItem *Get(size_t index)
{
- return this->files.Get(index);
+ return this->files.data() + index;
}
- inline const FiosItem &operator[](uint index) const
+ inline const FiosItem &operator[](size_t index) const
{
return this->files[index];
}
@@ -177,7 +178,7 @@ public:
* Get a reference to the indicated file information. File information must exist.
* @return The requested file information.
*/
- inline FiosItem &operator[](uint index)
+ inline FiosItem &operator[](size_t index)
{
return this->files[index];
}
@@ -185,19 +186,19 @@ public:
/** Remove all items from the list. */
inline void Clear()
{
- this->files.Clear();
+ this->files.clear();
}
/** Compact the list down to the smallest block size boundary. */
inline void Compact()
{
- this->files.Compact();
+ this->files.shrink_to_fit();
}
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop);
const FiosItem *FindItem(const char *file);
- SmallVector files; ///< The list of files.
+ std::vector files; ///< The list of files.
};
enum SortingBits {
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 63bb589d77..7a194054f5 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -57,11 +57,10 @@ void LoadCheckData::Clear()
this->current_date = 0;
memset(&this->settings, 0, sizeof(this->settings));
- const CompanyPropertiesMap::iterator end = this->companies.End();
- for (CompanyPropertiesMap::iterator it = this->companies.Begin(); it != end; it++) {
- delete it->second;
+ for (auto &pair : this->companies) {
+ delete pair.second;
}
- companies.Clear();
+ companies.clear();
GamelogFree(this->gamelog_action, this->gamelog_actions);
this->gamelog_action = NULL;
@@ -245,8 +244,8 @@ static const TextColour _fios_colours[] = {
*/
static void SortSaveGameList(FileList &file_list)
{
- uint sort_start = 0;
- uint sort_end = 0;
+ size_t sort_start = 0;
+ size_t sort_end = 0;
/* Directories are always above the files (FIOS_TYPE_DIR)
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
@@ -261,7 +260,7 @@ static void SortSaveGameList(FileList &file_list)
}
}
- uint s_amount = file_list.Length() - sort_start - sort_end;
+ size_t s_amount = file_list.Length() - sort_start - sort_end;
QSortT(file_list.Get(sort_start), s_amount, CompareFiosItems);
}
@@ -279,7 +278,7 @@ private:
StringFilter string_filter; ///< Filter for available games.
QueryString filter_editbox; ///< Filter editbox;
- SmallVector fios_items_shown; ///< Map of the filtered out fios items
+ std::vector fios_items_shown; ///< Map of the filtered out fios items
static void SaveGameConfirmationCallback(Window *w, bool confirmed)
{
@@ -407,7 +406,7 @@ public:
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_SL_SORT_BYNAME:
@@ -437,12 +436,15 @@ public:
GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
uint y = r.top + WD_FRAMERECT_TOP;
- for (uint pos = this->vscroll->GetPosition(); pos < this->fios_items.Length(); pos++) {
- if (!this->fios_items_shown[pos]) {
+ uint scroll_pos = this->vscroll->GetPosition();
+ for (uint row = 0; row < this->fios_items.Length(); row++) {
+ if (!this->fios_items_shown[row]) {
/* The current item is filtered out : we do not show it */
+ scroll_pos++;
continue;
}
- const FiosItem *item = this->fios_items.Get(pos);
+ if (row < scroll_pos) continue;
+ const FiosItem *item = this->fios_items.Get(row);
if (item == this->selected) {
GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_BLUE);
@@ -528,10 +530,9 @@ public:
if (y > y_max) break;
/* Companies / AIs */
- CompanyPropertiesMap::const_iterator end = _load_check_data.companies.End();
- for (CompanyPropertiesMap::const_iterator it = _load_check_data.companies.Begin(); it != end; it++) {
- SetDParam(0, it->first + 1);
- const CompanyProperties &c = *it->second;
+ for (auto &pair : _load_check_data.companies) {
+ SetDParam(0, pair.first + 1);
+ const CompanyProperties &c = *pair.second;
if (c.name != NULL) {
SetDParam(1, STR_JUST_RAW_STRING);
SetDParamStr(2, c.name);
@@ -550,7 +551,7 @@ public:
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_SL_BACKGROUND:
@@ -572,17 +573,18 @@ public:
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
if (_savegame_sort_dirty) {
_savegame_sort_dirty = false;
SortSaveGameList(this->fios_items);
+ this->OnInvalidateData(SLIWD_FILTER_CHANGES);
}
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_SL_SORT_BYNAME: // Sort save names by name
@@ -633,9 +635,7 @@ public:
if (!_network_available) {
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
} else if (_load_check_data.HasNewGrfs()) {
-#if defined(ENABLE_NETWORK)
ShowMissingContentWindow(_load_check_data.grfconfig);
-#endif
}
break;
@@ -697,14 +697,12 @@ public:
if (!_network_available) {
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
} else {
-#if defined(ENABLE_NETWORK)
assert(this->fop == SLO_LOAD);
switch (this->abstract_filetype) {
default: NOT_REACHED();
case FT_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
case FT_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break;
}
-#endif
}
break;
@@ -718,7 +716,7 @@ public:
}
}
- virtual EventState OnKeyPress(WChar key, uint16 keycode)
+ EventState OnKeyPress(WChar key, uint16 keycode) override
{
if (keycode == WKC_ESC) {
delete this;
@@ -728,7 +726,7 @@ public:
return ES_NOT_HANDLED;
}
- virtual void OnTimeout()
+ void OnTimeout() override
{
/* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */
if (this->fop != SLO_SAVE) return;
@@ -763,7 +761,7 @@ public:
}
}
- virtual void OnResize()
+ void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_SL_DRIVES_DIRECTORIES_LIST);
}
@@ -773,7 +771,7 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
switch (data) {
case SLIWD_RESCAN_FILES:
@@ -784,7 +782,7 @@ public:
_fios_path_changed = true;
this->fios_items.BuildFileList(this->abstract_filetype, this->fop);
- this->vscroll->SetCount(this->fios_items.Length());
+ this->vscroll->SetCount((uint)this->fios_items.Length());
this->selected = NULL;
_load_check_data.Clear();
@@ -824,7 +822,7 @@ public:
case SLIWD_FILTER_CHANGES:
/* Filter changes */
- this->fios_items_shown.Resize(this->fios_items.Length());
+ this->fios_items_shown.resize(this->fios_items.Length());
uint items_shown_count = 0; ///< The number of items shown in the list
/* We pass through every fios item */
for (uint i = 0; i < this->fios_items.Length(); i++) {
@@ -851,7 +849,7 @@ public:
}
}
- virtual void OnEditboxChanged(int wid)
+ void OnEditboxChanged(int wid) override
{
if (wid == WID_SL_FILTER) {
this->string_filter.SetFilterTerm(this->filter_editbox.text.buf);
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index 98e8bdf41c..82a441814f 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -184,12 +184,12 @@ uint SpriteFontCache::GetGlyphWidth(GlyphID key)
{
SpriteID sprite = this->GetUnicodeGlyph(key);
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
- return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleGUITrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
+ return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
}
int SpriteFontCache::GetHeight() const
{
- return ScaleGUITrad(this->height);
+ return ScaleFontTrad(this->height);
}
bool SpriteFontCache::GetDrawGlyphShadow()
@@ -282,16 +282,18 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
{
if (pixels == 0) {
/* Try to determine a good height based on the minimal height recommended by the font. */
- int scaled_height = ScaleGUITrad(_default_font_height[this->fs]);
+ int scaled_height = ScaleFontTrad(_default_font_height[this->fs]);
pixels = scaled_height;
TT_Header *head = (TT_Header *)FT_Get_Sfnt_Table(this->face, ft_sfnt_head);
if (head != NULL) {
/* Font height is minimum height plus the difference between the default
* height for this font size and the small size. */
- int diff = scaled_height - ScaleGUITrad(_default_font_height[FS_SMALL]);
+ int diff = scaled_height - ScaleFontTrad(_default_font_height[FS_SMALL]);
pixels = Clamp(min(head->Lowest_Rec_PPEM, 20) + diff, scaled_height, MAX_FONT_SIZE);
}
+ } else {
+ pixels = ScaleFontTrad(pixels);
}
this->used_size = pixels;
@@ -409,8 +411,8 @@ FreeTypeFontCache::~FreeTypeFontCache()
this->face = NULL;
this->ClearFontCache();
- for (FontTable::iterator iter = this->font_tables.Begin(); iter != this->font_tables.End(); iter++) {
- free(iter->second.second);
+ for (auto &iter : this->font_tables) {
+ free(iter.second.second);
}
}
@@ -419,6 +421,9 @@ FreeTypeFontCache::~FreeTypeFontCache()
*/
void FreeTypeFontCache::ClearFontCache()
{
+ /* Font scaling might have changed, determine font size anew if it was automatically selected. */
+ if (this->face != NULL) this->SetFontSize(this->fs, this->face, this->req_size);
+
if (this->glyph_to_sprite == NULL) return;
for (int i = 0; i < 256; i++) {
@@ -436,9 +441,6 @@ void FreeTypeFontCache::ClearFontCache()
this->glyph_to_sprite = NULL;
Layouter::ResetFontCache(this->fs);
-
- /* GUI scaling might have changed, determine font size anew if it was automatically selected. */
- if (this->face != NULL && this->req_size == 0) this->SetFontSize(this->fs, this->face, this->req_size);
}
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
@@ -631,7 +633,7 @@ GlyphID FreeTypeFontCache::MapCharToGlyph(WChar key)
const void *FreeTypeFontCache::GetFontTable(uint32 tag, size_t &length)
{
const FontTable::iterator iter = this->font_tables.Find(tag);
- if (iter != this->font_tables.End()) {
+ if (iter != this->font_tables.data() + this->font_tables.size()) {
length = iter->second.first;
return iter->second.second;
}
diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp
index 908cf81c0b..fe8338899d 100644
--- a/src/framerate_gui.cpp
+++ b/src/framerate_gui.cpp
@@ -13,13 +13,18 @@
#include
#include "gfx_func.h"
#include "window_gui.h"
+#include "window_func.h"
#include "table/sprites.h"
+#include "string_func.h"
#include "strings_func.h"
#include "console_func.h"
#include "console_type.h"
#include "guitimer_func.h"
+#include "company_base.h"
+#include "ai/ai_info.hpp"
#include "widgets/framerate_widget.h"
+#include "safeguards.h"
/**
@@ -183,6 +188,23 @@ namespace {
PerformanceData(1), // PFE_ACC_DRAWWORLD
PerformanceData(60.0), // PFE_VIDEO
PerformanceData(1000.0 * 8192 / 44100), // PFE_SOUND
+ PerformanceData(1), // PFE_ALLSCRIPTS
+ PerformanceData(1), // PFE_GAMESCRIPT
+ PerformanceData(1), // PFE_AI0 ...
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1),
+ PerformanceData(1), // PFE_AI14
};
}
@@ -215,6 +237,15 @@ PerformanceMeasurer::PerformanceMeasurer(PerformanceElement elem)
/** Finish a cycle of a measured element and store the measurement taken. */
PerformanceMeasurer::~PerformanceMeasurer()
{
+ if (this->elem == PFE_ALLSCRIPTS) {
+ /* Hack to not record scripts total when no scripts are active */
+ bool any_active = _pf_data[PFE_GAMESCRIPT].num_valid > 0;
+ for (uint e = PFE_AI0; e < PFE_MAX; e++) any_active |= _pf_data[e].num_valid > 0;
+ if (!any_active) {
+ PerformanceMeasurer::SetInactive(PFE_ALLSCRIPTS);
+ return;
+ }
+ }
_pf_data[this->elem].Add(this->start_time, GetPerformanceTimer());
}
@@ -224,11 +255,19 @@ void PerformanceMeasurer::SetExpectedRate(double rate)
_pf_data[this->elem].expected_rate = rate;
}
+/** Mark a performance element as not currently in use. */
+/* static */ void PerformanceMeasurer::SetInactive(PerformanceElement elem)
+{
+ _pf_data[elem].num_valid = 0;
+ _pf_data[elem].next_index = 0;
+ _pf_data[elem].prev_index = 0;
+}
+
/**
* Indicate that a cycle of "pause" where no processing occurs.
* @param elem The element not currently being processed
*/
-void PerformanceMeasurer::Paused(PerformanceElement elem)
+/* static */ void PerformanceMeasurer::Paused(PerformanceElement elem)
{
_pf_data[elem].AddPause(GetPerformanceTimer());
}
@@ -266,6 +305,44 @@ void PerformanceAccumulator::Reset(PerformanceElement elem)
void ShowFrametimeGraphWindow(PerformanceElement elem);
+static const PerformanceElement DISPLAY_ORDER_PFE[PFE_MAX] = {
+ PFE_GAMELOOP,
+ PFE_GL_ECONOMY,
+ PFE_GL_TRAINS,
+ PFE_GL_ROADVEHS,
+ PFE_GL_SHIPS,
+ PFE_GL_AIRCRAFT,
+ PFE_GL_LANDSCAPE,
+ PFE_ALLSCRIPTS,
+ PFE_GAMESCRIPT,
+ PFE_AI0,
+ PFE_AI1,
+ PFE_AI2,
+ PFE_AI3,
+ PFE_AI4,
+ PFE_AI5,
+ PFE_AI6,
+ PFE_AI7,
+ PFE_AI8,
+ PFE_AI9,
+ PFE_AI10,
+ PFE_AI11,
+ PFE_AI12,
+ PFE_AI13,
+ PFE_AI14,
+ PFE_GL_LINKGRAPH,
+ PFE_DRAWING,
+ PFE_DRAWWORLD,
+ PFE_VIDEO,
+ PFE_SOUND,
+};
+
+static const char * GetAIName(int ai_index)
+{
+ if (!Company::IsValidAiID(ai_index)) return "";
+ return Company::Get(ai_index)->ai_info->GetName();
+}
+
/** @hideinitializer */
static const NWidgetPart _framerate_window_widgets[] = {
NWidget(NWID_HORIZONTAL),
@@ -281,14 +358,20 @@ static const NWidgetPart _framerate_window_widgets[] = {
NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_RATE_FACTOR), SetDataTip(STR_FRAMERATE_SPEED_FACTOR, STR_FRAMERATE_SPEED_FACTOR_TOOLTIP),
EndContainer(),
EndContainer(),
- NWidget(WWT_PANEL, COLOUR_GREY),
- NWidget(NWID_VERTICAL), SetPadding(6), SetPIP(0, 3, 0),
- NWidget(NWID_HORIZONTAL), SetPIP(0, 6, 0),
- NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_NAMES),
- NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_CURRENT),
- NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_AVERAGE),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_PANEL, COLOUR_GREY),
+ NWidget(NWID_VERTICAL), SetPadding(6), SetPIP(0, 3, 0),
+ NWidget(NWID_HORIZONTAL), SetPIP(0, 6, 0),
+ NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_NAMES), SetScrollbar(WID_FRW_SCROLLBAR),
+ NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_CURRENT), SetScrollbar(WID_FRW_SCROLLBAR),
+ NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_AVERAGE), SetScrollbar(WID_FRW_SCROLLBAR),
+ EndContainer(),
+ NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_INFO_DATA_POINTS), SetDataTip(STR_FRAMERATE_DATA_POINTS, 0x0),
EndContainer(),
- NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_INFO_DATA_POINTS), SetDataTip(STR_FRAMERATE_DATA_POINTS, 0x0),
+ EndContainer(),
+ NWidget(NWID_VERTICAL),
+ NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_FRW_SCROLLBAR),
+ NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
};
@@ -296,6 +379,8 @@ static const NWidgetPart _framerate_window_widgets[] = {
struct FramerateWindow : Window {
bool small;
GUITimer next_update;
+ int num_active;
+ int num_displayed;
struct CachedDecimal {
StringID strid;
@@ -332,17 +417,22 @@ struct FramerateWindow : Window {
CachedDecimal times_shortterm[PFE_MAX]; ///< cached short term average times
CachedDecimal times_longterm[PFE_MAX]; ///< cached long term average times
- static const int VSPACING = 3; ///< space between column heading and values
+ static const int VSPACING = 3; ///< space between column heading and values
+ static const int MIN_ELEMENTS = 5; ///< smallest number of elements to display
FramerateWindow(WindowDesc *desc, WindowNumber number) : Window(desc)
{
this->InitNested(number);
this->small = this->IsShaded();
this->UpdateData();
+ this->num_displayed = this->num_active;
this->next_update.SetInterval(100);
+
+ /* Window is always initialised to MIN_ELEMENTS height, resize to contain num_displayed */
+ ResizeWindow(this, 0, (max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * FONT_HEIGHT_NORMAL);
}
- virtual void OnRealtimeTick(uint delta_ms)
+ void OnRealtimeTick(uint delta_ms) override
{
bool elapsed = this->next_update.Elapsed(delta_ms);
@@ -369,13 +459,23 @@ struct FramerateWindow : Window {
this->rate_drawing.SetRate(_pf_data[PFE_DRAWING].GetRate(), _pf_data[PFE_DRAWING].expected_rate);
+ int new_active = 0;
for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
this->times_shortterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(8), MILLISECONDS_PER_TICK);
this->times_longterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(NUM_FRAMERATE_POINTS), MILLISECONDS_PER_TICK);
+ if (_pf_data[e].num_valid > 0) new_active++;
+ }
+
+ if (new_active != this->num_active) {
+ this->num_active = new_active;
+ Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
+ sb->SetCount(this->num_active);
+ sb->SetCapacity(min(this->num_displayed, this->num_active));
+ this->ReInit();
}
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_FRW_CAPTION:
@@ -403,7 +503,7 @@ struct FramerateWindow : Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_FRW_RATE_GAMELOOP:
@@ -425,11 +525,20 @@ struct FramerateWindow : Window {
break;
case WID_FRW_TIMES_NAMES: {
- int linecount = PFE_MAX - PFE_FIRST;
size->width = 0;
- size->height = FONT_HEIGHT_NORMAL * (linecount + 1) + VSPACING;
- for (int line = 0; line < linecount; line++) {
- Dimension line_size = GetStringBoundingBox(STR_FRAMERATE_GAMELOOP + line);
+ size->height = FONT_HEIGHT_NORMAL + VSPACING + MIN_ELEMENTS * FONT_HEIGHT_NORMAL;
+ resize->width = 0;
+ resize->height = FONT_HEIGHT_NORMAL;
+ for (PerformanceElement e : DISPLAY_ORDER_PFE) {
+ if (_pf_data[e].num_valid == 0) continue;
+ Dimension line_size;
+ if (e < PFE_AI0) {
+ line_size = GetStringBoundingBox(STR_FRAMERATE_GAMELOOP + e);
+ } else {
+ SetDParam(0, e - PFE_AI0 + 1);
+ SetDParamStr(1, GetAIName(e - PFE_AI0));
+ line_size = GetStringBoundingBox(STR_FRAMERATE_AI);
+ }
size->width = max(size->width, line_size.width);
}
break;
@@ -437,13 +546,14 @@ struct FramerateWindow : Window {
case WID_FRW_TIMES_CURRENT:
case WID_FRW_TIMES_AVERAGE: {
- int linecount = PFE_MAX - PFE_FIRST;
*size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT));
SetDParam(0, 999999);
SetDParam(1, 2);
Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD);
size->width = max(size->width, item_size.width);
- size->height += FONT_HEIGHT_NORMAL * linecount + VSPACING;
+ size->height += FONT_HEIGHT_NORMAL * MIN_ELEMENTS + VSPACING;
+ resize->width = 0;
+ resize->height = FONT_HEIGHT_NORMAL;
break;
}
}
@@ -452,27 +562,51 @@ struct FramerateWindow : Window {
/** Render a column of formatted average durations */
void DrawElementTimesColumn(const Rect &r, StringID heading_str, const CachedDecimal *values) const
{
+ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
+ uint16 skip = sb->GetPosition();
+ int drawable = this->num_displayed;
int y = r.top;
DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true);
y += FONT_HEIGHT_NORMAL + VSPACING;
-
- for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
- values[e].InsertDParams(0);
- DrawString(r.left, r.right, y, values[e].strid, TC_FROMSTRING, SA_RIGHT);
- y += FONT_HEIGHT_NORMAL;
+ for (PerformanceElement e : DISPLAY_ORDER_PFE) {
+ if (_pf_data[e].num_valid == 0) continue;
+ if (skip > 0) {
+ skip--;
+ } else {
+ values[e].InsertDParams(0);
+ DrawString(r.left, r.right, y, values[e].strid, TC_FROMSTRING, SA_RIGHT);
+ y += FONT_HEIGHT_NORMAL;
+ drawable--;
+ if (drawable == 0) break;
+ }
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_FRW_TIMES_NAMES: {
/* Render a column of titles for performance element names */
- int linecount = PFE_MAX - PFE_FIRST;
+ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
+ uint16 skip = sb->GetPosition();
+ int drawable = this->num_displayed;
int y = r.top + FONT_HEIGHT_NORMAL + VSPACING; // first line contains headings in the value columns
- for (int i = 0; i < linecount; i++) {
- DrawString(r.left, r.right, y, STR_FRAMERATE_GAMELOOP + i, TC_FROMSTRING, SA_LEFT);
- y += FONT_HEIGHT_NORMAL;
+ for (PerformanceElement e : DISPLAY_ORDER_PFE) {
+ if (_pf_data[e].num_valid == 0) continue;
+ if (skip > 0) {
+ skip--;
+ } else {
+ if (e < PFE_AI0) {
+ DrawString(r.left, r.right, y, STR_FRAMERATE_GAMELOOP + e, TC_FROMSTRING, SA_LEFT);
+ } else {
+ SetDParam(0, e - PFE_AI0 + 1);
+ SetDParamStr(1, GetAIName(e - PFE_AI0));
+ DrawString(r.left, r.right, y, STR_FRAMERATE_AI, TC_FROMSTRING, SA_LEFT);
+ }
+ y += FONT_HEIGHT_NORMAL;
+ drawable--;
+ if (drawable == 0) break;
+ }
}
break;
}
@@ -487,26 +621,41 @@ struct FramerateWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_FRW_TIMES_NAMES:
case WID_FRW_TIMES_CURRENT:
case WID_FRW_TIMES_AVERAGE: {
/* Open time graph windows when clicking detail measurement lines */
- int line = this->GetRowFromWidget(pt.y, widget, VSPACING, FONT_HEIGHT_NORMAL);
- if (line > 0) {
- line -= 1;
- ShowFrametimeGraphWindow((PerformanceElement)line);
+ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
+ int line = sb->GetScrolledRowFromWidget(pt.y - FONT_HEIGHT_NORMAL - VSPACING, this, widget, VSPACING, FONT_HEIGHT_NORMAL);
+ if (line != INT_MAX) {
+ line++;
+ /* Find the visible line that was clicked */
+ for (PerformanceElement e : DISPLAY_ORDER_PFE) {
+ if (_pf_data[e].num_valid > 0) line--;
+ if (line == 0) {
+ ShowFrametimeGraphWindow(e);
+ break;
+ }
+ }
}
break;
}
}
}
+
+ void OnResize() override
+ {
+ auto *wid = this->GetWidget(WID_FRW_TIMES_NAMES);
+ this->num_displayed = (wid->current_y - wid->min_y - VSPACING) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
+ this->GetScrollbar(WID_FRW_SCROLLBAR)->SetCapacity(this->num_displayed);
+ }
};
static WindowDesc _framerate_display_desc(
- WDP_AUTO, "framerate_display", 60, 40,
+ WDP_AUTO, "framerate_display", 0, 0,
WC_FRAMERATE_DISPLAY, WC_NONE,
0,
_framerate_window_widgets, lengthof(_framerate_window_widgets)
@@ -545,16 +694,22 @@ struct FrametimeGraphWindow : Window {
this->InitNested(number);
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_FGW_CAPTION:
- SetDParam(0, STR_FRAMETIME_CAPTION_GAMELOOP + this->element);
+ if (this->element < PFE_AI0) {
+ SetDParam(0, STR_FRAMETIME_CAPTION_GAMELOOP + this->element);
+ } else {
+ SetDParam(0, STR_FRAMETIME_CAPTION_AI);
+ SetDParam(1, this->element - PFE_AI0 + 1);
+ SetDParamStr(2, GetAIName(this->element - PFE_AI0));
+ }
break;
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_FGW_GRAPH) {
SetDParam(0, 100);
@@ -652,7 +807,7 @@ struct FrametimeGraphWindow : Window {
this->SelectVerticalScale(peak_value);
}
- virtual void OnRealtimeTick(uint delta_ms)
+ void OnRealtimeTick(uint delta_ms) override
{
this->SetDirty();
@@ -671,7 +826,7 @@ struct FrametimeGraphWindow : Window {
return (value - src_min) * dst_diff / src_diff + dst_min;
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
if (widget == WID_FGW_GRAPH) {
const TimingMeasurement *durations = _pf_data[this->element].durations;
@@ -829,7 +984,10 @@ void ConPrintFramerate()
" Viewport drawing",
"Video output",
"Sound mixing",
+ "AI/GS scripts total",
+ "Game script",
};
+ char ai_name_buf[128];
static const PerformanceElement rate_elements[] = { PFE_GAMELOOP, PFE_DRAWING, PFE_VIDEO };
@@ -848,8 +1006,15 @@ void ConPrintFramerate()
for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
auto &pf = _pf_data[e];
if (pf.num_valid == 0) continue;
+ const char *name;
+ if (e < PFE_AI0) {
+ name = MEASUREMENT_NAMES[e];
+ } else {
+ seprintf(ai_name_buf, lastof(ai_name_buf), "AI %d %s", e - PFE_AI0 + 1, GetAIName(e - PFE_AI0)),
+ name = ai_name_buf;
+ }
IConsolePrintF(TC_LIGHT_BLUE, "%s times: %.2fms %.2fms %.2fms",
- MEASUREMENT_NAMES[e],
+ name,
pf.GetAverageDurationMilliseconds(count1),
pf.GetAverageDurationMilliseconds(count2),
pf.GetAverageDurationMilliseconds(count3));
diff --git a/src/framerate_type.h b/src/framerate_type.h
index 8df9a279a1..3c54e03078 100644
--- a/src/framerate_type.h
+++ b/src/framerate_type.h
@@ -60,6 +60,23 @@ enum PerformanceElement {
PFE_DRAWWORLD, ///< Time spent drawing world viewports in GUI
PFE_VIDEO, ///< Speed of painting drawn video buffer.
PFE_SOUND, ///< Speed of mixing audio samples
+ PFE_ALLSCRIPTS, ///< Sum of all GS/AI scripts
+ PFE_GAMESCRIPT, ///< Game script execution
+ PFE_AI0, ///< AI execution for player slot 1
+ PFE_AI1, ///< AI execution for player slot 2
+ PFE_AI2, ///< AI execution for player slot 3
+ PFE_AI3, ///< AI execution for player slot 4
+ PFE_AI4, ///< AI execution for player slot 5
+ PFE_AI5, ///< AI execution for player slot 6
+ PFE_AI6, ///< AI execution for player slot 7
+ PFE_AI7, ///< AI execution for player slot 8
+ PFE_AI8, ///< AI execution for player slot 9
+ PFE_AI9, ///< AI execution for player slot 10
+ PFE_AI10, ///< AI execution for player slot 11
+ PFE_AI11, ///< AI execution for player slot 12
+ PFE_AI12, ///< AI execution for player slot 13
+ PFE_AI13, ///< AI execution for player slot 14
+ PFE_AI14, ///< AI execution for player slot 15
PFE_MAX, ///< End of enum, must be last.
};
DECLARE_POSTFIX_INCREMENT(PerformanceElement)
@@ -81,6 +98,7 @@ public:
PerformanceMeasurer(PerformanceElement elem);
~PerformanceMeasurer();
void SetExpectedRate(double rate);
+ static void SetInactive(PerformanceElement elem);
static void Paused(PerformanceElement elem);
};
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 329ba5e500..95d9aa0a13 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -112,11 +112,9 @@ public:
*/
static class GameInstance *GetInstance() { return Game::instance; }
-#if defined(ENABLE_NETWORK)
/** Wrapper function for GameScanner::HasGame */
static bool HasGame(const struct ContentInfo *ci, bool md5sum);
static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
-#endif
/** Gets the ScriptScanner instance that is used to find Game scripts */
static GameScannerInfo *GetScannerInfo();
/** Gets the ScriptScanner instance that is used to find Game Libraries */
diff --git a/src/game/game_config.hpp b/src/game/game_config.hpp
index e9ebdc38c1..dfae62c3a9 100644
--- a/src/game/game_config.hpp
+++ b/src/game/game_config.hpp
@@ -42,7 +42,7 @@ public:
bool ResetInfo(bool force_exact_match);
protected:
- /* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match);
+ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override;
};
#endif /* GAME_CONFIG_HPP */
diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp
index 2f95e26224..7b05abb40d 100644
--- a/src/game/game_core.cpp
+++ b/src/game/game_core.cpp
@@ -15,6 +15,7 @@
#include "../company_func.h"
#include "../network/network.h"
#include "../window_func.h"
+#include "../framerate_type.h"
#include "game.hpp"
#include "game_scanner.hpp"
#include "game_config.hpp"
@@ -31,8 +32,16 @@
/* static */ void Game::GameLoop()
{
- if (_networking && !_network_server) return;
- if (Game::instance == NULL) return;
+ if (_networking && !_network_server) {
+ PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
+ return;
+ }
+ if (Game::instance == NULL) {
+ PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
+ return;
+ }
+
+ PerformanceMeasurer framerate(PFE_GAMESCRIPT);
Game::frame_counter++;
@@ -248,8 +257,6 @@
return Game::scanner_library->FindLibrary(library, version);
}
-#if defined(ENABLE_NETWORK)
-
/**
* Check whether we have an Game (library) with the exact characteristics as ci.
* @param ci the characteristics to search on (shortname and md5sum)
@@ -266,8 +273,6 @@
return Game::scanner_library->HasScript(ci, md5sum);
}
-#endif /* defined(ENABLE_NETWORK) */
-
/* static */ GameScannerInfo *Game::GetScannerInfo()
{
return Game::scanner_info;
diff --git a/src/game/game_info.cpp b/src/game/game_info.cpp
index f8c04608b7..0aa3161740 100644
--- a/src/game/game_info.cpp
+++ b/src/game/game_info.cpp
@@ -26,7 +26,7 @@ static bool CheckAPIVersion(const char *api_version)
{
return strcmp(api_version, "1.2") == 0 || strcmp(api_version, "1.3") == 0 || strcmp(api_version, "1.4") == 0 ||
strcmp(api_version, "1.5") == 0 || strcmp(api_version, "1.6") == 0 || strcmp(api_version, "1.7") == 0 ||
- strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0;
+ strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0 || strcmp(api_version, "1.10") == 0;
}
#if defined(_WIN32)
diff --git a/src/game/game_info.hpp b/src/game/game_info.hpp
index f4fc5ed86b..a799ed7d6d 100644
--- a/src/game/game_info.hpp
+++ b/src/game/game_info.hpp
@@ -40,7 +40,7 @@ public:
*/
const char *GetAPIVersion() const { return this->api_version; }
- /* virtual */ bool IsDeveloperOnly() const { return this->is_developer_only; }
+ bool IsDeveloperOnly() const override { return this->is_developer_only; }
private:
int min_loadable_version; ///< The Game can load savegame data if the version is equal or greater than this.
diff --git a/src/game/game_instance.hpp b/src/game/game_instance.hpp
index 08ce344247..dd0e7950aa 100644
--- a/src/game/game_instance.hpp
+++ b/src/game/game_instance.hpp
@@ -25,14 +25,14 @@ public:
*/
void Initialize(class GameInfo *info);
- /* virtual */ int GetSetting(const char *name);
- /* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
+ int GetSetting(const char *name) override;
+ ScriptInfo *FindLibrary(const char *library, int version) override;
private:
- /* virtual */ void RegisterAPI();
- /* virtual */ void Died();
- /* virtual */ CommandCallback *GetDoCommandCallback();
- /* virtual */ void LoadDummyScript() {}
+ void RegisterAPI() override;
+ void Died() override;
+ CommandCallback *GetDoCommandCallback() override;
+ void LoadDummyScript() override {}
};
#endif /* GAME_INSTANCE_HPP */
diff --git a/src/game/game_scanner.hpp b/src/game/game_scanner.hpp
index 071d19d38d..492545c2b1 100644
--- a/src/game/game_scanner.hpp
+++ b/src/game/game_scanner.hpp
@@ -16,7 +16,7 @@
class GameScannerInfo : public ScriptScanner {
public:
- /* virtual */ void Initialize();
+ void Initialize() override;
/**
* Check if we have a game by name and version available in our list.
@@ -28,17 +28,17 @@ public:
class GameInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
protected:
- /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
- /* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
- /* virtual */ Subdirectory GetDirectory() const { return GAME_DIR; }
- /* virtual */ const char *GetScannerName() const { return "Game Scripts"; }
- /* virtual */ void RegisterAPI(class Squirrel *engine);
+ void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
+ const char *GetFileName() const override { return PATHSEP "info.nut"; }
+ Subdirectory GetDirectory() const override { return GAME_DIR; }
+ const char *GetScannerName() const override { return "Game Scripts"; }
+ void RegisterAPI(class Squirrel *engine) override;
};
class GameScannerLibrary : public ScriptScanner {
public:
- /* virtual */ void Initialize();
+ void Initialize() override;
/**
* Find a library in the pool.
@@ -49,11 +49,11 @@ public:
class GameLibrary *FindLibrary(const char *library, int version);
protected:
- /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
- /* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
- /* virtual */ Subdirectory GetDirectory() const { return GAME_LIBRARY_DIR; }
- /* virtual */ const char *GetScannerName() const { return "GS Libraries"; }
- /* virtual */ void RegisterAPI(class Squirrel *engine);
+ void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
+ const char *GetFileName() const override { return PATHSEP "library.nut"; }
+ Subdirectory GetDirectory() const override { return GAME_LIBRARY_DIR; }
+ const char *GetScannerName() const override { return "GS Libraries"; }
+ void RegisterAPI(class Squirrel *engine) override;
};
#endif /* GAME_SCANNER_HPP */
diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp
index a32e5b41d7..d57b2bc77f 100644
--- a/src/game/game_text.cpp
+++ b/src/game/game_text.cpp
@@ -115,7 +115,7 @@ LanguageStrings *ReadRawLanguageStrings(const char *file)
while (i > 0 && (buffer[i - 1] == '\r' || buffer[i - 1] == '\n' || buffer[i - 1] == ' ')) i--;
buffer[i] = '\0';
- *ret->lines.Append() = stredup(buffer, buffer + to_read - 1);
+ ret->lines.push_back(stredup(buffer, buffer + to_read - 1));
if (len > to_read) {
to_read = 0;
@@ -147,11 +147,11 @@ struct StringListReader : StringReader {
* @param translation Are we reading a translation?
*/
StringListReader(StringData &data, const LanguageStrings *strings, bool master, bool translation) :
- StringReader(data, strings->language, master, translation), p(strings->lines.Begin()), end(strings->lines.End())
+ StringReader(data, strings->language, master, translation), p(strings->lines.data()), end(p + strings->lines.size())
{
}
- /* virtual */ char *ReadLine(char *buffer, const char *last)
+ char *ReadLine(char *buffer, const char *last) override
{
if (this->p == this->end) return NULL;
@@ -194,7 +194,7 @@ struct TranslationWriter : LanguageWriter {
char *dest = MallocT(length + 1);
memcpy(dest, buffer, length);
dest[length] = '\0';
- *this->strings->Append() = dest;
+ this->strings->push_back(dest);
}
};
@@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter {
void WriteStringID(const char *name, int stringid)
{
- if (stringid == (int)this->strings->Length()) *this->strings->Append() = stredup(name);
+ if (stringid == (int)this->strings->size()) this->strings->push_back(stredup(name));
}
void Finalise(const StringData &data)
@@ -242,11 +242,11 @@ public:
this->FileScanner::Scan(".txt", directory, false);
}
- /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
+ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
{
if (strcmp(filename, exclude) == 0) return true;
- *gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
+ gs->raw_strings.push_back(ReadRawLanguageStrings(filename));
return true;
}
};
@@ -269,7 +269,7 @@ GameStrings *LoadTranslations()
GameStrings *gs = new GameStrings();
try {
- *gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
+ gs->raw_strings.push_back(ReadRawLanguageStrings(filename));
/* Scan for other language files */
LanguageScanner scanner(gs, filename);
@@ -318,14 +318,14 @@ void GameStrings::Compile()
StringNameWriter id_writer(&this->string_names);
id_writer.WriteHeader(data);
- for (LanguageStrings **p = this->raw_strings.Begin(); p != this->raw_strings.End(); p++) {
+ for (LanguageStrings *p : this->raw_strings) {
data.FreeTranslation();
- StringListReader translation_reader(data, *p, false, strcmp((*p)->language, "english") != 0);
+ StringListReader translation_reader(data, p, false, strcmp(p->language, "english") != 0);
translation_reader.ParseFile();
if (_errors != 0) throw std::exception();
- LanguageStrings *compiled = *this->compiled_strings.Append() = new LanguageStrings((*p)->language);
- TranslationWriter writer(&compiled->lines);
+ this->compiled_strings.push_back(new LanguageStrings(p->language));
+ TranslationWriter writer(&this->compiled_strings.back()->lines);
writer.WriteLang(data);
}
}
@@ -340,7 +340,7 @@ GameStrings *_current_data = NULL;
*/
const char *GetGameStringPtr(uint id)
{
- if (id >= _current_data->cur_language->lines.Length()) return GetStringPtr(STR_UNDEFINED);
+ if (id >= _current_data->cur_language->lines.size()) return GetStringPtr(STR_UNDEFINED);
return _current_data->cur_language->lines[id];
}
@@ -360,10 +360,11 @@ void RegisterGameTranslation(Squirrel *engine)
if (SQ_FAILED(sq_get(vm, -2))) return;
int idx = 0;
- for (const char * const *p = _current_data->string_names.Begin(); p != _current_data->string_names.End(); p++, idx++) {
- sq_pushstring(vm, *p, -1);
+ for (const char * const p : _current_data->string_names) {
+ sq_pushstring(vm, p, -1);
sq_pushinteger(vm, idx);
sq_rawset(vm, -3);
+ idx++;
}
sq_pop(vm, 2);
@@ -391,9 +392,9 @@ void ReconsiderGameScriptLanguage()
assert(language != NULL);
language++;
- for (LanguageStrings **p = _current_data->compiled_strings.Begin(); p != _current_data->compiled_strings.End(); p++) {
- if (strcmp((*p)->language, language) == 0) {
- _current_data->cur_language = *p;
+ for (LanguageStrings *p : _current_data->compiled_strings) {
+ if (strcmp(p->language, language) == 0) {
+ _current_data->cur_language = p;
return;
}
}
diff --git a/src/game/game_text.hpp b/src/game/game_text.hpp
index 14da7d9b2e..11c63b5abb 100644
--- a/src/game/game_text.hpp
+++ b/src/game/game_text.hpp
@@ -32,9 +32,9 @@ struct GameStrings {
uint version; ///< The version of the language strings.
LanguageStrings *cur_language; ///< The current (compiled) language.
- AutoDeleteSmallVector raw_strings; ///< The raw strings per language, first must be English/the master language!.
- AutoDeleteSmallVector compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
- StringList string_names; ///< The names of the compiled strings.
+ AutoDeleteSmallVector raw_strings; ///< The raw strings per language, first must be English/the master language!.
+ AutoDeleteSmallVector compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
+ StringList string_names; ///< The names of the compiled strings.
void Compile();
};
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 29910d7ad1..1698dadad8 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -178,6 +178,7 @@ struct GRFPresence{
bool was_missing; ///< Grf was missing during some gameload in the past
GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {}
+ GRFPresence() = default;
};
typedef SmallMap GrfIDMapping;
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 25d6a7bd9d..ee8768b62a 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -34,6 +34,7 @@
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "string_func.h"
+#include "thread.h"
#include "safeguards.h"
@@ -93,14 +94,15 @@ static void CleanupGeneration()
/**
* The internal, real, generate function.
*/
-static void _GenerateWorld(void *)
+static void _GenerateWorld()
{
/* Make sure everything is done via OWNER_NONE. */
Backup _cur_company(_current_company, OWNER_NONE, FILE_LINE);
+ std::unique_lock lock(_modal_progress_work_mutex, std::defer_lock);
try {
_generating_world = true;
- _modal_progress_work_mutex->BeginCritical();
+ lock.lock();
if (_network_dedicated) DEBUG(net, 1, "Generating map, please wait...");
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
@@ -194,7 +196,7 @@ static void _GenerateWorld(void *)
IncreaseGeneratingWorldProgress(GWP_GAME_START);
CleanupGeneration();
- _modal_progress_work_mutex->EndCritical();
+ lock.unlock();
ShowNewGRFError();
@@ -210,7 +212,6 @@ static void _GenerateWorld(void *)
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true);
if (_cur_company.IsValid()) _cur_company.Restore();
_generating_world = false;
- _modal_progress_work_mutex->EndCritical();
throw;
}
}
@@ -241,17 +242,15 @@ void GenerateWorldSetAbortCallback(GWAbortProc *proc)
*/
void WaitTillGeneratedWorld()
{
- if (_gw.thread == NULL) return;
+ if (!_gw.thread.joinable()) return;
- _modal_progress_work_mutex->EndCritical();
- _modal_progress_paint_mutex->EndCritical();
+ _modal_progress_work_mutex.unlock();
+ _modal_progress_paint_mutex.unlock();
_gw.quit_thread = true;
- _gw.thread->Join();
- delete _gw.thread;
- _gw.thread = NULL;
+ _gw.thread.join();
_gw.threaded = false;
- _modal_progress_work_mutex->BeginCritical();
- _modal_progress_paint_mutex->BeginCritical();
+ _modal_progress_work_mutex.lock();
+ _modal_progress_paint_mutex.lock();
}
/**
@@ -283,7 +282,7 @@ void HandleGeneratingWorldAbortion()
CleanupGeneration();
- if (_gw.thread != NULL) _gw.thread->Exit();
+ if (_gw.thread.joinable() && _gw.thread.get_id() == std::this_thread::get_id()) throw OTTDThreadExitSignal();
SwitchToMode(_switch_mode);
}
@@ -325,18 +324,14 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
SetupColoursAndInitialWindow();
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
- if (_gw.thread != NULL) {
- _gw.thread->Join();
- delete _gw.thread;
- _gw.thread = NULL;
- }
+ if (_gw.thread.joinable()) _gw.thread.join();
- if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread, "ottd:genworld")) {
+ if (!UseThreadedModelProgress() || !VideoDriver::GetInstance()->HasGUI() || !StartNewThread(&_gw.thread, "ottd:genworld", &_GenerateWorld)) {
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
_gw.threaded = false;
- _modal_progress_work_mutex->EndCritical();
- _GenerateWorld(NULL);
- _modal_progress_work_mutex->BeginCritical();
+ _modal_progress_work_mutex.unlock();
+ _GenerateWorld();
+ _modal_progress_work_mutex.lock();
return;
}
diff --git a/src/genworld.h b/src/genworld.h
index 1b1c806e09..ce6b39bd99 100644
--- a/src/genworld.h
+++ b/src/genworld.h
@@ -13,6 +13,7 @@
#define GENWORLD_H
#include "company_type.h"
+#include
/** Constants related to world generation */
enum LandscapeGenerator {
@@ -61,7 +62,7 @@ struct GenWorldInfo {
uint size_y; ///< Y-size of the map
GWDoneProc *proc; ///< Proc that is called when done (can be NULL)
GWAbortProc *abortp; ///< Proc that is called when aborting (can be NULL)
- class ThreadObject *thread; ///< The thread we are in (can be NULL)
+ std::thread thread; ///< The thread we are in (joinable if a thread was created)
};
/** Current stage of world generation process */
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index b22ba5287e..697ce382d7 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -289,7 +289,7 @@ static DropDownList *BuildMapsizeDropDown()
for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
item->SetParam(0, 1LL << i);
- *list->Append() = item;
+ list->push_back(item);
}
return list;
@@ -332,7 +332,7 @@ struct GenerateLandscapeWindow : public Window {
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break;
@@ -393,7 +393,7 @@ struct GenerateLandscapeWindow : public Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
+ void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
/* Update the climate buttons */
@@ -440,7 +440,7 @@ struct GenerateLandscapeWindow : public Window {
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
const StringID *strs = NULL;
switch (widget) {
@@ -518,7 +518,7 @@ struct GenerateLandscapeWindow : public Window {
size->height = max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM));
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_GL_HEIGHTMAP_NAME_TEXT: {
@@ -528,7 +528,7 @@ struct GenerateLandscapeWindow : public Window {
}
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_GL_TEMPERATE:
@@ -703,7 +703,7 @@ struct GenerateLandscapeWindow : public Window {
}
}
- virtual void OnTimeout()
+ void OnTimeout() override
{
static const int raise_widgets[] = {WID_GL_MAX_HEIGHTLEVEL_DOWN, WID_GL_MAX_HEIGHTLEVEL_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_LEVEL_UP, WID_GL_SNOW_LEVEL_DOWN, WIDGET_LIST_END};
for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
@@ -714,7 +714,7 @@ struct GenerateLandscapeWindow : public Window {
}
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_GL_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
@@ -758,7 +758,7 @@ struct GenerateLandscapeWindow : public Window {
this->InvalidateData();
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
/* Was 'cancel' pressed? */
if (str == NULL) return;
@@ -888,7 +888,7 @@ struct CreateScenarioWindow : public Window
this->LowerWidget(_settings_newgame.game_creation.landscape + WID_CS_TEMPERATE);
}
- virtual void SetStringParameters(int widget) const
+ void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_CS_START_DATE_TEXT:
@@ -909,7 +909,7 @@ struct CreateScenarioWindow : public Window
}
}
- virtual void OnPaint()
+ void OnPaint() override
{
this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
this->SetWidgetDisabledState(WID_CS_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
@@ -924,7 +924,7 @@ struct CreateScenarioWindow : public Window
this->DrawWidgets();
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
StringID str = STR_JUST_INT;
switch (widget) {
@@ -950,7 +950,7 @@ struct CreateScenarioWindow : public Window
size->height += padding.height;
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_CS_TEMPERATE:
@@ -1015,7 +1015,7 @@ struct CreateScenarioWindow : public Window
}
}
- virtual void OnTimeout()
+ void OnTimeout() override
{
static const int raise_widgets[] = {WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP, WIDGET_LIST_END};
for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
@@ -1026,7 +1026,7 @@ struct CreateScenarioWindow : public Window
}
}
- virtual void OnDropdownSelect(int widget, int index)
+ void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
@@ -1035,7 +1035,7 @@ struct CreateScenarioWindow : public Window
this->SetDirty();
}
- virtual void OnQueryTextFinished(char *str)
+ void OnQueryTextFinished(char *str) override
{
if (!StrEmpty(str)) {
int32 value = atoi(str);
@@ -1187,7 +1187,7 @@ struct GenerateProgressWindow : public Window {
this->InitNested();
}
- virtual void OnClick(Point pt, int widget, int click_count)
+ void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_GP_ABORT:
@@ -1202,7 +1202,7 @@ struct GenerateProgressWindow : public Window {
}
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_GP_PROGRESS_BAR: {
@@ -1223,7 +1223,7 @@ struct GenerateProgressWindow : public Window {
}
}
- virtual void DrawWidget(const Rect &r, int widget) const
+ void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_GP_PROGRESS_BAR:
@@ -1321,10 +1321,10 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
* paint thread. The 'other' thread already has the paint thread rights so
* this ensures us that we are waiting until the paint thread is done
* before we reacquire the mapgen rights */
- _modal_progress_work_mutex->EndCritical();
- _modal_progress_paint_mutex->BeginCritical();
- _modal_progress_work_mutex->BeginCritical();
- _modal_progress_paint_mutex->EndCritical();
+ _modal_progress_work_mutex.unlock();
+ _modal_progress_paint_mutex.lock();
+ _modal_progress_work_mutex.lock();
+ _modal_progress_paint_mutex.unlock();
_gws.timer = _realtime_tick;
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 85cd3bfb59..f1b91c16eb 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -21,6 +21,7 @@
#include "network/network_func.h"
#include "window_func.h"
#include "newgrf_debug.h"
+#include "thread.h"
#include "table/palettes.h"
#include "table/string_colours.h"
@@ -58,6 +59,7 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
static ReusableBuffer _cursor_backup;
ZoomLevelByte _gui_zoom; ///< GUI Zoom level
+ZoomLevelByte _font_zoom; ///< Font Zoom level
/**
* The rect for repaint.
@@ -85,9 +87,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
if (_cursor.visible) UndrawMouseCursor();
-#ifdef ENABLE_NETWORK
if (_networking) NetworkUndrawChatMessage();
-#endif /* ENABLE_NETWORK */
blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
/* This part of the screen is now dirty. */
@@ -510,9 +510,9 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
}
Layouter layout(str, INT32_MAX, colour, fontsize);
- if (layout.Length() == 0) return 0;
+ if (layout.size() == 0) return 0;
- return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true);
+ return DrawLayoutLine(layout.front(), top, left, right, align, underline, true);
}
/**
@@ -575,7 +575,7 @@ int GetStringLineCount(StringID str, int maxw)
GetString(buffer, str, lastof(buffer));
Layouter layout(buffer, maxw);
- return layout.Length();
+ return (uint)layout.size();
}
/**
@@ -648,8 +648,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st
int last_line = top;
int first_line = bottom;
- for (const ParagraphLayouter::Line **iter = layout.Begin(); iter != layout.End(); iter++) {
- const ParagraphLayouter::Line *line = *iter;
+ for (const ParagraphLayouter::Line *line : layout) {
int line_height = line->GetLeading();
if (y >= top && y < bottom) {
@@ -969,7 +968,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo
if (topleft <= clicked && clicked <= bottomright) {
uint offset = (((size_t)clicked - (size_t)topleft) / (blitter->GetScreenDepth() / 8)) % bp.pitch;
if (offset < (uint)bp.width) {
- _newgrf_debug_sprite_picker.sprites.Include(sprite_id);
+ include(_newgrf_debug_sprite_picker.sprites, sprite_id);
}
}
}
@@ -1130,13 +1129,14 @@ TextColour GetContrastColour(uint8 background, uint8 threshold)
*/
void LoadStringWidthTable(bool monospace)
{
+ ClearFontCache();
+
for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) {
for (uint i = 0; i != 224; i++) {
_stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32);
}
}
- ClearFontCache();
ReInitAllWindows();
}
@@ -1286,9 +1286,7 @@ void RedrawScreenRect(int left, int top, int right, int bottom)
}
}
-#ifdef ENABLE_NETWORK
if (_networking) NetworkUndrawChatMessage();
-#endif /* ENABLE_NETWORK */
DrawOverlappedWindowForAll(left, top, right, bottom);
@@ -1311,8 +1309,8 @@ void DrawDirtyBlocks()
if (HasModalProgress()) {
/* We are generating the world, so release our rights to the map and
* painting while we are waiting a bit. */
- _modal_progress_paint_mutex->EndCritical();
- _modal_progress_work_mutex->EndCritical();
+ _modal_progress_paint_mutex.unlock();
+ _modal_progress_work_mutex.unlock();
/* Wait a while and update _realtime_tick so we are given the rights */
if (!IsFirstModalProgressLoop()) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
@@ -1320,9 +1318,9 @@ void DrawDirtyBlocks()
/* Modal progress thread may need blitter access while we are waiting for it. */
VideoDriver::GetInstance()->ReleaseBlitterLock();
- _modal_progress_paint_mutex->BeginCritical();
+ _modal_progress_paint_mutex.lock();
VideoDriver::GetInstance()->AcquireBlitterLock();
- _modal_progress_work_mutex->BeginCritical();
+ _modal_progress_work_mutex.lock();
/* When we ended with the modal progress, do not draw the blocks.
* Simply let the next run do so, otherwise we would be loading
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 9f7cb9153d..2abbcd2a87 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -75,7 +75,6 @@ void HandleKeypress(uint keycode, WChar key);
void HandleTextInput(const char *str, bool marked = false, const char *caret = NULL, const char *insert_location = NULL, const char *replacement_end = NULL);
void HandleCtrlChanged();
void HandleMouseEvents();
-void CSleep(int milliseconds);
void UpdateWindows();
void DrawMouseCursor();
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index c65ead90e1..124f1218a2 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -17,9 +17,9 @@
#include "table/control_codes.h"
-#ifdef WITH_ICU_LAYOUT
+#ifdef WITH_ICU_LX
#include
-#endif /* WITH_ICU_LAYOUT */
+#endif /* WITH_ICU_LX */
#ifdef WITH_UNISCRIBE
#include "os/windows/string_uniscribe.h"
@@ -50,7 +50,7 @@ Font::Font(FontSize size, TextColour colour) :
assert(size < FS_END);
}
-#ifdef WITH_ICU_LAYOUT
+#ifdef WITH_ICU_LX
/* Implementation details of LEFontInstance */
le_int32 Font::getUnitsPerEM() const
@@ -124,7 +124,7 @@ le_bool Font::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &poin
/**
* Wrapper for doing layouts with ICU.
*/
-class ICUParagraphLayout : public AutoDeleteSmallVector, public ParagraphLayouter {
+class ICUParagraphLayout : public AutoDeleteSmallVector, public ParagraphLayouter {
icu::ParagraphLayout *p; ///< The actual ICU paragraph layout.
public:
/** Visual run contains data about the bit of text with the same font. */
@@ -143,14 +143,14 @@ public:
};
/** A single line worth of VisualRuns. */
- class ICULine : public AutoDeleteSmallVector, public ParagraphLayouter::Line {
+ class ICULine : public AutoDeleteSmallVector, public ParagraphLayouter::Line {
icu::ParagraphLayout::Line *l; ///< The actual ICU line.
public:
ICULine(icu::ParagraphLayout::Line *l) : l(l)
{
for (int i = 0; i < l->countRuns(); i++) {
- *this->Append() = new ICUVisualRun(l->getVisualRun(i));
+ this->push_back(new ICUVisualRun(l->getVisualRun(i)));
}
}
~ICULine() { delete l; }
@@ -158,7 +158,7 @@ public:
int GetLeading() const { return l->getLeading(); }
int GetWidth() const { return l->getWidth(); }
int CountRuns() const { return l->countRuns(); }
- const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
+ const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return this->at(run); }
int GetInternalCharLength(WChar c) const
{
@@ -196,13 +196,13 @@ public:
/* ICU's ParagraphLayout cannot handle empty strings, so fake one. */
buff[0] = ' ';
length = 1;
- fontMapping.End()[-1].first++;
+ fontMapping.back().first++;
}
/* Fill ICU's FontRuns with the right data. */
- icu::FontRuns runs(fontMapping.Length());
- for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) {
- runs.add(iter->second, iter->first);
+ icu::FontRuns runs(fontMapping.size());
+ for (auto &pair : fontMapping) {
+ runs.add(pair.second, pair.first);
}
LEErrorCode status = LE_NO_ERROR;
@@ -226,7 +226,7 @@ public:
return length;
}
};
-#endif /* WITH_ICU_LAYOUT */
+#endif /* WITH_ICU_LX */
/*** Paragraph layout ***/
/**
@@ -269,7 +269,7 @@ public:
};
/** A single line worth of VisualRuns. */
- class FallbackLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line {
+ class FallbackLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line {
public:
int GetLeading() const;
int GetWidth() const;
@@ -419,8 +419,8 @@ int FallbackParagraphLayout::FallbackVisualRun::GetLeading() const
int FallbackParagraphLayout::FallbackLine::GetLeading() const
{
int leading = 0;
- for (const FallbackVisualRun * const *run = this->Begin(); run != this->End(); run++) {
- leading = max(leading, (*run)->GetLeading());
+ for (const FallbackVisualRun * const &run : *this) {
+ leading = max(leading, run->GetLeading());
}
return leading;
@@ -432,7 +432,7 @@ int FallbackParagraphLayout::FallbackLine::GetLeading() const
*/
int FallbackParagraphLayout::FallbackLine::GetWidth() const
{
- if (this->Length() == 0) return 0;
+ if (this->size() == 0) return 0;
/*
* The last X position of a run contains is the end of that run.
@@ -449,7 +449,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const
*/
int FallbackParagraphLayout::FallbackLine::CountRuns() const
{
- return this->Length();
+ return (uint)this->size();
}
/**
@@ -458,7 +458,7 @@ int FallbackParagraphLayout::FallbackLine::CountRuns() const
*/
const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const
{
- return *this->Get(run);
+ return this->at(run);
}
/**
@@ -498,12 +498,12 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
if (*this->buffer == '\0') {
/* Only a newline. */
this->buffer = NULL;
- *l->Append() = new FallbackVisualRun(this->runs.Begin()->second, this->buffer, 0, 0);
+ l->push_back(new FallbackVisualRun(this->runs.front().second, this->buffer, 0, 0));
return l;
}
int offset = this->buffer - this->buffer_begin;
- FontMap::iterator iter = this->runs.Begin();
+ FontMap::iterator iter = this->runs.data();
while (iter->first <= offset) {
iter++;
assert(iter != this->runs.End());
@@ -527,7 +527,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
if (this->buffer == next_run) {
int w = l->GetWidth();
- *l->Append() = new FallbackVisualRun(iter->second, begin, this->buffer - begin, w);
+ l->push_back(new FallbackVisualRun(iter->second, begin, this->buffer - begin, w));
iter++;
assert(iter != this->runs.End());
@@ -572,9 +572,9 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
this->buffer++;
}
- if (l->Length() == 0 || last_char - begin != 0) {
+ if (l->size() == 0 || last_char - begin != 0) {
int w = l->GetWidth();
- *l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
+ l->push_back(new FallbackVisualRun(iter->second, begin, last_char - begin, w));
}
return l;
}
@@ -600,7 +600,7 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str,
Font *f = Layouter::GetFont(state.fontsize, state.cur_colour);
line.buffer = buff_begin;
- fontMapping.Clear();
+ fontMapping.clear();
/*
* Go through the whole string while adding Font instances to the font map
@@ -674,11 +674,11 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
} else {
/* Line is new, layout it */
FontState old_state = state;
-#if defined(WITH_ICU_LAYOUT) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
+#if defined(WITH_ICU_LX) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
const char *old_str = str;
#endif
-#ifdef WITH_ICU_LAYOUT
+#ifdef WITH_ICU_LX
GetLayouter(line, str, state);
if (line.layout == NULL) {
static bool warned = false;
@@ -720,7 +720,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
/* Copy all lines into a local cache so we can reuse them later on more easily. */
const ParagraphLayouter::Line *l;
while ((l = line.layout->NextLine(maxw)) != NULL) {
- *this->Append() = l;
+ this->push_back(l);
}
} while (c != '\0');
@@ -733,9 +733,9 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
Dimension Layouter::GetBounds()
{
Dimension d = { 0, 0 };
- for (const ParagraphLayouter::Line **l = this->Begin(); l != this->End(); l++) {
- d.width = max(d.width, (*l)->GetWidth());
- d.height += (*l)->GetLeading();
+ for (const ParagraphLayouter::Line *l : *this) {
+ d.width = max(d.width, l->GetWidth());
+ d.height += l->GetLeading();
}
return d;
}
@@ -757,12 +757,12 @@ Point Layouter::GetCharPosition(const char *ch) const
size_t len = Utf8Decode(&c, str);
if (c == '\0' || c == '\n') break;
str += len;
- index += (*this->Begin())->GetInternalCharLength(c);
+ index += this->front()->GetInternalCharLength(c);
}
if (str == ch) {
/* Valid character. */
- const ParagraphLayouter::Line *line = *this->Begin();
+ const ParagraphLayouter::Line *line = this->front();
/* Pointer to the end-of-string/line marker? Return total line width. */
if (*ch == '\0' || *ch == '\n') {
@@ -795,7 +795,7 @@ Point Layouter::GetCharPosition(const char *ch) const
*/
const char *Layouter::GetCharAtPosition(int x) const
{
- const ParagraphLayouter::Line *line = *this->Begin();
+ const ParagraphLayouter::Line *line = this->front();
for (int run_index = 0; run_index < line->CountRuns(); run_index++) {
const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index);
@@ -834,7 +834,7 @@ Font *Layouter::GetFont(FontSize size, TextColour colour)
if (it != fonts[size].End()) return it->second;
Font *f = new Font(size, colour);
- *fonts[size].Append() = FontColourMap::Pair(colour, f);
+ fonts[size].emplace_back(colour, f);
return f;
}
@@ -844,10 +844,10 @@ Font *Layouter::GetFont(FontSize size, TextColour colour)
*/
void Layouter::ResetFontCache(FontSize size)
{
- for (FontColourMap::iterator it = fonts[size].Begin(); it != fonts[size].End(); ++it) {
- delete it->second;
+ for (auto &pair : fonts[size]) {
+ delete pair.second;
}
- fonts[size].Clear();
+ fonts[size].clear();
/* We must reset the linecache since it references the just freed fonts */
ResetLineCache();
diff --git a/src/gfx_layout.h b/src/gfx_layout.h
index f6fc3b5c71..93cc6fb2da 100644
--- a/src/gfx_layout.h
+++ b/src/gfx_layout.h
@@ -19,13 +19,14 @@
#include |