Merge branch 'master' into jgrpp
Replace build and refit, and group collapse implementations Fix template creation build and refit # Conflicts: # Makefile.bundle.in # config.lib # src/animated_tile.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.hpp # src/blitter/null.hpp # src/build_vehicle_gui.cpp # src/command.cpp # src/command_func.h # src/console_gui.cpp # src/core/smallstack_type.hpp # src/date.cpp # src/debug.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.h # src/main_gui.cpp # src/misc_gui.cpp # src/network/core/game.h # src/network/core/packet.cpp # src/network/core/udp.cpp # src/network/core/udp.h # src/network/network_content.cpp # src/network/network_type.h # src/network/network_udp.cpp # src/newgrf_house.h # src/openttd.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/osk_gui.cpp # src/pathfinder/opf/opf_ship.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.h # src/station_base.h # src/station_cmd.cpp # src/table/gameopt_settings.ini # src/table/newgrf_debug_data.h # src/table/settings.ini # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_gui.h
This commit is contained in:
3
Doxyfile
3
Doxyfile
@@ -289,8 +289,7 @@ EXPAND_ONLY_PREDEF = YES
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = ENABLE_NETWORK \
|
||||
WITH_ZLIB \
|
||||
PREDEFINED = WITH_ZLIB \
|
||||
WITH_LZO \
|
||||
WITH_LIBLZMA \
|
||||
WITH_SDL \
|
||||
|
@@ -98,12 +98,6 @@ ifdef MENU_DIR
|
||||
endif
|
||||
ifeq ($(TTD), openttd.exe)
|
||||
$(Q)unix2dos "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/COPYING" "$(BUNDLE_DIR)/changelog.txt" "$(BUNDLE_DIR)/known-bugs.txt" "$(BUNDLE_DIR)/"*.md
|
||||
ifeq ($(OS), DOS)
|
||||
$(Q)cp "$(ROOT_DIR)/os/dos/cwsdpmi/cwsdpmi.txt" "$(BUNDLE_DIR)/docs/"
|
||||
ifndef STRIP
|
||||
$(Q)cp "$(ROOT_DIR)/os/dos/cwsdpmi/cwsdpmi.exe" "$(TTD_DIR)/"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
### Packing the current bundle into several compressed file formats ###
|
||||
|
@@ -274,10 +274,6 @@ $(TTD): $(OBJS) $(CONFIG_CACHE_LINKER)
|
||||
ifdef STRIP
|
||||
$(Q)$(STRIP) $@
|
||||
endif
|
||||
ifeq ($(OS), DOS)
|
||||
$(E) '$(STAGE) Adding CWSDPMI stub to $@'
|
||||
$(Q)$(ROOT_DIR)/os/dos/make_dos_binary_selfcontained.sh $(SRC_OBJS_DIR)/$@
|
||||
endif
|
||||
|
||||
# Revision files
|
||||
|
||||
|
22
README.md
22
README.md
@@ -438,7 +438,6 @@ OpenTTD has been ported to several platforms and operating systems. It should
|
||||
not be very difficult to port it to a new platform. The currently working
|
||||
platforms are:
|
||||
|
||||
- DOS (Allegro)
|
||||
- FreeBSD (SDL)
|
||||
- Haiku (SDL)
|
||||
- Linux (SDL or Allegro)
|
||||
@@ -841,17 +840,6 @@ Use '`make`', but do a '`./configure`' before the first build.
|
||||
A comprehensive GNU build environment is required to build the OS/2 version.
|
||||
See the docs/Readme_OS2.txt file for more information.
|
||||
|
||||
### DOS:
|
||||
|
||||
A build environment with DJGPP is needed as well as libraries such as
|
||||
Allegro, zlib and libpng, which all can be downloaded from the DJGPP
|
||||
website. Compilation is straight forward: use '`make`', but do a '`./configure`'
|
||||
before the first build. The build binary will need cwsdpmi.exe to be in
|
||||
the same directory as the openttd executable. cwsdpmi.exe can be found in
|
||||
the os/dos/cwsdpmi subdirectory. If you compile with stripping turned on a
|
||||
binary will be generated that does not need cwsdpmi.exe by adding the
|
||||
cswdstub.exe to the created OpenTTD binary.
|
||||
|
||||
### 7.1) Required/optional libraries
|
||||
|
||||
The following libraries are used by OpenTTD for:
|
||||
@@ -1038,16 +1026,6 @@ License 2.1, and partly under the (3-clause) BSD license. The exact licensing
|
||||
terms can be found in src/3rdparty/os2/getaddrinfo.c resp.
|
||||
src/3rdparty/os2/getnameinfo.c.
|
||||
|
||||
The exe2coff implementation in os/dos/exe2coff is available under the
|
||||
GPL, with a number of additional terms. See os/dos/exe2coff/copying and
|
||||
os/dos/exe2coff/copying.dj for the exact licensing terms.
|
||||
|
||||
The CWSDPMI implementation in os/dos/cwsdpmi is distributed under a
|
||||
custom binary-only license that prohibits modification. The exact
|
||||
licensing terms can be found in os/dos/cwsdpmi/cwsdpmi.txt. The sources
|
||||
for these files can be downloaded at its author site, at
|
||||
http://homer.rice.edu/~sandmann/cwsdpmi/csdpmi5s.zip.
|
||||
|
||||
CONTRIBUTING.md is adapted from
|
||||
[Bootstrap](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md)
|
||||
under the [Creative Commons Attribution 3.0 Unported
|
||||
|
@@ -1,10 +1,14 @@
|
||||
steps:
|
||||
- bash: |
|
||||
set -ex
|
||||
|
||||
curl -L https://github.com/OpenTTD/CompileFarm/releases/download/latest/windows-dependencies.zip > windows-dependencies.zip
|
||||
unzip windows-dependencies.zip
|
||||
rm -f windows-dependencies.zip
|
||||
displayName: 'Download dependencies'
|
||||
workingDirectory: $(Build.ArtifactStagingDirectory)
|
||||
- script: $(Build.ArtifactStagingDirectory)\windows-dependencies\vcpkg.exe integrate install
|
||||
|
||||
mv windows-dependencies/installed /c/vcpkg/
|
||||
rm -rf windows-dependencies
|
||||
displayName: 'Install dependencies'
|
||||
workingDirectory: $(Build.ArtifactStagingDirectory)
|
||||
- script: c:\vcpkg\vcpkg.exe integrate install
|
||||
displayName: 'Integrate vcpkg'
|
||||
|
@@ -1704,6 +1704,19 @@ function Regression::Vehicle()
|
||||
print(" GetWagonEngineType(): " + AIVehicle.GetWagonEngineType(17 3));
|
||||
print(" GetWagonAge(): " + AIVehicle.GetWagonAge(17, 3));
|
||||
|
||||
print(" --Refit--");
|
||||
print(" GetBuildWithRefitCapacity(): " + AIVehicle.GetBuildWithRefitCapacity(28479, 211, 255));
|
||||
print(" GetBuildWithRefitCapacity(): " + AIVehicle.GetBuildWithRefitCapacity(28479, 211, 0));
|
||||
print(" GetBuildWithRefitCapacity(): " + AIVehicle.GetBuildWithRefitCapacity(28479, 211, 9));
|
||||
print(" BuildVehicleWithRefit(): " + AIVehicle.BuildVehicleWithRefit(28479, 211, 9));
|
||||
print(" GetCapacity(): " + AIVehicle.GetCapacity(20, 9));
|
||||
print(" GetCapacity(): " + AIVehicle.GetCapacity(20, 5));
|
||||
print(" GetRefitCapacity(): " + AIVehicle.GetRefitCapacity(20, 5));
|
||||
print(" RefitVehicle(): " + AIVehicle.RefitVehicle(20, 5));
|
||||
print(" GetCapacity(): " + AIVehicle.GetCapacity(20, 9));
|
||||
print(" GetCapacity(): " + AIVehicle.GetCapacity(20, 5));
|
||||
print(" SellVehicle(): " + AIVehicle.SellVehicle(20));
|
||||
|
||||
print(" --Errors--");
|
||||
print(" RefitVehicle(): " + AIVehicle.RefitVehicle(12, 0));
|
||||
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
|
||||
|
@@ -9128,6 +9128,18 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
GetWagonAge(): 0
|
||||
GetWagonEngineType(): 65535
|
||||
GetWagonAge(): -1
|
||||
--Refit--
|
||||
GetBuildWithRefitCapacity(): -1
|
||||
GetBuildWithRefitCapacity(): 0
|
||||
GetBuildWithRefitCapacity(): 160
|
||||
BuildVehicleWithRefit(): 20
|
||||
GetCapacity(): 160
|
||||
GetCapacity(): 0
|
||||
GetRefitCapacity(): 160
|
||||
RefitVehicle(): true
|
||||
GetCapacity(): 0
|
||||
GetCapacity(): 160
|
||||
SellVehicle(): true
|
||||
--Errors--
|
||||
RefitVehicle(): false
|
||||
GetLastErrorString(): ERR_VEHICLE_NOT_IN_DEPOT
|
||||
@@ -9175,7 +9187,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
13 => 5489
|
||||
12 => 5489
|
||||
CurrentSpeed ListDump:
|
||||
12 => 21
|
||||
12 => 27
|
||||
17 => 0
|
||||
16 => 0
|
||||
14 => 0
|
||||
|
68
config.lib
68
config.lib
@@ -52,7 +52,6 @@ set_default() {
|
||||
enable_profiling="0"
|
||||
enable_lto="0"
|
||||
enable_dedicated="0"
|
||||
enable_network="1"
|
||||
enable_static="1"
|
||||
enable_translator="0"
|
||||
enable_unicode="1"
|
||||
@@ -133,7 +132,6 @@ set_default() {
|
||||
enable_profiling
|
||||
enable_lto
|
||||
enable_dedicated
|
||||
enable_network
|
||||
enable_static
|
||||
enable_translator
|
||||
enable_unicode
|
||||
@@ -295,9 +293,6 @@ detect_params() {
|
||||
--enable-ipo=*) enable_lto="$optarg";;
|
||||
--enable-dedicated) enable_dedicated="1";;
|
||||
--enable-dedicated=*) enable_dedicated="$optarg";;
|
||||
--enable-network) enable_network="2";;
|
||||
--enable-network=*) enable_network="$optarg";;
|
||||
--disable-network) enable_network="0";;
|
||||
--disable-static) enable_static="0";;
|
||||
--enable-static) enable_static="2";;
|
||||
--enable-static=*) enable_static="$optarg";;
|
||||
@@ -577,10 +572,10 @@ check_params() {
|
||||
|
||||
# Check if all params have valid values
|
||||
|
||||
# OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HAIKU, SUNOS, CYGWIN, MINGW, OS2, and DOS
|
||||
if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS)$'`" ]; then
|
||||
# OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HAIKU, SUNOS, CYGWIN, MINGW, and OS2
|
||||
if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2)$'`" ]; then
|
||||
log 1 "configure: error: invalid option --os=$os"
|
||||
log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS]"
|
||||
log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2]"
|
||||
exit 1
|
||||
fi
|
||||
# cpu_type can be either 32 or 64
|
||||
@@ -647,7 +642,7 @@ check_params() {
|
||||
detect_sse_capable_architecture
|
||||
|
||||
if [ "$enable_static" = "1" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
|
||||
enable_static="2"
|
||||
else
|
||||
enable_static="0"
|
||||
@@ -657,8 +652,8 @@ check_params() {
|
||||
if [ "$enable_static" != "0" ]; then
|
||||
log 1 "checking static... yes"
|
||||
|
||||
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ]; then
|
||||
log 1 "WARNING: static is only known to work on Windows, DOS, and MacOSX"
|
||||
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ]; then
|
||||
log 1 "WARNING: static is only known to work on Windows, and MacOSX"
|
||||
log 1 "WARNING: use static at your own risk on this platform"
|
||||
|
||||
sleep 5
|
||||
@@ -668,7 +663,7 @@ check_params() {
|
||||
fi
|
||||
|
||||
if [ "$enable_unicode" = "1" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
|
||||
enable_unicode="2"
|
||||
else
|
||||
enable_unicode="0"
|
||||
@@ -773,11 +768,6 @@ check_params() {
|
||||
if [ "$enable_dedicated" != "0" ]; then
|
||||
log 1 "checking GDI video driver... dedicated server, skipping"
|
||||
log 1 "checking dedicated... found"
|
||||
|
||||
if [ "$enable_network" = "0" ]; then
|
||||
log 1 "configure: error: building a dedicated server without network support is pointless"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
|
||||
log 1 "checking GDI video driver... found"
|
||||
@@ -808,15 +798,6 @@ check_params() {
|
||||
log 1 "checking console application... enabled"
|
||||
fi
|
||||
|
||||
if [ "$enable_network" = "1" ] && [ "$os" = "DOS" ]; then
|
||||
log 1 "checking network... DOS, skipping"
|
||||
enable_network=0
|
||||
elif [ "$enable_network" != "0" ]; then
|
||||
log 1 "checking network... found"
|
||||
else
|
||||
log 1 "checking network... disabled"
|
||||
fi
|
||||
|
||||
log 1 "checking squirrel... found"
|
||||
SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
|
||||
|
||||
@@ -1047,10 +1028,6 @@ check_params() {
|
||||
grfcodec=""
|
||||
fi
|
||||
|
||||
if [ "$os" = "DOS" ]; then
|
||||
with_threads="0"
|
||||
fi
|
||||
|
||||
if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
|
||||
if [ "$with_application_bundle" = "1" ]; then
|
||||
with_application_bundle="0"
|
||||
@@ -1155,7 +1132,7 @@ check_params() {
|
||||
fi
|
||||
|
||||
if [ "$personal_dir" = "1" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ] || [ "$os" = "HAIKU" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "HAIKU" ]; then
|
||||
personal_dir="OpenTTD"
|
||||
elif [ "$os" = "OSX" ]; then
|
||||
personal_dir="Documents/OpenTTD"
|
||||
@@ -1377,6 +1354,9 @@ make_compiler_cflags() {
|
||||
# it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
|
||||
flags="$flags -Wno-self-assign"
|
||||
|
||||
# warning: <something> 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"
|
||||
@@ -1688,7 +1668,7 @@ make_cflags_and_ldflags() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$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" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
|
||||
@@ -1915,7 +1895,7 @@ EOL
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ]; then
|
||||
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ]; then
|
||||
LIBS="$LIBS -lc"
|
||||
fi
|
||||
|
||||
@@ -2148,16 +2128,12 @@ EOL
|
||||
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
|
||||
fi
|
||||
|
||||
if [ "$enable_network" != "0" ]; then
|
||||
CFLAGS="$CFLAGS -DENABLE_NETWORK"
|
||||
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
|
||||
@@ -2647,7 +2623,7 @@ detect_awk() {
|
||||
|
||||
detect_os() {
|
||||
if [ "$os" = "DETECT" ]; then
|
||||
# Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, 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 '
|
||||
@@ -2664,7 +2640,6 @@ detect_os() {
|
||||
/cygwin/ { print "CYGWIN"; exit}
|
||||
/mingw/ { print "MINGW"; exit}
|
||||
/os2/ { print "OS2"; exit}
|
||||
/dos/ { print "DOS"; exit}
|
||||
'`
|
||||
|
||||
if [ -z "$os" ]; then
|
||||
@@ -2688,7 +2663,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, HPUX, 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
|
||||
|
||||
@@ -3798,7 +3773,7 @@ showhelp() {
|
||||
echo " --os=OS the OS we are compiling for [DETECT]"
|
||||
echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/"
|
||||
echo " NETBSD/HPUX/SUNOS/CYGWIN/"
|
||||
echo " MINGW/OS2/DOS/HAIKU"
|
||||
echo " MINGW/OS2/HAIKU"
|
||||
echo ""
|
||||
echo "Paths:"
|
||||
echo " --prefix-dir=dir specifies the prefix for all installed"
|
||||
@@ -3852,7 +3827,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 "
|
||||
|
3
configure
vendored
3
configure
vendored
@@ -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,7 +116,6 @@ 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 == "HAIKU" && "'$os'" != "HAIKU") { next; }
|
||||
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
|
||||
"'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
|
||||
|
@@ -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.
|
Binary file not shown.
@@ -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.
|
Binary file not shown.
@@ -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.
|
@@ -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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
@@ -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
|
@@ -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.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
@@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
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 <exename>", argv[0]);
|
||||
for (i=1; i<argc; i++)
|
||||
exe2aout(argv[i]);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $Id$
|
||||
|
||||
cd `dirname $0`
|
||||
cc -o exe2coff/exe2coff exe2coff/exe2coff.c || exit
|
||||
cp $1 binary.exe || exit
|
||||
./exe2coff/exe2coff binary.exe || exit
|
||||
cat cwsdpmi/cwsdstub.exe binary > binary.exe || exit
|
||||
mv binary.exe $1
|
||||
rm binary exe2coff/exe2coff
|
@@ -1346,8 +1346,6 @@
|
||||
<ClCompile Include="..\src\network\core\udp.cpp" />
|
||||
<ClInclude Include="..\src\network\core\udp.h" />
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp" />
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp" />
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_type.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pf_performance_timer.hpp" />
|
||||
|
@@ -3129,12 +3129,6 @@
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -1346,8 +1346,6 @@
|
||||
<ClCompile Include="..\src\network\core\udp.cpp" />
|
||||
<ClInclude Include="..\src\network\core\udp.h" />
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp" />
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp" />
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_type.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pf_performance_timer.hpp" />
|
||||
|
@@ -3129,12 +3129,6 @@
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -1346,8 +1346,6 @@
|
||||
<ClCompile Include="..\src\network\core\udp.cpp" />
|
||||
<ClInclude Include="..\src\network\core\udp.h" />
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp" />
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp" />
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_type.h" />
|
||||
<ClInclude Include="..\src\pathfinder\pf_performance_timer.hpp" />
|
||||
|
@@ -3129,12 +3129,6 @@
|
||||
<ClInclude Include="..\src\pathfinder\follow_track.hpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\src\pathfinder\opf\opf_ship.cpp">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\src\pathfinder\opf\opf_ship.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pathfinder\pathfinder_func.h">
|
||||
<Filter>Pathfinder</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -1105,8 +1105,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
|
||||
@@ -1172,10 +1170,7 @@ music/midifile.cpp
|
||||
#if WIN32
|
||||
music/win32_m.cpp
|
||||
#else
|
||||
#if DOS
|
||||
#else
|
||||
music/extmidi.cpp
|
||||
#end
|
||||
music/extmidi.cpp
|
||||
#end
|
||||
#if HAIKU
|
||||
music/bemidi.cpp
|
||||
|
@@ -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
|
||||
|
@@ -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 */
|
||||
|
@@ -362,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)
|
||||
@@ -380,8 +378,6 @@
|
||||
return AI::scanner_library->HasScript(ci, md5sum);
|
||||
}
|
||||
|
||||
#endif /* defined(ENABLE_NETWORK) */
|
||||
|
||||
/* static */ AIScannerInfo *AI::GetScannerInfo()
|
||||
{
|
||||
return AI::scanner_info;
|
||||
|
@@ -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,7 +582,7 @@ 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);
|
||||
@@ -646,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);
|
||||
@@ -743,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:
|
||||
@@ -767,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:
|
||||
@@ -819,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: {
|
||||
@@ -858,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;
|
||||
@@ -928,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;
|
||||
}
|
||||
@@ -941,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;
|
||||
@@ -1098,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;
|
||||
@@ -1106,7 +1104,7 @@ struct AIDebugWindow : public Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
this->SelectValidDebugCompany();
|
||||
|
||||
@@ -1184,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:
|
||||
@@ -1207,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;
|
||||
|
||||
@@ -1266,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;
|
||||
@@ -1336,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. */
|
||||
@@ -1351,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. */
|
||||
@@ -1408,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);
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -795,6 +795,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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include "safeguards.h"
|
||||
|
||||
/** The table/list with animated tiles. */
|
||||
SmallVector<TileIndex, 256> _animated_tiles;
|
||||
std::vector<TileIndex> _animated_tiles;
|
||||
|
||||
/**
|
||||
* Removes the given tile from the animated tile table.
|
||||
@@ -27,10 +27,10 @@ SmallVector<TileIndex, 256> _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, ZOOM_LVL_DRAW_MAP);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ void DeleteAnimatedTile(TileIndex tile)
|
||||
void AddAnimatedTile(TileIndex tile)
|
||||
{
|
||||
MarkTileDirtyByTile(tile, ZOOM_LVL_DRAW_MAP);
|
||||
_animated_tiles.Include(tile);
|
||||
include(_animated_tiles, tile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +58,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;
|
||||
switch (GetTileType(curr)) {
|
||||
case MP_HOUSE:
|
||||
@@ -100,5 +100,5 @@ void AnimateAnimatedTiles()
|
||||
*/
|
||||
void InitializeAnimatedTiles()
|
||||
{
|
||||
_animated_tiles.Clear();
|
||||
_animated_tiles.clear();
|
||||
}
|
||||
|
@@ -201,16 +201,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);
|
||||
|
@@ -299,7 +299,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);
|
||||
|
@@ -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(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(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, 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<NWidgetBase>(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 */
|
||||
|
@@ -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.
|
||||
|
@@ -277,7 +277,6 @@ template <class Tbase_set>
|
||||
return p;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_NETWORK)
|
||||
#include "network/network_content.h"
|
||||
|
||||
template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
|
||||
@@ -307,22 +306,6 @@ template <class Tbase_set>
|
||||
(TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets) != NULL);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <class Tbase_set>
|
||||
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <class Tbase_set>
|
||||
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/**
|
||||
* Count the number of available graphics sets.
|
||||
* @return the number of sets
|
||||
|
@@ -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.
|
||||
|
@@ -37,23 +37,23 @@ 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 SetLine(void *video, int x, int y, uint8 *colours, uint width);
|
||||
/* virtual */ void SetLine32(void *video, int x, int y, uint32 *colours, uint width);
|
||||
/* 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 SetLine(void *video, int x, int y, uint8 *colours, uint width) override;
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) 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.
|
||||
@@ -79,7 +79,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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -35,19 +35,19 @@ private:
|
||||
|
||||
public:
|
||||
template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent, bool animated>
|
||||
/* 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 */
|
||||
|
@@ -20,21 +20,21 @@
|
||||
/** 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 SetLine(void *video, int x, int y, uint8 *colours, uint width);
|
||||
/* virtual */ void SetLine32(void *video, int x, int y, uint32 *colours, uint width);
|
||||
/* 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 SetLine(void *video, int x, int y, uint8 *colours, uint width) override;
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) 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.
|
||||
|
@@ -24,10 +24,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 <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||
};
|
||||
@@ -36,7 +36,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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -68,22 +68,22 @@ public:
|
||||
/** 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 <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
|
||||
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 */
|
||||
|
@@ -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 <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
|
||||
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 */
|
||||
|
@@ -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 <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
|
||||
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 */
|
||||
|
@@ -17,21 +17,21 @@
|
||||
/** 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 SetLine(void *video, int x, int y, uint8 *colours, uint width);
|
||||
/* 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 SetLine(void *video, int x, int y, uint8 *colours, uint width) 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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -17,32 +17,33 @@
|
||||
/** 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 SetLine(void *video, int x, int y, uint8 *colours, uint width) {};
|
||||
/* 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; };
|
||||
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 SetLine(void *video, int x, int y, uint8 *colours, uint width) override {};
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) 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; };
|
||||
|
||||
/* virtual */ const char *GetName() { return "null"; }
|
||||
/* virtual */ int GetBytesPerPixel() { return 0; }
|
||||
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 */
|
||||
|
@@ -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. */
|
||||
|
@@ -116,11 +116,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);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
this->bridges->NeedResort();
|
||||
this->SortBridgeList();
|
||||
|
||||
this->vscroll->SetCount(bl->Length());
|
||||
this->vscroll->SetCount(bl->size());
|
||||
}
|
||||
|
||||
~BuildBridgeWindow()
|
||||
@@ -166,7 +166,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: {
|
||||
@@ -189,11 +189,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));
|
||||
@@ -210,7 +210,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<NWidgetBase>(WID_BBS_BRIDGE_LIST);
|
||||
@@ -220,7 +220,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:
|
||||
@@ -229,10 +229,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);
|
||||
|
||||
@@ -246,10 +246,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;
|
||||
@@ -258,13 +258,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;
|
||||
}
|
||||
@@ -282,7 +282,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);
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_BBS_BRIDGE_LIST);
|
||||
}
|
||||
@@ -425,17 +425,18 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
/* Re-check bridge building possibility is initial bridge builindg query indicated a bridge type dependent failure */
|
||||
if (query_per_bridge_type && DoCommand(end, start, type | brd_type, CommandFlagsToDCFlags(GetCommandFlags(CMD_BUILD_BRIDGE)) | DC_QUERY_COST, CMD_BUILD_BRIDGE).Failed()) continue;
|
||||
/* 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;
|
||||
|
@@ -82,9 +82,6 @@ static const NWidgetPart _nested_build_vehicle_widgets[] = {
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BV_BUILD_SEL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BV_BUILD), SetResize(1, 0), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BV_BUILD_REFIT_SEL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BV_BUILD_REFIT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUY_REFIT_VEHICLE_BUY_VEHICLE_BUTTON, STR_BUY_REFIT_VEHICLE_BUY_VEHICLE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BV_SHOW_HIDE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BV_RENAME), SetResize(1, 0), SetFill(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
@@ -100,7 +97,6 @@ byte _engine_sort_last_criteria[] = {0, 0, 0, 0}; ///< Las
|
||||
bool _engine_sort_last_order[] = {false, false, false, false}; ///< Last set direction of the sort order, for each vehicle type.
|
||||
bool _engine_sort_show_hidden_engines[] = {false, false, false, false}; ///< Last set 'show hidden engines' setting for each vehicle type.
|
||||
static CargoID _engine_sort_last_cargo_criteria[] = {CF_ANY, CF_ANY, CF_ANY, CF_ANY}; ///< Last set filter criteria, for each vehicle type.
|
||||
static bool _refit_on_buy = false; ///< to save user's choice for at least this game session
|
||||
|
||||
/**
|
||||
* Determines order of engines by engineID
|
||||
@@ -537,11 +533,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;
|
||||
@@ -557,19 +553,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;
|
||||
@@ -595,14 +597,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 */
|
||||
@@ -637,20 +646,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;
|
||||
@@ -667,9 +682,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;
|
||||
}
|
||||
|
||||
@@ -682,7 +704,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);
|
||||
|
||||
@@ -691,13 +713,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);
|
||||
@@ -710,8 +746,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;
|
||||
@@ -733,31 +769,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);
|
||||
}
|
||||
@@ -814,7 +854,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;
|
||||
@@ -826,30 +866,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);
|
||||
@@ -901,7 +941,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);
|
||||
@@ -993,9 +1033,30 @@ 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;
|
||||
bool build_and_refit; ///< Build and refit. This is beauty, but we need some persistence to save user choice for this game session at least
|
||||
bool virtual_train_mode; ///< Are we building a virtual train?
|
||||
Train **virtual_train_out; ///< Virtual train ptr
|
||||
TestedEngineDetails te; ///< Tested cost and capacity after refit.
|
||||
|
||||
void SetBuyVehicleText()
|
||||
{
|
||||
NWidgetCore *widget = this->GetWidget<NWidgetCore>(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 (this->virtual_train_mode) {
|
||||
widget->widget_data = STR_TMPL_CONFIRM;
|
||||
widget->tool_tip = STR_TMPL_CONFIRM;
|
||||
} else {
|
||||
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, Train **virtual_train_out) : Window(desc)
|
||||
{
|
||||
@@ -1033,7 +1094,6 @@ struct BuildVehicleWindow : Window {
|
||||
* So we just hide it, and enlarge the Rename button by the now vacant place. */
|
||||
if (this->listview_mode) {
|
||||
this->GetWidget<NWidgetStacked>(WID_BV_BUILD_SEL)->SetDisplayedPlane(SZSP_NONE);
|
||||
this->GetWidget<NWidgetStacked>(WID_BV_BUILD_REFIT_SEL)->SetDisplayedPlane(SZSP_NONE);
|
||||
}
|
||||
|
||||
/* disable renaming engines in network games if you are not the server */
|
||||
@@ -1045,18 +1105,6 @@ struct BuildVehicleWindow : Window {
|
||||
widget = this->GetWidget<NWidgetCore>(WID_BV_SHOW_HIDE);
|
||||
widget->tool_tip = STR_BUY_VEHICLE_TRAIN_HIDE_SHOW_TOGGLE_TOOLTIP + type;
|
||||
|
||||
this->build_and_refit = _refit_on_buy;
|
||||
this->SetWidgetLoweredState(WID_BV_BUILD_REFIT, this->build_and_refit);
|
||||
|
||||
widget = this->GetWidget<NWidgetCore>(WID_BV_BUILD);
|
||||
if (this->virtual_train_mode) {
|
||||
widget->widget_data = STR_TMPL_CONFIRM;
|
||||
widget->tool_tip = STR_TMPL_CONFIRM;
|
||||
} else {
|
||||
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<NWidgetCore>(WID_BV_RENAME);
|
||||
widget->widget_data = STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON + type;
|
||||
widget->tool_tip = STR_BUY_VEHICLE_TRAIN_RENAME_TOOLTIP + type;
|
||||
@@ -1075,7 +1123,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. */
|
||||
@@ -1122,7 +1174,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();
|
||||
}
|
||||
@@ -1131,10 +1218,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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1154,7 +1241,7 @@ struct BuildVehicleWindow : Window {
|
||||
|
||||
this->filter.railtype = (this->listview_mode || this->virtual_train_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,
|
||||
@@ -1172,7 +1259,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++;
|
||||
@@ -1183,7 +1270,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;
|
||||
@@ -1202,7 +1289,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) {
|
||||
@@ -1210,29 +1297,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 */
|
||||
@@ -1240,7 +1327,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);
|
||||
|
||||
@@ -1256,11 +1343,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 */
|
||||
@@ -1271,7 +1358,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:
|
||||
@@ -1290,11 +1377,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:
|
||||
@@ -1314,8 +1401,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);
|
||||
@@ -1341,13 +1428,6 @@ struct BuildVehicleWindow : Window {
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BV_BUILD_REFIT: {
|
||||
_refit_on_buy = this->build_and_refit = !this->build_and_refit;
|
||||
this->SetWidgetLoweredState(WID_BV_BUILD_REFIT, this->build_and_refit);
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BV_BUILD: {
|
||||
EngineID sel_eng = this->sel_engine;
|
||||
if (sel_eng != INVALID_ENGINE) {
|
||||
@@ -1361,19 +1441,9 @@ struct BuildVehicleWindow : Window {
|
||||
? CcBuildWagon : CcBuildPrimaryVehicle;
|
||||
cmd = GetCmdBuildVeh(this->vehicle_type);
|
||||
}
|
||||
if (!this->IsWidgetDisabled(WID_BV_BUILD_REFIT) && this->build_and_refit) {
|
||||
/* build and refit */
|
||||
char text_buffer[2];
|
||||
text_buffer[0] = 'R';
|
||||
text_buffer[1] = this->cargo_filter[this->cargo_filter_criteria];
|
||||
if ((cmd & 0xFFFF) == CMD_BUILD_VEHICLE) {
|
||||
cmd = (cmd & ~0xFFFF) | CMD_BUILD_VEHICLE_NT;
|
||||
}
|
||||
DoCommandP(this->window_number, sel_eng, 0, cmd, callback, text_buffer, true, 2);
|
||||
} else {
|
||||
/* build only */
|
||||
DoCommandP(this->window_number, sel_eng, 0, cmd, 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, cmd, callback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1395,7 +1465,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. */
|
||||
@@ -1408,7 +1478,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:
|
||||
@@ -1440,7 +1510,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:
|
||||
@@ -1461,6 +1531,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));
|
||||
@@ -1470,11 +1547,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(), this->eng_list.size()), this->sel_engine, false, DEFAULT_GROUP);
|
||||
break;
|
||||
|
||||
case WID_BV_SORT_ASCENDING_DESCENDING:
|
||||
@@ -1483,20 +1560,13 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
this->GenerateBuildList();
|
||||
this->vscroll->SetCount(this->eng_list.Length());
|
||||
this->vscroll->SetCount(this->eng_list.size());
|
||||
|
||||
this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
|
||||
|
||||
// disable build and refit if all or none cargo type selected
|
||||
if (this->cargo_filter[this->cargo_filter_criteria] == CF_ANY || this->cargo_filter[this->cargo_filter_criteria] == CF_NONE) {
|
||||
this->DisableWidget(WID_BV_BUILD_REFIT);
|
||||
} else {
|
||||
this->EnableWidget(WID_BV_BUILD_REFIT);
|
||||
}
|
||||
|
||||
this->DrawWidgets();
|
||||
|
||||
if (!this->IsShaded()) {
|
||||
@@ -1505,7 +1575,7 @@ struct BuildVehicleWindow : Window {
|
||||
if (this->sel_engine != INVALID_ENGINE) {
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(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.
|
||||
@@ -1517,14 +1587,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:
|
||||
@@ -1542,13 +1612,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);
|
||||
}
|
||||
|
@@ -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<NWidgetBase>(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;
|
||||
|
@@ -305,7 +305,6 @@ static const Command _command_proc_table[] = {
|
||||
DEF_CMD(CmdPlantTree, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_PLANT_TREE
|
||||
|
||||
DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_BUILD_VEHICLE
|
||||
DEF_CMD(CmdBuildVehicle, CMD_NO_TEST | CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_BUILD_VEHICLE_NT
|
||||
DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_SELL_VEHICLE
|
||||
DEF_CMD(CmdRefitVehicle, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_REFIT_VEHICLE
|
||||
DEF_CMD(CmdSendVehicleToDepot, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_SEND_VEHICLE_TO_DEPOT
|
||||
@@ -692,7 +691,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 = command.Execute(tile, flags & ~DC_EXEC, p1, p2, text, binary_length);
|
||||
SetTownRatingTestMode(false);
|
||||
@@ -715,7 +714,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 = command.Execute(tile, flags, p1, p2, text, binary_length);
|
||||
if (res.Failed()) {
|
||||
error:
|
||||
@@ -800,10 +799,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, binary_length);
|
||||
if (res.Failed()) {
|
||||
@@ -884,10 +881,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);
|
||||
@@ -908,7 +903,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 = command.Execute(tile, flags, p1, p2, text, binary_length);
|
||||
@@ -934,7 +929,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
|
||||
@@ -949,12 +943,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: date{%08x; %02x; %02x}; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, _tick_skip_counter, (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 = command.Execute(tile, flags | DC_EXEC, p1, p2, text, binary_length);
|
||||
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
|
||||
|
@@ -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, uint32 binary_length);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company, uint32 binary_length);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
extern Money _additional_cash_required;
|
||||
|
||||
|
@@ -253,7 +253,6 @@ enum Commands {
|
||||
CMD_PLANT_TREE, ///< plant a tree
|
||||
|
||||
CMD_BUILD_VEHICLE, ///< build a vehicle
|
||||
CMD_BUILD_VEHICLE_NT, ///< build a vehicle (no test)
|
||||
CMD_SELL_VEHICLE, ///< sell a vehicle
|
||||
CMD_REFIT_VEHICLE, ///< refit the cargo space of a vehicle
|
||||
CMD_SEND_VEHICLE_TO_DEPOT, ///< send a vehicle to a depot
|
||||
|
@@ -106,10 +106,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());
|
||||
|
||||
@@ -605,9 +603,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;
|
||||
|
||||
@@ -800,9 +796,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 */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,9 +806,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 */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -840,7 +832,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();
|
||||
|
||||
@@ -884,7 +875,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
}
|
||||
|
||||
NetworkServerNewCompany(c, ci);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -893,9 +883,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@@ -291,7 +291,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:
|
||||
@@ -310,7 +310,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) {
|
||||
@@ -338,7 +338,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:
|
||||
@@ -399,7 +399,7 @@ struct CompanyFinancesWindow : Window {
|
||||
this->GetWidget<NWidgetStacked>(WID_CF_SEL_BUTTONS)->SetDisplayedPlane(plane);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
if (!this->IsShaded()) {
|
||||
if (!this->small) {
|
||||
@@ -429,7 +429,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
|
||||
@@ -458,7 +458,7 @@ struct CompanyFinancesWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnHundredthTick()
|
||||
void OnHundredthTick() override
|
||||
{
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
if (c->money > this->max_money) {
|
||||
@@ -528,17 +528,17 @@ public:
|
||||
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, Colours 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;
|
||||
@@ -566,7 +566,7 @@ private:
|
||||
uint rows;
|
||||
uint line_height;
|
||||
GUIGroupList groups;
|
||||
SmallVector<int, 32> indents;
|
||||
std::vector<int> indents;
|
||||
Scrollbar *vscroll;
|
||||
|
||||
void ShowColourDropDownMenu(uint32 widget)
|
||||
@@ -610,10 +610,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;
|
||||
@@ -644,11 +644,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,8 +656,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;
|
||||
@@ -666,7 +666,7 @@ private:
|
||||
const Group *g;
|
||||
FOR_ALL_GROUPS(g) {
|
||||
if (g->owner == owner && g->vehicle_type == vtype) {
|
||||
*list.Append() = g;
|
||||
list.push_back(g);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ private:
|
||||
AddChildren(&list, INVALID_GROUP, 0);
|
||||
}
|
||||
|
||||
this->groups.Compact();
|
||||
this->groups.shrink_to_fit();
|
||||
this->groups.RebuildDone();
|
||||
}
|
||||
|
||||
@@ -690,7 +690,7 @@ private:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this->rows = this->groups.Length();
|
||||
this->rows = this->groups.size();
|
||||
}
|
||||
|
||||
this->vscroll->SetCount(this->rows);
|
||||
@@ -744,7 +744,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: {
|
||||
@@ -797,7 +797,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
bool local = (CompanyID)this->window_number == _local_company;
|
||||
|
||||
@@ -811,7 +811,7 @@ public:
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SCL_CAPTION:
|
||||
@@ -851,7 +851,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;
|
||||
|
||||
@@ -906,7 +906,7 @@ public:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.Length());
|
||||
uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size());
|
||||
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||
const Group *g = this->groups[i];
|
||||
SetDParam(0, g->index);
|
||||
@@ -915,7 +915,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 */
|
||||
@@ -946,7 +946,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;
|
||||
}
|
||||
}
|
||||
@@ -989,12 +989,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;
|
||||
@@ -1020,7 +1020,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 (!gui_scope) return;
|
||||
|
||||
@@ -1033,7 +1033,7 @@ public:
|
||||
|
||||
if (!Group::IsValidID(this->sel)) {
|
||||
this->sel = INVALID_GROUP;
|
||||
if (this->groups.Length() > 0) this->sel = this->groups[0]->index;
|
||||
if (this->groups.size() > 0) this->sel = this->groups[0]->index;
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
@@ -1372,7 +1372,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));
|
||||
@@ -1395,7 +1395,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: {
|
||||
@@ -1454,7 +1454,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);
|
||||
@@ -1515,7 +1515,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:
|
||||
@@ -1604,7 +1604,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 */
|
||||
@@ -1713,7 +1713,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
/* Set a new company manager face number */
|
||||
@@ -1868,7 +1868,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
return total;
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_CI_CAPTION:
|
||||
@@ -1877,7 +1877,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);
|
||||
|
||||
@@ -2000,7 +2000,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;
|
||||
@@ -2103,7 +2103,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;
|
||||
|
||||
@@ -2282,7 +2282,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;
|
||||
@@ -2357,7 +2357,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: {
|
||||
@@ -2410,15 +2410,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) {
|
||||
@@ -2521,17 +2519,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:
|
||||
@@ -2549,7 +2545,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;
|
||||
@@ -2622,7 +2618,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;
|
||||
@@ -2642,17 +2637,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();
|
||||
@@ -2660,12 +2654,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;
|
||||
|
||||
@@ -2684,11 +2678,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 */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2698,7 +2690,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;
|
||||
|
||||
@@ -2766,7 +2758,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:
|
||||
@@ -2782,7 +2774,7 @@ struct BuyCompanyWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_BC_CAPTION:
|
||||
@@ -2792,7 +2784,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: {
|
||||
@@ -2811,7 +2803,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:
|
||||
|
@@ -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);
|
||||
|
@@ -89,8 +89,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.
|
||||
@@ -162,10 +160,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) {
|
||||
@@ -173,11 +167,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;
|
||||
}
|
||||
@@ -482,7 +472,6 @@ DEF_CONSOLE_CMD(ConClearBuffer)
|
||||
/**********************************
|
||||
* Network Core Console Commands
|
||||
**********************************/
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
static bool ConKickOrBan(const char *argv, bool ban)
|
||||
{
|
||||
@@ -566,21 +555,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'");
|
||||
@@ -599,8 +588,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;
|
||||
@@ -933,8 +922,6 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/*********************************
|
||||
* script file console commands
|
||||
*********************************/
|
||||
@@ -1571,12 +1558,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));
|
||||
@@ -1593,8 +1577,6 @@ DEF_CONSOLE_CMD(ConCompanies)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
DEF_CONSOLE_CMD(ConSay)
|
||||
{
|
||||
if (argc == 0) {
|
||||
@@ -1836,7 +1818,6 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return false;
|
||||
}
|
||||
#endif /* defined(WITH_ZLIB) */
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
DEF_CONSOLE_CMD(ConSetting)
|
||||
{
|
||||
@@ -2132,7 +2113,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);
|
||||
@@ -2190,7 +2171,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
|
||||
|
@@ -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(Window *newly_focused_window)
|
||||
void OnFocusLost(Window *newly_focused_window) override
|
||||
{
|
||||
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#define TTD_BIG_ENDIAN 1
|
||||
|
||||
/* Windows has always LITTLE_ENDIAN */
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__) || defined(__DJGPP__)
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__)
|
||||
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
|
||||
#elif defined(OSX)
|
||||
# include <sys/types.h>
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ enum PoolType {
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(PoolType)
|
||||
|
||||
typedef SmallVector<struct PoolBase *, 4> PoolVector; ///< Vector of pointers to PoolBase
|
||||
typedef std::vector<struct PoolBase *> 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();
|
||||
|
@@ -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 <typename T, typename U, uint S = 16>
|
||||
struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
template <typename T, typename U>
|
||||
struct SmallMap : std::vector<SmallPair<T, U> > {
|
||||
typedef ::SmallPair<T, U> Pair;
|
||||
typedef Pair *iterator;
|
||||
typedef const Pair *const_iterator;
|
||||
@@ -54,12 +55,13 @@ struct SmallMap : SmallVector<SmallPair<T, U>, 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<Pair>::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<Pair>::const_iterator it;
|
||||
for (it = std::vector<Pair>::begin(); it != std::vector<Pair>::end(); it++) {
|
||||
if (key == it->first) return it;
|
||||
}
|
||||
return this->End();
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,12 +71,23 @@ struct SmallMap : SmallVector<SmallPair<T, U>, 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<Pair>::size(); i++) {
|
||||
if (key == std::vector<Pair>::operator[](i).first) return &std::vector<Pair>::operator[](i);
|
||||
}
|
||||
return this->End();
|
||||
}
|
||||
|
||||
inline const Pair *End() const
|
||||
{
|
||||
return std::vector<Pair>::data() + std::vector<Pair>::size();
|
||||
}
|
||||
|
||||
inline Pair *End()
|
||||
{
|
||||
return std::vector<Pair>::data() + std::vector<Pair>::size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether a key is assigned in this map.
|
||||
* @param key key to test
|
||||
@@ -85,6 +98,16 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
return this->Find(key) != this->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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes given pair from this map
|
||||
* @param pair pair to remove
|
||||
@@ -92,8 +115,9 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
*/
|
||||
inline void Erase(Pair *pair)
|
||||
{
|
||||
assert(pair >= this->Begin() && pair < this->End());
|
||||
*pair = this->data[--this->items];
|
||||
assert(pair >= std::vector<Pair>::data() && pair < this->End());
|
||||
auto distance = pair - std::vector<Pair>::data();
|
||||
std::vector<Pair>::erase(std::vector<Pair>::begin() + distance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,13 +128,11 @@ struct SmallMap : SmallVector<SmallPair<T, U>, 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;
|
||||
Pair *pair = this->Find(key);
|
||||
if (pair == this->End()) return false;
|
||||
|
||||
this->Erase(pair);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,9 +144,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, 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<Pair>::emplace_back(key, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,17 +156,18 @@ struct SmallMap : SmallVector<SmallPair<T, U>, 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<Pair>::size(); i++) {
|
||||
if (key == std::vector<Pair>::operator[](i).first) return std::vector<Pair>::operator[](i).second;
|
||||
}
|
||||
Pair *n = this->Append();
|
||||
n->first = key;
|
||||
return n->second;
|
||||
/*C++17: Pair &n = */ std::vector<Pair>::emplace_back();
|
||||
Pair &n = std::vector<Pair>::back();
|
||||
n.first = key;
|
||||
return n.second;
|
||||
}
|
||||
|
||||
inline void SortByKey()
|
||||
{
|
||||
QSortT(this->Begin(), this->items, KeySorter);
|
||||
QSortT(std::vector<Pair>::data(), std::vector<Pair>::size(), KeySorter);
|
||||
}
|
||||
|
||||
static int CDECL KeySorter(const Pair *a, const Pair *b)
|
||||
|
@@ -64,8 +64,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;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
Tindex first_unused;
|
||||
Tindex first_free;
|
||||
|
||||
SmallVector<SimplePoolPoolItem, Tgrowth_step> data;
|
||||
std::vector<SimplePoolPoolItem> data;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -96,6 +96,7 @@ struct SmallStackItem {
|
||||
*/
|
||||
inline SmallStackItem(const Titem &value, Tindex next) :
|
||||
next(next), value(value) {}
|
||||
SmallStackItem() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -14,375 +14,60 @@
|
||||
|
||||
#include "alloc_func.hpp"
|
||||
#include "mem_func.hpp"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
* 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 <typename T, uint S>
|
||||
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
|
||||
template <typename T>
|
||||
inline bool include(std::vector<T>& 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;
|
||||
}
|
||||
|
||||
public:
|
||||
SmallVector() : data(NULL), items(0), capacity(0) { }
|
||||
/**
|
||||
* 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 <typename T>
|
||||
int find_index(std::vector<T> const& vec, T const& item)
|
||||
{
|
||||
auto const it = std::find(vec.begin(), vec.end(), item);
|
||||
if (it != vec.end()) return it - vec.begin();
|
||||
|
||||
/**
|
||||
* 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 <uint X>
|
||||
SmallVector(const SmallVector<T, X> &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 <uint X>
|
||||
SmallVector &operator=(const SmallVector<T, X> &other)
|
||||
{
|
||||
this->Assign(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~SmallVector()
|
||||
{
|
||||
free(this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign items from other vector.
|
||||
*/
|
||||
template <uint X>
|
||||
inline void Assign(const SmallVector<T, X> &other)
|
||||
{
|
||||
if ((const void *)&other == (void *)this) return;
|
||||
|
||||
this->Clear();
|
||||
if (other.Length() > 0) MemCpyT<T>(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <typename T>
|
||||
T* grow(std::vector<T>& 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 <typename T, uint S>
|
||||
class AutoFreeSmallVector : public SmallVector<T, S> {
|
||||
template <typename T>
|
||||
class AutoFreeSmallVector : public std::vector<T> {
|
||||
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<T>::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 <typename T, uint S>
|
||||
class AutoDeleteSmallVector : public SmallVector<T, S> {
|
||||
template <typename T>
|
||||
class AutoDeleteSmallVector : public std::vector<T> {
|
||||
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<T>::clear();
|
||||
}
|
||||
};
|
||||
|
||||
typedef AutoFreeSmallVector<char*, 4> StringList; ///< Type for a list of strings.
|
||||
typedef AutoFreeSmallVector<char*> StringList; ///< Type for a list of strings.
|
||||
|
||||
#endif /* SMALLVEC_TYPE_HPP */
|
||||
|
@@ -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;
|
||||
|
@@ -210,9 +210,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();
|
||||
|
||||
@@ -232,11 +230,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();
|
||||
@@ -260,9 +256,7 @@ static void OnNewMonth()
|
||||
IndustryMonthlyLoop();
|
||||
SubsidyMonthlyLoop();
|
||||
StationMonthlyLoop();
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) NetworkServerMonthlyLoop();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
IConsoleCmdExec("exec scripts/on_newmonth.scr 0");
|
||||
}
|
||||
|
||||
@@ -271,9 +265,7 @@ static void OnNewMonth()
|
||||
*/
|
||||
static void OnNewDay()
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) NetworkServerDailyLoop();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
DisasterDailyLoop();
|
||||
IndustryDailyLoop();
|
||||
|
@@ -56,7 +56,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;
|
||||
@@ -76,14 +76,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;
|
||||
@@ -92,7 +92,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;
|
||||
@@ -101,7 +101,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) {
|
||||
@@ -130,7 +130,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;
|
||||
@@ -139,7 +139,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:
|
||||
@@ -157,7 +157,7 @@ struct SetDateWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SD_DAY:
|
||||
@@ -203,7 +203,7 @@ struct SetMinutesWindow : SetDateWindow
|
||||
for (uint i = 0; i < 60; i++) {
|
||||
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
|
||||
item->SetParam(0, i);
|
||||
*list->Append() = item;
|
||||
list->push_back(item);
|
||||
}
|
||||
selected = MINUTES_MINUTE(minutes);
|
||||
break;
|
||||
@@ -212,7 +212,7 @@ struct SetMinutesWindow : SetDateWindow
|
||||
for (uint i = 0; i < 24; i++) {
|
||||
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
|
||||
item->SetParam(0, i);
|
||||
*list->Append() = item;
|
||||
list->push_back(item);
|
||||
}
|
||||
selected = MINUTES_HOUR(minutes);
|
||||
|
||||
|
@@ -23,10 +23,8 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if defined(ENABLE_NETWORK)
|
||||
#include "network/network_admin.h"
|
||||
SOCKET _debug_socket = INVALID_SOCKET;
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
#if defined(RANDOM_DEBUG) && defined(UNIX) && defined(__GLIBC__)
|
||||
#include <unistd.h>
|
||||
@@ -121,7 +119,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];
|
||||
|
||||
@@ -131,7 +128,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) {
|
||||
@@ -189,9 +185,7 @@ static void debug_print(const char *dbg, const char *buf)
|
||||
fputs(buffer, stderr);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkAdminConsole(dbg, buf);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
IConsoleDebug(dbg, buf);
|
||||
}
|
||||
|
||||
|
@@ -11,8 +11,6 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -67,10 +65,3 @@ void DedicatedFork()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/** Empty helper function call for NOT(UNIX) systems */
|
||||
void DedicatedFork() {}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
@@ -153,8 +153,8 @@ static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list)
|
||||
{
|
||||
/* Seperate departure by each shared order group */
|
||||
std::map<uint32, std::vector<Departure*>> separated_departure;
|
||||
for (Departure** departure = departure_list->Begin(); departure != departure_list->End(); departure++) {
|
||||
separated_departure[(*departure)->vehicle->orders.list->index].push_back(*departure);
|
||||
for (Departure* departure : *departure_list) {
|
||||
separated_departure[departure->vehicle->orders.list->index].push_back(departure);
|
||||
}
|
||||
|
||||
for (auto& pair : separated_departure) {
|
||||
@@ -190,7 +190,7 @@ static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list)
|
||||
}
|
||||
|
||||
/* Re-sort the departure list */
|
||||
QSortT<Departure*>(departure_list->Begin(), departure_list->Length(), [](Departure * const *a, Departure * const *b) -> int {
|
||||
QSortT<Departure*>(departure_list->data(), departure_list->size(), [](Departure * const *a, Departure * const *b) -> int {
|
||||
return (*a)->scheduled_date - (*b)->scheduled_date;
|
||||
});
|
||||
}
|
||||
@@ -215,12 +215,12 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
/* Having written that, it's not exactly slow at the moment. */
|
||||
|
||||
/* The list of departures which will be returned as a result. */
|
||||
SmallVector<Departure*, 32> *result = new SmallVector<Departure*, 32>();
|
||||
std::vector<Departure*> *result = new std::vector<Departure*>();
|
||||
|
||||
if (!show_pax && !show_freight) return result;
|
||||
|
||||
/* A list of the next scheduled orders to be considered for inclusion in the departure list. */
|
||||
SmallVector<OrderDate*, 32> next_orders;
|
||||
std::vector<OrderDate*> next_orders;
|
||||
|
||||
/* The maximum possible date for departures to be scheduled to occur. */
|
||||
DateTicksScaled max_date = _settings_client.gui.max_departure_time * DAY_TICKS * _settings_game.economy.day_length_factor;
|
||||
@@ -254,11 +254,11 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
/* Get the first order for each vehicle for the station we're interested in that doesn't have No Loading set. */
|
||||
/* We find the least order while we're at it. */
|
||||
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||
for (const Vehicle *v : vehicles) {
|
||||
if (show_pax != show_freight) {
|
||||
bool carries_passengers = false;
|
||||
|
||||
const Vehicle *u = *v;
|
||||
const Vehicle *u = v;
|
||||
while (u != NULL) {
|
||||
if (u->cargo_cap > 0 && IsCargoInClass(u->cargo_type, CC_PASSENGERS)) {
|
||||
carries_passengers = true;
|
||||
@@ -272,12 +272,12 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
}
|
||||
|
||||
const Order *order = (*v)->GetOrder((*v)->cur_implicit_order_index % (*v)->GetNumOrders());
|
||||
DateTicks start_date = date_fract_scaled - (*v)->current_order_time;
|
||||
if ((*v)->cur_timetable_order_index != INVALID_VEH_ORDER_ID && (*v)->cur_timetable_order_index != (*v)->cur_real_order_index) {
|
||||
const Order *order = v->GetOrder(v->cur_implicit_order_index % v->GetNumOrders());
|
||||
DateTicks start_date = date_fract_scaled - v->current_order_time;
|
||||
if (v->cur_timetable_order_index != INVALID_VEH_ORDER_ID && v->cur_timetable_order_index != v->cur_real_order_index) {
|
||||
/* vehicle is taking a conditional order branch, adjust start time to compensate */
|
||||
const Order *real_current_order = (*v)->GetOrder((*v)->cur_real_order_index);
|
||||
const Order *real_timetable_order = (*v)->GetOrder((*v)->cur_timetable_order_index);
|
||||
const Order *real_current_order = v->GetOrder(v->cur_real_order_index);
|
||||
const Order *real_timetable_order = v->GetOrder(v->cur_timetable_order_index);
|
||||
assert(real_timetable_order->IsType(OT_CONDITIONAL));
|
||||
start_date += (real_timetable_order->GetWaitTime() - real_current_order->GetTravelTime());
|
||||
}
|
||||
@@ -286,30 +286,30 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
uint waiting_time = 0;
|
||||
|
||||
/* If the vehicle is stopped in a depot, ignore it. */
|
||||
if ((*v)->IsStoppedInDepot()) {
|
||||
if (v->IsStoppedInDepot()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the vehicle is heading for a depot to stop there, then its departures are cancelled. */
|
||||
if ((*v)->current_order.IsType(OT_GOTO_DEPOT) && (*v)->current_order.GetDepotActionType() & ODATFB_HALT) {
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() & ODATFB_HALT) {
|
||||
status = D_CANCELLED;
|
||||
}
|
||||
|
||||
if ((*v)->current_order.IsAnyLoadingType()) {
|
||||
if (v->current_order.IsAnyLoadingType()) {
|
||||
/* Account for the vehicle having reached the current order and being in the loading phase. */
|
||||
status = D_ARRIVED;
|
||||
start_date -= order->GetTravelTime() + (((*v)->lateness_counter < 0) ? (*v)->lateness_counter : 0);
|
||||
start_date -= order->GetTravelTime() + ((v->lateness_counter < 0) ? v->lateness_counter : 0);
|
||||
}
|
||||
|
||||
/* Loop through the vehicle's orders until we've found a suitable order or we've determined that no such order exists. */
|
||||
/* We only need to consider each order at most once. */
|
||||
for (int i = (*v)->GetNumOrders(); i > 0; --i) {
|
||||
if (VehicleSetNextDepartureTime(&start_date, &waiting_time, date_only_scaled, *v, order, status == D_ARRIVED, schdispatch_last_planned_dispatch)) {
|
||||
for (int i = v->GetNumOrders(); i > 0; --i) {
|
||||
if (VehicleSetNextDepartureTime(&start_date, &waiting_time, date_only_scaled, v, order, status == D_ARRIVED, schdispatch_last_planned_dispatch)) {
|
||||
should_reset_lateness = true;
|
||||
}
|
||||
|
||||
/* If the scheduled departure date is too far in the future, stop. */
|
||||
if (start_date - (*v)->lateness_counter > max_date) {
|
||||
if (start_date - v->lateness_counter > max_date) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (status != D_CANCELLED) {
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = (*v)->GetOrder(order->GetConditionSkipToOrder());
|
||||
order = v->GetOrder(order->GetConditionSkipToOrder());
|
||||
if (order == NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (status != D_CANCELLED) {
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
/* Skip it if it's an automatic order. */
|
||||
if (order->IsType(OT_IMPLICIT)) {
|
||||
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -368,10 +368,10 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
OrderDate *od = new OrderDate();
|
||||
od->order = order;
|
||||
od->v = *v;
|
||||
od->v = v;
|
||||
/* We store the expected date for now, so that vehicles will be shown in order of expected time. */
|
||||
od->expected_date = start_date;
|
||||
od->lateness = (*v)->lateness_counter > 0 ? (*v)->lateness_counter : 0;
|
||||
od->lateness = v->lateness_counter > 0 ? v->lateness_counter : 0;
|
||||
od->status = status;
|
||||
od->scheduled_waiting_time = waiting_time;
|
||||
|
||||
@@ -381,8 +381,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
/* If we are early, use the scheduled date as the expected date. We also take lateness to be zero. */
|
||||
if (!should_reset_lateness && (*v)->lateness_counter < 0 && !(*v)->current_order.IsAnyLoadingType()) {
|
||||
od->expected_date -= (*v)->lateness_counter;
|
||||
if (!should_reset_lateness && v->lateness_counter < 0 && !v->current_order.IsAnyLoadingType()) {
|
||||
od->expected_date -= v->lateness_counter;
|
||||
}
|
||||
|
||||
/* Update least_order if this is the current least order. */
|
||||
@@ -393,7 +393,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
least_order = od;
|
||||
}
|
||||
|
||||
*(next_orders.Append(1)) = od;
|
||||
next_orders.push_back(od);
|
||||
|
||||
/* We're done with this vehicle. */
|
||||
break;
|
||||
@@ -402,14 +402,14 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (status != D_CANCELLED) {
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* No suitable orders found? Then stop. */
|
||||
if (next_orders.Length() == 0) {
|
||||
if (next_orders.size() == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -418,15 +418,15 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
for(int i = 10000; i > 0; --i) {
|
||||
/* I should probably try to convince you that this loop always terminates regardless of the safeguard. */
|
||||
/* 1. next_orders contains at least one element. */
|
||||
/* 2. The loop terminates if result->Length() exceeds a fixed (for this loop) value, or if the least order's scheduled date is later than max_date. */
|
||||
/* 2. The loop terminates if result->size() exceeds a fixed (for this loop) value, or if the least order's scheduled date is later than max_date. */
|
||||
/* (We ignore the case that the least order's scheduled date has overflown, as it is a relative rather than absolute date.) */
|
||||
/* 3. Every time we loop round, either result->Length() will have increased -OR- we will have increased the expected_date of one of the elements of next_orders. */
|
||||
/* 3. Every time we loop round, either result->size() will have increased -OR- we will have increased the expected_date of one of the elements of next_orders. */
|
||||
/* 4. Therefore the loop must eventually terminate. */
|
||||
|
||||
/* least_order is the best candidate for the next departure. */
|
||||
|
||||
/* First, we check if we can stop looking for departures yet. */
|
||||
if (result->Length() >= _settings_client.gui.max_departures ||
|
||||
if (result->size() >= _settings_client.gui.max_departures ||
|
||||
least_order->expected_date - least_order->lateness > max_date) {
|
||||
break;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
/* If we reach the order at which the departure occurs again, then use the departure station as the terminus. */
|
||||
if (order == least_order->order) {
|
||||
/* If we're not calling anywhere, then skip this departure. */
|
||||
found_terminus = (d->calling_at.Length() > 0);
|
||||
found_terminus = (d->calling_at.size() > 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
order->GetNonStopType() != ONSF_NO_STOP_AT_ANY_STATION &&
|
||||
order->GetNonStopType() != ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||
/* If we're not calling anywhere, then skip this departure. */
|
||||
found_terminus = (d->calling_at.Length() > 0);
|
||||
found_terminus = (d->calling_at.size() > 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
/* If this order's station is already in the calling, then the previous called at station is the terminus. */
|
||||
if (d->calling_at.Contains(c)) {
|
||||
if (std::find(d->calling_at.begin(), d->calling_at.end(), c) != d->calling_at.end()) {
|
||||
found_terminus = true;
|
||||
break;
|
||||
}
|
||||
@@ -551,13 +551,13 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
d->via = (StationID)order->GetDestination();
|
||||
}
|
||||
d->terminus = c;
|
||||
*(d->calling_at.Append(1)) = c;
|
||||
d->calling_at.push_back(c);
|
||||
}
|
||||
|
||||
/* If we unload all at this station, then it is the terminus. */
|
||||
if (order->GetType() == OT_GOTO_STATION &&
|
||||
order->GetUnloadType() == OUFB_UNLOAD) {
|
||||
if (d->calling_at.Length() > 0) {
|
||||
if (d->calling_at.size() > 0) {
|
||||
found_terminus = true;
|
||||
}
|
||||
break;
|
||||
@@ -574,8 +574,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
bool duplicate = false;
|
||||
|
||||
if (_settings_client.gui.departure_merge_identical) {
|
||||
for (uint i = 0; i < result->Length(); ++i) {
|
||||
if (*d == **(result->Get(i))) {
|
||||
for (uint i = 0; i < result->size(); ++i) {
|
||||
if (*d == *((*result)[i])) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
@@ -583,17 +583,17 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
if (!duplicate) {
|
||||
*(result->Append(1)) = d;
|
||||
result->push_back(d);
|
||||
|
||||
if (_settings_client.gui.departure_smart_terminus && type == D_DEPARTURE) {
|
||||
for (uint i = 0; i < result->Length()-1; ++i) {
|
||||
Departure *d_first = *(result->Get(i));
|
||||
uint k = d_first->calling_at.Length()-2;
|
||||
for (uint j = d->calling_at.Length(); j > 0; --j) {
|
||||
CallAt c = CallAt(*(d->calling_at.Get(j-1)));
|
||||
for (uint i = 0; i < result->size() - 1; ++i) {
|
||||
Departure *d_first = (*result)[i];
|
||||
uint k = d_first->calling_at.size() - 2;
|
||||
for (uint j = d->calling_at.size(); j > 0; --j) {
|
||||
CallAt c = CallAt(d->calling_at[j - 1]);
|
||||
|
||||
if (d_first->terminus >= c && d_first->calling_at.Length() >= 2) {
|
||||
d_first->terminus = CallAt(*(d_first->calling_at.Get(k)));
|
||||
if (d_first->terminus >= c && d_first->calling_at.size() >= 2) {
|
||||
d_first->terminus = CallAt(d_first->calling_at[k]);
|
||||
|
||||
if (k == 0) break;
|
||||
|
||||
@@ -666,7 +666,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (order->GetType() == OT_GOTO_STATION &&
|
||||
(order->GetLoadType() != OLFB_NO_LOAD ||
|
||||
_settings_client.gui.departure_show_all_stops)) {
|
||||
*(d->calling_at.Append(1)) = CallAt((StationID)order->GetDestination());
|
||||
d->calling_at.push_back(CallAt((StationID)order->GetDestination()));
|
||||
}
|
||||
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
@@ -678,8 +678,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
bool duplicate = false;
|
||||
|
||||
if (_settings_client.gui.departure_merge_identical) {
|
||||
for (uint i = 0; i < result->Length(); ++i) {
|
||||
if (*d == **(result->Get(i))) {
|
||||
for (uint i = 0; i < result->size(); ++i) {
|
||||
if (*d == *((*result)[i])) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
@@ -687,7 +687,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
if (!duplicate) {
|
||||
*(result->Append(1)) = d;
|
||||
result->push_back(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -784,8 +784,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
/* Find the new least order. */
|
||||
for (uint i = 0; i < next_orders.Length(); ++i) {
|
||||
OrderDate *od = *(next_orders.Get(i));
|
||||
for (uint i = 0; i < next_orders.size(); ++i) {
|
||||
OrderDate *od = next_orders[i];
|
||||
|
||||
DateTicks lod = least_order->expected_date - least_order->lateness;
|
||||
DateTicks odd = od->expected_date - od->lateness;
|
||||
@@ -802,8 +802,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
/* Avoid leaking OrderDate structs */
|
||||
for (uint i = 0; i < next_orders.Length(); ++i) {
|
||||
OrderDate *od = *(next_orders.Get(i));
|
||||
for (uint i = 0; i < next_orders.size(); ++i) {
|
||||
OrderDate *od = next_orders[i];
|
||||
delete od;
|
||||
}
|
||||
|
||||
|
@@ -274,7 +274,7 @@ public:
|
||||
|
||||
id_v += this->vscroll->GetPosition();
|
||||
|
||||
if (id_v >= (this->departures->Length() + this->arrivals->Length())) return; // click out of list bound
|
||||
if (id_v >= (this->departures->size() + this->arrivals->size())) return; // click out of list bound
|
||||
|
||||
uint departure = 0;
|
||||
uint arrival = 0;
|
||||
@@ -283,9 +283,9 @@ public:
|
||||
for (uint i = 0; i <= id_v; ++i) {
|
||||
const Departure *d;
|
||||
|
||||
if (arrival == this->arrivals->Length()) {
|
||||
if (arrival == this->arrivals->size()) {
|
||||
d = (*(this->departures))[departure++];
|
||||
} else if (departure == this->departures->Length()) {
|
||||
} else if (departure == this->departures->size()) {
|
||||
d = (*(this->arrivals))[arrival++];
|
||||
} else {
|
||||
d = (*(this->departures))[departure];
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
this->EnableWidget(WID_DB_SHOW_DEPS);
|
||||
}
|
||||
|
||||
this->vscroll->SetCount(min(_settings_client.gui.max_departures, this->departures->Length() + this->arrivals->Length()));
|
||||
this->vscroll->SetCount(min(_settings_client.gui.max_departures, this->departures->size() + this->arrivals->size()));
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
@@ -485,18 +485,18 @@ uint DeparturesWindow<Twaypoint>::GetMinWidth() const
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||
SetDParam(0, (uint64)((*v)->index));
|
||||
for (const Vehicle *v : vehicles) {
|
||||
SetDParam(0, (uint64)(v->index));
|
||||
int width = (GetStringBoundingBox(STR_DEPARTURES_VEH)).width;
|
||||
if (_settings_client.gui.departure_show_vehicle && width > veh_width) veh_width = width;
|
||||
|
||||
if ((*v)->group_id != INVALID_GROUP && (*v)->group_id != DEFAULT_GROUP) {
|
||||
SetDParam(0, (uint64)((*v)->group_id));
|
||||
if (v->group_id != INVALID_GROUP && v->group_id != DEFAULT_GROUP) {
|
||||
SetDParam(0, (uint64)(v->group_id));
|
||||
width = (GetStringBoundingBox(STR_DEPARTURES_GROUP)).width;
|
||||
if (_settings_client.gui.departure_show_group && width > group_width) group_width = width;
|
||||
}
|
||||
|
||||
SetDParam(0, (uint64)((*v)->owner));
|
||||
SetDParam(0, (uint64)(v->owner));
|
||||
width = (GetStringBoundingBox(STR_DEPARTURES_TOC)).width;
|
||||
if (_settings_client.gui.departure_show_company && width > toc_width) toc_width = width;
|
||||
}
|
||||
@@ -515,13 +515,12 @@ template<bool Twaypoint>
|
||||
void DeparturesWindow<Twaypoint>::DeleteDeparturesList(DepartureList *list)
|
||||
{
|
||||
/* SmallVector uses free rather than delete on its contents (which doesn't invoke the destructor), so we need to delete each departure manually. */
|
||||
for (uint i = 0; i < list->Length(); ++i) {
|
||||
Departure **d = list->Get(i);
|
||||
for (uint i = 0; i < list->size(); ++i) {
|
||||
Departure **d = &(*list)[i];
|
||||
delete *d;
|
||||
/* Make sure a double free doesn't happen. */
|
||||
*d = NULL;
|
||||
}
|
||||
list->Reset();
|
||||
delete list;
|
||||
list = NULL;
|
||||
}
|
||||
@@ -543,7 +542,7 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
int text_right = right - (rtl ? text_offset : 0);
|
||||
|
||||
int y = r.top + 1;
|
||||
uint max_departures = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->departures->Length() + this->arrivals->Length());
|
||||
uint max_departures = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->departures->size() + this->arrivals->size());
|
||||
|
||||
if (max_departures > _settings_client.gui.max_departures) {
|
||||
max_departures = _settings_client.gui.max_departures;
|
||||
@@ -618,18 +617,18 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||
SetDParam(0, (uint64)((*v)->index));
|
||||
for (const Vehicle *v : vehicles) {
|
||||
SetDParam(0, (uint64)(v->index));
|
||||
int width = (GetStringBoundingBox(STR_DEPARTURES_VEH)).width;
|
||||
if (_settings_client.gui.departure_show_vehicle && width > veh_width) veh_width = width;
|
||||
|
||||
if ((*v)->group_id != INVALID_GROUP && (*v)->group_id != DEFAULT_GROUP) {
|
||||
SetDParam(0, (uint64)((*v)->group_id));
|
||||
if (v->group_id != INVALID_GROUP && v->group_id != DEFAULT_GROUP) {
|
||||
SetDParam(0, (uint64)(v->group_id));
|
||||
width = (GetStringBoundingBox(STR_DEPARTURES_GROUP)).width;
|
||||
if (_settings_client.gui.departure_show_group && width > group_width) group_width = width;
|
||||
}
|
||||
|
||||
SetDParam(0, (uint64)((*v)->owner));
|
||||
SetDParam(0, (uint64)(v->owner));
|
||||
width = (GetStringBoundingBox(STR_DEPARTURES_TOC)).width;
|
||||
if (_settings_client.gui.departure_show_company && width > toc_width) toc_width = width;
|
||||
}
|
||||
@@ -646,9 +645,9 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
for (uint i = 0; i < max_departures; ++i) {
|
||||
const Departure *d;
|
||||
|
||||
if (arrival == this->arrivals->Length()) {
|
||||
if (arrival == this->arrivals->size()) {
|
||||
d = (*(this->departures))[departure++];
|
||||
} else if (departure == this->departures->Length()) {
|
||||
} else if (departure == this->departures->size()) {
|
||||
d = (*(this->arrivals))[arrival++];
|
||||
} else {
|
||||
d = (*(this->departures))[departure];
|
||||
@@ -851,23 +850,23 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
/* STR_DEPARTURES_CALLING_AT_LAST_STATION :{STATION} & {RAW_STRING}*/
|
||||
char buffer[512], scratch[512];
|
||||
|
||||
if (d->calling_at.Length() != 0) {
|
||||
SetDParam(0, (uint64)(*d->calling_at.Get(0)).station);
|
||||
if (d->calling_at.size() != 0) {
|
||||
SetDParam(0, (uint64)(d->calling_at[0]).station);
|
||||
GetString(scratch, STR_DEPARTURES_CALLING_AT_FIRST_STATION, lastof(scratch));
|
||||
|
||||
StationID continuesTo = INVALID_STATION;
|
||||
|
||||
if (d->calling_at.Get(0)->station == d->terminus.station && d->calling_at.Length() > 1) {
|
||||
continuesTo = d->calling_at.Get(d->calling_at.Length() - 1)->station;
|
||||
} else if (d->calling_at.Length() > 1) {
|
||||
if (d->calling_at[0].station == d->terminus.station && d->calling_at.size() > 1) {
|
||||
continuesTo = d->calling_at[d->calling_at.size() - 1].station;
|
||||
} else if (d->calling_at.size() > 1) {
|
||||
/* There's more than one stop. */
|
||||
|
||||
uint i;
|
||||
/* For all but the last station, write out ", <station>". */
|
||||
for (i = 1; i < d->calling_at.Length() - 1; ++i) {
|
||||
StationID s = d->calling_at.Get(i)->station;
|
||||
for (i = 1; i < d->calling_at.size() - 1; ++i) {
|
||||
StationID s = d->calling_at[i].station;
|
||||
if (s == d->terminus.station) {
|
||||
continuesTo = d->calling_at.Get(d->calling_at.Length() - 1)->station;
|
||||
continuesTo = d->calling_at[d->calling_at.size() - 1].station;
|
||||
break;
|
||||
}
|
||||
SetDParam(0, (uint64)scratch);
|
||||
@@ -878,7 +877,7 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
|
||||
/* Finally, finish off with " and <station>". */
|
||||
SetDParam(0, (uint64)scratch);
|
||||
SetDParam(1, (uint64)d->calling_at.Get(i)->station);
|
||||
SetDParam(1, (uint64)d->calling_at[i].station);
|
||||
GetString(buffer, STR_DEPARTURES_CALLING_AT_LAST_STATION, lastof(buffer));
|
||||
strncpy(scratch, buffer, sizeof(scratch));
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ typedef enum {
|
||||
D_ARRIVAL = 1,
|
||||
} DepartureType;
|
||||
|
||||
typedef struct CallAt {
|
||||
struct CallAt {
|
||||
StationID station;
|
||||
DateTicks scheduled_date;
|
||||
|
||||
@@ -61,31 +61,27 @@ typedef struct CallAt {
|
||||
inline bool operator==(StationID s) const {
|
||||
return this->station == s;
|
||||
}
|
||||
} CallAt;
|
||||
};
|
||||
|
||||
/** A scheduled departure. */
|
||||
typedef struct Departure {
|
||||
struct Departure {
|
||||
DateTicksScaled scheduled_date; ///< The date this departure is scheduled to finish on (i.e. when the vehicle leaves the station)
|
||||
Ticks lateness; ///< How delayed the departure is expected to be
|
||||
CallAt terminus; ///< The station at which the vehicle will terminate following this departure
|
||||
StationID via; ///< The station the departure should list as going via
|
||||
SmallVector<CallAt, 32> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
|
||||
std::vector<CallAt> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
|
||||
DepartureStatus status; ///< Whether the vehicle has arrived yet for this departure
|
||||
DepartureType type; ///< The type of the departure (departure or arrival)
|
||||
const Vehicle *vehicle; ///< The vehicle performing this departure
|
||||
const Order *order; ///< The order corresponding to this departure
|
||||
uint scheduled_waiting_time; ///< Scheduled waiting time if scheduled dispatch is used
|
||||
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), calling_at(), vehicle(NULL) { }
|
||||
~Departure()
|
||||
{
|
||||
calling_at.Reset();
|
||||
}
|
||||
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), vehicle(NULL), order(NULL) { }
|
||||
|
||||
inline bool operator==(const Departure& d) const {
|
||||
if (this->calling_at.Length() != d.calling_at.Length()) return false;
|
||||
if (this->calling_at.size() != d.calling_at.size()) return false;
|
||||
|
||||
for (uint i = 0; i < this->calling_at.Length(); ++i) {
|
||||
if (*(this->calling_at.Get(i)) != *(d.calling_at.Get(i))) return false;
|
||||
for (uint i = 0; i < this->calling_at.size(); ++i) {
|
||||
if (this->calling_at[i] != d.calling_at[i]) return false;
|
||||
}
|
||||
|
||||
return
|
||||
@@ -95,8 +91,8 @@ typedef struct Departure {
|
||||
this->type == d.type
|
||||
;
|
||||
}
|
||||
} Departure;
|
||||
};
|
||||
|
||||
typedef SmallVector<Departure*, 32> DepartureList;
|
||||
typedef std::vector<Departure*> DepartureList;
|
||||
|
||||
#endif /* DEPARTURES_TYPE_H */
|
||||
|
@@ -366,7 +366,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;
|
||||
|
||||
@@ -400,7 +400,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(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++) {
|
||||
@@ -415,16 +415,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(this->vehicle_list.size() + 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;
|
||||
|
||||
@@ -467,7 +467,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 */
|
||||
@@ -480,12 +480,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 -= this->vehicle_list.size();
|
||||
*veh = this->wagon_list[pos];
|
||||
/* free wagons don't have an initial loco. */
|
||||
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
@@ -652,7 +652,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: {
|
||||
@@ -703,12 +703,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
|
||||
@@ -728,7 +728,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();
|
||||
@@ -736,11 +736,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(this->vehicle_list.size() + 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(this->vehicle_list.size(), this->num_columns));
|
||||
}
|
||||
|
||||
/* Setup disabled buttons. */
|
||||
@@ -760,7 +760,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
|
||||
@@ -813,7 +813,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;
|
||||
|
||||
@@ -839,7 +839,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
|
||||
@@ -847,7 +847,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;
|
||||
|
||||
@@ -908,7 +908,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 */
|
||||
@@ -924,7 +924,7 @@ struct DepotWindow : Window {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObjectAbort()
|
||||
void OnPlaceObjectAbort() override
|
||||
{
|
||||
/* abort clone */
|
||||
this->RaiseWidget(WID_D_CLONE);
|
||||
@@ -942,7 +942,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) {
|
||||
@@ -994,7 +994,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: {
|
||||
@@ -1049,7 +1049,7 @@ struct DepotWindow : Window {
|
||||
_cursor.vehchain = false;
|
||||
}
|
||||
|
||||
virtual void OnTimeout()
|
||||
void OnTimeout() override
|
||||
{
|
||||
if (!this->IsWidgetDisabled(WID_D_SELL)) {
|
||||
this->RaiseWidget(WID_D_SELL);
|
||||
@@ -1061,7 +1061,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_D_MATRIX);
|
||||
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_D_MATRIX);
|
||||
@@ -1072,7 +1072,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual EventState OnCTRLStateChange()
|
||||
EventState OnCTRLStateChange() override
|
||||
{
|
||||
if (this->sel != INVALID_VEHICLE) {
|
||||
_cursor.vehchain = _ctrl_pressed;
|
||||
|
@@ -114,7 +114,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;
|
||||
|
||||
@@ -130,7 +130,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
|
||||
@@ -174,7 +174,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
|
||||
@@ -223,12 +223,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) {
|
||||
@@ -247,7 +247,7 @@ struct BuildDocksToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPlaceObjectAbort()
|
||||
void OnPlaceObjectAbort() override
|
||||
{
|
||||
this->RaiseButtons();
|
||||
|
||||
@@ -257,7 +257,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;
|
||||
|
||||
@@ -412,7 +412,7 @@ public:
|
||||
DeleteWindowById(WC_SELECT_STATION, 0);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
|
||||
rad += _settings_game.station.catchment_increase;
|
||||
@@ -440,7 +440,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:
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
CheckRedrawStationCoverage(this);
|
||||
}
|
||||
@@ -508,7 +508,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:
|
||||
@@ -519,7 +519,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
this->DrawWidgets();
|
||||
|
||||
@@ -534,7 +534,7 @@ public:
|
||||
DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + x1, this->GetWidget<NWidgetBase>(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:
|
||||
|
@@ -81,7 +81,7 @@ static inline int32 BigMulS(const int32 a, const int32 b, const uint8 shift)
|
||||
return (int32)((int64)a * (int64)b >> shift);
|
||||
}
|
||||
|
||||
typedef SmallVector<Industry *, 16> SmallIndustryList;
|
||||
typedef std::vector<Industry *> SmallIndustryList;
|
||||
|
||||
/**
|
||||
* Score info, values used for computing the detailed performance rating.
|
||||
@@ -264,7 +264,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<int64>(_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;
|
||||
}
|
||||
@@ -296,10 +296,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<CompanyByte> 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. */
|
||||
@@ -1092,7 +1090,7 @@ 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;
|
||||
@@ -2166,11 +2164,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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -497,14 +497,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,12 +521,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;
|
||||
}
|
||||
@@ -557,15 +558,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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -157,7 +157,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<EngineIDMapping, 256> {
|
||||
struct EngineOverrideManager : std::vector<EngineIDMapping> {
|
||||
static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries
|
||||
|
||||
void ResetToDefaultMapping();
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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();
|
||||
uint 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);
|
||||
}
|
||||
|
||||
|
@@ -183,7 +183,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: {
|
||||
@@ -213,7 +213,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) {
|
||||
@@ -249,18 +249,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: {
|
||||
@@ -312,13 +312,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) {
|
||||
@@ -333,7 +333,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;
|
||||
|
@@ -1000,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 {
|
||||
@@ -1056,7 +1052,7 @@ void DetermineBasePaths(const char *exe)
|
||||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
_searchpaths[SP_PERSONAL_DIR_XDG] = stredup(tmp);
|
||||
#endif
|
||||
#if defined(DOS) || defined(OS2) || !defined(WITH_PERSONAL_DIR)
|
||||
#if defined(OS2) || !defined(WITH_PERSONAL_DIR)
|
||||
_searchpaths[SP_PERSONAL_DIR] = NULL;
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
@@ -1244,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 */
|
||||
@@ -1257,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 */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
|
||||
|
30
src/fios.cpp
30
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 <sys/stat.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -274,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;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -378,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;
|
||||
}
|
||||
|
||||
@@ -632,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).
|
||||
@@ -657,7 +655,7 @@ struct ScenarioIdentifier {
|
||||
/**
|
||||
* Scanner to find the unique IDs of scenarios
|
||||
*/
|
||||
class ScenarioScanner : protected FileScanner, public SmallVector<ScenarioIdentifier, 8> {
|
||||
class ScenarioScanner : protected FileScanner, public std::vector<ScenarioIdentifier> {
|
||||
bool scanned; ///< Whether we've already scanned
|
||||
public:
|
||||
/** Initialise */
|
||||
@@ -675,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;
|
||||
@@ -708,7 +706,7 @@ public:
|
||||
|
||||
FioFCloseFile(f);
|
||||
|
||||
this->Include(id);
|
||||
include(*this, id);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -726,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,5 +752,3 @@ void ScanScenarios()
|
||||
{
|
||||
_scanner.Scan(true);
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
19
src/fios.h
19
src/fios.h
@@ -122,7 +122,8 @@ public:
|
||||
*/
|
||||
inline FiosItem *Append()
|
||||
{
|
||||
return this->files.Append();
|
||||
/*C++17: return &*/ this->files.emplace_back();
|
||||
return &this->files.back();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +132,7 @@ public:
|
||||
*/
|
||||
inline uint Length() const
|
||||
{
|
||||
return this->files.Length();
|
||||
return this->files.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +141,7 @@ public:
|
||||
*/
|
||||
inline const FiosItem *Begin() const
|
||||
{
|
||||
return this->files.Begin();
|
||||
return this->files.data();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +150,7 @@ public:
|
||||
*/
|
||||
inline const FiosItem *End() const
|
||||
{
|
||||
return this->files.End();
|
||||
return this->Begin() + this->Length();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +159,7 @@ public:
|
||||
*/
|
||||
inline const FiosItem *Get(uint index) const
|
||||
{
|
||||
return this->files.Get(index);
|
||||
return this->files.data() + index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +168,7 @@ public:
|
||||
*/
|
||||
inline FiosItem *Get(uint index)
|
||||
{
|
||||
return this->files.Get(index);
|
||||
return this->files.data() + index;
|
||||
}
|
||||
|
||||
inline const FiosItem &operator[](uint index) const
|
||||
@@ -187,19 +188,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<FiosItem, 32> files; ///< The list of files.
|
||||
std::vector<FiosItem> files; ///< The list of files.
|
||||
};
|
||||
|
||||
enum SortingBits {
|
||||
|
@@ -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;
|
||||
@@ -281,7 +280,7 @@ private:
|
||||
|
||||
StringFilter string_filter; ///< Filter for available games.
|
||||
QueryString filter_editbox; ///< Filter editbox;
|
||||
SmallVector<bool, 32> fios_items_shown; ///< Map of the filtered out fios items
|
||||
std::vector<bool> fios_items_shown; ///< Map of the filtered out fios items
|
||||
|
||||
static void SaveGameConfirmationCallback(Window *w, bool confirmed)
|
||||
{
|
||||
@@ -409,7 +408,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:
|
||||
@@ -439,12 +438,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);
|
||||
@@ -541,10 +543,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);
|
||||
@@ -563,7 +564,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:
|
||||
@@ -585,7 +586,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
if (_savegame_sort_dirty) {
|
||||
_savegame_sort_dirty = false;
|
||||
@@ -596,7 +597,7 @@ public:
|
||||
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
|
||||
@@ -647,9 +648,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;
|
||||
|
||||
@@ -711,14 +710,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;
|
||||
|
||||
@@ -732,7 +729,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(WChar key, uint16 keycode)
|
||||
EventState OnKeyPress(WChar key, uint16 keycode) override
|
||||
{
|
||||
if (keycode == WKC_ESC) {
|
||||
delete this;
|
||||
@@ -742,7 +739,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;
|
||||
@@ -783,7 +780,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SL_DRIVES_DIRECTORIES_LIST);
|
||||
}
|
||||
@@ -793,7 +790,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:
|
||||
@@ -844,7 +841,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++) {
|
||||
@@ -871,7 +868,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);
|
||||
|
@@ -417,8 +417,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,7 +639,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;
|
||||
}
|
||||
|
@@ -432,7 +432,7 @@ struct FramerateWindow : Window {
|
||||
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);
|
||||
|
||||
@@ -475,7 +475,7 @@ struct FramerateWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_FRW_CAPTION:
|
||||
@@ -503,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:
|
||||
@@ -582,7 +582,7 @@ struct FramerateWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
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: {
|
||||
@@ -621,7 +621,7 @@ 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:
|
||||
@@ -646,7 +646,7 @@ struct FramerateWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
auto *wid = this->GetWidget<NWidgetResizeBase>(WID_FRW_TIMES_NAMES);
|
||||
this->num_displayed = (wid->current_y - wid->min_y - VSPACING) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
|
||||
@@ -694,7 +694,7 @@ struct FrametimeGraphWindow : Window {
|
||||
this->InitNested(number);
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_FGW_CAPTION:
|
||||
@@ -709,7 +709,7 @@ struct FrametimeGraphWindow : 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_FGW_GRAPH) {
|
||||
SetDParam(0, 100);
|
||||
@@ -807,7 +807,7 @@ struct FrametimeGraphWindow : Window {
|
||||
this->SelectVerticalScale(peak_value);
|
||||
}
|
||||
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
this->SetDirty();
|
||||
|
||||
@@ -826,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;
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -257,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)
|
||||
@@ -275,8 +273,6 @@
|
||||
return Game::scanner_library->HasScript(ci, md5sum);
|
||||
}
|
||||
|
||||
#endif /* defined(ENABLE_NETWORK) */
|
||||
|
||||
/* static */ GameScannerInfo *Game::GetScannerInfo()
|
||||
{
|
||||
return Game::scanner_info;
|
||||
|
@@ -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.
|
||||
|
@@ -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 */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user