diff --git a/Doxyfile b/Doxyfile index b6b46257a7..5677118c54 100644 --- a/Doxyfile +++ b/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 \ diff --git a/Makefile.bundle.in b/Makefile.bundle.in index e7101253d9..29f94a09ee 100644 --- a/Makefile.bundle.in +++ b/Makefile.bundle.in @@ -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 ### diff --git a/Makefile.src.in b/Makefile.src.in index 29d551c22b..01c298d9ba 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -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 diff --git a/README.md b/README.md index 77803e3acd..2ea90cf3fd 100644 --- a/README.md +++ b/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 diff --git a/azure-pipelines/templates/windows-dependencies.yml b/azure-pipelines/templates/windows-dependencies.yml index c6fc6e407c..72368b9d71 100644 --- a/azure-pipelines/templates/windows-dependencies.yml +++ b/azure-pipelines/templates/windows-dependencies.yml @@ -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' diff --git a/bin/ai/regression/tst_regression/main.nut b/bin/ai/regression/tst_regression/main.nut index 7315f33f82..baece09d08 100644 --- a/bin/ai/regression/tst_regression/main.nut +++ b/bin/ai/regression/tst_regression/main.nut @@ -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()); diff --git a/bin/ai/regression/tst_regression/result.txt b/bin/ai/regression/tst_regression/result.txt index e93b2e2343..cda888d297 100644 --- a/bin/ai/regression/tst_regression/result.txt +++ b/bin/ai/regression/tst_regression/result.txt @@ -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 diff --git a/config.lib b/config.lib index 58263579a8..a74727c171 100644 --- a/config.lib +++ b/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: 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 " diff --git a/configure b/configure index f6c6a2eec9..7a13a96c88 100755 --- a/configure +++ b/configure @@ -75,7 +75,7 @@ save_params make_cflags_and_ldflags EXE="" -if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ] || [ "$os" = "DOS" ]; then +if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ]; then EXE=".exe" fi @@ -116,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; } diff --git a/os/dos/cwsdpmi/README.licensing b/os/dos/cwsdpmi/README.licensing deleted file mode 100644 index 112b02a087..0000000000 --- a/os/dos/cwsdpmi/README.licensing +++ /dev/null @@ -1,3 +0,0 @@ -The files in this directory are not licensed under the same terms as the -rest of OpenTTD. Licensing details can be found in OpenTTD's readme.txt -and in this directory or subdirectories as well. diff --git a/os/dos/cwsdpmi/cwsdpmi.exe b/os/dos/cwsdpmi/cwsdpmi.exe deleted file mode 100644 index 17e3220023..0000000000 Binary files a/os/dos/cwsdpmi/cwsdpmi.exe and /dev/null differ diff --git a/os/dos/cwsdpmi/cwsdpmi.txt b/os/dos/cwsdpmi/cwsdpmi.txt deleted file mode 100644 index 14b09c4d76..0000000000 --- a/os/dos/cwsdpmi/cwsdpmi.txt +++ /dev/null @@ -1,173 +0,0 @@ -CWSDPMI is Copyright (C) 1995-2000 Charles W Sandmann (sandmann@clio.rice.edu) - 1206 Braelinn, Sugar Land, TX 77479 - -This is release 5. The files in this binary distribution may be redistributed -under the GPL (with source) or without the source code provided: - -* CWSDPMI.EXE or CWSDPR0.EXE are not modified in any way except via CWSPARAM. - -* CWSDSTUB.EXE internal contents are not modified in any way except via - CWSPARAM or STUBEDIT. It may have a COFF image plus data appended to it. - -* Notice to users that they have the right to receive the source code and/or - binary updates for CWSDPMI. Distributors should indicate a site for the - source in their documentation. - -------------------------------------------------------------------------------- - -CWSDPMI was written to provide DPMI services for V2 of DJGPP. It currently -does not support 16-bit DPMI applications, or DPMI applications requiring a -built in extender. It does support virtual memory and hardware interrupt -reflection from real mode to protected mode. DJGPP V1.1x and RSX applications -will also run using this server, which can be used to provide enhanced control -over hardware interrupts. Some DPMI 1.0 extensions (0x506, 0x507, 0x508) have -been implemented. - -CWSDPR0.EXE is an alternate version which runs at ring 0 with virtual memory -disabled. It may be used if access to ring-0 features are desired. It -currently does not switch stacks on HW interrupts, so some DJGPP features -such as SIGINT and SIGFPE are not supported and will generate a double fault -or stack fault error (to be fixed someday). - -CWSDSTUB.EXE is a stub loader image for DJGPP which includes CWSDPMI. This -allows single executable image distributions. You can use the EXE2COFF -program and COPY /B CWSDSTUB.EXE+yourimage yourimage.exe to create a -standalone executable image. - -Some of the internal tuning and configuration parameters may be modified -in the image using CWSPARAM.EXE (see CWSPARAM.DOC). - -If you want to use CWSDPMI with DJGPP, you expand the distribution into the -DJGPP directory tree. CWSDPMI.EXE will be put in the BIN directory with your -DJGPP images and it will automatically be loaded when they run. - -Directions for use (server can be used in either of two different ways): - -1) "cwsdpmi" alone with no parameters will terminate and stay resident - FOR A SINGLE DPMI PROCESS. This means it unloads itself when your - DPMI application exits. This mode is useful in software which needs - DPMI services, since CWSDPMI can be exec'ed and then will unload on exit. - -2) "cwsdpmi -p" will terminate and stay resident until you remove it. - It can be loaded into UMBs with LH. "cwsdpmi -u" will unload the TSR. - -3) The file used for virtual memory swapping, if desired, is controlled - by the "-sc:\cwsdpmi.swp" syntax on the command line. You must specify - either a file with full disk/directory syntax, or "-s-" which disables - virtual memory. - -4) The default swap file name is c:\cwsdpmi.swp, but this can be changed - with the CWSPARAM image, as can some other parameters. - -5) You can disable the DPMI 1.0 extensions by starting the image with the - "cwsdpmi -x" syntax. This feature allows you to run programs developed - under other DPMI providers which do not behave properly with these - extensions enabled (typically use of NULL pointers). - -I would like to give special thanks to DJ Delorie who wrote the original -GO32 code on which CWSDPMI is based. Morten Welinder also provided and -improved much of the code in this program. - -------------------------------------------------------------------------------- - -This section contains a list of the error messages you might see out of -CWSDPMI and some details on what they mean. - -Exceptions are only handled by CWSDPMI if the application does not establish -an exception handler, exceptions nest 5 deep, or the error is particularly bad: - -"Page fault" - - 1) an illegal page fault happens in a RMCB or HW interrupt, (lock all pages!) - 2) all available pages have been locked, - 3) the application is using non-committed pages for null pointer protection. -"Double Fault" - multiple exceptions occurred -"Invalid TSS" - typically due to RMCB or HW interrupt being called after the - selectors/memory have been deallocated (remember to reset the mouse) -"General Protection Fault" - bad parameter sent to a DPMI call - -"80386 required." - -Since 80286 and lesser processors don't have the hardware necessary to -run CWSDPMI. No workaround, upgrade. - -"DOS 3 required." - -A few interrupts are used which need DOS 3.0 or higher. I don't expect to -ever see this message, since 80386 machines were introduced after DOS 3.0 -and that check is made first. - -"CWSDPMI V0.90+ (r5) Copyright (C) 2000 CW Sandmann ABSOLUTELY NO WARRANTY" - -An informational message displayed if the program is not run in one-pass mode. - -"Protected mode not accessible." - -This message should only be displayed if running CWSDPMI in a protected -environment with no access to protected mode. In this case, DPMI should -already be available and CWSDPMI would not be needed. This might happen if -a 16-bit DPMI client is loaded and a DJGPP image attempts to load CWSDPMI -to provide 32-bit DPMI services under Windows. - -"Warning: cannot open swap file c:\cwsdpmi.swp" - -Maybe you are out of file handles, or the swap file name is incorrectly -specified in the image (change the name with cwsparam). - -"No swap space!" - -This message means you tried to use more paging file than CWSDPMI was -configured to handle. Since this is protected against in the memory -allocation code, you should never see this message. - -"Swap disk full!" - -This means the paging file could not be expanded when trying to page -memory out to disk. This would normally not be seen, unless you are -writing output to the same disk which holds the paging file. Decrease -the amount of memory your DPMI application is using or free up disk space. - -"Interrupt 0x??" - -Your application tried to call an interrupt from protected mode which -normally shouldn't be called (something like a data pointer). If the -request was allowed to continue it would likely hang your machine. If you -see this message and think the interrupt should be allowed to continue, let -me know. - -"Error: Using XMS switched CPU into V86 mode." - -This message might be seen if you have your memory manager in AUTO mode. The -only workaround in this case is to stop using AUTO mode. - -"Error: could not allocate page table memory" - -The page table memory (a minimum of 16Kb) is allocated from conventional -memory (either in the 640Kb region or UMBs). If CWSDPMI cannot allocate the -minimum necessary memory, you would see this message. Free up some -conventional memory. You may also see this message if a page directory needs -to be faulted in, and there are no available pages. This means too many pages -have been locked for the allocated page tables available. While CWSDPMI -tries to dynamically allocate these if needed, this effort failed. You need -to increase the number of page tables with CWSPARAM, or increase the amount -of free conventional memory if it is low. If the application which calls -CWSDPMI internally manages all the DOS memory, the page tables may need to -be pre-allocated at DPMI startup time (if this is needed, try using the -run option flag 2 in cwsparam). - -"16-bit DPMI unsupported." - -CWSDPMI is a 32-bit only DPMI server. Ideally, on the request to enter DPMI's -PM with a 16-bit request, we would just fail the call setting the carry bit -like the DPMI specification describes. Some buggy 16-bit compiler tools don't -check the return status and will hang the machine in this case. So, I issue -an error message and exit the image instead. - -"Descriptors exhausted." - -An attempt to nest a DPMI client failed in the setup phase due to insufficient -free selectors in the LDT. - -"CWSDPMI not removed" - -When the -u parameter is specified, if DPMI is not detected this message is -printed. Informational. diff --git a/os/dos/cwsdpmi/cwsdstub.exe b/os/dos/cwsdpmi/cwsdstub.exe deleted file mode 100644 index fabaf3bf4f..0000000000 Binary files a/os/dos/cwsdpmi/cwsdstub.exe and /dev/null differ diff --git a/os/dos/exe2coff/README.licensing b/os/dos/exe2coff/README.licensing deleted file mode 100644 index 112b02a087..0000000000 --- a/os/dos/exe2coff/README.licensing +++ /dev/null @@ -1,3 +0,0 @@ -The files in this directory are not licensed under the same terms as the -rest of OpenTTD. Licensing details can be found in OpenTTD's readme.txt -and in this directory or subdirectories as well. diff --git a/os/dos/exe2coff/copying b/os/dos/exe2coff/copying deleted file mode 100644 index a43ea2126f..0000000000 --- a/os/dos/exe2coff/copying +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/os/dos/exe2coff/copying.dj b/os/dos/exe2coff/copying.dj deleted file mode 100644 index 8a55047845..0000000000 --- a/os/dos/exe2coff/copying.dj +++ /dev/null @@ -1,48 +0,0 @@ -This is the file "copying.dj". It does NOT apply to any sources or -binaries copyrighted by UCB Berkeley, the Free Software Foundation, or -any other agency besides DJ Delorie and others who have agreed to -allow their sources to be distributed under these terms. - - Copyright Information for sources and executables that are marked - Copyright (C) DJ Delorie - 7 Kim Lane - Rochester NH 03867-2954 - -This document is Copyright (C) DJ Delorie and may be distributed -verbatim, but changing it is not allowed. - -Source code copyright DJ Delorie is distributed under the terms of the -GNU General Public Licence, with the following exceptions: - -* Sources used to build crt0.o, gcrt0.o, libc.a, libdbg.a, and - libemu.a are distributed under the terms of the GNU Library General - Public License, rather than the GNU GPL. - -* Any existing copyright or authorship information in any given source - file must remain intact. If you modify a source file, a notice to that - effect must be added to the authorship information in the source file. - -* Runtime binaries, as provided by DJ in DJGPP, may be distributed - without sources ONLY if the recipient is given sufficient information - to obtain a copy of djgpp themselves. This primarily applies to - go32-v2.exe, emu387.dxe, and stubedit.exe. - -* Runtime objects and libraries, as provided by DJ in DJGPP, when - linked into an application, may be distributed without sources ONLY - if the recipient is given sufficient information to obtain a copy of - djgpp themselves. This primarily applies to crt0.o and libc.a. - ------ - -Changes to source code copyright BSD, FSF, or others, by DJ Delorie -fall under the terms of the original copyright. Such files usually -have multiple copyright notices in them. - -A copy of the files "COPYING" and "COPYING.LIB" are included with this -document. If you did not receive a copy of these files, you may -obtain one from whence this document was obtained, or by writing: - - Free Software Foundation - 59 Temple Place - Suite 330 - Boston, MA 02111-1307 - USA diff --git a/os/dos/exe2coff/copying.lib b/os/dos/exe2coff/copying.lib deleted file mode 100644 index bbe3fe1987..0000000000 --- a/os/dos/exe2coff/copying.lib +++ /dev/null @@ -1,481 +0,0 @@ - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/os/dos/exe2coff/exe2coff.c b/os/dos/exe2coff/exe2coff.c deleted file mode 100644 index aa072e8e41..0000000000 --- a/os/dos/exe2coff/exe2coff.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* Updated 2008 to use fread/fopen and friends instead of read/open so it compiles with GCC on Unix (Rubidium) */ -#include -#include -#include -#include -#include -#include -#include - - -static void -exe2aout(char *fname) -{ - unsigned short header[3]; - FILE *ifile; - FILE *ofile; - char buf[4096]; - int rbytes; - char *dot = strrchr(fname, '.'); - if (!dot || strlen(dot) != 4 - || tolower(dot[1]) != 'e' - || tolower(dot[2]) != 'x' - || tolower(dot[3]) != 'e') - { - fprintf(stderr, "%s: Arguments MUST end with a .exe extension\n", fname); - return; - } - - ifile = fopen(fname, "rb"); - if (!ifile) - { - perror(fname); - return; - } - fread(header, sizeof(header), 1, ifile); - if (header[0] == 0x5a4d) - { - long header_offset = (long)header[2]*512L; - if (header[1]) - header_offset += (long)header[1] - 512L; - fseek(ifile, header_offset, SEEK_SET); - header[0] = 0; - fread(header, sizeof(header), 1, ifile); - if ((header[0] != 0x010b) && (header[0] != 0x014c)) - { - fprintf(stderr, "`%s' does not have a COFF/AOUT program appended to it\n", fname); - return; - } - fseek(ifile, header_offset, SEEK_SET); - } - else - { - fprintf(stderr, "`%s' is not an .EXE file\n", fname); - return; - } - - *dot = 0; - ofile = fopen(fname, "w+b"); - if (!ofile) - { - perror(fname); - return; - } - - while ((rbytes=fread(buf, 1, 4096, ifile)) > 0) - { - int wb = fwrite(buf, 1, rbytes, ofile); - if (wb < 0) - { - perror(fname); - break; - } - if (wb < rbytes) - { - fprintf(stderr, "`%s': disk full\n", fname); - exit(1); - } - } - fclose(ifile); - fclose(ofile); -} - -int -main(int argc, char **argv) -{ - int i; - if (argc == 1) printf("Usage: %s ", argv[0]); - for (i=1; i binary.exe || exit -mv binary.exe $1 -rm binary exe2coff/exe2coff diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj index 654b6d1ca8..95611a60a5 100644 --- a/projects/openttd_vs140.vcxproj +++ b/projects/openttd_vs140.vcxproj @@ -1346,8 +1346,6 @@ - - diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters index 1c92bdfa55..67311daee0 100644 --- a/projects/openttd_vs140.vcxproj.filters +++ b/projects/openttd_vs140.vcxproj.filters @@ -3129,12 +3129,6 @@ Pathfinder - - Pathfinder - - - Pathfinder - Pathfinder diff --git a/projects/openttd_vs141.vcxproj b/projects/openttd_vs141.vcxproj index ca0b604ca9..3d3c92b2d0 100644 --- a/projects/openttd_vs141.vcxproj +++ b/projects/openttd_vs141.vcxproj @@ -1346,8 +1346,6 @@ - - diff --git a/projects/openttd_vs141.vcxproj.filters b/projects/openttd_vs141.vcxproj.filters index 1c92bdfa55..67311daee0 100644 --- a/projects/openttd_vs141.vcxproj.filters +++ b/projects/openttd_vs141.vcxproj.filters @@ -3129,12 +3129,6 @@ Pathfinder - - Pathfinder - - - Pathfinder - Pathfinder diff --git a/projects/openttd_vs142.vcxproj b/projects/openttd_vs142.vcxproj index b977a2502d..89dd51ee6b 100644 --- a/projects/openttd_vs142.vcxproj +++ b/projects/openttd_vs142.vcxproj @@ -1346,8 +1346,6 @@ - - diff --git a/projects/openttd_vs142.vcxproj.filters b/projects/openttd_vs142.vcxproj.filters index 1c92bdfa55..67311daee0 100644 --- a/projects/openttd_vs142.vcxproj.filters +++ b/projects/openttd_vs142.vcxproj.filters @@ -3129,12 +3129,6 @@ Pathfinder - - Pathfinder - - - Pathfinder - Pathfinder diff --git a/source.list b/source.list index 8db7fb9f8b..93d9ef6a07 100644 --- a/source.list +++ b/source.list @@ -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 diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp index 1b5b6c07da..bd9544b9f3 100644 --- a/src/ai/ai.hpp +++ b/src/ai/ai.hpp @@ -164,11 +164,9 @@ public: /** Gets the ScriptScanner instance that is used to find AI Libraries */ static AIScannerLibrary *GetScannerLibrary(); -#if defined(ENABLE_NETWORK) /** Wrapper function for AIScanner::HasAI */ static bool HasAI(const struct ContentInfo *ci, bool md5sum); static bool HasAILibrary(const ContentInfo *ci, bool md5sum); -#endif private: static uint frame_counter; ///< Tick counter for the AI code static class AIScannerInfo *scanner_info; ///< ScriptScanner instance that is used to find AIs diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp index 30c6f84bbd..9f667a6127 100644 --- a/src/ai/ai_config.hpp +++ b/src/ai/ai_config.hpp @@ -30,9 +30,9 @@ public: class AIInfo *GetInfo() const; - /* virtual */ int GetSetting(const char *name) const; - /* virtual */ void SetSetting(const char *name, int value); - /* virtual */ void AddRandomDeviation(); + int GetSetting(const char *name) const override; + void SetSetting(const char *name, int value) override; + void AddRandomDeviation() override; /** * When ever the AI Scanner is reloaded, all infos become invalid. This @@ -45,9 +45,9 @@ public: bool ResetInfo(bool force_exact_match); protected: - /* virtual */ void PushExtraConfigList(); - /* virtual */ void ClearConfigList(); - /* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match); + void PushExtraConfigList() override; + void ClearConfigList() override; + ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override; }; #endif /* AI_CONFIG_HPP */ diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 51522edaff..ff2fc286a0 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -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; diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 73806da15e..8b00de988e 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -98,7 +98,7 @@ struct AIListWindow : public Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_AIL_CAPTION: @@ -107,7 +107,7 @@ struct AIListWindow : public Window { } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_AIL_LIST) { this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; @@ -118,7 +118,7 @@ struct AIListWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_AIL_LIST: { @@ -183,7 +183,7 @@ struct AIListWindow : public Window { DeleteWindowByClass(WC_QUERY_STRING); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_AIL_LIST: { // Select one of the AIs @@ -211,7 +211,7 @@ struct AIListWindow : public Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_AIL_LIST); } @@ -221,7 +221,7 @@ struct AIListWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) { delete this; @@ -317,7 +317,7 @@ struct AISettingsWindow : public Window { this->RebuildVisibleSettings(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_AIS_CAPTION: @@ -346,7 +346,7 @@ struct AISettingsWindow : public Window { this->vscroll->SetCount((int)this->visible_settings.size()); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_AIS_BACKGROUND) { this->line_height = max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; @@ -357,7 +357,7 @@ struct AISettingsWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_AIS_BACKGROUND) return; @@ -421,7 +421,7 @@ struct AISettingsWindow : public Window { } } - virtual void OnPaint() + void OnPaint() override { if (this->closing_dropdown) { this->closing_dropdown = false; @@ -430,7 +430,7 @@ struct AISettingsWindow : public Window { this->DrawWidgets(); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_AIS_BACKGROUND: { @@ -481,7 +481,7 @@ struct AISettingsWindow : public Window { DropDownList *list = new DropDownList(); for (int i = config_item.min_value; i <= config_item.max_value; i++) { - *list->Append() = new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false); + list->push_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false)); } ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true); @@ -530,7 +530,7 @@ struct AISettingsWindow : public Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; VisibleSettingsList::const_iterator it = this->visible_settings.begin(); @@ -542,7 +542,7 @@ struct AISettingsWindow : public Window { this->SetDirty(); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { assert(this->clicked_dropdown); VisibleSettingsList::const_iterator it = this->visible_settings.begin(); @@ -553,7 +553,7 @@ struct AISettingsWindow : public Window { this->SetDirty(); } - virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close) + void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override { /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether * the same dropdown button was clicked again, and then not open the dropdown again. @@ -564,12 +564,12 @@ struct AISettingsWindow : public Window { this->SetDirty(); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_AIS_BACKGROUND); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (this->timeout.Elapsed(delta_ms)) { this->clicked_button = -1; @@ -582,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); } diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp index 204bf9712a..06998558b3 100644 --- a/src/ai/ai_instance.hpp +++ b/src/ai/ai_instance.hpp @@ -25,14 +25,14 @@ public: */ void Initialize(class AIInfo *info); - /* virtual */ int GetSetting(const char *name); - /* virtual */ ScriptInfo *FindLibrary(const char *library, int version); + int GetSetting(const char *name) override; + ScriptInfo *FindLibrary(const char *library, int version) override; private: - /* virtual */ void RegisterAPI(); - /* virtual */ void Died(); - /* virtual */ CommandCallback *GetDoCommandCallback(); - /* virtual */ void LoadDummyScript(); + void RegisterAPI() override; + void Died() override; + CommandCallback *GetDoCommandCallback() override; + void LoadDummyScript() override; }; #endif /* AI_INSTANCE_HPP */ diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp index d8e8a6993d..dafc340beb 100644 --- a/src/ai/ai_scanner.hpp +++ b/src/ai/ai_scanner.hpp @@ -19,7 +19,7 @@ public: AIScannerInfo(); ~AIScannerInfo(); - /* virtual */ void Initialize(); + void Initialize() override; /** * Select a random AI. @@ -42,11 +42,11 @@ public: void SetDummyAI(class AIInfo *info); protected: - /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last); - /* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; } - /* virtual */ Subdirectory GetDirectory() const { return AI_DIR; } - /* virtual */ const char *GetScannerName() const { return "AIs"; } - /* virtual */ void RegisterAPI(class Squirrel *engine); + void GetScriptName(ScriptInfo *info, char *name, const char *last) override; + const char *GetFileName() const override { return PATHSEP "info.nut"; } + Subdirectory GetDirectory() const override { return AI_DIR; } + const char *GetScannerName() const override { return "AIs"; } + void RegisterAPI(class Squirrel *engine) override; private: AIInfo *info_dummy; ///< The dummy AI. @@ -54,7 +54,7 @@ private: class AIScannerLibrary : public ScriptScanner { public: - /* virtual */ void Initialize(); + void Initialize() override; /** * Find a library in the pool. @@ -65,11 +65,11 @@ public: class AILibrary *FindLibrary(const char *library, int version); protected: - /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last); - /* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; } - /* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; } - /* virtual */ const char *GetScannerName() const { return "AI Libraries"; } - /* virtual */ void RegisterAPI(class Squirrel *engine); + void GetScriptName(ScriptInfo *info, char *name, const char *last) override; + const char *GetFileName() const override { return PATHSEP "library.nut"; } + Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; } + const char *GetScannerName() const override { return "AI Libraries"; } + void RegisterAPI(class Squirrel *engine) override; }; #endif /* AI_SCANNER_HPP */ diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 1539454e12..dcd093d31d 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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 diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 0ec5620771..391e5ca4ca 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -87,14 +87,14 @@ struct BuildAirToolbarWindow : Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_AT_AIRPORT: @@ -114,7 +114,7 @@ struct BuildAirToolbarWindow : Window { } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (this->last_user_action) { case WID_AT_AIRPORT: @@ -129,19 +129,19 @@ struct BuildAirToolbarWindow : Window { } } - virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) + void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } - virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) + void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override { if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) { GUIPlaceProcDragXY(select_proc, start_tile, end_tile); } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); @@ -219,7 +219,7 @@ class BuildAirportWindow : public PickerWindowBase { DropDownList *list = new DropDownList(); for (uint i = 0; i < AirportClass::GetClassCount(); i++) { - *list->Append() = new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false); + list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false)); } return list; @@ -268,7 +268,7 @@ public: DeleteWindowById(WC_SELECT_STATION, 0); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_AP_CLASS_DROPDOWN: @@ -293,7 +293,7 @@ public: } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_AP_CLASS_DROPDOWN: { @@ -357,7 +357,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_AP_AIRPORT_LIST: { @@ -394,7 +394,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -462,7 +462,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_AP_CLASS_DROPDOWN: @@ -535,7 +535,7 @@ public: this->SelectOtherAirport(-1); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { assert(widget == WID_AP_CLASS_DROPDOWN); _selected_airport_class = (AirportClassID)index; @@ -543,7 +543,7 @@ public: this->SelectFirstAvailableAirport(false); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { CheckRedrawStationCoverage(this); } diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 96a99755aa..7406686b21 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -19,7 +19,7 @@ #include "safeguards.h" /** The table/list with animated tiles. */ -SmallVector _animated_tiles; +std::vector _animated_tiles; /** * Removes the given tile from the animated tile table. @@ -27,10 +27,10 @@ SmallVector _animated_tiles; */ void DeleteAnimatedTile(TileIndex tile) { - TileIndex *to_remove = _animated_tiles.Find(tile); - if (to_remove != _animated_tiles.End()) { + auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile); + if (to_remove != _animated_tiles.end()) { /* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */ - _animated_tiles.ErasePreservingOrder(to_remove); + _animated_tiles.erase(to_remove); MarkTileDirtyByTile(tile, 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(); } diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index 0d7164ec55..c90c97032b 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -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); diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 1d1d819427..eb82028d3a 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -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); diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index eae0a378eb..133e9fb382 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -123,7 +123,7 @@ class ReplaceVehicleWindow : public Window { byte side = draw_left ? 0 : 1; GUIEngineList *list = &this->engines[side]; - list->Clear(); + list->clear(); const Engine *e; FOR_ALL_ENGINES_OF_TYPE(e, type) { @@ -140,7 +140,7 @@ class ReplaceVehicleWindow : public Window { if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue; } - *list->Append() = eid; + list->push_back(eid); if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list } this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore) @@ -160,8 +160,8 @@ class ReplaceVehicleWindow : public Window { if (this->engines[0].NeedRebuild()) { /* We need to rebuild the left engines list */ this->GenerateReplaceVehList(true); - this->vscroll[0]->SetCount(this->engines[0].Length()); - if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) { + this->vscroll[0]->SetCount(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(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS); int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT, - nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side]); + nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side], ted); needed_height = max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM); } } @@ -437,7 +444,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: @@ -461,8 +468,8 @@ public: case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: { DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false); - *list->Append() = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false); + list->push_back(new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false)); + list->push_back(new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false)); ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN); break; } @@ -501,7 +508,7 @@ public: click_side = 1; } uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget); - size_t engine_count = this->engines[click_side].Length(); + size_t engine_count = this->engines[click_side].size(); EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE; if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected @@ -516,7 +523,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_RV_SORT_DROPDOWN: @@ -557,7 +564,7 @@ public: } } - virtual void OnResize() + void OnResize() override { this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX); this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX); @@ -568,7 +575,7 @@ public: * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (data != 0) { /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */ diff --git a/src/base_media_base.h b/src/base_media_base.h index b040abcf9d..5655401558 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -76,9 +76,9 @@ struct BaseSet { { free(this->name); - for (TranslatedStrings::iterator iter = this->description.Begin(); iter != this->description.End(); iter++) { - free(iter->first); - free(iter->second); + for (auto &pair : this->description) { + free(pair.first); + free(pair.second); } for (uint i = 0; i < NUM_FILES; i++) { @@ -122,16 +122,16 @@ struct BaseSet { { if (isocode != NULL) { /* First the full ISO code */ - for (TranslatedStrings::const_iterator iter = this->description.Begin(); iter != this->description.End(); iter++) { - if (strcmp(iter->first, isocode) == 0) return iter->second; + for (const auto &pair : this->description) { + if (strcmp(pair.first, isocode) == 0) return pair.second; } /* Then the first two characters */ - for (TranslatedStrings::const_iterator iter = this->description.Begin(); iter != this->description.End(); iter++) { - if (strncmp(iter->first, isocode, 2) == 0) return iter->second; + for (const auto &pair : this->description) { + if (strncmp(pair.first, isocode, 2) == 0) return pair.second; } } /* Then fall back */ - return this->description.Begin()->second; + return this->description.front().second; } /** @@ -176,7 +176,7 @@ protected: static Tbase_set *duplicate_sets; ///< All sets that aren't available, but needed for not downloading base sets when a newer version than the one on BaNaNaS is loaded. static const Tbase_set *used_set; ///< The currently used set - /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename); + bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override; /** * Get the extension that is used to identify this set. diff --git a/src/base_media_func.h b/src/base_media_func.h index f7afca0edb..ed954360a0 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -277,7 +277,6 @@ template return p; } -#if defined(ENABLE_NETWORK) #include "network/network_content.h" template const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s) @@ -307,22 +306,6 @@ template (TryGetBaseSetFile(ci, md5sum, BaseMedia::duplicate_sets) != NULL); } -#else - -template -const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s) -{ - return NULL; -} - -template -/* static */ bool BaseMedia::HasSet(const ContentInfo *ci, bool md5sum) -{ - return false; -} - -#endif /* ENABLE_NETWORK */ - /** * Count the number of available graphics sets. * @return the number of sets diff --git a/src/base_station_base.h b/src/base_station_base.h index 08a66bea56..16b451cd74 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -110,6 +110,12 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { */ virtual void UpdateVirtCoord() = 0; + virtual void MoveSign(TileIndex new_xy) + { + this->xy = new_xy; + this->UpdateVirtCoord(); + } + /** * Get the tile area for a given station type. * @param ta tile area to fill. diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index 466628684c..46810d8f34 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -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 */ diff --git a/src/blitter/32bpp_anim_sse2.hpp b/src/blitter/32bpp_anim_sse2.hpp index 0d4a5f1e65..aed11026c0 100644 --- a/src/blitter/32bpp_anim_sse2.hpp +++ b/src/blitter/32bpp_anim_sse2.hpp @@ -28,15 +28,15 @@ /** A partially 32 bpp blitter with palette animation. */ class Blitter_32bppSSE2_Anim : public Blitter_32bppAnim { public: - /* virtual */ void PaletteAnimate(const Palette &palette); - /* virtual */ const char *GetName() { return "32bpp-sse2-anim"; } + void PaletteAnimate(const Palette &palette) override; + const char *GetName() override { return "32bpp-sse2-anim"; } }; /** Factory for the partially 32bpp blitter with animation. */ class FBlitter_32bppSSE2_Anim : public BlitterFactory { public: FBlitter_32bppSSE2_Anim() : BlitterFactory("32bpp-sse2-anim", "32bpp partially SSE2 Animation Blitter (palette animation)", HasCPUIDFlag(1, 3, 26)) {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2_Anim(); } + Blitter *CreateInstance() override { return new Blitter_32bppSSE2_Anim(); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_anim_sse4.hpp b/src/blitter/32bpp_anim_sse4.hpp index 5ff1fb01be..2fefd3001f 100644 --- a/src/blitter/32bpp_anim_sse4.hpp +++ b/src/blitter/32bpp_anim_sse4.hpp @@ -35,19 +35,19 @@ private: public: template - /* virtual */ void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) { + void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override { return Blitter_32bppSSE_Base::Encode(sprite, allocator); } - /* virtual */ const char *GetName() { return "32bpp-sse4-anim"; } + const char *GetName() override { return "32bpp-sse4-anim"; } }; /** Factory for the SSE4 32 bpp blitter (with palette animation). */ class FBlitter_32bppSSE4_Anim: public BlitterFactory { public: FBlitter_32bppSSE4_Anim() : BlitterFactory("32bpp-sse4-anim", "SSE4 Blitter (palette animation)", HasCPUIDFlag(1, 2, 19)) {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4_Anim(); } + Blitter *CreateInstance() override { return new Blitter_32bppSSE4_Anim(); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 3fde4e6fdc..6f94950352 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -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. diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index 2c08096582..81fa44e3b9 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -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 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 */ diff --git a/src/blitter/32bpp_simple.hpp b/src/blitter/32bpp_simple.hpp index 0751f6f753..3d43971e9e 100644 --- a/src/blitter/32bpp_simple.hpp +++ b/src/blitter/32bpp_simple.hpp @@ -26,18 +26,18 @@ class Blitter_32bppSimple : public Blitter_32bppBase { uint8 v; ///< Brightness-channel }; public: - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; + void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override; + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; - /* virtual */ const char *GetName() { return "32bpp-simple"; } + const char *GetName() override { return "32bpp-simple"; } }; /** Factory for the simple 32 bpp blitter. */ class FBlitter_32bppSimple : public BlitterFactory { public: FBlitter_32bppSimple() : BlitterFactory("32bpp-simple", "32bpp Simple Blitter (no palette animation)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSimple(); } + Blitter *CreateInstance() override { return new Blitter_32bppSimple(); } }; #endif /* BLITTER_32BPP_SIMPLE_HPP */ diff --git a/src/blitter/32bpp_sse2.hpp b/src/blitter/32bpp_sse2.hpp index 7afae87546..7f877529ea 100644 --- a/src/blitter/32bpp_sse2.hpp +++ b/src/blitter/32bpp_sse2.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 void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) { + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override { return Blitter_32bppSSE_Base::Encode(sprite, allocator); } - /* virtual */ const char *GetName() { return "32bpp-sse2"; } + const char *GetName() override { return "32bpp-sse2"; } }; /** Factory for the SSE2 32 bpp blitter (without palette animation). */ class FBlitter_32bppSSE2 : public BlitterFactory { public: FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2(); } + Blitter *CreateInstance() override { return new Blitter_32bppSSE2(); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_sse4.hpp b/src/blitter/32bpp_sse4.hpp index 9c59d253f5..36b5b16d4c 100644 --- a/src/blitter/32bpp_sse4.hpp +++ b/src/blitter/32bpp_sse4.hpp @@ -27,17 +27,17 @@ /** The SSE4 32 bpp blitter (without palette animation). */ class Blitter_32bppSSE4 : public Blitter_32bppSSSE3 { public: - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); - /* virtual */ const char *GetName() { return "32bpp-sse4"; } + const char *GetName() override { return "32bpp-sse4"; } }; /** Factory for the SSE4 32 bpp blitter (without palette animation). */ class FBlitter_32bppSSE4: public BlitterFactory { public: FBlitter_32bppSSE4() : BlitterFactory("32bpp-sse4", "32bpp SSE4 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 19)) {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4(); } + Blitter *CreateInstance() override { return new Blitter_32bppSSE4(); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_ssse3.hpp b/src/blitter/32bpp_ssse3.hpp index e9cac8ff0b..3d6152e9e7 100644 --- a/src/blitter/32bpp_ssse3.hpp +++ b/src/blitter/32bpp_ssse3.hpp @@ -27,17 +27,17 @@ /** The SSSE3 32 bpp blitter (without palette animation). */ class Blitter_32bppSSSE3 : public Blitter_32bppSSE2 { public: - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); - /* virtual */ const char *GetName() { return "32bpp-ssse3"; } + const char *GetName() override { return "32bpp-ssse3"; } }; /** Factory for the SSSE3 32 bpp blitter (without palette animation). */ class FBlitter_32bppSSSE3: public BlitterFactory { public: FBlitter_32bppSSSE3() : BlitterFactory("32bpp-ssse3", "32bpp SSSE3 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 9)) {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSSE3(); } + Blitter *CreateInstance() override { return new Blitter_32bppSSSE3(); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index e7e8db9607..2ceff37874 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -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 */ diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index b5b5324b91..509edb8c40 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -24,17 +24,17 @@ public: byte data[]; ///< Data, all zoomlevels. }; - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; - /* virtual */ const char *GetName() { return "8bpp-optimized"; } + const char *GetName() override { return "8bpp-optimized"; } }; /** Factory for the 8bpp blitter optimised for speed. */ class FBlitter_8bppOptimized : public BlitterFactory { public: FBlitter_8bppOptimized() : BlitterFactory("8bpp-optimized", "8bpp Optimized Blitter (compression + all-ZoomLevel cache)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppOptimized(); } + Blitter *CreateInstance() override { return new Blitter_8bppOptimized(); } }; #endif /* BLITTER_8BPP_OPTIMIZED_HPP */ diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp index c00c75ac04..e48bc37585 100644 --- a/src/blitter/8bpp_simple.hpp +++ b/src/blitter/8bpp_simple.hpp @@ -18,17 +18,17 @@ /** Most trivial 8bpp blitter. */ class Blitter_8bppSimple FINAL : public Blitter_8bppBase { public: - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator); + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; - /* virtual */ const char *GetName() { return "8bpp-simple"; } + const char *GetName() override { return "8bpp-simple"; } }; /** Factory for the most trivial 8bpp blitter. */ class FBlitter_8bppSimple : public BlitterFactory { public: FBlitter_8bppSimple() : BlitterFactory("8bpp-simple", "8bpp Simple Blitter (relative slow, but never wrong)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppSimple(); } + Blitter *CreateInstance() override { return new Blitter_8bppSimple(); } }; #endif /* BLITTER_8BPP_SIMPLE_HPP */ diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index 96863c0c3e..89f287bce7 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.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; }; - - /* virtual */ const char *GetName() { return "null"; } - /* virtual */ int GetBytesPerPixel() { return 0; } + uint8 GetScreenDepth() override { return 0; } + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {}; + void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {}; + Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; + void *MoveTo(void *video, int x, int y) override { return NULL; }; + void SetPixel(void *video, int x, int y, uint8 colour) override {}; + void DrawRect(void *video, int width, int height, uint8 colour) override {}; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {}; + void 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; }; + + const char *GetName() override { return "null"; } + int GetBytesPerPixel() override { return 0; } }; /** Factory for the blitter that does nothing. */ class FBlitter_Null : public BlitterFactory { public: FBlitter_Null() : BlitterFactory("null", "Null Blitter (does nothing)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_Null(); } + Blitter *CreateInstance() override { return new Blitter_Null(); } }; #endif /* BLITTER_NULL_HPP */ diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 3fb52a1f9e..b6fb35bffd 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -13,7 +13,7 @@ #include "base_media_base.h" #include "blitter/factory.hpp" -#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) +#if defined(WITH_FREETYPE) #include "core/geometry_func.hpp" #include "fontcache.h" @@ -56,7 +56,7 @@ public: ResizeWindow(this, _screen.width, _screen.height); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE); GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER); @@ -88,7 +88,7 @@ public: { } - virtual void OnDownloadComplete(ContentID cid) + void OnDownloadComplete(ContentID cid) override { /* We have completed downloading. We can trigger finding the right set now. */ BaseGraphics::FindSets(); @@ -142,7 +142,7 @@ public: _network_content_client.RemoveCallback(this); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { /* We cache the button size. This is safe as no reinit can happen here. */ if (this->button_size.width == 0) { @@ -165,14 +165,14 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != 0) return; DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BAFD_YES: @@ -189,13 +189,13 @@ public: } } - virtual void OnConnect(bool success) + void OnConnect(bool success) override { /* Once connected, request the metadata. */ _network_content_client.RequestContentList(CONTENT_TYPE_BASE_GRAPHICS); } - virtual void OnReceiveContentInfo(const ContentInfo *ci) + void OnReceiveContentInfo(const ContentInfo *ci) override { /* And once the meta data is received, start downloading it. */ _network_content_client.Select(ci->id); @@ -204,7 +204,7 @@ public: } }; -#endif /* defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) */ +#endif /* defined(WITH_FREETYPE) */ /** * Handle all procedures for bootstrapping OpenTTD without a base graphics set. @@ -220,7 +220,7 @@ bool HandleBootstrap() if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure; /* If there is no network or no freetype, then there is nothing we can do. Go straight to failure. */ -#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__)) +#if defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__)) if (!_network_available) goto failure; /* First tell the game we're bootstrapping. */ diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 2459c88276..5de49e5e34 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -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(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; diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 2c05187c0d..9a188a2a22 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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(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(WID_BV_BUILD_SEL)->SetDisplayedPlane(SZSP_NONE); - this->GetWidget(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(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(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(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(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); } diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index fda2b246e4..e6bfc8c0a2 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -221,7 +221,7 @@ struct CheatWindow : Window { this->InitNested(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_C_PANEL) return; @@ -283,7 +283,7 @@ struct CheatWindow : Window { } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget != WID_C_PANEL) return; @@ -330,7 +330,7 @@ struct CheatWindow : Window { size->height = this->header_height + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { const NWidgetBase *wid = this->GetWidget(WID_C_PANEL); uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / this->line_height; @@ -384,13 +384,13 @@ struct CheatWindow : Window { this->SetDirty(); } - virtual void OnTimeout() + void OnTimeout() override { this->clicked = 0; this->SetDirty(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { /* Was 'cancel' pressed or nothing entered? */ if (str == NULL || StrEmpty(str)) return; diff --git a/src/command.cpp b/src/command.cpp index 96fc1dfefa..cacab7be56 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -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); diff --git a/src/command_func.h b/src/command_func.h index 4c03c222ef..09cafefc36 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -42,9 +42,7 @@ bool DoCommandP(const CommandContainer *container, bool my_cmd = true); CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, 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; diff --git a/src/command_type.h b/src/command_type.h index e10e50678c..849ad9da6d 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -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 diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 04652ba545..432a4fc69d 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -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; } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 3a678422f3..4988991bb0 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -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(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 indents; + std::vector 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: diff --git a/src/console.cpp b/src/console.cpp index 2f44eb70e9..f2aab004b2 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -33,10 +33,8 @@ FILE *_iconsole_output_file; void IConsoleInit() { _iconsole_output_file = NULL; -#ifdef ENABLE_NETWORK /* Initialize network only variables */ _redirect_console_to_client = INVALID_CLIENT_ID; _redirect_console_to_admin = INVALID_ADMIN_ID; -#endif IConsoleGUIInit(); @@ -90,7 +88,6 @@ void IConsolePrint(TextColour colour_code, const char *string) assert(IsValidConsoleColour(colour_code)); char *str; -#ifdef ENABLE_NETWORK if (_redirect_console_to_client != INVALID_CLIENT_ID) { /* Redirect the string to the client */ NetworkServerSendRcon(_redirect_console_to_client, colour_code, string); @@ -101,7 +98,6 @@ void IConsolePrint(TextColour colour_code, const char *string) NetworkServerSendAdminRcon(_redirect_console_to_admin, colour_code, string); return; } -#endif /* Create a copy of the string, strip if of colours and invalid * characters and (when applicable) assign it to the console buffer */ @@ -110,9 +106,7 @@ void IConsolePrint(TextColour colour_code, const char *string) str_validate(str, str + strlen(str)); if (_network_dedicated) { -#ifdef ENABLE_NETWORK NetworkAdminConsole("console", str); -#endif /* ENABLE_NETWORK */ fprintf(stdout, "%s%s\n", GetLogPrefix(), str); fflush(stdout); IConsoleWriteToLogFile(str); diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 76566e0ebe..9ba7fdf29b 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -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 diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 6e807b3e25..49ca34b31f 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -201,7 +201,7 @@ struct IConsoleWindow : Window this->SetDirty(); } - virtual void OnPaint() + void OnPaint() override { const int right = this->width - 5; @@ -229,7 +229,7 @@ struct IConsoleWindow : Window } } - virtual void OnHundredthTick() + void OnHundredthTick() override { if (IConsoleLine::Truncate() && (IConsoleWindow::scroll > IConsoleLine::size)) { @@ -238,12 +238,12 @@ struct IConsoleWindow : Window } } - virtual void OnMouseLoop() + void OnMouseLoop() override { if (_iconsole_cmdline.HandleCaret()) this->SetDirty(); } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { if (_focused_window != this) return ES_NOT_HANDLED; @@ -314,7 +314,7 @@ struct IConsoleWindow : Window return ES_HANDLED; } - virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) + void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override { if (_iconsole_cmdline.InsertString(str, marked, caret, insert_location, replacement_end)) { IConsoleWindow::scroll = 0; @@ -323,17 +323,17 @@ struct IConsoleWindow : Window } } - virtual const char *GetFocusedText() const + const char *GetFocusedText() const override { return _iconsole_cmdline.buf; } - virtual const char *GetCaret() const + const char *GetCaret() const override { return _iconsole_cmdline.buf + _iconsole_cmdline.caretpos; } - virtual const char *GetMarkedText(size_t *length) const + const char *GetMarkedText(size_t *length) const override { if (_iconsole_cmdline.markend == 0) return NULL; @@ -341,7 +341,7 @@ struct IConsoleWindow : Window return _iconsole_cmdline.buf + _iconsole_cmdline.markpos; } - virtual Point GetCaretPosition() const + Point GetCaretPosition() const override { int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0); Point pt = {this->line_offset + delta + _iconsole_cmdline.caretxoffs, this->height - this->line_height}; @@ -349,7 +349,7 @@ struct IConsoleWindow : Window return pt; } - virtual Rect GetTextBoundingRect(const char *from, const char *to) const + Rect GetTextBoundingRect(const char *from, const char *to) const override { int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0); @@ -360,7 +360,7 @@ struct IConsoleWindow : Window return r; } - virtual const char *GetTextCharacterAtPosition(const Point &pt) const + const char *GetTextCharacterAtPosition(const Point &pt) const override { int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0); @@ -369,12 +369,12 @@ struct IConsoleWindow : Window return GetCharAtPosition(_iconsole_cmdline.buf, pt.x - delta); } - virtual void OnMouseWheel(int wheel) + void OnMouseWheel(int wheel) override { this->Scroll(-wheel); } - virtual void OnFocusLost(Window *newly_focused_window) + void OnFocusLost(Window *newly_focused_window) override { VideoDriver::GetInstance()->EditBoxLostFocus(); } diff --git a/src/core/endian_type.hpp b/src/core/endian_type.hpp index 6e5defc647..1cacf6c0cb 100644 --- a/src/core/endian_type.hpp +++ b/src/core/endian_type.hpp @@ -26,7 +26,7 @@ #define TTD_BIG_ENDIAN 1 /* Windows has always LITTLE_ENDIAN */ -#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__) || defined(__DJGPP__) +#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__) # define TTD_ENDIAN TTD_LITTLE_ENDIAN #elif defined(OSX) # include diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp index f8ff93cecc..7a65bf77a4 100644 --- a/src/core/pool_func.cpp +++ b/src/core/pool_func.cpp @@ -21,8 +21,8 @@ /* virtual */ PoolBase::~PoolBase() { PoolVector *pools = PoolBase::GetPools(); - pools->Erase(pools->Find(this)); - if (pools->Length() == 0) delete pools; + pools->erase(std::find(pools->begin(), pools->end(), this)); + if (pools->size() == 0) delete pools; } /** @@ -31,10 +31,7 @@ */ /* static */ void PoolBase::Clean(PoolType pt) { - PoolVector *pools = PoolBase::GetPools(); - PoolBase **end = pools->End(); - for (PoolBase **ppool = pools->Begin(); ppool != end; ppool++) { - PoolBase *pool = *ppool; + for (PoolBase *pool : *PoolBase::GetPools()) { if (pool->type & pt) pool->CleanPool(); } } diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 91986d3a18..1a45588674 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -26,7 +26,7 @@ enum PoolType { }; DECLARE_ENUM_AS_BIT_SET(PoolType) -typedef SmallVector PoolVector; ///< Vector of pointers to PoolBase +typedef std::vector PoolVector; ///< Vector of pointers to PoolBase /** Base class for base of all pools. */ struct PoolBase { @@ -50,7 +50,7 @@ struct PoolBase { */ PoolBase(PoolType pt) : type(pt) { - *PoolBase::GetPools()->Append() = this; + PoolBase::GetPools()->push_back(this); } virtual ~PoolBase(); diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index dda0fc2a1e..af48980f08 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -27,6 +27,7 @@ struct SmallPair { /** Initializes this Pair with data */ inline SmallPair(const T &first, const U &second) : first(first), second(second) { } + SmallPair() = default; }; /** @@ -38,8 +39,8 @@ struct SmallPair { * * @see SmallVector */ -template -struct SmallMap : SmallVector, S> { +template +struct SmallMap : std::vector > { typedef ::SmallPair Pair; typedef Pair *iterator; typedef const Pair *const_iterator; @@ -54,12 +55,13 @@ struct SmallMap : SmallVector, S> { * @param key key to find * @return &Pair(key, data) if found, this->End() if not */ - inline const Pair *Find(const T &key) const + inline typename std::vector::const_iterator Find(const T &key) const { - for (uint i = 0; i < this->items; i++) { - if (key == this->data[i].first) return &this->data[i]; + typename std::vector::const_iterator it; + for (it = std::vector::begin(); it != std::vector::end(); it++) { + if (key == it->first) return it; } - return this->End(); + return it; } /** @@ -69,12 +71,23 @@ struct SmallMap : SmallVector, S> { */ inline Pair *Find(const T &key) { - for (uint i = 0; i < this->items; i++) { - if (key == this->data[i].first) return &this->data[i]; + for (uint i = 0; i < std::vector::size(); i++) { + if (key == std::vector::operator[](i).first) return &std::vector::operator[](i); } return this->End(); } + inline const Pair *End() const + { + return std::vector::data() + std::vector::size(); + } + + inline Pair *End() + { + return std::vector::data() + std::vector::size(); + } + + /** * Tests whether a key is assigned in this map. * @param key key to test @@ -85,6 +98,16 @@ struct SmallMap : SmallVector, 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, S> { */ inline void Erase(Pair *pair) { - assert(pair >= this->Begin() && pair < this->End()); - *pair = this->data[--this->items]; + assert(pair >= std::vector::data() && pair < this->End()); + auto distance = pair - std::vector::data(); + std::vector::erase(std::vector::begin() + distance); } /** @@ -104,13 +128,11 @@ struct SmallMap : SmallVector, S> { */ inline bool Erase(const T &key) { - for (uint i = 0; i < this->items; i++) { - if (key == this->data[i].first) { - this->data[i] = this->data[--this->items]; - return true; - } - } - return false; + Pair *pair = this->Find(key); + if (pair == this->End()) return false; + + this->Erase(pair); + return true; } /** @@ -122,9 +144,7 @@ struct SmallMap : SmallVector, S> { inline bool Insert(const T &key, const U &data) { if (this->Contains(key)) return false; - Pair *n = this->Append(); - n->first = key; - n->second = data; + std::vector::emplace_back(key, data); return true; } @@ -136,17 +156,18 @@ struct SmallMap : SmallVector, S> { */ inline U &operator[](const T &key) { - for (uint i = 0; i < this->items; i++) { - if (key == this->data[i].first) return this->data[i].second; + for (uint i = 0; i < std::vector::size(); i++) { + if (key == std::vector::operator[](i).first) return std::vector::operator[](i).second; } - Pair *n = this->Append(); - n->first = key; - return n->second; + /*C++17: Pair &n = */ std::vector::emplace_back(); + Pair &n = std::vector::back(); + n.first = key; + return n.second; } inline void SortByKey() { - QSortT(this->Begin(), this->items, KeySorter); + QSortT(std::vector::data(), std::vector::size(), KeySorter); } static int CDECL KeySorter(const Pair *a, const Pair *b) diff --git a/src/core/smallstack_type.hpp b/src/core/smallstack_type.hpp index f144107901..934a5076c9 100644 --- a/src/core/smallstack_type.hpp +++ b/src/core/smallstack_type.hpp @@ -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 data; + std::vector data; }; /** @@ -96,6 +96,7 @@ struct SmallStackItem { */ inline SmallStackItem(const Titem &value, Tindex next) : next(next), value(value) {} + SmallStackItem() = default; }; /** diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 588dd599dc..f43265ebe8 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -14,375 +14,60 @@ #include "alloc_func.hpp" #include "mem_func.hpp" +#include +#include /** - * Simple vector template class. + * Helper function to append an item to a vector if it is not already contained + * Consider using std::set, std::unordered_set or std::flat_set in new code * - * @note There are no asserts in the class so you have - * to care about that you grab an item which is - * inside the list. + * @param vec A reference to the vector to be extended + * @param item Reference to the item to be copy-constructed if not found * - * @tparam T The type of the items stored - * @tparam S The steps of allocation + * @return Whether the item was already present */ -template -class SmallVector { -protected: - T *data; ///< The pointer to the first item - uint items; ///< The number of items stored - uint capacity; ///< The available space for storing items - -public: - SmallVector() : data(NULL), items(0), capacity(0) { } - - /** - * Copy constructor. - * @param other The other vector to copy. - */ - SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0) - { - this->Assign(other); - } - - /** - * Generic copy constructor. - * @param other The other vector to copy. - */ - template - SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0) - { - this->Assign(other); - } - - /** - * Assignment. - * @param other The other vector to assign. - */ - SmallVector &operator=(const SmallVector &other) - { - this->Assign(other); - return *this; - } - - /** - * Generic assignment. - * @param other The other vector to assign. - */ - template - SmallVector &operator=(const SmallVector &other) - { - this->Assign(other); - return *this; - } - - ~SmallVector() - { - free(this->data); - } - - /** - * Assign items from other vector. - */ - template - inline void Assign(const SmallVector &other) - { - if ((const void *)&other == (void *)this) return; - - this->Clear(); - if (other.Length() > 0) MemCpyT(this->Append(other.Length()), other.Begin(), other.Length()); - } - - /** - * Remove all items from the list. - */ - inline void Clear() - { - /* In fact we just reset the item counter avoiding the need to - * probably reallocate the same amount of memory the list was - * previously using. */ - this->items = 0; - } - - /** - * Remove all items from the list and free allocated memory. - */ - inline void Reset() - { - this->items = 0; - this->capacity = 0; - free(data); - data = NULL; - } - - /** - * Compact the list down to the smallest block size boundary. - */ - inline void Compact() - { - uint capacity = Align(this->items, S); - if (capacity >= this->capacity) return; - - this->capacity = capacity; - this->data = ReallocT(this->data, this->capacity); - } - - /** - * Append an item and return it. - * @param to_add the number of items to append - * @return pointer to newly allocated item - */ - inline T *Append(uint to_add = 1) - { - uint begin = this->items; - this->items += to_add; - - if (this->items > this->capacity) { - this->capacity = Align(this->items, S); - this->data = ReallocT(this->data, this->capacity); - } - - return &this->data[begin]; - } - - /** - * Set the size of the vector, effectively truncating items from the end or appending uninitialised ones. - * @param num_items Target size. - */ - inline void Resize(uint num_items) - { - this->items = num_items; - - if (this->items > this->capacity) { - this->capacity = Align(this->items, S); - this->data = ReallocT(this->data, this->capacity); - } - } - - /** - * Insert a new item at a specific position into the vector, moving all following items. - * @param item Position at which the new item should be inserted - * @return pointer to the new item - */ - inline T *Insert(T *item) - { - assert(item >= this->Begin() && item <= this->End()); - - size_t to_move = this->End() - item; - size_t start = item - this->Begin(); - - this->Append(); - if (to_move > 0) MemMoveT(this->Begin() + start + 1, this->Begin() + start, to_move); - return this->Begin() + start; - } - - /** - * Search for the first occurrence of an item. - * The '!=' operator of T is used for comparison. - * @param item Item to search for - * @return The position of the item, or End() when not present - */ - inline const T *Find(const T &item) const - { - const T *pos = this->Begin(); - const T *end = this->End(); - while (pos != end && *pos != item) pos++; - return pos; - } - - /** - * Search for the first occurrence of an item. - * The '!=' operator of T is used for comparison. - * @param item Item to search for - * @return The position of the item, or End() when not present - */ - inline T *Find(const T &item) - { - T *pos = this->Begin(); - const T *end = this->End(); - while (pos != end && *pos != item) pos++; - return pos; - } +template +inline bool include(std::vector& vec, const T &item) +{ + const bool is_member = std::find(vec.begin(), vec.end(), item) != vec.end(); + if (!is_member) vec.emplace_back(item); + return is_member; +} - /** - * Search for the first occurrence of an item. - * The '!=' operator of T is used for comparison. - * @param item Item to search for - * @return The position of the item, or -1 when not present - */ - inline int FindIndex(const T &item) const - { - int index = 0; - const T *pos = this->Begin(); - const T *end = this->End(); - while (pos != end && *pos != item) { - pos++; - index++; - } - return pos == end ? -1 : index; - } - - /** - * Tests whether a item is present in the vector. - * The '!=' operator of T is used for comparison. - * @param item Item to test for - * @return true iff the item is present - */ - inline bool Contains(const T &item) const - { - return this->Find(item) != this->End(); - } - - /** - * Removes given item from this vector - * @param item item to remove - * @note it has to be pointer to item in this map. It is overwritten by the last item. - */ - inline void Erase(T *item) - { - assert(item >= this->Begin() && item < this->End()); - *item = this->data[--this->items]; - } - - /** - * Remove items from the vector while preserving the order of other items. - * @param pos First item to remove. - * @param count Number of consecutive items to remove. - */ - void ErasePreservingOrder(uint pos, uint count = 1) - { - ErasePreservingOrder(this->data + pos, count); - } - - /** - * Remove items from the vector while preserving the order of other items. - * @param item First item to remove. - * @param count Number of consecutive items to remove. - */ - inline void ErasePreservingOrder(T *item, uint count = 1) - { - if (count == 0) return; - assert(item >= this->Begin()); - assert(item + count <= this->End()); - - this->items -= count; - ptrdiff_t to_move = this->End() - item; - if (to_move > 0) MemMoveT(item, item + count, to_move); - } - - /** - * Tests whether a item is present in the vector, and appends it to the end if not. - * The '!=' operator of T is used for comparison. - * @param item Item to test for - * @return true iff the item is was already present - */ - inline bool Include(const T &item) - { - bool is_member = this->Contains(item); - if (!is_member) *this->Append() = item; - return is_member; - } - - /** - * Get the number of items in the list. - * - * @return The number of items in the list. - */ - inline uint Length() const - { - return this->items; - } - - /** - * Get the pointer to the first item (const) - * - * @return the pointer to the first item - */ - inline const T *Begin() const - { - return this->data; - } - - /** - * Get the pointer to the first item - * - * @return the pointer to the first item - */ - inline T *Begin() - { - return this->data; - } - - /** - * Get the pointer behind the last valid item (const) - * - * @return the pointer behind the last valid item - */ - inline const T *End() const - { - return &this->data[this->items]; - } - - /** - * Get the pointer behind the last valid item - * - * @return the pointer behind the last valid item - */ - inline T *End() - { - return &this->data[this->items]; - } - - /** - * Get the pointer to item "number" (const) - * - * @param index the position of the item - * @return the pointer to the item - */ - inline const T *Get(uint index) const - { - /* Allow access to the 'first invalid' item */ - assert(index <= this->items); - return &this->data[index]; - } - - /** - * Get the pointer to item "number" - * - * @param index the position of the item - * @return the pointer to the item - */ - inline T *Get(uint index) - { - /* Allow access to the 'first invalid' item */ - assert(index <= this->items); - return &this->data[index]; - } - - /** - * Get item "number" (const) - * - * @param index the position of the item - * @return the item - */ - inline const T &operator[](uint index) const - { - assert(index < this->items); - return this->data[index]; - } +/** + * Helper function to get the index of an item + * Consider using std::set, std::unordered_set or std::flat_set in new code + * + * @param vec A reference to the vector to be extended + * @param item Reference to the item to be search for + * + * @return Index of element if found, otherwise -1 + */ +template +int find_index(std::vector const& vec, T const& item) +{ + auto const it = std::find(vec.begin(), vec.end(), item); + if (it != vec.end()) return it - vec.begin(); - /** - * Get item "number" - * - * @param index the position of the item - * @return the item - */ - inline T &operator[](uint index) - { - assert(index < this->items); - return this->data[index]; - } -}; + return -1; +} +/** + * Helper function to append N default-constructed elements and get a pointer to the first new element + * Consider using std::back_inserter in new code + * + * @param vec A reference to the vector to be extended + * @param num Number of elements to be default-constructed + * + * @return Pointer to the first new element + */ +template +T* grow(std::vector& vec, std::size_t num) +{ + std::size_t const pos = vec.size(); + vec.resize(pos + num); + return vec.data() + pos; +} /** * Simple vector template class, with automatic free. @@ -392,10 +77,9 @@ public: * inside the list. * * @param T The type of the items stored, must be a pointer - * @param S The steps of allocation */ -template -class AutoFreeSmallVector : public SmallVector { +template +class AutoFreeSmallVector : public std::vector { public: ~AutoFreeSmallVector() { @@ -407,11 +91,11 @@ public: */ inline void Clear() { - for (uint i = 0; i < this->items; i++) { - free(this->data[i]); + for (T p : *this) { + free(p); } - this->items = 0; + std::vector::clear(); } }; @@ -423,10 +107,9 @@ public: * inside the list. * * @param T The type of the items stored, must be a pointer - * @param S The steps of allocation */ -template -class AutoDeleteSmallVector : public SmallVector { +template +class AutoDeleteSmallVector : public std::vector { public: ~AutoDeleteSmallVector() { @@ -438,14 +121,14 @@ public: */ inline void Clear() { - for (uint i = 0; i < this->items; i++) { - delete this->data[i]; + for (T p : *this) { + delete p; } - this->items = 0; + std::vector::clear(); } }; -typedef AutoFreeSmallVector StringList; ///< Type for a list of strings. +typedef AutoFreeSmallVector StringList; ///< Type for a list of strings. #endif /* SMALLVEC_TYPE_HPP */ diff --git a/src/cpu.cpp b/src/cpu.cpp index 9393ea0613..8d5eb5e5e7 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -35,7 +35,7 @@ unsigned __int64 ottd_rdtsc(); #endif /* rdtsc for all other *nix-en (hopefully). Use GCC syntax */ -#if (defined(__i386__) || defined(__x86_64__)) && !defined(__DJGPP__) && !defined(RDTSC_AVAILABLE) +#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE) uint64 ottd_rdtsc() { uint32 high, low; diff --git a/src/date.cpp b/src/date.cpp index 8e4fe8faa0..46f370ffc5 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -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(); diff --git a/src/date_gui.cpp b/src/date_gui.cpp index f53b102537..6a6659a8ce 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -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); diff --git a/src/debug.cpp b/src/debug.cpp index 64d0bab41a..c046d459dd 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -23,10 +23,8 @@ #include -#if defined(ENABLE_NETWORK) #include "network/network_admin.h" SOCKET _debug_socket = INVALID_SOCKET; -#endif /* ENABLE_NETWORK */ #if defined(RANDOM_DEBUG) && defined(UNIX) && defined(__GLIBC__) #include @@ -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); } diff --git a/src/dedicated.cpp b/src/dedicated.cpp index 574cbb0c34..141a917208 100644 --- a/src/dedicated.cpp +++ b/src/dedicated.cpp @@ -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 */ diff --git a/src/departures.cpp b/src/departures.cpp index c38b2bef21..0b2911c68e 100644 --- a/src/departures.cpp +++ b/src/departures.cpp @@ -153,8 +153,8 @@ static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list) { /* Seperate departure by each shared order group */ std::map> 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_list->Begin(), departure_list->Length(), [](Departure * const *a, Departure * const *b) -> int { + QSortT(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 *result = new SmallVector(); + std::vector *result = new std::vector(); if (!show_pax && !show_freight) return result; /* A list of the next scheduled orders to be considered for inclusion in the departure list. */ - SmallVector next_orders; + std::vector 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; } diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 4bdf0f2e67..9ab84a1587 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -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::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 void DeparturesWindow::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::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::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::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::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 ", ". */ - 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::DrawDeparturesListItems(const Rect &r) const /* Finally, finish off with " and ". */ 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)); } diff --git a/src/departures_type.h b/src/departures_type.h index 8ee178e140..13495ddd3e 100644 --- a/src/departures_type.h +++ b/src/departures_type.h @@ -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 calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates + std::vector 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 DepartureList; +typedef std::vector DepartureList; #endif /* DEPARTURES_TYPE_H */ diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index ce7cbad7af..93006603f9 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -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(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; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 2bb5153af6..01c3a4834f 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -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(WID_BDD_Y)->pos_x + x1, this->GetWidget(WID_BDD_Y)->pos_y + y2, AXIS_Y, DEPOT_PART_SOUTH); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BDD_X: diff --git a/src/economy.cpp b/src/economy.cpp index d71e79296e..49e0a48c16 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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 SmallIndustryList; +typedef std::vector 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(_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 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(); } /** diff --git a/src/engine.cpp b/src/engine.cpp index 7467e86f97..fcd08cbb61 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -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++; } } diff --git a/src/engine_base.h b/src/engine_base.h index 0c327eebe0..dde8f80175 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -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 { +struct EngineOverrideManager : std::vector { static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries void ResetToDefaultMapping(); diff --git a/src/engine_func.h b/src/engine_func.h index 37fb005092..79dad18c72 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -26,7 +26,7 @@ extern const uint8 _engine_offsets[4]; bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company); bool IsEngineRefittable(EngineID engine); -void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits); +void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits, CargoID cargo_type, uint16 cargo_capacity); void SetYearEngineAgingStops(); void StartupOneEngine(Engine *e, Date aging_date); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 1954b3f853..9a6568f1e1 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -75,7 +75,7 @@ struct EnginePreviewWindow : Window { this->flags |= WF_STICKY; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget != WID_EP_QUESTION) return; @@ -102,7 +102,7 @@ struct EnginePreviewWindow : Window { size->height += GetStringHeight(GetEngineInfoString(engine), size->width); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_EP_QUESTION) return; @@ -121,7 +121,7 @@ struct EnginePreviewWindow : Window { DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_EP_YES: @@ -133,7 +133,7 @@ struct EnginePreviewWindow : Window { } } - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; @@ -325,11 +325,11 @@ void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID eng */ void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare) { - uint size = el->Length(); + 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); } diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 7a62f2af09..5bad84321f 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -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; diff --git a/src/fileio.cpp b/src/fileio.cpp index 6f3786190a..dbc29eec9e 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -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 */ } /** diff --git a/src/fileio_func.h b/src/fileio_func.h index af6c9c1137..2c46a54777 100644 --- a/src/fileio_func.h +++ b/src/fileio_func.h @@ -107,7 +107,7 @@ public: ALL = BASESET | NEWGRF | AI | SCENARIO | GAME, ///< Scan for everything. }; - /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL); + bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL) override; bool AddFile(Subdirectory sd, const char *filename); diff --git a/src/fios.cpp b/src/fios.cpp index aef3a8407d..cb157492e9 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -13,11 +13,13 @@ */ #include "stdafx.h" -#include "fios.h" +#include "3rdparty/md5/md5.h" #include "fileio_func.h" -#include "tar_type.h" +#include "fios.h" +#include "network/network_content.h" #include "screenshot.h" #include "string_func.h" +#include "tar_type.h" #include #ifndef _WIN32 @@ -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 { +class ScenarioScanner : protected FileScanner, public std::vector { 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 */ diff --git a/src/fios.h b/src/fios.h index f937972d61..ee02d9aa3e 100644 --- a/src/fios.h +++ b/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 files; ///< The list of files. + std::vector files; ///< The list of files. }; enum SortingBits { diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 8098465852..55f99cc0d9 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -57,11 +57,10 @@ void LoadCheckData::Clear() this->current_date = 0; memset(&this->settings, 0, sizeof(this->settings)); - const CompanyPropertiesMap::iterator end = this->companies.End(); - for (CompanyPropertiesMap::iterator it = this->companies.Begin(); it != end; it++) { - delete it->second; + for (auto &pair : this->companies) { + delete pair.second; } - companies.Clear(); + companies.clear(); GamelogFree(this->gamelog_action, this->gamelog_actions); this->gamelog_action = NULL; @@ -281,7 +280,7 @@ private: StringFilter string_filter; ///< Filter for available games. QueryString filter_editbox; ///< Filter editbox; - SmallVector fios_items_shown; ///< Map of the filtered out fios items + std::vector fios_items_shown; ///< Map of the filtered out fios items static void SaveGameConfirmationCallback(Window *w, bool confirmed) { @@ -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); diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 54c83d8185..2190f91c81 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -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; } diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 060b19a4a1..fe8338899d 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -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(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; diff --git a/src/game/game.hpp b/src/game/game.hpp index 329ba5e500..95d9aa0a13 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -112,11 +112,9 @@ public: */ static class GameInstance *GetInstance() { return Game::instance; } -#if defined(ENABLE_NETWORK) /** Wrapper function for GameScanner::HasGame */ static bool HasGame(const struct ContentInfo *ci, bool md5sum); static bool HasGameLibrary(const ContentInfo *ci, bool md5sum); -#endif /** Gets the ScriptScanner instance that is used to find Game scripts */ static GameScannerInfo *GetScannerInfo(); /** Gets the ScriptScanner instance that is used to find Game Libraries */ diff --git a/src/game/game_config.hpp b/src/game/game_config.hpp index e9ebdc38c1..dfae62c3a9 100644 --- a/src/game/game_config.hpp +++ b/src/game/game_config.hpp @@ -42,7 +42,7 @@ public: bool ResetInfo(bool force_exact_match); protected: - /* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match); + ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override; }; #endif /* GAME_CONFIG_HPP */ diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index 10b079bee3..7b05abb40d 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -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; diff --git a/src/game/game_info.hpp b/src/game/game_info.hpp index f4fc5ed86b..a799ed7d6d 100644 --- a/src/game/game_info.hpp +++ b/src/game/game_info.hpp @@ -40,7 +40,7 @@ public: */ const char *GetAPIVersion() const { return this->api_version; } - /* virtual */ bool IsDeveloperOnly() const { return this->is_developer_only; } + bool IsDeveloperOnly() const override { return this->is_developer_only; } private: int min_loadable_version; ///< The Game can load savegame data if the version is equal or greater than this. diff --git a/src/game/game_instance.hpp b/src/game/game_instance.hpp index 08ce344247..dd0e7950aa 100644 --- a/src/game/game_instance.hpp +++ b/src/game/game_instance.hpp @@ -25,14 +25,14 @@ public: */ void Initialize(class GameInfo *info); - /* virtual */ int GetSetting(const char *name); - /* virtual */ ScriptInfo *FindLibrary(const char *library, int version); + int GetSetting(const char *name) override; + ScriptInfo *FindLibrary(const char *library, int version) override; private: - /* virtual */ void RegisterAPI(); - /* virtual */ void Died(); - /* virtual */ CommandCallback *GetDoCommandCallback(); - /* virtual */ void LoadDummyScript() {} + void RegisterAPI() override; + void Died() override; + CommandCallback *GetDoCommandCallback() override; + void LoadDummyScript() override {} }; #endif /* GAME_INSTANCE_HPP */ diff --git a/src/game/game_scanner.hpp b/src/game/game_scanner.hpp index 071d19d38d..492545c2b1 100644 --- a/src/game/game_scanner.hpp +++ b/src/game/game_scanner.hpp @@ -16,7 +16,7 @@ class GameScannerInfo : public ScriptScanner { public: - /* virtual */ void Initialize(); + void Initialize() override; /** * Check if we have a game by name and version available in our list. @@ -28,17 +28,17 @@ public: class GameInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match); protected: - /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last); - /* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; } - /* virtual */ Subdirectory GetDirectory() const { return GAME_DIR; } - /* virtual */ const char *GetScannerName() const { return "Game Scripts"; } - /* virtual */ void RegisterAPI(class Squirrel *engine); + void GetScriptName(ScriptInfo *info, char *name, const char *last) override; + const char *GetFileName() const override { return PATHSEP "info.nut"; } + Subdirectory GetDirectory() const override { return GAME_DIR; } + const char *GetScannerName() const override { return "Game Scripts"; } + void RegisterAPI(class Squirrel *engine) override; }; class GameScannerLibrary : public ScriptScanner { public: - /* virtual */ void Initialize(); + void Initialize() override; /** * Find a library in the pool. @@ -49,11 +49,11 @@ public: class GameLibrary *FindLibrary(const char *library, int version); protected: - /* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last); - /* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; } - /* virtual */ Subdirectory GetDirectory() const { return GAME_LIBRARY_DIR; } - /* virtual */ const char *GetScannerName() const { return "GS Libraries"; } - /* virtual */ void RegisterAPI(class Squirrel *engine); + void GetScriptName(ScriptInfo *info, char *name, const char *last) override; + const char *GetFileName() const override { return PATHSEP "library.nut"; } + Subdirectory GetDirectory() const override { return GAME_LIBRARY_DIR; } + const char *GetScannerName() const override { return "GS Libraries"; } + void RegisterAPI(class Squirrel *engine) override; }; #endif /* GAME_SCANNER_HPP */ diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp index a32e5b41d7..d57b2bc77f 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -115,7 +115,7 @@ LanguageStrings *ReadRawLanguageStrings(const char *file) while (i > 0 && (buffer[i - 1] == '\r' || buffer[i - 1] == '\n' || buffer[i - 1] == ' ')) i--; buffer[i] = '\0'; - *ret->lines.Append() = stredup(buffer, buffer + to_read - 1); + ret->lines.push_back(stredup(buffer, buffer + to_read - 1)); if (len > to_read) { to_read = 0; @@ -147,11 +147,11 @@ struct StringListReader : StringReader { * @param translation Are we reading a translation? */ StringListReader(StringData &data, const LanguageStrings *strings, bool master, bool translation) : - StringReader(data, strings->language, master, translation), p(strings->lines.Begin()), end(strings->lines.End()) + StringReader(data, strings->language, master, translation), p(strings->lines.data()), end(p + strings->lines.size()) { } - /* virtual */ char *ReadLine(char *buffer, const char *last) + char *ReadLine(char *buffer, const char *last) override { if (this->p == this->end) return NULL; @@ -194,7 +194,7 @@ struct TranslationWriter : LanguageWriter { char *dest = MallocT(length + 1); memcpy(dest, buffer, length); dest[length] = '\0'; - *this->strings->Append() = dest; + this->strings->push_back(dest); } }; @@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter { void WriteStringID(const char *name, int stringid) { - if (stringid == (int)this->strings->Length()) *this->strings->Append() = stredup(name); + if (stringid == (int)this->strings->size()) this->strings->push_back(stredup(name)); } void Finalise(const StringData &data) @@ -242,11 +242,11 @@ public: this->FileScanner::Scan(".txt", directory, false); } - /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) + bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override { if (strcmp(filename, exclude) == 0) return true; - *gs->raw_strings.Append() = ReadRawLanguageStrings(filename); + gs->raw_strings.push_back(ReadRawLanguageStrings(filename)); return true; } }; @@ -269,7 +269,7 @@ GameStrings *LoadTranslations() GameStrings *gs = new GameStrings(); try { - *gs->raw_strings.Append() = ReadRawLanguageStrings(filename); + gs->raw_strings.push_back(ReadRawLanguageStrings(filename)); /* Scan for other language files */ LanguageScanner scanner(gs, filename); @@ -318,14 +318,14 @@ void GameStrings::Compile() StringNameWriter id_writer(&this->string_names); id_writer.WriteHeader(data); - for (LanguageStrings **p = this->raw_strings.Begin(); p != this->raw_strings.End(); p++) { + for (LanguageStrings *p : this->raw_strings) { data.FreeTranslation(); - StringListReader translation_reader(data, *p, false, strcmp((*p)->language, "english") != 0); + StringListReader translation_reader(data, p, false, strcmp(p->language, "english") != 0); translation_reader.ParseFile(); if (_errors != 0) throw std::exception(); - LanguageStrings *compiled = *this->compiled_strings.Append() = new LanguageStrings((*p)->language); - TranslationWriter writer(&compiled->lines); + this->compiled_strings.push_back(new LanguageStrings(p->language)); + TranslationWriter writer(&this->compiled_strings.back()->lines); writer.WriteLang(data); } } @@ -340,7 +340,7 @@ GameStrings *_current_data = NULL; */ const char *GetGameStringPtr(uint id) { - if (id >= _current_data->cur_language->lines.Length()) return GetStringPtr(STR_UNDEFINED); + if (id >= _current_data->cur_language->lines.size()) return GetStringPtr(STR_UNDEFINED); return _current_data->cur_language->lines[id]; } @@ -360,10 +360,11 @@ void RegisterGameTranslation(Squirrel *engine) if (SQ_FAILED(sq_get(vm, -2))) return; int idx = 0; - for (const char * const *p = _current_data->string_names.Begin(); p != _current_data->string_names.End(); p++, idx++) { - sq_pushstring(vm, *p, -1); + for (const char * const p : _current_data->string_names) { + sq_pushstring(vm, p, -1); sq_pushinteger(vm, idx); sq_rawset(vm, -3); + idx++; } sq_pop(vm, 2); @@ -391,9 +392,9 @@ void ReconsiderGameScriptLanguage() assert(language != NULL); language++; - for (LanguageStrings **p = _current_data->compiled_strings.Begin(); p != _current_data->compiled_strings.End(); p++) { - if (strcmp((*p)->language, language) == 0) { - _current_data->cur_language = *p; + for (LanguageStrings *p : _current_data->compiled_strings) { + if (strcmp(p->language, language) == 0) { + _current_data->cur_language = p; return; } } diff --git a/src/game/game_text.hpp b/src/game/game_text.hpp index 14da7d9b2e..11c63b5abb 100644 --- a/src/game/game_text.hpp +++ b/src/game/game_text.hpp @@ -32,9 +32,9 @@ struct GameStrings { uint version; ///< The version of the language strings. LanguageStrings *cur_language; ///< The current (compiled) language. - AutoDeleteSmallVector raw_strings; ///< The raw strings per language, first must be English/the master language!. - AutoDeleteSmallVector compiled_strings; ///< The compiled strings per language, first must be English/the master language!. - StringList string_names; ///< The names of the compiled strings. + AutoDeleteSmallVector raw_strings; ///< The raw strings per language, first must be English/the master language!. + AutoDeleteSmallVector compiled_strings; ///< The compiled strings per language, first must be English/the master language!. + StringList string_names; ///< The names of the compiled strings. void Compile(); }; diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 074159138c..d811d5e7e9 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -155,6 +155,7 @@ struct GRFPresence{ bool was_missing; ///< Grf was missing during some gameload in the past GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {} + GRFPresence() = default; }; typedef SmallMap GrfIDMapping; diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 4c8ff79666..e10d68e86f 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -315,7 +315,7 @@ static DropDownList *BuildMapsizeDropDown(int other_dimension) for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) { DropDownListParamStringItem *item = new DropDownListParamStringItem((i + other_dimension > MAX_MAP_TILES_BITS) ? STR_RED_INT : STR_JUST_INT, i, false); item->SetParam(0, 1LL << i); - *list->Append() = item; + list->push_back(item); } return list; @@ -368,7 +368,7 @@ struct GenerateLandscapeWindow : public Window { } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break; @@ -429,7 +429,7 @@ struct GenerateLandscapeWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; /* Update the climate buttons */ @@ -476,7 +476,7 @@ struct GenerateLandscapeWindow : public Window { } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { const StringID *strs = NULL; switch (widget) { @@ -554,7 +554,7 @@ struct GenerateLandscapeWindow : public Window { size->height = max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM)); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_GL_HEIGHTMAP_NAME_TEXT: { @@ -564,7 +564,7 @@ struct GenerateLandscapeWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_GL_TEMPERATE: @@ -740,7 +740,7 @@ struct GenerateLandscapeWindow : public Window { } } - virtual void OnTimeout() + void OnTimeout() override { static const int raise_widgets[] = {WID_GL_MAX_HEIGHTLEVEL_DOWN, WID_GL_MAX_HEIGHTLEVEL_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_LEVEL_UP, WID_GL_SNOW_LEVEL_DOWN, WIDGET_LIST_END}; for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) { @@ -751,7 +751,7 @@ struct GenerateLandscapeWindow : public Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_GL_MAPSIZE_X_PULLDOWN: @@ -801,7 +801,7 @@ struct GenerateLandscapeWindow : public Window { this->InvalidateData(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { /* Was 'cancel' pressed? */ if (str == NULL) return; @@ -940,7 +940,7 @@ struct CreateScenarioWindow : public Window SetDropDownColor(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_CS_START_DATE_TEXT: @@ -961,9 +961,7 @@ struct CreateScenarioWindow : public Window } } - - - virtual void OnPaint() + void OnPaint() override { this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); this->SetWidgetDisabledState(WID_CS_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR); @@ -978,7 +976,7 @@ struct CreateScenarioWindow : public Window this->DrawWidgets(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { StringID str = STR_JUST_INT; switch (widget) { @@ -1004,7 +1002,7 @@ struct CreateScenarioWindow : public Window size->height += padding.height; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_CS_TEMPERATE: @@ -1071,7 +1069,7 @@ struct CreateScenarioWindow : public Window } } - virtual void OnTimeout() + void OnTimeout() override { static const int raise_widgets[] = {WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP, WIDGET_LIST_END}; for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) { @@ -1082,7 +1080,7 @@ struct CreateScenarioWindow : public Window } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break; @@ -1093,7 +1091,7 @@ struct CreateScenarioWindow : public Window this->SetDirty(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (!StrEmpty(str)) { int32 value = atoi(str); @@ -1245,7 +1243,7 @@ struct GenerateProgressWindow : public Window { this->InitNested(); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_GP_ABORT: @@ -1260,7 +1258,7 @@ struct GenerateProgressWindow : public Window { } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_GP_PROGRESS_BAR: { @@ -1281,7 +1279,7 @@ struct GenerateProgressWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_GP_PROGRESS_BAR: diff --git a/src/gfx.cpp b/src/gfx.cpp index b0c055624a..bc4023350e 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -86,9 +86,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) if (_cursor.visible) UndrawMouseCursor(); -#ifdef ENABLE_NETWORK if (_networking) NetworkUndrawChatMessage(); -#endif /* ENABLE_NETWORK */ blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo); /* This part of the screen is now dirty. */ @@ -511,9 +509,9 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour, } Layouter layout(str, INT32_MAX, colour, fontsize); - if (layout.Length() == 0) return 0; + if (layout.size() == 0) return 0; - return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true); + return DrawLayoutLine(layout.front(), top, left, right, align, underline, true); } /** @@ -576,7 +574,7 @@ int GetStringLineCount(StringID str, int maxw) GetString(buffer, str, lastof(buffer)); Layouter layout(buffer, maxw); - return layout.Length(); + return layout.size(); } /** @@ -649,8 +647,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st int last_line = top; int first_line = bottom; - for (const ParagraphLayouter::Line **iter = layout.Begin(); iter != layout.End(); iter++) { - const ParagraphLayouter::Line *line = *iter; + for (const ParagraphLayouter::Line *line : layout) { int line_height = line->GetLeading(); if (y >= top && y < bottom) { @@ -970,7 +967,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo if (topleft <= clicked && clicked <= bottomright) { uint offset = (((size_t)clicked - (size_t)topleft) / (blitter->GetScreenDepth() / 8)) % bp.pitch; if (offset < (uint)bp.width) { - _newgrf_debug_sprite_picker.sprites.Include(sprite_id); + include(_newgrf_debug_sprite_picker.sprites, sprite_id); } } } @@ -1291,9 +1288,7 @@ void RedrawScreenRect(int left, int top, int right, int bottom) } } -#ifdef ENABLE_NETWORK if (_networking) NetworkUndrawChatMessage(); -#endif /* ENABLE_NETWORK */ DrawOverlappedWindowForAll(left, top, right, bottom); diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index 3bf490da67..f09b87efa9 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -124,7 +124,7 @@ le_bool Font::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &poin /** * Wrapper for doing layouts with ICU. */ -class ICUParagraphLayout : public AutoDeleteSmallVector, public ParagraphLayouter { +class ICUParagraphLayout : public AutoDeleteSmallVector, public ParagraphLayouter { icu::ParagraphLayout *p; ///< The actual ICU paragraph layout. public: /** Visual run contains data about the bit of text with the same font. */ @@ -143,14 +143,14 @@ public: }; /** A single line worth of VisualRuns. */ - class ICULine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { + class ICULine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { icu::ParagraphLayout::Line *l; ///< The actual ICU line. public: ICULine(icu::ParagraphLayout::Line *l) : l(l) { for (int i = 0; i < l->countRuns(); i++) { - *this->Append() = new ICUVisualRun(l->getVisualRun(i)); + this->push_back(new ICUVisualRun(l->getVisualRun(i))); } } ~ICULine() { delete l; } @@ -158,7 +158,7 @@ public: int GetLeading() const { return l->getLeading(); } int GetWidth() const { return l->getWidth(); } int CountRuns() const { return l->countRuns(); } - const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { @@ -196,13 +196,13 @@ public: /* ICU's ParagraphLayout cannot handle empty strings, so fake one. */ buff[0] = ' '; length = 1; - fontMapping.End()[-1].first++; + fontMapping.back().first++; } /* Fill ICU's FontRuns with the right data. */ - icu::FontRuns runs(fontMapping.Length()); - for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) { - runs.add(iter->second, iter->first); + icu::FontRuns runs(fontMapping.size()); + for (auto &pair : fontMapping) { + runs.add(pair.second, pair.first); } LEErrorCode status = LE_NO_ERROR; @@ -269,7 +269,7 @@ public: }; /** A single line worth of VisualRuns. */ - class FallbackLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { + class FallbackLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { public: int GetLeading() const; int GetWidth() const; @@ -419,8 +419,8 @@ int FallbackParagraphLayout::FallbackVisualRun::GetLeading() const int FallbackParagraphLayout::FallbackLine::GetLeading() const { int leading = 0; - for (const FallbackVisualRun * const *run = this->Begin(); run != this->End(); run++) { - leading = max(leading, (*run)->GetLeading()); + for (const FallbackVisualRun * const &run : *this) { + leading = max(leading, run->GetLeading()); } return leading; @@ -432,7 +432,7 @@ int FallbackParagraphLayout::FallbackLine::GetLeading() const */ int FallbackParagraphLayout::FallbackLine::GetWidth() const { - if (this->Length() == 0) return 0; + if (this->size() == 0) return 0; /* * The last X position of a run contains is the end of that run. @@ -449,7 +449,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const */ int FallbackParagraphLayout::FallbackLine::CountRuns() const { - return this->Length(); + return this->size(); } /** @@ -458,7 +458,7 @@ int FallbackParagraphLayout::FallbackLine::CountRuns() const */ const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const { - return *this->Get(run); + return this->at(run); } /** @@ -498,12 +498,12 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width) if (*this->buffer == '\0') { /* Only a newline. */ this->buffer = NULL; - *l->Append() = new FallbackVisualRun(this->runs.Begin()->second, this->buffer, 0, 0); + l->push_back(new FallbackVisualRun(this->runs.front().second, this->buffer, 0, 0)); return l; } int offset = this->buffer - this->buffer_begin; - FontMap::iterator iter = this->runs.Begin(); + FontMap::iterator iter = this->runs.data(); while (iter->first <= offset) { iter++; assert(iter != this->runs.End()); @@ -527,7 +527,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width) if (this->buffer == next_run) { int w = l->GetWidth(); - *l->Append() = new FallbackVisualRun(iter->second, begin, this->buffer - begin, w); + l->push_back(new FallbackVisualRun(iter->second, begin, this->buffer - begin, w)); iter++; assert(iter != this->runs.End()); @@ -572,9 +572,9 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width) this->buffer++; } - if (l->Length() == 0 || last_char - begin != 0) { + if (l->size() == 0 || last_char - begin != 0) { int w = l->GetWidth(); - *l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w); + l->push_back(new FallbackVisualRun(iter->second, begin, last_char - begin, w)); } return l; } @@ -600,7 +600,7 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str, Font *f = Layouter::GetFont(state.fontsize, state.cur_colour); line.buffer = buff_begin; - fontMapping.Clear(); + fontMapping.clear(); /* * Go through the whole string while adding Font instances to the font map @@ -720,7 +720,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi /* Copy all lines into a local cache so we can reuse them later on more easily. */ const ParagraphLayouter::Line *l; while ((l = line.layout->NextLine(maxw)) != NULL) { - *this->Append() = l; + this->push_back(l); } } while (c != '\0'); @@ -733,9 +733,9 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi Dimension Layouter::GetBounds() { Dimension d = { 0, 0 }; - for (const ParagraphLayouter::Line **l = this->Begin(); l != this->End(); l++) { - d.width = max(d.width, (*l)->GetWidth()); - d.height += (*l)->GetLeading(); + for (const ParagraphLayouter::Line *l : *this) { + d.width = max(d.width, l->GetWidth()); + d.height += l->GetLeading(); } return d; } @@ -757,12 +757,12 @@ Point Layouter::GetCharPosition(const char *ch) const size_t len = Utf8Decode(&c, str); if (c == '\0' || c == '\n') break; str += len; - index += (*this->Begin())->GetInternalCharLength(c); + index += this->front()->GetInternalCharLength(c); } if (str == ch) { /* Valid character. */ - const ParagraphLayouter::Line *line = *this->Begin(); + const ParagraphLayouter::Line *line = this->front(); /* Pointer to the end-of-string/line marker? Return total line width. */ if (*ch == '\0' || *ch == '\n') { @@ -795,7 +795,7 @@ Point Layouter::GetCharPosition(const char *ch) const */ const char *Layouter::GetCharAtPosition(int x) const { - const ParagraphLayouter::Line *line = *this->Begin(); + const ParagraphLayouter::Line *line = this->front(); for (int run_index = 0; run_index < line->CountRuns(); run_index++) { const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index); @@ -834,7 +834,7 @@ Font *Layouter::GetFont(FontSize size, TextColour colour) if (it != fonts[size].End()) return it->second; Font *f = new Font(size, colour); - *fonts[size].Append() = FontColourMap::Pair(colour, f); + fonts[size].emplace_back(colour, f); return f; } @@ -844,10 +844,10 @@ Font *Layouter::GetFont(FontSize size, TextColour colour) */ void Layouter::ResetFontCache(FontSize size) { - for (FontColourMap::iterator it = fonts[size].Begin(); it != fonts[size].End(); ++it) { - delete it->second; + for (auto &pair : fonts[size]) { + delete pair.second; } - fonts[size].Clear(); + fonts[size].clear(); /* We must reset the linecache since it references the just freed fonts */ ResetLineCache(); diff --git a/src/gfx_layout.h b/src/gfx_layout.h index 6f611d6e66..93cc6fb2da 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -150,7 +150,7 @@ public: * * It also accounts for the memory allocations and frees. */ -class Layouter : public AutoDeleteSmallVector { +class Layouter : public AutoDeleteSmallVector { const char *string; ///< Pointer to the original string. /** Key into the linecache */ diff --git a/src/goal.cpp b/src/goal.cpp index f7aae350e5..eba72b7f40 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -247,20 +247,14 @@ CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint { uint16 uniqueid = (GoalType)GB(p1, 0, 16); CompanyID company = (CompanyID)GB(p1, 16, 8); -#ifdef ENABLE_NETWORK ClientIndex client = (ClientIndex)GB(p1, 16, 8); -#endif byte type = GB(p1, 24, 2); bool is_client = HasBit(p1, 31); if (_current_company != OWNER_DEITY) return CMD_ERROR; if (StrEmpty(text)) return CMD_ERROR; if (is_client) { -#ifdef ENABLE_NETWORK if (!NetworkClientInfo::IsValidID(client)) return CMD_ERROR; -#else - return CMD_ERROR; -#endif } else { if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR; } @@ -270,9 +264,7 @@ CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (flags & DC_EXEC) { if (is_client) { -#ifdef ENABLE_NETWORK if (NetworkClientInfo::Get(client)->client_id != _network_own_client_id) return CommandCost(); -#endif } else { if (company == INVALID_COMPANY && !Company::IsValidID(_local_company)) return CommandCost(); if (company != INVALID_COMPANY && company != _local_company) return CommandCost(); diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index ee4d8170e1..7c3e330043 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -50,7 +50,7 @@ struct GoalListWindow : public Window { this->OnInvalidateData(0); } - /* virtual */ void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget != WID_GOAL_CAPTION) return; @@ -62,7 +62,7 @@ struct GoalListWindow : 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_GOAL_LIST) return; @@ -177,7 +177,7 @@ struct GoalListWindow : public Window { return 3 + num_global + num_company; } - /* 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_GOAL_LIST) return; Dimension d = maxdim(GetStringBoundingBox(STR_GOALS_GLOBAL_TITLE), GetStringBoundingBox(STR_GOALS_COMPANY_TITLE)); @@ -272,7 +272,7 @@ struct GoalListWindow : public Window { DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, false, column); } - /* virtual */ void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -299,7 +299,7 @@ struct GoalListWindow : public Window { } - /* virtual */ void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST); } @@ -309,7 +309,7 @@ struct GoalListWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - /* virtual */ void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; this->vscroll->SetCount(this->CountLines()); @@ -388,7 +388,7 @@ struct GoalQuestionWindow : public Window { free(this->question); } - /* virtual */ void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_GQ_CAPTION: @@ -409,7 +409,7 @@ struct GoalQuestionWindow : public Window { } } - /* virtual */ void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_GQ_BUTTON_1: @@ -429,7 +429,7 @@ struct GoalQuestionWindow : 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_GQ_QUESTION) return; @@ -437,7 +437,7 @@ struct GoalQuestionWindow : public Window { size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE; } - /* virtual */ void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_GQ_QUESTION) return; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 39df8ab6e2..69bdb3b1fc 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -56,7 +56,7 @@ struct GraphLegendWindow : Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -74,7 +74,7 @@ struct GraphLegendWindow : Window { DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + 4)), r.right - (rtl ? (d.width + 4) : (uint)WD_FRAMERECT_RIGHT), r.top + (r.bottom - r.top + 1 - FONT_HEIGHT_NORMAL) / 2, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -93,7 +93,7 @@ struct GraphLegendWindow : 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 (Company::IsValidID(data)) return; @@ -485,7 +485,7 @@ protected: } 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 { if (widget != this->graph_widget) return; @@ -521,7 +521,7 @@ public: size->height = max(size->height, size->width / 3); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != this->graph_widget) return; @@ -533,13 +533,13 @@ public: return INVALID_DATAPOINT; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { /* Clicked on legend? */ if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend(); } - virtual void OnGameTick() + void OnGameTick() override { this->UpdateStatistics(false); } @@ -549,7 +549,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; this->UpdateStatistics(true); @@ -621,7 +621,7 @@ struct OperatingProfitGraphWindow : BaseGraphWindow { this->InitializeWindow(window_number); } - virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) + OverflowSafeInt64 GetGraphData(const Company *c, int j) override { return c->old_economy[j].income + c->old_economy[j].expenses; } @@ -672,7 +672,7 @@ struct IncomeGraphWindow : BaseGraphWindow { this->InitializeWindow(window_number); } - virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) + OverflowSafeInt64 GetGraphData(const Company *c, int j) override { return c->old_economy[j].income; } @@ -721,7 +721,7 @@ struct DeliveredCargoGraphWindow : BaseGraphWindow { this->InitializeWindow(window_number); } - virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) + OverflowSafeInt64 GetGraphData(const Company *c, int j) override { return c->old_economy[j].delivered_cargo.GetSum(); } @@ -770,12 +770,12 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow { this->InitializeWindow(window_number); } - virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) + OverflowSafeInt64 GetGraphData(const Company *c, int j) override { return c->old_economy[j].performance_history; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail(); this->BaseGraphWindow::OnClick(pt, widget, click_count); @@ -826,7 +826,7 @@ struct CompanyValueGraphWindow : BaseGraphWindow { this->InitializeWindow(window_number); } - virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) + OverflowSafeInt64 GetGraphData(const Company *c, int j) override { return c->old_economy[j].company_value; } @@ -903,7 +903,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - 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_CPR_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -926,7 +926,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { resize->height = this->line_height; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -963,7 +963,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_CPR_ENABLE_CARGOES: @@ -1004,12 +1004,12 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_CPR_MATRIX); } - virtual void OnGameTick() + void OnGameTick() override { /* Override default OnGameTick */ } @@ -1019,13 +1019,13 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { * @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; this->OnHundredthTick(); } - virtual void OnHundredthTick() + void OnHundredthTick() override { this->UpdateExcludedData(); @@ -1136,14 +1136,14 @@ private: { if (!this->companies.NeedRebuild()) return; - this->companies.Clear(); + this->companies.clear(); const Company *c; FOR_ALL_COMPANIES(c) { - *this->companies.Append() = c; + this->companies.push_back(c); } - this->companies.Compact(); + this->companies.shrink_to_fit(); this->companies.RebuildDone(); } @@ -1161,7 +1161,7 @@ public: this->companies.NeedResort(); } - virtual void OnPaint() + void OnPaint() override { this->BuildCompanyList(); this->companies.Sort(&PerformanceSorter); @@ -1169,7 +1169,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_CL_BACKGROUND) return; @@ -1183,7 +1183,7 @@ public: uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width; uint text_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT; - for (uint i = 0; i != this->companies.Length(); i++) { + for (uint i = 0; i != this->companies.size(); i++) { const Company *c = this->companies[i]; DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW); @@ -1197,7 +1197,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 { if (widget != WID_CL_BACKGROUND) return; @@ -1236,7 +1236,7 @@ public: } - virtual void OnGameTick() + void OnGameTick() override { if (this->companies.NeedResort()) { this->SetDirty(); @@ -1248,7 +1248,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 */ @@ -1318,7 +1318,7 @@ struct PerformanceRatingDetailWindow : Window { uint score_detail_left; uint score_detail_right; - 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_PRD_SCORE_FIRST: @@ -1376,7 +1376,7 @@ struct PerformanceRatingDetailWindow : Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { /* No need to draw when there's nothing to draw */ if (this->company == INVALID_COMPANY) return; @@ -1455,7 +1455,7 @@ struct PerformanceRatingDetailWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { /* Check which button is clicked */ if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) { @@ -1469,7 +1469,7 @@ struct PerformanceRatingDetailWindow : Window { } } - virtual void OnGameTick() + void OnGameTick() override { /* Update the company score every 5 days */ if (--this->timeout == 0) { @@ -1483,7 +1483,7 @@ struct PerformanceRatingDetailWindow : Window { * @param data the company ID of the company that is going to be removed * @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; /* Disable the companies who are not active */ diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index bc515a90a3..fcf27fc550 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -93,7 +93,7 @@ struct GroundVehicle : public SpecializedVehicle { void PowerChanged(); void CargoChanged(); - bool IsChainInDepot() const; + bool IsChainInDepot() const override; void CalculatePower(uint32& power, uint32& max_te, bool breakdowns) const; @@ -104,7 +104,7 @@ struct GroundVehicle : public SpecializedVehicle { * @param flooded was this vehicle flooded? * @return number of victims */ - /* virtual */ uint Crash(bool flooded) + uint Crash(bool flooded) override { /* Crashed vehicles aren't going up or down */ for (T *v = T::From(this); v != NULL; v = v->Next()) { diff --git a/src/group.h b/src/group.h index 062c66837e..f8c92f9553 100644 --- a/src/group.h +++ b/src/group.h @@ -73,6 +73,8 @@ struct Group : GroupPool::PoolItem<&_group_pool> { Livery livery; ///< Custom colour scheme for vehicles in this group GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group. + bool folded; ///< NOSAVE: Is this group folded in the group view? + GroupID parent; ///< Parent group Group(CompanyID owner = INVALID_COMPANY); @@ -105,6 +107,9 @@ static inline bool IsTopLevelGroupID(GroupID index) uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e); +uint GetGroupNumVehicle(CompanyID company, GroupID id_g, VehicleType type); +uint GetGroupNumProfitVehicle(CompanyID company, GroupID id_g, VehicleType type); +Money GetGroupProfitLastYear(CompanyID company, GroupID id_g, VehicleType type); void SetTrainGroupID(Train *v, GroupID grp); void UpdateTrainGroupID(Train *v); diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index cb1e19f78b..708653f8da 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -306,6 +306,7 @@ void PropagateChildLivery(const Group *g) Group::Group(Owner owner) { this->owner = owner; + this->folded = false; } Group::~Group() @@ -463,7 +464,7 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* Ensure request parent isn't child of group. * This is the only place that infinite loops are prevented. */ - if (GroupIsInGroup(pg->index, g->index)) return CMD_ERROR; + if (GroupIsInGroup(pg->index, g->index)) return_cmd_error(STR_ERROR_GROUP_CAN_T_SET_PARENT_RECURSION); } if (flags & DC_EXEC) { @@ -522,7 +523,7 @@ CommandCost CmdCreateGroupFromList(TileIndex tile, DoCommandFlag flags, uint32 p DoCommand(tile, g->index, 0, flags, CMD_ALTER_GROUP, text); } - for (uint i = 0; i < list.Length(); i++) { + for (uint i = 0; i < list.size(); i++) { const Vehicle *v = list[i]; /* Just try and don't care if some vehicle's can't be added. */ @@ -867,6 +868,60 @@ uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e) return count + GroupStatistics::Get(company, id_g, e->type).num_engines[id_e]; } +/** + * Get the number of vehicles in the group with GroupID + * id_g and its sub-groups. + * @param company The company the group belongs to + * @param id_g The GroupID of the group used + * @param type The vehicle type of the group + * @return The number of vehicles in the group + */ +uint GetGroupNumVehicle(CompanyID company, GroupID id_g, VehicleType type) +{ + uint count = 0; + const Group *g; + FOR_ALL_GROUPS(g) { + if (g->parent == id_g) count += GetGroupNumVehicle(company, g->index, type); + } + return count + GroupStatistics::Get(company, id_g, type).num_vehicle; +} + +/** + * Get the number of vehicles above profit minimum age in the group with GroupID + * id_g and its sub-groups. + * @param company The company the group belongs to + * @param id_g The GroupID of the group used + * @param type The vehicle type of the group + * @return The number of vehicles above profit minimum age in the group + */ +uint GetGroupNumProfitVehicle(CompanyID company, GroupID id_g, VehicleType type) +{ + uint count = 0; + const Group *g; + FOR_ALL_GROUPS(g) { + if (g->parent == id_g) count += GetGroupNumProfitVehicle(company, g->index, type); + } + return count + GroupStatistics::Get(company, id_g, type).num_profit_vehicle; +} + +/** + * Get last year's profit for the group with GroupID + * id_g and its sub-groups. + * @param company The company the group belongs to + * @param id_g The GroupID of the group used + * @param type The vehicle type of the group + * @return Last year's profit for the group + */ +Money GetGroupProfitLastYear(CompanyID company, GroupID id_g, VehicleType type) +{ + Money sum = 0; + const Group *g; + FOR_ALL_GROUPS(g) { + if (g->parent == id_g) sum += GetGroupProfitLastYear(company, g->index, type); + } + return sum + GroupStatistics::Get(company, id_g, type).profit_last_year; +} + void RemoveAllGroupsForCompany(const CompanyID company) { Group *g; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index b013faadac..faeb5c9b74 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -68,11 +68,6 @@ static const NWidgetPart _nested_group_widgets[] = { SetDataTip(SPR_GROUP_RENAME_TRAIN, STR_GROUP_RENAME_TOOLTIP), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_LIVERY_GROUP), SetFill(0, 1), SetDataTip(SPR_GROUP_LIVERY_TRAIN, STR_GROUP_LIVERY_TOOLTIP), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_COLLAPSE_EXPAND_GROUP), SetFill(0, 1), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_COLLAPSE_ALL_GROUPS), SetFill(0, 1), - SetDataTip(STR_GROUP_COLLAPSE_ALL, STR_GROUP_COLLAPSE_ALL), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_EXPAND_ALL_GROUPS), SetFill(0, 1), - SetDataTip(STR_GROUP_EXPAND_ALL, STR_GROUP_EXPAND_ALL), NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_REPLACE_PROTECTION), SetFill(0, 1), SetDataTip(SPR_GROUP_REPLACE_OFF_TRAIN, STR_GROUP_REPLACE_PROTECTION_TOOLTIP), @@ -136,8 +131,8 @@ class VehicleGroupWindow : public BaseVehicleListWindow { private: /* Columns in the group list */ enum ListColumns { + VGC_FOLD, ///< Fold / Unfold button. VGC_NAME, ///< Group name. - VGC_COLLAPSED, ///< Collapsed icon VGC_PROTECT, ///< Autoreplace protect icon. VGC_AUTOREPLACE, ///< Autoreplace active icon. VGC_PROFIT, ///< Profit icon. @@ -153,46 +148,27 @@ private: GUIGroupList groups; ///< List of groups uint tiny_step_height; ///< Step height for the group list Scrollbar *group_sb; - SmallVector all_groups; ///< List of all groups, including hidden ones - SmallVector collapsed_groups; ///< List of collapsed groups - SmallVector collapsable_groups; ///< List of collapsable groups - SmallVector indents; ///< Indentation levels + std::vector indents; ///< Indentation levels Dimension column_size[VGC_END]; ///< Size of the columns in the group list. /** return true if group has children */ - bool AddChildren(GUIGroupList *source, GroupID parent, int indent, bool parent_collapsed) + void AddChildren(GUIGroupList *source, GroupID parent, int indent) { - bool is_collapsed = this->collapsed_groups.Contains(parent); - bool overall_collapsed = is_collapsed || parent_collapsed; - bool has_children = false; - - for (const Group **g = source->Begin(); g != source->End(); g++) { - if ((*g)->parent == parent) { - has_children = true; - *this->all_groups.Append() = (*g)->index; - if (!overall_collapsed) { - *this->groups.Append() = *g; - *this->indents.Append() = indent; - } - bool child_has_children = AddChildren(source, (*g)->index, indent + 1, overall_collapsed); - if (child_has_children) *this->collapsable_groups.Append() = (*g)->index; + for (const Group *g : *source) { + if (g->parent != parent) continue; + this->groups.push_back(g); + this->indents.push_back(indent); + if (g->folded) { + /* Test if this group has children at all. If not, the folded flag should be cleared to avoid lingering unfold buttons in the list. */ + auto child = std::find_if(source->begin(), source->end(), [g](const Group *child){ return child->parent == g->index; }); + bool has_children = child != source->end(); + Group::Get(g->index)->folded = has_children; + } else { + AddChildren(source, g->index, indent + 1); } } - return has_children; - } - - void ToogleGroupCollapse(GroupID group) - { - GroupID *item = this->collapsed_groups.Find(group); - if (item == this->collapsed_groups.End()) { - if (this->collapsable_groups.Find(group) != this->collapsable_groups.End()) { - *(this->collapsed_groups.Append()) = group; - } - } else { - this->collapsed_groups.Erase(item); - } } /** @@ -204,26 +180,24 @@ private: { if (!this->groups.NeedRebuild()) return; - this->all_groups.Clear(); - this->groups.Clear(); - this->indents.Clear(); - this->collapsable_groups.Clear(); + this->groups.clear(); + this->indents.clear(); GUIGroupList list; const Group *g; FOR_ALL_GROUPS(g) { if (g->owner == owner && g->vehicle_type == this->vli.vtype) { - *list.Append() = g; + list.push_back(g); } } list.ForceResort(); list.Sort(&GroupNameSorter); - AddChildren(&list, INVALID_GROUP, 0, false); + AddChildren(&list, INVALID_GROUP, 0); - this->groups.Compact(); + this->groups.shrink_to_fit(); this->groups.RebuildDone(); } @@ -233,12 +207,12 @@ private: */ uint ComputeGroupInfoSize() { + this->column_size[VGC_FOLD] = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED)); + this->tiny_step_height = this->column_size[VGC_FOLD].height; + this->column_size[VGC_NAME] = maxdim(GetStringBoundingBox(STR_GROUP_DEFAULT_TRAINS + this->vli.vtype), GetStringBoundingBox(STR_GROUP_ALL_TRAINS + this->vli.vtype)); this->column_size[VGC_NAME].width = max((170u * FONT_HEIGHT_NORMAL) / 10u, this->column_size[VGC_NAME].width); - this->tiny_step_height = this->column_size[VGC_NAME].height; - - this->column_size[VGC_COLLAPSED] = GetSpriteSize(SPR_WINDOW_UNSHADE); - this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_COLLAPSED].height); + this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_NAME].height); this->column_size[VGC_PROTECT] = GetSpriteSize(SPR_GROUP_REPLACE_PROTECT); this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_PROTECT].height); @@ -255,15 +229,17 @@ private: } this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_PROFIT].height); - SetDParamMaxValue(0, GroupStatistics::Get(this->vli.company, ALL_GROUP, this->vli.vtype).num_vehicle, 3, FS_SMALL); - this->column_size[VGC_NUMBER] = GetStringBoundingBox(STR_TINY_COMMA); + int num_vehicle = GetGroupNumVehicle(this->vli.company, ALL_GROUP, this->vli.vtype); + SetDParamMaxValue(0, num_vehicle, 3, FS_SMALL); + SetDParamMaxValue(1, num_vehicle, 3, FS_SMALL); + this->column_size[VGC_NUMBER] = GetStringBoundingBox(STR_GROUP_COUNT_WITH_SUBGROUP); this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_NUMBER].height); this->tiny_step_height += WD_MATRIX_TOP; return WD_FRAMERECT_LEFT + 8 + + this->column_size[VGC_FOLD].width + 2 + this->column_size[VGC_NAME].width + 8 + - this->column_size[VGC_COLLAPSED].width + 2 + this->column_size[VGC_PROTECT].width + 2 + this->column_size[VGC_AUTOREPLACE].width + 2 + this->column_size[VGC_PROFIT].width + 2 + @@ -279,8 +255,9 @@ private: * @param g_id Group to list. * @param indent Indentation level. * @param protection Whether autoreplace protection is set. + * @param has_children Whether the group has children and should have a fold / unfold button. */ - void DrawGroupInfo(int y, int left, int right, GroupID g_id, int indent = 0, bool protection = false) const + void DrawGroupInfo(int y, int left, int right, GroupID g_id, int indent = 0, bool protection = false, bool has_children = false) const { /* Highlight the group if a vehicle is dragged over it */ if (g_id == this->group_over) { @@ -294,6 +271,12 @@ private: const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype); bool rtl = _current_text_dir == TD_RTL; + /* draw fold / unfold button */ + int x = rtl ? right - WD_FRAMERECT_RIGHT - 8 - this->column_size[VGC_FOLD].width + 1 : left + WD_FRAMERECT_LEFT + 8; + if (has_children) { + DrawSprite(Group::Get(g_id)->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED, PAL_NONE, rtl ? x - indent : x + indent, y + (this->tiny_step_height - this->column_size[VGC_FOLD].height) / 2); + } + /* draw group name */ StringID str; if (IsAllGroupID(g_id)) { @@ -304,15 +287,11 @@ private: SetDParam(0, g_id); str = STR_GROUP_NAME; } - int x = rtl ? right - WD_FRAMERECT_RIGHT - 8 - this->column_size[VGC_NAME].width + 1 : left + WD_FRAMERECT_LEFT + 8; + x = rtl ? x - 2 - this->column_size[VGC_NAME].width : x + 2 + this->column_size[VGC_FOLD].width; DrawString(x + (rtl ? 0 : indent), x + this->column_size[VGC_NAME].width - 1 - (rtl ? indent : 0), y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour); - /* draw collapse state */ - x = rtl ? x - 8 - this->column_size[VGC_COLLAPSED].width : x + 8 + this->column_size[VGC_NAME].width; - if (this->collapsed_groups.Contains(g_id)) DrawSprite(SPR_WINDOW_UNSHADE, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_COLLAPSED].height) / 2); - /* draw autoreplace protection */ - x = rtl ? x - 2 - this->column_size[VGC_PROTECT].width : x + 2 + this->column_size[VGC_COLLAPSED].width; + x = rtl ? x - 2 - this->column_size[VGC_PROTECT].width : x + 2 + this->column_size[VGC_NAME].width; if (protection) DrawSprite(SPR_GROUP_REPLACE_PROTECT, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_PROTECT].height) / 2); /* draw autoreplace status */ @@ -322,11 +301,13 @@ private: /* draw the profit icon */ x = rtl ? x - 2 - this->column_size[VGC_PROFIT].width : x + 2 + this->column_size[VGC_AUTOREPLACE].width; SpriteID spr; - if (stats.num_profit_vehicle == 0) { + uint num_profit_vehicle = GetGroupNumProfitVehicle(this->vli.company, g_id, this->vli.vtype); + Money profit_last_year = GetGroupProfitLastYear(this->vli.company, g_id, this->vli.vtype); + if (num_profit_vehicle == 0) { spr = SPR_PROFIT_NA; - } else if (stats.profit_last_year < 0) { + } else if (profit_last_year < 0) { spr = SPR_PROFIT_NEGATIVE; - } else if (stats.profit_last_year < 10000 * stats.num_profit_vehicle) { // TODO magic number + } else if (profit_last_year < (Money)10000 * num_profit_vehicle) { // TODO magic number spr = SPR_PROFIT_SOME; } else { spr = SPR_PROFIT_LOT; @@ -335,8 +316,16 @@ private: /* draw the number of vehicles of the group */ x = rtl ? x - 2 - this->column_size[VGC_NUMBER].width : x + 2 + this->column_size[VGC_PROFIT].width; - SetDParam(0, stats.num_vehicle); - DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_TINY_COMMA, colour, SA_RIGHT | SA_FORCE); + int num_vehicle_with_subgroups = GetGroupNumVehicle(this->vli.company, g_id, this->vli.vtype); + int num_vehicle = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype).num_vehicle; + if (IsAllGroupID(g_id) || IsDefaultGroupID(g_id) || num_vehicle_with_subgroups == num_vehicle) { + SetDParam(0, num_vehicle); + DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_TINY_COMMA, colour, SA_RIGHT | SA_FORCE); + } else { + SetDParam(0, num_vehicle); + SetDParam(1, num_vehicle_with_subgroups - num_vehicle); + DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_GROUP_COUNT_WITH_SUBGROUP, colour, SA_RIGHT | SA_FORCE); + } } /** @@ -392,9 +381,6 @@ public: this->GetWidget(WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype; this->GetWidget(WID_GL_LIST_VEHICLE)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype; - this->GetWidget(WID_GL_COLLAPSE_EXPAND_GROUP)->widget_data = STR_GROUP_COLLAPSE; - this->GetWidget(WID_GL_COLLAPSE_EXPAND_GROUP)->tool_tip = STR_GROUP_COLLAPSE_TOOLTIP; - this->GetWidget(WID_GL_CREATE_GROUP)->widget_data += this->vli.vtype; this->GetWidget(WID_GL_RENAME_GROUP)->widget_data += this->vli.vtype; this->GetWidget(WID_GL_DELETE_GROUP)->widget_data += this->vli.vtype; @@ -410,7 +396,7 @@ public: *this->sorting = this->vehicles.GetListing(); } - 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_GL_LIST_GROUP: { @@ -474,7 +460,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 */ @@ -501,7 +487,7 @@ public: this->SetDirty(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { @@ -518,21 +504,21 @@ public: if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) { SetDParam(0, STR_COMPANY_NAME); SetDParam(1, this->vli.company); - SetDParam(2, this->vehicles.Length()); - SetDParam(3, this->vehicles.Length()); + SetDParam(2, this->vehicles.size()); + SetDParam(3, this->vehicles.size()); } else { - const Group *g = Group::Get(this->vli.index); + uint num_vehicle = GetGroupNumVehicle(this->vli.company, this->vli.index, this->vli.vtype); SetDParam(0, STR_GROUP_NAME); - SetDParam(1, g->index); - SetDParam(2, g->statistics.num_vehicle); - SetDParam(3, g->statistics.num_vehicle); + SetDParam(1, this->vli.index); + SetDParam(2, num_vehicle); + SetDParam(3, num_vehicle); } break; } } - virtual void OnPaint() + void OnPaint() override { /* If we select the all vehicles, this->list will contain all vehicles of the owner * else this->list will contain all vehicles which belong to the selected group */ @@ -541,8 +527,8 @@ public: this->BuildGroupList(this->owner); - this->group_sb->SetCount(this->groups.Length()); - this->vscroll->SetCount(this->vehicles.Length()); + this->group_sb->SetCount(this->groups.size()); + this->vscroll->SetCount(this->vehicles.size()); /* The drop down menu is out, *but* it may not be used, retract it. */ if (!this->ShouldShowActionDropdownList() && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) { @@ -552,7 +538,7 @@ public: /* Disable all lists management button when the list is empty */ this->SetWidgetDisabledState(WID_GL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList() || _local_company != this->vli.company); - this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company || (IsTopLevelGroupID(this->vli.index) && _settings_client.gui.disable_top_veh_list_mass_actions), + this->SetWidgetsDisabledState(this->vehicles.size() == 0 || _local_company != this->vli.company || (IsTopLevelGroupID(this->vli.index) && _settings_client.gui.disable_top_veh_list_mass_actions), WID_GL_STOP_ALL, WID_GL_START_ALL, WIDGET_LIST_END); @@ -586,29 +572,10 @@ public: this->GetWidget(WID_GL_FILTER_BY_CARGO)->widget_data = this->cargo_filter_texts[this->cargo_filter_criteria]; - - bool is_non_collapsable_group = (this->vli.index == ALL_GROUP) || (this->vli.index == DEFAULT_GROUP) - || (this->vli.index == INVALID_GROUP) || !this->collapsable_groups.Contains(this->vli.index); - - this->SetWidgetDisabledState(WID_GL_COLLAPSE_EXPAND_GROUP, is_non_collapsable_group); - - NWidgetCore *collapse_widget = this->GetWidget(WID_GL_COLLAPSE_EXPAND_GROUP); - - if (is_non_collapsable_group || !this->collapsed_groups.Contains(this->vli.index)) { - collapse_widget->widget_data = STR_GROUP_COLLAPSE; - collapse_widget->tool_tip = STR_GROUP_COLLAPSE_TOOLTIP; - } else { - collapse_widget->widget_data = STR_GROUP_EXPAND; - collapse_widget->tool_tip = STR_GROUP_EXPAND_TOOLTIP; - } - - this->SetWidgetDisabledState(WID_GL_EXPAND_ALL_GROUPS, this->collapsed_groups.Length() == 0); - this->SetWidgetDisabledState(WID_GL_COLLAPSE_ALL_GROUPS, this->collapsable_groups.Length() == 0 || this->collapsed_groups.Length() == this->collapsable_groups.Length()); - this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_GL_ALL_VEHICLES: @@ -623,7 +590,7 @@ public: Money this_year = 0; Money last_year = 0; uint32 occupancy = 0; - uint32 vehicle_count = this->vehicles.Length(); + uint32 vehicle_count = this->vehicles.size(); for (uint i = 0; i < vehicle_count; i++) { const Vehicle *v = this->vehicles[i]; @@ -659,17 +626,17 @@ public: case WID_GL_LIST_GROUP: { int y1 = r.top + WD_FRAMERECT_TOP; - int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.Length()); + int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size()); for (int i = this->group_sb->GetPosition(); i < max; ++i) { const Group *g = this->groups[i]; assert(g->owner == this->owner); - DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * LEVEL_WIDTH, g->replace_protection); + DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * LEVEL_WIDTH, g->replace_protection, g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i])); y1 += this->tiny_step_height; } - if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.Length()) { + if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) { DrawGroupInfo(y1, r.left, r.right, NEW_GROUP); } break; @@ -683,7 +650,7 @@ public: if (this->vli.index != ALL_GROUP) { /* Mark vehicles which are in sub-groups */ int y = r.top; - uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.Length()); + uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size()); for (uint i = this->vscroll->GetPosition(); i < max; ++i) { const Vehicle *v = this->vehicles[i]; if (v->group_id != this->vli.index) { @@ -707,7 +674,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_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending @@ -742,15 +709,37 @@ public: case WID_GL_LIST_GROUP: { // Matrix Group uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); - if (id_g >= this->groups.Length()) return; + if (id_g >= this->groups.size()) return; + + if (groups[id_g]->folded || (id_g + 1 < this->groups.size() && this->indents[id_g + 1] > this->indents[id_g])) { + /* The group has children, check if the user clicked the fold / unfold button. */ + NWidgetCore *group_display = this->GetWidget(widget); + int x = _current_text_dir == TD_RTL ? + group_display->pos_x + group_display->current_x - WD_FRAMERECT_RIGHT - 8 - this->indents[id_g] * LEVEL_WIDTH - this->column_size[VGC_FOLD].width : + group_display->pos_x + WD_FRAMERECT_LEFT + 8 + this->indents[id_g] * LEVEL_WIDTH; + if (click_count > 1 || (pt.x >= x && pt.x < (int)(x + this->column_size[VGC_FOLD].width))) { + + GroupID g = this->vli.index; + if (!IsAllGroupID(g) && !IsDefaultGroupID(g)) { + do { + g = Group::Get(g)->parent; + if (g == groups[id_g]->index) { + this->vli.index = g; + break; + } + } while (g != INVALID_GROUP); + } - this->group_sel = this->vli.index = this->groups[id_g]->index; + Group::Get(groups[id_g]->index)->folded = !groups[id_g]->folded; + this->groups.ForceRebuild(); - if (click_count % 2 == 0) { - this->ToogleGroupCollapse(this->vli.index); - OnInvalidateData(); + this->SetDirty(); + break; + } } + this->group_sel = this->vli.index = this->groups[id_g]->index; + SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this); this->vehicles.ForceRebuild(); @@ -760,7 +749,7 @@ public: case WID_GL_LIST_VEHICLE: { // Matrix Vehicle uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE); - if (id_v >= this->vehicles.Length()) return; // click out of list bound + if (id_v >= this->vehicles.size()) return; // click out of list bound const Vehicle *v = this->vehicles[id_v]; if (VehicleClicked(v)) break; @@ -791,32 +780,6 @@ public: this->ShowRenameGroupWindow(this->vli.index, false); break; - case WID_GL_COLLAPSE_EXPAND_GROUP: // Toggle collapse/expand - this->ToogleGroupCollapse(this->vli.index); - OnInvalidateData(); - this->SetDirty(); - break; - - case WID_GL_COLLAPSE_ALL_GROUPS: { - this->collapsed_groups.Clear(); - for (const GroupID *gid = this->all_groups.Begin(); gid != this->all_groups.End(); ++gid) { - GroupID id = *gid; - if (id != ALL_GROUP && id != DEFAULT_GROUP && id != INVALID_GROUP && this->collapsable_groups.Contains(id)) { - *this->collapsed_groups.Append() = id; - } - } - OnInvalidateData(); - this->SetDirty(); - break; - } - - case WID_GL_EXPAND_ALL_GROUPS: { - this->collapsed_groups.Clear(); - OnInvalidateData(); - this->SetDirty(); - break; - } - case WID_GL_LIVERY_GROUP: // Set group livery ShowCompanyLiveryWindow(this->owner, this->vli.index); break; @@ -866,12 +829,10 @@ public: case WID_GL_LIST_GROUP: { // Matrix group uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); - GroupID new_g = id_g >= this->groups.Length() ? INVALID_GROUP : this->groups[id_g]->index; + GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index; if (this->group_sel != new_g && g->parent != new_g) { DoCommandP(0, this->group_sel | (1 << 16), new_g, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT)); - GroupID *group = this->collapsed_groups.Find(new_g); - if (group != this->collapsed_groups.End()) this->collapsed_groups.Erase(group); } this->group_sel = INVALID_GROUP; @@ -901,7 +862,7 @@ public: this->SetDirty(); uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); - GroupID new_g = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index; + GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : NULL); break; @@ -914,7 +875,7 @@ public: this->SetDirty(); uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE); - if (id_v >= this->vehicles.Length()) return; // click out of list bound + if (id_v >= this->vehicles.size()) return; // click out of list bound const Vehicle *v = this->vehicles[id_v]; if (!VehicleClicked(v) && vindex == v->index) { @@ -925,7 +886,7 @@ public: } } - virtual void OnDragDrop(Point pt, int widget) + void OnDragDrop(Point pt, int widget) override { if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget); if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget); @@ -933,20 +894,20 @@ public: _cursor.vehchain = false; } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str != NULL) DoCommandP(0, this->group_rename, 0, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_RENAME), NULL, str); InvalidateWindowData(WC_TEMPLATEGUI_MAIN, 0, 0, 0); this->group_rename = INVALID_GROUP; } - virtual void OnResize() + void OnResize() override { this->group_sb->SetCapacityFromWidget(this, WID_GL_LIST_GROUP); this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_GL_SORT_BY_DROPDOWN: @@ -1006,14 +967,14 @@ public: this->SetDirty(); } - virtual void OnGameTick() + void OnGameTick() override { if (this->groups.NeedResort() || this->vehicles.NeedResort()) { this->SetDirty(); } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { /* abort drag & drop */ this->vehicle_sel = INVALID_VEHICLE; @@ -1022,7 +983,7 @@ public: this->SetWidgetDirty(WID_GL_LIST_VEHICLE); } - virtual void OnMouseDrag(Point pt, int widget) + void OnMouseDrag(Point pt, int widget) override { if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return; @@ -1035,7 +996,7 @@ public: case WID_GL_LIST_GROUP: { // ... the list of custom groups. uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); - new_group_over = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index; + new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; break; } } diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index c67aaa170b..d6ea8c0c1c 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -63,12 +63,12 @@ struct EndGameHighScoreBaseWindow : Window { return pt; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { delete this; } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { /* All keys are 'handled' by this window but we want to make * sure that 'quit' still works correctly. Not handling the @@ -129,7 +129,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { ShowHighscoreTable(this->window_number, this->rank); } - virtual void OnPaint() + void OnPaint() override { this->SetupHighScoreEndWindow(); Point pt = this->GetTopLeft(640, 480); @@ -177,7 +177,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause } - virtual void OnPaint() + void OnPaint() override { const HighScore *hs = _highscore_table[this->window_number]; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index a574746325..f1f41c5b94 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -24,7 +24,7 @@ char *_hotkeys_file; * List of all HotkeyLists. * This is a pointer to ensure initialisation order with the various static HotkeyList instances. */ -static SmallVector *_hotkey_lists = NULL; +static std::vector *_hotkey_lists = NULL; /** String representation of a keycode */ struct KeycodeNames { @@ -205,7 +205,7 @@ const char *SaveKeycodes(const Hotkey *hotkey) { static char buf[128]; buf[0] = '\0'; - for (uint i = 0; i < hotkey->keycodes.Length(); i++) { + for (uint i = 0; i < hotkey->keycodes.size(); i++) { const char *str = KeycodeToString(hotkey->keycodes[i]); if (i > 0) strecat(buf, ",", lastof(buf)); strecat(buf, str, lastof(buf)); @@ -250,19 +250,19 @@ Hotkey::Hotkey(const uint16 *default_keycodes, const char *name, int num) : */ void Hotkey::AddKeycode(uint16 keycode) { - this->keycodes.Include(keycode); + include(this->keycodes, keycode); } HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) : global_hotkey_handler(global_hotkey_handler), ini_group(ini_group), items(items) { - if (_hotkey_lists == NULL) _hotkey_lists = new SmallVector(); - *_hotkey_lists->Append() = this; + if (_hotkey_lists == NULL) _hotkey_lists = new std::vector(); + _hotkey_lists->push_back(this); } HotkeyList::~HotkeyList() { - _hotkey_lists->Erase(_hotkey_lists->Find(this)); + _hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this)); } /** @@ -275,7 +275,7 @@ void HotkeyList::Load(IniFile *ini) for (Hotkey *hotkey = this->items; hotkey->name != NULL; ++hotkey) { IniItem *item = group->GetItem(hotkey->name, false); if (item != NULL) { - hotkey->keycodes.Clear(); + hotkey->keycodes.clear(); if (item->value != NULL) ParseHotkeys(hotkey, item->value); } } @@ -303,7 +303,9 @@ void HotkeyList::Save(IniFile *ini) const int HotkeyList::CheckMatch(uint16 keycode, bool global_only) const { for (const Hotkey *list = this->items; list->name != NULL; ++list) { - if (list->keycodes.Contains(keycode | WKC_GLOBAL_HOTKEY) || (!global_only && list->keycodes.Contains(keycode))) { + auto begin = list->keycodes.begin(); + auto end = list->keycodes.end(); + if (std::find(begin, end, keycode | WKC_GLOBAL_HOTKEY) != end || (!global_only && std::find(begin, end, keycode) != end)) { return list->num; } } @@ -316,11 +318,11 @@ static void SaveLoadHotkeys(bool save) IniFile *ini = new IniFile(); ini->LoadFromDisk(_hotkeys_file, NO_DIRECTORY); - for (HotkeyList **list = _hotkey_lists->Begin(); list != _hotkey_lists->End(); ++list) { + for (HotkeyList *list : *_hotkey_lists) { if (save) { - (*list)->Save(ini); + list->Save(ini); } else { - (*list)->Load(ini); + list->Load(ini); } } @@ -343,11 +345,11 @@ void SaveHotkeysToConfig() void HandleGlobalHotkeys(WChar key, uint16 keycode) { - for (HotkeyList **list = _hotkey_lists->Begin(); list != _hotkey_lists->End(); ++list) { - if ((*list)->global_hotkey_handler == NULL) continue; + for (HotkeyList *list : *_hotkey_lists) { + if (list->global_hotkey_handler == NULL) continue; - int hotkey = (*list)->CheckMatch(keycode, true); - if (hotkey >= 0 && ((*list)->global_hotkey_handler(hotkey) == ES_HANDLED)) return; + int hotkey = list->CheckMatch(keycode, true); + if (hotkey >= 0 && (list->global_hotkey_handler(hotkey) == ES_HANDLED)) return; } } diff --git a/src/hotkeys.h b/src/hotkeys.h index 25a489b3f3..fd729a47a9 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -29,7 +29,7 @@ struct Hotkey { const char *name; int num; - SmallVector keycodes; + std::vector keycodes; }; #define HOTKEY_LIST_END Hotkey((uint16)0, NULL, -1) diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index c622b78f34..084d350352 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1759,8 +1759,16 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, } if (_generating_world) { + if (HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) { + IndustryProductionCallback(i, 1); + for (size_t ci = 0; ci < lengthof(i->last_month_production); ci++) { + i->last_month_production[ci] = i->produced_cargo_waiting[ci] * 8; + i->produced_cargo_waiting[ci] = 0; + } + } + for (size_t ci = 0; ci < lengthof(i->last_month_production); ci++) { - i->last_month_production[ci] = i->production_rate[ci] * 8; + i->last_month_production[ci] += i->production_rate[ci] * 8; } } @@ -1884,7 +1892,7 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do *ip = NULL; - SmallVector object_areas(_cleared_object_areas); + std::vector object_areas(_cleared_object_areas); CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, creation_type, &custom_shape_check); _cleared_object_areas = object_areas; if (ret.Failed()) return ret; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index f5c90706fa..0ca5108fd3 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -403,12 +403,12 @@ public: this->SetButtons(); } - virtual void OnInit() + void OnInit() override { this->SetupArrays(); } - 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_DPI_MATRIX_WIDGET: { @@ -477,7 +477,7 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_DPI_FUND_WIDGET: @@ -494,7 +494,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -581,7 +581,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_DPI_MATRIX_WIDGET: { @@ -635,13 +635,13 @@ public: } } - virtual void OnResize() + void OnResize() override { /* Adjust the number of items in the matrix depending of the resize */ this->vscroll->SetCapacityFromWidget(this, WID_DPI_MATRIX_WIDGET); } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { bool success = true; /* We do not need to protect ourselves against "Random Many Industries" in this mode */ @@ -674,7 +674,7 @@ public: if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } - virtual void OnGameTick() + void OnGameTick() override { if (!this->timer_enabled) return; if (--this->callback_timer == 0) { @@ -697,12 +697,12 @@ public: } } - virtual void OnTimeout() + void OnTimeout() override { this->RaiseButtons(); } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); } @@ -712,7 +712,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; this->SetupArrays(); @@ -787,7 +787,7 @@ public: this->InvalidateData(); } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -924,17 +924,17 @@ public: return y + WD_FRAMERECT_BOTTOM; } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_IV_CAPTION) SetDParam(0, this->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 { if (widget == WID_IV_INFO) size->height = this->info_height; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_IV_INFO: { @@ -1039,14 +1039,14 @@ public: } } - virtual void OnTimeout() + void OnTimeout() override { this->clicked_line = IL_NONE; this->clicked_button = 0; this->SetDirty(); } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_IV_VIEWPORT); @@ -1056,7 +1056,7 @@ public: } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; @@ -1082,7 +1082,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; const Industry *i = Industry::Get(this->window_number); @@ -1094,12 +1094,12 @@ public: } } - virtual bool IsNewGRFInspectable() const + bool IsNewGRFInspectable() const override { return ::IsNewGRFInspectable(GSF_INDUSTRIES, this->window_number); } - virtual void ShowNewGRFInspectWindow() const + void ShowNewGRFInspectWindow() const override { ::ShowNewGRFInspectWindow(GSF_INDUSTRIES, this->window_number); } @@ -1202,16 +1202,16 @@ protected: void BuildSortIndustriesList() { if (this->industries.NeedRebuild()) { - this->industries.Clear(); + this->industries.clear(); const Industry *i; FOR_ALL_INDUSTRIES(i) { - *this->industries.Append() = i; + this->industries.push_back(i); } - this->industries.Compact(); + this->industries.shrink_to_fit(); this->industries.RebuildDone(); - this->vscroll->SetCount(this->industries.Length()); // Update scrollbar as well. + this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well. } if (!this->industries.Sort()) return; @@ -1357,12 +1357,12 @@ public: this->last_sorting = this->industries.GetListing(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_ID_DROPDOWN_CRITERIA) SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_ID_DROPDOWN_ORDER: @@ -1372,11 +1372,11 @@ public: case WID_ID_INDUSTRY_LIST: { int n = 0; int y = r.top + WD_FRAMERECT_TOP; - if (this->industries.Length() == 0) { + if (this->industries.size() == 0) { DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_DIRECTORY_NONE); break; } - for (uint i = this->vscroll->GetPosition(); i < this->industries.Length(); i++) { + for (uint i = this->vscroll->GetPosition(); i < this->industries.size(); i++) { DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, this->GetIndustryString(this->industries[i])); y += this->resize.step_height; @@ -1387,7 +1387,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_ID_DROPDOWN_ORDER: { @@ -1411,7 +1411,7 @@ public: case WID_ID_INDUSTRY_LIST: { Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE); - for (uint i = 0; i < this->industries.Length(); i++) { + for (uint i = 0; i < this->industries.size(); i++) { d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i]))); } resize->height = d.height; @@ -1425,7 +1425,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_ID_DROPDOWN_ORDER: @@ -1439,7 +1439,7 @@ public: case WID_ID_INDUSTRY_LIST: { uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP); - if (p < this->industries.Length()) { + if (p < this->industries.size()) { if (_ctrl_pressed) { ShowExtraViewPortWindow(this->industries[p]->location.tile); } else { @@ -1451,7 +1451,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (this->industries.SortType() != index) { this->industries.SetSortType(index); @@ -1459,18 +1459,18 @@ public: } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); } - virtual void OnPaint() + void OnPaint() override { if (this->industries.NeedRebuild()) this->BuildSortIndustriesList(); this->DrawWidgets(); } - virtual void OnHundredthTick() + void OnHundredthTick() override { this->industries.ForceResort(); this->BuildSortIndustriesList(); @@ -1481,7 +1481,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 */ @@ -2155,7 +2155,7 @@ next_cargo: ; struct IndustryCargoesWindow : public Window { static const int HOR_TEXT_PADDING, VERT_TEXT_PADDING; - typedef SmallVector Fields; + typedef std::vector Fields; Fields fields; ///< Fields to display in the #WID_IC_PANEL. uint ind_cargo; ///< If less than #NUM_INDUSTRYTYPES, an industry type, else a cargo id + NUM_INDUSTRYTYPES. @@ -2172,7 +2172,7 @@ struct IndustryCargoesWindow : public Window { this->OnInvalidateData(id); } - virtual void OnInit() + void OnInit() override { /* Initialize static CargoesField size variables. */ Dimension d = GetStringBoundingBox(STR_INDUSTRY_CARGOES_PRODUCERS); @@ -2219,7 +2219,7 @@ struct IndustryCargoesWindow : public Window { CargoesField::cargo_field_width = CargoesField::HOR_CARGO_BORDER_SPACE * 2 + CargoesField::HOR_CARGO_WIDTH * CargoesField::max_cargoes + CargoesField::HOR_CARGO_SPACE * (CargoesField::max_cargoes - 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 { switch (widget) { case WID_IC_PANEL: @@ -2238,7 +2238,7 @@ struct IndustryCargoesWindow : public Window { CargoesFieldType type; ///< Type of field. - virtual void SetStringParameters (int widget) const + void SetStringParameters (int widget) const override { if (widget != WID_IC_CAPTION) return; @@ -2422,13 +2422,14 @@ struct IndustryCargoesWindow : public Window { _displayed_industries.reset(); _displayed_industries.set(it); - this->fields.Clear(); - CargoesRow *row = this->fields.Append(); - row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); - row->columns[1].MakeEmpty(CFT_SMALL_EMPTY); - row->columns[2].MakeEmpty(CFT_SMALL_EMPTY); - row->columns[3].MakeEmpty(CFT_SMALL_EMPTY); - row->columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); + this->fields.clear(); + /*C++17: CargoesRow &row = */ this->fields.emplace_back(); + CargoesRow &row = this->fields.back(); + row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); + row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); + row.columns[2].MakeEmpty(CFT_SMALL_EMPTY); + row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); + row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); const IndustrySpec *central_sp = GetIndustrySpec(it); bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); @@ -2438,12 +2439,13 @@ struct IndustryCargoesWindow : public Window { int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)) + houses_accept; int num_indrows = max(3, max(num_supp, num_cust)); // One is needed for the 'it' industry, and 2 for the cargo labels. for (int i = 0; i < num_indrows; i++) { - CargoesRow *row = this->fields.Append(); - row->columns[0].MakeEmpty(CFT_EMPTY); - row->columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); - row->columns[2].MakeEmpty(CFT_EMPTY); - row->columns[3].MakeCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)); - row->columns[4].MakeEmpty(CFT_EMPTY); + /*C++17: CargoesRow &row = */ this->fields.emplace_back(); + CargoesRow &row = this->fields.back(); + row.columns[0].MakeEmpty(CFT_EMPTY); + row.columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); + row.columns[2].MakeEmpty(CFT_EMPTY); + row.columns[3].MakeCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)); + row.columns[4].MakeEmpty(CFT_EMPTY); } /* Add central industry. */ int central_row = 1 + num_indrows / 2; @@ -2500,13 +2502,14 @@ struct IndustryCargoesWindow : public Window { this->ind_cargo = cid + NUM_INDUSTRYTYPES; _displayed_industries.reset(); - this->fields.Clear(); - CargoesRow *row = this->fields.Append(); - row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); - row->columns[1].MakeEmpty(CFT_SMALL_EMPTY); - row->columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); - row->columns[3].MakeEmpty(CFT_SMALL_EMPTY); - row->columns[4].MakeEmpty(CFT_SMALL_EMPTY); + this->fields.clear(); + /*C++17: CargoesRow &row = */ this->fields.emplace_back(); + CargoesRow &row = this->fields.back(); + row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); + row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); + row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); + row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); + row.columns[4].MakeEmpty(CFT_SMALL_EMPTY); bool houses_supply = HousesCanSupply(&cid, 1); bool houses_accept = HousesCanAccept(&cid, 1); @@ -2514,12 +2517,13 @@ struct IndustryCargoesWindow : public Window { int num_cust = CountMatchingAcceptingIndustries(&cid, 1) + houses_accept; int num_indrows = max(num_supp, num_cust); for (int i = 0; i < num_indrows; i++) { - CargoesRow *row = this->fields.Append(); - row->columns[0].MakeEmpty(CFT_EMPTY); - row->columns[1].MakeCargo(&cid, 1); - row->columns[2].MakeEmpty(CFT_EMPTY); - row->columns[3].MakeEmpty(CFT_EMPTY); - row->columns[4].MakeEmpty(CFT_EMPTY); + /*C++17: CargoesRow &row = */ this->fields.emplace_back(); + CargoesRow &row = this->fields.back(); + row.columns[0].MakeEmpty(CFT_EMPTY); + row.columns[1].MakeCargo(&cid, 1); + row.columns[2].MakeEmpty(CFT_EMPTY); + row.columns[3].MakeEmpty(CFT_EMPTY); + row.columns[4].MakeEmpty(CFT_EMPTY); } this->fields[num_indrows].MakeCargoLabel(0, false); // Add cargo labels at the left bottom. @@ -2565,7 +2569,7 @@ struct IndustryCargoesWindow : public Window { * - data = NUM_INDUSTRYTYPES: Stop sending updates to the smallmap window. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; if (data == NUM_INDUSTRYTYPES) { @@ -2580,7 +2584,7 @@ struct IndustryCargoesWindow : public Window { this->ComputeIndustryDisplay(data); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_IC_PANEL) return; @@ -2597,7 +2601,7 @@ struct IndustryCargoesWindow : public Window { const NWidgetBase *nwp = this->GetWidget(WID_IC_PANEL); int vpos = -this->vscroll->GetPosition() * nwp->resize_y; - for (uint i = 0; i < this->fields.Length(); i++) { + for (uint i = 0; i < this->fields.size(); i++) { int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height; if (vpos + row_height >= 0) { int xpos = left_pos; @@ -2639,7 +2643,7 @@ struct IndustryCargoesWindow : public Window { if (pt.y < vpos) return false; int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1. - if (row + 1 >= (int)this->fields.Length()) return false; + if (row + 1 >= (int)this->fields.size()) return false; vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field row++; // rebase row to match index of this->fields. @@ -2668,7 +2672,7 @@ struct IndustryCargoesWindow : public Window { return true; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_IC_PANEL: { @@ -2716,9 +2720,9 @@ struct IndustryCargoesWindow : public Window { DropDownList *lst = new DropDownList; const CargoSpec *cs; FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { - *lst->Append() = new DropDownListStringItem(cs->name, cs->Index(), false); + lst->push_back(new DropDownListStringItem(cs->name, cs->Index(), false)); } - if (lst->Length() == 0) { + if (lst->size() == 0) { delete lst; break; } @@ -2733,9 +2737,9 @@ struct IndustryCargoesWindow : public Window { IndustryType ind = _sorted_industry_types[i]; const IndustrySpec *indsp = GetIndustrySpec(ind); if (!indsp->enabled) continue; - *lst->Append() = new DropDownListStringItem(indsp->name, ind, false); + lst->push_back(new DropDownListStringItem(indsp->name, ind, false)); } - if (lst->Length() == 0) { + if (lst->size() == 0) { delete lst; break; } @@ -2746,7 +2750,7 @@ struct IndustryCargoesWindow : public Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (index < 0) return; @@ -2761,12 +2765,12 @@ struct IndustryCargoesWindow : public Window { } } - virtual void OnHover(Point pt, int widget) + bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override { - if (widget != WID_IC_PANEL) return; + if (widget != WID_IC_PANEL) return false; Point fieldxy, xy; - if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return; + if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return false; const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x; CargoID cid = INVALID_CARGO; @@ -2785,9 +2789,9 @@ struct IndustryCargoesWindow : public Window { case CFT_INDUSTRY: if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) { - GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, TCC_HOVER); + GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, close_cond); } - return; + return true; default: break; @@ -2796,11 +2800,14 @@ struct IndustryCargoesWindow : public Window { const CargoSpec *csp = CargoSpec::Get(cid); uint64 params[5]; params[0] = csp->name; - GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, TCC_HOVER); + GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, close_cond); + return true; } + + return false; } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL); } diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index a7a444cc86..307be44050 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -49,7 +49,7 @@ struct SelectGameWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; this->SetWidgetLoweredState(WID_SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); @@ -58,7 +58,7 @@ struct SelectGameWindow : public Window { this->SetWidgetLoweredState(WID_SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND); } - virtual void OnInit() + void OnInit() override { bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion(); this->GetWidget(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE); @@ -67,7 +67,7 @@ struct SelectGameWindow : public Window { this->GetWidget(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_SGI_BASESET: @@ -82,7 +82,7 @@ struct SelectGameWindow : 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 { StringID str = 0; switch (widget) { @@ -111,13 +111,11 @@ struct SelectGameWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { -#ifdef ENABLE_NETWORK /* Do not create a network server when you (just) have closed one of the game * creation/load windows for the network server. */ if (IsInsideMM(widget, WID_SGI_GENERATE_GAME, WID_SGI_EDIT_SCENARIO + 1)) _is_network_server = false; -#endif /* ENABLE_NETWORK */ switch (widget) { case WID_SGI_GENERATE_GAME: @@ -299,8 +297,6 @@ void AskExitGame() SetDParam(0, STR_OSNAME_OS2); #elif defined(SUNOS) SetDParam(0, STR_OSNAME_SUNOS); -#elif defined(DOS) - SetDParam(0, STR_OSNAME_DOS); #else SetDParam(0, STR_OSNAME_UNIX); #endif diff --git a/src/lang/afrikaans.txt b/src/lang/afrikaans.txt index d59a2a6c54..0fddfce7ce 100644 --- a/src/lang/afrikaans.txt +++ b/src/lang/afrikaans.txt @@ -1685,7 +1685,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Vragver STR_CONFIG_SETTING_AI :{ORANGE}Mededingers STR_CONFIG_SETTING_AI_NPC :{ORANGE}Rekenaar spelers -STR_CONFIG_SETTING_PATHFINDER_OPF :Oorspronklik STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Aanbevole) @@ -1768,7 +1767,6 @@ STR_QUIT_NO :{BLACK}Nee # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3389,11 +3387,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Koop Voe STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Bou skip STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Koop vliegtuig + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Koop die gekose lokomotief/wa. Shift+klik vir kwotasie STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Koop die gekose voertuig. Shift+klik vir kwotasie STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Koop die gekose skip. Shift+klik vir kwotasie STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Koop die gekose vliegtuig. Shift+klik vir kwotasie + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Hernoem STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Hernoem STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Hernoem diff --git a/src/lang/arabic_egypt.txt b/src/lang/arabic_egypt.txt index 66936ea19a..0af16ae2fd 100644 --- a/src/lang/arabic_egypt.txt +++ b/src/lang/arabic_egypt.txt @@ -1369,7 +1369,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :توزيع ال STR_CONFIG_SETTING_AI :{ORANGE}المتنافسين STR_CONFIG_SETTING_AI_NPC :{ORANGE} لاعبين الحاسوب -STR_CONFIG_SETTING_PATHFINDER_OPF :اصلي STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(مفضل) @@ -1440,7 +1439,6 @@ STR_QUIT_NO :{BLACK}لا # Supported OSes STR_OSNAME_WINDOWS :ويندوز -STR_OSNAME_DOS :دوس STR_OSNAME_UNIX :يونكس STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :هايكو @@ -2917,11 +2915,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}شراء STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}شراء سفينة STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}شراء طائرة + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}شراء العربة الموضحة STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}شراء العربة STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}شراء السفينة المختارة STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}اشتر الطائرة المختارة + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}اعادة تسمية STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}أعد التسمية STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}تسمية diff --git a/src/lang/basque.txt b/src/lang/basque.txt index 19a29014f2..c7650d3c36 100644 --- a/src/lang/basque.txt +++ b/src/lang/basque.txt @@ -1598,7 +1598,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Zama ba STR_CONFIG_SETTING_AI :{ORANGE}Lehiakideak STR_CONFIG_SETTING_AI_NPC :{ORANGE}Ordenagailu jokalariak -STR_CONFIG_SETTING_PATHFINDER_OPF :Jatorrizkoa STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Gomendatua) @@ -1680,7 +1679,6 @@ STR_QUIT_NO :{BLACK}Ez # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3276,11 +3274,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Ibilgail STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Itsasontia erosi STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Hegazkina erosi + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Aukeratuta dagoen ibilgailua erosi. Shift+Klik gutxi gora beherako kostea erakutsi STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Aukeratuta dagoen ibilgailua erosi. Shift+Klik gutxi gora beherako kostea erakutsi STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Aukeratuta dagoen itsasontzia erosi. Shift+Klik gutxi gora beherako kostea erakutsi STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Aukeratuta dagoen hegazkina erosi. Shift+Klik gutxi gora beherako kostea erakutsi + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Berrizendatu STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Berrizendatu STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Berrizendatu diff --git a/src/lang/belarusian.txt b/src/lang/belarusian.txt index 34f05fa8b6..28e597665f 100644 --- a/src/lang/belarusian.txt +++ b/src/lang/belarusian.txt @@ -2009,7 +2009,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Раз STR_CONFIG_SETTING_AI :{ORANGE}Канкурэнты STR_CONFIG_SETTING_AI_NPC :{ORANGE}Кампутарныя гульцы -STR_CONFIG_SETTING_PATHFINDER_OPF :арыґінальны STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(рэкамэндуецца) @@ -2093,7 +2092,6 @@ STR_QUIT_NO :{BLACK}Не # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3746,11 +3744,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Купі STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Купіць STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Купіць + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Набыць абраны лякаматыў/ваґон. Shift+пстрычка — ацэнка кошту набыцьця. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Набыць абраны аўтамабіль. Shift+пстрычка — ацэнка кошту набыцьця. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Набыць абраны карабель. Shift+пстрычка — ацэнка кошту набыцьця. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Набыць абраны авіятранспарт. Shift+пстрычка — ацэнка кошту набыцьця. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Перайменаваць STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Перайменаваць STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Перайменаваць diff --git a/src/lang/brazilian_portuguese.txt b/src/lang/brazilian_portuguese.txt index 78385d620e..fdb0ce44a2 100644 --- a/src/lang/brazilian_portuguese.txt +++ b/src/lang/brazilian_portuguese.txt @@ -1700,7 +1700,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Oponentes STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computadores -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomendado) @@ -1784,7 +1783,6 @@ STR_QUIT_NO :{BLACK}Não # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3456,11 +3454,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Comprar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Comprar Embarcação STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Comprar Aeronave + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Compra o veículo ferroviário selecionado. Shift+Clique mostra preço estimado sem a compra STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Compra o veículo selecionado. Shift+Clique mostra preço estimado sem a compra STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Compra a embarcação selecionada. Shift+Clique mostra preço estimado sem a compra STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Compra a aeronave selecionada. Shift+Clique mostra o preço estimado sem a compra + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renomear diff --git a/src/lang/bulgarian.txt b/src/lang/bulgarian.txt index f9f3f81357..bae13a74ed 100644 --- a/src/lang/bulgarian.txt +++ b/src/lang/bulgarian.txt @@ -1634,7 +1634,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Инд STR_CONFIG_SETTING_AI :{ORANGE}Съперници STR_CONFIG_SETTING_AI_NPC :{ORANGE}Компютърни играчи -STR_CONFIG_SETTING_PATHFINDER_OPF :Оригинален STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(препоръчва се) @@ -1716,7 +1715,6 @@ STR_QUIT_NO :{BLACK}Не # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :ДОС STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3321,11 +3319,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Купи STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Купи Кораб STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Купи самолет + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Купи маркираният влак. Shift строеж/цена за построяване STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Купи посоченото МПС. Shift строеж/цена за построяване STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Купи посоченият кораб. Shift строеж/цена за построяване STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Купи посоченият самолет. Shift строеж/цена за построяване + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Преименувай STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Преименувай STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Промяна на име diff --git a/src/lang/catalan.txt b/src/lang/catalan.txt index 57f4476999..76a9733c3a 100644 --- a/src/lang/catalan.txt +++ b/src/lang/catalan.txt @@ -1715,7 +1715,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Competidors STR_CONFIG_SETTING_AI_NPC :{ORANGE}Jugadors IA -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomanat) @@ -1799,7 +1798,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2998,7 +2996,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Els recursos GR STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} ha estat desactivat per {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Format de disposició de sprite no vàlid o desconegut (sprite {3:NUM}). STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Hi ha massa elements a la llista de valors de propietats (sprite {3:NUM}, propietat {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :«Callback» de producció d'indústria no vàlid (sprite {3:NUM}, «{1:STRING}»). +STR_NEWGRF_ERROR_INDPROD_CALLBACK :«Callback» de producció d'indústria no vàlid (sprite {3:NUM}, «{2:STRING}»). # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Alerta! @@ -3500,11 +3498,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Compra e STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Compra el vaixell STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Compra l'aeronau + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Compra el tren/vagó seleccionat. Amb Maj+Clic, mostra el cost estimat sense comprar-lo. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Compra el vehicle marcat. Amb Maj+Clic, mostra el cost estimat sense comprar-lo. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Compra el vaixell seleccionat. Amb Maj+Clic, mostra el cost estimat sense comprar-lo. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Compra l'aeronau marcada. Amb Maj+Clic, mostra el cost estimat sense comprar-la. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Canvia el nom STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Canvia el nom STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Canvia el nom diff --git a/src/lang/croatian.txt b/src/lang/croatian.txt index d12acb1a05..3ccdd9b2b7 100644 --- a/src/lang/croatian.txt +++ b/src/lang/croatian.txt @@ -1812,7 +1812,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Suparnici STR_CONFIG_SETTING_AI_NPC :{ORANGE}Računalni igrači -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Preporučljivo) @@ -1896,7 +1895,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2234,7 +2232,7 @@ STR_NETWORK_CHAT_ALL :[Svima] {STRING STR_NETWORK_CHAT_OSKTITLE :{BLACK}Upišite tekst mrežnog razgovora # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nisu pronađeni mrežni uređaji ili je kompajlirano bez opcije ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nisu pronađeni mrežni uređaji STR_NETWORK_ERROR_NOSERVER :{WHITE}Niti jedna mrežna igra nije pronađena STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Poslužitelj nije odgovorio na zahtjev STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Spajanje nije moguće zbog razlike u NewGRF datotekama @@ -3095,7 +3093,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Zatraženi GRF STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} je isključen od strane {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Pogrešan/nepoznat format raspored sprite-a (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Previše elemenata na listi postavki varijabli (sprite {3:NUM}, postavka {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Pogrešna callback funkcija za industrijsku proizvodnju (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Pogrešna callback funkcija za industrijsku proizvodnju (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Oprez! @@ -3127,6 +3125,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Informacija o teretu/remontu za '{1:ENGINE}' je različita od kupovne liste nakon izgradnje. Zbog toga bi automatsko obnavljanje/zamjena mogla biti neuspješna STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{G=male}{WHITE}'{1:STRING}' je uzrokovao beskonačnu petlju u pozivu za povrat produkcije STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Povratnica {1:HEX} je vratio nepoznat/nemoguć rezultat {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' callback funkcija za proizvodnju je vratila nevažeći teret na {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3597,11 +3596,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kupi voz STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kupi brod STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kupi zrakoplov + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi označeni vlak. Shift+Klik prikazuje trošak bez kupnje. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi označeno cestovno vozilo. Shift+Klik prikazuje trošak bez kupnje. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi označeni brod. Shift+Klik prikazuje trošak bez kupnje. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi označeni zrakoplov. Shift+Klik prikazuje trošak bez kupnje. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Preimenuj STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Preimenuj STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Preimenuj diff --git a/src/lang/czech.txt b/src/lang/czech.txt index 65c2d6a0cf..23bcf9e060 100644 --- a/src/lang/czech.txt +++ b/src/lang/czech.txt @@ -1778,7 +1778,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Konkurenti STR_CONFIG_SETTING_AI_NPC :{ORANGE}Umělá inteligence -STR_CONFIG_SETTING_PATHFINDER_OPF :Původní STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(doporučený) @@ -1862,7 +1861,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unixu STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3516,11 +3514,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Koupit v STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Koupit loď STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Koupit letadlo + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kup označený vagon/lokomotivu. Stisknutý Shift pro zobrazení odhadu ceny STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Koupit označené vozidlo. Stisknutý Shift pro zobrazení odhadu ceny STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Koupit označenou loď. Stisknutý Shift pro zobrazení odhadu ceny STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Koupit označené letadlo. Stisknutý Shift pro zobrazení odhadu ceny + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Přejmenovat STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Přejmenovat STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Přejmenovat diff --git a/src/lang/danish.txt b/src/lang/danish.txt index 39a88623f6..76c6634d37 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -1717,7 +1717,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Fragtdi STR_CONFIG_SETTING_AI :{ORANGE}Modstandere STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computerstyrede spillere -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Anbefalet) @@ -1801,7 +1800,6 @@ STR_QUIT_NO :{BLACK}Nej # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2139,7 +2137,7 @@ STR_NETWORK_CHAT_ALL :[Alle] {STRING} STR_NETWORK_CHAT_OSKTITLE :{BLACK}Skriv tekst i netværks-chat # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Ingen netværksheder fundet eller kompilet uden ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Ingen netværksheder fundet STR_NETWORK_ERROR_NOSERVER :{WHITE}Kunne ikke finde nogen netværksspil STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Serveren besvarede ikke denne forspørgsel STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Kunne ikke tilslutte grundet NewGRF ulighed @@ -3000,7 +2998,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :De ønskede GRF STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} blev deaktiveret af {2:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Ugyldigt/ukendt sprite layoutformat (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :For mange elementer i værdiliste for egenskab (sprite {3:NUM}, egenskab {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ugyldig produktion-callback for industri (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ugyldig produktion-callback for industri (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Advarsel! @@ -3032,6 +3030,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Fragt-/ombygningsinformation for '{1:ENGINE}' afviger fra indkøbslisten efter konstruktion. Dette kan medføre, at autofornyelse ikke fungerer korrekt. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' forårsagede en uendelig løkke i produktions-callback'en. STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback {1:HEX} returnerede ukendt/ugyldigt resultat {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' returnerede ugyldig godstype i produktion-callback ved {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3502,11 +3501,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Køb kø STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Køb skib STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Køb et fly + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Køb det markerede lokomotiv/togvogn. Shift skifter mellem at købe og vise prisoverslag. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Køb det markerede køretøj. Shift skifter mellem at købe og vise prisoverslag. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Køb det markerede skib. Shift skifter mellem at købe og vise prisoverslag. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Køb det markerede fly. Shift skifter mellem at købe og vise prisoverslag. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Omdøb STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Omdøb STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Omdøb diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index f7fead9d77..9820d543d8 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -1124,7 +1124,7 @@ STR_CONFIG_SETTING_RESTRICT_BASIC :Basis (alleen b STR_CONFIG_SETTING_RESTRICT_ADVANCED :Geavanceerd (meeste instellingen weergeven) STR_CONFIG_SETTING_RESTRICT_ALL :Expert (alle instellingen weergeven, inclusief vreemde) STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT :Instellingen met een andere waarde dan de standaard -STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW :Instellingen met een andere waarde dan je 'nieuw spel' instellingen +STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW :Instellingen met een andere waarde dan je instellingen voor 'Nieuw spel' STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT :{BLACK}Filter de lijst hieronder op bepaalde instellingstypen STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL :Alle instellingen @@ -1169,7 +1169,7 @@ STR_CONFIG_SETTING_SUBSIDY_MULTIPLIER_HELPTEXT :Instellen hoeve STR_CONFIG_SETTING_CONSTRUCTION_COSTS :Bouwkosten: {STRING} STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HELPTEXT :Het niveau van bouw- en aankoopkosten instellen STR_CONFIG_SETTING_RECESSIONS :Recessies: {STRING} -STR_CONFIG_SETTING_RECESSIONS_HELPTEXT :Wanneer ingeschakeld kunnen recessies om de paar jaar optreden. Tijdens een recessie is alle productie aanzienlijk lager (deze keert terug naar het vorige niveau als de recessie voorbij is) +STR_CONFIG_SETTING_RECESSIONS_HELPTEXT :Wanneer dit is ingeschakeld, kunnen om de paar jaar recessies optreden. Tijdens een recessie is alle productie aanzienlijk lager (deze keert terug naar het vorige niveau als de recessie voorbij is). STR_CONFIG_SETTING_TRAIN_REVERSING :Niet toestaan dat treinen keren in stations: {STRING} STR_CONFIG_SETTING_TRAIN_REVERSING_HELPTEXT :Indien ingeschakeld zullen treinen niet omkeren in niet-eind stations, zelfs als er een kortere weg naar hun volgende bestemming is bij omkeren STR_CONFIG_SETTING_DISASTERS :Rampen: {STRING} @@ -1184,13 +1184,15 @@ STR_CONFIG_SETTING_AUTOSLOPE :Omgeving aanpas STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Staat het aanpassen van funderingen onder gebouwen en sporen toe zonder deze te verwijderen STR_CONFIG_SETTING_CATCHMENT :Meer realistische verzorgingsgebieden toestaan: {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Verzorgingsgebieden met verschillende groottes voor verschillende typen stations en luchthavens +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Stations van het bedrijf kunnen leveren aan industrieën met bijbehorend neutraal station: {STRING} +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Wanneer dit is ingeschakeld, kunnen industrieën met bijbehorende stations (zoals olievelden) ook worden voorzien door stations van het bedrijf die in de buurt zijn gebouwd. Wanneer dit is uitgeschakeld, kunnen deze industrieën alleen worden voorzien door het bijbehorende station. Eventuele stations van het bedrijif in de buurt kunnen niet aan ze leveren; ook levert het bijbehorende station alleen aan de industrie zelf. STR_CONFIG_SETTING_EXTRADYNAMITE :Verwijderen van meer stedelijke wegen, bruggen en tunnels toestaan: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Maakt het gemakkelijker om door de stad beheerde infrastructuur en gebouwen te verwijderen. STR_CONFIG_SETTING_TRAIN_LENGTH :Maximale lengte van treinen: {STRING} STR_CONFIG_SETTING_TRAIN_LENGTH_HELPTEXT :Stel de maximale lengte van treinen in STR_CONFIG_SETTING_TILE_LENGTH :{COMMA} tegel{P 0 "" s} STR_CONFIG_SETTING_SMOKE_AMOUNT :Hoeveelheid rook/vonken: {STRING} -STR_CONFIG_SETTING_SMOKE_AMOUNT_HELPTEXT :Bepaal hoeveel rook of hoeveel vonken door de voertuigen worden uitgestoten. +STR_CONFIG_SETTING_SMOKE_AMOUNT_HELPTEXT :Bepaal hoeveel rook en vonken voertuigen uitstoten STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL :Treinacceleratiemodel: {STRING} STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL_HELPTEXT :Natuurkundig model selecteren voor treinacceleratie. In het 'originele' model hebben hellingen dezelfde invloed op alle voertuigen. In het 'realistische' model hebben hellingen en bochten een verschillende invloed, afhankelijk van verschillende eigenschappen van de samenstelling, zoals lengte en trekkracht. STR_CONFIG_SETTING_ROAD_VEHICLE_ACCELERATION_MODEL :Acceleratiemodel voor wegvoertuigen: {STRING} @@ -1220,16 +1222,16 @@ STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :Onderzoeken STR_CONFIG_SETTING_INDUSTRY_PLATFORM :Vlak gebied rond industrieën: {STRING} STR_CONFIG_SETTING_INDUSTRY_PLATFORM_HELPTEXT :Hoeveelheid ruimte rond een industrie. Dit zorgt ervoor dat lege ruimte rond een industrie beschikbaar blijft voor sporen, stations, wegen enz. STR_CONFIG_SETTING_MULTIPINDTOWN :Meerdere vergelijkbare industrieën per stad toestaan: {STRING} -STR_CONFIG_SETTING_MULTIPINDTOWN_HELPTEXT :Normaal zal een stad niet meer dan één industrie van ieder type toestaan. Door deze optie in te schakelen zullen steden meerdere industrieën van één soort accepteren. +STR_CONFIG_SETTING_MULTIPINDTOWN_HELPTEXT :Normaal staat een stad niet meer dan één industrie van ieder type toe. Wanneer je deze optie inschakelt, accepteren steden meerdere industrieën van één soort. STR_CONFIG_SETTING_SIGNALSIDE :Seinen weergeven: {STRING} STR_CONFIG_SETTING_SIGNALSIDE_HELPTEXT :Kiest aan welke kant van het spoor seinen worden geplaatst STR_CONFIG_SETTING_SIGNALSIDE_LEFT :Links STR_CONFIG_SETTING_SIGNALSIDE_DRIVING_SIDE :Aan de rij zijde STR_CONFIG_SETTING_SIGNALSIDE_RIGHT :Rechts STR_CONFIG_SETTING_SHOWFINANCES :Financieel overzicht aan het einde van het jaar weergeven: {STRING} -STR_CONFIG_SETTING_SHOWFINANCES_HELPTEXT :Indien ingeschakeld verschijnt het financiën venster aan het eind van elk jaar voor een gemakkelijke controle van de financiële status van het bedrijf +STR_CONFIG_SETTING_SHOWFINANCES_HELPTEXT :Indien dit is ingeschakeld, verschijnt het venster met financiën aan het eind van elk jaar. Zo kun je gemakkelijk de financiële status van het bedrijf in de gaten houden. STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT :Nieuwe orders zijn standaard 'non-stop': {STRING} -STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Normaal gesproken zal een voertuig stoppen op elk station dit wordt gepasseerd. Door het inschakelen van deze instelling, zal het rijden door alle station op weg naar de eindbestemming zonder te stoppen. Merk op dat deze instelling alleen een standaardwaarde voor nieuwe orders bepaalt. Individuele opdrachten kan expliciet worden ingesteld op het gedrag +STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Normaal gesproken stopt een voertuig op elk station dat wordt gepasseerd. Wanneer je deze instelling inschakelt, passeert het alle stations op weg naar de eindbestemming zonder te stoppen. Merk op dat deze instelling alleen een standaardwaarde voor nieuwe orders bepaalt. Individuele opdrachten kunnen expliciet worden ingesteld op elk gewenst gedrag. STR_CONFIG_SETTING_STOP_LOCATION :Nieuwe treinorders stoppen de trein standaard {STRING} van het perron STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Plaats waar een trein standaard stopt aan het perron. 'Aan het begin' betekent in de buurt van de ingang, 'In het midden' betekent in het midden van het perron, en 'Aan het einde' betekent ver weg van de ingang. Merk op dat deze instelling alleen een standaardwaarde voor nieuwe orders bepaalt. Je kunt opdrachten expliciet instellen op elk gewenst gedrag. STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END :aan het begin @@ -1278,7 +1280,7 @@ STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Het inschakelen STR_CONFIG_SETTING_WARN_LOST_VEHICLE :Waarschuwen wanneer voertuig verdwaald is: {STRING} STR_CONFIG_SETTING_WARN_LOST_VEHICLE_HELPTEXT :Veroorzaakt berichten over voertuigen die niet in staat zijn om een pad naar hun bestemming te vinden STR_CONFIG_SETTING_ORDER_REVIEW :Orders van voertuigen controleren: {STRING} -STR_CONFIG_SETTING_ORDER_REVIEW_HELPTEXT :Wanneer ingeschakeld, worden de orders van de voertuigen regelmatig gecontroleerd, en sommige voor de hand liggende problemen worden gemeld met een nieuwsbericht bij detectie +STR_CONFIG_SETTING_ORDER_REVIEW_HELPTEXT :Wanneer dit is ingeschakeld, worden de orders van de voertuigen regelmatig gecontroleerd, en sommige duidelijke problemen worden gemeld met een nieuwsbericht STR_CONFIG_SETTING_ORDER_REVIEW_OFF :Nee STR_CONFIG_SETTING_ORDER_REVIEW_EXDEPOT :Ja, maar gestopte voertuigen uitsluiten STR_CONFIG_SETTING_ORDER_REVIEW_ON :Alle voertuigen @@ -1316,8 +1318,8 @@ STR_CONFIG_SETTING_TERRAIN_TYPE :Terreintype: {S STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Alleen TerraGenesis) Heuvelachtigheid van het landschap STR_CONFIG_SETTING_INDUSTRY_DENSITY :Industriedichtheid: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Stelt in hoeveel industrieën worden gegenereerd en welk niveau tijdens het spel moet worden gehandhaafd -STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Maximumafstand van de rand voor Olierafinaderijen: {STRING} -STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Olieraffinaderijen worden alleen gebouwd nabij de kaart grens, dat is aan de kust van eiland kaarten +STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Maximumafstand van de rand voor olieraffinaderijen: {STRING} +STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Olieraffinaderijen worden alleen gebouwd nabij de kaartgrens, dat is aan de kust van eilandkaarten STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Sneeuwhoogte: {STRING} STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Stelt in op welke hoogte de sneeuw begint in subarctisch landschap. Sneeuw heeft ook invloed op het ontstaan van industrieën en op de vereisten voor stadsgroei. STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Ruwheid van het terrein: {STRING} @@ -1383,8 +1385,8 @@ STR_CONFIG_SETTING_OSK_ACTIVATION :Toetsenbord op STR_CONFIG_SETTING_OSK_ACTIVATION_HELPTEXT :Selecteer de methode om het toetsenbord op het scherm te openen voor tekst invoeren in bewerkingsvensters met alleen het aanwijsapparaat. Dit is bedoeld voor kleine apparaten zonder toetsenbord. STR_CONFIG_SETTING_OSK_ACTIVATION_DISABLED :Uitgeschakeld STR_CONFIG_SETTING_OSK_ACTIVATION_DOUBLE_CLICK :Dubbelklik -STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK_FOCUS :Enkel klik (met focus) -STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK :Enkel klik (onmiddelijk) +STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK_FOCUS :Enkele klik (met focus) +STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK :Enkele klik (onmiddelijk) STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU :Rechtsklikemulatie: {STRING} STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_HELPTEXT :Methode selecteeren voor nabootsen van rechtsklikken @@ -1393,7 +1395,7 @@ STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_CONTROL :Ctrl+klik STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_OFF :Uit STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE :Vensters sluiten met rechtsklik: {STRING} -STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_HELPTEXT :Venster sluiten met de rechtermuisknop. Schakelt knopinfo met de rechtermuisknop uit! +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_HELPTEXT :Sluit vensters met de rechtermuisknop. Schakelt knopinfo met de rechtermuisknop uit! STR_CONFIG_SETTING_AUTOSAVE :Automatisch opslaan: {STRING} STR_CONFIG_SETTING_AUTOSAVE_HELPTEXT :Tijdsduur kiezen voor automatische spelopslag @@ -1405,7 +1407,7 @@ STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES_SHORT :kort (31-12-200 STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES_ISO :ISO (2008-12-31) STR_CONFIG_SETTING_PAUSE_ON_NEW_GAME :Automatisch pauzeren als je een nieuw spel start: {STRING} -STR_CONFIG_SETTING_PAUSE_ON_NEW_GAME_HELPTEXT :Wanneer ingeschakeld, het spel zal automatisch pauzeren bij het starten van een nieuw spel, waardoor nadere bestudering van de kaart mogelijk is +STR_CONFIG_SETTING_PAUSE_ON_NEW_GAME_HELPTEXT :Wanneer dit is ingeschakeld, pauzeert het spel automatisch wanneer je een nieuw spel start; zo kun je rustig de kaart bestuderen STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL :Toestaan wanneer gepauzeerd: {STRING} STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL_HELPTEXT :Selecteer welke acties kunnen worden uitgevoerd terwijl het spel is gepauzeerd STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL_NO_ACTIONS :Niets @@ -1421,25 +1423,25 @@ STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Reistijden in t STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Aankomst- en vertrektijden in dienstregeling weergeven: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Geef de verwachte aankomst-en vertrektijden in de dienstregeling weer STR_CONFIG_SETTING_QUICKGOTO :Snel voertuigorders maken: {STRING} -STR_CONFIG_SETTING_QUICKGOTO_HELPTEXT :Pre-selecteer de 'Ga naar cursor' bij het openen van de orders venster +STR_CONFIG_SETTING_QUICKGOTO_HELPTEXT :Selecteer meteen de 'ga-naar-cursor' wanneer je het ordervenster opent STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE :Standaard spoorsoort (bij nieuw of opgeslagen spel): {STRING} STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE_HELPTEXT :Spoortype om te selecteren na het starten of het laden van een spel. 'eerst beschikbare' selecteert de oudste vorm van sporen, 'laatst beschikbare' selecteert het nieuwste type van sporen, en 'meest gebruikte' selecteert het type dat op dit moment het meest in gebruik is STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE_FIRST :Eerst beschikbare STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE_LAST :Laatst beschikbare STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE_MOST_USED :Meest gebruikte STR_CONFIG_SETTING_SHOW_TRACK_RESERVATION :Gereserveerd spoor weergeven: {STRING} -STR_CONFIG_SETTING_SHOW_TRACK_RESERVATION_HELPTEXT :Geef gereserveerde tracks een andere kleur om te helpen met de problemen met treinen te weigeren een route op basis van blokken in te gaan +STR_CONFIG_SETTING_SHOW_TRACK_RESERVATION_HELPTEXT :Geeft gereserveerde sporen een andere kleur. Dit is handig om te bepalen waarom treinen een routeblok niet ingaan. STR_CONFIG_SETTING_PERSISTENT_BUILDINGTOOLS :Bouwgereedschappen actief houden na gebruik: {STRING} STR_CONFIG_SETTING_PERSISTENT_BUILDINGTOOLS_HELPTEXT :Houd de bouwhulpmiddelen voor bruggen, tunnels, enz. open na gebruik STR_CONFIG_SETTING_EXPENSES_LAYOUT :Uitgaven in bedrijfsfinanciënvenster groeperen: {STRING} STR_CONFIG_SETTING_EXPENSES_LAYOUT_HELPTEXT :Definieer de lay-out voor het bedrijfsuitgavenvenster STR_CONFIG_SETTING_SOUND_TICKER :Nieuwsticker: {STRING} -STR_CONFIG_SETTING_SOUND_TICKER_HELPTEXT :Geluidseffect afspelen bij korte nieuwsberichten +STR_CONFIG_SETTING_SOUND_TICKER_HELPTEXT :Speel geluidseffecten af bij korte nieuwsberichten STR_CONFIG_SETTING_SOUND_NEWS :Krant: {STRING} -STR_CONFIG_SETTING_SOUND_NEWS_HELPTEXT :Geluidseffect weergeven bij nieuwsbericht +STR_CONFIG_SETTING_SOUND_NEWS_HELPTEXT :Speel geluidseffecten af bij nieuwsberichten STR_CONFIG_SETTING_SOUND_NEW_YEAR :Einde jaar: {STRING} -STR_CONFIG_SETTING_SOUND_NEW_YEAR_HELPTEXT :Geluidseffect afspelen bij jaaroverzicht van bedrijf t.o.v. vorig jaar +STR_CONFIG_SETTING_SOUND_NEW_YEAR_HELPTEXT :Speel geluidseffecten af bij jaaroverzicht van bedrijf t.o.v. vorig jaar STR_CONFIG_SETTING_SOUND_CONFIRM :Bouw: {STRING} STR_CONFIG_SETTING_SOUND_CONFIRM_HELPTEXT :Speel geluidseffecten af wanneer constructies of andere acties zijn gelukt STR_CONFIG_SETTING_SOUND_CLICK :Klikgeluid knoppen: {STRING} @@ -1540,7 +1542,7 @@ STR_CONFIG_SETTING_COLOURED_NEWS_YEAR :Kleurenfoto's v STR_CONFIG_SETTING_COLOURED_NEWS_YEAR_HELPTEXT :Jaar dat de krant aankondigt in kleur te gaan afdrukken. Voor dit jaar wordt zwart-wit gebruikt STR_CONFIG_SETTING_STARTING_YEAR :Startjaar: {STRING} STR_CONFIG_SETTING_SMOOTH_ECONOMY :Vloeiende economie inschakelen (meer, kleinere veranderingen): {STRING} -STR_CONFIG_SETTING_SMOOTH_ECONOMY_HELPTEXT :Wanneer ingeschakeld, industrie produktie verandert vaker en in kleinere stappen. Deze instelling heeft meestal geen effect, als de industrie soorten worden geleverd door een NewGRF +STR_CONFIG_SETTING_SMOOTH_ECONOMY_HELPTEXT :Wanneer dit is ingeschakeld, verandert de productie van industrieën vaker en in kleinere stappen. Deze instelling heeft meestal geen effect als de industriesoorten worden geleverd door een NewGRF. STR_CONFIG_SETTING_ALLOW_SHARES :Kopen van aandelen in andere bedrijven toestaan: {STRING} STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :Wanneer ingeschakeld is het toegestaan om bedrijfsaandelen te kopen en te verkopen. Aandelen zullen alleen beschikbaar zijn voor bedrijven die een bepaalde leeftijd hebben bereikt STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Percentage van routeopbrengst in overdrachtssysteem: {STRING} @@ -1551,7 +1553,7 @@ STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_VALUE :{COMMA} tegel{P STR_CONFIG_SETTING_DRAG_SIGNALS_FIXED_DISTANCE :Bij slepen vaste afstand tussen seinen aanhouden: {STRING} STR_CONFIG_SETTING_DRAG_SIGNALS_FIXED_DISTANCE_HELPTEXT :Selecteer het gedrag van seinplaatsing wanneer je met Ctrl+slepen seinen plaatst. Indien dit uitgeschakeld is, dan worden seinen rondom tunnels of bruggen geplaatst om lange stukken te vermijden zonder seinen. Indien dit ingeschakeld is, dan worden seinen om de N tegels geplaatst, waardoor de uitlijning van de seinen op parallelle sporen makkelijker is STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE :Automatisch armseinen plaatsen voor: {STRING} -STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE_HELPTEXT :Stel het jaar waarin elektrische seinen zal worden gebruikt voor sporen. Voor dit jaar zal niet-elektrische seinen worden gebruikt (die exact dezelfde functie hebben, maar verschillend uiterlijk) +STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE_HELPTEXT :Stelt het jaar in waarin elektrische seinen worden gebruikt voor sporen. Eerder dan dit jaar worden niet-elektrische seinen gebruikt (die exact op dezelfde manier werken, maar een verschillend uiterlijk hebben). STR_CONFIG_SETTING_ENABLE_SIGNAL_GUI :Seinenvenster inschakelen: {STRING} STR_CONFIG_SETTING_ENABLE_SIGNAL_GUI_HELPTEXT :Een venster weergeven waar je de soorten seinen kunt kiezen om te bouwen in plaats van alleen bladeren door seintypes met Ctrl+klikken op gebouwde seinen STR_CONFIG_SETTING_DEFAULT_SIGNAL_TYPE :Seintype dat standaard moet worden gebouwd: {STRING} @@ -1577,7 +1579,7 @@ STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Steden toestaan STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Steden mogen gelijkvloerse kruisingen bouwen: {STRING} STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Door deze optie in te schakelen, kunnen steden gelijkvloerse kruisingen bouwen. STR_CONFIG_SETTING_NOISE_LEVEL :Geluidsniveaucontrole door steden voor vliegvelden toestaan: {STRING} -STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Met deze instelling uitgeschakeld kunnen er twee luchthavens in elke stad zijn. Als deze instelling is ingeschakeld, wordt het aantal luchthavens in een stad beperkt door het lawaai tollerantie van de stad, die afhankelijk is van de bevolking en de luchthaven grootte en afstand +STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Als je deze instelling uitschakelt, mogen er twee luchthavens per stad zijn. Als je deze instelling ingeschakelt, wordt het aantal luchthavens in een stad beperkt door de lawaaitolerantie van de stad; deze is afhankelijk van de bevolking en de grootte en afstand van de luchthaven. STR_CONFIG_SETTING_TOWN_FOUNDING :Steden stichten in spel: {STRING} STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Wanneer deze instelling is ingeschakeld, kunnen spelers nieuwe steden stichten tijdens het spel. STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Verboden @@ -1597,9 +1599,9 @@ STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_ALL :Overal STR_CONFIG_SETTING_TOOLBAR_POS :Positie van algemene knoppenbalk: {STRING} STR_CONFIG_SETTING_TOOLBAR_POS_HELPTEXT :Horizontale positie van de algemene taakbalk aan de bovenkant van het scherm. STR_CONFIG_SETTING_STATUSBAR_POS :Positie van de statusbalk: {STRING} -STR_CONFIG_SETTING_STATUSBAR_POS_HELPTEXT :De horizontale positie van de statusbalk aan de onderkant van het scherm. +STR_CONFIG_SETTING_STATUSBAR_POS_HELPTEXT :De horizontale positie van de statusbalk aan de onderkant van het scherm STR_CONFIG_SETTING_SNAP_RADIUS :Straal voor vensters vastmaken: {STRING} -STR_CONFIG_SETTING_SNAP_RADIUS_HELPTEXT :Afstand tussen vensters voordat het venster wordt verplaatst wordt automatisch uitgelijnd naar de nabijgelegen vensters +STR_CONFIG_SETTING_SNAP_RADIUS_HELPTEXT :Afstand tussen vensters voordat het venster automatisch wordt uitgelijnd op nabijgelegen vensters STR_CONFIG_SETTING_SNAP_RADIUS_VALUE :{COMMA} pixel{P 0 "" s} STR_CONFIG_SETTING_SNAP_RADIUS_DISABLED :Uitgeschakeld STR_CONFIG_SETTING_SOFT_LIMIT :Maximumaantal (niet-blijvende) vensters: {STRING} @@ -1714,7 +1716,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Vrachtd STR_CONFIG_SETTING_AI :{ORANGE}Tegenstanders STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computerspelers -STR_CONFIG_SETTING_PATHFINDER_OPF :Origineel STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Aanbevolen) @@ -1727,7 +1728,7 @@ STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_HELPTEXT :Routezoeker voo STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :Automatisch omdraaien bij seinen: {STRING} STR_CONFIG_SETTING_REVERSE_AT_SIGNALS_HELPTEXT :Treinen mogen keren bij een sein als ze hier lang staan wachten -STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Verander waarde +STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Instelwaarde wijzigen # Config errors STR_CONFIG_ERROR :{WHITE}Fout in het configuratiebestand... @@ -1798,7 +1799,6 @@ STR_QUIT_NO :{BLACK}Nee # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2136,7 +2136,7 @@ STR_NETWORK_CHAT_ALL :[Iedereen] {STR STR_NETWORK_CHAT_OSKTITLE :{BLACK}Geef tekst voor netwerkchat # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Geen netwerkapparaten gevonden of gecompileerd zonder ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Geen netwerkapparaten gevonden STR_NETWORK_ERROR_NOSERVER :{WHITE}Kon geen enkel netwerkspel vinden STR_NETWORK_ERROR_NOCONNECTION :{WHITE}De server beantwoordde het verzoek niet STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Kan geen verbinding maken, je hebt niet dezelfde NewGRF-bestanden als de server @@ -2582,7 +2582,7 @@ STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP :{BLACK}Klik op STR_INDUSTRY_CARGOES_CARGO_TOOLTIP :{BLACK}{STRING}{}Klik op de vracht om de leveranciers en klanten te zien STR_INDUSTRY_DISPLAY_CHAIN :{BLACK}Keten weergeven STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP :{BLACK}Industrieën weergeven die vracht leveren en accepteren -STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP :{BLACK}Link naar de kleine kaart +STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP :{BLACK}Koppeling naar de kleine kaart STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP :{BLACK}Weergegeven industrieën ook op de kleine kaart selecteren STR_INDUSTRY_CARGOES_SELECT_CARGO :{BLACK}Vracht selecteren STR_INDUSTRY_CARGOES_SELECT_CARGO_TOOLTIP :{BLACK}Vracht selecteren voor weergeven @@ -2757,7 +2757,7 @@ STR_FRAMETIME_CAPTION_GL_ROADVEHS :Wegvoertuigtikk STR_FRAMETIME_CAPTION_GL_SHIPS :Scheepstikken STR_FRAMETIME_CAPTION_GL_AIRCRAFT :Vliegtuigtikken STR_FRAMETIME_CAPTION_GL_LANDSCAPE :Wereldtikken -STR_FRAMETIME_CAPTION_GL_LINKGRAPH :Link grafiekvertraging +STR_FRAMETIME_CAPTION_GL_LINKGRAPH :Vertraging koppelinggrafiek STR_FRAMETIME_CAPTION_DRAWING :Grafische elementen realiseren STR_FRAMETIME_CAPTION_DRAWING_VIEWPORTS :Wereldkijkvenster weergeven STR_FRAMETIME_CAPTION_VIDEO :Video-output @@ -2936,7 +2936,7 @@ STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Sla de h STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}NewGRF-parameters wijzigen STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Sluiten STR_NEWGRF_PARAMETERS_RESET :{BLACK}Terugstellen -STR_NEWGRF_PARAMETERS_RESET_TOOLTIP :{BLACK}Zet alle parameters naar de standaardwaarde +STR_NEWGRF_PARAMETERS_RESET_TOOLTIP :{BLACK}Stel alle parameters terug naar de standaardwaarde STR_NEWGRF_PARAMETERS_DEFAULT_NAME :Parameter {NUM} STR_NEWGRF_PARAMETERS_SETTING :{STRING}: {ORANGE}{STRING} STR_NEWGRF_PARAMETERS_NUM_PARAM :{LTBLUE}Aantal parameters: {ORANGE}{NUM} @@ -2997,7 +2997,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Gevraagde GRF-m STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} is uitgeschakeld door {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Ongeldige/onbekende indeling voor spritelay-out (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Te veel elementen in eigenschappenwaardelijst (affbeelding {3:NUM}, eigenschap {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ongeldige terugroep voor industriële productie (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ongeldige terugroep voor industriële productie (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Waarschuwing! @@ -3029,6 +3029,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Vracht- of ombouwinformatie voor '{1:ENGINE}' wijkt af van aanschaflijst na het bouwen. Dit kan resulteren in problemen bij ombouwen door automatisch vernieuwen/vervangen STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' heeft een eindeloze loop veroorzaakt in de productiecallback STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback {1:HEX} gaf onbekend/ongeldig resultaat {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' retourneerde een ongeldig vrachttype in de productie-terugroep op {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3467,6 +3468,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Nieuwe schepen STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Nieuwe vliegtuigen STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Kosten: {GOLD}{CURRENCY_LONG}{BLACK} Gewicht: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Kosten: {GOLD}{CURRENCY_LONG}{BLACK} (ombouwkosten: {GOLD}{CURRENCY_LONG}{BLACK}) Gewicht: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Snelheid: {GOLD}{VELOCITY}{BLACK} Vermogen: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Snelheid: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Snelheid op oceaan: {GOLD}{VELOCITY} @@ -3477,8 +3479,10 @@ STR_PURCHASE_INFO_REFITTABLE :(ombouwbaar) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Ontworpen: {GOLD}{NUM}{BLACK} Levensduur: {GOLD}{COMMA} jaar STR_PURCHASE_INFO_RELIABILITY :{BLACK}Max. betrouwbaarheid: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Kosten: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Kosten: {GOLD}{CURRENCY_LONG}{BLACK} (ombouwkosten: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Gewicht: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Kosten: {GOLD}{CURRENCY_LONG}{BLACK} Snelheid: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Kosten: {GOLD}{CURRENCY_LONG}{BLACK} (ombouwkosten: {GOLD}{CURRENCY_LONG}{BLACK}) Snelheid: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Capaciteit: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Aangedreven wagons: {GOLD}+{POWER}{BLACK} Gewicht: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Om te bouwen naar: {GOLD}{STRING} @@ -3499,11 +3503,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Wegvoert STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Schip kopen STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Vliegtuig kopen +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Voertuig kopen en ombouwen +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Voertuig kopen en ombouwen +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Schip kopen en ombouwen +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Vliegtuig kopen en ombouwen + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Geselecteerd spoorvoertuig bouwen. Shift+klik geeft de verwachte kosten zonder te kopen. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde wegvoertuig. Shift+klik geeft de verwachte kosten zonder te kopen. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde schip. Shift+klik geeft de verwachte kosten zonder te kopen STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde vliegtuig. Shift+klik geeft de verwachte kosten zonder te kopen. +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Koop de geselecteerde trein en bouw hem om. Shift+klik geeft de verwachte kosten zonder te kopen. +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde wegvoertuig en bouw het om. Shift+klik geeft de geschatte kosten zonder te kopen. +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde schip en bouw het om. Shift+klik geeft de verwachte kosten zonder te kopen. +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Koop het geselecteerde vliegtuig en bouw het om. Shift+klik geeft de verwachte kosten zonder te kopen. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Hernoemen STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Hernoemen STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Hernoemen @@ -3514,7 +3528,7 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_TOOLTIP :{BLACK}Hiermee STR_BUY_VEHICLE_SHIP_RENAME_TOOLTIP :{BLACK}Hernoem type schip STR_BUY_VEHICLE_AIRCRAFT_RENAME_TOOLTIP :{BLACK}Hiermee hernoem je dit type vliegtuig -STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON :{BLACK}Verberg +STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON :{BLACK}Verbergen STR_BUY_VEHICLE_ROAD_VEHICLE_HIDE_TOGGLE_BUTTON :{BLACK}Verbergen STR_BUY_VEHICLE_SHIP_HIDE_TOGGLE_BUTTON :{BLACK}Verbergen STR_BUY_VEHICLE_AIRCRAFT_HIDE_TOGGLE_BUTTON :{BLACK}Verbergen diff --git a/src/lang/english.txt b/src/lang/english.txt index 2364157d98..d1953b3aaf 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1898,7 +1898,6 @@ STR_CONFIG_SETTING_AI_NPC :{ORANGE}Compute STR_CONFIG_SETTING_VIEWPORT_MAP_OPTIONS :{ORANGE}Map mode STR_CONFIG_SETTING_SHARING :{ORANGE}Infrastructure sharing -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -2019,7 +2018,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2357,7 +2355,7 @@ STR_NETWORK_CHAT_ALL :[All] {RAW_STRI STR_NETWORK_CHAT_OSKTITLE :{BLACK}Enter text for network chat # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}No network devices found or compiled without ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}No network devices found STR_NETWORK_ERROR_NOSERVER :{WHITE}Could not find any network games STR_NETWORK_ERROR_NOCONNECTION :{WHITE}The server didn't answer the request STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Could not connect due to NewGRF mismatch @@ -3539,7 +3537,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Requested GRF r STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:RAW_STRING} was disabled by {2:RAW_STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Invalid/unknown sprite layout format (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Too many elements in property value list (sprite {3:NUM}, property {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Invalid industry production callback (sprite {3:NUM}, "{1:RAW_STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Invalid industry production callback (sprite {3:NUM}, "{2:RAW_STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Caution! @@ -3571,6 +3569,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Cargo/refit information for '{1:ENGINE}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' caused an endless loop in the production callback STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback {1:HEX} returned unknown/invalid result {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' returned invalid cargo type in the production callback at {2:HEX} STR_NEWGRF_TOO_MANY_STRINGS :{WHITE}Not enough string IDs available for all NewGRFs. STR_NEWGRF_TOO_MANY_STRINGS_DETAIL :{WHITE}Some names and text fields may be displayed incorrectly. Try using fewer NewGRFs. @@ -4120,17 +4119,13 @@ STR_GROUP_DEFAULT_ROAD_VEHICLES :Ungrouped road STR_GROUP_DEFAULT_SHIPS :Ungrouped ships STR_GROUP_DEFAULT_AIRCRAFTS :Ungrouped aircraft +STR_GROUP_COUNT_WITH_SUBGROUP :{TINY_FONT}{COMMA} (+{COMMA}) + STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP :{BLACK}Groups - click on a group to list all vehicles of this group. Drag and drop groups to arrange hierarchy. STR_GROUP_CREATE_TOOLTIP :{BLACK}Click to create a group STR_GROUP_DELETE_TOOLTIP :{BLACK}Delete the selected group STR_GROUP_RENAME_TOOLTIP :{BLACK}Rename the selected group STR_GROUP_LIVERY_TOOLTIP :{BLACK}Change livery of the selected group -STR_GROUP_COLLAPSE :{BLACK}Collapse -STR_GROUP_EXPAND :{BLACK}Expand -STR_GROUP_EXPAND_ALL :{BLACK}Expand all -STR_GROUP_COLLAPSE_ALL :{BLACK}Collapse all -STR_GROUP_COLLAPSE_TOOLTIP :{BLACK}Click to collapse the selected group -STR_GROUP_EXPAND_TOOLTIP :{BLACK}Click to expand the selected group STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}Click to protect this group from global autoreplace STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}Delete Group @@ -4158,6 +4153,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :New Ships STR_BUY_VEHICLE_AIRCRAFT_CAPTION :New Aircraft STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Cost: {GOLD}{CURRENCY_LONG}{BLACK} Weight: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Cost: {GOLD}{CURRENCY_LONG}{BLACK} (Refit Cost: {GOLD}{CURRENCY_LONG}{BLACK}) Weight: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Speed: {GOLD}{VELOCITY}{BLACK} Power: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Speed: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Speed on ocean: {GOLD}{VELOCITY} @@ -4168,8 +4164,10 @@ STR_PURCHASE_INFO_REFITTABLE :(refittable) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Designed: {GOLD}{NUM}{BLACK} Life: {GOLD}{COMMA} year{P "" s} STR_PURCHASE_INFO_RELIABILITY :{BLACK}Max. Reliability: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Cost: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Cost: {GOLD}{CURRENCY_LONG}{BLACK} (Refit Cost: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Weight: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Cost: {GOLD}{CURRENCY_LONG}{BLACK} Speed: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Cost: {GOLD}{CURRENCY_LONG}{BLACK} (Refit Cost: {GOLD}{CURRENCY_LONG}{BLACK}) Speed: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Capacity: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Powered Wagons: {GOLD}+{POWER}{BLACK} Weight: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Refittable to: {GOLD}{STRING2} @@ -4195,11 +4193,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Buy Vehi STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Buy Ship STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Buy Aircraft +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Buy and Refit Vehicle +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Buy and Refit Vehicle +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Buy and Refit Ship +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Buy and Refit Aircraft + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted train vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted road vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted ship. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted aircraft. Shift+Click shows estimated cost without purchase +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Buy and refit the highlighted train vehicle. Shift+Click shows estimated cost without purchase +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Buy and refit the highlighted road vehicle. Shift+Click shows estimated cost without purchase +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Buy and refit the highlighted ship. Shift+Click shows estimated cost without purchase +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Buy and refit the highlighted aircraft. Shift+Click shows estimated cost without purchase + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Rename @@ -5347,6 +5355,7 @@ STR_ERROR_GROUP_CAN_T_CREATE :{WHITE}Can't cr STR_ERROR_GROUP_CAN_T_DELETE :{WHITE}Can't delete this group... STR_ERROR_GROUP_CAN_T_RENAME :{WHITE}Can't rename group... STR_ERROR_GROUP_CAN_T_SET_PARENT :{WHITE}Can't set parent group... +STR_ERROR_GROUP_CAN_T_SET_PARENT_RECURSION :{WHITE}... loops in the group hierarchy are not allowed STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES :{WHITE}Can't remove all vehicles from this group... STR_ERROR_GROUP_CAN_T_ADD_VEHICLE :{WHITE}Can't add the vehicle to this group... STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE :{WHITE}Can't add shared vehicles to group... diff --git a/src/lang/english_AU.txt b/src/lang/english_AU.txt index 0b465e2755..2924f8b9bc 100644 --- a/src/lang/english_AU.txt +++ b/src/lang/english_AU.txt @@ -1663,7 +1663,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Cargo d STR_CONFIG_SETTING_AI :{ORANGE}Competitors STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computer players -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -1744,7 +1743,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3355,11 +3353,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Buy Vehi STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Buy Ship STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Buy Aircraft + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted train vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted road vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted ship. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted aircraft. Shift+Click shows estimated cost without purchase + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Rename diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index e8c514f582..2dda4d60bd 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -1714,7 +1714,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Cargo d STR_CONFIG_SETTING_AI :{ORANGE}Competitors STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computer players -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -1798,7 +1797,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2997,7 +2995,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Requested GRF r STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} was disabled by {2:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Invalid/unknown sprite layout format (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Too many elements in property value list (sprite {3:NUM}, property {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Invalid industry production callback (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Invalid industry production callback (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Caution! @@ -3499,11 +3497,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Buy Vehi STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Buy Ship STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Buy Aircraft + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted train vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted road vehicle. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted ship. Shift+Click shows estimated cost without purchase STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Buy the highlighted aircraft. Shift+Click shows estimated cost without purchase + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Rename STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Rename diff --git a/src/lang/esperanto.txt b/src/lang/esperanto.txt index ab9b21c3fa..4396228fc0 100644 --- a/src/lang/esperanto.txt +++ b/src/lang/esperanto.txt @@ -1368,7 +1368,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Industr STR_CONFIG_SETTING_AI :{ORANGE}Konkurantoj STR_CONFIG_SETTING_AI_NPC :{ORANGE}Komputil-ludantoj -STR_CONFIG_SETTING_PATHFINDER_OPF :Originale STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Rekomendite) @@ -1427,7 +1426,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Vindozo -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unikso STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2827,11 +2825,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Aĉeti V STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Aĉeti Ŝipon STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Aĉeti Aviadilon + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Aĉeti la emfazitan trajnveturilon. Montri taksitaj kostoj sen aĉeti per maljuskliga klavo + Klaki STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Aĉeti la emfazitan stratveturilon. Montri taksitaj kostoj sen aĉeti per maljuskliga klavo + Klaki STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Aĉeti la emfazitan ŝipon. Montri taksitaj kostoj sen aĉeti per maljuskliga klavo + Klaki STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Aĉeti la emfazitan aviadilon. Montri taksitaj kostoj sen aĉeti per maljuskliga klavo + Klaki + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Alinomi STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Alinomi STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Alinomi diff --git a/src/lang/estonian.txt b/src/lang/estonian.txt index fb49599909..ccea539b96 100644 --- a/src/lang/estonian.txt +++ b/src/lang/estonian.txt @@ -1745,7 +1745,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Kaubaja STR_CONFIG_SETTING_AI :{ORANGE}Konkurendid STR_CONFIG_SETTING_AI_NPC :{ORANGE}Arvuti -STR_CONFIG_SETTING_PATHFINDER_OPF :Algne STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(soovitatud) @@ -1828,7 +1827,6 @@ STR_QUIT_NO :{BLACK}Ei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3467,11 +3465,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Ehita ve STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Ehita laev STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Ehita lennuk + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valitud raudteesõiduk. Shift+klõpsuga kuvatakse eeldatav ostuhind STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valitud mootorsõiduk. Shift+klõpsuga kuvatakse eeldatav ostuhind STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valitud laev. Shift+klõpsuga kuvatakse eeldatav ostuhind STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valitud õhusõiduk. Shift+klõpsuga kuvatakse eeldatav ostuhind + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Nimevahetus STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Nimevahetus STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Nimevahetus diff --git a/src/lang/faroese.txt b/src/lang/faroese.txt index 0231129321..0cc21ef09f 100644 --- a/src/lang/faroese.txt +++ b/src/lang/faroese.txt @@ -1523,7 +1523,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Ídnað STR_CONFIG_SETTING_AI :{ORANGE}Kappingarneytar STR_CONFIG_SETTING_AI_NPC :{ORANGE}Teldu spælarir -STR_CONFIG_SETTING_PATHFINDER_OPF :Upprunaligur STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Viðmældur) @@ -1591,7 +1590,6 @@ STR_QUIT_NO :{BLACK}Nei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3020,11 +3018,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Keyp akf STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Keyp skip STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Keyp flogfar + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Keyp undirstrikaða tok flutningstóli. Shift+trýst vísur kostnaðar meting uttan at keypa STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Keyp undirstrikaða akfari. Shift+trýst vísur kostnaðar meting uttan at keypa STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Keyp undirstrikaða skipi. Shift+trýst vísur kostnaðar meting uttan at keypa STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Keyp undirstrikaða flogfari. Shift+trýst vísur kostnaðar meting uttan at keypa + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Navngev STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Navngev STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Navngev diff --git a/src/lang/finnish.txt b/src/lang/finnish.txt index d8f9f713dd..b76e83fefa 100644 --- a/src/lang/finnish.txt +++ b/src/lang/finnish.txt @@ -137,7 +137,7 @@ STR_ABBREV_OIL :{TINY_FONT}ÖL STR_ABBREV_LIVESTOCK :{TINY_FONT}KA STR_ABBREV_GOODS :{TINY_FONT}TA STR_ABBREV_GRAIN :{TINY_FONT}VL -STR_ABBREV_WOOD :{TINY_FONT}PT +STR_ABBREV_WOOD :{TINY_FONT}PU STR_ABBREV_IRON_ORE :{TINY_FONT}RM STR_ABBREV_STEEL :{TINY_FONT}TR STR_ABBREV_VALUABLES :{TINY_FONT}AT @@ -785,12 +785,12 @@ STR_NEWS_MESSAGE_CAPTION :{WHITE}Viesti STR_NEWS_CUSTOM_ITEM :{BIG_FONT}{BLACK}{STRING} STR_NEWS_FIRST_TRAIN_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}Ensimmäinen juna saapuu asemalle {STATION}! -STR_NEWS_FIRST_BUS_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen linja-auton! -STR_NEWS_FIRST_TRUCK_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen kuorma-auton! -STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen raitiovaunun! -STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen rahtiraitiovaunun! -STR_NEWS_FIRST_SHIP_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen laivan! -STR_NEWS_FIRST_AIRCRAFT_ARRIVAL :{BIG_FONT}{BLACK}Kaupunkilaiset juhlivat . . .{}{STATION} vastaanottaa ensimmäisen lentokoneen! +STR_NEWS_FIRST_BUS_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen linja-auton! +STR_NEWS_FIRST_TRUCK_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen kuorma-auton! +STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen raitiovaunun! +STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen rahtiraitiovaunun! +STR_NEWS_FIRST_SHIP_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen laivan! +STR_NEWS_FIRST_AIRCRAFT_ARRIVAL :{BIG_FONT}{BLACK}Asukkaat juhlivat . . .{}{STATION} vastaanottaa ensimmäisen lentokoneen! STR_NEWS_TRAIN_CRASH :{BIG_FONT}{BLACK}Junaonnettomuus!{}{COMMA} kuolee törmäyksen jälkeisessä tulipallossa. STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER :{BIG_FONT}{BLACK}Tasoristeysturma!{}Kuljettaja kuolee junan ja auton törmäyksen jälkeisessä tulipallossa @@ -1075,7 +1075,7 @@ STR_SEA_LEVEL_LOW :Matala STR_SEA_LEVEL_MEDIUM :Keskitaso STR_SEA_LEVEL_HIGH :Korkea STR_SEA_LEVEL_CUSTOM :Oma -STR_SEA_LEVEL_CUSTOM_PERCENTAGE :Oma ({NUM}%) +STR_SEA_LEVEL_CUSTOM_PERCENTAGE :Oma ({NUM}{NBSP}%) STR_RIVERS_NONE :Ei yhtään STR_RIVERS_FEW :Vähän @@ -1199,7 +1199,7 @@ STR_CONFIG_SETTING_ROAD_VEHICLE_ACCELERATION_MODEL :Ajoneuvojen kii STR_CONFIG_SETTING_ROAD_VEHICLE_ACCELERATION_MODEL_HELPTEXT :Valitsee ajoneuvojen käyttämän fysiikkamallin. "Alkuperäinen" malli hidastaa ajoneuvoja mäissä tasapuolisesta. "Realistinen" malli hidastaa ajoneuvoja mäissä niiden ominaisuuksista riippuen STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS :Mäkien jyrkkyys junille: {STRING} STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS_HELPTEXT :Mäkien jyrkkyys junille. Korkeammat arvot tekevät mäkien nousemisesta vaikeampaa -STR_CONFIG_SETTING_PERCENTAGE :{COMMA}% +STR_CONFIG_SETTING_PERCENTAGE :{COMMA}{NBSP}% STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS :Mäkien jyrkkyys ajoneuvoille: {STRING} STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT :Mäkien jyrkkyys ajoneuvoille. Korkeammat arvot tekevät mäkien nousemisesta vaikeampaa STR_CONFIG_SETTING_FORBID_90_DEG :90 asteen käännökset kielletty junilta: {STRING} @@ -1626,7 +1626,7 @@ STR_CONFIG_SETTING_TOWN_GROWTH_NORMAL :Tavallinen STR_CONFIG_SETTING_TOWN_GROWTH_FAST :Nopea STR_CONFIG_SETTING_TOWN_GROWTH_VERY_FAST :Erittäin nopea STR_CONFIG_SETTING_LARGER_TOWNS :Kaupunkien osuus: {STRING} -STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Suurkaupungiksi muuttuvien kaupunkien määrä, eli suurempana aloittavat ja nopeammin kasvavat kaupungit +STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Kaupunkien määrä: kaupungit ovat isompia jo alussa ja kasvavat nopeammin kuin muut kunnat STR_CONFIG_SETTING_LARGER_TOWNS_VALUE :1 / {COMMA} STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :Ei yhtään STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Kasvukerroin alussa: {STRING} @@ -1652,9 +1652,9 @@ STR_CONFIG_SETTING_LINKGRAPH_ACCURACY_HELPTEXT :Mitä suuremmak STR_CONFIG_SETTING_DEMAND_DISTANCE :Välimatkan vaikutus kysyntään: {STRING} STR_CONFIG_SETTING_DEMAND_DISTANCE_HELPTEXT :Mikäli asetuksen arvo on määritelty suuremmaksi kuin 0, alkuperäisen aseman A ja mahdollisen määränpään B välimatkalla on vaikutus A:sta B:hen lähetetyn rahdin määrään. Mitä kauempana B on A:sta, sitä vähemmän rahtia lähetetään. Mitä suuremmaksi tämä asetus on määritetty, sitä vähemmän rahtia lähetetään kaukana oleville ja enemmän lähellä oleville asemille. STR_CONFIG_SETTING_DEMAND_SIZE :Palautettavan rahdin määrä symmetrisessä tilassa: {STRING} -STR_CONFIG_SETTING_DEMAND_SIZE_HELPTEXT :Mikäli asetuksen arvoksi on määritetty alle 100%, symmetrinen jakauma toimii enemmän epäsymmetrisen jakauman tavoin ja vähemmän rahtia pakotetaan lähetettäväksi takaisin alkuperäiselle asemalle. Jos arvoksi määritetään 0%, symmetrinen jakauma toimii täysin epäsymmetrisen jakauman tavoin. +STR_CONFIG_SETTING_DEMAND_SIZE_HELPTEXT :Mikäli asetuksen arvoksi on määritetty alle 100{NBSP}%, symmetrinen jakauma toimii enemmän epäsymmetrisen jakauman tavoin, ja vähemmän rahtia pakotetaan lähetettäväksi takaisin alkuperäiselle asemalle. Jos arvoksi määritetään 0{NBSP}%, symmetrinen jakauma toimii täysin epäsymmetrisen jakauman tavoin. STR_CONFIG_SETTING_SHORT_PATH_SATURATION :Lyhyiden reittien kuormittuminen ennen vapaampien reittien käyttämistä: {STRING} -STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Kahden aseman välillä on usein useita reittejä. Lyhintä reittiä käytetään ensisijaisesti, toisiksi lyhintä ensimmäisen kuormittuessa ja niin edelleen. Kuormitus määritellään arvioidun kapasiteetin ja suunnitellun käytön mukaan. Kaikkien reittien ollessa kuormittuneita reittejä aletaan ylikuormittamaan, suurimman kapasiteetin omaavista reiteista aloittaen. Algoritmi ei kuitenkaan aina arvioi kapasiteettia oikein. Tämä asetus mahdollistaa reitin kuormitustason määrittämisen ennen seuraavan reitin käyttämistä. Määritä arvoksi vähemmän kuin 100% välttääksesi ylikuormittuneita asemia jos kapasiteetti yliarvioidaan. +STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Kahden aseman välillä on usein useita reittejä. Lyhintä reittiä käytetään ensisijaisesti, toiseksi lyhintä ensimmäisen kuormittuessa ja niin edelleen. Kuormitus määritellään arvioidun kapasiteetin ja suunnitellun käytön mukaan. Kaikkien reittien ollessa kuormittuneita reittejä aletaan ylikuormittaa, suurimman kapasiteetin omaavista reiteista aloittaen. Algoritmi ei kuitenkaan aina arvioi kapasiteettia oikein. Tämä asetus mahdollistaa reitin kuormitustason määrittämisen ennen seuraavan reitin käyttämistä. Määritä arvoksi vähemmän kuin 100{NBSP}% välttääksesi ylikuormittuneita asemia, jos kapasiteetti yliarvioidaan. STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Nopeuden yksikkö: {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Kun käyttöliittymässä näytetään nopeus, näytä se valittua yksikköä käyttäen @@ -1716,7 +1716,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Rahdin STR_CONFIG_SETTING_AI :{ORANGE}Kilpailijat STR_CONFIG_SETTING_AI_NPC :{ORANGE}Tietokonepelaajat -STR_CONFIG_SETTING_PATHFINDER_OPF :Alkuperäinen STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Suositeltu) @@ -1800,7 +1799,6 @@ STR_QUIT_NO :{BLACK}Ei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2138,7 +2136,7 @@ STR_NETWORK_CHAT_ALL :[Kaikki] {STRIN STR_NETWORK_CHAT_OSKTITLE :{BLACK}Syötä teksti verkkokeskustelua varten # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Verkkolaitteita ei löytynyt tai käännetty ilman ENABLE_NETWORK-valintaa +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Verkkolaitteita ei löytynyt STR_NETWORK_ERROR_NOSERVER :{WHITE}Verkkopelejä ei löytynyt STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Palvelin ei vastannut pyyntöön STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Yhteyden muodostaminen epäonnistui NewGRF-virheen vuoksi @@ -2535,7 +2533,7 @@ STR_RESET_LANDSCAPE_CONFIRMATION_TEXT :{WHITE}Haluatko # Town generation window (SE) STR_FOUND_TOWN_CAPTION :{WHITE}Luo kuntia STR_FOUND_TOWN_NEW_TOWN_BUTTON :{BLACK}Uusi kunta -STR_FOUND_TOWN_NEW_TOWN_TOOLTIP :{BLACK}Perusta uusi kaupunki. Shift+Klik näyttää vain kustannusarvion +STR_FOUND_TOWN_NEW_TOWN_TOOLTIP :{BLACK}Perusta uusi kunta. Shift+Klik näyttää vain kustannusarvion STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Satunnainen kunta STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Perusta kunta satunnaiseen paikkaan STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Monta satunnaista kuntaa @@ -2543,7 +2541,7 @@ STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Täytä STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Kunnan nimi: STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Syötä kunnan nimi -STR_FOUND_TOWN_NAME_EDITOR_HELP :{BLACK}Syötä kaupungin nimi napsauttamalla +STR_FOUND_TOWN_NAME_EDITOR_HELP :{BLACK}Syötä kunnan nimi napsauttamalla STR_FOUND_TOWN_NAME_RANDOM_BUTTON :{BLACK}Satunnainen nimi STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP :{BLACK}Arvo uusi satunnainen nimi @@ -2803,7 +2801,7 @@ STR_MAPGEN_WORLD_GENERATION_CAPTION :{WHITE}Maailman STR_MAPGEN_MAPSIZE :{BLACK}Kartan koko: STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Valitse kartan koko ruutuina. Saatavilla olevien ruutujen määrä on hieman alhaisempi STR_MAPGEN_BY :{BLACK}× -STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Kaupunkien määrä: +STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Kuntien määrä: STR_MAPGEN_DATE :{BLACK}Päivämäärä: STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Teollisuuden määrä: STR_MAPGEN_MAX_HEIGHTLEVEL :{BLACK}Suurin sallittu kartan korkeus: @@ -2858,7 +2856,7 @@ STR_GENERATION_WORLD :{WHITE}Maailmaa STR_GENERATION_ABORT :{BLACK}Peruuta STR_GENERATION_ABORT_CAPTION :{WHITE}Keskeytä maailman luominen STR_GENERATION_ABORT_MESSAGE :{YELLOW}Haluatko varmasti keskeyttää maan luomisen? -STR_GENERATION_PROGRESS :{WHITE}{NUM}% valmiina +STR_GENERATION_PROGRESS :{WHITE}{NUM}{NBSP}% valmiina STR_GENERATION_PROGRESS_NUM :{BLACK}{NUM} / {NUM} STR_GENERATION_WORLD_GENERATION :{BLACK}Maailman luominen STR_GENERATION_RIVER_GENERATION :{BLACK}Jokien luominen @@ -2999,7 +2997,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Pyydetyt GRF-re STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{2:STRING} poisti käytöstä NewGRF:n {1:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Virheellinen/tuntematon spriten asettelumuoto (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Liian monta elementtiä ominaisuusarvolistassa (sprite {3:NUM}, ominaisuus {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Virhe teollisuuden tuotannon takaisinkutsussa (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Virhe teollisuuden tuotannon takaisinkutsussa (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Varoitus! @@ -3031,6 +3029,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Kulkuneuvon ”{1:ENGINE}” rahti-/uudelleensovitustiedot ovat toiset kuin ostolistassa rakentamisen jälkeen. Tämä voi johtaa uudelleensovituksen epäonnistumiseen, kun kulkuneuvo uudistetaan tai korvataan automaattisesti STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}”{1:STRING}” aiheutti ikuisen silmukan tuotannon takaisinkutsussa STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback-funktio {1:HEX} palautti tuntemattoman/kelvottoman tuloksen {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}”{1:STRING}” palautti virheellisen rahtityypin tuotannon takaisinkutsun kohdassa {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3065,7 +3064,7 @@ STR_TOWN_DIRECTORY_CAPTION :{WHITE}Kunnat STR_TOWN_DIRECTORY_NONE :{ORANGE}- Ei mitään - STR_TOWN_DIRECTORY_TOWN :{ORANGE}{TOWN}{BLACK} ({COMMA}) STR_TOWN_DIRECTORY_CITY :{ORANGE}{TOWN}{YELLOW} (kaupunki){BLACK} ({COMMA}) -STR_TOWN_DIRECTORY_LIST_TOOLTIP :{BLACK}Kaupunkien nimet – keskitä päänäkymä kaupunkiin napsauttamalla nimeä. Ctrl+Klik avaa uuden näkymäikkunan kaupungin sijaintiin +STR_TOWN_DIRECTORY_LIST_TOOLTIP :{BLACK}Kuntien nimet – keskitä päänäkymä kuntaan napsauttamalla nimeä. Ctrl+Klik avaa uuden näkymäikkunan kunnan sijaintiin STR_TOWN_POPULATION :{BLACK}Maailman asukasluku: {COMMA} # Town view window @@ -3133,7 +3132,7 @@ STR_GOALS_SPECTATOR_NONE :{ORANGE}- Ei sa STR_GOALS_PROGRESS :{ORANGE}{STRING} STR_GOALS_PROGRESS_COMPLETE :{GREEN}{STRING} STR_GOALS_COMPANY_TITLE :{BLACK}Yhtiön tavoitteet: -STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Keskitä päänäkymä teollisuuteen/kaupunkiin/ruutuun napsauttamalla tavoitetta. Ctrl+Klik avaa uuden näkymän teollisuuden/kaupungin/ruudun sijaintiin +STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Keskitä päänäkymä laitokseen/kuntaan/ruutuun napsauttamalla tavoitetta. Ctrl+Klik avaa uuden näkymän laitoksen/kunnan/ruudun sijaintiin # Goal question window STR_GOAL_QUESTION_CAPTION_QUESTION :Kysymys @@ -3211,7 +3210,7 @@ STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY :{YELLOW}{COMPAN STR_STATION_VIEW_RATINGS_BUTTON :{BLACK}Arviot STR_STATION_VIEW_RATINGS_TOOLTIP :{BLACK}Näytä aseman arviot STR_STATION_VIEW_SUPPLY_RATINGS_TITLE :{BLACK}Kuukausittainen tarjonta ja paikallinen arvio: -STR_STATION_VIEW_CARGO_SUPPLY_RATING :{WHITE}{STRING}: {YELLOW}{COMMA} / {STRING} ({COMMA}%) +STR_STATION_VIEW_CARGO_SUPPLY_RATING :{WHITE}{STRING}: {YELLOW}{COMMA} / {STRING} ({COMMA}{NBSP}%) STR_STATION_VIEW_GROUP :{BLACK}Järjestä STR_STATION_VIEW_WAITING_STATION :Asema: Odottaa @@ -3368,8 +3367,8 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL :{WHITE}{CURRENC # Industry directory STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Teollisuusala STR_INDUSTRY_DIRECTORY_NONE :{ORANGE}- Ei mitään - -STR_INDUSTRY_DIRECTORY_ITEM :{ORANGE}{INDUSTRY}{BLACK} ({CARGO_LONG}{STRING}){YELLOW} ({COMMA}% kuljetettu) -STR_INDUSTRY_DIRECTORY_ITEM_TWO :{ORANGE}{INDUSTRY}{BLACK} ({CARGO_LONG}{STRING}/{CARGO_LONG}{STRING}){YELLOW} ({COMMA}%/{COMMA}% kuljetettu) +STR_INDUSTRY_DIRECTORY_ITEM :{ORANGE}{INDUSTRY}{BLACK} ({CARGO_LONG}{STRING}){YELLOW} ({COMMA}{NBSP}% kuljetettu) +STR_INDUSTRY_DIRECTORY_ITEM_TWO :{ORANGE}{INDUSTRY}{BLACK} ({CARGO_LONG}{STRING}/{CARGO_LONG}{STRING}){YELLOW} ({COMMA}{NBSP}% / {COMMA}{NBSP}% kuljetettu) STR_INDUSTRY_DIRECTORY_ITEM_NOPROD :{ORANGE}{INDUSTRY} STR_INDUSTRY_DIRECTORY_LIST_CAPTION :{BLACK}Teollisuusmuotojen nimet - kohdista päänäkymä teollisuuslaitokseen napsauttamalla nimeä. Ctrl+Klik avaa uuden näkymäikkunan teollisuuslaitoksen sijaintiin @@ -3378,7 +3377,7 @@ STR_INDUSTRY_VIEW_CAPTION :{WHITE}{INDUSTR STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE :{BLACK}Tuotto viime kuussa: STR_INDUSTRY_VIEW_TRANSPORTED :{YELLOW}{CARGO_LONG}{STRING}{BLACK} ({COMMA}{NBSP}% kuljetettu) STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Keskitä päänäkymä teollisuuden sijaintiin. Ctrl+Klik avaa uuden näkymäikkunan teollisuuden sijaintiin -STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Tuotantotaso: {YELLOW}{COMMA}% +STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Tuotantotaso: {YELLOW}{COMMA}{NBSP}% STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE :{YELLOW}Teollisuuslaitos ilmoittaa pikaisesta sulkeutumisestaan! STR_INDUSTRY_VIEW_REQUIRES_N_CARGO :{BLACK}Tarvitsee: {YELLOW}{STRING}{STRING} @@ -3469,6 +3468,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Uusia laivoja STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Uusi lentokone STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Hinta: {GOLD}{CURRENCY_LONG}{BLACK} Paino: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Hinta: {GOLD}{CURRENCY_LONG}{BLACK} (Sovituskustannus: {GOLD}{CURRENCY_LONG}{BLACK}) Paino: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Nopeus: {GOLD}{VELOCITY}{BLACK} Teho: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Nopeus: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Nopeus merellä: {GOLD}{VELOCITY} @@ -3477,10 +3477,12 @@ STR_PURCHASE_INFO_RUNNINGCOST :{BLACK}Käyttö STR_PURCHASE_INFO_CAPACITY :{BLACK}Kapasiteetti: {GOLD}{CARGO_LONG} {STRING} STR_PURCHASE_INFO_REFITTABLE :(sovitettava) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Suunniteltu: {GOLD}{NUM}{BLACK} Elinikä: {GOLD}{COMMA} vuo{P si tta} -STR_PURCHASE_INFO_RELIABILITY :{BLACK}Enimmäisluotettavuus: {GOLD}{COMMA}% +STR_PURCHASE_INFO_RELIABILITY :{BLACK}Enimmäisluotettavuus: {GOLD}{COMMA}{NBSP}% STR_PURCHASE_INFO_COST :{BLACK}Hinta: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Hinta: {GOLD}{CURRENCY_LONG}{BLACK} (Sovituskustannus: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Paino: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Hinta: {GOLD}{CURRENCY_LONG}{BLACK} Nopeus: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Hinta: {GOLD}{CURRENCY_LONG}{BLACK} (Sovituskustannus: {GOLD}{CURRENCY_LONG}{BLACK}) Nopeus: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Kapasiteetti: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Moottoroidut vaunut: {GOLD}+{POWER}{BLACK} Paino: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Sovitettavissa: {GOLD}{STRING} @@ -3501,11 +3503,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Osta ajo STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Osta laiva STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Osta lentokone +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Osta ja sovita yksikkö +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Osta ja sovita ajoneuvo +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Osta ja sovita laiva +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Osta ja sovita lentokone + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valittu yksikkö. Shift+Klik näyttää kustannusarvion ostamatta STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valittu ajoneuvo. Shift+Klik näyttää kustannusarvion ostamatta STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Osta valittu laiva. Shift+Klik näyttää kustannusarvion ostamatta STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Osta korostettu lentokone. Shift+Klik näyttää kustannusarvion ostamatta +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Osta ja sovita valittu yksikkö. Shift+Klik näyttää kustannusarvion ostamatta +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Osta ja sovita valittu ajoneuvo. Shift+Klik näyttää kustannusarvion ostamatta +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Osta ja sovita valittu laiva. Shift+Klik näyttää kustannusarvion ostamatta +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Osta ja sovita valittu lentokone. Shift+Klik näyttää kustannusarvion ostamatta + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Nimeä STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Nimeä STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Nimeä @@ -3756,7 +3768,7 @@ STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED :{BLACK}Paino: { STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :{BLACK}Paino: {LTBLUE}{WEIGHT_SHORT} {BLACK}Teho: {LTBLUE}{POWER}{BLACK} Maks. nopeus: {LTBLUE}{VELOCITY} {BLACK}Maks. vetovoima: {LTBLUE}{FORCE} STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR :{BLACK}Tuotto tänä vuonna: {LTBLUE}{CURRENCY_LONG} (viime vuonna: {CURRENCY_LONG}) -STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS :{BLACK}Luotettavuus: {LTBLUE}{COMMA}% {BLACK}Hajoamiset viime huollon jälkeen: {LTBLUE}{COMMA} +STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS :{BLACK}Luotettavuus: {LTBLUE}{COMMA}{NBSP}% {BLACK}Hajoamiset viime huollon jälkeen: {LTBLUE}{COMMA} STR_VEHICLE_INFO_BUILT_VALUE :{LTBLUE}{ENGINE} {BLACK}Rakennettu: {LTBLUE}{NUM}{BLACK} Arvo: {LTBLUE}{CURRENCY_LONG} STR_VEHICLE_INFO_NO_CAPACITY :{BLACK}Kapasiteetti: {LTBLUE}-{STRING} @@ -3767,7 +3779,7 @@ STR_VEHICLE_INFO_CAPACITY_CAPACITY :{BLACK}Kapasite STR_VEHICLE_INFO_FEEDER_CARGO_VALUE :{BLACK}Siirron arvo: {LTBLUE}{CURRENCY_LONG} STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS :{BLACK}Huoltoväli: {LTBLUE}{COMMA}{NBSP}päivää{BLACK} Viimeisin huolto: {LTBLUE}{DATE_LONG} -STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT :{BLACK}Huoltoväli: {LTBLUE}{COMMA}%{BLACK} Viime huolto: {LTBLUE}{DATE_LONG} +STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT :{BLACK}Huoltoväli: {LTBLUE}{COMMA}{NBSP}%{BLACK} Viime huolto: {LTBLUE}{DATE_LONG} STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP :{BLACK}Kasvata huoltoväliä kymmenellä. Ctrl+Klik kasvattaa huoltoväliä viidellä STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP :{BLACK}Pienennä huoltoväliä kymmenellä. Ctrl+Klik vähentää huoltoväliä viidellä diff --git a/src/lang/french.txt b/src/lang/french.txt index 207ab0e214..a3d0e236e6 100644 --- a/src/lang/french.txt +++ b/src/lang/french.txt @@ -1185,6 +1185,7 @@ STR_CONFIG_SETTING_AUTOSLOPE :Terrassement so STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Autoriser le terrassement sous les bâtiments et les voies sans les retirer STR_CONFIG_SETTING_CATCHMENT :Autoriser des zones de desserte plus réalistes{NBSP}: {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Les zones de desserte ont des tailles différentes selon les types de stations et d'aéroports +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Si activé, les industries avec une station intégré (comme les plateformes pétrolière) peuvent aussi être servi par les stations des compagnies construites à proximité. Si désactivé, ces industries peuvent uniquement être servi par leur station intégré. Aucune station de compagnie ne pourra servir cette industrie, et la station intégré ne pourra servir que pour cette industrie. STR_CONFIG_SETTING_EXTRADYNAMITE :Permettre le retrait de plus d'éléments possédés par une ville{NBSP}: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Simplifier le retrait d'éléments possédés par une ville STR_CONFIG_SETTING_TRAIN_LENGTH :Longueur maximum des trains{NBSP}: {STRING} @@ -1711,7 +1712,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Compétiteurs STR_CONFIG_SETTING_AI_NPC :{ORANGE}Intelligence artificielle -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(recommandé) @@ -1795,7 +1795,6 @@ STR_QUIT_NO :{BLACK}Non # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2994,7 +2993,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Indisponibilit STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} a été désactivé par {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Format de sprite invalide ou inconnu (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Trop d'éléments dans la liste des valeurs de la propriété (sprite {3:NUM}, propriété {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Fonction de rappel de production d'industrie invalide (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Fonction de rappel de production d'industrie invalide (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Attention{NBSP}! @@ -3496,11 +3495,16 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Acheter STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Acheter STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Acheter +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :Achat et réaménagement du véhicule +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :Acheter et réaménager le bateau + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Acheter le véhicule sélectionné.{}Shift-clic pour afficher seulement le coût estimé. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Acheter le véhicule sélectionné.{}Shift-clic pour afficher seulement le coût estimé. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Acheter le navire sélectionné.{}Shift-clic pour afficher seulement le coût estimé. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Acheter l'aéronef sélectionné.{}Shift-clic pour afficher seulement le coût estimé. +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :Acheter et réaménager le véhicule ferroviaire sélectionné. Shift+Click montre une estimation du coût sans acheter le véhicule. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renommer STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renommer STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renommer diff --git a/src/lang/gaelic.txt b/src/lang/gaelic.txt index 4e2f503740..bdc06dc9cb 100644 --- a/src/lang/gaelic.txt +++ b/src/lang/gaelic.txt @@ -1894,7 +1894,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Sgaoile STR_CONFIG_SETTING_AI :{ORANGE}Co-farpaisichean STR_CONFIG_SETTING_AI_NPC :{ORANGE}Cluicheadairean coimpiutair -STR_CONFIG_SETTING_PATHFINDER_OPF :Tùsail STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(molta) @@ -1978,7 +1977,6 @@ STR_QUIT_NO :{BLACK}Chan eil # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3676,11 +3674,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Ceannaic STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Ceannaich long STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Ceannaich carbad-adhair + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaich an carbad-rèile a thagh thu. Seallaidh Shift+briogadh tuairmse air na cosgaisean gun a bhith a' ceannach dad STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaich an carbad-rathaid a thagh thu. Seallaidh Shift+briogadh tuairmse air na cosgaisean gun a bhith a' ceannach dad STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaich an long a thagh thu. Seallaidh Shift+briogadh tuairmse air na cosgaisean gun a bhith a' ceannach dad STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaich an carbad-adhair a thagh thu. Seallaidh Shift+briogadh tuairmse air na cosgaisean gun a bhith a' ceannach dad + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Thoir ainm ùr air STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Thoir ainm ùr air STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Thoir ainm ùr air diff --git a/src/lang/galician.txt b/src/lang/galician.txt index 595ee54075..ebbf6fb522 100644 --- a/src/lang/galician.txt +++ b/src/lang/galician.txt @@ -1687,7 +1687,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Competidores STR_CONFIG_SETTING_AI_NPC :{ORANGE}Xogadores da computadora -STR_CONFIG_SETTING_PATHFINDER_OPF :Orixinal STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomendado) @@ -1771,7 +1770,6 @@ STR_QUIT_NO :{BLACK}Non # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3401,11 +3399,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Mercar v STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Mercar barco STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Mercar aeronave + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Mercar o vehículo ferroviario seleccionado. Shift+click mostra o custo estimado sen mercar STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Mercar o vehículo de estrada seleccionado. Shift+click mostra o custo estimado sen mercar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Mercar o barco seleccionado. Shift+click mostra o custo estimado sen mercar STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Mercar a aeronave seleccionada. Shift+click mostra o custo estimado sen mercar + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renomear diff --git a/src/lang/german.txt b/src/lang/german.txt index 60a175bb09..0e174ec096 100644 --- a/src/lang/german.txt +++ b/src/lang/german.txt @@ -1851,7 +1851,6 @@ STR_CONFIG_SETTING_AI_NPC :{ORANGE}Compute STR_CONFIG_SETTING_VIEWPORT_MAP_OPTIONS :{ORANGE}Zusätzliche Kartenansicht STR_CONFIG_SETTING_SHARING :{ORANGE}Infrastruktur-Sharing -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(empfohlen) @@ -1951,7 +1950,6 @@ STR_QUIT_NO :{BLACK}Nein # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3430,7 +3428,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Die angefordert STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} wurde von {STRING} deaktiviert STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Ungültiges oder unbekanntes Format für Spritelayout (Sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Zu viele Elemente in Eigenschaftswert-Liste (Sprite {3:NUM}, Eigenschaft {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ungültige Produktions-Rückruffunktion (Sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ungültige Produktions-Rückruffunktion (Sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Achtung! @@ -3987,12 +3985,6 @@ STR_GROUP_CREATE_TOOLTIP :{BLACK}Neue Gru STR_GROUP_DELETE_TOOLTIP :{BLACK}Ausgewählte Gruppe löschen STR_GROUP_RENAME_TOOLTIP :{BLACK}Ausgewählte Gruppe umbenennen STR_GROUP_LIVERY_TOOLTIP :{BLACK}Farbschema der ausgewählten Gruppe ändern -STR_GROUP_COLLAPSE :{BLACK}Einklappen -STR_GROUP_EXPAND :{BLACK}Ausklappen -STR_GROUP_EXPAND_ALL :{BLACK}Alles ausklappen -STR_GROUP_COLLAPSE_ALL :{BLACK}Alles einklappen -STR_GROUP_COLLAPSE_TOOLTIP :{BLACK}Klicke, um die ausgewählte Gruppe einzuklappen -STR_GROUP_EXPAND_TOOLTIP :{BLACK}Klicke, um die ausgewählte Gruppe auszuklappen STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}Diese Gruppe von der automatischen Fahrzeugersetzung ausschließen STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}Gruppe löschen @@ -4055,11 +4047,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Fahrzeug STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Schiff kaufen STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Flugzeug kaufen + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Angewähltes Fahrzeug kaufen. Shift+Klick zeigt einen Kostenvoranschlag STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Ausgewähltes Fahrzeug kaufen. Shift+Klick zeigt einen Kostenvoranschlag STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Ausgewähltes Schiff kaufen. Shift+Klick zeigt einen Kostenvoranschlag STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Augewähltes Flugzeug kaufen. Shift schaltet zwischen Bauen und Kostenvoranschlag um + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Umbenennen STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Umbenennen STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Umbenennen diff --git a/src/lang/greek.txt b/src/lang/greek.txt index 787832d826..267a4cfd6a 100644 --- a/src/lang/greek.txt +++ b/src/lang/greek.txt @@ -527,6 +527,7 @@ STR_TOOLBAR_SOUND_MUSIC :Ήχος/Μου ############ range for message menu starts STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Τελευταίο μήνυμα/αναφορά ειδήσεων STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Ιστορικό μηνυμάτων +STR_NEWS_MENU_DELETE_ALL_MESSAGES :Διαγραφή όλων των μηνυμάτων ############ range ends here ############ range for about menu starts @@ -538,6 +539,7 @@ STR_ABOUT_MENU_SCREENSHOT :Στιγμιό STR_ABOUT_MENU_ZOOMIN_SCREENSHOT :Στιγμιότυπο οθόνης μέγιστης μεγέθυνσης STR_ABOUT_MENU_DEFAULTZOOM_SCREENSHOT :Στιγμιότυπο οθόνης τυπικής μεγέθυνσης STR_ABOUT_MENU_GIANT_SCREENSHOT :Στιγμιότυπο οθόνης για ολό τον χάρτη +STR_ABOUT_MENU_SHOW_FRAMERATE :Εμφάνιση ρυθμού καρέ STR_ABOUT_MENU_ABOUT_OPENTTD :Σχετικά με το 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Ευθυγραμμιστής στοιχεών STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Εναλλαγή πλαισίου οριοθέτησης @@ -923,6 +925,7 @@ STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLAC STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}({G 0 Διευθυντής Διευθύντρια ""}) STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}Η {STRING} χορήγεισε την κατασκεύη της νέας πόλης {TOWN}! +STR_NEWS_NEW_TOWN_UNSPONSORED :{BLACK}{BIG_FONT}Μια νέα πόλη με όνομα {TOWN} κατασκευάστηκε! STR_NEWS_INDUSTRY_CONSTRUCTION :{BIG_FONT}{BLACK}Νέ{G ος α ο} {STRING} υπό κατασκευή κοντά στην πόλη {TOWN}! STR_NEWS_INDUSTRY_PLANTED :{BIG_FONT}{BLACK}Νέο {STRING} φυτεύεται κοντά στην πόλη {TOWN}! @@ -1099,7 +1102,12 @@ STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL :Κανονικ STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Διπλό μέγεθος STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Τετραπλό μέγεθος +STR_GAME_OPTIONS_FONT_ZOOM :{BLACK}Μέγεθος γραμματοσειράς +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP :{BLACK}Επιλέξτε το μέγεθος της γραμματοσειράς διεπαφής +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL :Κανονικό +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM :Διπλό μέγεθος +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM :Τετραπλό μέγεθος STR_GAME_OPTIONS_BASE_GRF :{BLACK}Βασικό σετ γραφικών STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Επιλογή του βασικού σετ γραφικών που θα χρησιμοποιηθεί @@ -1283,6 +1291,8 @@ STR_CONFIG_SETTING_AUTOSLOPE :Να επιτρ STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Επιτρέπεται η διαμόρφωση του εδάφους κάτω από κτίρια και σιδηροτροχιές χωρίς αυτά να αφαιρούνται STR_CONFIG_SETTING_CATCHMENT :Επιτρέπονται πιο ρεαλιστικά ταξινομημένες περιοχές συλλογής : {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Διαφορετικοί σταθμοί και αεροδρόμια έχουν περιοχές κάλυψης διαφορετικού μεγέθους +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Οι σταθμοί της εταιρίας μπορούν να εξυπηρετήσεουν βιομηχανίες με κοντινούς ουδέτερους σταθμούς: {STRING} +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Όταν είναι ενεργοποιημένο, βιομηχανίες με ενσωματωμένους σταθμούς (όπως Πλατφόρμες Πετρελαίου) μπορούν να εξυπηρετούνται από κοντινούς σταθμούς της εταιρίας. Όταν είναι απενεργοποιημένο, οι βιομηχανίες αυτές μπορούν να εξυπηρετούνται μόνο από τους ενσωματωμένους σταθμούς τους. Κοντινοί σταθμοί της εταιρίας δεν θα μπορούν να τους εξυπηρετούν, ούτε και ο ενσωματωμένος σταθμός θα μπορεί να εξυπηρετήσει οτιδήποτε άλλο εκτός από τη βιομηχανία. STR_CONFIG_SETTING_EXTRADYNAMITE :Επιτρέπεται η αφαίρεση περισσότερων ιδιοκτησιών των πολέων: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Είναι ευκολότερη η αφαίρεση υποδομών και κτιρίων που κατέχονται από την πόλη STR_CONFIG_SETTING_TRAIN_LENGTH :Μέγιστο μήκος τρένων: {STRING} @@ -1299,7 +1309,7 @@ STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS_HELPTEXT :Η κλίση STR_CONFIG_SETTING_PERCENTAGE :{COMMA}% STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS :Κλίση εδάφους για τα οδικά οχήματα: {STRING} STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT :Η κλίση ενός κεκλιμένου τετραγωνίδιου για τα οδικά οχήματα. Μεγαλύτερες τιμές καθιστούν δυσκολότερο το ανέβασμα λόφων -STR_CONFIG_SETTING_FORBID_90_DEG :Απαγόρευση στα τρένα και πλοία να κάνουν στροφές 90°: {STRING} +STR_CONFIG_SETTING_FORBID_90_DEG :Απαγόρευση στα τρένα να κάνουν στροφές 90°: {STRING} STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :Στροφές 90 μοιρών προκύπτουν όταν μια οριζόντια σιδηροτροχιά ακολουθείται από μια κάθετη στο επόμενο τετραγωνίδιο, κάνοντας το τρένο να στρίψει κατά 90 μοίρες όταν αλλάζει τετραγωνίδιο, αντί για τις συνηθισμένες 45 μοίρες σε άλλους συνδυασμούς σιδηροτροχιών. Αυτό έχει επίσης εφαρμογή στην ακτίνα στροφής των πλοίων STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS :Να επιτρέπεται η συνένωση μη παρακείμενων σταθμών: {STRING} STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT :Επιτρέπεται η προσθήκη τμημάτων σε σταθμό χωρίς αυτά να αγγίζουν τα ήδη υπάρχοντα τμήματα. Χρειάζεται Ctrl+Κλικ κατά την τοποθέτηση των νέων τμημάτων @@ -1356,8 +1366,8 @@ STR_CONFIG_SETTING_PLANE_SPEED :Παράγον STR_CONFIG_SETTING_PLANE_SPEED_HELPTEXT :Ορίζεται η σχετική ταχύτητα των αεροπλάνων συγκριτικά με τους άλλους τύπους οχημάτων, ώστε να μειώνεται το ποσό του εισοδήματος από μεταφορές με αεροσκάφη STR_CONFIG_SETTING_PLANE_SPEED_VALUE :1 / {COMMA} STR_CONFIG_SETTING_PLANE_CRASHES :Αριθμός των αεροπορικών ατυχημάτων: {STRING} -STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Ορίστε την πιθανότητα συντριβής ενός αεροσκάφους -STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Καθόλου +STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Ορίστε την πιθανότητα συντριβής ενός τυχαίου αεροσκάφους.{}* Μεγάλα αεροσκάφη πάντα έχουν ένα ρίσκο συντριβής όταν προσγειώνονται σε μικρά αεροδρόμια. +STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Κανένα* STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :Μειωμένη STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :Κανονική STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Επιτρέπονται οι στάσεις σε δρόμους που είναι ιδιοκτησία των πόλεων : {STRING} @@ -1368,6 +1378,8 @@ STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Δεν STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Συντήρηση υποδομής: {STRING} STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :Όταν είναι ενεργοποιημένη, οι υποδομές προκαλούν έξοδα συντήρησης. Το κόστος μεγαλώνει δυσανάλογα με το μέγεθος του δικτύου, επηρεάζοντας έτσι τις μεγάλες εταιρείες περισσότερο από τις μικρότερες +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR :Αρχικό χρώμα εταιρίας: {STRING} +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT :Επιλογή του αρχικού χρώματος της εταιρίας STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Τα αεροδρόμια δεν λήγουν ποτέ: {STRING} STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Ενεργοποιώντας αυτήν τη ρύθμιση κάθε τύπος αεροδρομίου παραμένει διαθέσιμο για πάντα μετά την παρουσίασή του @@ -1680,6 +1692,10 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Ενεργοπ STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Δεν επιτρέπεται STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Επιτρέπεται STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Επιτρέπεται, προσαρμοσμένο σχέδιο πόλης +STR_CONFIG_SETTING_TOWN_CARGOGENMODE :Δημιουργία εμπορευμάτων πόλης: {STRING} +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT :Η ποσότητα εμπορευμάτων που παράγεται απο σπίτια σε πόλεις, σε σχέση με τον πληθυσμό της πόλης.{}Τετραγωνική ανάπτυξη: Μια πόλη διπλού μεγέθους παράγει τετραπλάσιο αριθμό επιβατών.{}Γραμμική ανάπτυξη: Μια πόλη διπλού μεγέθους παράγει διπλάσιο αριθμό επιβατών. +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_ORIGINAL :Τετραγωνικός (αρχική έκδοση) +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Γραμμικό STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Τοποθέτηση δέντρων εντός παιχνιδιού: {STRING} STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Έλεγχος της τυχαίας εμφάνισης δέντρων κατά τη διάρκεια του παιχνιδιού. Αυτό είναι πιθανό να επηρεάσει βιομηχανίες που εξαρτώνται από την ανάπτυξη των δέντρων, όπως για παράδειγμα οι υλοτομίες @@ -1807,7 +1823,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Κατ STR_CONFIG_SETTING_AI :{ORANGE}Ανταγωνιστές STR_CONFIG_SETTING_AI_NPC :{ORANGE}Παίκτες υπολογιστή -STR_CONFIG_SETTING_PATHFINDER_OPF :Αρχικό STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Συνίσταται) @@ -1885,13 +1900,12 @@ STR_INTRO_TRANSLATION :{BLACK}Λείπ # Quit window STR_QUIT_CAPTION :{WHITE}Έξοδος -STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD :{YELLOW}Είστε σίγουροι ότι θέλετε να εγκαταλείψετε το OpenTTD και να επιστρέψετε στο {STRING}; +STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD :{YELLOW}Είστε σίγουροι ότι θέλετε να εγκαταλείψετε το OpenTTD και να επιστρέψετε στο λειτουργικό {STRING}; STR_QUIT_YES :{BLACK}Ναι STR_QUIT_NO :{BLACK}Όχι # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2183,6 +2197,7 @@ STR_NETWORK_CONNECTION_DISCONNECT :{BLACK}Αποσ STR_NETWORK_NEED_GAME_PASSWORD_CAPTION :{WHITE}Η πρόσβαση στον διακομιστή προστατεύεται. Εισάγετε τον κωδικό STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION :{WHITE}Η εταιρεία προστατεύεται από κωδικό. Εισάγετε κωδικό +STR_NETWORK_COMPANY_LIST_CLIENT_LIST_CAPTION :{WHITE}Λίστα συμμετεχόντων # Network company list added strings STR_NETWORK_COMPANY_LIST_CLIENT_LIST :Λίστα συμμετεχόντων @@ -2228,7 +2243,7 @@ STR_NETWORK_CHAT_ALL :[Όλοι] {STR STR_NETWORK_CHAT_OSKTITLE :{BLACK}Εισάγετε το κείμενο για δικτυακή συζήτηση # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Δεν βρέθηκε συσκευή δικτύου ή έγινε μεταγλώττιση χωρίς την παράμετρο ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Δεν βρέθηκαν συσκευές δικτύου STR_NETWORK_ERROR_NOSERVER :{WHITE}Δεν βρέθηκε κάποιο δικτυακό παιχνίδι STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Ο διακομιστής δεν απάντησε στο αίτημα STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Απέτυχε η σύνδεση λόγο ασυμφωνίας NewGRF @@ -2480,9 +2495,9 @@ STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP :{BLACK}Συνδ STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP :{BLACK}Σηματοδότης Τροχιάς (ηλεκτρικός){}Ένας σηματοδότης τροχιάς επιτρέπει σε περισσότερα από ένα τρένο να είναι σε ένα κομμάτι ελέγχου την ίδια στιγμή, εάν το τρένο μπορεί να δεσμεύσει τροχιά σε ασφαλές σημείο στάσης. Κανονικοί σηματοδότες τροχιάς μπορούν να περαστούν από την πίσω πλευρά STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP :{BLACK}Μονόδρομος Σηματοδότης Τροχιάς (ηλεκτρικός){}Ένας σηματοδότης τροχιάς επιτρέπει σε περισσότερα από ένα τρένο να είναι σε ένα κομμάτι ελέγχου την ίδια στιγμή, εάν το τρένο μπορεί να δεσμεύσει τροχιά σε ασφαλές σημείο στάσης. Μονόδρομοι σηματοδότες τροχιάς δεν μπορούν να περαστούν από την πίσω πλευρά STR_BUILD_SIGNAL_CONVERT_TOOLTIP :{BLACK}Μετατροπέας Σηματοδότη{}Όταν επιλέγεται, πατώντας σε έναν υπάρχωντα σηματοδότη θα τον μετατρέψει στον επιλεγμένο τύπο και παραλλαγή σηματοδότη. Με Ctrl+Κλικ εναλλάσσεται με την υπάρχουσα παραλλαγή. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος μετατροπής -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP :{BLACK}Πυκνότητα σηματοδοτών με σύρσιμο -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP :{BLACK}Μείωση πυκνότητας σηματοδοτών με σύρσιμο -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Αύξηση πυκνότητας σηματοδοτών με σύρσιμο +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP :{BLACK}Απόσταση μεταξύ σηματοδοτών με σύρσιμο +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP :{BLACK}Μείωση απόστασης μεταξύ σηματοδοτών με σύρσιμο +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Αύξηση απόστασης μεταξύ σηματοδοτών με σύρσιμο # Bridge selection window STR_SELECT_RAIL_BRIDGE_CAPTION :{WHITE}Επιλογή Γέφυρας @@ -2801,33 +2816,48 @@ STR_LAI_OBJECT_DESCRIPTION_COMPANY_OWNED_LAND :Ιδιοκτη # About OpenTTD window STR_ABOUT_OPENTTD :{WHITE}Σχετικά με το OpenTTD STR_ABOUT_ORIGINAL_COPYRIGHT :{BLACK}Αρχικά Πνευματικά Δικαιώματα {COPYRIGHT} 1995 Chris Sawyer, Όλα τα δικαιώματα διατηρούνται -STR_ABOUT_VERSION :{BLACK}Έκδοση OpenTTD{REV} +STR_ABOUT_VERSION :{BLACK}OpenTTD έκδοση {REV} STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-2019 Η ομάδα του OpenTTD # Framerate display window +STR_FRAMERATE_CAPTION :{WHITE}Ρυθμός καρέ γραφικών STR_FRAMERATE_CAPTION_SMALL :{STRING}{WHITE} ({DECIMAL}x) +STR_FRAMERATE_RATE_GAMELOOP :{BLACK}Ρυθμός προσομοίωσης: {STRING} STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP :{BLACK}Αριθμός στιγμών παιχνιδιού που προσομοιώνεται ανά δευτερόλεπτο. -STR_FRAMERATE_RATE_BLITTER_TOOLTIP :{BLACK}Αριθμος των παραγμενων video frames ανα δευτερολεπτο -STR_FRAMERATE_SPEED_FACTOR :{WHITE}Παράγοντας ταχύτητας τρέχοντος παιχνιδιού: {DECIMAL}x +STR_FRAMERATE_RATE_BLITTER :{BLACK}Ρυθμός καρέ γραφικών: {STRING} +STR_FRAMERATE_RATE_BLITTER_TOOLTIP :{BLACK}Αριθμος των παραγμενων καρέ ανα δευτερολεπτο +STR_FRAMERATE_SPEED_FACTOR :{BLACK}Παράγοντας ταχύτητας τρέχοντος παιχνιδιού: {DECIMAL}x STR_FRAMERATE_SPEED_FACTOR_TOOLTIP :{BLACK}Πόσο γρήγορα εκτελείται το παιχνίδι αυτήν τη στιγμή, σε σύγκριση με την αναμενόμενη ταχύτητα στον κανονικό ρυθμό εξομοίωσης. STR_FRAMERATE_CURRENT :{WHITE}Τρέχον STR_FRAMERATE_AVERAGE :{WHITE}Μέσο -STR_FRAMERATE_DATA_POINTS :{WHITE}Τα δεδομένα βασίζονται σε μετρήσεις {COMMA} -STR_FRAMERATE_MS_GOOD :{LTBLUE}{DECIMAL}{WHITE} ms +STR_FRAMERATE_DATA_POINTS :{BLACK}Τα δεδομένα βασίζονται σε μετρήσεις {COMMA} +STR_FRAMERATE_MS_GOOD :{LTBLUE}{DECIMAL} ms +STR_FRAMERATE_MS_WARN :{YELLOW}{DECIMAL} ms STR_FRAMERATE_MS_BAD :{RED}{DECIMAL} ms -STR_FRAMERATE_FPS_GOOD :{LTBLUE}{DECIMAL} frames/δευτ. -STR_FRAMERATE_FPS_BAD :{RED}{DECIMAL} frames/δευτ. +STR_FRAMERATE_FPS_GOOD :{LTBLUE}{DECIMAL} καρέ/δευτερόλεπτο +STR_FRAMERATE_FPS_WARN :{YELLOW}{DECIMAL} καρέ/δευτερόλεπτο +STR_FRAMERATE_FPS_BAD :{RED}{DECIMAL} καρέ/δευτερόλεπτο +STR_FRAMERATE_GRAPH_MILLISECONDS :{TINY_FONT}{COMMA} ms +STR_FRAMERATE_GRAPH_SECONDS :{TINY_FONT}{COMMA} ς ############ Leave those lines in this order!! -STR_FRAMERATE_GL_ECONOMY :{WHITE} Διαχείριση φορτίου: -STR_FRAMERATE_GL_TRAINS :Στιγμές τρένων: -STR_FRAMERATE_GL_ROADVEHS :{WHITE} Στιγμές οχημάτων δρόμου: -STR_FRAMERATE_GL_SHIPS :Στιγμές πλοίων: -STR_FRAMERATE_GL_AIRCRAFT :Στιγμές αεροσκαφών: -STR_FRAMERATE_GL_LANDSCAPE :Στιγμές κόσμου: -STR_FRAMERATE_VIDEO :{WHITE}Έξοδος βίντεο: -STR_FRAMERATE_SOUND :{WHITE}Μίξη ήχου: +STR_FRAMERATE_GAMELOOP :{BLACK}Σύνολο βρόγχου παιχνιδιού: +STR_FRAMERATE_GL_ECONOMY :{BLACK} Διαχείριση φορτίου: +STR_FRAMERATE_GL_TRAINS :{BLACK} Στιγμές τρένων: +STR_FRAMERATE_GL_ROADVEHS :{BLACK} Στιγμές οχημάτων δρόμου: +STR_FRAMERATE_GL_SHIPS :{BLACK} Στιγμές πλοίων: +STR_FRAMERATE_GL_AIRCRAFT :{BLACK} Στιγμές αεροσκαφών: +STR_FRAMERATE_GL_LANDSCAPE :{BLACK} Στιγμές κόσμου: +STR_FRAMERATE_GL_LINKGRAPH :{BLACK} Καθυστέρηση γραφήματος συνδέσμου: +STR_FRAMERATE_DRAWING :{BLACK}Γραφική απόδοση: +STR_FRAMERATE_DRAWING_VIEWPORTS :Παράθυρα προβολής κόσμου: +STR_FRAMERATE_VIDEO :{BLACK}Έξοδος βίντεο: +STR_FRAMERATE_SOUND :{BLACK}Μίξη ήχου: +STR_FRAMERATE_ALLSCRIPTS :Σύνολο GS/AI: +STR_FRAMERATE_GAMESCRIPT :{BLACK} Δέσμη ενεργειών παιχνιδιού: +STR_FRAMERATE_AI :{BLACK} AI {NUM} {STRING} ############ End of leave-in-this-order ############ Leave those lines in this order!! +STR_FRAMETIME_CAPTION_GAMELOOP :Βρόγχος παιχνιδιού STR_FRAMETIME_CAPTION_GL_ECONOMY :Διαχείριση φορτίου STR_FRAMETIME_CAPTION_GL_TRAINS :Στιγμές τρένων STR_FRAMETIME_CAPTION_GL_ROADVEHS :Στιγμές οχημάτων δρόμου @@ -2835,8 +2865,13 @@ STR_FRAMETIME_CAPTION_GL_SHIPS :Στιγμές STR_FRAMETIME_CAPTION_GL_AIRCRAFT :Στιγμές αεροσκαφών STR_FRAMETIME_CAPTION_GL_LANDSCAPE :Στιγμές κόσμου STR_FRAMETIME_CAPTION_GL_LINKGRAPH :Καθυστέρηση γραφήματος συνδέσμου +STR_FRAMETIME_CAPTION_DRAWING :Γραφική απόδοση +STR_FRAMETIME_CAPTION_DRAWING_VIEWPORTS :Παράθυρα προβολής κόσμου STR_FRAMETIME_CAPTION_VIDEO :Έξοδος βίντεο STR_FRAMETIME_CAPTION_SOUND :Μίξη ήχου +STR_FRAMETIME_CAPTION_ALLSCRIPTS :Σύνολο GS/AI δεσμών ενεργειών +STR_FRAMETIME_CAPTION_GAMESCRIPT :Δέσμη Ενεργειών παιχνιδιού +STR_FRAMETIME_CAPTION_AI :AI {NUM} {STRING} ############ End of leave-in-this-order @@ -2862,6 +2897,7 @@ STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Λεπτ STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}Δεν υπάρχουν πληροφορίες. STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING} STR_SAVELOAD_DETAIL_GRFSTATUS :{SILVER}NewGRF: {WHITE}{STRING} +STR_SAVELOAD_FILTER_TITLE :Φιλτράρισμα κειμένου: STR_SAVELOAD_OVERWRITE_TITLE :{WHITE}Αντικατάσταση Αρχείου STR_SAVELOAD_OVERWRITE_WARNING :{YELLOW}Είστε σίγουροι οτι θέλετε να αντικαταστήσετε το υπάρχων αρχείο; @@ -2982,6 +3018,9 @@ STR_NEWGRF_SETTINGS_MIN_VERSION :{BLACK}Ελάχ STR_NEWGRF_SETTINGS_MD5SUM :{BLACK}MD5sum: {SILVER}{STRING} STR_NEWGRF_SETTINGS_PALETTE :{BLACK}Παλέτα: {SILVER}{STRING} STR_NEWGRF_SETTINGS_PALETTE_DEFAULT :Προεπιλογή (D) +STR_NEWGRF_SETTINGS_PALETTE_DEFAULT_32BPP :Προεπιλογή (D) / 32 bpp +STR_NEWGRF_SETTINGS_PALETTE_LEGACY :Παλαιού τύπου (W) +STR_NEWGRF_SETTINGS_PALETTE_LEGACY_32BPP :Παλαιού τύπου (W) / 32 bpp STR_NEWGRF_SETTINGS_PARAMETER :{BLACK}Παράμετροι: {SILVER}{STRING} STR_NEWGRF_SETTINGS_PARAMETER_NONE :Κανένα @@ -3064,6 +3103,8 @@ STR_NEWGRF_ERROR_READ_BOUNDS :Διάβασε STR_NEWGRF_ERROR_GRM_FAILED :Οι ζητημένοι πόροι GRF δεν είναι διαθέσιμοι (sprite {3:NUM}) STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :Το {1:STRING} απενεργοποιήθηκε από το {2:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Άκυρη/άγνωστη μορφή σχεδίου sprite (sprite {3:NUM}) +STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Πάρα πολλά αντικέιμενα στη λίστα τιμών ιδιοτήτων (sprite {3:NUM}, ιδιότητα {4:HEX}) +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Άγνωστη/άκυρη σπιτροφή κήσης από παραγωγή βιομηχανίας (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Προσοχή! @@ -3089,12 +3130,13 @@ STR_NEWGRF_BROKEN :{WHITE}Η συ STR_NEWGRF_BROKEN_POWERED_WAGON :{WHITE}Άλλαξε την κατάσταση *** για «{1:ENGINE}» όταν δεν είναι μέσα σε αμαξοστάσιο STR_NEWGRF_BROKEN_VEHICLE_LENGTH :{WHITE}Άλλαξε το μήκος του οχήματος «{1:ENGINE}» ενώ δεν βρισκόταν μέσα σε αμαξοστάσιο STR_NEWGRF_BROKEN_CAPACITY :{WHITE}Άλλαξε τη χωριτικότητα όχηματος για τη «{1:ENGINE}» όταν δεν είναι σε αμαξοστάσιο ή διαδικασία μετατροπής -STR_BROKEN_VEHICLE_LENGTH :{WHITE}Το τρένο «{VEHICLE}» που ανήκει στην εταιρία «{COMPANY}» έχει μη έγκυρο μήκος. Πιθανόν να προέρχεται από προβλήματα με NewGRF. Το παιχνίδι μπορεί να αποσυγχρονιστεί ή να κλείσει απρόοπτα. +STR_BROKEN_VEHICLE_LENGTH :{WHITE}Το τρένο «{VEHICLE}» που ανήκει στην εταιρία «{COMPANY}» έχει μη έγκυρο μήκος. Πιθανόν να προκλήθηκε από προβλήματα με κάποια NewGRF. Το παιχνίδι μπορεί να αποσυγχρονιστεί ή να κλείσει απρόοπτα. STR_NEWGRF_BUGGY :{WHITE}Το NewGRF «{0:STRING}» δίνει λάθος πληροφορίες STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Η πληροφορία εμπορεύματος/μετατροπής για το «{1:ENGINE}» διαφέρει από τη λίστα αγοράς μετά την κατασκευή. Αυτό μπορεί να προκαλέσει την αποτυχία της αυτόματης ανανέωσης/αντικατάστασης για σωστή μετατροπή STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}Το «{1:STRING}» προκάλεσε ένα ατέρμονο βρόχο στην κλήση παραγωγής STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Η κλήση {1:HEX} επέστρεψε άγνωστο/άκυρο αποτέλεσμα {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}Το '{1:STRING}' επέστρεψε άγνωστο/άκυρο τύπο εμπορεύματος στην κλήση {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO :<μη έγκυρο φορτίο> @@ -3189,6 +3231,7 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{YELLOW}Δωρ # Goal window STR_GOALS_CAPTION :{WHITE}{COMPANY} Στόχοι: STR_GOALS_SPECTATOR_CAPTION :{WHITE}Καθολικοί στόχοι: +STR_GOALS_SPECTATOR :Καθολικοί στόχοι STR_GOALS_GLOBAL_TITLE :{BLACK}Καθολικοί στόχοι: STR_GOALS_TEXT :{ORANGE}{STRING} STR_GOALS_NONE :{ORANGE}- Κανένας - @@ -3237,6 +3280,7 @@ STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Πατή # Story book window STR_STORY_BOOK_CAPTION :{WHITE}{COMPANY} Βιβλίο Ιστορίας STR_STORY_BOOK_SPECTATOR_CAPTION :{WHITE}Παγκόσμιο Βιβλίο Ιστορίας +STR_STORY_BOOK_SPECTATOR :Παγκόσμιο Βιβλίο Ιστορίας STR_STORY_BOOK_TITLE :{YELLOW}{STRING} STR_STORY_BOOK_GENERIC_PAGE_ITEM :Σελίδα {NUM} STR_STORY_BOOK_SEL_PAGE_TOOLTIP :{BLACK}Μεταβείτε σε μια συγκεκριμένη σελίδα επιλέγοντάς την από αυτή τη λίστα. @@ -3443,6 +3487,8 @@ STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Κεντ STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Επίπεδο παραγωγής: {YELLOW}{COMMA}% STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE :{YELLOW}Η βιομηχανία έχει ανακοινώσει άμεσο κλείσιμο! +STR_INDUSTRY_VIEW_REQUIRES_N_CARGO :{BLACK}Απαιτεί: {YELLOW}{STRING}{STRING} +STR_INDUSTRY_VIEW_PRODUCES_N_CARGO :{BLACK}Παράγει: {YELLOW}{STRING}{STRING} STR_INDUSTRY_VIEW_CARGO_LIST_EXTENSION :, {STRING}{STRING} STR_INDUSTRY_VIEW_REQUIRES :{BLACK}Απαιτεί: @@ -3501,6 +3547,7 @@ STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP :{BLACK}Ομάδ STR_GROUP_CREATE_TOOLTIP :{BLACK}Πατήστε για δημιουργήσετε ομάδα STR_GROUP_DELETE_TOOLTIP :{BLACK}Διαγραφή της επιλεγμένης ομάδας STR_GROUP_RENAME_TOOLTIP :{BLACK}Μετονομασία της επιλεγμένης ομάδας +STR_GROUP_LIVERY_TOOLTIP :{BLACK}Αλλαγή εμφάνισης της επιλεγμένης ομάδας STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}Πατήστε για προστατέψετε αυτήν την ομάδα από την γενική αυτόματη αντικατάσταση STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}Διαγραφή ομάδας @@ -3528,6 +3575,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Νέα Πλοί STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Νέα Αεροσκάφη STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG}{BLACK} Βάρος: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG}{BLACK} (Κόστος μετατροπής: {GOLD}{CURRENCY_LONG}{BLACK}) Βάρος: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Ταχύτητα: {GOLD}{VELOCITY}{BLACK} Δύναμη κινητήρα: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Ταχύτητα: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Ταχύτητα στον ωκεανό: {GOLD}{VELOCITY} @@ -3538,13 +3586,16 @@ STR_PURCHASE_INFO_REFITTABLE :(μετατρέ STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Έτος σχεδίασης: {GOLD}{NUM}{BLACK} Χρόνος ζωής: {GOLD}{COMMA} χρόν{P ο ια} STR_PURCHASE_INFO_RELIABILITY :{BLACK}Μέγ. Αξιοπιστία: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG}{BLACK} (Κόστος μετατροπής: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Βάρος: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG}{BLACK} Ταχύτητα: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Κόστος: {GOLD}{CURRENCY_LONG}{BLACK} (Κόστος μετατροπής: {GOLD}{CURRENCY_LONG}{BLACK}) Ταχύτητα: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Χωρητικότητα: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Ενισχυμένα Βαγόνια: {GOLD}+{POWER}{BLACK} Βάρος: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Μετατρέψιμο σε: {GOLD}{STRING} STR_PURCHASE_INFO_ALL_TYPES :Όλοι οι τύποι εμπορεύματος -STR_PURCHASE_INFO_ALL_BUT :Όλοι εκτός από {CARGO_LIST} +STR_PURCHASE_INFO_NONE :Κανένα +STR_PURCHASE_INFO_ALL_BUT :Όλα εκτός από {CARGO_LIST} STR_PURCHASE_INFO_MAX_TE :{BLACK}Μέγ. Δύναμη Έλξης: {GOLD}{FORCE} STR_PURCHASE_INFO_AIRCRAFT_RANGE :{BLACK}Εύρος: {GOLD}{COMMA} τετραγωνίδια STR_PURCHASE_INFO_AIRCRAFT_TYPE :{BLACK}Τύπος αεροσκάφους: {GOLD}{STRING} @@ -3559,10 +3610,20 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Αγορ STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Αγορά Πλοίου STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Αγορά Αεροσκάφους -STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Αγοράστε το επιλεγμένο όχημα τρένου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά -STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Αγοράστε το επιλεγμένο όχημα δρόμου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Αγορά και μετατροπή οχήματος +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Αγορά και μετατροπή οχήματος +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Αγορά και μετατροπή πλοίου +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Αγορά και μετατροπή του αεροσκάφους + +STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Αγορά του επιλεγμένου οχήματος τρένου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Αγορά του επιλεγμένου οχήματος δρόμου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Αγοράστε το επιλεγμένο πλοίο. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά -STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Αγοράστε το επιλεγμένο αεροσκάφος. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Αγορά του επιλεγμένου αεροσκάφους. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά + +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Αγορά και μετατροπή του επιλεγμένου οχήματος τρένου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Αγορά και μετατροπή του επιλεγμένου οχήματος δρόμου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Αγορά και μετατροπή του επιλεγμένου πλοίου. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Αγορά και μετατροπή του επιλεγμένου αεροσκάφους. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς αγορά STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Μετονομασία STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Μετονομασία @@ -3644,7 +3705,7 @@ STR_DEPOT_CLONE_AIRCRAFT :{BLACK}Κλων STR_DEPOT_CLONE_TRAIN_DEPOT_INFO :{BLACK}Αυτό θα αγοράσει ένα αντίγραφο του τρένου μαζί με τα όλα τα βαγόνια. Πατήστε αυτό το κουμπί και μετά σε κάποιο τρένο μέσα ή έξω από το αμαξοστάσιο. Με Ctrl+Κλικ θα έχει τις ίδιες εντολές. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς να γίνει η αγορά STR_DEPOT_CLONE_ROAD_VEHICLE_DEPOT_INFO :{BLACK}Αυτό θα αγοράσει ένα αντίγραφο του οχήματος. Πατήστε αυτό το κουμπί και μετά σε κάποιο όχημα μέσα ή έξω από το αμαξοστάσιο. Με Ctrl+Κλικ θα έχει τις ίδιες εντολές. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς να γίνει η αγορά -STR_DEPOT_CLONE_SHIP_DEPOT_INFO :{BLACK}Αυτό θα αγοράσει ένα αντίγραφο του πλοίου. Πατήστε αυτό το κουμπί και μετά σε κάποιο πλοίο μέσα ή έξω από το ναυπηγείο. Με Ctrl+Κλικ θα έχει τις ίδιες εντολές. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς να γίνει η αγορά +STR_DEPOT_CLONE_SHIP_DEPOT_INFO :{BLACK}Αυτό θα αγοράσει ένα αντίγραφο ενός πλοίου. Πατήστε αυτό το κουμπί και μετά σε κάποιο πλοίο μέσα ή έξω από το ναυπηγείο. Με Ctrl+Κλικ θα έχει τις ίδιες εντολές. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς να γίνει η αγορά STR_DEPOT_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW :{BLACK}Αυτό θα αγοράσει ένα αντίγραφο του αεροσκάφους. Πατήστε αυτό το κουμπί και μετά σε κάποιο αεροσκάφος μέσα στο ή έξω από το υπόστεγο. Με Ctrl+Κλικ θα έχει τις ίδιες εντολές. Με Shift+Κλικ εμφανίζεται το εκτιμώμενο κόστος χωρίς να γίνει η αγορά STR_DEPOT_TRAIN_LOCATION_TOOLTIP :{BLACK}Κεντράρισμα της εικόνας στην τοποθεσία του αμαξοστάσιου. Με Ctrl+Κλικ ανοίγει νέο παράθυρο εμφάνισης στην τοποθεσία του αμαξοστασίου @@ -3949,6 +4010,7 @@ STR_ORDER_CONDITIONAL_AGE :{G=f}Ηλικί STR_ORDER_CONDITIONAL_REQUIRES_SERVICE :Απαιτεί επισκευή STR_ORDER_CONDITIONAL_UNCONDITIONALLY :Πάντα STR_ORDER_CONDITIONAL_REMAINING_LIFETIME :Υπόλοιπη διάρκεια ζωής (χρόνια) +STR_ORDER_CONDITIONAL_MAX_RELIABILITY :Μέγιστη αξιοπιστία STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP :{BLACK}Πως να συγκρίνετε τα δεδομένα του οχήματος με την δοσμένη τιμή STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS :είναι ίσο με diff --git a/src/lang/hebrew.txt b/src/lang/hebrew.txt index 0d61413cbc..847f55c3d1 100644 --- a/src/lang/hebrew.txt +++ b/src/lang/hebrew.txt @@ -1709,7 +1709,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}התפ STR_CONFIG_SETTING_AI :{ORANGE}מתחרים STR_CONFIG_SETTING_AI_NPC :{ORANGE}שחקני מחשב -STR_CONFIG_SETTING_PATHFINDER_OPF :מקורי STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(מומלץ) @@ -1793,7 +1792,6 @@ STR_QUIT_NO :{BLACK}לא # Supported OSes STR_OSNAME_WINDOWS :חלונות -STR_OSNAME_DOS :דוס STR_OSNAME_UNIX :יוניקס STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :הייקו @@ -3454,11 +3452,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}רכוש STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}רכוש כלי שייט STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}רכוש כלי טייס + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}רכוש את קרון הרכבת שמודגש. Shift+לחיצה מציג הערכת עלות ללא רכישה STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}רכוש את כלי הרכב שמודגש. Shift+לחיצה מציג הערכת עלות ללא רכישה STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}רכוש את כלי השייט שמודגש. Shift+לחיצה מציג הערכת עלות ללא רכישה STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}רכוש את כלי הטייס שמודגש. Shift+לחיצה מציג הערכת עלות ללא רכישה + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}שנה שם STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}שנה שם STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}החלף שם diff --git a/src/lang/hungarian.txt b/src/lang/hungarian.txt index 5a893b2af1..8fc9e4589a 100644 --- a/src/lang/hungarian.txt +++ b/src/lang/hungarian.txt @@ -1780,7 +1780,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Rakomá STR_CONFIG_SETTING_AI :{ORANGE}Ellenfelek STR_CONFIG_SETTING_AI_NPC :{ORANGE}Számítógép által vezérelt ellenfelek -STR_CONFIG_SETTING_PATHFINDER_OPF :Eredeti STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Ajánlott) @@ -1864,7 +1863,6 @@ STR_QUIT_NO :{BLACK}Nem # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2202,7 +2200,7 @@ STR_NETWORK_CHAT_ALL :[Mindenkinek] { STR_NETWORK_CHAT_OSKTITLE :{BLACK}Add meg a hálózati beszélgetéshez a neved # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nem található a hálózati csatoló, vagy a játékban nincs hálózati támogatás (ENABLE_NETWORK) +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nem található a hálózati csatoló STR_NETWORK_ERROR_NOSERVER :{WHITE}Nem található semmilyen hálózati játék STR_NETWORK_ERROR_NOCONNECTION :{WHITE}A szerver nem válaszolt a kérésre STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}NewGRF eltérés miatt nem sikerült kapcsolódni @@ -3063,7 +3061,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Kért GRF forr STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} kikapcsolva {STRING} által STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Érvénytelen/ismeretlen sprite szerkezet formátum (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Túl sok érték a tulajdonságlistában (sprite {3:NUM}, property {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Érvénytelen termelési callback gazdasági épületben (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Érvénytelen termelési callback gazdasági épületben (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Figyelem! @@ -3095,6 +3093,7 @@ STR_NEWGRF_BUGGY :{WHITE}A(z) '{0 STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}A(z) '{1:ENGINE}' rakomány/átalakítás információja a gyártás után különbözik a vételi listán találhatótól. Ez hibát okozhat az automatikus felújítás/lecserélés során az átalakításban STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' végtelen ciklust okozott a termelés folyamatnál STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}{1:HEX} visszatérő érték ismeretlen/érvénytelen {2:HEX} értékkel tért vissza +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' érvénytelen rakománytípussal tért vissza a termelési callback-ben: {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO :<érvénytelen rakomány> @@ -3533,6 +3532,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Új hajók STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Új repülőgépek STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Ár: {GOLD}{CURRENCY_LONG}{BLACK} Súly: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Ár: {GOLD}{CURRENCY_LONG}{BLACK} (Átalakítás költsége: {GOLD}{CURRENCY_LONG}{BLACK}) Súly: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Sebesség: {GOLD}{VELOCITY}{BLACK} Telj.: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Sebesség: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Sebesség óceánon: {GOLD}{VELOCITY} @@ -3543,12 +3543,14 @@ STR_PURCHASE_INFO_REFITTABLE :(átalakíthat STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Kifejlesztve: {GOLD}{NUM}{BLACK} Élettartam: {GOLD}{COMMA} év STR_PURCHASE_INFO_RELIABILITY :{BLACK}Max. megbízhatóság: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Ár: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Ár: {GOLD}{CURRENCY_LONG}{BLACK} (Átalakítás költsége: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Súly: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Ár: {GOLD}{CURRENCY_LONG}{BLACK} Sebesség: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Ár: {GOLD}{CURRENCY_LONG}{BLACK} (Átalakítás költsége: {GOLD}{CURRENCY_LONG}{BLACK}) Végsebesség: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Kapacitás: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Meghajtott vagonok: {GOLD}+{POWER}{BLACK} Súly: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Átalakítható: {GOLD}{STRING} -STR_PURCHASE_INFO_ALL_TYPES :Minden rakomány típusra +STR_PURCHASE_INFO_ALL_TYPES :Minden rakománytípusra STR_PURCHASE_INFO_NONE :Semmi STR_PURCHASE_INFO_ALL_BUT :Mindenre, kivéve {CARGO_LIST} STR_PURCHASE_INFO_MAX_TE :{BLACK}Maximális vonóerő: {GOLD}{FORCE} @@ -3565,11 +3567,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Megvesz STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Megvesz STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Megvesz +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Megvesz és átalakít +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Megvesz és átalakít +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Megvesz és átalakít +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Megvesz és átalakít + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}A kijelölt vasúti jármű megvétele. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}A kijelölt közúti jármű megvétele. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}A kijelölt hajó megvétele. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}A kijelölt repülőgép megvétele. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}A kijelölt vasúti jármű megvétele és átalakítása a kijelölt rakománytípusra. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}A kijelölt közúti jármű megvétele és átalakítása a kijelölt rakománytípusra. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}A kijelölt hajó megvétele és átalakítása a kijelölt rakománytípusra. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}A kijelölt repülőgép megvétele és átalakítása a kijelölt rakománytípusra. Shift+kattintással megmutatja a becsült költséget vásárlás nélkül + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Átnevez STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Átnevez STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Átnevez diff --git a/src/lang/icelandic.txt b/src/lang/icelandic.txt index 992208bf89..afa0fa88c2 100644 --- a/src/lang/icelandic.txt +++ b/src/lang/icelandic.txt @@ -1551,7 +1551,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Iðnað STR_CONFIG_SETTING_AI :{ORANGE}Mótherji STR_CONFIG_SETTING_AI_NPC :{ORANGE}Gervigreind -STR_CONFIG_SETTING_PATHFINDER_OPF :Upprunalegt STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Ráðlegt) @@ -1632,7 +1631,6 @@ STR_QUIT_NO :{BLACK}Nei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3177,11 +3175,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kaupa bi STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kaupa skip STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kaupa flugvél + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kaupa valinn lestarvagn. Shift+smella sýnir áætlaðan kostnað án þess að kaupa STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kaupa valda bifreið. Shift+smella sýnir áætlaðan kostnað án þess að kaupa STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kaupa valið skip. Shift+smella sýnir áætlaðan kostnað án þess að kaupa STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kaupa valda flugvél. Shift+smella sýnir áætlaðan kostnað án þess að kaupa + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Endurnefna STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Endurnefna STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Endurnefna diff --git a/src/lang/indonesian.txt b/src/lang/indonesian.txt index 105338f4b1..c6febf1884 100644 --- a/src/lang/indonesian.txt +++ b/src/lang/indonesian.txt @@ -1694,7 +1694,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Pesaing STR_CONFIG_SETTING_AI_NPC :{ORANGE}Pemain Komputer -STR_CONFIG_SETTING_PATHFINDER_OPF :Asli STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -1777,7 +1776,6 @@ STR_QUIT_NO :{BLACK}Tidak # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3429,11 +3427,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Beli Ken STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Beli Kapal STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Beli Pesawat + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kereta yang dipilih. Shift untuk menampilkan perkiraan biaya STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kendaraan yang dipilih. Shift untuk menampilkan perkiraan biaya STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kapal yang dipilih. Shift untuk menampilkan perkiraan biaya STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Beli pesawat yang dipilih. Shift untuk menampilkan perkiraan biaya + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Ubah Nama STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Ganti Nama STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Ubah Nama diff --git a/src/lang/irish.txt b/src/lang/irish.txt index 686c742792..0070b38257 100644 --- a/src/lang/irish.txt +++ b/src/lang/irish.txt @@ -1684,7 +1684,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Dáilea STR_CONFIG_SETTING_AI :{ORANGE}Iomaitheoirí STR_CONFIG_SETTING_AI_NPC :{ORANGE}Ríomh-imreoirí -STR_CONFIG_SETTING_PATHFINDER_OPF :Bunaidh STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Molta) @@ -1767,7 +1766,6 @@ STR_QUIT_NO :{BLACK}Níl # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3388,11 +3386,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Ceannaig STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Ceannaigh Long STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Ceannaigh Aerárthach + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaigh an fheithicil traenach aibhsithe STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaigh an fheithicil bóthair aibhsithe STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaigh an long aibhsithe STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Ceannaigh an t-aerárthach aibhsithe + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Athainmnigh STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Athainmnigh STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Athainmnigh diff --git a/src/lang/italian.txt b/src/lang/italian.txt index 23ae0d6794..6a2c091847 100644 --- a/src/lang/italian.txt +++ b/src/lang/italian.txt @@ -1734,7 +1734,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Avversari STR_CONFIG_SETTING_AI_NPC :{ORANGE}Giocatori controllati dal computer -STR_CONFIG_SETTING_PATHFINDER_OPF :Originale STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(raccomandato) @@ -1818,7 +1817,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3023,7 +3021,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Risorsa GRF ric STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} è stato disabilitato da {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Formato di layout dello sprite sconosciuto o non valido (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Troppi elementi nella lista valori di una proprietà (sprite {3:NUM}, proprietà {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Callback di produzione industria non valido (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Callback di produzione industria non valido (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Attenzione! @@ -3525,11 +3523,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Compra v STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Compra nave STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Compra aeromobile + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Compra il veicolo ferroviario selezionato. MAIUSC+clic mostra il costo stimato senza comprare STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Compra l'automezzo selezionato. MAIUSC+clic mostra il costo stimato senza comprare STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Compra la nave selezionata. MAIUSC+clic mostra il costo stimato senza comprare STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Compra l'aeromobile selezionato. MAIUSC+clic mostra il costo stimato senza comprare + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Rinomina STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Rinomina STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Rinomina diff --git a/src/lang/japanese.txt b/src/lang/japanese.txt index 1c14185aca..fd8ec41f32 100644 --- a/src/lang/japanese.txt +++ b/src/lang/japanese.txt @@ -1688,7 +1688,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}貨物 STR_CONFIG_SETTING_AI :{ORANGE}競争会社 STR_CONFIG_SETTING_AI_NPC :{ORANGE}コンピュータプレイヤー -STR_CONFIG_SETTING_PATHFINDER_OPF :オリジナル STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF{BLUE}(おすすめ) @@ -1771,7 +1770,6 @@ STR_QUIT_NO :{BLACK}いい # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3454,11 +3452,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}車両 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}船舶を購入 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}航空機を購入 + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}選択した列車を購入します。Shift+クリックで購入費を見積もります STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}選択した車両を購入します。Shift+クリックで購入費を見積もります STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}選択した船舶を購入します。Shift+クリックで購入費を見積もります STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}選択した航空機を購入します。Shift+クリックで購入費を見積もります + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}名称を変更 STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}名称を変更 STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}名称を変更 diff --git a/src/lang/korean.txt b/src/lang/korean.txt index 77dfe49bd6..c5b4b2da73 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -1192,6 +1192,8 @@ STR_CONFIG_SETTING_AUTOSLOPE :건물, 트랙 STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :건물이나 도로/선로 등을 제거하지 않고도 하부의 지형을 편집할 수 있게 허용합니다. STR_CONFIG_SETTING_CATCHMENT :더 현실적인 역세권 지정: {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :역과 공항의 종류에 따라 다른 크기의 역세권을 가지도록 만듭니다. +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :역이 붙어 있는 산업 시설의 화물을 회사의 역이 취급 가능: {STRING} +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :이 설정을 켜면, (유전과 같이) 역이 붙어 있는 산업시설이 근처에 지은 회사 소유의 역에서도 화물을 취급할 수 있습니다. 이 설정을 끄면, 반드시 산업시설에 붙어 있는 역에서만 화물을 취급할 수 있습니다. 인근에 있는 모든 회사 소유의 역은 화물을 취급할 수 없게 되며, 산업시설에 붙어 있는 역도 그 산업시설 이외의 화물을 취급할 수 없게 됩니다. STR_CONFIG_SETTING_CATCHMENT_INCREASE :역세권 크기 늘리기: {STRING} STR_CONFIG_SETTING_CATCHMENT_INCREASE_HELPTEXT :정한 칸 만큼 역세권을 증가시킵니다. STR_CONFIG_SETTING_STATION_RATING_CARGO_CLASS_WAIT_TIME :화물 종류에 따라 대기 시간이 역 등급에 미치는 영향 조정: {STRING} @@ -1719,6 +1721,10 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :플레이어가 STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :금지 STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :허용 STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :허용, 도시 구조 선택 가능 +STR_CONFIG_SETTING_TOWN_CARGOGENMODE :도시 화물 생성: {STRING} +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT :도시의 전반적인 인구에 따라, 도시가 얼마나 많은 화물을 생산하는 지를 설정합니다.{}제곱 성장: 도시의 규모가 2배 커지면 승객을 4배 더 생산합니다.{}선형 성장: 도시의 규모가 2배 커지면 승객을 2배 더 생산합니다. +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_ORIGINAL :제곱 (기본) +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :선형 STR_CONFIG_SETTING_TOWN_CARGO_FACTOR :도시 화물 생성 계수 (적음 < 0 < 많음): {STRING} STR_CONFIG_SETTING_TOWN_CARGO_FACTOR_HELPTEXT :도시가 생산하는 화물의 양을 2^(생성 계수)에 근접하게 조절합니다. @@ -1881,7 +1887,6 @@ STR_CONFIG_SETTING_AI_NPC :{ORANGE}컴퓨 STR_CONFIG_SETTING_VIEWPORT_MAP_OPTIONS :{ORANGE}지도 모드 STR_CONFIG_SETTING_SHARING :{ORANGE}시설 공유 -STR_CONFIG_SETTING_PATHFINDER_OPF :오리지널 STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(권장) @@ -1999,7 +2004,6 @@ STR_QUIT_NO :{BLACK}아니 # Supported OSes STR_OSNAME_WINDOWS :{G=f}Windows -STR_OSNAME_DOS :{G=f}DOS STR_OSNAME_UNIX :{G=f}Unix STR_OSNAME_OSX :{G=f}OS{NBSP}X STR_OSNAME_HAIKU :{G=f}Haiku @@ -2337,7 +2341,7 @@ STR_NETWORK_CHAT_ALL :[모두] {STRIN STR_NETWORK_CHAT_OSKTITLE :{BLACK}채팅 메시지를 입력하세요. # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}네트워크 장치를 찾을수 없거나 게임 자체가 네트워크를 사용할 수 없는 버전으로 컴파일되었습니다. +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}사용할 수 있는 네트워크 장치가 없습니다. STR_NETWORK_ERROR_NOSERVER :{WHITE}네트워크 게임이 존재하지 않습니다. STR_NETWORK_ERROR_NOCONNECTION :{WHITE}서버가 요청을 받지 않습니다. STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}NewGRF이 맞지 않아서 연결할 수 없습니다 @@ -3515,7 +3519,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :요청한 GRF STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING}(은)는 {STRING} 때문에 사용할 수 없습니다 STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :유효하지 않은/알 수 없는 스프라이트 구조 유형 (스프라이트 {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :속성값 목록에 너무 많은 요소가 있음 (스프라이트 {3:NUM}, 속성 {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :유효하지 않은 산업 생산 콜백 (스프라이트 {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :유효하지 않은 산업 생산 콜백 (스프라이트 {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}경고! @@ -3547,6 +3551,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}{1:ENGINE}(을)를 만들기 이전과 이후의 화물/개조 정보가 현재의 구매 목록과 다릅니다. 이 경우 자동 교체시 열차 개조에 실패할 수도 있습니다. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' 때문에 결과물 콜백 과정에서 무한 루프가 발생하고 있습니다. STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}콜백 함수({1:HEX})가 알 수 없거나 잘못된 결과 값({2:HEX})을 반환했습니다. +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' - 생산 콜백 함수의 {2:HEX}에서 잘못된 화물 종류를 반환했습니다. STR_NEWGRF_TOO_MANY_STRINGS :{WHITE}NewGRF에서 할당 가능한 문자열 ID 개수보다 많은 문자열을 사용하고 있습니다. STR_NEWGRF_TOO_MANY_STRINGS_DETAIL :{WHITE}몇몇 이름이나 텍스트가 잘못된 문자열을 표시할 수 있습니다. NewGRF의 개수를 줄이십시오. @@ -4101,12 +4106,6 @@ STR_GROUP_CREATE_TOOLTIP :{BLACK}그룹 STR_GROUP_DELETE_TOOLTIP :{BLACK}선택한 그룹 삭제 STR_GROUP_RENAME_TOOLTIP :{BLACK}선택한 그룹 이름 바꾸기 STR_GROUP_LIVERY_TOOLTIP :{BLACK}선택한 그룹의 차량 색상을 변경합니다. -STR_GROUP_COLLAPSE :{BLACK}접기 -STR_GROUP_EXPAND :{BLACK}펼치기 -STR_GROUP_EXPAND_ALL :{BLACK}모두 펼치기 -STR_GROUP_COLLAPSE_ALL :{BLACK}모두 접기 -STR_GROUP_COLLAPSE_TOOLTIP :{BLACK}선택한 그룹을 접으려면 클릭하십시오. -STR_GROUP_EXPAND_TOOLTIP :{BLACK}선택한 그룹을 펼치려면 클릭하십시오. STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}클릭하여 전체 자동 교체로부터 이 그룹을 보호합니다. STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}그룹 삭제 @@ -4171,11 +4170,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}차량 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}선박 구입 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}항공기 구입 + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}선택된 차량을 구입합니다. SHIFT+클릭으로 예상 구입 가격을 볼 수 있습니다. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}선택한 차량을 구입합니다. Shift+클릭하면 예상 구입 비용을 볼 수 있습니다. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}선택한 선박을 구입합니다. SHIFT+클릭으로 예상 구입 비용을 볼 수 있습니다. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}선택한 항공기를 구입합니다. SHIFT+클릭으로 예상 구입 비용을 볼 수 있습니다. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}이름 STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}이름 지정 STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}이름 지정 diff --git a/src/lang/latin.txt b/src/lang/latin.txt index 08fc44b6ed..3e3f873729 100644 --- a/src/lang/latin.txt +++ b/src/lang/latin.txt @@ -377,6 +377,8 @@ STR_COLOUR_ORANGE :Fulvus STR_COLOUR_BROWN :Aquilus STR_COLOUR_GREY :Canus STR_COLOUR_WHITE :Albus +STR_COLOUR_RANDOM :Fortuitus +STR_COLOUR_DEFAULT :Solitus # Units used in OpenTTD STR_UNITS_VELOCITY_IMPERIAL :{COMMA}{NBSP}mph @@ -652,6 +654,7 @@ STR_TOOLBAR_SOUND_MUSIC :Sonus musicave ############ range for message menu starts STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Monstrare nuntium novissimum STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Historia nuntiorum +STR_NEWS_MENU_DELETE_ALL_MESSAGES :Delere omnia nuntia ############ range ends here ############ range for about menu starts @@ -1114,6 +1117,7 @@ STR_GAME_OPTIONS_CURRENCY_ZAR :Randum Africae STR_GAME_OPTIONS_CURRENCY_CUSTOM :Propria... STR_GAME_OPTIONS_CURRENCY_GEL :Lari Georgiana (GEL) STR_GAME_OPTIONS_CURRENCY_IRR :Regalis Iranica (IRR) +STR_GAME_OPTIONS_CURRENCY_RUB :Novus Rubelus Russicus (RUB) ############ end of currency region STR_GAME_OPTIONS_ROAD_VEHICLES_FRAME :{BLACK}Vehicula Viaria @@ -1376,8 +1380,8 @@ STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS_HELPTEXT :Arduitas tegula STR_CONFIG_SETTING_PERCENTAGE :{COMMA}% STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS :Arduitas clivorum vehiculis viariis: {STRING} STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT :Arduitas tegulae clivosae vehiculo viario. Arduitate maiore, difficultas ascendendi maior est vehiculis -STR_CONFIG_SETTING_FORBID_90_DEG :Vetare tramina et naves cursum flectere 90°: {STRING} -STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :Tramina possunt cursum flectere in astariis aut 45° (diagonale deinde horizontale/verticale) aut 90° (horizontale deinde verticale); quoque naves possunt cursum 90° aut 45° cursum flectere. Hac electa, tantum 45° licet +STR_CONFIG_SETTING_FORBID_90_DEG :Vetare traminum cursum flectere 90°: {STRING} +STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :Tramina possunt cursum flectere in astariis aut 45° (diagonale deinde horizontale/verticale) aut 90° (horizontale deinde verticale). Hac electa, tantum 45° licet. STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS :Sinere stationes iungi quae non contigua sunt: {STRING} STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT :Sinere partes stationi addere quae non prorsus contigua sunt. Necesse est Ctrl premere dum novae partes adduntur. STR_CONFIG_SETTING_INFLATION :Inflatio: {STRING} @@ -1433,8 +1437,8 @@ STR_CONFIG_SETTING_PLANE_SPEED :Multiplicator v STR_CONFIG_SETTING_PLANE_SPEED_HELPTEXT :Eligere si aeroplana eant lentius quam alia vehicula, ut reditus aeroplanorum minuatur STR_CONFIG_SETTING_PLANE_SPEED_VALUE :1 / {COMMA} STR_CONFIG_SETTING_PLANE_CRASHES :Calamitates aeroplanicae accidunt: {STRING} -STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Eligere crebritatem calamitatum aeroplanicarum -STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Numquam +STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Eligere crebritatem calamitatum aeroplanicarum.{}* Aeroplana magna tamen semper corruere possunt si aeroportui parvo appellant. +STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Numquam* STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :Raro STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :Mediocriter STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Sinere stationes viarias pervias esse in viis oppidorum: {STRING} @@ -1884,7 +1888,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Partiti STR_CONFIG_SETTING_AI :{ORANGE}Competitores STR_CONFIG_SETTING_AI_NPC :{ORANGE}Lusores computatrales -STR_CONFIG_SETTING_PATHFINDER_OPF :Originale STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Commendatum) @@ -1968,7 +1971,6 @@ STR_QUIT_NO :{BLACK}Non # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2000,6 +2002,7 @@ STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Mutare a STR_CHEAT_SETUP_PROD :{LTBLUE}Sinere mutare productiones industriarum: {ORANGE}{STRING} # Livery window +STR_LIVERY_CAPTION :{WHITE}{COMPANY} Schema Coloris STR_LIVERY_GENERAL_TOOLTIP :{BLACK}Monstrare schemata coloris generalia STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Monstrare schemata coloris traminum @@ -2304,7 +2307,7 @@ STR_NETWORK_CHAT_ALL :[Omnibus] {STRI STR_NETWORK_CHAT_OSKTITLE :{BLACK}Inscribere nuntium ad retis colloquium # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nullae res retis inventae vel compilata sine ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Nullae res retis inventae STR_NETWORK_ERROR_NOSERVER :{WHITE}Nulli ludi in rete inventi STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Nulla responsa a servatro STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Non potest iungere propter NewGRF imparia @@ -2570,9 +2573,9 @@ STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP :{BLACK}Signale STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP :{BLACK}Signale Itineris (electricum){}Signale itineris sinit plura tramina inire intra signalia eodem tempore, si tramen potest reservare iter ad destinatum tutum. Signalia itineris usitata possunt transiri a tergo STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP :{BLACK}Signale Itineris Unius Cursus (electricum){}Signale itineris sinit plura tramina inire intra signalia eodem tempore, si tramen potest reservare iter ad destinatum tutum. Signalia itineris unius cursus non possunt transiri a tergo STR_BUILD_SIGNAL_CONVERT_TOOLTIP :{BLACK}Mutare Signalia{}Electa, pressio in signale facit ut mutetur in novum typum electum. Ctrl+Preme ut signale mutetur inter semaphoricum et electricum. Shift mutat inter mutationem et aestimationem monstrandam -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP :{BLACK}Densitas signalia trahendi -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP :{BLACK}Minuere densitatem signalia trahendi -STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Augere densitatem signalia trahendi +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP :{BLACK}Intervallum signalia trahendi +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP :{BLACK}Minuere intervallum signalia trahendi +STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Augere intervallum signalia trahendi # Bridge selection window STR_SELECT_RAIL_BRIDGE_CAPTION :{WHITE}Eligere Pontem Ferriviarium @@ -2892,7 +2895,7 @@ STR_LAI_OBJECT_DESCRIPTION_COMPANY_OWNED_LAND :Terra societati STR_ABOUT_OPENTTD :{WHITE}De OpenTTD STR_ABOUT_ORIGINAL_COPYRIGHT :{BLACK}Privilegium impressorium originale {COPYRIGHT} MCMXCV Chris Sawyer, Omnia proprietatis iura reservantur STR_ABOUT_VERSION :{BLACK}OpenTTD editio {REV} -STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} MMII-MMXVII Manus OpenTTD +STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} MMII-MMXIX Manus OpenTTD # Framerate display window ############ Leave those lines in this order!! @@ -3193,6 +3196,7 @@ STR_TOWN_POPULATION :{BLACK}Incolae STR_TOWN_VIEW_TOWN_CAPTION :{WHITE}{TOWN} STR_TOWN_VIEW_CITY_CAPTION :{WHITE}{TOWN} (Urbs) STR_TOWN_VIEW_POPULATION_HOUSES :{BLACK}Incolae: {ORANGE}{COMMA}{BLACK} Aedificia: {ORANGE}{COMMA} +STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX :{BLACK}{CARGO_LIST} mensis prioris: {ORANGE}{COMMA}{BLACK} max: {ORANGE}{COMMA} STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH :{BLACK}Onera mandata ad oppidum crescendum: STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL :{ORANGE}{STRING}{RED} mandatur STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{ORANGE}{STRING}{BLACK} hieme mandatur @@ -3245,6 +3249,7 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{YELLOW}Largiri # Goal window STR_GOALS_CAPTION :{WHITE}{COMPANY} Proposita STR_GOALS_SPECTATOR_CAPTION :{WHITE}Proposita Universalia +STR_GOALS_SPECTATOR :Proposita universalia STR_GOALS_GLOBAL_TITLE :{BLACK}Proposita universalia: STR_GOALS_TEXT :{ORANGE}{STRING} STR_GOALS_NONE :{ORANGE}- Nullae - @@ -3556,6 +3561,7 @@ STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP :{BLACK}Greges - STR_GROUP_CREATE_TOOLTIP :{BLACK}Preme ut grex creatur STR_GROUP_DELETE_TOOLTIP :{BLACK}Delere gregem electam STR_GROUP_RENAME_TOOLTIP :{BLACK}Renominare gregem electam +STR_GROUP_LIVERY_TOOLTIP :{BLACK}Mutare schema coloris gregis electi STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}Preme ut vehicula huius gregis custodiantur contra autocommutationem universalem STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}Gregem Delere @@ -3614,11 +3620,15 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Emere Ve STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Emere Navem STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Emere Aeroplanum +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Emere reficereque vehiculum +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Emere reficereque aeroplanum + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Emere vehiculum ferriviarium electum. Shift+Preme ut pretium monstretur sine emptione STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Emere vehiculum viarium electum. Shift+Preme ut pretium monstretur sine emptione STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Emere navem electam. Shift+Preme ut pretium monstretur sine emptione STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Emere aeroplanum electum. Shift+Preme ut pretium monstretur sine emptione + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renominare STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renominare STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renominare diff --git a/src/lang/latvian.txt b/src/lang/latvian.txt index edabacbb0b..8b0996aedb 100644 --- a/src/lang/latvian.txt +++ b/src/lang/latvian.txt @@ -1632,7 +1632,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Kravu s STR_CONFIG_SETTING_AI :{ORANGE}Sāncenši STR_CONFIG_SETTING_AI_NPC :{ORANGE}Nespēlētāju tēli (datora vadīti) -STR_CONFIG_SETTING_PATHFINDER_OPF :Sākotnējais STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(ieteicamais) @@ -1714,7 +1713,6 @@ STR_QUIT_NO :{BLACK}Nē # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3332,11 +3330,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Pirkt au STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Pirkt kuģi STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Pirkt lidaparātu + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkt atzīmēto vilciena vagonu. Shift+klikšķis rāda izmaksu novērtējumu, neveicot pirkumu STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkt atzīmēto transportlīdzekli. Shift+klikšķis rāda izmaksu novērtējumu, neveicot pirkumu STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkt atzīmēto kuģi. Shift+klikšķis rāda izmaksu novērtējumu, neveicot pirkumu STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkt izvēlēto lidaparātu. Shift+klikšķis rāda izmaksu novērtējumu, neveicot pirkumu + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Pārdēvēt STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Pārdēvēt STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Pārdēvēt diff --git a/src/lang/lithuanian.txt b/src/lang/lithuanian.txt index e0490f9334..69016c70d4 100644 --- a/src/lang/lithuanian.txt +++ b/src/lang/lithuanian.txt @@ -1903,7 +1903,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Krovini STR_CONFIG_SETTING_AI :{ORANGE}Konkurentai STR_CONFIG_SETTING_AI_NPC :{ORANGE}Kompiuterio žaidėjai -STR_CONFIG_SETTING_PATHFINDER_OPF :Originalus STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Rekomenduojama) @@ -1986,7 +1985,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3607,11 +3605,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Pirkti STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Pirkti STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Pirkti + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkti pažymėtą lokomotyvą ir/ar vagonus. Spragtelėjus laikant nuspaustą Shift klavišą, bus parodyta pirkinio kaina nieko realiai nenuperkant STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkti pažymėtą automobilį. Spragtelėjus laikant nuspaustą Shift klavišą, bus parodyta pirkinio kaina nieko realiai nenuperkant STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkti pažymėtą laivą. Spragtelėjus laikant nuspaustą Shift klavišą, bus parodyta pirkinio kaina nieko realiai nenuperkant STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Pirkti pažymėtą lėktuvą. Spragtelėjus laikant nuspaustą Shift klavišą, bus parodyta pirkinio kaina nieko realiai nenuperkant + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Pervardinti STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Pervardinti STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Pervardinti diff --git a/src/lang/luxembourgish.txt b/src/lang/luxembourgish.txt index 9c8754470f..25f4750ccc 100644 --- a/src/lang/luxembourgish.txt +++ b/src/lang/luxembourgish.txt @@ -189,6 +189,7 @@ STR_COLOUR_ORANGE :Orange STR_COLOUR_BROWN :Brong STR_COLOUR_GREY :Gro STR_COLOUR_WHITE :Wäiss +STR_COLOUR_RANDOM :Zoufälleg # Units used in OpenTTD STR_UNITS_VELOCITY_IMPERIAL :{COMMA}{NBSP}mph @@ -475,6 +476,7 @@ STR_ABOUT_MENU_SCREENSHOT :Screenshot (Ctr STR_ABOUT_MENU_ZOOMIN_SCREENSHOT :Voll eragezoomte Screenshot STR_ABOUT_MENU_DEFAULTZOOM_SCREENSHOT :Standard Zoom Screenshot STR_ABOUT_MENU_GIANT_SCREENSHOT :Screenshot vun der ganzer Kaart +STR_ABOUT_MENU_SHOW_FRAMERATE :Biller pro Sekonn uweisen STR_ABOUT_MENU_ABOUT_OPENTTD :Iwwert 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite Alignéirer STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Zeechen-Boxen un/aus @@ -650,6 +652,7 @@ STR_MUSIC_RULER_MARKER :{TINY_FONT}{BLA STR_MUSIC_TRACK_NONE :{TINY_FONT}{DKGREEN}-- STR_MUSIC_TRACK_DIGIT :{TINY_FONT}{DKGREEN}{ZEROFILL_NUM} STR_MUSIC_TITLE_NONE :{TINY_FONT}{DKGREEN}------ +STR_MUSIC_TITLE_NOMUSIC :{TINY_FONT}{DKGREEN}Keng Musik verfügbar STR_MUSIC_TITLE_NAME :{TINY_FONT}{DKGREEN}"{STRING}" STR_MUSIC_TRACK :{TINY_FONT}{BLACK}Nummer STR_MUSIC_XTITLE :{TINY_FONT}{BLACK}Titel @@ -674,7 +677,9 @@ STR_PLAYLIST_TRACK_NAME :{TINY_FONT}{LTB STR_PLAYLIST_TRACK_INDEX :{TINY_FONT}{BLACK}Lidder Index STR_PLAYLIST_PROGRAM :{TINY_FONT}{BLACK}Programm - '{STRING}' STR_PLAYLIST_CLEAR :{TINY_FONT}{BLACK}Läschen +STR_PLAYLIST_CHANGE_SET :{BLACK}Set wiesselen STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1 :{BLACK}De gewielte Program reseten (nëmmen Benotzerdéf.1 oder Benotzerdéf.2) +STR_PLAYLIST_TOOLTIP_CHANGE_SET :{BLACK}Wiessel d'Musikselektioun op en anert installéiert Set STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Klick op d'Lidd fir et zum aktuellen Program dobäi zesetzen (nëmme Benotzerdéf.1 oder Benotzerdéf.2) STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Klick op d'Lidd fir et vum aktuellen Programm ze läschen (Benotzerdefinéiert 1 an 2 nëmmen) @@ -810,6 +815,7 @@ STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLAC STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}(Manager) STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{STRING} huet Kontruktioun vun der Stad {TOWN} gesponsort! +STR_NEWS_NEW_TOWN_UNSPONSORED :{BLACK}{BIG_FONT}En neit Duerf mam Numm {TOWN} gouf gegrënnt! STR_NEWS_INDUSTRY_CONSTRUCTION :{BIG_FONT}{BLACK}{STRING} gëtt bei {TOWN} gebaut! STR_NEWS_INDUSTRY_PLANTED :{BIG_FONT}{BLACK}{STRING} gëtt bei {TOWN} geplanzt! @@ -985,6 +991,8 @@ STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Duebel STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Véierfach +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL :Normal +STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM :Véierfach STR_GAME_OPTIONS_BASE_GRF :{BLACK}Basis Grafikset STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Wielt de Basis Grafikset dee soll benotzt ginn @@ -1168,6 +1176,7 @@ STR_CONFIG_SETTING_AUTOSLOPE :Erlaabt Landfor STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Erlaabt Terraintransformatioun ënnert Gebaier an Schinnen ouni dës ewechzehuelen STR_CONFIG_SETTING_CATCHMENT :Erlaabt méi realistësch Einzugsberäicher: {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Statiounen a Fluchhäfen hunn verschidde grouss Einzugsberäicher +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Gare vun der Firma kënnen Industrie beliwwere mat neutrale Statiounen: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE :Erlaabt d'Ewechhuelen vu méi Stroossen, Brécken, etc. vun der Stad: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Mach et méi einfach fir Infrastruktur oder Gebaier ewechzehuelen déi enger Stad gehéiren STR_CONFIG_SETTING_TRAIN_LENGTH :Maximal Längt vun Zich: {STRING} @@ -1337,6 +1346,7 @@ STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_HELPTEXT :Faarf vum Terra STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_GREEN :Gréng STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_DARK_GREEN :Donkelgréng STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_VIOLET :Mof +STR_CONFIG_SETTING_SCROLLMODE_LMB :Kaart mat der lénker Maustast bewegen STR_CONFIG_SETTING_SMOOTH_SCROLLING :Feine Scrolling: {STRING} STR_CONFIG_SETTING_SMOOTH_SCROLLING_HELPTEXT :Kontrolléiert wéi d'Haptusiicht op eng bestëmmten Positioun scrollt, wann een op déi kléng Kaart klickt oder en Befehl fir ob en spezifescht Objet ze scrollen gëtt. Wann ugeschalt, gëtt bis dohin gescrollt, wann ausgeschalt, spréngt d'Vue op den Zielobjet STR_CONFIG_SETTING_MEASURE_TOOLTIP :Weis en Mooss-Tooltip wann verschidde Bau-Tools benotzt ginn: {STRING} @@ -1559,6 +1569,8 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Wann dës Astel STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Verbueden STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Erlaabt STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Erlaabt, custom Stad-Layout +STR_CONFIG_SETTING_TOWN_CARGOGENMODE :Duerfwuerengeneratioun: {STRING} +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Linear STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Bamplazéirung: {STRING} STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Kontrolléiert zoufälleg Optauche vu Beem während dem Spill. Dëst kann Industrie beaflossen, déi op d'Wuessen vu Beem ugewisen sinn @@ -1579,7 +1591,7 @@ STR_CONFIG_SETTING_SOFT_LIMIT_HELPTEXT :Unzuel un net-g STR_CONFIG_SETTING_SOFT_LIMIT_VALUE :{COMMA} STR_CONFIG_SETTING_SOFT_LIMIT_DISABLED :ausgeschalt STR_CONFIG_SETTING_ZOOM_MIN :Maximalen Ranzoom Level: {STRING} -STR_CONFIG_SETTING_ZOOM_MIN_HELPTEXT :Maximal Ranzoomstuf fir Usiichtsfënsteren. Et gëtt méi Späicher gebraucht wann d'Stufen ze grouss ginn +STR_CONFIG_SETTING_ZOOM_MIN_HELPTEXT :Maximal Razoomstuf fir Usiichtsfënsteren. Et gëtt méi Späicher gebraucht wann d'Stufen ze grouss ginn STR_CONFIG_SETTING_ZOOM_MAX :Maximalen Rauszoom Level: {STRING} STR_CONFIG_SETTING_ZOOM_MAX_HELPTEXT :Maximal Rauszoom-Stuf fir Usiichtsfënsteren. Méi grouss Rauszoom-Stufen kënnen Ruckeler verursaachen STR_CONFIG_SETTING_ZOOM_LVL_MIN :4x @@ -1686,7 +1698,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Wuereve STR_CONFIG_SETTING_AI :{ORANGE}Géigner STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computerspiller -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(recommandéiert) @@ -1770,7 +1781,6 @@ STR_QUIT_NO :{BLACK}Nee # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -1802,6 +1812,7 @@ STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Wiessel STR_CHEAT_SETUP_PROD :{LTBLUE}Erlaabt d'ännere vun de Produktiounswäerter: {ORANGE}{STRING} # Livery window +STR_LIVERY_CAPTION :{WHITE}{COMPANY} - Neie Faarfschema STR_LIVERY_GENERAL_TOOLTIP :{BLACK}Weis generell Faarfschemen STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Weis Zuch Faarfschemen @@ -2682,9 +2693,22 @@ STR_ABOUT_VERSION :{BLACK}OpenTTD STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-2019 D'OpenTTD team # Framerate display window +STR_FRAMERATE_AVERAGE :{WHITE}Mëttel +STR_FRAMERATE_MS_GOOD :{LTBLUE}{DECIMAL} ms +STR_FRAMERATE_MS_WARN :{YELLOW}{DECIMAL} ms +STR_FRAMERATE_FPS_GOOD :{LTBLUE}{DECIMAL} Biller/s +STR_FRAMERATE_FPS_BAD :{RED}{DECIMAL} Biller/s +STR_FRAMERATE_GRAPH_SECONDS :{TINY_FONT}{COMMA} s ############ Leave those lines in this order!! +STR_FRAMERATE_GL_ROADVEHS :{BLACK} Stroossegefierer Ticken: +STR_FRAMERATE_GL_LINKGRAPH :{BLACK} Linkgrafik-Verzögerung: +STR_FRAMERATE_DRAWING :{BLACK}Graphikrendering: +STR_FRAMERATE_VIDEO :{BLACK}Video-output: ############ End of leave-in-this-order ############ Leave those lines in this order!! +STR_FRAMETIME_CAPTION_GL_ROADVEHS :Stroossegefierer Ticken +STR_FRAMETIME_CAPTION_GL_SHIPS :Schëffticker +STR_FRAMETIME_CAPTION_SOUND :Soundmixing ############ End of leave-in-this-order @@ -2827,6 +2851,7 @@ STR_NEWGRF_SETTINGS_VERSION :{BLACK}Versioun STR_NEWGRF_SETTINGS_MIN_VERSION :{BLACK}Min. kompatibel Versioun: {SILVER}{NUM} STR_NEWGRF_SETTINGS_MD5SUM :{BLACK}MD5sum: {SILVER}{STRING} STR_NEWGRF_SETTINGS_PALETTE :{BLACK}Palette: {SILVER}{STRING} +STR_NEWGRF_SETTINGS_PALETTE_LEGACY :Legacy (W) STR_NEWGRF_SETTINGS_PARAMETER :{BLACK}Parameter: {SILVER}{STRING} STR_NEWGRF_SETTINGS_NO_INFO :{BLACK}Keng Info verfügbar @@ -2908,6 +2933,7 @@ STR_NEWGRF_ERROR_READ_BOUNDS :Lanscht d'Enn v STR_NEWGRF_ERROR_GRM_FAILED :Ugefroten GRF Ressource net verfügbar (sprite {3:NUM}) STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} gouf ausgeschalt vun {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Invalid/onbekannten Sprite Layout Format (Sprite {3:NUM}) +STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Zevill Elementer an der Eegeschaftewert-Lëscht (Sprite {3:NUM}, Eegeschaft {4:HEX}) # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Opgepasst! @@ -3342,6 +3368,7 @@ STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP :{BLACK}Gruppen STR_GROUP_CREATE_TOOLTIP :{BLACK}Klick fir eng Grupp ze maachen STR_GROUP_DELETE_TOOLTIP :{BLACK}Déi ungewielte Grupp läschen STR_GROUP_RENAME_TOOLTIP :{BLACK}Déi ungewielte Grupp ëmbenennen +STR_GROUP_LIVERY_TOOLTIP :{BLACK}Wiessel d'Faarwschema vun dem ausgewielte Grupp STR_GROUP_REPLACE_PROTECTION_TOOLTIP :{BLACK}Klick fir déi Grupp vum globalen "Autoersetzen" auszeschléissen STR_QUERY_GROUP_DELETE_CAPTION :{WHITE}Grupp läschen @@ -3369,6 +3396,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Nei Schëffer STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Neie Fliger STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Käschten: {GOLD}{CURRENCY_LONG}{BLACK} Gewiicht: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Käschten: {GOLD}{CURRENCY_LONG}{BLACK} (Embaukäschten: {GOLD}{CURRENCY_LONG}{BLACK}) Gewiicht: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Geschw.: {GOLD}{VELOCITY}{BLACK} Kraaft: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Geschw.: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Geschwindegkeet um Ozean: {GOLD}{VELOCITY} @@ -3400,11 +3428,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Gefier k STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Schëff kafen STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Fliger kafen + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Keeft den ungewielten Zuch. Shift+Klick weist ongeféier Käschten ouni Kaf STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Keeft dat ugewielte Stroossegefier. Shift+Klick weist ongeféier Käschten ouni Kaf STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Keeft dat ugewielte Schëff. Shift+Klick weist ongeféier Käschten ouni Kaf STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Keeft den ungewielte Fliger. Shift+Klick weist ongeféier Käschten ouni Kaf + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Ëmbenennen STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Ëmbenennen STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Ëmbenennen @@ -4216,6 +4246,7 @@ STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... d'St STR_ERROR_DRIVE_THROUGH_DIRECTION :{WHITE}... Strooss geet an dei falsch Richtung STR_ERROR_DRIVE_THROUGH_CORNER :{WHITE}... Duerchfahrtstops kënnen keng Kéiren hunn STR_ERROR_DRIVE_THROUGH_JUNCTION :{WHITE}... Duerchfahrtstops kënnen keng Kräizungen hunn +STR_ERROR_DRIVE_THROUGH_ON_ONEWAY_ROAD :{WHITE}... Einbahnstrooss oder blockéiert # Station destruction related errors STR_ERROR_CAN_T_REMOVE_PART_OF_STATION :{WHITE}Kann den Deel vun der Gare net ofrappen... @@ -4467,6 +4498,7 @@ STR_BASESOUNDS_DOS_DESCRIPTION :Original Transp STR_BASESOUNDS_WIN_DESCRIPTION :Original Transport Tycoon Deluxe Windows Editioun Sound. STR_BASESOUNDS_NONE_DESCRIPTION :E Soundpack ouni iergendee Sound. STR_BASEMUSIC_WIN_DESCRIPTION :Original Transport Tycoon Deluxe Windows Editioun Musik. +STR_BASEMUSIC_TTO_DESCRIPTION :Original Transport Tycoon (Original/World Editor) DOS Editioun-Musik. STR_BASEMUSIC_NONE_DESCRIPTION :E Musikpack ouni aktuell Musik. ##id 0x2000 diff --git a/src/lang/malay.txt b/src/lang/malay.txt index 5692526ce8..d9ce1ef0b1 100644 --- a/src/lang/malay.txt +++ b/src/lang/malay.txt @@ -1450,7 +1450,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Industr STR_CONFIG_SETTING_AI :{ORANGE}Pesaing STR_CONFIG_SETTING_AI_NPC :{ORANGE}Pemain komputer -STR_CONFIG_SETTING_PATHFINDER_OPF :Asal STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Disyorkan) @@ -1528,7 +1527,6 @@ STR_QUIT_NO :{BLACK}Tidak # Supported OSes STR_OSNAME_WINDOWS :Tetingkap -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3088,11 +3086,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Beli Ken STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Beli Kapal STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Beli Pesawat + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Beli gerabak keretapi yang terpilih. Shift+Klik menunjukkan anggaran kos tanpa membeli STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kenderaan jalanraya yang terpilih. Shift+Klik menunjukkan anggaran kos tanpa membeli STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kapal yang terpilih. Shift+Klik menunjukkan anggaran kos tanpa membeli STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Beli pesawat yang terpilih. Shift+Klik menunjukkan anggaran kos tanpa membeli + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Namakan semula STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Namakan semula STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Namakan semula diff --git a/src/lang/norwegian_bokmal.txt b/src/lang/norwegian_bokmal.txt index d3ee3f14fe..35aa97583b 100644 --- a/src/lang/norwegian_bokmal.txt +++ b/src/lang/norwegian_bokmal.txt @@ -1719,7 +1719,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Gods-di STR_CONFIG_SETTING_AI :{ORANGE}Motstandere STR_CONFIG_SETTING_AI_NPC :{ORANGE}Datamaskinstyrte spillere -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Anbefalt) @@ -1803,7 +1802,6 @@ STR_QUIT_NO :{BLACK}Nei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2142,7 +2140,7 @@ STR_NETWORK_CHAT_ALL :[Alle] {STRING} STR_NETWORK_CHAT_OSKTITLE :{BLACK}Skriv inn tekst for nettverkssamtale # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Ingen nettverksadaptere funnet eller kompilert uten ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Ingen nettverksadapter funnet STR_NETWORK_ERROR_NOSERVER :{WHITE}Kunne ikke finne noen nettverksspill STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Tjeneren svarte ikke på forespørselen STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Kunne ikke koble til pga. ulike versjoner av NewGRF @@ -3003,7 +3001,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Etterspurte GRF STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} ble deaktivert av {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Ugyldig/ukjent sprite layout-format (figur {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :For mange elementer i fortegnelse over eiendomsverdier (sprite {3:NUM}, property {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ugyldig industriprodukjson callback (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ugyldig industriprodukjson callback (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Advarsel! @@ -3035,6 +3033,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Vare-/ombyggingsinformasjon for '{1:ENGINE}' er forskjellig fra kjøpelisten etter konstruksjonen. Dette kan resultere i at autofornying ikke fungerer på riktig måte. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' forårsaket en uendelig løkke i produksjonstilbakekallet. STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Tilbakekall {1:HEX} rapporterte ukjent/ugyldig resultat {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' ugyldig varetype i produksjonscallback at {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3473,6 +3472,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Nye skip STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Nye luftfartøy STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG}{BLACK} Vekt: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG}{BLACK} (Ombyggingskostnad: {GOLD}{CURRENCY_LONG}{BLACK}) Vekt: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Hastighet: {GOLD}{VELOCITY}{BLACK} Kraft: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Hastighet: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Hastighet på havet: {GOLD}{VELOCITY} @@ -3483,8 +3483,10 @@ STR_PURCHASE_INFO_REFITTABLE :(ombyggbart) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Designet: {GOLD}{NUM}{BLACK} Levetid: {GOLD}{COMMA} år STR_PURCHASE_INFO_RELIABILITY :{BLACK}Maks pålitelighet: {GOLD}{COMMA}{NBSP}% STR_PURCHASE_INFO_COST :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG}{BLACK} (Ombyggingskostnad: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Vekt: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG}{BLACK} Hastighet: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Kostnad: {GOLD}{CURRENCY_LONG}{BLACK} (Ombyggingskostnad: {GOLD}{CURRENCY_LONG}{BLACK}) Hastighet: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Kapasitet: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Lokomotivvogner: {GOLD}+{POWER}{BLACK} Vekt: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Kan bygges om til: {GOLD}{STRING} @@ -3505,11 +3507,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kjøp kj STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kjøp skip STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kjøp luftfartøy +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Kjøp og bygg om kjøretøy +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Kjøp og bygg om kjøretøy +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Kjøp og bygg om skip +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Kjøp og bygg om luftfartøy + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kjøp det merkede tog/vogn. Shift+klikk viser estimert kostnad STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kjøp det merkede kjøretøy. Shift+klikk viser estimert kostnad STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kjøp det merkede skip. Shift+klikk viser estimert kostnad STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kjøp det merkede luftfartøy. Shift+klikk viser estimert kostnad +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Kjøp og bygg om merket tog/vogn. Shift+klikk viser anslått kostnad uten å kjøpe. +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Kjøp og bygg om det merkede kjøretøyet. Shift+klikk viser anslått kostnad uten å kjøpe. +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Kjøp og bygg om det merkede skipet. Shift+klikk viser anslått kostnad uten å kjøpe. +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Kjøp og bygg om det merkede luftfartøyet. Shift+klikk viser anslått kostnad uten å kjøpe. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Endre navn STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Endre navn STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Endre navn diff --git a/src/lang/norwegian_nynorsk.txt b/src/lang/norwegian_nynorsk.txt index fb12ae9a2f..f3ae43efa4 100644 --- a/src/lang/norwegian_nynorsk.txt +++ b/src/lang/norwegian_nynorsk.txt @@ -1607,7 +1607,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Varefor STR_CONFIG_SETTING_AI :{ORANGE}Motstandarar STR_CONFIG_SETTING_AI_NPC :{ORANGE}Datamaskinspelarar -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Anbefalt) @@ -1690,7 +1689,6 @@ STR_QUIT_NO :{BLACK}Nei # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3307,11 +3305,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kjøp k STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Bygg skip STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Bygg luftfartøy + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Bygg den valde farkosten. Skift-klikk viser prisoverslag utan å kjøpe. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Bygg det valde køyretøyet. Skift-klikk viser prisoverslag utan å kjøpe. STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Bygg det valde skipet. Skift-klikk viser prisoverslag utan å kjøpe. STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Bygg det valde luftfartøyet. Skift-klikk viser prisoverslag utan å kjøpe. + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Gje nytt namn STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Endre namn STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Endre namn diff --git a/src/lang/polish.txt b/src/lang/polish.txt index ebf5e4cf3e..7435ceef71 100644 --- a/src/lang/polish.txt +++ b/src/lang/polish.txt @@ -2084,7 +2084,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Dystryb STR_CONFIG_SETTING_AI :{ORANGE}Rywale STR_CONFIG_SETTING_AI_NPC :{ORANGE}Gracze komputerowi -STR_CONFIG_SETTING_PATHFINDER_OPF :Oryginalne STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Zalecane) @@ -2168,7 +2167,6 @@ STR_QUIT_NO :{BLACK}Nie # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3840,11 +3838,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kup poja STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kup statek STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kup samolot + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kup zaznaczony pociąg. Shift+klik pokazuje szacunkowy koszt bez dokonania zakupu STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kup zaznaczony pojazd drogowy. Shift+klik pokazuje szacunkowy koszt bez dokonania zakupu STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kup zaznaczony statek. Shift+klik pokazuje szacunkowy koszt bez dokonania zakupu STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kup zaznaczony samolot. Shift+klik pokazuje szacunkowy koszt bez dokonania zakupu + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Zmień nazwę STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Zmień nazwę STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Zmień nazwę diff --git a/src/lang/portuguese.txt b/src/lang/portuguese.txt index ac2403022e..782b86cc73 100644 --- a/src/lang/portuguese.txt +++ b/src/lang/portuguese.txt @@ -321,7 +321,7 @@ STR_TOOLBAR_TOOLTIP_FORWARD :{BLACK}Aumentar STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Opções STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Guardar jogo, abandonar jogo, sair STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Mostrar mapa -STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY :{BLACK}Mostrar lista de cidades +STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY :{BLACK}Mostrar lista de localidades STR_TOOLBAR_TOOLTIP_DISPLAY_SUBSIDIES :{BLACK}Mostrar subsídios STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_STATIONS :{BLACK}Mostrar lista de estações da empresa STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_FINANCES :{BLACK}Mostrar informações financeiras da empresa @@ -354,9 +354,9 @@ STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR :{YELLOW}Editor STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD :{BLACK}Retroceder data de início 1 ano STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD :{BLACK}Avançar data de início 1 ano STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE :{BLACK}Clique para escolher o ano inicial -STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY :{BLACK}Mostrar mapa, lista de cidades +STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY :{BLACK}Mostrar mapa, lista de localidades STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION :{BLACK}Gerar terreno -STR_SCENEDIT_TOOLBAR_TOWN_GENERATION :{BLACK}Gerar cidades +STR_SCENEDIT_TOOLBAR_TOWN_GENERATION :{BLACK}Gerar localidades STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION :{BLACK}Gerar indústrias STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION :{BLACK}Construir estradas STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Plantar árvores. Shift alterna contruir/mostrar custo estimado @@ -379,7 +379,7 @@ STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE :Definições STR_SETTINGS_MENU_SCRIPT_SETTINGS :Definições de IA / Scripts de Jogo STR_SETTINGS_MENU_NEWGRF_SETTINGS :Definições NewGRF STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS :Opções de Transparência -STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED :Mostrar nomes de cidades +STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED :Mostrar nomes de localidades STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED :Mostrar nomes de estações STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED :Mostrar nomes dos pontos de passagem STR_SETTINGS_MENU_SIGNS_DISPLAYED :Mostrar sinais @@ -405,8 +405,8 @@ STR_MAP_MENU_LINGRAPH_LEGEND :Legenda de flux STR_MAP_MENU_SIGN_LIST :Lista de sinais ############ range for town menu starts -STR_TOWN_MENU_TOWN_DIRECTORY :Lista de cidades -STR_TOWN_MENU_FOUND_TOWN :Fundar cidade +STR_TOWN_MENU_TOWN_DIRECTORY :Lista de localidades +STR_TOWN_MENU_FOUND_TOWN :Fundar localidade ############ range ends here ############ range for subsidies menu starts @@ -748,12 +748,12 @@ STR_SMALLMAP_LEGENDA_TREES :{TINY_FONT}{BLA STR_SMALLMAP_LEGENDA_ROCKS :{TINY_FONT}{BLACK}Rochas STR_SMALLMAP_LEGENDA_WATER :{TINY_FONT}{BLACK}Água STR_SMALLMAP_LEGENDA_NO_OWNER :{TINY_FONT}{BLACK}Sem Proprietário -STR_SMALLMAP_LEGENDA_TOWNS :{TINY_FONT}{BLACK}Cidades +STR_SMALLMAP_LEGENDA_TOWNS :{TINY_FONT}{BLACK}Localidades STR_SMALLMAP_LEGENDA_INDUSTRIES :{TINY_FONT}{BLACK}Indústrias STR_SMALLMAP_LEGENDA_DESERT :{TINY_FONT}{BLACK}Deserto STR_SMALLMAP_LEGENDA_SNOW :{TINY_FONT}{BLACK}Neve -STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF :{BLACK}Mostrar/ocultar nomes das cidades no mapa +STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF :{BLACK}Mostrar/ocultar nomes das localidades no mapa STR_SMALLMAP_CENTER :{BLACK}Centrar o mapa na posição actual STR_SMALLMAP_INDUSTRY :{TINY_FONT}{STRING} ({NUM}) STR_SMALLMAP_LINKSTATS :{TINY_FONT}{STRING} @@ -818,8 +818,8 @@ STR_NEWS_COMPANY_LAUNCH_DESCRIPTION :{BIG_FONT}{BLAC STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLACK}{STRING} foi comprada por {STRING}! STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}(Presidente) -STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{STRING} subsidiou a construção da nova cidade de {TOWN}! -STR_NEWS_NEW_TOWN_UNSPONSORED :{BLACK}{BIG_FONT}Uma nova cidade chamada {TOWN} foi construida! +STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{STRING} subsidiou a construção da nova localidade de {TOWN}! +STR_NEWS_NEW_TOWN_UNSPONSORED :{BLACK}{BIG_FONT}Uma nova localidade chamada {TOWN} foi fundada! STR_NEWS_INDUSTRY_CONSTRUCTION :{BIG_FONT}{BLACK}Nov{G 0 o o a os as} {STRING} em construção em {TOWN}! STR_NEWS_INDUSTRY_PLANTED :{BIG_FONT}{BLACK}Nov{G 0 o o a os as} {STRING} est{G 0 á á á ão ão} a ser plantad{G 0 o o a os as} em {TOWN}! @@ -941,8 +941,8 @@ STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_TOOLTIP :{BLACK}Seleccio STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT :Circular pela esquerda STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT :Circular pela direita -STR_GAME_OPTIONS_TOWN_NAMES_FRAME :{BLACK}Nomes das cidades -STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP :{BLACK}Seleccionar o estilo dos nomes das cidades +STR_GAME_OPTIONS_TOWN_NAMES_FRAME :{BLACK}Nomes das localidades +STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP :{BLACK}Seleccionar o estilo dos nomes das localidades ############ start of townname region STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH :Inglês @@ -1175,7 +1175,7 @@ STR_CONFIG_SETTING_TRAIN_REVERSING :Desabilitar inv STR_CONFIG_SETTING_TRAIN_REVERSING_HELPTEXT :Quando activo, os combóios não podem inverter marcha em estações não-terminais, mesmo se existir um caminho mais curto para o destino seguinte com inversão STR_CONFIG_SETTING_DISASTERS :Desastres: {STRING} STR_CONFIG_SETTING_DISASTERS_HELPTEXT :Activa desastres que podem ocasionalmente bloquear ou destruir veículos ou infraestruturas -STR_CONFIG_SETTING_CITY_APPROVAL :Atitude da do Concelho Municipal em relação a reestruturação de áreas: {STRING} +STR_CONFIG_SETTING_CITY_APPROVAL :Atitude do Concelho Municipal em relação a reestruturação de áreas: {STRING} STR_CONFIG_SETTING_CITY_APPROVAL_HELPTEXT :Escolha quanto ruído e estragos ambientais causados pelas empresas afecta o rating da povoação e futuras acções de construção na área STR_CONFIG_SETTING_MAX_HEIGHTLEVEL :Altura máxima do mapa: {STRING} @@ -1185,8 +1185,10 @@ STR_CONFIG_SETTING_AUTOSLOPE :Permite altera STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Permite alteração de terra sob edifícios e vias sem os remover STR_CONFIG_SETTING_CATCHMENT :Dimensionamento mais realista de áreas de abrangência: {STRING} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Haver diferentes áreas de cobertura para diferentes tipos de estações e aeroportos +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Estações da companhia podem servir industrias equipadas com estações neutras: {STRING} +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Quando activo, industrias com estações incluídas (com as Petrolíferas) podem ser servidas por estações da companhia construídas nas redondezas. Quando inactivo, estas industrias só podem ser servidas pela sua própria estação. Qualquer estação da companhia não poderá servir a industria, nem a estação incluída poder servir outra entidade senão a própria industria STR_CONFIG_SETTING_EXTRADYNAMITE :Permite remover mais estradas, pontes e túneis detidos pela cidade: {STRING} -STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Facilitar a remoçar de edifícios e infraestruturas detidas pela cidade +STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Facilitar a remoçar de edifícios e infraestruturas detidas pela localidade STR_CONFIG_SETTING_TRAIN_LENGTH :Tamanho máximo de comboios: {STRING} STR_CONFIG_SETTING_TRAIN_LENGTH_HELPTEXT :Assignar o tamanho máximo dos comboios STR_CONFIG_SETTING_TILE_LENGTH :{COMMA} quadrado{P 0 "" s} @@ -1201,8 +1203,8 @@ STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS_HELPTEXT :Ângulo de incl STR_CONFIG_SETTING_PERCENTAGE :{COMMA}% STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS :Ângulo de inclínação para veículos rodoviários: {STRING} STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT :Declive de um quadrado inclinado para um veiculo de estrada. Valores mais altos tornam mais difícil de subir. -STR_CONFIG_SETTING_FORBID_90_DEG :Proibir comboios e barcos fazer curvas de 90º: {STRING} -STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :Curvas de 90 graus ocorrem quando uma pista horizontal é directamente seguida por outra vertical num quadrado adjacente, fazendo com que o combóio vire 90 graus quando atravessa a fronteira dos quadrados, ao invés dos habituais 45 graus para outras combinações de pistas. Também se aplica ao raio de curvatura dos navios +STR_CONFIG_SETTING_FORBID_90_DEG :Proibir comboios fazer curvas de 90º: {STRING} +STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :Curvas de 90 graus ocorrem quando uma pista horizontal é directamente seguida por outra vertical num quadrado adjacente, fazendo com que o combóio vire 90 graus quando atravessa a fronteira dos quadrados, ao invés dos habituais 45 graus para outras combinações de pistas. STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS :Permitir juntar estações não adjacentes: {STRING} STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT :Permite adicionar novas partes a uma estação sem tocar nas partes já existentes. Requer pressionar CTRL+click para adicionar as novas partes STR_CONFIG_SETTING_INFLATION :Inflação: {STRING} @@ -1220,8 +1222,8 @@ STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_NORMAL :Como as outras STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :Prospecção STR_CONFIG_SETTING_INDUSTRY_PLATFORM :Área plana à volta das industrias: {STRING} STR_CONFIG_SETTING_INDUSTRY_PLATFORM_HELPTEXT :Quantidade de terreno plano á volta de uma industria. Isto garante que terreno vazio esteja disponível para construir linhas, etc -STR_CONFIG_SETTING_MULTIPINDTOWN :Permitir várias indústrias semelhantes por cidade: {STRING} -STR_CONFIG_SETTING_MULTIPINDTOWN_HELPTEXT :Normalmente, uma cidade não aceita mais do que uma indústria de cada tipo. Com esta configuração, será possível ter várias indústrias do mesmo tipo na mesma cidade +STR_CONFIG_SETTING_MULTIPINDTOWN :Permitir várias indústrias semelhantes por localidade: {STRING} +STR_CONFIG_SETTING_MULTIPINDTOWN_HELPTEXT :Normalmente, uma localidade não aceita mais do que uma indústria de cada tipo. Com esta configuração, será possível ter várias indústrias do mesmo tipo na mesma localidade STR_CONFIG_SETTING_SIGNALSIDE :Mostrar sínais: {STRING} STR_CONFIG_SETTING_SIGNALSIDE_HELPTEXT :Escolha em que lado da via colocar sinais STR_CONFIG_SETTING_SIGNALSIDE_LEFT :Na esquerda @@ -1245,9 +1247,9 @@ STR_CONFIG_SETTING_AUTOSCROLL_EVERY_VIEWPORT :Todos os visual STR_CONFIG_SETTING_BRIBE :Permite o suborno da autoridade local: {STRING} STR_CONFIG_SETTING_BRIBE_HELPTEXT :Permite que as companhias tentem subornar a autoridade local. Se o suborno for descoberto por um inspector, a companhia não poderá construir nessa localidade durante seis meses STR_CONFIG_SETTING_ALLOW_EXCLUSIVE :Permite comprar direitos de transporte em exclusividade: {STRING} -STR_CONFIG_SETTING_ALLOW_EXCLUSIVE_HELPTEXT :Se uma empresa compra direitos exclusivos de transporte para uma cidade, as estações dos concorrentes (passageiros e carga) não receberão cargo durante um ano +STR_CONFIG_SETTING_ALLOW_EXCLUSIVE_HELPTEXT :Se uma empresa compra direitos exclusivos de transporte para uma localidade, as estações dos concorrentes (passageiros e carga) não receberão cargo durante um ano STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS :Permite investir em edifícios: {STRING} -STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS_HELPTEXT :Permite que empresas doem dinheiro às cidades para financiar novas casas +STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS_HELPTEXT :Permite que empresas doem dinheiro às localidades para financiar novas casas STR_CONFIG_SETTING_ALLOW_FUND_ROAD :Permite financiar a reconstrução de estradas locais:{STRING} STR_CONFIG_SETTING_ALLOW_FUND_ROAD_HELPTEXT :Permite que as companhias financiem reparações de estrada para sabotar serviços rodoviários dos oponentes. STR_CONFIG_SETTING_ALLOW_GIVE_MONEY :Permite enviar dinheiro para outras empresas: {STRING} @@ -1258,11 +1260,11 @@ STR_CONFIG_SETTING_PLANE_SPEED :Fator de veloci STR_CONFIG_SETTING_PLANE_SPEED_HELPTEXT :Set the relative speed of planes compared to other vehicle types, to reduce the amount of income of transport by aircraft STR_CONFIG_SETTING_PLANE_SPEED_VALUE :1 / {COMMA} STR_CONFIG_SETTING_PLANE_CRASHES :Número de acidentes de aeronaves: {STRING} -STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Indicar a hipótese da ocorrência de um acidente aéreo -STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Nenhum +STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT :Indicar a hipótese da ocorrência de um acidente aéreo.{}* As aeronaves maiores tem um risco acrescido a despenhar quando aterram em aeroportos pequenos +STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Nenhum* STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :Reduzido STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :Normal -STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Permite estações de passagem em estradas das cidades: {STRING} +STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Permite estações de passagem em estradas das localidades: {STRING} STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Permite construção de paragens drive-through em ruas que são prorpiedade das povoações STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD :Permite estações de passagem em estradas do adversário: {STRING} STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Permite construção de paragens drive-through em ruas que são prorpiedade de outras companhias @@ -1302,13 +1304,13 @@ STR_CONFIG_SETTING_HOVER_DELAY :Mostrar textos STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT :Atraso após o qual os textos de ajuda são mostrados após parar o cursor sobre algum elemento da interface. Alternativamente, os textos de ajuda podem ser mostrados com o botão direito do rato quando este valor está definido como 0 STR_CONFIG_SETTING_HOVER_DELAY_VALUE :Parar o rato por {COMMA} milisegundo{P 0 "" s} STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :Clique com botão direito -STR_CONFIG_SETTING_POPULATION_IN_LABEL :Mostra população da cidade na janela da cidade: {STRING} +STR_CONFIG_SETTING_POPULATION_IN_LABEL :Mostra população da localidade na identificação da mesma: {STRING} STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Mostrar a população das povoações na sua etiqueta no mapa STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS :Grossura das linhas nos gráficos: {STRING} STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Largura da linha nos gráficos. Uma linha mais estreita é de leitura mais precisa, enquanto uma linha mais espessa é mais fácil de ver e as cores distinguem-se melhor. STR_CONFIG_SETTING_LANDSCAPE :Cenário: {STRING} -STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Os estilos dos cenários definem a jogabilidade base, cada um com cargas e requerimentos diferentes para o desenvolvimento das cidades. NewGRF e Scripts de Jogo permitem um controlo mais refinado +STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Os estilos dos cenários definem a jogabilidade base, cada um com cargas e requerimentos diferentes para o desenvolvimento das localidades. NewGRF e Scripts de Jogo permitem um controlo mais refinado STR_CONFIG_SETTING_LAND_GENERATOR :Gerador de terreno: {STRING} STR_CONFIG_SETTING_LAND_GENERATOR_HELPTEXT :O gerador original é dependente do conjunto gráfico base, e compõe formas de terreno já afixadas. TerraGenesis é um gerador baseado no algoritmo de ruído de Perlin que permite definições mais refinadas STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Original @@ -1320,7 +1322,7 @@ STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Define quantas STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Distância máxima entre o limite do mapa e Refinarias de Petróleo: {STRING} STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Refinarias de petróleo são construídas apenas próximo da borda do mapa, isto é, na costa para mapas de ilha STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Altura da linha de neve: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a que altura a neve começa em paisagens sub-árticas. A neve também afecta a geração de indústrias e os requisitos de crescimento das cidades +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a que altura a neve começa em paisagens sub-árticas. A neve também afecta a geração de indústrias e os requisitos de crescimento das localidades STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Rudeza do terreno: {STRING} STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Apenas TerraGenesis) Escolhe a frequência de montes: paisagens macias têm menos montes e mais espalhados. Paisagens duras têm muitos montes, que podem parecer repetitivos STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Muito suave @@ -1450,7 +1452,7 @@ STR_CONFIG_SETTING_SOUND_DISASTER_HELPTEXT :Reproduzir efei STR_CONFIG_SETTING_SOUND_VEHICLE :Veículos: {STRING} STR_CONFIG_SETTING_SOUND_VEHICLE_HELPTEXT :Reproduzir efeitos sonoros dos veículos STR_CONFIG_SETTING_SOUND_AMBIENT :Ambiente: {STRING} -STR_CONFIG_SETTING_SOUND_AMBIENT_HELPTEXT :Reproduzir efeitos sonoros da paisagem, indústrias e cidades +STR_CONFIG_SETTING_SOUND_AMBIENT_HELPTEXT :Reproduzir efeitos sonoros da paisagem, indústrias e localidades STR_CONFIG_SETTING_DISABLE_UNSUITABLE_BUILDING :Desativar construção de infra-estrutura quando não estão disponíveis veículos adequados: {STRING} STR_CONFIG_SETTING_DISABLE_UNSUITABLE_BUILDING_HELPTEXT :Quando activo, as infraestruturas só estão disponíveis se os veículos estiverem também, prevenindo desperdícios de tempo e dinheiro em infraestruturas sem utilidade. @@ -1566,24 +1568,28 @@ STR_CONFIG_SETTING_CYCLE_SIGNAL_NORMAL :Apenas sinais d STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS :Apenas sinais de rota STR_CONFIG_SETTING_CYCLE_SIGNAL_ALL :Todos -STR_CONFIG_SETTING_TOWN_LAYOUT :Disposição de estradas para novas cidades: {STRING} -STR_CONFIG_SETTING_TOWN_LAYOUT_HELPTEXT :Disposição da rede de estradas das cidades +STR_CONFIG_SETTING_TOWN_LAYOUT :Disposição de estradas para novas localidades: {STRING} +STR_CONFIG_SETTING_TOWN_LAYOUT_HELPTEXT :Disposição da rede de estradas das localidades STR_CONFIG_SETTING_TOWN_LAYOUT_DEFAULT :Original STR_CONFIG_SETTING_TOWN_LAYOUT_BETTER_ROADS :Estradas melhores STR_CONFIG_SETTING_TOWN_LAYOUT_2X2_GRID :grelha 2x2 STR_CONFIG_SETTING_TOWN_LAYOUT_3X3_GRID :grelha 3x3 STR_CONFIG_SETTING_TOWN_LAYOUT_RANDOM :Aleatório -STR_CONFIG_SETTING_ALLOW_TOWN_ROADS :As cidades têm permissão para construir estradas: {STRING} -STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Permite às cidades a construção de estradas para crescimento. Desactivar para não permitir às autoridades a construção de estradas -STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Cidades podem construir passagens de nível: {STRING} -STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Activar esta preferência permite às cidades construir cruzamentos nivelados -STR_CONFIG_SETTING_NOISE_LEVEL :Permitir que a cidade controle o nível de ruído dos aeroportos: {STRING} -STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Com esta preferência desactivada, podem haver dois aeroportos em cada cidade. Com esta preferência activa, o número de aeroportos numa cidade é limitado pela aceitação do ruído na cidade, que depende da população, do tamanho do aeroporto e da sua distância -STR_CONFIG_SETTING_TOWN_FOUNDING :Fundar cidades no jogo: {STRING} +STR_CONFIG_SETTING_ALLOW_TOWN_ROADS :As localidades têm permissão para construir estradas: {STRING} +STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Permite às localidades a construção de estradas para crescimento. Desactivar para não permitir às autoridades a construção de estradas +STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Localidades podem construir passagens de nível: {STRING} +STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Activar esta preferência permite às localidades construir cruzamentos nivelados +STR_CONFIG_SETTING_NOISE_LEVEL :Permitir que a localidade controle o nível de ruído dos aeroportos: {STRING} +STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Com esta preferência desactivada, podem haver dois aeroportos em cada localidade. Com esta preferência activa, o número de aeroportos numa localidade é limitado pela aceitação do ruído na mesma, que depende da população, do tamanho do aeroporto e da sua distância +STR_CONFIG_SETTING_TOWN_FOUNDING :Fundar localidades no jogo: {STRING} STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Activar esta preferência permite aos jogadores fundar novas povoações no jogo STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Proibido STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Permitido -STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Permitido, estrutura personalizada da cidade +STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Permitido, estrutura personalizada da localidade +STR_CONFIG_SETTING_TOWN_CARGOGENMODE :Geração de carga citadina: {STRING} +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT :Quantidade de carga produzida por casas em localidades, relativa à população total da mesma.{}Crescimento quadrático: Uma localidade do dobro do tamanho gera 4x mais passageiros.{}Crescimento linear: Uma localidade do dobro do tamanho gera 2x a quantidade de passageiros. +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_ORIGINAL :Quadrático (original) +STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Linear STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Criação de árvores no decorrer do jogo: {STRING} STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Controlar o aparecimento aleatório de árvores durante o jogo. Isto poderá afectar indústrias que dependem do crescimento de árvores, como as madeireiras @@ -1613,19 +1619,19 @@ STR_CONFIG_SETTING_ZOOM_LVL_NORMAL :Normal STR_CONFIG_SETTING_ZOOM_LVL_OUT_2X :2x STR_CONFIG_SETTING_ZOOM_LVL_OUT_4X :4x STR_CONFIG_SETTING_ZOOM_LVL_OUT_8X :8x -STR_CONFIG_SETTING_TOWN_GROWTH :Ritmo de crescimento de cidades: {STRING} -STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT :Velocidade de crescimento das cidades +STR_CONFIG_SETTING_TOWN_GROWTH :Ritmo de crescimento de localidades: {STRING} +STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT :Velocidade de crescimento das localidades STR_CONFIG_SETTING_TOWN_GROWTH_NONE :Nenhum STR_CONFIG_SETTING_TOWN_GROWTH_SLOW :Lento STR_CONFIG_SETTING_TOWN_GROWTH_NORMAL :Normal STR_CONFIG_SETTING_TOWN_GROWTH_FAST :Rápido STR_CONFIG_SETTING_TOWN_GROWTH_VERY_FAST :Muito Rápido -STR_CONFIG_SETTING_LARGER_TOWNS :Proporção de cidades que chegarão a metrópoles: {STRING} -STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Quantidade de povoações que se tornarão cidades, logo cidades que começarão maiores e crescerão mais depressa +STR_CONFIG_SETTING_LARGER_TOWNS :Proporção de localidades que chegarão a cidades: {STRING} +STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Quantidade de localidades que se tornarão cidades, ou seja uma localidade que começa maior e crescerá mais depressa. STR_CONFIG_SETTING_LARGER_TOWNS_VALUE :1 em {COMMA} STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :Nenhum STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Multiplicador inicial para a dimensão das metrópoles: {STRING} -STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Tamanho relativo das metrópoles em relação ao tamanho normal das cidades aquando o início do jogo +STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Tamanho relativo das cidades em relação ao tamanho normal das localidades aquando o início do jogo STR_CONFIG_SETTING_LINKGRAPH_INTERVAL :Actualizar gráfico de distribuição a cada {STRING} dia{P 0:2 "" s} STR_CONFIG_SETTING_LINKGRAPH_INTERVAL_HELPTEXT :Tempo entre recalculos subsequentes de cada gráfico. Cada recalculo calcula os planos para cada componente do gráfico. Isto significa que um valor X para essa configuração não indica que o gráfico será todo actualizado a cada X dias. Apenas alguns componentes serão. Quanto mais curto o definir, mais tempo será necessário ao CPU para o calcular. Quanto mais longo, mais tempo levará até que a distribuição da carga inicie em novas rotas. @@ -1705,13 +1711,12 @@ STR_CONFIG_SETTING_ACCIDENTS :{ORANGE}Desastr STR_CONFIG_SETTING_GENWORLD :{ORANGE}Geração do mundo STR_CONFIG_SETTING_ENVIRONMENT :{ORANGE}Meio Ambiente STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES :{ORANGE}Autoridades -STR_CONFIG_SETTING_ENVIRONMENT_TOWNS :{ORANGE}Cidades +STR_CONFIG_SETTING_ENVIRONMENT_TOWNS :{ORANGE}Localidades STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Industrias STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distribuição de Carga STR_CONFIG_SETTING_AI :{ORANGE}Oponentes STR_CONFIG_SETTING_AI_NPC :{ORANGE}Jogadores Computador -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomendado) @@ -1795,7 +1800,6 @@ STR_QUIT_NO :{BLACK}Não # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2133,7 +2137,7 @@ STR_NETWORK_CHAT_ALL :[Todos] {STRING STR_NETWORK_CHAT_OSKTITLE :{BLACK}Introduza a mensagem para os outros jogadores # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Não foram encontradas interfaces de rede ou o jogo foi compilado sem ENABLE_NETWORK +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Não foram encontradas interfaces de rede STR_NETWORK_ERROR_NOSERVER :{WHITE}Não foram encontrados jogos de rede STR_NETWORK_ERROR_NOCONNECTION :{WHITE}O servidor não respondeu ao pedido STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Impossível ligar devido a incompatibilidade de NewGRF @@ -2528,31 +2532,31 @@ STR_QUERY_RESET_LANDSCAPE_CAPTION :{WHITE}Repor Te STR_RESET_LANDSCAPE_CONFIRMATION_TEXT :{WHITE}Tem a certeza que quer apagar todas as propriedades das empresas? # Town generation window (SE) -STR_FOUND_TOWN_CAPTION :{WHITE}Gerar Cidades -STR_FOUND_TOWN_NEW_TOWN_BUTTON :{BLACK}Nova Cidade -STR_FOUND_TOWN_NEW_TOWN_TOOLTIP :{BLACK}Fundar nova cidade. Shift+Clique mostra apenas o custo estimado -STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Cidade Aleatória -STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Fundar uma cidade num local aleatório -STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Várias cidades aleatórias -STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Cobrir o mapa com cidades colocadas aleatoriamente - -STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Nome da cidade: -STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Introduza o nome da cidade -STR_FOUND_TOWN_NAME_EDITOR_HELP :{BLACK}Clique para introduzir o nome da cidade +STR_FOUND_TOWN_CAPTION :{WHITE}Gerar Localidades +STR_FOUND_TOWN_NEW_TOWN_BUTTON :{BLACK}Nova Localidade +STR_FOUND_TOWN_NEW_TOWN_TOOLTIP :{BLACK}Fundar nova localidade. Shift+Clique mostra apenas o custo estimado +STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Localidade Aleatória +STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Fundar uma localidade num local aleatório +STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Várias localidades aleatórias +STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Cobrir o mapa com localidades colocadas aleatoriamente + +STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Nome da localidade: +STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Introduza o nome da localidade +STR_FOUND_TOWN_NAME_EDITOR_HELP :{BLACK}Clique para introduzir o nome da localidade STR_FOUND_TOWN_NAME_RANDOM_BUTTON :{BLACK}Nome aleatório STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP :{BLACK}Gerar novo nome aleatório -STR_FOUND_TOWN_INITIAL_SIZE_TITLE :{YELLOW}Tamanho da cidade: +STR_FOUND_TOWN_INITIAL_SIZE_TITLE :{YELLOW}Tamanho da localidade: STR_FOUND_TOWN_INITIAL_SIZE_SMALL_BUTTON :{BLACK}Pequena STR_FOUND_TOWN_INITIAL_SIZE_MEDIUM_BUTTON :{BLACK}Média STR_FOUND_TOWN_INITIAL_SIZE_LARGE_BUTTON :{BLACK}Grande STR_FOUND_TOWN_SIZE_RANDOM :{BLACK}Aleatório -STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP :{BLACK}Seleccione o tamanho da cidade -STR_FOUND_TOWN_CITY :{BLACK}Metrópole -STR_FOUND_TOWN_CITY_TOOLTIP :{BLACK}Metrópoles crescem mais depressa do que as cidades normais{}Dependendo da configuração, são maiores aquando da sua fundação +STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP :{BLACK}Seleccione o tamanho da localidade +STR_FOUND_TOWN_CITY :{BLACK}Cidade +STR_FOUND_TOWN_CITY_TOOLTIP :{BLACK}Cidades crescem mais depressa do que as localidades normais{}Dependendo da configuração, são maiores aquando da sua fundação -STR_FOUND_TOWN_ROAD_LAYOUT :{YELLOW}Disposição de estradas na cidade: -STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT :{BLACK}Seleccione disposição das estradas utilizada para esta cidade +STR_FOUND_TOWN_ROAD_LAYOUT :{YELLOW}Disposição de estradas na localidade: +STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT :{BLACK}Seleccione disposição das estradas utilizada para esta localidade STR_FOUND_TOWN_SELECT_LAYOUT_ORIGINAL :{BLACK}Original STR_FOUND_TOWN_SELECT_LAYOUT_BETTER_ROADS :{BLACK}Estradas melhores STR_FOUND_TOWN_SELECT_LAYOUT_2X2_GRID :{BLACK}grelha 2x2 @@ -2798,7 +2802,7 @@ STR_MAPGEN_WORLD_GENERATION_CAPTION :{WHITE}Gerador STR_MAPGEN_MAPSIZE :{BLACK}Dim. do mapa: STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Seleccionar o tamanho do mapa em mosaicos. O numero de mosaicos disponiveis será ligeiramente menor STR_MAPGEN_BY :{BLACK}* -STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Num. de cidades: +STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Num. de localidades: STR_MAPGEN_DATE :{BLACK}Data: STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Num. de indústrias: STR_MAPGEN_MAX_HEIGHTLEVEL :{BLACK}Altura máxima do mapa: @@ -2994,7 +2998,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Recursos GRF pe STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} foi desactivado por {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Formato de Gráfico Inválido ou desconhecido (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Demasiados elementos na lista de valores de propriedade (sprite {3:NUM}, propriedade {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Revogação da produção industrial inválida (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Revogação da produção industrial inválida (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Alerta! @@ -3026,6 +3030,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}A informação de carga/adaptação do modelo de veículo '{1:ENGINE}' difere da que consta na lista de veículos depois de adquirido. Isto poderá causar problemas ao adaptar quando automaticamente renovado/substituído. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' causou um loop infinito no callback de produção. STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback {1:HEX} devolveu resultado desconhecido/inválido {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' devolveu tipo de carga inválida no callback de produção em {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO : @@ -3056,16 +3061,16 @@ STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP :{BLACK}Ir para STR_EDIT_SIGN_SIGN_OSKTITLE :{BLACK}Introduza um nome para o sinal # Town directory window -STR_TOWN_DIRECTORY_CAPTION :{WHITE}Cidades +STR_TOWN_DIRECTORY_CAPTION :{WHITE}Localidades STR_TOWN_DIRECTORY_NONE :{ORANGE}- Nenhuma - STR_TOWN_DIRECTORY_TOWN :{ORANGE}{TOWN}{BLACK} ({COMMA}) STR_TOWN_DIRECTORY_CITY :{ORANGE}{TOWN}{YELLOW} (Cidade){BLACK} ({COMMA}) -STR_TOWN_DIRECTORY_LIST_TOOLTIP :{BLACK}Nomes das cidades - clique no nome para centrar a visualização na cidade. Ctrl+Clique abre um novo visualizador na localização da cidade +STR_TOWN_DIRECTORY_LIST_TOOLTIP :{BLACK}Nomes das localidades - clique no nome para centrar a visualização na cidade. Ctrl+Clique abre um novo visualizador na localização da localidade STR_TOWN_POPULATION :{BLACK}População Mundial: {COMMA} # Town view window STR_TOWN_VIEW_TOWN_CAPTION :{WHITE}{TOWN} -STR_TOWN_VIEW_CITY_CAPTION :{WHITE}{TOWN} (Metrópole) +STR_TOWN_VIEW_CITY_CAPTION :{WHITE}{TOWN} (Cidade) STR_TOWN_VIEW_POPULATION_HOUSES :{BLACK}População: {ORANGE}{COMMA}{BLACK} Casas: {ORANGE}{COMMA} STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX :{BLACK}{CARGO_LIST} ultimo mês: {ORANGE}{COMMA}{BLACK} max: {ORANGE}{COMMA} STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH :{BLACK}Mercadoria necessária para o seu desenvolvimento: @@ -3074,28 +3079,28 @@ STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{BLACK}No inver STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL :{ORANGE}{STRING}{GREEN} entregue STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (ainda necessário) STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (entregue) -STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Cidade cresce a cada {ORANGE}{COMMA}{BLACK} dia{P "" s} -STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Cidade cresce a cada {ORANGE}{COMMA}{BLACK} dia{P "" s} (financiado) -STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Cidade {RED}não{BLACK} está a crescer -STR_TOWN_VIEW_NOISE_IN_TOWN :{BLACK}Limite de ruído na cidade: {ORANGE}{COMMA}{BLACK} máx: {ORANGE}{COMMA} -STR_TOWN_VIEW_CENTER_TOOLTIP :{BLACK}Centrar visualização na cidade. Ctrl+Clique abre um novo visualizador na localização da cidade +STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Localidade cresce a cada {ORANGE}{COMMA}{BLACK}{NBSP}dia{P "" s} +STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Localidade cresce a cada {ORANGE}{COMMA}{BLACK}{NBSP}dia{P "" s} (financiado) +STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Localidade {RED}não{BLACK} está a crescer +STR_TOWN_VIEW_NOISE_IN_TOWN :{BLACK}Limite de ruído na localidade: {ORANGE}{COMMA}{BLACK} máx: {ORANGE}{COMMA} +STR_TOWN_VIEW_CENTER_TOOLTIP :{BLACK}Centrar visualização na localidade. Ctrl+Clique abre um novo visualizador na localização da localidade STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON :{BLACK}Autoridade local STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP :{BLACK}Ver informações sobre a autoridade local -STR_TOWN_VIEW_RENAME_TOOLTIP :{BLACK}Alterar o nome da cidade +STR_TOWN_VIEW_RENAME_TOOLTIP :{BLACK}Alterar o nome da localidade STR_TOWN_VIEW_EXPAND_BUTTON :{BLACK}Expandir STR_TOWN_VIEW_EXPAND_TOOLTIP :{BLACK}Aumentar o tamanho da cidade STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Apagar -STR_TOWN_VIEW_DELETE_TOOLTIP :{BLACK}Apagar completamente esta cidade +STR_TOWN_VIEW_DELETE_TOOLTIP :{BLACK}Apagar completamente esta localidade -STR_TOWN_VIEW_RENAME_TOWN_BUTTON :Renomear Cidade +STR_TOWN_VIEW_RENAME_TOWN_BUTTON :Renomear Localidade # Town local authority window STR_LOCAL_AUTHORITY_CAPTION :{WHITE}{TOWN} autoridade local STR_LOCAL_AUTHORITY_COMPANY_RATINGS :{BLACK}Avaliações da empresa de transporte: STR_LOCAL_AUTHORITY_COMPANY_RATING :{YELLOW}{COMPANY} {COMPANY_NUM}: {ORANGE}{STRING} STR_LOCAL_AUTHORITY_ACTIONS_TITLE :{BLACK}Acções disponíveis: -STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP :{BLACK}Lista de acções disponíveis nesta cidade - fazer clique no item para mais detalhes +STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP :{BLACK}Lista de acções disponíveis nesta localidade - fazer clique no item para mais detalhes STR_LOCAL_AUTHORITY_DO_IT_BUTTON :{BLACK}Aplicar STR_LOCAL_AUTHORITY_DO_IT_TOOLTIP :{BLACK}Realizar a acção destacada na lista acima @@ -3113,8 +3118,8 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_MEDIUM_ADVERTISING :{YELLOW}Iniciar STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_LARGE_ADVERTISING :{YELLOW}Iniciar uma campanha publicitária grande, para atrair mais passageiros e carga à sua empresa.{}Custo: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_ROAD_RECONSTRUCTION :{YELLOW}Financiar a reconstrução da rede rodoviária urbana. Causa engarrafamentos consideráveis ao tráfego até 6 meses.{}Custo: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_STATUE_OF_COMPANY :{YELLOW}Construir uma estátua em honra da sua empresa.{}Custo: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_NEW_BUILDINGS :{YELLOW}Financiar a construção de edifícios comerciais novos na cidade.{}Custo: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{YELLOW}Comprar a exclusividade dos serviços durante 1 ano na cidade. A autoridade da cidade permitirá que os passageiros e a carga usem somente estações da sua empresa.{}Custo: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_NEW_BUILDINGS :{YELLOW}Financiar a construção de edifícios comerciais novos na localidade.{}Custo: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{YELLOW}Comprar a exclusividade dos serviços durante 1 ano nesta localidade. A autoridade local permitirá que os passageiros e a carga usem somente estações da sua empresa.{}Custo: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{YELLOW}Subornar a autoridade local para aumentar a sua avaliação, correndo o risco de uma penalidade severa se apanhado.{}Custo: {CURRENCY_LONG} # Goal window @@ -3128,7 +3133,7 @@ STR_GOALS_SPECTATOR_NONE :{ORANGE}- Não STR_GOALS_PROGRESS :{ORANGE}{STRING} STR_GOALS_PROGRESS_COMPLETE :{GREEN}{STRING} STR_GOALS_COMPANY_TITLE :{BLACK}Objetivos da empresa: -STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Clique no objetivo para centrar a vista principal na indústria/cidade/quadrado. Ctrl+clique abre uma nova vista na localização da indústria/cidade/quadrado +STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Clique no objetivo para centrar a vista principal na indústria/localidade/quadrado. Ctrl+Clique abre uma nova vista na localização da indústria/localidade/quadrado # Goal question window STR_GOAL_QUESTION_CAPTION_QUESTION :Questão @@ -3164,7 +3169,7 @@ STR_SUBSIDIES_OFFERED_FROM_TO :{ORANGE}{STRING STR_SUBSIDIES_NONE :{ORANGE}- Nenhum - STR_SUBSIDIES_SUBSIDISED_TITLE :{BLACK}Serviços já subsidiados: STR_SUBSIDIES_SUBSIDISED_FROM_TO :{ORANGE}{STRING} d{G 1 e o a os as} {STRING} para{G 2 "" " o" " a" " os" " as"} {STRING}{YELLOW} ({COMPANY}{YELLOW}, até {DATE_SHORT}) -STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Clique num serviço para centrar a visualização numa indústria/cidade. Ctrl+Clique abre um novo visualizador na localização da indústria/cidade +STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Clique num serviço para centrar a visualização numa indústria/localidade. Ctrl+Clique abre um novo visualizador na localização da indústria/localidade # Story book window STR_STORY_BOOK_CAPTION :{WHITE}{COMPANY} Livro de História @@ -3200,8 +3205,8 @@ STR_STATION_VIEW_ACCEPTS_BUTTON :{BLACK}Aceita STR_STATION_VIEW_ACCEPTS_TOOLTIP :{BLACK}Mostrar lista de carga aceite STR_STATION_VIEW_ACCEPTS_CARGO :{BLACK}Aceita: {WHITE}{CARGO_LIST} -STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF :{BLACK}Esta estação tem direitos de transporte exclusivos nesta cidade. -STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY :{YELLOW}{COMPANY}{BLACK} comprou direitos exclusivos de transporte nesta cidade. +STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF :{BLACK}Esta estação tem direitos de transporte exclusivos nesta localidade. +STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY :{YELLOW}{COMPANY}{BLACK} comprou direitos exclusivos de transporte nesta localidade. STR_STATION_VIEW_RATINGS_BUTTON :{BLACK}Avaliações STR_STATION_VIEW_RATINGS_TOOLTIP :{BLACK}Mostrar avaliações da estação @@ -3464,6 +3469,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Novos Barcos STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Nova Aeronave STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Custo: {GOLD}{CURRENCY_LONG}{BLACK} Peso: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Custo: {GOLD}{CURRENCY_LONG}{BLACK} (Custo da conversão: {GOLD}{CURRENCY_LONG}{BLACK}) Peso: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Velocidade: {GOLD}{VELOCITY}{BLACK} Potência: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Velocidade: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Velocidade no oceano: {GOLD}{VELOCITY} @@ -3474,8 +3480,10 @@ STR_PURCHASE_INFO_REFITTABLE :(adaptável) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Concebido: {GOLD}{NUM}{BLACK} Vida útil: {GOLD}{COMMA} ano{P "" s} STR_PURCHASE_INFO_RELIABILITY :{BLACK}Fiabilidade máxima: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Custo: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Custo: {GOLD}{CURRENCY_LONG}{BLACK} (Custo da adaptação: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Peso: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Custo: {GOLD}{CURRENCY_LONG}{BLACK} Velocidade: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Custo: {GOLD}{CURRENCY_LONG}{BLACK} (Custo de conversão: {GOLD}{CURRENCY_LONG}{BLACK}) Velocidade: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Capacidade: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Vagões Motorizados: {GOLD}+{POWER}{BLACK} Peso: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Reconvertível para: {GOLD}{STRING} @@ -3496,11 +3504,21 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Comprar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Comprar Barco STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Comprar Aeronave +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Comprar e Reconverter veiculo +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Comprar e Reconverter Veículo +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Comprar e Converter Barco +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Comprar e Adaptar Carga da Aeronave + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar o veículo ferroviário seleccionado. Shift+Clique mostra estimativa de custo, sem comprar STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar o veículo rodoviário seleccionado. Shift+Clique mostra estimativa de custo, sem comprar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar barco seleccionado. Shift+Clique mostra estimativa de custo, sem comprar STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar aeronave seleccionada. Shift+Clique mostra estimativa de custo, sem comprar +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Comprar e converter veículo ferroviário seleccionado. Shift+Clique mostra estimativa de custo, sem comprar +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :Comprar e converter veículo rodoviário seleccionado. Shift+Clique mostra estimativa de custo, sem comprar +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Comprar e converter barco seleccionado. Shift+Clique mostra estimativa de custo, sem comprar +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Comprar e converter aeronave seleccionada. Shift+Clique mostra estimativa de custo, sem comprar + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renomear STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renomear @@ -4173,8 +4191,8 @@ STR_GAME_SAVELOAD_NOT_AVAILABLE : STR_WARNING_LOADGAME_REMOVED_TRAMS :{WHITE}O jogo foi salvo numa versão sem suporte a eléctricos. Todos os eléctricos foram removidos. # Map generation messages -STR_ERROR_COULD_NOT_CREATE_TOWN :{WHITE}Geração de mapa abortada...{}... não há locais apropriados para cidades -STR_ERROR_NO_TOWN_IN_SCENARIO :{WHITE}... não existe nenhuma cidade neste cenário +STR_ERROR_COULD_NOT_CREATE_TOWN :{WHITE}Geração de mapa abortada...{}... não há locais apropriados para localidades +STR_ERROR_NO_TOWN_IN_SCENARIO :{WHITE}... não existe nenhuma localidade neste cenário STR_ERROR_PNGMAP :{WHITE}Impossível carregar paisagem do PNG... STR_ERROR_PNGMAP_FILE_NOT_FOUND :{WHITE}... ficheiro não encontrado @@ -4225,7 +4243,7 @@ STR_ERROR_NOT_ALLOWED_WHILE_PAUSED :{WHITE}Não per # Local authority errors STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS :{WHITE}A autoridade local de {TOWN} não autorizou -STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT :{WHITE}{TOWN} a autoridade local recusa permitir que outro aeroporto seja construído nesta cidade +STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT :{WHITE}{TOWN} a autoridade local recusa permitir que outro aeroporto seja construído nesta localidade STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE :{WHITE}{TOWN} a autoridade local não permite a construção do aeroporto devido à poluição sonora STR_ERROR_BRIBE_FAILED :{WHITE}A sua tentativa de suborno foi descoberta por um investigador regional @@ -4256,18 +4274,18 @@ STR_ERROR_CAN_T_SELL_25_SHARE_IN :{WHITE}Não é STR_ERROR_PROTECTED :{WHITE}Esta empresa ainda não troca acções... # Town related errors -STR_ERROR_CAN_T_GENERATE_TOWN :{WHITE}Não é possível construir cidades -STR_ERROR_CAN_T_RENAME_TOWN :{WHITE}Não é possível renomear cidade... -STR_ERROR_CAN_T_FOUND_TOWN_HERE :{WHITE}Não é possível construir uma cidade aqui... -STR_ERROR_CAN_T_EXPAND_TOWN :{WHITE}Não é possível expandir cidade... +STR_ERROR_CAN_T_GENERATE_TOWN :{WHITE}Não é possível construir localidades +STR_ERROR_CAN_T_RENAME_TOWN :{WHITE}Não é possível renomear localidade... +STR_ERROR_CAN_T_FOUND_TOWN_HERE :{WHITE}Não é possível construir uma localidade aqui... +STR_ERROR_CAN_T_EXPAND_TOWN :{WHITE}Não é possível expandir localidade... STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP_SUB :{WHITE}... muito perto do limite do mapa -STR_ERROR_TOO_CLOSE_TO_ANOTHER_TOWN :{WHITE}... muito perto de outra cidade -STR_ERROR_TOO_MANY_TOWNS :{WHITE}... demasiadas cidades +STR_ERROR_TOO_CLOSE_TO_ANOTHER_TOWN :{WHITE}... muito perto de outra localidade +STR_ERROR_TOO_MANY_TOWNS :{WHITE}... demasiadas localidades STR_ERROR_NO_SPACE_FOR_TOWN :{WHITE}... não existe mais espaço no mapa -STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS :{WHITE}A cidade não construirá estradas. Pode-se permitir a construção de estradas por Opções Avançadas->Economia->Cidades +STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS :{WHITE}A localidade não construirá estradas. Pode-se permitir a construção de estradas por Opções Avançadas->Economia->Localidades STR_ERROR_ROAD_WORKS_IN_PROGRESS :{WHITE}Trabalhos na estrada em curso -STR_ERROR_TOWN_CAN_T_DELETE :{WHITE}Não é possível eliminar esta cidade...{}Uma estação ou depósito refere-se à cidade ou não é possível remover terreno pertencente à cidade -STR_ERROR_STATUE_NO_SUITABLE_PLACE :{WHITE}... não há um sítio adequado para uma estátua no centro desta cidade +STR_ERROR_TOWN_CAN_T_DELETE :{WHITE}Não é possível eliminar esta localidade...{}Uma estação ou depósito refere-se à localidade ou não é possível remover terreno pertencente à mesma +STR_ERROR_STATUE_NO_SUITABLE_PLACE :{WHITE}... não há um sítio adequado para uma estátua no centro desta localidade # Industry related errors STR_ERROR_TOO_MANY_INDUSTRIES :{WHITE}... demasiadas indústrias @@ -4275,13 +4293,13 @@ STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Não é STR_ERROR_CAN_T_BUILD_HERE :{WHITE}Não é possível construir {STRING} aqui... STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY :{WHITE}Não é possível construir este tipo de indústria aqui... STR_ERROR_INDUSTRY_TOO_CLOSE :{WHITE}... muito perto de outra indústria -STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... é necessário construir uma cidade primeiro -STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... só é permitido uma por cidade -STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS_WITH_POPULATION_OF_1200 :{WHITE}... só pode ser construído em cidades com pelo menos 1200 habitantes +STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... é necessário construir uma localidade primeiro +STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... só é permitido uma por localidade +STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS_WITH_POPULATION_OF_1200 :{WHITE}... só pode ser construído em localidades com pelo menos 1200 habitantes STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST :{WHITE}... só se pode construir em zonas florestais STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT :{WHITE}... só se pode construir em zonas desérticas -STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS :{WHITE}... só se pode construir em cidades (substituindo casas) -STR_ERROR_CAN_ONLY_BE_BUILT_NEAR_TOWN_CENTER :{WHITE}... só se pode construir no centro de uma cidade +STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS :{WHITE}... só se pode construir em localidades (substituindo casas) +STR_ERROR_CAN_ONLY_BE_BUILT_NEAR_TOWN_CENTER :{WHITE}... só se pode construir no centro de uma localidade STR_ERROR_CAN_ONLY_BE_BUILT_IN_LOW_AREAS :{WHITE}... só se pode construir em planícies STR_ERROR_CAN_ONLY_BE_POSITIONED :{WHITE}... só pode ser colocado perto das bordas do mapa STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED :{WHITE}... a floresta só pode ser plantada acima do nível de neve @@ -4309,7 +4327,7 @@ STR_ERROR_TOO_MANY_TRUCK_STOPS :{WHITE}Demasiad STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK :{WHITE}Muito perto de outra doca STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT :{WHITE}Demasiado perto de outro aeroporto STR_ERROR_CAN_T_RENAME_STATION :{WHITE}Não pode alterar o nome da estação... -STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... esta estrada é detida pela cidade +STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... esta estrada é detida pela localidade. STR_ERROR_DRIVE_THROUGH_DIRECTION :{WHITE}... estrada orientada na direcção incorrecta STR_ERROR_DRIVE_THROUGH_CORNER :{WHITE}... estações de passagem não podem ter curvas STR_ERROR_DRIVE_THROUGH_JUNCTION :{WHITE}... estações de passagem não podem ter cruzamentos diff --git a/src/lang/romanian.txt b/src/lang/romanian.txt index b260965928..46764aa6fa 100644 --- a/src/lang/romanian.txt +++ b/src/lang/romanian.txt @@ -1105,6 +1105,7 @@ STR_CONFIG_SETTING_TYPE_COMPANY_MENU :Setări compani STR_CONFIG_SETTING_TYPE_COMPANY_INGAME :Setări companie (stocate în fişierul de salvare; afectează doar compania curentă) STR_CONFIG_SETTING_RESTRICT_CATEGORY :{BLACK}Categorie: +STR_CONFIG_SETTING_RESTRICT_TYPE :{BLACK}Tip: STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT :{BLACK}Arată în lista de mai jos doar setările modificate STR_CONFIG_SETTING_RESTRICT_BASIC :Setări de bază (afişează numai setări importante) STR_CONFIG_SETTING_RESTRICT_ADVANCED :Setări avansate (afişează majoritatea setărilor) @@ -1312,6 +1313,7 @@ STR_CONFIG_SETTING_TREE_PLACER_HELPTEXT :Alegeți distri STR_CONFIG_SETTING_TREE_PLACER_NONE :Niciunul STR_CONFIG_SETTING_TREE_PLACER_ORIGINAL :Original STR_CONFIG_SETTING_TREE_PLACER_IMPROVED :Îmbunătăţit +STR_CONFIG_SETTING_ROAD_SIDE :Autovehicule: {STRING} STR_CONFIG_SETTING_ROAD_SIDE_HELPTEXT :Alege banda pentru condus STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Rotaţie hartă înălţimi: {STRING} STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Spre stânga @@ -1364,6 +1366,7 @@ STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_CONTROL :Control+Click STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_OFF :Oprit +STR_CONFIG_SETTING_AUTOSAVE :Autosalvare: {STRING} STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES :Foloseşte formatul datei {STRING} pentru numele salvărilor STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES_HELPTEXT :Formatul datei in numele salvărilor @@ -1643,6 +1646,7 @@ STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_METRIC :Metric (m) STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_SI :SI (m) STR_CONFIG_SETTING_LOCALISATION :{ORANGE}Localizare +STR_CONFIG_SETTING_GRAPHICS :{ORANGE}Grafică STR_CONFIG_SETTING_SOUND :{ORANGE}Efecte sonore STR_CONFIG_SETTING_INTERFACE :{ORANGE}Interfaţă STR_CONFIG_SETTING_INTERFACE_GENERAL :{ORANGE}General @@ -1661,7 +1665,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Concurenţi STR_CONFIG_SETTING_AI_NPC :{ORANGE}Jucători virtuali -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomandat) @@ -1744,7 +1747,6 @@ STR_QUIT_NO :{BLACK}Nu # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2659,6 +2661,7 @@ STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP :{BLACK}Număr de evenimente de joc simulate per secundă. STR_FRAMERATE_AVERAGE :{WHITE}Medie STR_FRAMERATE_DATA_POINTS :{BLACK}Date bazate pe măsurători {COMMA} +STR_FRAMERATE_MS_GOOD :{LTBLUE}{DECIMAL} ms STR_FRAMERATE_GRAPH_MILLISECONDS :{TINY_FONT}{COMMA} ms ############ Leave those lines in this order!! STR_FRAMERATE_VIDEO :{BLACK}Ieșire video: @@ -2815,6 +2818,7 @@ STR_NEWGRF_SETTINGS_DISABLED :{RED}Dezactivat STR_NEWGRF_SETTINGS_INCOMPATIBLE :{RED}Incompatibil cu această versiune de OpenTTD # NewGRF save preset window +STR_SAVE_PRESET_TITLE :{BLACK}Adaugă denumire presetare STR_SAVE_PRESET_CANCEL :{BLACK}Anulează STR_SAVE_PRESET_CANCEL_TOOLTIP :{BLACK}Nu schimba setarea implicită STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Salvează setarea pe numele selectat @@ -3325,6 +3329,7 @@ STR_GROUP_REMOVE_ALL_VEHICLES :Elimină toate STR_GROUP_RENAME_CAPTION :{BLACK}Redenumeşte un grup STR_GROUP_OCCUPANCY :Utilizare curentă: +STR_GROUP_OCCUPANCY_VALUE :{NUM}% # Build vehicle window STR_BUY_VEHICLE_TRAIN_RAIL_CAPTION :Noi vehicule feroviare @@ -3368,11 +3373,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Cumpăr STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Cumpără navă STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Cumpără aeronavă + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Cumpără vehiculul feroviar selectat. Shift+Click arată costul estimat fără să cumpere vehiculul STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Cumpără autovehiculul selectat. Shift+Click arată costul estimat fără să cumpere autovehiculul STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Cumpără nava selectată. Shift+Click arată costul estimativ fără a efectua achiziţia STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Cumpără aeronava selectată. Shift+Click arată costul estimativ fără a efectua achiziţia + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Nume nou STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Nume nou STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Nume nou @@ -3491,6 +3498,7 @@ STR_ENGINE_PREVIEW_MAGLEV_LOCOMOTIVE :locomotivă per STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER :{BLACK}Cost: {CURRENCY_LONG} Greutate: {WEIGHT_SHORT}{}Vitezã: {VELOCITY} Putere: {POWER}{}Cost de rulare: {CURRENCY_LONG}/an{}Capacitate: {CARGO_LONG} STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE :{BLACK}Cost: {CURRENCY_LONG} Greutate: {WEIGHT_SHORT}{}Viteză: {VELOCITY} Putere: {POWER} Ef. T. Max.: {6:FORCE}{}Cost rulaj: {4:CURRENCY_LONG}/an{}Capacitate: {5:CARGO_LONG} STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST :{BLACK}Cost: {CURRENCY_LONG} Viteză max.: {VELOCITY}{}Capacitate: {CARGO_LONG}{}Mentenanţă: {CURRENCY_LONG}/an +STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_CAP_RUNCOST :{BLACK}Cost: {CURRENCY_LONG} Viteza maximă: {VELOCITY}{}Tip avion: {STRING} Rază: {COMMA} pătrățele{}Capacitate: {CARGO_LONG}, {CARGO_LONG}{}Cost întreținere: {CURRENCY_LONG}/an # Autoreplace window STR_REPLACE_VEHICLES_WHITE :{WHITE}Înlocuieşte {STRING} - {STRING} diff --git a/src/lang/russian.txt b/src/lang/russian.txt index 8fe4cc9c64..0f6ed4c343 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -1871,7 +1871,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Рас STR_CONFIG_SETTING_AI :{ORANGE}Конкуренты STR_CONFIG_SETTING_AI_NPC :{ORANGE}Искусственный интеллект -STR_CONFIG_SETTING_PATHFINDER_OPF :оригинальный STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Рекомендуется) @@ -1955,7 +1954,6 @@ STR_QUIT_NO :{BLACK}Нет # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2293,7 +2291,7 @@ STR_NETWORK_CHAT_ALL :[Всем] {STR STR_NETWORK_CHAT_OSKTITLE :{BLACK}Введите текст для сетевого сообщения # Network messages -STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Не найдены сетевые устройства или игра скомпилирована без поддержки сети +STR_NETWORK_ERROR_NOTAVAILABLE :{WHITE}Не найдены сетевые устройства STR_NETWORK_ERROR_NOSERVER :{WHITE}Не найдены сетевые игры STR_NETWORK_ERROR_NOCONNECTION :{WHITE}Сервер не ответил на запрос STR_NETWORK_ERROR_NEWGRF_MISMATCH :{WHITE}Невозможно присоединиться из-за несоответствия NewGRF @@ -3185,7 +3183,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Запроше STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} был отключён из-за {2:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Недопустимый/неизвестный формат расположения спрайтов (спрайт {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Слишком много элементов в списке значений (спрайт {3:NUM}, свойство {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Неверная обработка продукции предприятия (спрайт {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Неверная обработка продукции предприятия (спрайт {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Осторожно! @@ -3217,6 +3215,7 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Информация о вместимости/переоборудовании для локомотива «{1:ENGINE}» после постройки отличается от сведений в списке покупки, что может помешать функции автообновления/автозамены корректно произвести переоборудование. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}Модуль «{1:STRING}» вызвал бесконечный цикл STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Функция обратного вызова {1:HEX} вернула непонятный/неверный результат {2:HEX} +STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}«{1:STRING}» вернул неверный тип груза по адресу {2:HEX} # 'User removed essential NewGRFs'-placeholders for stuff without specs STR_NEWGRF_INVALID_CARGO :<неизвестный груз> @@ -3655,18 +3654,21 @@ STR_BUY_VEHICLE_SHIP_CAPTION :Новый ко STR_BUY_VEHICLE_AIRCRAFT_CAPTION :Новый авиатранспорт STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}Цена: {GOLD}{CURRENCY_LONG}{BLACK} Вес: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK}Цена: {GOLD}{CURRENCY_LONG}{BLACK} (Стоимость переоборудования: {GOLD}{CURRENCY_LONG}{BLACK}) Вес: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}Скорость: {GOLD}{VELOCITY}{BLACK} Мощность: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}Скорость: {GOLD}{VELOCITY} -STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Скорость по океану: {GOLD}{VELOCITY} -STR_PURCHASE_INFO_SPEED_CANAL :{BLACK}Скорость по каналу/реке: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}Скорость в море: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_SPEED_CANAL :{BLACK}Скорость в каналах и реках: {GOLD}{VELOCITY} STR_PURCHASE_INFO_RUNNINGCOST :{BLACK}Стоимость обслуживания: {GOLD}{CURRENCY_LONG}/год STR_PURCHASE_INFO_CAPACITY :{BLACK}Ёмкость: {GOLD}{CARGO_LONG} {STRING} STR_PURCHASE_INFO_REFITTABLE :(переоб.) STR_PURCHASE_INFO_DESIGNED_LIFE :{BLACK}Разработан в {GOLD}{NUM} г.{BLACK} Срок службы: {GOLD}{COMMA} {P год года лет} STR_PURCHASE_INFO_RELIABILITY :{BLACK}Макс. надёжность: {GOLD}{COMMA}% STR_PURCHASE_INFO_COST :{BLACK}Цена: {GOLD}{CURRENCY_LONG} +STR_PURCHASE_INFO_COST_REFIT :{BLACK}Цена: {GOLD}{CURRENCY_LONG}{BLACK} (Стоимость переоборудования: {GOLD}{CURRENCY_LONG}{BLACK}) STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Вес: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT}) STR_PURCHASE_INFO_COST_SPEED :{BLACK}Цена: {GOLD}{CURRENCY_LONG}{BLACK} Скорость: {GOLD}{VELOCITY} +STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Цена: {GOLD}{CURRENCY_LONG}{BLACK} (Стоимость переоборудования: {GOLD}{CURRENCY_LONG}{BLACK}) Скорость: {GOLD}{VELOCITY} STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Ёмкость: {GOLD}{CARGO_LONG}, {CARGO_LONG} STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Ведущие вагоны: {GOLD}+{POWER}{BLACK} Вес: {GOLD}+{WEIGHT_SHORT} STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Может перевозить: {GOLD}{STRING} @@ -3690,10 +3692,20 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Купи STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Купить STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Купить -STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Купить выбранный локомотив/вагон. Shift+щелчок - оценка стоимости покупки. -STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Купить выбранный автомобиль. Shift+щелчок - оценка стоимости покупки. -STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Купить выбранный корабль. Shift+щелчок - оценка стоимости покупки. -STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Купить выбранный авиатранспорт. Shift+щелчок - оценка стоимости покупки. +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Купить и переоборудовать +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Купить и переоборудовать +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Купить и переоборудовать +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_BUTTON :{BLACK}Купить и переоборудовать + +STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Приобрести выбранный локомотив/вагон. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Приобрести выбранный автомобиль. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Приобрести выбранное судно. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Приобрести выбранное воздушное судно. Shift+щелчок покажет ориентировочную стоимость покупки. + +STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Приобрести и переоборудовать выбранный локомотив/вагон. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Приобрести и переоборудовать выбранный автомобиль. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Приобрести и переоборудовать выбранное судно. Shift+щелчок покажет ориентировочную стоимость покупки. +STR_BUY_VEHICLE_AIRCRAFT_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Приобрести и переоборудовать выбранное воздушное судно. Shift+щелчок покажет ориентировочную стоимость покупки. STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Переименовать STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Переименовать diff --git a/src/lang/serbian.txt b/src/lang/serbian.txt index d386d3f7a1..e5b14421c2 100644 --- a/src/lang/serbian.txt +++ b/src/lang/serbian.txt @@ -1891,7 +1891,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Suparnici STR_CONFIG_SETTING_AI_NPC :{ORANGE}Računar -STR_CONFIG_SETTING_PATHFINDER_OPF :Originalno STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Preporučuje se) @@ -1974,7 +1973,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3607,11 +3605,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kupi Voz STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kupi Brod STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kupi Letelicu + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kupuje označeno šinsko vozilo. Shift+Klik prikazuje procenu troškova bez kupovine STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kupuje označeno drumsko vozilo. Shift+Klik prikazuje procenu troškova bez kupovine STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kupuje označeni brod. Shift+Klik prikazuje procenu troškova bez kupovine STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kupuje označenu letilicu. Shift+Klik prikazuje procenu troškova bez kupovine + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Preimenuj STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Promena naziva STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Preimenuj diff --git a/src/lang/simplified_chinese.txt b/src/lang/simplified_chinese.txt index b9e4aefa59..ce263e5335 100644 --- a/src/lang/simplified_chinese.txt +++ b/src/lang/simplified_chinese.txt @@ -1694,7 +1694,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}货物 STR_CONFIG_SETTING_AI :{ORANGE}竞争 STR_CONFIG_SETTING_AI_NPC :{ORANGE}电脑玩家 -STR_CONFIG_SETTING_PATHFINDER_OPF :原始的 STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(推荐) @@ -1777,7 +1776,6 @@ STR_QUIT_NO :{BLACK}否 # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3420,11 +3418,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}购买 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}购买船只 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}购买飞机 + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}购买选定的列车,按住 Shift 键单击可以显示所需资金 STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}购买选定的汽车,按住 Shift 键单击可以显示所需资金 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}购买选定的船只,按住 Shift 键单击可以显示所需资金 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}购买选定的飞机,按住 Shift 键单击可以显示所需资金 + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}重命名 STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}重命名 STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}重命名 diff --git a/src/lang/slovak.txt b/src/lang/slovak.txt index 5fb50eba1e..f1291958eb 100644 --- a/src/lang/slovak.txt +++ b/src/lang/slovak.txt @@ -1752,7 +1752,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Konkurenti STR_CONFIG_SETTING_AI_NPC :{ORANGE}Počítačový hráči -STR_CONFIG_SETTING_PATHFINDER_OPF :Pôvodný STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(odporučený) @@ -1835,7 +1834,6 @@ STR_QUIT_NO :{BLACK}Nie # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3456,11 +3454,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kúpiť STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kúpiť loď STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kúpiť lietadlo + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kúpiť vybraný vlak. Shift+klik zobrazí predpokladanú cenu bez nákupu. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kúpiť vybrané vozidlo. Shift+klik zobrazí predpokladanú cenu bez nákupu STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kúpiť vybranú loď. Shift+klik zobrazí predpokladanú cenu bez nákupu STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kúpiť vybrané lietadlo. Shift+klik zobrazí predpokladanú cenu bez nákupu + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Premenovať STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Premenovať STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Premenovať diff --git a/src/lang/slovenian.txt b/src/lang/slovenian.txt index 5ad9581ef3..aee22e5ddf 100644 --- a/src/lang/slovenian.txt +++ b/src/lang/slovenian.txt @@ -1838,7 +1838,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Razpore STR_CONFIG_SETTING_AI :{ORANGE}Tekmeci STR_CONFIG_SETTING_AI_NPC :{ORANGE}Računalniški igralci -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Priporočeno) @@ -1921,7 +1920,6 @@ STR_QUIT_NO :{BLACK}Ne # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3542,11 +3540,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Kupi voz STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Kupi ladjo STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Kupi letalo + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi izbrano železniško vozilo. Shift+Klik prikaže predviden strošek brez nakupa STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi izbrano cestno vozilo. Shift+Klik prikaže predviden strošek brez nakupa STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi izbrano ladjo. Shift+Klik prikaže predviden strošek brez nakupa STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Kupi izbrano letalo. Shift+Klik prikaže predviden strošek brez nakupa + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Preimenuj STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Preimenuj STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Preimenuj diff --git a/src/lang/spanish.txt b/src/lang/spanish.txt index 47fb4ac8de..af303eb7ba 100644 --- a/src/lang/spanish.txt +++ b/src/lang/spanish.txt @@ -1696,7 +1696,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Competidores STR_CONFIG_SETTING_AI_NPC :{ORANGE}Jugadores de la CPU (IA) -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recomendado) @@ -1780,7 +1779,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3447,11 +3445,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Comprar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Comprar barco STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Comprar aeronave + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Compra el vehículo de ferrocarril resaltado. Shift+Click muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar el vehículo de carretera resaltado. Shift+Click muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar el barco resaltado. Shift+Click muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar la aeronave resaltada. Shift+Click muestra una estimación del precio sin realizar la compra + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Renombrar STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Renombrar STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Renombrar diff --git a/src/lang/spanish_MX.txt b/src/lang/spanish_MX.txt index b7959abeab..fda97ae84a 100644 --- a/src/lang/spanish_MX.txt +++ b/src/lang/spanish_MX.txt @@ -1711,7 +1711,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Distrib STR_CONFIG_SETTING_AI :{ORANGE}Competidores STR_CONFIG_SETTING_AI_NPC :{ORANGE}Jugadores no humanos -STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(recomendado) @@ -1795,7 +1794,6 @@ STR_QUIT_NO :{BLACK}No # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2994,7 +2992,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Recursos GRF so STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} fue desactivado por {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Formato de colocación de sprites no válido o desconocido (sprite {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Demasiados elementos en la lista de valores de propiedad (sprite {3:NUM}, property {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Llamada de producción de industria no válida (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Llamada de producción de industria no válida (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}¡Precaución! @@ -3496,11 +3494,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Comprar STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Comprar STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Comprar + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar el tren elegido. Mayús+Clic muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar el vehículo de carretera elegido. Mayús+Clic muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar el barco elegido. Mayús+Clic muestra una estimación del precio sin realizar la compra STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Comprar la aeronave elegida. Mayús+Clic muestra una estimación del precio sin realizar la compra + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Cambiar nombre STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Cambiar nombre STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Cambiar nombre diff --git a/src/lang/swedish.txt b/src/lang/swedish.txt index 129ea02bf0..1aaa168a7b 100644 --- a/src/lang/swedish.txt +++ b/src/lang/swedish.txt @@ -1704,7 +1704,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Godsdis STR_CONFIG_SETTING_AI :{ORANGE}Motståndare STR_CONFIG_SETTING_AI_NPC :{ORANGE}Datorspelare -STR_CONFIG_SETTING_PATHFINDER_OPF :Standard STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Rekommenderad) @@ -1788,7 +1787,6 @@ STR_QUIT_NO :{BLACK}Nej # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2980,7 +2978,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :Efterfrågade G STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} har inaktiverats av {2:STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Felaktigt/okänt layout-format av spriteobjekt (spriteobjekt {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :För många poster i listan med egenskapsvärden (spriteobjekt {3:NUM}, egenskap {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ogiltig industriproduktions-callback (spriteobjekt {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Ogiltig industriproduktions-callback (spriteobjekt {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Varning! @@ -3480,11 +3478,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Köp for STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Köp skepp STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Köp flygplan + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Köp markerad tågvagn. Shift+klick visar kostnad utan att köpa STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Köp markerat vägfordon. Shift+klick visar kostnad utan att köpa STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Köp markerat skepp. Shift+klick visar kostnad utan att köpa STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Köp markerat flygplan. Shift+klick visar kostnad utan att köpa + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Byt namn på STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Byt namn på STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Byt namn på diff --git a/src/lang/tamil.txt b/src/lang/tamil.txt index 21a9663655..6f6daef70b 100644 --- a/src/lang/tamil.txt +++ b/src/lang/tamil.txt @@ -1468,7 +1468,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}சர STR_CONFIG_SETTING_AI :{ORANGE}போட்டியாளர்கள் STR_CONFIG_SETTING_AI_NPC :{ORANGE}கணினி வீரர்கள் -STR_CONFIG_SETTING_PATHFINDER_OPF :அசல் STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(பரிந்துரைக்கப்பட்டது) @@ -1537,7 +1536,6 @@ STR_QUIT_NO :{BLACK}இல # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3007,11 +3005,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}வா STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}கப்பலை வாங்கு STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}விமானத்தை வாங்கு + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}காட்டப்படும் இரயில் வாகனத்தை வாங்கவும். Shift+Click செய்தால் வாங்கும்போது ஆகும் மதிப்பிடப்பட்டச் செலவுகளைக் காட்டு STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}காட்டப்படும் சாலை வாகனத்தை வாங்கவும். Shift+Click செய்தால் வாங்கும்போது ஆகும் மதிப்பிடப்பட்டச் செலவுகளைக் காட்டும் STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}காட்டப்படும் கப்பலை வாங்கவும். Shift+Click செய்தால் வாங்கும்போது ஆகும் மதிப்பிடப்பட்டச் செலவுகளைக் காட்டும் STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}காட்டப்படும் விமானத்தை வாங்கவும். Shift+Click செய்தால் வாங்கும்போது ஆகும் மதிப்பிடப்பட்டச் செலவுகளைக் காட்டும் + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}பெயரிடு STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}பெயரிடு STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}பெயரிடு diff --git a/src/lang/thai.txt b/src/lang/thai.txt index d9332595ba..3121f13a9c 100644 --- a/src/lang/thai.txt +++ b/src/lang/thai.txt @@ -1635,7 +1635,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}กา STR_CONFIG_SETTING_AI :{ORANGE}คู่แข่ง STR_CONFIG_SETTING_AI_NPC :{ORANGE}ผู้เล่นคอมพิวเตอร์ -STR_CONFIG_SETTING_PATHFINDER_OPF :ดั้งเดิม STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(แนะนำ) @@ -1718,7 +1717,6 @@ STR_QUIT_NO :{BLACK}ไม # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :ระบบปฏิบัติการ Haiku @@ -3318,11 +3316,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}ซื STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}ซื้อเรือ STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}ซื้อเครื่องบิน + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}ซื้อรถไฟที่เลือกไว้ เมื่อกด Shift+คลิกเมาส์ จะแสดงมูลค่าโดยประมาณโดยไม่ทำการซื้อ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}ซื้อรถที่เลือกไว้ เมื่อกด Shift+คลิกเมาส์ จะแสดงมูลค่าโดยประมาณโดยไม่ทำการซื้อ STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}ซื้อเรือที่เลือกไว้ เมื่อกด Shift+คลิกเมาส์ จะแสดงมูลค่าโดยประมาณโดยไม่ทำการซื้อ STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}ซื้อเครื่องบินที่เลือกไว้ เมื่อกด Shift+คลิกเมาส์ จะแสดงมูลค่าโดยประมาณโดยไม่ทำการซื้อ + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}เปลี่ยนชื่อ STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}เปลี่ยนชื่อ STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}เปลี่ยนชื่อ diff --git a/src/lang/traditional_chinese.txt b/src/lang/traditional_chinese.txt index cea370e736..da510803c0 100644 --- a/src/lang/traditional_chinese.txt +++ b/src/lang/traditional_chinese.txt @@ -1684,7 +1684,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}貨物 STR_CONFIG_SETTING_AI :{ORANGE}競爭對手 STR_CONFIG_SETTING_AI_NPC :{ORANGE}電腦玩家 -STR_CONFIG_SETTING_PATHFINDER_OPF :預設 STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(建議) @@ -1767,7 +1766,6 @@ STR_QUIT_NO :{BLACK}否 # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3388,11 +3386,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}購買 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}購買船舶 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}購買飛機 + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}購買選定的列車。按住 Shift 點選則只會顯示預估的購買費用 STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}購買選定的車輛。按住 Shift 點選則只會顯示預估的購買費用 STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}購買選定的船舶。按住 Shift 點選則只會顯示預估的購買費用 STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}購買選定的飛機。按住 Shift 點選則只會顯示預估的購買費用 + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}重新命名 STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}重新命名 STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}重新命名 diff --git a/src/lang/turkish.txt b/src/lang/turkish.txt index 329c2b80f4..5139523bd2 100644 --- a/src/lang/turkish.txt +++ b/src/lang/turkish.txt @@ -1709,7 +1709,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Kargo d STR_CONFIG_SETTING_AI :{ORANGE}Rakipler STR_CONFIG_SETTING_AI_NPC :{ORANGE}Bilgisayar oyuncuları -STR_CONFIG_SETTING_PATHFINDER_OPF :Özgün STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Önerilen) @@ -1793,7 +1792,6 @@ STR_QUIT_NO :{BLACK}Hayır # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2987,7 +2985,7 @@ STR_NEWGRF_ERROR_GRM_FAILED :İstenen GRF ka STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} {STRING} tarafından deaktive edildi STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Geçersiz/bilinmeyen nesne yerleşim biçimi (nesne {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Özellik değeri listesinde çok fazla öğe (sprite {3:NUM}, özellik {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Geçersiz endüstri üretim geri çağrımı (sprite {3:NUM}, "{1:STRING}") +STR_NEWGRF_ERROR_INDPROD_CALLBACK :Geçersiz endüstri üretim geri çağrımı (sprite {3:NUM}, "{2:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Uyarı! @@ -3489,11 +3487,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Araç Sa STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Gemi Satın Al STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Uçak Satın Al + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Seçili treni satın al. Shift ile tıklama satın almadan tahmini maliyeti gösterir. STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}İşaretli aracı al. Shift ile tıklama satın almadan tahmini maliyeti gösterir STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Seçili gemiyi satın al. Shift ile tıklama satın almadan tahmini maliyeti gösterir STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Seçili uçağı satın al. Shift ile tıklama satın almadan tahmini maliyeti gösterir + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Yeni isim STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}İsim STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}İsim diff --git a/src/lang/ukrainian.txt b/src/lang/ukrainian.txt index dcb381b495..f664b8180d 100644 --- a/src/lang/ukrainian.txt +++ b/src/lang/ukrainian.txt @@ -1844,7 +1844,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Роз STR_CONFIG_SETTING_AI :{ORANGE}Конкуренти STR_CONFIG_SETTING_AI_NPC :{ORANGE}Віртуальні гравці -STR_CONFIG_SETTING_PATHFINDER_OPF :стандартний STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(рекомендовано) @@ -1928,7 +1927,6 @@ STR_QUIT_NO :{BLACK}Ні # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3130,7 +3128,6 @@ STR_NEWGRF_ERROR_GRM_FAILED :Недосту STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:STRING} був вимкнений {STRING} STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Некоректний або невідомий формат розміщення спрайтів (спрайт {3:NUM}) STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG :Дуже багато елементів у списку значень (спрайт {3:NUM}, властивість {4:HEX}) -STR_NEWGRF_ERROR_INDPROD_CALLBACK :Невірна обробка продукції підприємства (спрайт {3:NUM}, "{1:STRING}") # NewGRF related 'general' warnings STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Обережно! @@ -3632,11 +3629,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Купи STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Купити STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Купити + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Купити вибраний поїзд. Утримуйте Shift для показу витрат на придбання STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Купити вибране авто. Утримуйте Shift для показу витрат на придбання STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Купити вибраний корабель. Утримуйте Shift для показу витрат на придбання STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Купити вибраний літак. Утримуйте Shift для показу витрат на придбання + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Назва STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Зміна назви STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Зміна назви diff --git a/src/lang/unfinished/chuvash.txt b/src/lang/unfinished/chuvash.txt index 8d93f19360..e7b0adbda5 100644 --- a/src/lang/unfinished/chuvash.txt +++ b/src/lang/unfinished/chuvash.txt @@ -662,7 +662,6 @@ STR_QUIT_NO :{BLACK}Ҫук # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -1148,6 +1147,8 @@ STR_INDUSTRY_DIRECTORY_NONE :{ORANGE}- Ҫу + + # Depot window STR_DEPOT_CAPTION :{WHITE}{DEPOT} diff --git a/src/lang/unfinished/frisian.txt b/src/lang/unfinished/frisian.txt index 2c399a5208..8b02042810 100644 --- a/src/lang/unfinished/frisian.txt +++ b/src/lang/unfinished/frisian.txt @@ -1635,7 +1635,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Frachtd STR_CONFIG_SETTING_AI :{ORANGE}Tsjinstânners STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computer spilers -STR_CONFIG_SETTING_PATHFINDER_OPF :Orizjiniel STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -1701,7 +1700,6 @@ STR_QUIT_NO :{BLACK}Nee # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3117,11 +3115,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Keapje a STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Keapje boat STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Keapje fleantúg + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Keapje ferljochte trein STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Keapje ferljochte auto STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Keapje ferljochte boat STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Keapje ferljochte fleantúg + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Jow in nije namme STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Jow in nije namme STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Jow in nije namme diff --git a/src/lang/unfinished/ido.txt b/src/lang/unfinished/ido.txt index dcc3027782..f850fc769a 100644 --- a/src/lang/unfinished/ido.txt +++ b/src/lang/unfinished/ido.txt @@ -985,6 +985,8 @@ STR_GROUP_DEFAULT_AIRCRAFTS :Negrupigita aer + + # Depot window STR_DEPOT_CAPTION :{WHITE}{DEPOT} diff --git a/src/lang/unfinished/macedonian.txt b/src/lang/unfinished/macedonian.txt index b25ee84b06..b927c74a82 100644 --- a/src/lang/unfinished/macedonian.txt +++ b/src/lang/unfinished/macedonian.txt @@ -1459,8 +1459,10 @@ STR_BUY_VEHICLE_AIRCRAFT_LIST_TOOLTIP :{BLACK}Лист STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Направи авион + STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Направи авион од селектираниот тип + STR_BUY_VEHICLE_AIRCRAFT_RENAME_BUTTON :{BLACK}Преименувај STR_BUY_VEHICLE_AIRCRAFT_RENAME_TOOLTIP :{BLACK}Преименувај го типот на авиони diff --git a/src/lang/unfinished/maltese.txt b/src/lang/unfinished/maltese.txt index f25027744e..f66ee02a6d 100644 --- a/src/lang/unfinished/maltese.txt +++ b/src/lang/unfinished/maltese.txt @@ -857,6 +857,8 @@ STR_FINANCES_POSITIVE_INCOME :{BLACK}+{CURREN + + # Depot window STR_DEPOT_CAPTION :{WHITE}{DEPOT} diff --git a/src/lang/unfinished/marathi.txt b/src/lang/unfinished/marathi.txt index cfc34dcc4b..a79303bcbf 100644 --- a/src/lang/unfinished/marathi.txt +++ b/src/lang/unfinished/marathi.txt @@ -1330,6 +1330,8 @@ STR_PURCHASE_INFO_COST_SPEED :{BLACK}कि + + # Depot window STR_DEPOT_CAPTION :{WHITE}{DEPOT} diff --git a/src/lang/unfinished/persian.txt b/src/lang/unfinished/persian.txt index 2259c5160a..548be517dc 100644 --- a/src/lang/unfinished/persian.txt +++ b/src/lang/unfinished/persian.txt @@ -1414,7 +1414,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}توز STR_CONFIG_SETTING_AI :{ORANGE}رقیبان STR_CONFIG_SETTING_AI_NPC :{ORANGE}بازیگران رایانه -STR_CONFIG_SETTING_PATHFINDER_OPF :اصلی STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(توصیه می گردد) @@ -1484,7 +1483,6 @@ STR_QUIT_NO :{BLACK}خیر # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :هایکو @@ -2961,10 +2959,12 @@ STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON :{BLACK}ساخت STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}خرید وسیله نقلیه STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}خرید هواپیما + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}خرید قطار مشخص شده. Shift+Click کنید تا قبل از خرید، مبلغ تقریبی آنرا نمایش دهد STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}خرید کشتی مشخص شده . Shift+Click کنید تا هزینه تقریبی نمایش داده شود STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}خرید هواپیمای مشخص شده. برای مشاهده هزینه تقریبی Shift+Click کنید + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}تغییر نام STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}تغییر نام STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}نام گذاری مجدد diff --git a/src/lang/unfinished/urdu.txt b/src/lang/unfinished/urdu.txt index c0f94b9b5a..9b833bb963 100644 --- a/src/lang/unfinished/urdu.txt +++ b/src/lang/unfinished/urdu.txt @@ -1311,7 +1311,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}صنع STR_CONFIG_SETTING_AI :{ORANGE}مد مقابل STR_CONFIG_SETTING_AI_NPC :{ORANGE}کمپیوٹر کے کھلاڑی -STR_CONFIG_SETTING_PATHFINDER_OPF :اصلی STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Recommended) @@ -1381,7 +1380,6 @@ STR_QUIT_NO :{BLACK}نہیں # Supported OSes STR_OSNAME_WINDOWS :ونڈوز -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :یونیکس STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -2356,6 +2354,8 @@ STR_PURCHASE_INFO_AIRCRAFT_RANGE :{BLACK}پہنچ + + STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON :{BLACK}چهپایں STR_BUY_VEHICLE_ROAD_VEHICLE_HIDE_TOGGLE_BUTTON :{BLACK}چهپایں STR_BUY_VEHICLE_SHIP_HIDE_TOGGLE_BUTTON :{BLACK}چهپایں diff --git a/src/lang/vietnamese.txt b/src/lang/vietnamese.txt index e2882ed865..8c034abb37 100644 --- a/src/lang/vietnamese.txt +++ b/src/lang/vietnamese.txt @@ -1699,7 +1699,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Phân b STR_CONFIG_SETTING_AI :{ORANGE}Đối Thủ STR_CONFIG_SETTING_AI_NPC :{ORANGE}Nhân vật máy -STR_CONFIG_SETTING_PATHFINDER_OPF :Nguyên bản STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Nên dùng) @@ -1783,7 +1782,6 @@ STR_QUIT_NO :{BLACK}Không # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3459,11 +3457,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Mua P.Ti STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Mua tàu STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Mua Máy Bay + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Mua tàu hỏa đã ấn định. Shift+Click để xem giá mua dự tính STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Mua xe đã ấn định. Shift+Click để xem giá mua dự tính STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Mua tàu đã ấn định. Shift+Click để xem giá mua dự tính STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Mua máy bay đã ấn định. Shift+Click để xem giá mua dự tính + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Thay tên STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Thay tên STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Thay tên diff --git a/src/lang/welsh.txt b/src/lang/welsh.txt index 3a4a8c2b50..81873bc718 100644 --- a/src/lang/welsh.txt +++ b/src/lang/welsh.txt @@ -1686,7 +1686,6 @@ STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Dosrani STR_CONFIG_SETTING_AI :{ORANGE}Cystadleuwyr STR_CONFIG_SETTING_AI_NPC :{ORANGE}Chwaraewyr Cyfrifiadurol -STR_CONFIG_SETTING_PATHFINDER_OPF :Gwreiddiol STR_CONFIG_SETTING_PATHFINDER_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_YAPF_RECOMMENDED :YAPF {BLUE}(Argymellir) @@ -1770,7 +1769,6 @@ STR_QUIT_NO :{BLACK}Na # Supported OSes STR_OSNAME_WINDOWS :Windows -STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS{NBSP}X STR_OSNAME_HAIKU :Haiku @@ -3400,11 +3398,13 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Prynu Ce STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_BUTTON :{BLACK}Prynu Llong STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_BUTTON :{BLACK}Prynu Awyren + STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP :{BLACK}Adeiladu'r cerbyd trên sydd wedi'i amlygu. Mae Shift+Clic yn dangos amcangyfrif o'r gost STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Adeiladu'r cerbyd ffordd sydd wedi'i amlygu. Mae Shift+Clic yn dangos amcangyfrif o'r gost STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Adeiladu'r llong sydd wedi'i hamlygu. Mae Shift+Clic yn dfangos amcangyfrif o'r gost STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Adeiladu'r awyren sydd wedi'i hamlygu. Mae Shift+Clic yn dangos amcangyfrif o'r gost + STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Ailenwi STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Ailenwi STR_BUY_VEHICLE_SHIP_RENAME_BUTTON :{BLACK}Ailenwi diff --git a/src/language.h b/src/language.h index 8df59f74ff..be2d37084b 100644 --- a/src/language.h +++ b/src/language.h @@ -96,7 +96,7 @@ struct LanguageMetadata : public LanguagePackHeader { }; /** Type for the list of language meta data. */ -typedef SmallVector LanguageList; +typedef std::vector LanguageList; /** The actual list of language meta data. */ extern LanguageList _languages; diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp index 34b3a4aa09..d8cbf9b50a 100644 --- a/src/linkgraph/linkgraph.cpp +++ b/src/linkgraph/linkgraph.cpp @@ -139,7 +139,7 @@ void LinkGraph::RemoveNode(NodeID id) node_edges[id] = node_edges[last_node]; } Station::Get(this->nodes[last_node].station)->goods[this->cargo].node = id; - this->nodes.Erase(this->nodes.Get(id)); + this->nodes.erase(this->nodes.begin() + id); this->edges.EraseColumn(id); /* Not doing EraseRow here, as having the extra invalid row doesn't hurt * and removing it would trigger a lot of memmove. The data has already @@ -159,7 +159,7 @@ NodeID LinkGraph::AddNode(const Station *st) const GoodsEntry &good = st->goods[this->cargo]; NodeID new_node = this->Size(); - this->nodes.Append(); + this->nodes.emplace_back(); /* Avoid reducing the height of the matrix as that is expensive and we * most likely will increase it again later which is again expensive. */ this->edges.Resize(new_node + 1U, @@ -281,7 +281,7 @@ void LinkGraph::Init(uint size) { assert(this->Size() == 0); this->edges.Resize(size, size); - this->nodes.Resize(size); + this->nodes.resize(size); for (uint i = 0; i < size; ++i) { this->nodes[i].Init(); diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 2d19fd574f..8d600b3bce 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -436,7 +436,7 @@ public: void RemoveEdge(NodeID to); }; - typedef SmallVector NodeVector; + typedef std::vector NodeVector; typedef SmallMatrix EdgeMatrix; /** Minimum effective distance for timeout calculation. */ @@ -497,7 +497,7 @@ public: * Get the current size of the component. * @return Size. */ - inline uint Size() const { return this->nodes.Length(); } + inline uint Size() const { return this->nodes.size(); } /** * Get date of last compression. diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 168c2e08be..d80acc02df 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -664,7 +664,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const } } -bool LinkGraphLegendWindow::OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond) +bool LinkGraphLegendWindow::OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) { if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { if (this->IsWidgetDisabled(widget)) { @@ -689,19 +689,6 @@ bool LinkGraphLegendWindow::OnHoverCommon(Point pt, int widget, TooltipCloseCond return false; } -void LinkGraphLegendWindow::OnHover(Point pt, int widget) -{ - this->OnHoverCommon(pt, widget, TCC_HOVER); -} - -bool LinkGraphLegendWindow::OnRightClick(Point pt, int widget) -{ - if (_settings_client.gui.hover_delay_ms == 0) { - return this->OnHoverCommon(pt, widget, TCC_RIGHT_CLICK); - } - return false; -} - /** * Update the overlay with the new company selection. */ diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index c6bda77284..17383e0e22 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -120,19 +120,17 @@ public: LinkGraphLegendWindow(WindowDesc *desc, int window_number); void SetOverlay(LinkGraphOverlay *overlay); - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize); - virtual void DrawWidget(const Rect &r, int widget) const; - virtual void OnHover(Point pt, int widget) override; - virtual bool OnRightClick(Point pt, int widget) override; - virtual void OnClick(Point pt, int widget, int click_count); - virtual void OnInvalidateData(int data = 0, bool gui_scope = true); + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override; + void DrawWidget(const Rect &r, int widget) const override; + bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override; + void OnClick(Point pt, int widget, int click_count) override; + void OnInvalidateData(int data = 0, bool gui_scope = true) override; private: LinkGraphOverlay *overlay; void UpdateOverlayCompanies(); void UpdateOverlayCargoes(); - bool OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond); }; #endif /* LINKGRAPH_GUI_H */ diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 66319c92a2..eb973c9ed1 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -50,7 +50,6 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { -#ifdef ENABLE_NETWORK if (result.Failed() || !_settings_game.economy.give_money || !_networking) return; /* Inform the company of the action of one of its clients (controllers). */ @@ -69,7 +68,6 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 } else { NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_BROADCAST_SS, p2, msg, CLIENT_ID_SERVER, NetworkTextMessageData(p1, auxdata)); } -#endif /* ENABLE_NETWORK */ } /** @@ -233,7 +231,7 @@ struct MainWindow : Window this->refresh.SetInterval(LINKGRAPH_DELAY); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (!this->refresh.Elapsed(delta_ms)) return; @@ -248,7 +246,7 @@ struct MainWindow : Window this->GetWidget(WID_M_VIEWPORT)->SetDirty(this); } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); if (_game_mode == GM_MENU) { @@ -268,7 +266,7 @@ struct MainWindow : Window } } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { if (hotkey == GHK_QUIT) { HandleExitGameRequest(); @@ -374,7 +372,6 @@ struct MainWindow : Window ResetRestoreAllTransparency(); break; -#ifdef ENABLE_NETWORK case GHK_CHAT: // smart chat; send to team if any, otherwise to all if (_networking) { const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id); @@ -402,7 +399,6 @@ struct MainWindow : Window ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, CLIENT_ID_SERVER); } break; -#endif case GHK_CHANGE_MAP_MODE_PREV: if (_focused_window && _focused_window->viewport && _focused_window->viewport->zoom >= ZOOM_LVL_DRAW_MAP) { @@ -428,7 +424,7 @@ struct MainWindow : Window return ES_HANDLED; } - virtual void OnScroll(Point delta) + void OnScroll(Point delta) override { this->viewport->scrollpos_x += ScaleByZoom(delta.x, this->viewport->zoom); this->viewport->scrollpos_y += ScaleByZoom(delta.y, this->viewport->zoom); @@ -437,7 +433,7 @@ struct MainWindow : Window this->refresh.SetInterval(LINKGRAPH_DELAY); } - virtual void OnMouseWheel(int wheel) + void OnMouseWheel(int wheel) override { if (_ctrl_pressed) { /* Cycle through the drawing modes */ @@ -448,7 +444,7 @@ struct MainWindow : Window } } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_M_VIEWPORT); @@ -462,7 +458,7 @@ struct MainWindow : 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; /* Forward the message to the appropriate toolbar (ingame or scenario editor) */ @@ -526,12 +522,10 @@ static Hotkey global_hotkeys[] = { Hotkey('8' | WKC_CTRL | WKC_SHIFT, "invisibility_catenary", GHK_TOGGLE_INVISIBILITY + 7), Hotkey('X' | WKC_CTRL, "transparency_toolbar", GHK_TRANSPARENCY_TOOLBAR), Hotkey('X', "toggle_transparency", GHK_TRANSPARANCY), -#ifdef ENABLE_NETWORK Hotkey(_ghk_chat_keys, "chat", GHK_CHAT), Hotkey(_ghk_chat_all_keys, "chat_all", GHK_CHAT_ALL), Hotkey(_ghk_chat_company_keys, "chat_company", GHK_CHAT_COMPANY), Hotkey(_ghk_chat_server_keys, "chat_server", GHK_CHAT_SERVER), -#endif Hotkey(WKC_PAGEUP, "previous_map_mode", GHK_CHANGE_MAP_MODE_PREV), Hotkey(WKC_PAGEDOWN, "next_map_mode", GHK_CHANGE_MAP_MODE_NEXT), HOTKEY_LIST_END diff --git a/src/misc.cpp b/src/misc.cpp index 98d8955825..5cee807ffc 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -132,9 +132,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin InitializeCheats(); InitTextEffects(); -#ifdef ENABLE_NETWORK NetworkInitChatMessage(); -#endif /* ENABLE_NETWORK */ InitializeAnimatedTiles(); InitializeEconomy(); diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index 736715cbf5..8fe18e0a74 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -155,12 +155,10 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, case PM_PAUSED_LINK_GRAPH: break; -#ifdef ENABLE_NETWORK case PM_PAUSED_JOIN: case PM_PAUSED_ACTIVE_CLIENTS: if (!_networking) return CMD_ERROR; break; -#endif /* ENABLE_NETWORK */ default: return CMD_ERROR; } @@ -173,9 +171,7 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, AskUnsafeUnpauseCallback ); } else { -#ifdef ENABLE_NETWORK PauseMode prev_mode = _pause_mode; -#endif /* ENABLE_NETWORK */ if (p2 == 0) { _pause_mode = _pause_mode & ~p1; @@ -183,9 +179,7 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, _pause_mode = _pause_mode | p1; } -#ifdef ENABLE_NETWORK NetworkHandlePauseChange(prev_mode, (PauseMode)p1); -#endif /* ENABLE_NETWORK */ } SetWindowDirty(WC_STATUS_BAR, 0); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 062ac8e0a5..af22562393 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -74,7 +74,7 @@ public: char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE]; TileIndex tile; - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_LI_BACKGROUND) return; @@ -93,7 +93,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 { if (widget != WID_LI_BACKGROUND) return; @@ -146,7 +146,7 @@ public: #undef LANDINFOD_LEVEL } - virtual void OnInit() + void OnInit() override { Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); @@ -354,12 +354,12 @@ public: if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0'; } - virtual bool IsNewGRFInspectable() const + bool IsNewGRFInspectable() const override { return ::IsNewGRFInspectable(GetGrfSpecFeature(this->tile), this->tile); } - virtual void ShowNewGRFInspectWindow() const + void ShowNewGRFInspectWindow() const override { ::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile); } @@ -369,7 +369,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; switch (data) { @@ -501,14 +501,14 @@ struct AboutWindow : public Window { this->timer.SetInterval(TIMER_INTERVAL); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_A_WEBSITE) SetDParamStr(0, "Main project website: http://www.openttd.org"); if (widget == WID_A_WEBSITE1) SetDParamStr(0, "Patchpack thread: https://www.tt-forums.net/viewtopic.php?f=33&t=73469"); if (widget == WID_A_WEBSITE2) SetDParamStr(0, "Patchpack Github: https://github.com/JGRennison/OpenTTD-patches"); } - 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_A_SCROLLING_TEXT) return; @@ -524,7 +524,7 @@ struct AboutWindow : public Window { *size = maxdim(*size, d); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -539,7 +539,7 @@ struct AboutWindow : public Window { } } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { uint count = this->timer.CountElapsed(delta_ms); if (count > 0) { @@ -711,7 +711,7 @@ struct TooltipsWindow : public Window CLRBITS(this->flags, WF_WHITE_BORDER); } - virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) + Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override { /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. * Add a fixed distance 2 so the tooltip floats free from both bars. @@ -731,7 +731,7 @@ struct TooltipsWindow : public Window return pt; } - 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 { /* There is only one widget. */ for (uint i = 0; i != this->paramcount; i++) SetDParam(i, this->params[i]); @@ -744,7 +744,7 @@ struct TooltipsWindow : public Window size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { /* There is only one widget. */ GfxFillRect(r.left, r.top, r.right, r.bottom, PC_BLACK); @@ -760,7 +760,7 @@ struct TooltipsWindow : public Window } } - virtual void OnMouseLoop() + void OnMouseLoop() override { /* Always close tooltips when the cursor is not in our window. */ if (!_cursor.in_window || this->delete_next_mouse_loop) { @@ -772,8 +772,8 @@ struct TooltipsWindow : public Window * we are dragging the tool. Normal tooltips work with hover or rmb. */ switch (this->close_cond) { case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break; - case TCC_LEFT_CLICK: if (!_left_button_down) delete this; break; case TCC_HOVER: if (!_mouse_hovering) delete this; break; + case TCC_NONE: break; case TCC_NEXT_LOOP: this->delete_next_mouse_loop = true; break; case TCC_HOVER_VIEWPORT: @@ -1037,7 +1037,7 @@ struct QueryStringWindow : public Window this->SetFocusedWidget(WID_QS_TEXT); } - 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_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { /* We don't want this widget to show! */ @@ -1047,7 +1047,7 @@ struct QueryStringWindow : public Window } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_QS_CAPTION) SetDParam(0, this->editbox.caption); } @@ -1066,7 +1066,7 @@ struct QueryStringWindow : public Window } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_QS_DEFAULT: @@ -1161,7 +1161,7 @@ struct QueryWindow : public Window { if (this->proc != NULL) this->proc(this->parent, false); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_Q_CAPTION: @@ -1175,7 +1175,7 @@ struct QueryWindow : 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_Q_TEXT) return; @@ -1185,7 +1185,7 @@ struct QueryWindow : public Window { *size = d; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_Q_TEXT) return; @@ -1193,7 +1193,7 @@ struct QueryWindow : public Window { this->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_Q_YES: { @@ -1216,7 +1216,7 @@ struct QueryWindow : public Window { } } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { /* ESC closes the window, Enter confirms the action */ switch (keycode) { diff --git a/src/music/allegro_m.h b/src/music/allegro_m.h index 65d8ab811d..9451162a21 100644 --- a/src/music/allegro_m.h +++ b/src/music/allegro_m.h @@ -17,18 +17,18 @@ /** Allegro's music player. */ class MusicDriver_Allegro : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "allegro"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "allegro"; } }; /** Factory for allegro's music player. */ @@ -43,7 +43,7 @@ public: static const int PRIORITY = 2; #endif FMusicDriver_Allegro() : DriverFactoryBase(Driver::DT_MUSIC, PRIORITY, "allegro", "Allegro MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Allegro(); } + Driver *CreateInstance() const override { return new MusicDriver_Allegro(); } }; #endif /* MUSIC_ALLEGRO_H */ diff --git a/src/music/bemidi.h b/src/music/bemidi.h index 7c546525d2..8591ec0159 100644 --- a/src/music/bemidi.h +++ b/src/music/bemidi.h @@ -17,25 +17,25 @@ /** The midi player for BeOS. */ class MusicDriver_BeMidi : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "bemidi"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "bemidi"; } }; /** Factory for the BeOS midi player. */ class FMusicDriver_BeMidi : public DriverFactoryBase { public: FMusicDriver_BeMidi() : DriverFactoryBase(Driver::DT_MUSIC, 10, "bemidi", "BeOS MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_BeMidi(); } + Driver *CreateInstance() const override { return new MusicDriver_BeMidi(); } }; #endif /* MUSIC_BEMIDI_H */ diff --git a/src/music/cocoa_m.h b/src/music/cocoa_m.h index fdb10b84e6..7694927993 100644 --- a/src/music/cocoa_m.h +++ b/src/music/cocoa_m.h @@ -16,24 +16,24 @@ class MusicDriver_Cocoa : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "cocoa"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "cocoa"; } }; class FMusicDriver_Cocoa : public DriverFactoryBase { public: FMusicDriver_Cocoa() : DriverFactoryBase(Driver::DT_MUSIC, 10, "cocoa", "Cocoa MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Cocoa(); } + Driver *CreateInstance() const override { return new MusicDriver_Cocoa(); } }; #endif /* MUSIC_MACOSX_COCOA_H */ diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index fece709fda..241ab191bf 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -686,7 +686,7 @@ static void MidiThreadProc(void *) size_t preload_bytes = 0; for (size_t bl = 0; bl < current_file.blocks.size(); bl++) { MidiFile::DataBlock &block = current_file.blocks[bl]; - preload_bytes += block.data.Length(); + preload_bytes += block.data.size(); if (block.ticktime >= current_segment.start) { if (current_segment.loop) { DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); @@ -751,8 +751,8 @@ static void MidiThreadProc(void *) block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME; DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME)); - byte *data = block.data.Begin(); - size_t remaining = block.data.Length(); + byte *data = block.data.data(); + size_t remaining = block.data.size(); byte last_status = 0; while (remaining > 0) { /* MidiFile ought to have converted everything out of running status, diff --git a/src/music/dmusic.h b/src/music/dmusic.h index 527e064e49..5b363b8917 100644 --- a/src/music/dmusic.h +++ b/src/music/dmusic.h @@ -19,25 +19,25 @@ class MusicDriver_DMusic : public MusicDriver { public: virtual ~MusicDriver_DMusic(); - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "dmusic"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "dmusic"; } }; /** Factory for the DirectX music player. */ class FMusicDriver_DMusic : public DriverFactoryBase { public: FMusicDriver_DMusic() : DriverFactoryBase(Driver::DT_MUSIC, 10, "dmusic", "DirectMusic MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_DMusic(); } + Driver *CreateInstance() const override { return new MusicDriver_DMusic(); } }; #endif /* MUSIC_DMUSIC_H */ diff --git a/src/music/extmidi.h b/src/music/extmidi.h index e174dc9b08..55050c0d2b 100644 --- a/src/music/extmidi.h +++ b/src/music/extmidi.h @@ -24,24 +24,24 @@ private: void DoStop(); public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "extmidi"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "extmidi"; } }; class FMusicDriver_ExtMidi : public DriverFactoryBase { public: FMusicDriver_ExtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 3, "extmidi", "External MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_ExtMidi(); } + Driver *CreateInstance() const override { return new MusicDriver_ExtMidi(); } }; #endif /* MUSIC_EXTERNAL_H */ diff --git a/src/music/fluidsynth.h b/src/music/fluidsynth.h index 171128a8e9..e8a294b77b 100644 --- a/src/music/fluidsynth.h +++ b/src/music/fluidsynth.h @@ -17,25 +17,25 @@ /** Music driver making use of FluidSynth. */ class MusicDriver_FluidSynth : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "fluidsynth"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "fluidsynth"; } }; /** Factory for the fluidsynth driver. */ class FMusicDriver_FluidSynth : public DriverFactoryBase { public: FMusicDriver_FluidSynth() : DriverFactoryBase(Driver::DT_MUSIC, 5, "fluidsynth", "FluidSynth MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_FluidSynth(); } + Driver *CreateInstance() const override { return new MusicDriver_FluidSynth(); } }; #endif /* MUSIC_FLUIDSYNTH_H */ diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index 91f83c529d..97fb2edf80 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -21,7 +21,6 @@ #include "../console_func.h" #include "../console_internal.h" - /* SMF reader based on description at: http://www.somascape.org/midi/tech/mfile.html */ @@ -217,7 +216,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) case MIDIST_CONTROLLER: case MIDIST_PITCHBEND: /* 3 byte messages */ - data = block->data.Append(3); + data = grow(block->data, 3); data[0] = status; if (!chunk.ReadBuffer(&data[1], 2)) { return false; @@ -226,7 +225,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) case MIDIST_PROGCHG: case MIDIST_CHANPRESS: /* 2 byte messages */ - data = block->data.Append(2); + data = grow(block->data, 2); data[0] = status; if (!chunk.ReadByte(data[1])) { return false; @@ -267,7 +266,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) if (!chunk.ReadVariableLength(length)) { return false; } - byte *data = block->data.Append(length + 1); + byte *data = grow(block->data, length + 1); data[0] = 0xF0; if (!chunk.ReadBuffer(data + 1, length)) { return false; @@ -275,7 +274,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) if (data[length] != 0xF7) { /* Engage Casio weirdo mode - convert to normal sysex */ running_sysex = true; - *block->data.Append() = 0xF7; + block->data.push_back(0xF7); } else { running_sysex = false; } @@ -285,7 +284,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) if (!chunk.ReadVariableLength(length)) { return false; } - byte *data = block->data.Append(length); + byte *data = grow(block->data, length); if (!chunk.ReadBuffer(data, length)) { return false; } @@ -330,14 +329,14 @@ static bool FixupMidiData(MidiFile &target) uint32 last_ticktime = 0; for (size_t i = 0; i < target.blocks.size(); i++) { MidiFile::DataBlock &block = target.blocks[i]; - if (block.data.Length() == 0) { + if (block.data.size() == 0) { continue; } else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) { merged_blocks.push_back(block); last_ticktime = block.ticktime; } else { - byte *datadest = merged_blocks.back().data.Append(block.data.Length()); - memcpy(datadest, block.data.Begin(), block.data.Length()); + byte *datadest = grow(merged_blocks.back().data, block.data.size()); + memcpy(datadest, block.data.data(), block.data.size()); } } std::swap(merged_blocks, target.blocks); @@ -508,14 +507,14 @@ struct MpsMachine { static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2) { - *block.data.Append() = b1; - *block.data.Append() = b2; + block.data.push_back(b1); + block.data.push_back(b2); } static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2, byte b3) { - *block.data.Append() = b1; - *block.data.Append() = b2; - *block.data.Append() = b3; + block.data.push_back(b1); + block.data.push_back(b2); + block.data.push_back(b3); } /** @@ -941,8 +940,8 @@ bool MidiFile::WriteSMF(const char *filename) } /* Write each block data command */ - byte *dp = block.data.Begin(); - while (dp < block.data.End()) { + byte *dp = block.data.data(); + while (dp < block.data.data() + block.data.size()) { /* Always zero delta time inside blocks */ if (needtime) { fputc(0, f); diff --git a/src/music/midifile.hpp b/src/music/midifile.hpp index 0016be86ca..4d362a1be2 100644 --- a/src/music/midifile.hpp +++ b/src/music/midifile.hpp @@ -22,9 +22,9 @@ struct MusicSongInfo; struct MidiFile { struct DataBlock { - uint32 ticktime; ///< tick number since start of file this block should be triggered at - uint32 realtime; ///< real-time (microseconds) since start of file this block should be triggered at - SmallVector data; ///< raw midi data contained in block + uint32 ticktime; ///< tick number since start of file this block should be triggered at + uint32 realtime; ///< real-time (microseconds) since start of file this block should be triggered at + std::vector data; ///< raw midi data contained in block DataBlock(uint32 _ticktime = 0) : ticktime(_ticktime) { } }; struct TempoChange { diff --git a/src/music/null_m.h b/src/music/null_m.h index 51e1a06656..837eeb092b 100644 --- a/src/music/null_m.h +++ b/src/music/null_m.h @@ -17,25 +17,25 @@ /** The music player that does nothing. */ class MusicDriver_Null : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param) { return NULL; } + const char *Start(const char * const *param) override { return NULL; } - /* virtual */ void Stop() { } + void Stop() override { } - /* virtual */ void PlaySong(const MusicSongInfo &song) { } + void PlaySong(const MusicSongInfo &song) override { } - /* virtual */ void StopSong() { } + void StopSong() override { } - /* virtual */ bool IsSongPlaying() { return true; } + bool IsSongPlaying() override { return true; } - /* virtual */ void SetVolume(byte vol) { } - /* virtual */ const char *GetName() const { return "null"; } + void SetVolume(byte vol) override { } + const char *GetName() const override { return "null"; } }; /** Factory for the null music player. */ class FMusicDriver_Null : public DriverFactoryBase { public: FMusicDriver_Null() : DriverFactoryBase(Driver::DT_MUSIC, 1, "null", "Null Music Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Null(); } + Driver *CreateInstance() const override { return new MusicDriver_Null(); } }; #endif /* MUSIC_NULL_H */ diff --git a/src/music/os2_m.h b/src/music/os2_m.h index ac7cd03197..e320946edb 100644 --- a/src/music/os2_m.h +++ b/src/music/os2_m.h @@ -17,25 +17,25 @@ /** OS/2's music player. */ class MusicDriver_OS2 : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "os2"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "os2"; } }; /** Factory for OS/2's music player. */ class FMusicDriver_OS2 : public DriverFactoryBase { public: FMusicDriver_OS2() : DriverFactoryBase(Driver::DT_MUSIC, 10, "os2", "OS/2 Music Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_OS2(); } + Driver *CreateInstance() const override { return new MusicDriver_OS2(); } }; #endif /* MUSIC_OS2_H */ diff --git a/src/music/qtmidi.h b/src/music/qtmidi.h index 32163db939..631f04d2db 100644 --- a/src/music/qtmidi.h +++ b/src/music/qtmidi.h @@ -16,24 +16,24 @@ class MusicDriver_QtMidi : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "qt"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "qt"; } }; class FMusicDriver_QtMidi : public DriverFactoryBase { public: FMusicDriver_QtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 5, "qt", "QuickTime MIDI Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_QtMidi(); } + Driver *CreateInstance() const override { return new MusicDriver_QtMidi(); } }; #endif /* MUSIC_MACOSX_QUICKTIME_H */ diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp index a32318db12..18a3bce3e7 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -187,7 +187,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW uint preload_bytes = 0; for (size_t bl = 0; bl < _midi.current_file.blocks.size(); bl++) { MidiFile::DataBlock &block = _midi.current_file.blocks[bl]; - preload_bytes += block.data.Length(); + preload_bytes += block.data.size(); if (block.ticktime >= _midi.current_segment.start) { if (_midi.current_segment.loop) { DEBUG(driver, 2, "Win32-MIDI: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime)/1000.0, (int)preload_bytes); @@ -229,8 +229,8 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW break; } - byte *data = block.data.Begin(); - size_t remaining = block.data.Length(); + byte *data = block.data.data(); + size_t remaining = block.data.size(); byte last_status = 0; while (remaining > 0) { /* MidiFile ought to have converted everything out of running status, diff --git a/src/music/win32_m.h b/src/music/win32_m.h index 1ac8ae69e4..5366cf5d71 100644 --- a/src/music/win32_m.h +++ b/src/music/win32_m.h @@ -17,25 +17,25 @@ /** The Windows music player. */ class MusicDriver_Win32 : public MusicDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void PlaySong(const MusicSongInfo &song); + void PlaySong(const MusicSongInfo &song) override; - /* virtual */ void StopSong(); + void StopSong() override; - /* virtual */ bool IsSongPlaying(); + bool IsSongPlaying() override; - /* virtual */ void SetVolume(byte vol); - /* virtual */ const char *GetName() const { return "win32"; } + void SetVolume(byte vol) override; + const char *GetName() const override { return "win32"; } }; /** Factory for Windows' music player. */ class FMusicDriver_Win32 : public DriverFactoryBase { public: FMusicDriver_Win32() : DriverFactoryBase(Driver::DT_MUSIC, 5, "win32", "Win32 Music Driver") {} - /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Win32(); } + Driver *CreateInstance() const override { return new MusicDriver_Win32(); } }; #endif /* MUSIC_WIN32_H */ diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 885647427f..da63192e02 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -459,7 +459,7 @@ struct MusicTrackSelectionWindow : public Window { this->LowerWidget(WID_MTS_ALL + _settings_client.music.playlist); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_MTS_PLAYLIST: @@ -476,7 +476,7 @@ struct MusicTrackSelectionWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; for (int i = 0; i < 6; i++) { @@ -486,7 +486,7 @@ struct MusicTrackSelectionWindow : public Window { this->SetDirty(); } - 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_MTS_PLAYLIST: { @@ -521,7 +521,7 @@ struct MusicTrackSelectionWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_MTS_LIST_LEFT: { @@ -554,7 +554,7 @@ struct MusicTrackSelectionWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_MTS_LIST_LEFT: { // add to playlist @@ -587,7 +587,7 @@ struct MusicTrackSelectionWindow : public Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_MTS_MUSICSET: @@ -672,7 +672,7 @@ struct MusicWindow : 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) { /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size. @@ -714,7 +714,7 @@ struct MusicWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_M_TRACK_NR: { @@ -763,7 +763,7 @@ struct MusicWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; for (int i = 0; i < 6; i++) { @@ -775,7 +775,7 @@ struct MusicWindow : public Window { this->SetDirty(); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_M_PREV: // skip to prev diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 62af3a40bf..9522297768 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -11,8 +11,6 @@ #include "../../stdafx.h" -#ifdef ENABLE_NETWORK - #include "address.h" #include "../../debug.h" @@ -433,5 +431,3 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets) default: return "unsupported"; } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/address.h b/src/network/core/address.h index 9fd40eaeef..2f26a3d00f 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -17,11 +17,9 @@ #include "../../string_func.h" #include "../../core/smallmap_type.hpp" -#ifdef ENABLE_NETWORK - class NetworkAddress; -typedef SmallVector NetworkAddressList; ///< Type for a list of addresses. -typedef SmallMap SocketList; ///< Type for a mapping between address and socket. +typedef std::vector NetworkAddressList; ///< Type for a list of addresses. +typedef SmallMap SocketList; ///< Type for a mapping between address and socket. /** * Wrapper for (un)resolved network addresses; there's no reason to transform @@ -192,5 +190,4 @@ public: static const char *AddressFamilyAsString(int family); }; -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_ADDRESS_H */ diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp index e5f1df7214..1726e4176e 100644 --- a/src/network/core/core.cpp +++ b/src/network/core/core.cpp @@ -11,8 +11,6 @@ * @file core.cpp Functions used to initialize/shut down the core network */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../debug.h" #include "os_abstraction.h" @@ -80,5 +78,3 @@ void NetworkSocketHandler::ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf) grf->md5sum[j] = p->Recv_uint8(); } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/core.h b/src/network/core/core.h index a250dbb081..1536c08a7a 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -17,8 +17,6 @@ #include "../../newgrf_config.h" #include "config.h" -#ifdef ENABLE_NETWORK - bool NetworkCoreInitialize(); void NetworkCoreShutdown(); @@ -80,6 +78,4 @@ public: void SendCompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len = NETWORK_COMPANY_NAME_LENGTH); }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_CORE_H */ diff --git a/src/network/core/game.h b/src/network/core/game.h index 846551678e..6771c3858a 100644 --- a/src/network/core/game.h +++ b/src/network/core/game.h @@ -19,8 +19,6 @@ #include "../../newgrf_config.h" #include "../../date_type.h" -#ifdef ENABLE_NETWORK - /** * The game information that is not generated on-the-fly and has to * be sent to the clients. @@ -57,6 +55,4 @@ struct NetworkGameInfo : NetworkServerGameInfo { byte map_set; ///< Graphical set }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_GAME_H */ diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp index c2faf4c8b5..2bf862a4f5 100644 --- a/src/network/core/host.cpp +++ b/src/network/core/host.cpp @@ -9,8 +9,6 @@ /** @file host.cpp Functions related to getting host specific data (IPs). */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../debug.h" #include "address.h" @@ -78,7 +76,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // BE memset(&address, 0, sizeof(address)); ((sockaddr_in*)&address)->sin_addr.s_addr = htonl(ip | ~netmask); NetworkAddress addr(address, sizeof(sockaddr)); - if (!broadcast->Contains(addr)) *broadcast->Append() = addr; + if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr); } if (read < 0) { break; @@ -102,7 +100,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // GE if (ifa->ifa_broadaddr->sa_family != AF_INET) continue; NetworkAddress addr(ifa->ifa_broadaddr, sizeof(sockaddr)); - if (!broadcast->Contains(addr)) *broadcast->Append() = addr; + if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr); } freeifaddrs(ifap); } @@ -138,7 +136,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // Wi memcpy(&address, &ifo[j].iiAddress.Address, sizeof(sockaddr)); ((sockaddr_in*)&address)->sin_addr.s_addr = ifo[j].iiAddress.AddressIn.sin_addr.s_addr | ~ifo[j].iiNetmask.AddressIn.sin_addr.s_addr; NetworkAddress addr(address, sizeof(sockaddr)); - if (!broadcast->Contains(addr)) *broadcast->Append() = addr; + if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr); } free(ifo); @@ -176,7 +174,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // !G (r.ifr_flags & IFF_BROADCAST) && ioctl(sock, SIOCGIFBRDADDR, &r) != -1) { NetworkAddress addr(&r.ifr_broadaddr, sizeof(sockaddr)); - if (!broadcast->Contains(addr)) *broadcast->Append() = addr; + if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) *broadcast->Append() = addr; } } @@ -202,10 +200,8 @@ void NetworkFindBroadcastIPs(NetworkAddressList *broadcast) /* Now display to the debug all the detected ips */ DEBUG(net, 3, "Detected broadcast addresses:"); int i = 0; - for (NetworkAddress *addr = broadcast->Begin(); addr != broadcast->End(); addr++) { - addr->SetPort(NETWORK_DEFAULT_PORT); - DEBUG(net, 3, "%d) %s", i++, addr->GetHostname()); + for (NetworkAddress &addr : *broadcast) { + addr.SetPort(NETWORK_DEFAULT_PORT); + DEBUG(net, 3, "%d) %s", i++, addr.GetHostname()); } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h index e58a48a6d1..a8df976d51 100644 --- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -18,8 +18,6 @@ /* Include standard stuff per OS */ -#ifdef ENABLE_NETWORK - /* Windows stuff */ #if defined(_WIN32) #include @@ -185,6 +183,4 @@ static inline bool SetNoDelay(SOCKET d) assert_compile(sizeof(in_addr) == 4); ///< IPv4 addresses should be 4 bytes. assert_compile(sizeof(in6_addr) == 16); ///< IPv6 addresses should be 16 bytes. -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_OS_ABSTRACTION_H */ diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index be922428d7..21f6956318 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -11,8 +11,6 @@ * @file packet.cpp Basic functions to create, fill and read packets. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../string_func.h" #include "../../command_type.h" @@ -373,5 +371,3 @@ void Packet::Recv_binary(std::string &buffer, size_t size) buffer.assign((const char *) &this->buffer[this->pos], size); this->pos += (PacketSize) size; } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/packet.h b/src/network/core/packet.h index 185969dc35..dc5096c9bb 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -19,8 +19,6 @@ #include "../../string_type.h" #include -#ifdef ENABLE_NETWORK - typedef uint16 PacketSize; ///< Size of the whole packet. typedef uint8 PacketType; ///< Identifier for the packet @@ -94,6 +92,4 @@ public: void Recv_binary(std::string &buffer, size_t size); }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_PACKET_H */ diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index 70138bf38f..8e0481b1a5 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -11,8 +11,6 @@ * @file tcp.cpp Basic functions to receive and send TCP packets. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../debug.h" @@ -238,5 +236,3 @@ bool NetworkTCPSocketHandler::CanSendReceive() this->writable = !!FD_ISSET(this->sock, &write_fd); return FD_ISSET(this->sock, &read_fd) != 0; } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index b736189b4e..243ec042d2 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -17,8 +17,6 @@ #include "address.h" #include "packet.h" -#ifdef ENABLE_NETWORK - /** The states of sending the packets. */ enum SendPacketsState { SPS_CLOSED, ///< The connection got closed. @@ -42,7 +40,7 @@ public: */ bool IsConnected() const { return this->sock != INVALID_SOCKET; } - virtual NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; virtual void SendPacket(Packet *packet); SendPacketsState SendPackets(bool closing_down = false); @@ -99,6 +97,4 @@ public: static void KillAll(); }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_H */ diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp index 284ceda9b1..226bae0245 100644 --- a/src/network/core/tcp_admin.cpp +++ b/src/network/core/tcp_admin.cpp @@ -11,8 +11,6 @@ * @file tcp_admin.cpp Basic functions to receive and send TCP packets to and from the admin network. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../network_internal.h" @@ -172,5 +170,3 @@ NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p) NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON_END); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PONG); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index e141a191a8..7bcc878403 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -19,8 +19,6 @@ #include "../network_type.h" #include "../../core/pool_type.hpp" -#ifdef ENABLE_NETWORK - /** * Enum with types of TCP packets specific to the admin network. * This protocol may only be extended to ensure stability. @@ -483,7 +481,7 @@ protected: NetworkRecvStatus HandlePacket(Packet *p); public: - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; NetworkAdminSocketHandler(SOCKET s); ~NetworkAdminSocketHandler(); @@ -500,6 +498,4 @@ public: } }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_ADMIN_H */ diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp index 2dc7898824..d76042821a 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -11,8 +11,6 @@ * @file tcp_connect.cpp Basic functions to create connections without blocking. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../thread/thread.h" @@ -21,7 +19,7 @@ #include "../../safeguards.h" /** List of connections that are currently being created */ -static SmallVector _tcp_connecters; +static std::vector _tcp_connecters; /** * Create a new connecter for the given address @@ -34,7 +32,7 @@ TCPConnecter::TCPConnecter(const NetworkAddress &address) : sock(INVALID_SOCKET), address(address) { - *_tcp_connecters.Append() = this; + _tcp_connecters.push_back(this); if (!ThreadObject::New(TCPConnecter::ThreadEntry, this, &this->thread, "ottd:tcp")) { this->Connect(); } @@ -68,22 +66,22 @@ void TCPConnecter::Connect() */ /* static */ void TCPConnecter::CheckCallbacks() { - for (TCPConnecter **iter = _tcp_connecters.Begin(); iter < _tcp_connecters.End(); /* nothing */) { + for (auto iter = _tcp_connecters.begin(); iter < _tcp_connecters.end(); /* nothing */) { TCPConnecter *cur = *iter; if ((cur->connected || cur->aborted) && cur->killed) { - _tcp_connecters.Erase(iter); + iter = _tcp_connecters.erase(iter); if (cur->sock != INVALID_SOCKET) closesocket(cur->sock); delete cur; continue; } if (cur->connected) { - _tcp_connecters.Erase(iter); + iter = _tcp_connecters.erase(iter); cur->OnConnect(cur->sock); delete cur; continue; } if (cur->aborted) { - _tcp_connecters.Erase(iter); + iter = _tcp_connecters.erase(iter); cur->OnFailure(); delete cur; continue; @@ -95,7 +93,5 @@ void TCPConnecter::Connect() /** Kill all connection attempts. */ /* static */ void TCPConnecter::KillAll() { - for (TCPConnecter **iter = _tcp_connecters.Begin(); iter != _tcp_connecters.End(); iter++) (*iter)->killed = true; + for (TCPConnecter *conn : _tcp_connecters) conn->killed = true; } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index fc22c4491f..8257a72526 100644 --- a/src/network/core/tcp_content.cpp +++ b/src/network/core/tcp_content.cpp @@ -11,8 +11,6 @@ * @file tcp_content.cpp Basic functions to receive and send Content packets. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #ifndef OPENTTD_MSU #include "../../textfile_gui.h" @@ -266,5 +264,3 @@ Subdirectory GetContentInfoSubDir(ContentType type) } } #endif /* OPENTTD_MSU */ - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index a506439da9..689de7a018 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -19,8 +19,6 @@ #include "packet.h" #include "../../debug.h" -#ifdef ENABLE_NETWORK - /** The values in the enum are important; they are used as database 'keys' */ enum ContentType { CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types @@ -100,7 +98,7 @@ struct ContentInfo { class NetworkContentSocketHandler : public NetworkTCPSocketHandler { protected: NetworkAddress client_addr; ///< The address we're connected to. - virtual void Close(); + void Close() override; bool ReceiveInvalidPacket(PacketContentType type); @@ -213,6 +211,4 @@ public: Subdirectory GetContentInfoSubDir(ContentType type); #endif /* OPENTTD_MSU */ -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_CONTENT_H */ diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index caa378fc4c..2d8a74a118 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -11,8 +11,6 @@ * @file tcp_game.cpp Basic functions to receive and send TCP packets for game purposes. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../network.h" @@ -199,5 +197,3 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p) { ret NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_MOVE); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_COMPANY_UPDATE); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_CONFIG_UPDATE); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index f929997d51..07b1002f02 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -20,8 +20,6 @@ #include "../../core/pool_type.hpp" #include -#ifdef ENABLE_NETWORK - /** * Enum with all types of TCP packets. * For the exact meaning, look at #NetworkGameSocketHandler. @@ -528,7 +526,7 @@ public: CommandQueue incoming_queue; ///< The command-queue awaiting handling uint last_packet; ///< Time we received the last frame. - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; /** * Close the network connection due to the given status. @@ -562,6 +560,4 @@ public: void SendCommand(Packet *p, const CommandPacket *cp); }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_GAME_H */ diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp index 3b0f0d1489..d20b5e3b42 100644 --- a/src/network/core/tcp_http.cpp +++ b/src/network/core/tcp_http.cpp @@ -11,8 +11,6 @@ * @file tcp_http.cpp Basic functions to receive and send HTTP TCP packets. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../debug.h" #include "../../rev.h" @@ -23,7 +21,7 @@ #include "../../safeguards.h" /** List of open HTTP connections. */ -static SmallVector _http_connections; +static std::vector _http_connections; /** * Start the querying @@ -65,7 +63,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s, return; } - *_http_connections.Append() = this; + _http_connections.push_back(this); } /** Free whatever needs to be freed. */ @@ -299,21 +297,21 @@ int NetworkHTTPSocketHandler::Receive() /* static */ void NetworkHTTPSocketHandler::HTTPReceive() { /* No connections, just bail out. */ - if (_http_connections.Length() == 0) return; + if (_http_connections.size() == 0) return; fd_set read_fd; struct timeval tv; FD_ZERO(&read_fd); - for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); iter++) { - FD_SET((*iter)->sock, &read_fd); + for (NetworkHTTPSocketHandler *handler : _http_connections) { + FD_SET(handler->sock, &read_fd); } tv.tv_sec = tv.tv_usec = 0; // don't block at all. int n = select(FD_SETSIZE, &read_fd, NULL, NULL, &tv); if (n == -1) return; - for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); /* nothing */) { + for (auto iter = _http_connections.begin(); iter < _http_connections.end(); /* nothing */) { NetworkHTTPSocketHandler *cur = *iter; if (FD_ISSET(cur->sock, &read_fd)) { @@ -323,7 +321,7 @@ int NetworkHTTPSocketHandler::Receive() if (ret <= 0) { /* Then... the connection can be closed */ cur->CloseConnection(); - _http_connections.Erase(iter); + iter = _http_connections.erase(iter); delete cur; continue; } @@ -331,5 +329,3 @@ int NetworkHTTPSocketHandler::Receive() iter++; } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_http.h b/src/network/core/tcp_http.h index 36520f1364..5a5cdd9f2f 100644 --- a/src/network/core/tcp_http.h +++ b/src/network/core/tcp_http.h @@ -16,8 +16,6 @@ #include "tcp.h" -#ifdef ENABLE_NETWORK - /** Callback for when the HTTP handler has something to tell us. */ struct HTTPCallback { /** @@ -62,7 +60,7 @@ public: return this->sock != INVALID_SOCKET; } - virtual NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; NetworkHTTPSocketHandler(SOCKET sock, HTTPCallback *callback, const char *host, const char *url, const char *data, int depth); @@ -108,13 +106,13 @@ public: free(this->url); } - virtual void OnFailure() + void OnFailure() override { this->callback->OnFailure(); free(this->data); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { new NetworkHTTPSocketHandler(s, this->callback, this->address.GetHostname(), this->url, this->data, this->depth); /* We've relinquished control of data now. */ @@ -122,6 +120,4 @@ public: } }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_HTTP_H */ diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h index 8cd8257b25..744f8841fd 100644 --- a/src/network/core/tcp_listen.h +++ b/src/network/core/tcp_listen.h @@ -20,8 +20,6 @@ #include "../../debug.h" #include "table/strings.h" -#ifdef ENABLE_NETWORK - /** * Template for TCP listeners. * @param Tsocket The class we create sockets for. @@ -56,13 +54,13 @@ public: /* Check if the client is banned */ bool banned = false; - for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) { - banned = address.IsInNetmask(*iter); + for (char *entry : _network_ban_list) { + banned = address.IsInNetmask(entry); if (banned) { Packet p(Tban_packet); p.PrepareToSend(); - DEBUG(net, 1, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), *iter); + DEBUG(net, 1, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), entry); if (send(s, (const char*)p.buffer, p.size, 0) < 0) { DEBUG(net, 0, "send failed with error %d", GET_LAST_ERROR()); @@ -113,16 +111,16 @@ public: } /* take care of listener port */ - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - FD_SET(s->second, &read_fd); + for (auto &s : sockets) { + FD_SET(s.second, &read_fd); } tv.tv_sec = tv.tv_usec = 0; // don't block at all. if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false; /* accept clients.. */ - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - if (FD_ISSET(s->second, &read_fd)) AcceptClient(s->second); + for (auto &s : sockets) { + if (FD_ISSET(s.second, &read_fd)) AcceptClient(s.second); } /* read stuff from clients */ @@ -142,16 +140,16 @@ public: */ static bool Listen(uint16 port) { - assert(sockets.Length() == 0); + assert(sockets.size() == 0); NetworkAddressList addresses; GetBindAddresses(&addresses, port); - for (NetworkAddress *address = addresses.Begin(); address != addresses.End(); address++) { - address->Listen(SOCK_STREAM, &sockets); + for (NetworkAddress &address : addresses) { + address.Listen(SOCK_STREAM, &sockets); } - if (sockets.Length() == 0) { + if (sockets.size() == 0) { DEBUG(net, 0, "[server] could not start network: could not create listening socket"); NetworkError(STR_NETWORK_ERROR_SERVER_START); return false; @@ -163,16 +161,14 @@ public: /** Close the sockets we're listening on. */ static void CloseListeners() { - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - closesocket(s->second); + for (auto &s : sockets) { + closesocket(s.second); } - sockets.Clear(); + sockets.clear(); DEBUG(net, 1, "[%s] closed listeners", Tsocket::GetName()); } }; template SocketList TCPListenHandler::sockets; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_TCP_LISTEN_H */ diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index 57fe84e256..263a2c46b0 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -11,8 +11,6 @@ * @file core/udp.cpp Basic functions to receive and send UDP packets. */ -#ifdef ENABLE_NETWORK - #include "../../stdafx.h" #include "../../date_func.h" #include "../../debug.h" @@ -31,15 +29,15 @@ extern const uint8 _out_of_band_grf_md5[16]; NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind) { if (bind != NULL) { - for (NetworkAddress *addr = bind->Begin(); addr != bind->End(); addr++) { - *this->bind.Append() = *addr; + for (NetworkAddress &addr : *bind) { + this->bind.push_back(addr); } } else { /* As hostname NULL and port 0/NULL don't go well when * resolving it we need to add an address for each of * the address families we support. */ - *this->bind.Append() = NetworkAddress(NULL, 0, AF_INET); - *this->bind.Append() = NetworkAddress(NULL, 0, AF_INET6); + this->bind.emplace_back(nullptr, 0, AF_INET); + this->bind.emplace_back(nullptr, 0, AF_INET6); } this->fragment_token = ((uint64) InteractiveRandom()) | (((uint64) InteractiveRandom()) << 32); @@ -55,11 +53,11 @@ bool NetworkUDPSocketHandler::Listen() /* Make sure socket is closed */ this->Close(); - for (NetworkAddress *addr = this->bind.Begin(); addr != this->bind.End(); addr++) { - addr->Listen(SOCK_DGRAM, &this->sockets); + for (NetworkAddress &addr : this->bind) { + addr.Listen(SOCK_DGRAM, &this->sockets); } - return this->sockets.Length() != 0; + return this->sockets.size() != 0; } /** @@ -67,10 +65,10 @@ bool NetworkUDPSocketHandler::Listen() */ void NetworkUDPSocketHandler::Close() { - for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) { - closesocket(s->second); + for (auto &s : this->sockets) { + closesocket(s.second); } - this->sockets.Clear(); + this->sockets.clear(); } NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection(bool error) @@ -88,7 +86,7 @@ NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection(bool error) */ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool all, bool broadcast) { - if (this->sockets.Length() == 0) this->Listen(); + if (this->sockets.size() == 0) this->Listen(); if (p->size > SEND_MTU) { p->PrepareToSend(); @@ -117,26 +115,26 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a return; } - for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) { + for (auto &s : this->sockets) { /* Make a local copy because if we resolve it we cannot * easily unresolve it so we can resolve it later again. */ NetworkAddress send(*recv); /* Not the same type */ - if (!send.IsFamily(s->first.GetAddress()->ss_family)) continue; + if (!send.IsFamily(s.first.GetAddress()->ss_family)) continue; p->PrepareToSend(); if (broadcast) { /* Enable broadcast */ unsigned long val = 1; - if (setsockopt(s->second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) { + if (setsockopt(s.second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) { DEBUG(net, 1, "[udp] setting broadcast failed with: %i", GET_LAST_ERROR()); } } /* Send the buffer */ - int res = sendto(s->second, (const char*)p->buffer, p->size, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength()); + int res = sendto(s.second, (const char*)p->buffer, p->size, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength()); DEBUG(net, 7, "[udp] sendto(%s)", send.GetAddressAsString()); /* Check for any errors, but ignore it otherwise */ @@ -151,7 +149,7 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a */ void NetworkUDPSocketHandler::ReceivePackets() { - for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) { + for (auto &s : this->sockets) { for (int i = 0; i < 1000; i++) { // Do not infinitely loop when DoSing with UDP struct sockaddr_storage client_addr; memset(&client_addr, 0, sizeof(client_addr)); @@ -160,8 +158,8 @@ void NetworkUDPSocketHandler::ReceivePackets() socklen_t client_len = sizeof(client_addr); /* Try to receive anything */ - SetNonBlocking(s->second); // Some OSes seem to lose the non-blocking status of the socket - int nbytes = recvfrom(s->second, (char*)p.buffer, SEND_MTU, 0, (struct sockaddr *)&client_addr, &client_len); + SetNonBlocking(s.second); // Some OSes seem to lose the non-blocking status of the socket + int nbytes = recvfrom(s.second, (char*)p.buffer, SEND_MTU, 0, (struct sockaddr *)&client_addr, &client_len); /* Did we get the bytes for the base header of the packet? */ if (nbytes <= 0) break; // No data, i.e. no packet @@ -569,5 +567,3 @@ void NetworkUDPSocketHandler::Receive_SERVER_UNREGISTER(Packet *p, NetworkAddres void NetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_GET_NEWGRFS, client_addr); } void NetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_SERVER_NEWGRFS, client_addr); } void NetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_MASTER_SESSION_KEY, client_addr); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/core/udp.h b/src/network/core/udp.h index ba183609fa..6331682115 100644 --- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -22,8 +22,6 @@ #include #include -#ifdef ENABLE_NETWORK - /** Enum with all types of UDP packets. The order MUST not be changed **/ enum PacketUDPType { PACKET_UDP_CLIENT_FIND_SERVER, ///< Queries a game server for game information @@ -71,7 +69,7 @@ protected: }; std::vector fragments; - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; void ReceiveInvalidPacket(PacketUDPType, NetworkAddress *client_addr); @@ -258,7 +256,7 @@ public: virtual ~NetworkUDPSocketHandler() { this->Close(); } bool Listen(); - void Close(); + void Close() override; void SendPacket(Packet *p, NetworkAddress *recv, bool all = false, bool broadcast = false); void ReceivePackets(); @@ -269,6 +267,4 @@ public: void ReceiveNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info); }; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CORE_UDP_H */ diff --git a/src/network/network.cpp b/src/network/network.cpp index 29348f5470..d10b9ca7c7 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -11,8 +11,6 @@ #include "../stdafx.h" -#ifdef ENABLE_NETWORK - #include "../strings_func.h" #include "../command_func.h" #include "../date_func.h" @@ -597,12 +595,12 @@ class TCPQueryConnecter : TCPConnecter { public: TCPQueryConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { NetworkDisconnect(); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { _networking = true; new ClientNetworkGameSocketHandler(s); @@ -653,13 +651,13 @@ void NetworkAddServer(const char *b) */ void GetBindAddresses(NetworkAddressList *addresses, uint16 port) { - for (char **iter = _network_bind_list.Begin(); iter != _network_bind_list.End(); iter++) { - *addresses->Append() = NetworkAddress(*iter, port); + for (char *iter : _network_bind_list) { + addresses->emplace_back(iter, port); } /* No address, so bind to everything. */ - if (addresses->Length() == 0) { - *addresses->Append() = NetworkAddress("", port); + if (addresses->size() == 0) { + addresses->emplace_back("", port); } } @@ -671,7 +669,7 @@ void NetworkRebuildHostList() _network_host_list.Clear(); for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) { - if (item->manually) *_network_host_list.Append() = stredup(item->address.GetAddressAsString(false)); + if (item->manually) _network_host_list.push_back(stredup(item->address.GetAddressAsString(false))); } } @@ -680,12 +678,12 @@ class TCPClientConnecter : TCPConnecter { public: TCPClientConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { NetworkError(STR_NETWORK_ERROR_NOCONNECTION); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { _networking = true; new ClientNetworkGameSocketHandler(s); @@ -1132,5 +1130,3 @@ bool IsNetworkCompatibleVersion(const char *other, bool extended) { return strncmp(_openttd_revision, other, (extended ? NETWORK_LONG_REVISION_LENGTH : NETWORK_REVISION_LENGTH) - 1) == 0; } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network.h b/src/network/network.h index 26f94482ec..9f8e3b790b 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -12,9 +12,6 @@ #ifndef NETWORK_H #define NETWORK_H - -#ifdef ENABLE_NETWORK - void NetworkStartUp(); void NetworkShutDown(); void NetworkDrawChatMessage(); @@ -26,19 +23,4 @@ extern bool _network_available; ///< is network mode available? extern bool _network_dedicated; ///< are we a dedicated server? extern bool _is_network_server; ///< Does this client wants to be a network-server? -#else /* ENABLE_NETWORK */ -/* Network function stubs when networking is disabled */ - -static inline void NetworkStartUp() {} -static inline void NetworkShutDown() {} -static inline void NetworkDrawChatMessage() {} -static inline bool HasClients() { return false; } - -#define _networking 0 -#define _network_server 0 -#define _network_available 0 -#define _network_dedicated 0 -#define _is_network_server 0 - -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_H */ diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index c5c14d0fc3..f0f3895aca 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -9,8 +9,6 @@ /** @file network_admin.cpp Server part of the admin network protocol. */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "../strings_func.h" #include "../date_func.h" @@ -1045,5 +1043,3 @@ void NetworkAdminUpdate(AdminUpdateFrequency freq) } } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_admin.h b/src/network/network_admin.h index ad780bcf36..b702430d45 100644 --- a/src/network/network_admin.h +++ b/src/network/network_admin.h @@ -12,8 +12,6 @@ #ifndef NETWORK_ADMIN_H #define NETWORK_ADMIN_H -#ifdef ENABLE_NETWORK - #include "network_internal.h" #include "core/tcp_listen.h" #include "core/tcp_admin.h" @@ -28,14 +26,14 @@ extern NetworkAdminSocketPool _networkadminsocket_pool; /** Class for handling the server side of the game connection. */ class ServerNetworkAdminSocketHandler : public NetworkAdminSocketPool::PoolItem<&_networkadminsocket_pool>, public NetworkAdminSocketHandler, public TCPListenHandler { protected: - virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_PING(Packet *p); + NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_POLL(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_RCON(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_PING(Packet *p) override; NetworkRecvStatus SendProtocol(); NetworkRecvStatus SendPong(uint32 d1); @@ -124,5 +122,4 @@ void NetworkAdminConsole(const char *origin, const char *string); void NetworkAdminGameScript(const char *json); void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp); -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_ADMIN_H */ diff --git a/src/network/network_base.h b/src/network/network_base.h index 1644b3558a..817d0e4c89 100644 --- a/src/network/network_base.h +++ b/src/network/network_base.h @@ -12,8 +12,6 @@ #ifndef NETWORK_BASE_H #define NETWORK_BASE_H -#ifdef ENABLE_NETWORK - #include "network_type.h" #include "core/address.h" #include "../core/pool_type.hpp" @@ -54,5 +52,4 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p */ #define FOR_ALL_CLIENT_INFOS(var) FOR_ALL_CLIENT_INFOS_FROM(var, 0) -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_BASE_H */ diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index d628299d71..e626a598d8 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -11,8 +11,6 @@ #include /* va_list */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "../strings_func.h" #include "../blitter/factory.hpp" @@ -324,7 +322,7 @@ struct NetworkChatWindow : public Window { InvalidateWindowData(WC_NEWS_WINDOW, 0, 0); } - virtual void FindWindowPlacementAndResize(int def_width, int def_height) + void FindWindowPlacementAndResize(int def_width, int def_height) override { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } @@ -462,13 +460,13 @@ struct NetworkChatWindow : public Window { free(pre_buf); } - 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 = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; return pt; } - 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_NC_DESTINATION) return; @@ -481,7 +479,7 @@ struct NetworkChatWindow : public Window { *size = maxdim(*size, d); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_NC_DESTINATION) return; @@ -491,7 +489,7 @@ struct NetworkChatWindow : public Window { DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, this->dest_string, TC_BLACK, SA_RIGHT); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_NC_SENDBUTTON: /* Send */ @@ -504,7 +502,7 @@ struct NetworkChatWindow : public Window { } } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { EventState state = ES_NOT_HANDLED; if (keycode == WKC_TAB) { @@ -514,7 +512,7 @@ struct NetworkChatWindow : public Window { return state; } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { _chat_tab_completion_active = false; } @@ -524,7 +522,7 @@ struct NetworkChatWindow : 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 (data == this->dest) delete this; } @@ -564,5 +562,3 @@ void ShowNetworkChatQueryWindow(DestType type, int dest) DeleteWindowByClass(WC_SEND_NETWORK_MSG); new NetworkChatWindow(&_chat_window_desc, type, dest); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index fd2145e1a7..2cb588972f 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -9,8 +9,6 @@ /** @file network_client.cpp Client part of the network protocol. */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "network_gui.h" #include "../saveload/saveload.h" @@ -44,7 +42,7 @@ struct PacketReader : LoadFilter { static const size_t CHUNK = 32 * 1024; ///< 32 KiB chunks of memory. - AutoFreeSmallVector blocks; ///< Buffer with blocks of allocated memory. + AutoFreeSmallVector blocks; ///< Buffer with blocks of allocated memory. byte *buf; ///< Buffer we're going to write to/read from. byte *bufe; ///< End of the buffer we write to/read from. byte **block; ///< The block we're reading from/writing to. @@ -80,14 +78,14 @@ struct PacketReader : LoadFilter { /* Allocate a new chunk and add the remaining data. */ pbuf += to_write; to_write = in_packet - to_write; - this->buf = *this->blocks.Append() = CallocT(CHUNK); + this->blocks.push_back(this->buf = CallocT(CHUNK)); this->bufe = this->buf + CHUNK; memcpy(this->buf, pbuf, to_write); this->buf += to_write; } - /* virtual */ size_t Read(byte *rbuf, size_t size) + size_t Read(byte *rbuf, size_t size) override { /* Limit the amount to read to whatever we still have. */ size_t ret_size = size = min(this->written_bytes - this->read_bytes, size); @@ -109,11 +107,11 @@ struct PacketReader : LoadFilter { return ret_size; } - /* virtual */ void Reset() + void Reset() override { this->read_bytes = 0; - this->block = this->blocks.Begin(); + this->block = this->blocks.data(); this->buf = *this->block++; this->bufe = this->buf + CHUNK; } @@ -1328,5 +1326,3 @@ bool NetworkMaxSpectatorsReached() { return NetworkSpectatorCount() >= (_network_server ? _settings_client.network.max_spectators : _network_server_max_spectators); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_client.h b/src/network/network_client.h index b74f9686af..4fc27571b9 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -12,8 +12,6 @@ #ifndef NETWORK_CLIENT_H #define NETWORK_CLIENT_H -#ifdef ENABLE_NETWORK - #include "network_internal.h" /** Class for handling the client side of the game connection. */ @@ -44,33 +42,33 @@ protected: friend void NetworkClose(bool close_admins); static ClientNetworkGameSocketHandler *my_client; ///< This is us! - virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_RCON(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p); + NetworkRecvStatus Receive_SERVER_FULL(Packet *p) override; + NetworkRecvStatus Receive_SERVER_BANNED(Packet *p) override; + NetworkRecvStatus Receive_SERVER_ERROR(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_WAIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_JOIN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_FRAME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_SYNC(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CHAT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_QUIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_RCON(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MOVE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p) override; static NetworkRecvStatus SendNewGRFsOk(); static NetworkRecvStatus SendGetMap(); @@ -80,7 +78,7 @@ public: ClientNetworkGameSocketHandler(SOCKET s); ~ClientNetworkGameSocketHandler(); - NetworkRecvStatus CloseConnection(NetworkRecvStatus status); + NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override; void ClientError(NetworkRecvStatus res); static NetworkRecvStatus SendCompanyInformationQuery(); @@ -118,6 +116,4 @@ extern CompanyID _network_join_as; extern const char *_network_join_server_password; extern const char *_network_join_company_password; -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CLIENT_H */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 42bf85ab31..5b148b6c35 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -9,8 +9,6 @@ /** @file network_command.cpp Command handling over network connections. */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "network_admin.h" #include "network_client.h" @@ -373,5 +371,3 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp) } p->Send_uint8 (callback); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index b2aed203c6..b7f9d72d25 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -9,8 +9,6 @@ /** @file network_content.cpp Content sending/receiving part of the network protocol. */ -#if defined(ENABLE_NETWORK) - #include "../stdafx.h" #include "../rev.h" #include "../ai/ai.hpp" @@ -139,8 +137,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) if (ci->state == ContentInfo::UNSELECTED && ci->filesize == 0) ci->state = ContentInfo::DOES_NOT_EXIST; /* Do we already have a stub for this? */ - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - ContentInfo *ici = *iter; + for (ContentInfo *ici : this->infos) { if (ici->type == ci->type && ici->unique_id == ci->unique_id && memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) { /* Preserve the name if possible */ @@ -167,11 +164,11 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) return true; } - *this->infos.Append() = ci; + this->infos.push_back(ci); /* Incoming data means that we might need to reconsider dependencies */ - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - this->CheckDependencyState(*iter); + for (ContentInfo *ici : this->infos) { + this->CheckDependencyState(ici); } this->OnReceiveContentInfo(ci); @@ -253,13 +250,12 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo uint offset = 0; - while (cv->Length() > offset) { + while (cv->size() > offset) { Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID); - const uint to_send = min(cv->Length() - offset, max_per_packet); + const uint to_send = min(cv->size() - offset, max_per_packet); p->Send_uint8(to_send); - for (uint i = 0; i < to_send; i++) { - const ContentInfo *ci = (*cv)[offset + i]; + for (const ContentInfo *ci : *cv) { p->Send_uint8((byte)ci->type); p->Send_uint32(ci->unique_id); if (!send_md5sum) continue; @@ -274,11 +270,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo offset += to_send; } - for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) { - ContentInfo *ci = *iter; + for (ContentInfo *ci : *cv) { bool found = false; - for (ContentIterator iter2 = this->infos.Begin(); iter2 != this->infos.End(); iter2++) { - ContentInfo *ci2 = *iter2; + for (ContentInfo *ci2 : this->infos) { if (ci->type == ci2->type && ci->unique_id == ci2->unique_id && (!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) { found = true; @@ -286,7 +280,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo } } if (!found) { - *this->infos.Append() = ci; + this->infos.push_back(ci); } else { delete ci; } @@ -304,15 +298,14 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin bytes = 0; ContentIDList content; - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - const ContentInfo *ci = *iter; + for (const ContentInfo *ci : this->infos) { if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue; - *content.Append() = ci->id; + content.push_back(ci->id); bytes += ci->filesize; } - files = content.Length(); + files = content.size(); /* If there's nothing to download, do nothing. */ if (files == 0) return; @@ -330,7 +323,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin */ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content) { - uint count = content.Length(); + uint count = content.size(); /* Allocate memory for the whole request. * Requests are "id\nid\n..." (as strings), so assume the maximum ID, @@ -341,8 +334,8 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten const char *lastof = content_request + bytes - 1; char *p = content_request; - for (const ContentID *id = content.Begin(); id != content.End(); id++) { - p += seprintf(p, lastof, "%d\n", *id); + for (const ContentID &id : content) { + p += seprintf(p, lastof, "%d\n", id); } this->http_response_index = -1; @@ -358,8 +351,8 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten */ void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content) { - uint count = content.Length(); - const ContentID *content_ids = content.Begin(); + uint count = content.size(); + const ContentID *content_ids = content.data(); this->Connect(); while (count > 0) { @@ -563,7 +556,8 @@ void ClientNetworkContentSocketHandler::OnFailure() uint files, bytes; this->DownloadSelectedContent(files, bytes, true); - this->http_response.Reset(); + this->http_response.clear(); + this->http_response.shrink_to_fit(); this->http_response_index = -2; if (this->curFile != NULL) { @@ -586,11 +580,11 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l if (this->http_response_index == -1) { if (data != NULL) { /* Append the rest of the response. */ - memcpy(this->http_response.Append((uint)length), data, length); + memcpy(grow(this->http_response, (uint)length), data, length); return; } else { /* Make sure the response is properly terminated. */ - *this->http_response.Append() = '\0'; + this->http_response.push_back('\0'); /* And prepare for receiving the rest of the data. */ this->http_response_index = 0; @@ -615,7 +609,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l this->AfterDownload(); } - if ((uint)this->http_response_index >= this->http_response.Length()) { + if ((uint)this->http_response_index >= this->http_response.size()) { /* It's not a real failure, but if there's * nothing more to download it helps with * cleaning up the stuff we allocated. */ @@ -633,7 +627,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l #define check_and_terminate(p) { check_not_null(p); *(p) = '\0'; } for (;;) { - char *str = this->http_response.Begin() + this->http_response_index; + char *str = this->http_response.data() + this->http_response_index; char *p = strchr(str, '\n'); check_and_terminate(p); @@ -661,7 +655,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l str = p + 1; /* Is it a fallback URL? If so, just continue with the next one. */ if (strncmp(str, "ottd", 4) == 0) { - if ((uint)this->http_response_index >= this->http_response.Length()) { + if ((uint)this->http_response_index >= this->http_response.size()) { /* Have we gone through all lines? */ this->OnFailure(); return; @@ -720,7 +714,7 @@ ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler() delete this->curInfo; if (this->curFile != NULL) fclose(this->curFile); - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter; + for (ContentInfo *ci : this->infos) delete ci; } /** Connect to the content server. */ @@ -732,13 +726,13 @@ public: */ NetworkContentConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { _network_content_client.isConnecting = false; _network_content_client.OnConnect(false); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { assert(_network_content_client.sock == INVALID_SOCKET); _network_content_client.isConnecting = false; @@ -801,10 +795,9 @@ void ClientNetworkContentSocketHandler::SendReceive() void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid) { /* When we tried to download it already, don't try again */ - if (this->requested.Contains(cid)) return; + if (std::find(this->requested.begin(), this->requested.end(), cid) != this->requested.end()) return; - *this->requested.Append() = cid; - assert(this->requested.Contains(cid)); + this->requested.push_back(cid); this->RequestContentList(1, &cid); } @@ -815,8 +808,7 @@ void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid) */ ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid) { - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - ContentInfo *ci = *iter; + for (ContentInfo *ci : this->infos) { if (ci->id == cid) return ci; } return NULL; @@ -852,8 +844,7 @@ void ClientNetworkContentSocketHandler::Unselect(ContentID cid) /** Select everything we can select */ void ClientNetworkContentSocketHandler::SelectAll() { - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - ContentInfo *ci = *iter; + for (ContentInfo *ci : this->infos) { if (ci->state == ContentInfo::UNSELECTED) { ci->state = ContentInfo::SELECTED; this->CheckDependencyState(ci); @@ -864,8 +855,7 @@ void ClientNetworkContentSocketHandler::SelectAll() /** Select everything that's an update for something we've got */ void ClientNetworkContentSocketHandler::SelectUpgrade() { - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - ContentInfo *ci = *iter; + for (ContentInfo *ci : this->infos) { if (ci->state == ContentInfo::UNSELECTED && ci->upgrade) { ci->state = ContentInfo::SELECTED; this->CheckDependencyState(ci); @@ -876,8 +866,7 @@ void ClientNetworkContentSocketHandler::SelectUpgrade() /** Unselect everything that we've not downloaded so far. */ void ClientNetworkContentSocketHandler::UnselectAll() { - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - ContentInfo *ci = *iter; + for (ContentInfo *ci : this->infos) { if (ci->IsSelected() && ci->state != ContentInfo::ALREADY_HERE) ci->state = ContentInfo::UNSELECTED; } } @@ -907,13 +896,12 @@ void ClientNetworkContentSocketHandler::ToggleSelectedState(const ContentInfo *c */ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const { - for (ConstContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { - const ContentInfo *ci = *iter; + for (const ContentInfo * const &ci : this->infos) { if (ci == child) continue; for (uint i = 0; i < ci->dependency_count; i++) { if (ci->dependencies[i] == child->id) { - *parents.Append() = ci; + parents.push_back(ci); break; } } @@ -927,18 +915,18 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect */ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const { - *tree.Append() = child; + tree.push_back(child); /* First find all direct parents. We can't use the "normal" iterator as * we are including stuff into the vector and as such the vector's data * store can be reallocated (and thus move), which means out iterating * pointer gets invalid. So fall back to the indices. */ - for (uint i = 0; i < tree.Length(); i++) { + for (uint i = 0; i < tree.size(); i++) { ConstContentVector parents; this->ReverseLookupDependency(parents, tree[i]); - for (ConstContentIterator piter = parents.Begin(); piter != parents.End(); piter++) { - tree.Include(*piter); + for (const ContentInfo *ci : parents) { + include(tree, ci); } } } @@ -973,8 +961,7 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) * we automatically selected them. */ ConstContentVector parents; this->ReverseLookupDependency(parents, ci); - for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) { - const ContentInfo *c = *iter; + for (const ContentInfo *c : parents) { if (!c->IsSelected()) continue; this->Unselect(c->id); @@ -989,15 +976,15 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) if (c->state != ContentInfo::AUTOSELECTED) continue; /* Only unselect when WE are the only parent. */ - parents.Clear(); + parents.clear(); this->ReverseLookupDependency(parents, c); /* First check whether anything depends on us */ int sel_count = 0; bool force_selection = false; - for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) { - if ((*iter)->IsSelected()) sel_count++; - if ((*iter)->state == ContentInfo::SELECTED) force_selection = true; + for (const ContentInfo *ci : parents) { + if (ci->IsSelected()) sel_count++; + if (ci->state == ContentInfo::SELECTED) force_selection = true; } if (sel_count == 0) { /* Nothing depends on us */ @@ -1008,12 +995,12 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) if (force_selection) continue; /* "Flood" search to find all items in the dependency graph*/ - parents.Clear(); + parents.clear(); this->ReverseLookupTreeDependency(parents, c); /* Is there anything that is "force" selected?, if so... we're done. */ - for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) { - if ((*iter)->state != ContentInfo::SELECTED) continue; + for (const ContentInfo *ci : parents) { + if (ci->state != ContentInfo::SELECTED) continue; force_selection = true; break; @@ -1026,12 +1013,11 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) * After that's done run over them once again to test their children * to unselect. Don't do it immediately because it'll do exactly what * we're doing now. */ - for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) { - const ContentInfo *c = *iter; + for (const ContentInfo *c : parents) { if (c->state == ContentInfo::AUTOSELECTED) this->Unselect(c->id); } - for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) { - this->CheckDependencyState(this->GetContent((*iter)->id)); + for (const ContentInfo *c : parents) { + this->CheckDependencyState(this->GetContent(c->id)); } } } @@ -1039,47 +1025,47 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) /** Clear all downloaded content information. */ void ClientNetworkContentSocketHandler::Clear() { - for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter; + for (ContentInfo *c : this->infos) delete c; - this->infos.Clear(); - this->requested.Clear(); + this->infos.clear(); + this->requested.clear(); } /*** CALLBACK ***/ void ClientNetworkContentSocketHandler::OnConnect(bool success) { - for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) { + for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) { ContentCallback *cb = *iter; cb->OnConnect(success); - if (iter != this->callbacks.End() && *iter == cb) iter++; + if (iter != this->callbacks.end() && *iter == cb) iter++; } } void ClientNetworkContentSocketHandler::OnDisconnect() { - for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) { + for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) { ContentCallback *cb = *iter; cb->OnDisconnect(); - if (iter != this->callbacks.End() && *iter == cb) iter++; + if (iter != this->callbacks.end() && *iter == cb) iter++; } } void ClientNetworkContentSocketHandler::OnReceiveContentInfo(const ContentInfo *ci) { - for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) { + for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) { ContentCallback *cb = *iter; cb->OnReceiveContentInfo(ci); - if (iter != this->callbacks.End() && *iter == cb) iter++; + if (iter != this->callbacks.end() && *iter == cb) iter++; } } void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, int bytes) { - for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) { + for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) { ContentCallback *cb = *iter; cb->OnDownloadProgress(ci, bytes); - if (iter != this->callbacks.End() && *iter == cb) iter++; + if (iter != this->callbacks.end() && *iter == cb) iter++; } } @@ -1090,11 +1076,9 @@ void ClientNetworkContentSocketHandler::OnDownloadComplete(ContentID cid) ci->state = ContentInfo::ALREADY_HERE; } - for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) { + for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) { ContentCallback *cb = *iter; cb->OnDownloadComplete(cid); - if (iter != this->callbacks.End() && *iter == cb) iter++; + if (iter != this->callbacks.end() && *iter == cb) iter++; } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_content.h b/src/network/network_content.h index 25788065fd..29a25f2597 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -15,12 +15,10 @@ #include "core/tcp_content.h" #include "core/tcp_http.h" -#if defined(ENABLE_NETWORK) - /** Vector with content info */ -typedef SmallVector ContentVector; +typedef std::vector ContentVector; /** Vector with constant content info */ -typedef SmallVector ConstContentVector; +typedef std::vector ConstContentVector; /** Iterator for the content vector */ typedef ContentInfo **ContentIterator; @@ -68,12 +66,12 @@ struct ContentCallback { */ class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, ContentCallback, HTTPCallback { protected: - typedef SmallVector ContentIDList; ///< List of content IDs to (possibly) select. - SmallVector callbacks; ///< Callbacks to notify "the world" - ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again) - ContentVector infos; ///< All content info we received - SmallVector http_response; ///< The HTTP response to the requests we've been doing - int http_response_index; ///< Where we are, in the response, with handling it + typedef std::vector ContentIDList; ///< List of content IDs to (possibly) select. + std::vector callbacks; ///< Callbacks to notify "the world" + ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again) + ContentVector infos; ///< All content info we received + std::vector http_response; ///< The HTTP response to the requests we've been doing + int http_response_index; ///< Where we are, in the response, with handling it FILE *curFile; ///< Currently downloaded file ContentInfo *curInfo; ///< Information about the currently downloaded file @@ -82,20 +80,20 @@ protected: friend class NetworkContentConnecter; - virtual bool Receive_SERVER_INFO(Packet *p); - virtual bool Receive_SERVER_CONTENT(Packet *p); + bool Receive_SERVER_INFO(Packet *p) override; + bool Receive_SERVER_CONTENT(Packet *p) override; ContentInfo *GetContent(ContentID cid); void DownloadContentInfo(ContentID cid); - void OnConnect(bool success); - void OnDisconnect(); - void OnReceiveContentInfo(const ContentInfo *ci); - void OnDownloadProgress(const ContentInfo *ci, int bytes); - void OnDownloadComplete(ContentID cid); + void OnConnect(bool success) override; + void OnDisconnect() override; + void OnReceiveContentInfo(const ContentInfo *ci) override; + void OnDownloadProgress(const ContentInfo *ci, int bytes) override; + void OnDownloadComplete(ContentID cid) override; - void OnFailure(); - void OnReceiveData(const char *data, size_t length); + void OnFailure() override; + void OnReceiveData(const char *data, size_t length) override; bool BeforeDownload(); void AfterDownload(); @@ -111,7 +109,7 @@ public: void Connect(); void SendReceive(); - void Close(); + void Close() override; void RequestContentList(ContentType type); void RequestContentList(uint count, const ContentID *content_ids); @@ -131,20 +129,20 @@ public: void CheckDependencyState(ContentInfo *ci); /** Get the number of content items we know locally. */ - uint Length() const { return this->infos.Length(); } + uint Length() const { return this->infos.size(); } /** Get the begin of the content inf iterator. */ - ConstContentIterator Begin() const { return this->infos.Begin(); } + ConstContentIterator Begin() const { return this->infos.data(); } /** Get the nth position of the content inf iterator. */ - ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); } + ConstContentIterator Get(uint32 index) const { return this->infos.data() + index; } /** Get the end of the content inf iterator. */ - ConstContentIterator End() const { return this->infos.End(); } + ConstContentIterator End() const { return this->Begin() + this->Length(); } void Clear(); /** Add a callback to this class */ - void AddCallback(ContentCallback *cb) { this->callbacks.Include(cb); } + void AddCallback(ContentCallback *cb) { include(this->callbacks, cb); } /** Remove a callback */ - void RemoveCallback(ContentCallback *cb) { this->callbacks.Erase(this->callbacks.Find(cb)); } + void RemoveCallback(ContentCallback *cb) { this->callbacks.erase(std::find(this->callbacks.begin(), this->callbacks.end(), cb)); } }; extern ClientNetworkContentSocketHandler _network_content_client; @@ -153,8 +151,4 @@ void ShowNetworkContentListWindow(ContentVector *cv = NULL, ContentType type1 = void ShowMissingContentWindow(const struct GRFConfig *list); -#else -static inline void ShowNetworkContentListWindow() {} -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_CONTENT_H */ diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 877dea9786..09168185ac 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -9,7 +9,6 @@ /** @file network_content_gui.cpp Implementation of the Network Content related GUIs. */ -#if defined(ENABLE_NETWORK) #include "../stdafx.h" #include "../strings_func.h" #include "../gfx_func.h" @@ -65,7 +64,7 @@ struct ContentTextfileWindow : public TextfileWindow { } } - /* virtual */ void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, this->GetTypeString()); @@ -116,7 +115,7 @@ BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow( _network_content_client.RemoveCallback(this); } -/* virtual */ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const +void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const { if (widget != WID_NCDS_BACKGROUND) return; @@ -145,7 +144,7 @@ BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow( DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER); } -/* virtual */ void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes) +void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes) { if (ci->id != this->cur_id) { strecpy(this->name, ci->filename, lastof(this->name)); @@ -161,7 +160,7 @@ BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow( /** Window for showing the download status of content */ struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow { private: - SmallVector receivedTypes; ///< Types we received so we can update their cache + std::vector receivedTypes; ///< Types we received so we can update their cache public: /** @@ -177,8 +176,8 @@ public: ~NetworkContentDownloadStatusWindow() { TarScanner::Mode mode = TarScanner::NONE; - for (ContentType *iter = this->receivedTypes.Begin(); iter != this->receivedTypes.End(); iter++) { - switch (*iter) { + for (auto ctype : this->receivedTypes) { + switch (ctype) { case CONTENT_TYPE_AI: case CONTENT_TYPE_AI_LIBRARY: /* AI::Rescan calls the scanner. */ @@ -211,8 +210,8 @@ public: TarScanner::DoScan(mode); /* Tell all the backends about what we've downloaded */ - for (ContentType *iter = this->receivedTypes.Begin(); iter != this->receivedTypes.End(); iter++) { - switch (*iter) { + for (auto ctype : this->receivedTypes) { + switch (ctype) { case CONTENT_TYPE_AI: case CONTENT_TYPE_AI_LIBRARY: AI::Rescan(); @@ -258,7 +257,7 @@ public: InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget == WID_NCDS_CANCELOK) { if (this->downloaded_bytes != this->total_bytes) { @@ -272,10 +271,10 @@ public: } } - virtual void OnDownloadProgress(const ContentInfo *ci, int bytes) + void OnDownloadProgress(const ContentInfo *ci, int bytes) override { BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes); - this->receivedTypes.Include(ci->type); + include(this->receivedTypes, ci->type); /* When downloading is finished change cancel in ok */ if (this->downloaded_bytes == this->total_bytes) { @@ -334,8 +333,7 @@ class NetworkContentListWindow : public Window, ContentCallback { pos = strecpy(pos, "do=searchgrfid&q=", last); bool first = true; - for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) { - const ContentInfo *ci = *iter; + for (const ContentInfo *ci : this->content) { if (ci->state != ContentInfo::DOES_NOT_EXIST) continue; if (!first) pos = strecpy(pos, ",", last); @@ -386,23 +384,23 @@ class NetworkContentListWindow : public Window, ContentCallback { if (!this->content.NeedRebuild()) return; /* Create temporary array of games to use for listing */ - this->content.Clear(); + this->content.clear(); bool all_available = true; for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) { if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false; - *this->content.Append() = *iter; + this->content.push_back(*iter); } this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available); this->FilterContentList(); - this->content.Compact(); + this->content.shrink_to_fit(); this->content.RebuildDone(); this->SortContentList(); - this->vscroll->SetCount(this->content.Length()); // Update the scrollbar + this->vscroll->SetCount(this->content.size()); // Update the scrollbar this->ScrollToSelected(); } @@ -436,12 +434,8 @@ class NetworkContentListWindow : public Window, ContentCallback { { if (!this->content.Sort()) return; - for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) { - if (*iter == this->selected) { - this->list_pos = iter - this->content.Begin(); - break; - } - } + int idx = find_index(this->content, this->selected); + if (idx >= 0) this->list_pos = idx; } /** Filter content by tags/name */ @@ -479,11 +473,10 @@ class NetworkContentListWindow : public Window, ContentCallback { if (!changed) return; /* update list position */ - for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) { - if (*iter == this->selected) { - this->list_pos = iter - this->content.Begin(); - return; - } + int idx = find_index(this->content, this->selected); + if (idx >= 0) { + this->list_pos = idx; + return; } /* previously selected item not in list anymore */ @@ -563,7 +556,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 { switch (widget) { case WID_NCL_FILTER_CAPT: @@ -591,7 +584,7 @@ public: } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NCL_FILTER_CAPT: @@ -608,7 +601,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { const SortButtonState arrow = this->content.IsDescSortOrder() ? SBS_DOWN : SBS_UP; @@ -641,8 +634,13 @@ public: int sprite_y_offset = WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1; int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2; uint y = r.top; - int cnt = 0; - for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) { + + auto iter = this->content.begin() + this->vscroll->GetPosition(); + auto end = iter + this->vscroll->GetCapacity(); + if (end > this->content.end()) + end = this->content.end(); + + for (/**/; iter != end; iter++) { const ContentInfo *ci = *iter; if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY); @@ -767,8 +765,7 @@ public: char buf[DRAW_STRING_BUFFER] = ""; char *p = buf; - for (ConstContentIterator iter = tree.Begin(); iter != tree.End(); iter++) { - const ContentInfo *ci = *iter; + for (const ContentInfo *ci : tree) { if (ci == this->selected || ci->state != ContentInfo::SELECTED) continue; p += seprintf(p, lastof(buf), buf == p ? "%s" : ", %s", ci->name); @@ -780,7 +777,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_END) { if (this->selected == NULL || this->selected->state != ContentInfo::ALREADY_HERE) return; @@ -792,9 +789,9 @@ public: switch (widget) { case WID_NCL_MATRIX: { uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX); - if (id_v >= this->content.Length()) return; // click out of bounds + if (id_v >= this->content.size()) return; // click out of bounds - this->selected = *this->content.Get(id_v); + this->selected = this->content[id_v]; this->list_pos = id_v; const NWidgetBase *checkbox = this->GetWidget(WID_NCL_CHECKBOX); @@ -816,7 +813,7 @@ public: case WID_NCL_NAME: if (this->content.SortType() == widget - WID_NCL_CHECKBOX) { this->content.ToggleSortOrder(); - if (this->content.Length() > 0) this->list_pos = this->content.Length() - this->list_pos - 1; + if (this->content.size() > 0) this->list_pos = this->content.size() - this->list_pos - 1; } else { this->content.SetSortType(widget - WID_NCL_CHECKBOX); this->content.ForceResort(); @@ -866,7 +863,7 @@ public: } } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { switch (keycode) { case WKC_UP: @@ -875,7 +872,7 @@ public: break; case WKC_DOWN: /* scroll down by one */ - if (this->list_pos < (int)this->content.Length() - 1) this->list_pos++; + if (this->list_pos < (int)this->content.size() - 1) this->list_pos++; break; case WKC_PAGEUP: /* scroll up a page */ @@ -883,7 +880,7 @@ public: break; case WKC_PAGEDOWN: /* scroll down a page */ - this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.Length() - 1); + this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.size() - 1); break; case WKC_HOME: /* jump to beginning */ @@ -891,7 +888,7 @@ public: break; case WKC_END: /* jump to end */ - this->list_pos = this->content.Length() - 1; + this->list_pos = this->content.size() - 1; break; case WKC_SPACE: @@ -915,7 +912,7 @@ public: return ES_NOT_HANDLED; } - if (this->content.Length() == 0) { + if (this->content.size() == 0) { this->list_pos = 0; // above stuff may result in "-1". if (this->UpdateFilterState()) { this->content.ForceRebuild(); @@ -924,7 +921,7 @@ public: return ES_HANDLED; } - this->selected = *this->content.Get(this->list_pos); + this->selected = this->content[this->list_pos]; if (this->UpdateFilterState()) { this->content.ForceRebuild(); @@ -938,7 +935,7 @@ public: return ES_HANDLED; } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { if (wid == WID_NCL_FILTER) { this->filter_data.string_filter.SetFilterTerm(this->filter_editbox.text.buf); @@ -948,25 +945,25 @@ public: } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NCL_MATRIX); } - virtual void OnReceiveContentInfo(const ContentInfo *rci) + void OnReceiveContentInfo(const ContentInfo *rci) override { if (this->auto_select && !rci->IsSelected()) _network_content_client.ToggleSelectedState(rci); this->content.ForceRebuild(); this->InvalidateData(); } - virtual void OnDownloadComplete(ContentID cid) + void OnDownloadComplete(ContentID cid) override { this->content.ForceResort(); this->InvalidateData(); } - virtual void OnConnect(bool success) + void OnConnect(bool success) override { if (!success) { ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR); @@ -982,7 +979,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; if (this->content.NeedRebuild()) this->BuildContentList(); @@ -991,8 +988,7 @@ public: this->filesize_sum = 0; bool show_select_all = false; bool show_select_upgrade = false; - for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) { - const ContentInfo *ci = *iter; + for (const ContentInfo *ci : this->content) { switch (ci->state) { case ContentInfo::SELECTED: case ContentInfo::AUTOSELECTED: @@ -1164,9 +1160,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentT ShowErrorMessage(STR_CONTENT_NO_ZLIB, STR_CONTENT_NO_ZLIB_SUB, WL_ERROR); /* Connection failed... clean up the mess */ if (cv != NULL) { - for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) delete *iter; + for (ContentInfo *ci : *cv) delete ci; } #endif /* WITH_ZLIB */ } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 1397010019..8afd245d7c 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -39,8 +39,8 @@ public: */ ~BaseNetworkContentDownloadStatusWindow(); - virtual void DrawWidget(const Rect &r, int widget) const; - virtual void OnDownloadProgress(const ContentInfo *ci, int bytes); + void DrawWidget(const Rect &r, int widget) const override; + void OnDownloadProgress(const ContentInfo *ci, int bytes) override; }; void BuildContentTypeStringList(); diff --git a/src/network/network_func.h b/src/network/network_func.h index a4d36011b9..77a41b30d3 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -26,8 +26,6 @@ #include "../openttd.h" #include "../company_type.h" -#ifdef ENABLE_NETWORK - extern NetworkServerGameInfo _network_game_info; extern NetworkCompanyState *_network_company_states; @@ -90,5 +88,4 @@ void NetworkChatMessageLoop(); void NetworkAfterNewGRFScan(); -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_FUNC_H */ diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index e5d80630e1..6c65c52c98 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -12,8 +12,6 @@ * Also, it handles the request to a server for data about the server */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "../debug.h" #include "../window_func.h" @@ -206,5 +204,3 @@ void NetworkAfterNewGRFScan() InvalidateWindowClassesData(WC_NETWORK_WINDOW); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index fc10b9cde9..d861059607 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -9,7 +9,6 @@ /** @file network_gui.cpp Implementation of the Network related GUIs. */ -#ifdef ENABLE_NETWORK #include "../stdafx.h" #include "../strings_func.h" #include "../date_func.h" @@ -120,7 +119,7 @@ public: *lastof(this->visible) = true; } - void SetupSmallestSize(Window *w, bool init_array) + void SetupSmallestSize(Window *w, bool init_array) override { /* Oh yeah, we ought to be findable! */ w->nested_array[WID_NG_HEADER] = this; @@ -146,7 +145,7 @@ public: this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); @@ -186,7 +185,7 @@ public: } } - /* virtual */ void Draw(const Window *w) + void Draw(const Window *w) override { int i = 0; for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) { @@ -196,7 +195,7 @@ public: } } - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y) + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL; @@ -253,10 +252,10 @@ protected: if (!this->servers.NeedRebuild()) return; /* Create temporary array of games to use for listing */ - this->servers.Clear(); + this->servers.clear(); for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) { - *this->servers.Append() = ngl; + this->servers.push_back(ngl); } /* Apply the filter condition immediately, if a search string has been provided. */ @@ -270,9 +269,9 @@ protected: this->servers.SetFilterState(false); } - this->servers.Compact(); + this->servers.shrink_to_fit(); this->servers.RebuildDone(); - this->vscroll->SetCount(this->servers.Length()); + this->vscroll->SetCount(this->servers.size()); /* Sort the list of network games as requested. */ this->servers.Sort(); @@ -357,7 +356,7 @@ protected: void UpdateListPos() { this->list_pos = SLP_INVALID; - for (uint i = 0; i != this->servers.Length(); i++) { + for (uint i = 0; i != this->servers.size(); i++) { if (this->servers[i] == this->server) { this->list_pos = i; break; @@ -497,7 +496,7 @@ public: this->last_sorting = this->servers.GetListing(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_NG_CONN_BTN: @@ -506,7 +505,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_NG_CONN_BTN: @@ -561,13 +560,13 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NG_MATRIX: { uint16 y = r.top; - const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.Length()); + const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size()); for (int i = this->vscroll->GetPosition(); i < max; ++i) { const NetworkGameList *ngl = this->servers[i]; @@ -598,7 +597,7 @@ public: } - virtual void OnPaint() + void OnPaint() override { if (this->servers.NeedRebuild()) { this->BuildGUINetworkGameList(); @@ -694,7 +693,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_NG_CANCEL: // Cancel button @@ -713,7 +712,7 @@ public: case WID_NG_INFO: // Connectivity (green dot) if (this->servers.SortType() == widget - WID_NG_NAME) { this->servers.ToggleSortOrder(); - if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.Length() - this->list_pos - 1; + if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.size() - this->list_pos - 1; } else { this->servers.SetSortType(widget - WID_NG_NAME); this->servers.ForceResort(); @@ -725,7 +724,7 @@ public: case WID_NG_MATRIX: { // Show available network games uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX); - this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL; + this->server = (id_v < this->servers.size()) ? this->servers[id_v] : NULL; this->list_pos = (server == NULL) ? SLP_INVALID : id_v; this->SetDirty(); @@ -791,7 +790,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_NG_CONN_BTN: @@ -810,19 +809,19 @@ 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 { this->servers.ForceRebuild(); this->SetDirty(); } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { EventState state = ES_NOT_HANDLED; /* handle up, down, pageup, pagedown, home and end */ if (keycode == WKC_UP || keycode == WKC_DOWN || keycode == WKC_PAGEUP || keycode == WKC_PAGEDOWN || keycode == WKC_HOME || keycode == WKC_END) { - if (this->servers.Length() == 0) return ES_HANDLED; + if (this->servers.size() == 0) return ES_HANDLED; switch (keycode) { case WKC_UP: /* scroll up by one */ @@ -832,7 +831,7 @@ public: case WKC_DOWN: /* scroll down by one */ if (this->list_pos == SLP_INVALID) return ES_HANDLED; - if (this->list_pos < this->servers.Length() - 1) this->list_pos++; + if (this->list_pos < this->servers.size() - 1) this->list_pos++; break; case WKC_PAGEUP: /* scroll up a page */ @@ -842,7 +841,7 @@ public: case WKC_PAGEDOWN: /* scroll down a page */ if (this->list_pos == SLP_INVALID) return ES_HANDLED; - this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1); + this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.size() - 1); break; case WKC_HOME: /* jump to beginning */ @@ -850,7 +849,7 @@ public: break; case WKC_END: /* jump to end */ - this->list_pos = this->servers.Length() - 1; + this->list_pos = this->servers.size() - 1; break; default: NOT_REACHED(); } @@ -877,7 +876,7 @@ public: return state; } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { switch (wid) { case WID_NG_FILTER: { @@ -899,17 +898,17 @@ public: } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (!StrEmpty(str)) NetworkAddServer(str); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (!this->requery_timer.Elapsed(delta_ms)) return; this->requery_timer.SetInterval(MILLISECONDS_PER_TICK); @@ -1048,8 +1047,8 @@ void ShowNetworkGameWindow() if (first) { first = false; /* Add all servers from the config file to our list. */ - for (char **iter = _network_host_list.Begin(); iter != _network_host_list.End(); iter++) { - NetworkAddServer(*iter); + for (char *iter : _network_host_list) { + NetworkAddServer(iter); } } @@ -1070,7 +1069,7 @@ struct NetworkStartServerWindow : public Window { this->SetFocusedWidget(WID_NSS_GAMENAME); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1095,7 +1094,7 @@ struct NetworkStartServerWindow : 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_NSS_CONNTYPE_BTN: @@ -1106,7 +1105,7 @@ struct NetworkStartServerWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NSS_SETPWD: @@ -1115,7 +1114,7 @@ struct NetworkStartServerWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_NSS_CANCEL: // Cancel button @@ -1211,7 +1210,7 @@ struct NetworkStartServerWindow : public Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1227,14 +1226,14 @@ struct NetworkStartServerWindow : public Window { this->SetDirty(); } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { if (wid == WID_NSS_GAMENAME) { strecpy(_settings_client.network.server_name, this->name_editbox.text.buf, lastof(_settings_client.network.server_name)); } } - virtual void OnTimeout() + void OnTimeout() override { static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WID_NSS_SPECTATORS_BTND, WID_NSS_SPECTATORS_BTNU, WIDGET_LIST_END}; for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) { @@ -1245,7 +1244,7 @@ struct NetworkStartServerWindow : public Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; @@ -1387,7 +1386,7 @@ struct NetworkLobbyWindow : public Window { return COMPANY_FIRST; } - 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_NL_HEADER: @@ -1405,7 +1404,7 @@ struct NetworkLobbyWindow : public Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_NL_TEXT: @@ -1414,7 +1413,7 @@ struct NetworkLobbyWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NL_DETAILS: @@ -1427,7 +1426,7 @@ struct NetworkLobbyWindow : public Window { } } - virtual void OnPaint() + void OnPaint() override { const NetworkGameInfo *gi = &this->server->info; @@ -1549,7 +1548,7 @@ struct NetworkLobbyWindow : public Window { DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_NL_CANCEL: // Cancel button @@ -1588,7 +1587,7 @@ struct NetworkLobbyWindow : public Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NL_MATRIX); } @@ -1725,7 +1724,7 @@ struct NetworkClientListPopupWindow : Window { uint sel_index; ClientID client_id; Point desired_location; - SmallVector actions; ///< Actions to execute + std::vector actions; ///< Actions to execute /** * Add an action to the list of actions to execute. @@ -1734,9 +1733,7 @@ struct NetworkClientListPopupWindow : Window { */ inline void AddAction(StringID name, ClientList_Action_Proc *proc) { - ClientListAction *action = this->actions.Append(); - action->name = name; - action->proc = proc; + this->actions.push_back({name, proc}); } NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) : @@ -1767,30 +1764,30 @@ struct NetworkClientListPopupWindow : Window { CLRBITS(this->flags, WF_WHITE_BORDER); } - virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) + Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override { return this->desired_location; } - 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 = *size; - for (const ClientListAction *action = this->actions.Begin(); action != this->actions.End(); action++) { - d = maxdim(GetStringBoundingBox(action->name), d); + for (const ClientListAction &action : this->actions) { + d = maxdim(GetStringBoundingBox(action.name), d); } - d.height *= this->actions.Length(); + d.height *= this->actions.size(); d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; *size = d; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { /* Draw the actions */ int sel = this->sel_index; int y = r.top + WD_FRAMERECT_TOP; - for (const ClientListAction *action = this->actions.Begin(); action != this->actions.End(); action++, y += FONT_HEIGHT_NORMAL) { + for (const ClientListAction &action : this->actions) { TextColour colour; if (sel-- == 0) { // Selected item, highlight it GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, PC_BLACK); @@ -1799,22 +1796,23 @@ struct NetworkClientListPopupWindow : Window { colour = TC_BLACK; } - DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, action->name, colour); + DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, action.name, colour); + y += FONT_HEIGHT_NORMAL; } } - virtual void OnMouseLoop() + void OnMouseLoop() override { /* We selected an action */ uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL; if (_left_button_down) { - if (index == this->sel_index || index >= this->actions.Length()) return; + if (index == this->sel_index || index >= this->actions.size()) return; this->sel_index = index; this->SetDirty(); } else { - if (index < this->actions.Length() && _cursor.pos.y >= this->top) { + if (index < this->actions.size() && _cursor.pos.y >= this->top) { const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id); if (ci != NULL) this->actions[index].proc(ci); } @@ -1894,7 +1892,7 @@ struct NetworkClientListWindow : Window { return true; } - 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_CL_PANEL) return; @@ -1911,7 +1909,7 @@ struct NetworkClientListWindow : Window { size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT; } - virtual void OnPaint() + void OnPaint() override { /* Check if we need to reset the height */ if (!this->CheckClientListHeight()) return; @@ -1919,7 +1917,7 @@ struct NetworkClientListWindow : Window { this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_CL_PANEL) return; @@ -1965,7 +1963,7 @@ struct NetworkClientListWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { /* Show the popup with option */ if (this->selected_item != -1) { @@ -1981,7 +1979,7 @@ struct NetworkClientListWindow : Window { } } - virtual void OnMouseOver(Point pt, int widget) + void OnMouseOver(Point pt, int widget) override { /* -1 means we left the current window */ if (pt.y == -1) { @@ -2025,7 +2023,7 @@ struct NetworkJoinStatusWindow : Window { this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_NJS_BACKGROUND) return; @@ -2059,7 +2057,7 @@ struct NetworkJoinStatusWindow : Window { DrawFrameRect(r.left + 20, r.top + 5, (int)((this->width - 20) * progress / 100), r.top + 15, COLOUR_MAUVE, FR_NONE); } - 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_NJS_BACKGROUND) return; @@ -2085,7 +2083,7 @@ struct NetworkJoinStatusWindow : Window { size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget == WID_NJS_CANCELOK) { // Disconnect button NetworkDisconnect(); @@ -2094,7 +2092,7 @@ struct NetworkJoinStatusWindow : Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) { NetworkDisconnect(); @@ -2174,7 +2172,7 @@ struct NetworkCompanyPasswordWindow : public Window { NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_NCP_OK: @@ -2230,5 +2228,3 @@ void ShowNetworkCompanyPasswordWindow(Window *parent) new NetworkCompanyPasswordWindow(&_network_company_password_window_desc, parent); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_gui.h b/src/network/network_gui.h index a196c75e9f..d9dfb57dd6 100644 --- a/src/network/network_gui.h +++ b/src/network/network_gui.h @@ -17,8 +17,6 @@ #include "../window_type.h" #include "network_type.h" -#ifdef ENABLE_NETWORK - void ShowNetworkNeedPassword(NetworkPasswordType npt); void ShowNetworkGiveMoneyWindow(CompanyID company); void ShowNetworkChatQueryWindow(DestType type, int dest); @@ -42,14 +40,4 @@ struct NetworkCompanyInfo : NetworkCompanyStats { NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company); -#else /* ENABLE_NETWORK */ -/* Network function stubs when networking is disabled */ - -static inline void ShowNetworkChatQueryWindow(byte desttype, int dest) {} -static inline void ShowClientList() {} -static inline void ShowNetworkGameWindow() {} -static inline void ShowNetworkCompanyPasswordWindow(Window *parent) {} - -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_GUI_H */ diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 112d834ea8..02ccf96a7d 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -17,8 +17,6 @@ #include "../command_type.h" -#ifdef ENABLE_NETWORK - #ifdef RANDOM_DEBUG /** * If this line is enable, every frame will have a sync test @@ -171,5 +169,4 @@ StringID GetNetworkErrorMsg(NetworkErrorCode err); bool NetworkFindName(char *new_name, const char *last); const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed); -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_INTERNAL_H */ diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 734b379e16..194aae4a33 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -9,8 +9,6 @@ /** @file network_server.cpp Server part of the network protocol. */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "../strings_func.h" #include "../date_func.h" @@ -165,7 +163,7 @@ struct PacketWriter : SaveFilter { this->current = NULL; } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { /* We want to abort the saving when the socket is closed. */ if (this->cs == NULL) SlError(STR_NETWORK_ERROR_LOSTCONNECTION); @@ -192,7 +190,7 @@ struct PacketWriter : SaveFilter { this->total_size += size; } - /* virtual */ void Finish() + void Finish() override { /* We want to abort the saving when the socket is closed. */ if (this->cs == NULL) SlError(STR_NETWORK_ERROR_LOSTCONNECTION); @@ -2104,13 +2102,13 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban) /* Add address to ban-list */ if (ban) { bool contains = false; - for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) { - if (strcmp(*iter, ip) == 0) { + for (char *iter : _network_ban_list) { + if (strcmp(iter, ip) == 0) { contains = true; break; } } - if (!contains) *_network_ban_list.Append() = stredup(ip); + if (!contains) _network_ban_list.push_back(stredup(ip)); } uint n = 0; @@ -2213,5 +2211,3 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1); } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_server.h b/src/network/network_server.h index d9079672db..fe98128b82 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -12,8 +12,6 @@ #ifndef NETWORK_SERVER_H #define NETWORK_SERVER_H -#ifdef ENABLE_NETWORK - #include "network_internal.h" #include "core/tcp_listen.h" #include "../thread/thread.h" @@ -28,22 +26,22 @@ extern NetworkClientSocketPool _networkclientsocket_pool; /** Class for handling the server side of the game connection. */ class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler { protected: - virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMPANY_INFO(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_RCON(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p); + NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMPANY_INFO(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_ACK(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_RCON(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p) override; NetworkRecvStatus SendCompanyInfo(); NetworkRecvStatus SendNewGRFCheck(); @@ -81,8 +79,8 @@ public: ServerNetworkGameSocketHandler(SOCKET s); ~ServerNetworkGameSocketHandler(); - virtual Packet *ReceivePacket(); - NetworkRecvStatus CloseConnection(NetworkRecvStatus status); + virtual Packet *ReceivePacket() override; + NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override; void GetClientName(char *client_name, const char *last) const; NetworkRecvStatus SendMap(); @@ -138,12 +136,4 @@ void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded) */ #define FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0) -#else /* ENABLE_NETWORK */ -/* Network function stubs when networking is disabled */ - -static inline void NetworkServerMonthlyLoop() {} -static inline void NetworkServerYearlyLoop() {} - -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_SERVER_H */ diff --git a/src/network/network_type.h b/src/network/network_type.h index 33124fdbaa..145bc05042 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -14,8 +14,6 @@ #include "core/game.h" -#ifdef ENABLE_NETWORK - /** How many clients can we have */ static const uint MAX_CLIENTS = 255; @@ -149,5 +147,4 @@ struct NetworkTextMessageData { } }; -#endif /* ENABLE_NETWORK */ #endif /* NETWORK_TYPE_H */ diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 996749858e..1e82bd5928 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -14,8 +14,6 @@ * communication before the game is being joined. */ -#ifdef ENABLE_NETWORK - #include "../stdafx.h" #include "../date_func.h" #include "../map_func.h" @@ -133,8 +131,8 @@ void NetworkUDPQueryServer(NetworkAddress address, bool manually) /** Helper class for connecting to the master server. */ class MasterNetworkUDPSocketHandler : public NetworkUDPSocketHandler { protected: - virtual void Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr); - virtual void Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr); + void Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr) override; + void Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr) override; public: /** * Create the socket. @@ -164,9 +162,9 @@ void MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, Networ /** Helper class for handling all server side communication. */ class ServerNetworkUDPSocketHandler : public NetworkUDPSocketHandler { protected: - virtual void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr); - virtual void Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr); - virtual void Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr); + void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr) override; + void Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr) override; + void Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr) override; void Reply_CLIENT_FIND_SERVER_extended(Packet *p, NetworkAddress *client_addr, NetworkGameInfo *ngi); public: /** @@ -386,11 +384,11 @@ class ClientNetworkUDPSocketHandler : public NetworkUDPSocketHandler { private: void Receive_SERVER_RESPONSE_Common(Packet *p, NetworkAddress *client_addr, bool extended); protected: - virtual void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr); - virtual void Receive_EX_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr); - virtual void Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr); - virtual void Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr); - virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config); + void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr) override; + void Receive_EX_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr) override; + void Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr) override; + void Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr) override; + void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) override; public: virtual ~ClientNetworkUDPSocketHandler() {} }; @@ -579,12 +577,12 @@ void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFCo /** Broadcast to all ips */ static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket) { - for (NetworkAddress *addr = _broadcast_list.Begin(); addr != _broadcast_list.End(); addr++) { + for (NetworkAddress &addr : _broadcast_list) { Packet p = PrepareUdpClientFindServerPacket(); - DEBUG(net, 4, "[udp] broadcasting to %s", addr->GetHostname()); + DEBUG(net, 4, "[udp] broadcasting to %s", addr.GetHostname()); - socket->SendPacket(&p, addr, true, true); + socket->SendPacket(&p, &addr, true, true); } } @@ -752,7 +750,7 @@ void NetworkUDPInitialize() GetBindAddresses(&server, _settings_client.network.server_port); _udp_server_socket = new ServerNetworkUDPSocketHandler(&server); - server.Clear(); + server.clear(); GetBindAddresses(&server, 0); _udp_master_socket = new MasterNetworkUDPSocketHandler(&server); @@ -796,5 +794,3 @@ void NetworkBackgroundUDPLoop() _network_udp_mutex->EndCritical(); } - -#endif /* ENABLE_NETWORK */ diff --git a/src/network/network_udp.h b/src/network/network_udp.h index 3dfd076720..12de30bca3 100644 --- a/src/network/network_udp.h +++ b/src/network/network_udp.h @@ -12,8 +12,6 @@ #ifndef NETWORK_UDP_H #define NETWORK_UDP_H -#ifdef ENABLE_NETWORK - #include "core/address.h" void NetworkUDPInitialize(); @@ -25,6 +23,4 @@ void NetworkUDPRemoveAdvertise(bool blocking); void NetworkUDPClose(); void NetworkBackgroundUDPLoop(); -#endif /* ENABLE_NETWORK */ - #endif /* NETWORK_UDP_H */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index ae879af71a..459dbf5796 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -66,7 +66,7 @@ * served as subject to the initial testing of this codec. */ /** List of all loaded GRF files */ -static SmallVector _grf_files; +static std::vector _grf_files; /** Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ byte _misc_grf_features = 0; @@ -396,9 +396,8 @@ void CDECL _intl_grfmsg(int severity, const char *str, ...) */ static GRFFile *GetFileByGRFID(uint32 grfid) { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile * const *file = _grf_files.Begin(); file != end; file++) { - if ((*file)->grfid == grfid) return *file; + for (GRFFile * const file : _grf_files) { + if (file->grfid == grfid) return file; } return NULL; } @@ -410,9 +409,8 @@ static GRFFile *GetFileByGRFID(uint32 grfid) */ static GRFFile *GetFileByFilename(const char *filename) { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile * const *file = _grf_files.Begin(); file != end; file++) { - if (strcmp((*file)->filename, filename) == 0) return *file; + for (GRFFile * const file : _grf_files) { + if (strcmp(file->filename, filename) == 0) return file; } return NULL; } @@ -466,7 +464,7 @@ struct StringIDMapping { StringID source; ///< Source StringID (GRF local). StringID *target; ///< Destination for mapping result. }; -typedef SmallVector StringIDMappingVector; +typedef std::vector StringIDMappingVector; static StringIDMappingVector _string_to_grf_mapping; /** @@ -477,10 +475,7 @@ static StringIDMappingVector _string_to_grf_mapping; static void AddStringForMapping(StringID source, StringID *target) { *target = STR_UNDEFINED; - StringIDMapping *item = _string_to_grf_mapping.Append(); - item->grfid = _cur.grffile->grfid; - item->source = source; - item->target = target; + _string_to_grf_mapping.push_back({_cur.grffile->grfid, source, target}); } /** @@ -642,7 +637,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern /* Reserve the engine slot */ if (!static_access) { - EngineIDMapping *eid = _engine_mngr.Get(engine); + EngineIDMapping *eid = _engine_mngr.data() + engine; eid->grfid = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation } @@ -663,12 +658,13 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern e->grf_prop.grffile = file; /* Reserve the engine slot */ - assert(_engine_mngr.Length() == e->index); - EngineIDMapping *eid = _engine_mngr.Append(); - eid->type = type; - eid->grfid = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation - eid->internal_id = internal_id; - eid->substitute_id = min(internal_id, _engine_counts[type]); // substitute_id == _engine_counts[subtype] means "no substitute" + assert(_engine_mngr.size() == e->index); + _engine_mngr.push_back({ + scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation + internal_id, + {static_cast(type)}, + static_cast(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute" + }); if (engine_pool_size != Engine::GetPoolSize()) { /* Resize temporary engine data ... */ @@ -1093,7 +1089,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop case 0x05: { // Track type uint8 tracktype = buf->ReadByte(); - if (tracktype < _cur.grffile->railtype_list.Length()) { + if (tracktype < _cur.grffile->railtype_list.size()) { _gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype]; break; } @@ -1235,7 +1231,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; } - if (_cur.grffile->railtype_list.Length() == 0) { + if (_cur.grffile->railtype_list.size() == 0) { /* Use traction type to select between normal and electrified * rail only when no translation list is in place. */ if (_gted[e->index].railtypelabel == RAILTYPE_RAIL_LABEL && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_ELECTRIC_LABEL; @@ -1940,26 +1936,27 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, cons /* On error, bail out immediately. Temporary GRF data was already freed */ if (_cur.skip_sprites < 0) return CIR_DISABLED; - static SmallVector tmp_layout; - tmp_layout.Clear(); + static std::vector tmp_layout; + tmp_layout.clear(); for (;;) { /* no relative bounding box support */ - DrawTileSeqStruct *dtss = tmp_layout.Append(); - MemSetT(dtss, 0); - - dtss->delta_x = buf->ReadByte(); - if (dtss->IsTerminator()) break; - dtss->delta_y = buf->ReadByte(); - dtss->delta_z = buf->ReadByte(); - dtss->size_x = buf->ReadByte(); - dtss->size_y = buf->ReadByte(); - dtss->size_z = buf->ReadByte(); - - ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss->image); + /*C++17: DrawTileSeqStruct &dtss = */ tmp_layout.emplace_back(); + DrawTileSeqStruct &dtss = tmp_layout.back(); + MemSetT(&dtss, 0); + + dtss.delta_x = buf->ReadByte(); + if (dtss.IsTerminator()) break; + dtss.delta_y = buf->ReadByte(); + dtss.delta_z = buf->ReadByte(); + dtss.size_x = buf->ReadByte(); + dtss.size_y = buf->ReadByte(); + dtss.size_z = buf->ReadByte(); + + ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss.image); /* On error, bail out immediately. Temporary GRF data was already freed */ if (_cur.skip_sprites < 0) return CIR_DISABLED; } - dts->Clone(tmp_layout.Begin()); + dts->Clone(tmp_layout.data()); } break; @@ -2156,7 +2153,7 @@ static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, const GR ChangeInfoResult ret = CIR_SUCCESS; if (id + numinfo > CF_END) { - grfmsg(1, "CanalChangeInfo: Canal feature %u is invalid, max %u, ignoring", id + numinfo, CF_END); + grfmsg(1, "CanalChangeInfo: Canal feature 0x%02X is invalid, max %u, ignoring", id + numinfo, CF_END); return CIR_INVALID_ID; } @@ -2662,10 +2659,10 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader return CIR_INVALID_ID; } - translation_table.Clear(); + translation_table.clear(); for (int i = 0; i < numinfo; i++) { uint32 item = buf->ReadDWord(); - *translation_table.Append() = BSWAP32(item); + translation_table.push_back(BSWAP32(item)); } return CIR_SUCCESS; @@ -2870,14 +2867,14 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co if (map.openttd_id >= MAX_NUM_GENDERS) { grfmsg(1, "GlobalVarChangeInfo: Gender name %s is not known, ignoring", name); } else { - *_cur.grffile->language_map[curidx].gender_map.Append() = map; + _cur.grffile->language_map[curidx].gender_map.push_back(map); } } else { map.openttd_id = lang->GetCaseIndex(name); if (map.openttd_id >= MAX_NUM_CASES) { grfmsg(1, "GlobalVarChangeInfo: Case name %s is not known, ignoring", name); } else { - *_cur.grffile->language_map[curidx].case_map.Append() = map; + _cur.grffile->language_map[curidx].case_map.push_back(map); } } newgrf_id = buf->ReadByte(); @@ -4409,7 +4406,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, cons if (_cur.grffile->railtype_map[id + i] != INVALID_RAILTYPE) { int n = buf->ReadByte(); for (int j = 0; j != n; j++) { - *_railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.Append() = BSWAP32(buf->ReadDWord()); + _railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.push_back(BSWAP32(buf->ReadDWord())); } break; } @@ -4637,11 +4634,16 @@ static void FeatureChangeInfo(ByteReader *buf) uint numinfo = buf->ReadByte(); uint engine = buf->ReadExtendedByte(); - grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", + if (feature >= GSF_END) { + grfmsg(1, "FeatureChangeInfo: Unsupported feature 0x%02X, skipping", feature); + return; + } + + grfmsg(6, "FeatureChangeInfo: Feature 0x%02X, %d properties, to apply to %d+%d", feature, numprops, engine, numinfo); if (feature >= lengthof(handler) || handler[feature] == NULL) { - if (feature != GSF_CARGOES) grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); + if (feature != GSF_CARGOES) grfmsg(1, "FeatureChangeInfo: Unsupported feature 0x%02X, skipping", feature); return; } @@ -4756,9 +4758,15 @@ static void NewSpriteSet(ByteReader *buf) } uint16 num_ents = buf->ReadExtendedByte(); + if (feature >= GSF_END) { + _cur.skip_sprites = num_sets * num_ents; + grfmsg(1, "NewSpriteSet: Unsupported feature 0x%02X, skipping %d sprites", feature, _cur.skip_sprites); + return; + } + _cur.AddSpriteSets(feature, _cur.spriteid, first_set, num_sets, num_ents); - grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", + grfmsg(7, "New sprite set at %d of feature 0x%02X, consisting of %d sets with %d views each (total %d)", _cur.spriteid, feature, num_sets, num_ents, num_sets * num_ents ); @@ -4850,6 +4858,11 @@ static void NewSpriteGroup(ByteReader *buf) SpriteGroup *act_group = NULL; uint8 feature = buf->ReadByte(); + if (feature >= GSF_END) { + grfmsg(1, "NewSpriteGroup: Unsupported feature 0x%02X, skipping", feature); + return; + } + uint8 setid = buf->ReadByte(); uint8 type = buf->ReadByte(); @@ -4881,43 +4894,44 @@ static void NewSpriteGroup(ByteReader *buf) case 2: group->size = DSG_SIZE_DWORD; varsize = 4; break; } - static SmallVector adjusts; - adjusts.Clear(); + static std::vector adjusts; + adjusts.clear(); /* Loop through the var adjusts. Unfortunately we don't know how many we have * from the outset, so we shall have to keep reallocing. */ do { - DeterministicSpriteGroupAdjust *adjust = adjusts.Append(); + /*C++17: DeterministicSpriteGroupAdjust &adjust = */ adjusts.emplace_back(); + DeterministicSpriteGroupAdjust &adjust = adjusts.back(); /* The first var adjust doesn't have an operation specified, so we set it to add. */ - adjust->operation = adjusts.Length() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte(); - adjust->variable = buf->ReadByte(); - if (adjust->variable == 0x7E) { + adjust.operation = adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte(); + adjust.variable = buf->ReadByte(); + if (adjust.variable == 0x7E) { /* Link subroutine group */ - adjust->subroutine = GetGroupFromGroupID(setid, type, buf->ReadByte()); + adjust.subroutine = GetGroupFromGroupID(setid, type, buf->ReadByte()); } else { - adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? buf->ReadByte() : 0; + adjust.parameter = IsInsideMM(adjust.variable, 0x60, 0x80) ? buf->ReadByte() : 0; } varadjust = buf->ReadByte(); - adjust->shift_num = GB(varadjust, 0, 5); - adjust->type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); - adjust->and_mask = buf->ReadVarSize(varsize); + adjust.shift_num = GB(varadjust, 0, 5); + adjust.type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); + adjust.and_mask = buf->ReadVarSize(varsize); - if (adjust->type != DSGA_TYPE_NONE) { - adjust->add_val = buf->ReadVarSize(varsize); - adjust->divmod_val = buf->ReadVarSize(varsize); + if (adjust.type != DSGA_TYPE_NONE) { + adjust.add_val = buf->ReadVarSize(varsize); + adjust.divmod_val = buf->ReadVarSize(varsize); } else { - adjust->add_val = 0; - adjust->divmod_val = 0; + adjust.add_val = 0; + adjust.divmod_val = 0; } /* Continue reading var adjusts while bit 5 is set. */ } while (HasBit(varadjust, 5)); - group->num_adjusts = adjusts.Length(); + group->num_adjusts = adjusts.size(); group->adjusts = MallocT(group->num_adjusts); - MemCpyT(group->adjusts, adjusts.Begin(), group->num_adjusts); + MemCpyT(group->adjusts, adjusts.data(), group->num_adjusts); std::vector ranges; ranges.resize(buf->ReadByte()); @@ -5112,7 +5126,12 @@ static void NewSpriteGroup(ByteReader *buf) for (uint i = 0; i < group->num_input; i++) { byte rawcargo = buf->ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); - if (std::find(group->cargo_input, group->cargo_input + i, cargo) != group->cargo_input + i) { + if (cargo == CT_INVALID) { + /* The mapped cargo is invalid. This is permitted at this point, + * as long as the result is not used. Mark it invalid so this + * can be tested later. */ + group->version = 0xFF; + } else if (std::find(group->cargo_input, group->cargo_input + i, cargo) != group->cargo_input + i) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = stredup("duplicate input cargo"); return; @@ -5129,7 +5148,10 @@ static void NewSpriteGroup(ByteReader *buf) for (uint i = 0; i < group->num_output; i++) { byte rawcargo = buf->ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); - if (std::find(group->cargo_output, group->cargo_output + i, cargo) != group->cargo_output + i) { + if (cargo == CT_INVALID) { + /* Mark this result as invalid to use */ + group->version = 0xFF; + } else if (std::find(group->cargo_output, group->cargo_output + i, cargo) != group->cargo_output + i) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = stredup("duplicate output cargo"); return; @@ -5145,7 +5167,7 @@ static void NewSpriteGroup(ByteReader *buf) } /* Loading of Tile Layout and Production Callback groups would happen here */ - default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); + default: grfmsg(1, "NewSpriteGroup: Unsupported feature 0x%02X, skipping", feature); } } } @@ -5168,7 +5190,7 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype) if (feature == GSF_STATIONS && ctype == 0xFE) return CT_DEFAULT_NA; if (ctype == 0xFF) return CT_PURCHASE; - if (_cur.grffile->cargo_list.Length() == 0) { + if (_cur.grffile->cargo_list.size() == 0) { /* No cargo table, so use bitnum values */ if (ctype >= 32) { grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype); @@ -5188,8 +5210,8 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype) } /* Check if the cargo type is out of bounds of the cargo translation table */ - if (ctype >= _cur.grffile->cargo_list.Length()) { - grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur.grffile->cargo_list.Length() - 1); + if (ctype >= _cur.grffile->cargo_list.size()) { + grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1); return CT_INVALID; } @@ -5672,6 +5694,11 @@ static void FeatureMapSpriteGroup(ByteReader *buf) uint8 feature = buf->ReadByte(); uint8 idcount = buf->ReadByte(); + if (feature >= GSF_END) { + grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature 0x%02X, skipping", feature); + return; + } + /* If idcount is zero, this is a feature callback */ if (idcount == 0) { /* Skip number of cargo ids? */ @@ -5679,7 +5706,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) uint16 groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "FeatureMapSpriteGroup")) return; - grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature %d", feature); + grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature 0x%02X", feature); AddGenericCallback(feature, _cur.grffile, _cur.spritegroups[groupid]); return; @@ -5688,7 +5715,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) /* Mark the feature as used by the grf (generic callbacks do not count) */ SetBit(_cur.grffile->grf_features, feature); - grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids", feature, idcount); + grfmsg(6, "FeatureMapSpriteGroup: Feature 0x%02X, %d ids", feature, idcount); switch (feature) { case GSF_TRAINS: @@ -5739,7 +5766,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) return; default: - grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); + grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature 0x%02X, skipping", feature); return; } } @@ -5766,6 +5793,11 @@ static void FeatureNewName(ByteReader *buf) bool new_scheme = _cur.grffile->grf_version >= 7; uint8 feature = buf->ReadByte(); + if (feature >= GSF_END) { + grfmsg(1, "FeatureNewName: Unsupported feature 0x%02X, skipping", feature); + return; + } + uint8 lang = buf->ReadByte(); uint8 num = buf->ReadByte(); bool generic = HasBit(lang, 7); @@ -5782,7 +5814,7 @@ static void FeatureNewName(ByteReader *buf) uint16 endid = id + num; - grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", + grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature 0x%02X) in language 0x%02X", id, endid, feature, lang); for (; id < endid && buf->HasData(); id++) { @@ -7952,10 +7984,8 @@ static bool HandleParameterInfo(ByteReader *buf) continue; } - if (id >= _cur.grfconfig->param_info.Length()) { - uint num_to_add = id - _cur.grfconfig->param_info.Length() + 1; - GRFParameterInfo **newdata = _cur.grfconfig->param_info.Append(num_to_add); - MemSetT(newdata, 0, num_to_add); + if (id >= _cur.grfconfig->param_info.size()) { + _cur.grfconfig->param_info.resize(id + 1); } if (_cur.grfconfig->param_info[id] == NULL) { _cur.grfconfig->param_info[id] = new GRFParameterInfo(id); @@ -8199,7 +8229,7 @@ struct GRFPropertyMapAction { const char *str_store = stredup(str); grfmsg(2, "Unimplemented mapped %s: %s, feature: %X, mapped to: %X, %s on use", this->descriptor, str, this->feature, this->prop_id, (this->fallback_mode == GPMFM_IGNORE) ? "ignoring" : "error"); - *(_cur.grffile->remap_unknown_property_names.Append()) = str_store; + _cur.grffile->remap_unknown_property_names.push_back(str_store); GRFFilePropertyRemapEntry &entry = _cur.grffile->action0_property_remaps[this->feature].Entry(this->prop_id); entry.name = str_store; entry.id = (this->fallback_mode == GPMFM_IGNORE) ? A0RPI_UNKNOWN_IGNORE : A0RPI_UNKNOWN_ERROR; @@ -8244,7 +8274,7 @@ struct GRFPropertyMapAction { const char *str_store = stredup(str); grfmsg(2, "Unimplemented mapped %s: %s, mapped to: %X, %s on use", this->descriptor, str, this->prop_id, (this->fallback_mode == GPMFM_IGNORE) ? "ignoring" : "error"); - *(_cur.grffile->remap_unknown_property_names.Append()) = str_store; + _cur.grffile->remap_unknown_property_names.push_back(str_store); Action5TypeRemapEntry &entry = _cur.grffile->action5_type_remaps.Entry(this->prop_id); entry.name = str_store; entry.info = nullptr; @@ -8623,9 +8653,8 @@ static void InitializeGRFSpecial() /** Reset and clear all NewGRF stations */ static void ResetCustomStations() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - StationSpec **&stations = (*file)->stations; + for (GRFFile * const file : _grf_files) { + StationSpec **&stations = file->stations; if (stations == NULL) continue; for (uint i = 0; i < NUM_STATIONS_PER_GRF; i++) { if (stations[i] == NULL) continue; @@ -8658,9 +8687,8 @@ static void ResetCustomStations() /** Reset and clear all NewGRF houses */ static void ResetCustomHouses() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - HouseSpec **&housespec = (*file)->housespec; + for (GRFFile * const file : _grf_files) { + HouseSpec **&housespec = file->housespec; if (housespec == NULL) continue; for (uint i = 0; i < NUM_HOUSES_PER_GRF; i++) { free(housespec[i]); @@ -8674,9 +8702,8 @@ static void ResetCustomHouses() /** Reset and clear all NewGRF airports */ static void ResetCustomAirports() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - AirportSpec **aslist = (*file)->airportspec; + for (GRFFile * const file : _grf_files) { + AirportSpec **aslist = file->airportspec; if (aslist != NULL) { for (uint i = 0; i < NUM_AIRPORTS_PER_GRF; i++) { AirportSpec *as = aslist[i]; @@ -8695,10 +8722,10 @@ static void ResetCustomAirports() } } free(aslist); - (*file)->airportspec = NULL; + file->airportspec = NULL; } - AirportTileSpec **&airporttilespec = (*file)->airtspec; + AirportTileSpec **&airporttilespec = file->airtspec; if (airporttilespec != NULL) { for (uint i = 0; i < NUM_AIRPORTTILES_PER_GRF; i++) { free(airporttilespec[i]); @@ -8712,10 +8739,9 @@ static void ResetCustomAirports() /** Reset and clear all NewGRF industries */ static void ResetCustomIndustries() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - IndustrySpec **&industryspec = (*file)->industryspec; - IndustryTileSpec **&indtspec = (*file)->indtspec; + for (GRFFile * const file : _grf_files) { + IndustrySpec **&industryspec = file->industryspec; + IndustryTileSpec **&indtspec = file->indtspec; /* We are verifiying both tiles and industries specs loaded from the grf file * First, let's deal with industryspec */ @@ -8752,9 +8778,8 @@ static void ResetCustomIndustries() /** Reset and clear all NewObjects */ static void ResetCustomObjects() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - ObjectSpec **&objectspec = (*file)->objectspec; + for (GRFFile * const file : _grf_files) { + ObjectSpec **&objectspec = file->objectspec; if (objectspec == NULL) continue; for (uint i = 0; i < NUM_OBJECTS_PER_GRF; i++) { free(objectspec[i]); @@ -8768,12 +8793,11 @@ static void ResetCustomObjects() /** Reset and clear all NewGRFs */ static void ResetNewGRF() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - delete *file; + for (GRFFile * const file : _grf_files) { + delete file; } - _grf_files.Clear(); + _grf_files.clear(); _cur.grffile = NULL; } @@ -8907,13 +8931,13 @@ static void BuildCargoTranslationMap() const CargoSpec *cs = CargoSpec::Get(c); if (!cs->IsValid()) continue; - if (_cur.grffile->cargo_list.Length() == 0) { + if (_cur.grffile->cargo_list.size() == 0) { /* Default translation table, so just a straight mapping to bitnum */ _cur.grffile->cargo_map[c] = cs->bitnum; } else { /* Check the translation table for this cargo's label */ - int index = _cur.grffile->cargo_list.FindIndex(cs->label); - if (index >= 0) _cur.grffile->cargo_map[c] = index; + int idx = find_index(_cur.grffile->cargo_list, {cs->label}); + if (idx >= 0) _cur.grffile->cargo_map[c] = idx; } } } @@ -8932,7 +8956,7 @@ static void InitNewGRFFile(const GRFConfig *config) } newfile = new GRFFile(config); - *_grf_files.Append() = _cur.grffile = newfile; + _grf_files.push_back(_cur.grffile = newfile); } /** @@ -9087,7 +9111,7 @@ static void CalculateRefitMasks() { const GRFFile *file = _gted[engine].defaultcargo_grf; if (file == NULL) file = e->GetGRF(); - if (file != NULL && file->grf_version >= 8 && file->cargo_list.Length() != 0) { + if (file != NULL && file->grf_version >= 8 && file->cargo_list.size() != 0) { cargo_map_for_first_refittable = file->cargo_map; } } @@ -9289,9 +9313,8 @@ static void FinaliseHouseArray() * On the other hand, why 1930? Just 'fix' the houses with the lowest * minimum introduction date to 0. */ - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - HouseSpec **&housespec = (*file)->housespec; + for (GRFFile * const file : _grf_files) { + HouseSpec **&housespec = file->housespec; if (housespec == NULL) continue; for (int i = 0; i < NUM_HOUSES_PER_GRF; i++) { @@ -9303,7 +9326,7 @@ static void FinaliseHouseArray() const HouseSpec *next2 = (i + 2 < NUM_HOUSES_PER_GRF ? housespec[i + 2] : NULL); const HouseSpec *next3 = (i + 3 < NUM_HOUSES_PER_GRF ? housespec[i + 3] : NULL); - if (!IsHouseSpecValid(hs, next1, next2, next3, (*file)->filename)) continue; + if (!IsHouseSpecValid(hs, next1, next2, next3, file->filename)) continue; _house_mngr.SetEntitySpec(hs); } @@ -9352,10 +9375,9 @@ static void FinaliseHouseArray() */ static void FinaliseIndustriesArray() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - IndustrySpec **&industryspec = (*file)->industryspec; - IndustryTileSpec **&indtspec = (*file)->indtspec; + for (GRFFile * const file : _grf_files) { + IndustrySpec **&industryspec = file->industryspec; + IndustryTileSpec **&indtspec = file->indtspec; if (industryspec != NULL) { for (int i = 0; i < NUM_INDUSTRYTYPES_PER_GRF; i++) { IndustrySpec *indsp = industryspec[i]; @@ -9423,9 +9445,8 @@ static void FinaliseIndustriesArray() */ static void FinaliseObjectsArray() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - ObjectSpec **&objectspec = (*file)->objectspec; + for (GRFFile * const file : _grf_files) { + ObjectSpec **&objectspec = file->objectspec; if (objectspec != NULL) { for (int i = 0; i < NUM_OBJECTS_PER_GRF; i++) { if (objectspec[i] != NULL && objectspec[i]->grf_prop.grffile != NULL && objectspec[i]->enabled) { @@ -9443,9 +9464,8 @@ static void FinaliseObjectsArray() */ static void FinaliseAirportsArray() { - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - AirportSpec **&airportspec = (*file)->airportspec; + for (GRFFile * const file : _grf_files) { + AirportSpec **&airportspec = file->airportspec; if (airportspec != NULL) { for (int i = 0; i < NUM_AIRPORTS_PER_GRF; i++) { if (airportspec[i] != NULL && airportspec[i]->enabled) { @@ -9454,7 +9474,7 @@ static void FinaliseAirportsArray() } } - AirportTileSpec **&airporttilespec = (*file)->airtspec; + AirportTileSpec **&airporttilespec = file->airtspec; if (airporttilespec != NULL) { for (uint i = 0; i < NUM_AIRPORTTILES_PER_GRF; i++) { if (airporttilespec[i] != NULL && airporttilespec[i]->enabled) { @@ -9743,7 +9763,7 @@ static void FinalisePriceBaseMultipliers() static const uint32 override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT); /* Evaluate grf overrides */ - int num_grfs = _grf_files.Length(); + int num_grfs = _grf_files.size(); int *grf_overrides = AllocaM(int, num_grfs); for (int i = 0; i < num_grfs; i++) { grf_overrides[i] = -1; @@ -9755,7 +9775,7 @@ static void FinalisePriceBaseMultipliers() GRFFile *dest = GetFileByGRFID(override); if (dest == NULL) continue; - grf_overrides[i] = _grf_files.FindIndex(dest); + grf_overrides[i] = find_index(_grf_files, dest); assert(grf_overrides[i] >= 0); } @@ -9815,10 +9835,9 @@ static void FinalisePriceBaseMultipliers() } /* Apply fallback prices for grf version < 8 */ - const GRFFile * const *end = _grf_files.End(); - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - if ((*file)->grf_version >= 8) continue; - PriceMultipliers &price_base_multipliers = (*file)->price_base_multipliers; + for (GRFFile * const file : _grf_files) { + if (file->grf_version >= 8) continue; + PriceMultipliers &price_base_multipliers = file->price_base_multipliers; for (Price p = PR_BEGIN; p < PR_END; p++) { Price fallback_price = _price_base_specs[p].fallback_price; if (fallback_price != INVALID_PRICE && price_base_multipliers[p] == INVALID_PRICE_MODIFIER) { @@ -9830,21 +9849,21 @@ static void FinalisePriceBaseMultipliers() } /* Decide local/global scope of price base multipliers */ - for (GRFFile **file = _grf_files.Begin(); file != end; file++) { - PriceMultipliers &price_base_multipliers = (*file)->price_base_multipliers; + for (GRFFile * const file : _grf_files) { + PriceMultipliers &price_base_multipliers = file->price_base_multipliers; for (Price p = PR_BEGIN; p < PR_END; p++) { if (price_base_multipliers[p] == INVALID_PRICE_MODIFIER) { /* No multiplier was set; set it to a neutral value */ price_base_multipliers[p] = 0; } else { - if (!HasBit((*file)->grf_features, _price_base_specs[p].grf_feature)) { + if (!HasBit(file->grf_features, _price_base_specs[p].grf_feature)) { /* The grf does not define any objects of the feature, * so it must be a difficulty setting. Apply it globally */ - DEBUG(grf, 3, "'%s' sets global price base multiplier %d", (*file)->filename, p); + DEBUG(grf, 3, "'%s' sets global price base multiplier %d", file->filename, p); SetPriceBaseMultiplier(p, price_base_multipliers[p]); price_base_multipliers[p] = 0; } else { - DEBUG(grf, 3, "'%s' sets local price base multiplier %d", (*file)->filename, p); + DEBUG(grf, 3, "'%s' sets local price base multiplier %d", file->filename, p); } } } @@ -9856,10 +9875,10 @@ extern void InitGRFTownGeneratorNames(); /** Finish loading NewGRFs and execute needed post-processing */ static void AfterLoadGRFs() { - for (StringIDMapping *it = _string_to_grf_mapping.Begin(); it != _string_to_grf_mapping.End(); it++) { - *it->target = MapGRFStringID(it->grfid, it->source); + for (StringIDMapping &it : _string_to_grf_mapping) { + *it.target = MapGRFStringID(it.grfid, it.source); } - _string_to_grf_mapping.Clear(); + _string_to_grf_mapping.clear(); /* Free the action 6 override sprites. */ for (GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.begin(); it != _grf_line_to_action6_sprite_override.end(); it++) { diff --git a/src/newgrf.h b/src/newgrf.h index d2b8d7294e..9621789e4f 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -226,17 +226,17 @@ struct GRFFile : ZeroedMemoryAllocator { GRFFilePropertyRemapSet action0_property_remaps[GSF_END]; Action5TypeRemapSet action5_type_remaps; - AutoFreeSmallVector remap_unknown_property_names; + AutoFreeSmallVector remap_unknown_property_names; uint32 param[0x80]; uint param_end; ///< one more than the highest set parameter GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array. - SmallVector cargo_list; ///< Cargo translation table (local ID -> label) + std::vector cargo_list; ///< Cargo translation table (local ID -> label) uint8 cargo_map[NUM_CARGO]; ///< Inverse cargo translation table (CargoID -> local ID) - SmallVector railtype_list; ///< Railtype translation table + std::vector railtype_list; ///< Railtype translation table RailTypeByte railtype_map[RAILTYPE_END]; CanalProperties canal_local_properties[CF_END]; ///< Canal properties as set by this NewGRF diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index 6213097bd0..14af15a371 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -39,9 +39,9 @@ struct AirportScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - /* virtual */ void StorePSA(uint pos, int32 value); + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + void StorePSA(uint pos, int32 value) override; }; /** Resolver object for airports. */ @@ -51,7 +51,7 @@ struct AirportResolverObject : public ResolverObject { AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &this->airport_scope; @@ -59,7 +59,7 @@ struct AirportResolverObject : public ResolverObject { } } - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; /** diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h index dc04642037..e55409c1b3 100644 --- a/src/newgrf_airporttiles.h +++ b/src/newgrf_airporttiles.h @@ -38,8 +38,8 @@ struct AirportTileScopeResolver : public ScopeResolver { this->airport_id = st->airport.type; } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; }; /** Resolver for tiles of an airport. */ @@ -49,7 +49,7 @@ struct AirportTileResolverObject : public ResolverObject { AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &tiles_scope; diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index 3438bb9850..32180ee1a5 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -30,8 +30,8 @@ struct CanalScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; }; /** Resolver object for canals. */ @@ -41,7 +41,7 @@ struct CanalResolverObject : public ResolverObject { CanalResolverObject(CanalFeature feature, TileIndex tile, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &this->canal_scope; @@ -49,7 +49,7 @@ struct CanalResolverObject : public ResolverObject { } } - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; /* virtual */ uint32 CanalScopeResolver::GetRandomBits() const diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index 7d830c5730..58d4102d33 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -19,7 +19,7 @@ struct CargoResolverObject : public ResolverObject { CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; /* virtual */ const SpriteGroup *CargoResolverObject::ResolveReal(const RealSpriteGroup *group) const @@ -82,10 +82,10 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) /* Other cases use (possibly translated) cargobits */ - if (grffile->cargo_list.Length() > 0) { + if (grffile->cargo_list.size() > 0) { /* ...and the cargo is in bounds, then get the cargo ID for * the label */ - if (cargo < grffile->cargo_list.Length()) return GetCargoIDByLabel(grffile->cargo_list[cargo]); + if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]); } else { /* Else the cargo value is a 'climate independent' 'bitnum' */ return GetCargoIDByBitnum(cargo); diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 4caf3a5d47..e05217fee9 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -579,7 +579,7 @@ bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_r } -/* static */ SmallVector NewGRFSpriteLayout::result_seq; +/* static */ std::vector NewGRFSpriteLayout::result_seq; /** * Clone the building sprites of a spritelayout. @@ -661,12 +661,13 @@ void NewGRFSpriteLayout::AllocateRegisters() */ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const { - result_seq.Clear(); + result_seq.clear(); uint32 var10_values = 0; /* Create a copy of the spritelayout, so we can modify some values. * Also include the groundsprite into the sequence for easier processing. */ - DrawTileSeqStruct *result = result_seq.Append(); + /*C++17: DrawTileSeqStruct *result = &*/ result_seq.emplace_back(); + DrawTileSeqStruct *result = &result_seq.back(); result->image = ground; result->delta_x = 0; result->delta_y = 0; @@ -674,15 +675,15 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, this->seq) { - *result_seq.Append() = *dtss; + result_seq.push_back(*dtss); } - result_seq.Append()->MakeTerminator(); - + result_seq.emplace_back() /*C++17: .MakeTerminator()*/; + result_seq.back().MakeTerminator(); /* Determine the var10 values the action-1-2-3 chains needs to be resolved for, * and apply the default sprite offsets (unless disabled). */ const TileLayoutRegisters *regs = this->registers; bool ground = true; - foreach_draw_tile_seq(result, result_seq.Begin()) { + foreach_draw_tile_seq(result, result_seq.data()) { TileLayoutFlags flags = TLF_NOTHING; if (regs != NULL) flags = regs->flags; @@ -736,7 +737,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_ DrawTileSeqStruct *result; const TileLayoutRegisters *regs = this->registers; bool ground = true; - foreach_draw_tile_seq(result, result_seq.Begin()) { + foreach_draw_tile_seq(result, result_seq.data()) { TileLayoutFlags flags = TLF_NOTHING; if (regs != NULL) flags = regs->flags; diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 5721b7eb20..819e84451c 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -164,13 +164,13 @@ struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites { */ const DrawTileSeqStruct *GetLayout(PalSpriteID *ground) const { - DrawTileSeqStruct *front = result_seq.Begin(); + DrawTileSeqStruct *front = result_seq.data(); *ground = front->image; return front + 1; } private: - static SmallVector result_seq; ///< Temporary storage when preprocessing spritelayouts. + static std::vector result_seq; ///< Temporary storage when preprocessing spritelayouts. }; /** @@ -228,6 +228,7 @@ class HouseOverrideManager : public OverrideManagerBase { public: HouseOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : OverrideManagerBase(offset, maximum, invalid) {} + void SetEntitySpec(const HouseSpec *hs); }; @@ -238,8 +239,9 @@ public: IndustryOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : OverrideManagerBase(offset, maximum, invalid) {} - virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id); - virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const; + uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id) override; + uint16 GetID(uint8 grf_local_id, uint32 grfid) const override; + void SetEntitySpec(IndustrySpec *inds); }; diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 894c346fb5..e270634d37 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -83,11 +83,11 @@ GRFConfig::GRFConfig(const GRFConfig &config) : this->info->AddRef(); this->url->AddRef(); if (config.error != NULL) this->error = new GRFError(*config.error); - for (uint i = 0; i < config.param_info.Length(); i++) { + for (uint i = 0; i < config.param_info.size(); i++) { if (config.param_info[i] == NULL) { - *this->param_info.Append() = NULL; + this->param_info.push_back(NULL); } else { - *this->param_info.Append() = new GRFParameterInfo(*config.param_info[i]); + this->param_info.push_back(new GRFParameterInfo(*config.param_info[i])); } } } @@ -104,7 +104,7 @@ GRFConfig::~GRFConfig() this->info->Release(); this->url->Release(); - for (uint i = 0; i < this->param_info.Length(); i++) delete this->param_info[i]; + for (uint i = 0; i < this->param_info.size(); i++) delete this->param_info[i]; } /** @@ -155,7 +155,7 @@ void GRFConfig::SetParameterDefaults() if (!this->has_param_defaults) return; - for (uint i = 0; i < this->param_info.Length(); i++) { + for (uint i = 0; i < this->param_info.size(); i++) { if (this->param_info[i] == NULL) continue; this->param_info[i]->SetValue(this, this->param_info[i]->def_value); } @@ -182,9 +182,9 @@ void GRFConfig::SetSuitablePalette() */ void GRFConfig::FinalizeParameterInfo() { - for (GRFParameterInfo **info = this->param_info.Begin(); info != this->param_info.End(); ++info) { - if (*info == NULL) continue; - (*info)->Finalize(); + for (GRFParameterInfo *info : this->param_info) { + if (info == NULL) continue; + info->Finalize(); } } @@ -263,8 +263,8 @@ GRFParameterInfo::GRFParameterInfo(GRFParameterInfo &info) : num_bit(info.num_bit), complete_labels(info.complete_labels) { - for (uint i = 0; i < info.value_names.Length(); i++) { - SmallPair *data = info.value_names.Get(i); + for (uint i = 0; i < info.value_names.size(); i++) { + SmallPair *data = info.value_names.data() + i; this->value_names.Insert(data->first, DuplicateGRFText(data->second)); } } @@ -274,8 +274,8 @@ GRFParameterInfo::~GRFParameterInfo() { CleanUpGRFText(this->name); CleanUpGRFText(this->desc); - for (uint i = 0; i < this->value_names.Length(); i++) { - SmallPair *data = this->value_names.Get(i); + for (uint i = 0; i < this->value_names.size(); i++) { + SmallPair *data = this->value_names.data() + i; CleanUpGRFText(data->second); } } @@ -611,11 +611,11 @@ compatible_grf: c->min_loadable_version = f->min_loadable_version; c->num_valid_params = f->num_valid_params; c->has_param_defaults = f->has_param_defaults; - for (uint i = 0; i < f->param_info.Length(); i++) { + for (uint i = 0; i < f->param_info.size(); i++) { if (f->param_info[i] == NULL) { - *c->param_info.Append() = NULL; + c->param_info.push_back(NULL); } else { - *c->param_info.Append() = new GRFParameterInfo(*f->param_info[i]); + c->param_info.push_back(new GRFParameterInfo(*f->param_info[i])); } } } @@ -635,7 +635,7 @@ public: { } - /* 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; /** Do the scan for GRFs. */ static uint DoScan() @@ -759,9 +759,7 @@ void DoScanNewGRFFiles(void *callback) free(to_sort); -#ifdef ENABLE_NETWORK NetworkAfterNewGRFScan(); -#endif } _modal_progress_work_mutex->EndCritical(); @@ -828,8 +826,6 @@ const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 return best; } -#ifdef ENABLE_NETWORK - /** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */ struct UnknownGRF : public GRFIdentifier { UnknownGRF *next; ///< The next unknown GRF. @@ -879,9 +875,6 @@ GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create) return grf->name; } -#endif /* ENABLE_NETWORK */ - - /** * Retrieve a NewGRF from the current config by its grfid. * @param grfid grf to look for. diff --git a/src/newgrf_config.h b/src/newgrf_config.h index def7843db8..4a437fc794 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -133,7 +133,7 @@ struct GRFParameterInfo { byte param_nr; ///< GRF parameter to store content in byte first_bit; ///< First bit to use in the GRF parameter byte num_bit; ///< Number of bits to use for this parameter - SmallMap value_names; ///< Names for each value. + SmallMap value_names; ///< Names for each value. bool complete_labels; ///< True if all values have a label. uint32 GetValue(struct GRFConfig *config) const; @@ -155,27 +155,27 @@ struct GRFConfig : ZeroedMemoryAllocator { GRFConfig(const GRFConfig &config); ~GRFConfig(); - GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs - uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded - char *filename; ///< Filename - either with or without full path - GRFTextWrapper *name; ///< NOSAVE: GRF name (Action 0x08) - GRFTextWrapper *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) - GRFTextWrapper *url; ///< NOSAVE: URL belonging to this GRF. - GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) - - uint32 version; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown - uint32 min_loadable_version; ///< NOSAVE: Minimum compatible version a NewGRF can define - uint8 flags; ///< NOSAVE: GCF_Flags, bitset - GRFStatus status; ///< NOSAVE: GRFStatus, enum - uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs - uint32 param[0x80]; ///< GRF parameters - uint8 num_params; ///< Number of used parameters - uint8 num_valid_params; ///< NOSAVE: Number of valid parameters (action 0x14) - uint8 palette; ///< GRFPalette, bitset - SmallVector param_info; ///< NOSAVE: extra information about the parameters - bool has_param_defaults; ///< NOSAVE: did this newgrf specify any defaults for it's parameters - - struct GRFConfig *next; ///< NOSAVE: Next item in the linked list + GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs + uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded + char *filename; ///< Filename - either with or without full path + GRFTextWrapper *name; ///< NOSAVE: GRF name (Action 0x08) + GRFTextWrapper *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) + GRFTextWrapper *url; ///< NOSAVE: URL belonging to this GRF. + GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) + + uint32 version; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown + uint32 min_loadable_version; ///< NOSAVE: Minimum compatible version a NewGRF can define + uint8 flags; ///< NOSAVE: GCF_Flags, bitset + GRFStatus status; ///< NOSAVE: GRFStatus, enum + uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs + uint32 param[0x80]; ///< GRF parameters + uint8 num_params; ///< Number of used parameters + uint8 num_valid_params; ///< NOSAVE: Number of valid parameters (action 0x14) + uint8 palette; ///< GRFPalette, bitset + std::vector param_info; ///< NOSAVE: extra information about the parameters + bool has_param_defaults; ///< NOSAVE: did this newgrf specify any defaults for it's parameters + + struct GRFConfig *next; ///< NOSAVE: Next item in the linked list void CopyParams(const GRFConfig &src); @@ -231,11 +231,9 @@ char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last); /* In newgrf_gui.cpp */ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); -#ifdef ENABLE_NETWORK /** For communication about GRFs over the network */ #define UNKNOWN_GRF_NAME_PLACEHOLDER "" GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create); -#endif /* ENABLE_NETWORK */ void UpdateNewGRFScanStatus(uint num, const char *name); bool UpdateNewGRFConfigPalette(int32 p1 = 0); diff --git a/src/newgrf_debug.h b/src/newgrf_debug.h index 6e514c4ce1..dac97726da 100644 --- a/src/newgrf_debug.h +++ b/src/newgrf_debug.h @@ -29,7 +29,7 @@ struct NewGrfDebugSpritePicker { NewGrfDebugSpritePickerMode mode; ///< Current state void *clicked_pixel; ///< Clicked pixel (pointer to blitter buffer) uint32 click_time; ///< Realtime tick when clicked to detect next frame - SmallVector sprites; ///< Sprites found + std::vector sprites; ///< Sprites found }; extern NewGrfDebugSpritePicker _newgrf_debug_sprite_picker; diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 11326ec21e..554bb9f751 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -48,7 +48,7 @@ #include "safeguards.h" /** The sprite picker. */ -NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector() }; +NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, std::vector() }; /** * Get the feature index related to the window number. @@ -369,14 +369,14 @@ struct NewGRFInspectWindow : Window { this->OnInvalidateData(0, true); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget != WID_NGRFI_CAPTION) return; GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex()); } - 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_NGRFI_VEH_CHAIN: { @@ -416,7 +416,7 @@ struct NewGRFInspectWindow : Window { ::DrawString(r.left + LEFT_OFFSET, r.right - RIGHT_OFFSET, r.top + TOP_OFFSET + (offset * this->resize.step_height), buf, TC_BLACK); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NGRFI_VEH_CHAIN: { @@ -569,7 +569,7 @@ struct NewGRFInspectWindow : Window { const_cast(this)->vscroll->SetCount(i); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_NGRFI_PARENT: { @@ -621,7 +621,7 @@ struct NewGRFInspectWindow : Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; @@ -629,7 +629,7 @@ struct NewGRFInspectWindow : Window { this->SetDirty(); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NGRFI_MAINPANEL, TOP_OFFSET + BOTTOM_OFFSET); } @@ -639,7 +639,7 @@ struct NewGRFInspectWindow : 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 (this->HasChainIndex()) { @@ -847,7 +847,7 @@ struct SpriteAlignerWindow : Window { while (GetSpriteType(this->current_sprite) != ST_NORMAL) this->current_sprite++; } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL); switch (widget) { @@ -865,8 +865,8 @@ struct SpriteAlignerWindow : Window { /* Relative offset is new absolute offset - starting absolute offset. * Show 0, 0 as the relative offsets if entry is not in the map (meaning they have not been changed yet). */ - const SmallPair *key_offs_pair = this->offs_start_map.Find(this->current_sprite); - if (key_offs_pair != this->offs_start_map.End()) { + const auto key_offs_pair = this->offs_start_map.Find(this->current_sprite); + if (key_offs_pair != this->offs_start_map.end()) { SetDParam(0, spr->x_offs - key_offs_pair->second.first); SetDParam(1, spr->y_offs - key_offs_pair->second.second); } else { @@ -881,7 +881,7 @@ struct SpriteAlignerWindow : 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_SA_LIST) return; @@ -892,7 +892,7 @@ struct SpriteAlignerWindow : Window { size->height = (1 + 200 / resize->height) * resize->height; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_SA_SPRITE: { @@ -919,8 +919,8 @@ struct SpriteAlignerWindow : Window { const NWidgetBase *nwid = this->GetWidget(widget); int step_size = nwid->resize_y; - SmallVector &list = _newgrf_debug_sprite_picker.sprites; - int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.Length()); + std::vector &list = _newgrf_debug_sprite_picker.sprites; + int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size()); int y = r.top + WD_FRAMERECT_TOP; for (int i = this->vscroll->GetPosition(); i < max; i++) { @@ -933,7 +933,7 @@ struct SpriteAlignerWindow : 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_SA_PREVIOUS: @@ -965,7 +965,7 @@ struct SpriteAlignerWindow : Window { int step_size = nwid->resize_y; uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size; - if (i < _newgrf_debug_sprite_picker.sprites.Length()) { + if (i < _newgrf_debug_sprite_picker.sprites.size()) { SpriteID spr = _newgrf_debug_sprite_picker.sprites[i]; if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr; } @@ -1011,13 +1011,13 @@ struct SpriteAlignerWindow : Window { case WID_SA_RESET_REL: /* Reset the starting offsets for the current sprite. */ - this->offs_start_map.Erase(this->current_sprite); + this->offs_start_map.erase(this->offs_start_map.begin() + this->current_sprite); this->SetDirty(); break; } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; @@ -1034,17 +1034,17 @@ struct SpriteAlignerWindow : 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 (data == 1) { /* Sprite picker finished */ this->RaiseWidget(WID_SA_PICKER); - this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.Length()); + this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.size()); } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SA_LIST); } diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 63817a5e5d..8f9d3e3c89 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1191,7 +1191,7 @@ struct ListOrderChange { uint target; ///< local ID }; -static SmallVector _list_order_changes; +static std::vector _list_order_changes; /** * Record a vehicle ListOrderChange. @@ -1202,9 +1202,7 @@ static SmallVector _list_order_changes; void AlterVehicleListOrder(EngineID engine, uint target) { /* Add the list order change to a queue */ - ListOrderChange *loc = _list_order_changes.Append(); - loc->engine = engine; - loc->target = target; + _list_order_changes.push_back({engine, target}); } /** @@ -1215,17 +1213,17 @@ void AlterVehicleListOrder(EngineID engine, uint target) */ static int CDECL EnginePreSort(const EngineID *a, const EngineID *b) { - const EngineIDMapping *id_a = _engine_mngr.Get(*a); - const EngineIDMapping *id_b = _engine_mngr.Get(*b); + const EngineIDMapping &id_a = _engine_mngr.at(*a); + const EngineIDMapping &id_b = _engine_mngr.at(*b); /* 1. Sort by engine type */ - if (id_a->type != id_b->type) return (int)id_a->type - (int)id_b->type; + if (id_a.type != id_b.type) return (int)id_a.type - (int)id_b.type; /* 2. Sort by scope-GRFID */ - if (id_a->grfid != id_b->grfid) return id_a->grfid < id_b->grfid ? -1 : 1; + if (id_a.grfid != id_b.grfid) return id_a.grfid < id_b.grfid ? -1 : 1; /* 3. Sort by local ID */ - return (int)id_a->internal_id - (int)id_b->internal_id; + return (int)id_a.internal_id - (int)id_b.internal_id; } /** @@ -1234,32 +1232,31 @@ static int CDECL EnginePreSort(const EngineID *a, const EngineID *b) void CommitVehicleListOrderChanges() { /* Pre-sort engines by scope-grfid and local index */ - SmallVector ordering; + std::vector ordering; Engine *e; FOR_ALL_ENGINES(e) { - *ordering.Append() = e->index; + ordering.push_back(e->index); } - QSortT(ordering.Begin(), ordering.Length(), EnginePreSort); + QSortT(ordering.data(), ordering.size(), EnginePreSort); /* Apply Insertion-Sort operations */ - const ListOrderChange *end = _list_order_changes.End(); - for (const ListOrderChange *it = _list_order_changes.Begin(); it != end; ++it) { - EngineID source = it->engine; - uint local_target = it->target; + for (const ListOrderChange &it : _list_order_changes) { + EngineID source = it.engine; + uint local_target = it.target; - const EngineIDMapping *id_source = _engine_mngr.Get(source); + const EngineIDMapping *id_source = _engine_mngr.data() + source; if (id_source->internal_id == local_target) continue; EngineID target = _engine_mngr.GetID(id_source->type, local_target, id_source->grfid); if (target == INVALID_ENGINE) continue; - int source_index = ordering.FindIndex(source); - int target_index = ordering.FindIndex(target); + int source_index = find_index(ordering, source); + int target_index = find_index(ordering, target); assert(source_index >= 0 && target_index >= 0); assert(source_index != target_index); - EngineID *list = ordering.Begin(); + EngineID *list = ordering.data(); if (source_index < target_index) { --target_index; for (int i = source_index; i < target_index; ++i) list[i] = list[i + 1]; @@ -1271,14 +1268,15 @@ void CommitVehicleListOrderChanges() } /* Store final sort-order */ - const EngineID *idend = ordering.End(); uint index = 0; - for (const EngineID *it = ordering.Begin(); it != idend; ++it, ++index) { - Engine::Get(*it)->list_position = index; + for (const EngineID &eid : ordering) { + Engine::Get(eid)->list_position = index; + ++index; } /* Clear out the queue */ - _list_order_changes.Reset(); + _list_order_changes.clear(); + _list_order_changes.shrink_to_fit(); } /** diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index 51adb0b7fb..644ff5f015 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -40,9 +40,9 @@ struct VehicleScopeResolver : public ScopeResolver { void SetVehicle(const Vehicle *v) { this->v = v; } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - /* virtual */ uint32 GetTriggers() const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32 GetTriggers() const override; }; /** Resolver for a vehicle (chain) */ @@ -64,9 +64,9 @@ struct VehicleResolverObject : public ResolverObject { VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool info_view = false, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0); + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override; - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29; diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index aafe492052..82f4a1c80a 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -42,7 +42,7 @@ struct GenericScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; private: bool ai_callback; ///< Callback comes from the AI. @@ -55,7 +55,7 @@ struct GenericResolverObject : public ResolverObject { GenericResolverObject(bool ai_callback, CallbackID callback = CBID_NO_CALLBACK); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &this->generic_scope; @@ -63,7 +63,7 @@ struct GenericResolverObject : public ResolverObject { } } - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; struct GenericCallback { diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index cbd6320ef5..0f17d99aa0 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -166,7 +166,7 @@ struct NewGRFParametersWindow : public Window { clicked_row(UINT_MAX), editable(editable) { - this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.Length() != 0); + this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.size() != 0); this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR); @@ -190,7 +190,7 @@ struct NewGRFParametersWindow : public Window { return &dummy_parameter_info; } - 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_NP_NUMPAR_DEC: @@ -220,7 +220,7 @@ struct NewGRFParametersWindow : public Window { case WID_NP_DESCRIPTION: /* Minimum size of 4 lines. The 500 is the default size of the window. */ Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, (uint)FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM}; - for (uint i = 0; i < this->grf_config->param_info.Length(); i++) { + for (uint i = 0; i < this->grf_config->param_info.size(); i++) { const GRFParameterInfo *par_info = this->grf_config->param_info[i]; if (par_info == NULL) continue; const char *desc = GetGRFStringFromGRFText(par_info->desc); @@ -234,7 +234,7 @@ struct NewGRFParametersWindow : public Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_NP_NUMPAR: @@ -243,10 +243,10 @@ struct NewGRFParametersWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget == WID_NP_DESCRIPTION) { - const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL; + const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL; if (par_info == NULL) return; const char *desc = GetGRFStringFromGRFText(par_info->desc); if (desc == NULL) return; @@ -265,7 +265,7 @@ struct NewGRFParametersWindow : public Window { int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { - GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL; + GRFParameterInfo *par_info = (i < this->grf_config->param_info.size()) ? this->grf_config->param_info[i] : NULL; if (par_info == NULL) par_info = GetDummyParameterInfo(i); uint32 current_value = par_info->GetValue(this->grf_config); bool selected = (i == this->clicked_row); @@ -304,7 +304,7 @@ struct NewGRFParametersWindow : public Window { } } - virtual void OnPaint() + void OnPaint() override { if (this->closing_dropdown) { this->closing_dropdown = false; @@ -313,7 +313,7 @@ struct NewGRFParametersWindow : 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_NP_NUMPAR_DEC: @@ -350,7 +350,7 @@ struct NewGRFParametersWindow : public Window { if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x; x -= 4; - GRFParameterInfo *par_info = (num < this->grf_config->param_info.Length()) ? this->grf_config->param_info[num] : NULL; + GRFParameterInfo *par_info = (num < this->grf_config->param_info.size()) ? this->grf_config->param_info[num] : NULL; if (par_info == NULL) par_info = GetDummyParameterInfo(num); /* One of the arrows is clicked */ @@ -378,7 +378,7 @@ struct NewGRFParametersWindow : public Window { DropDownList *list = new DropDownList(); for (uint32 i = par_info->min_value; i <= par_info->max_value; i++) { - *list->Append() = new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false); + list->push_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false)); } ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true); @@ -427,27 +427,27 @@ struct NewGRFParametersWindow : public Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; int32 value = atoi(str); - GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL; + GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL; if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row); uint32 val = Clamp(value, par_info->min_value, par_info->max_value); par_info->SetValue(this->grf_config, val); this->SetDirty(); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { assert(this->clicked_dropdown); - GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL; + GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL; if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row); par_info->SetValue(this->grf_config, index); 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. @@ -458,7 +458,7 @@ struct NewGRFParametersWindow : public Window { this->SetDirty(); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NP_BACKGROUND); } @@ -468,7 +468,7 @@ struct NewGRFParametersWindow : public Window { * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */ - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; if (!this->action14present) { @@ -483,7 +483,7 @@ struct NewGRFParametersWindow : public Window { } } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (timeout.Elapsed(delta_ms)) { this->clicked_button = UINT_MAX; @@ -550,7 +550,7 @@ struct NewGRFTextfileWindow : public TextfileWindow { this->LoadTextfile(textfile, NEWGRF_DIR); } - /* virtual */ void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, STR_CONTENT_TYPE_NEWGRF); @@ -720,7 +720,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - 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_NS_FILE_LIST: @@ -749,7 +749,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_PRESET_LIST: { Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM); - for (uint i = 0; i < _grf_preset_list.Length(); i++) { + for (uint i = 0; i < _grf_preset_list.size(); i++) { if (_grf_preset_list[i] != NULL) { SetDParamStr(0, _grf_preset_list[i]); d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING)); @@ -771,13 +771,13 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_NS_FILE_LIST); this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_NS_PRESET_LIST: @@ -826,7 +826,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { return pal; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_NS_FILE_LIST: { @@ -884,7 +884,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; uint y = r.top + WD_FRAMERECT_TOP; uint min_index = this->vscroll2->GetPosition(); - uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.Length()); + uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.size()); for (uint i = min_index; i < max_index; i++) { const GRFConfig *c = this->avails[i]; @@ -915,7 +915,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_END) { if (this->active_sel == NULL && this->avail_sel == NULL) return; @@ -929,11 +929,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { DropDownList *list = new DropDownList(); /* Add 'None' option for clearing list */ - *list->Append() = new DropDownListStringItem(STR_NONE, -1, false); + list->push_back(new DropDownListStringItem(STR_NONE, -1, false)); - for (uint i = 0; i < _grf_preset_list.Length(); i++) { + for (uint i = 0; i < _grf_preset_list.size(); i++) { if (_grf_preset_list[i] != NULL) { - *list->Append() = new DropDownListCharStringItem(_grf_preset_list[i], i, false); + list->push_back(new DropDownListCharStringItem(_grf_preset_list[i], i, false)); } } @@ -1071,7 +1071,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, WID_NS_AVAIL_LIST); this->active_sel = NULL; DeleteWindowByClass(WC_GRF_PARAMETERS); - if (i < this->avails.Length()) { + if (i < this->avails.size()) { if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE); this->avail_sel = this->avails[i]; this->avail_pos = i; @@ -1129,11 +1129,9 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { if (!_network_available) { ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR); } else { -#if defined(ENABLE_NETWORK) this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window ShowMissingContentWindow(this->actives); -#endif } break; @@ -1144,7 +1142,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - virtual void OnNewGRFsScanned() + void OnNewGRFsScanned() override { if (this->active_sel == NULL) DeleteWindowByClass(WC_TEXTFILE); this->avail_sel = NULL; @@ -1153,7 +1151,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (!this->editable) return; @@ -1172,7 +1170,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->InvalidateData(GOID_NEWGRF_PRESET_LOADED); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; @@ -1180,7 +1178,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { GetGRFPresetList(&_grf_preset_list); /* Switch to this preset */ - for (uint i = 0; i < _grf_preset_list.Length(); i++) { + for (uint i = 0; i < _grf_preset_list.size(); i++) { if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) { this->preset = i; break; @@ -1195,7 +1193,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { * @param data Information about the changed data. @see GameOptionsInvalidationData * @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; switch (data) { @@ -1301,7 +1299,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->SetWidgetDisabledState(WID_NS_PRESET_SAVE, has_missing); } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { if (!this->editable) return ES_NOT_HANDLED; @@ -1313,7 +1311,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WKC_DOWN: /* scroll down by one */ - if (this->avail_pos < (int)this->avails.Length() - 1) this->avail_pos++; + if (this->avail_pos < (int)this->avails.size() - 1) this->avail_pos++; break; case WKC_PAGEUP: @@ -1323,7 +1321,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WKC_PAGEDOWN: /* scroll down a page */ - this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1); + this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.size() - 1); break; case WKC_HOME: @@ -1333,14 +1331,14 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WKC_END: /* jump to end */ - this->avail_pos = this->avails.Length() - 1; + this->avail_pos = this->avails.size() - 1; break; default: return ES_NOT_HANDLED; } - if (this->avails.Length() == 0) this->avail_pos = -1; + if (this->avails.size() == 0) this->avail_pos = -1; if (this->avail_pos >= 0) { this->active_sel = NULL; DeleteWindowByClass(WC_GRF_PARAMETERS); @@ -1353,7 +1351,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { return ES_HANDLED; } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { if (!this->editable) return; @@ -1363,7 +1361,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->InvalidateData(0); } - virtual void OnDragDrop(Point pt, int widget) + void OnDragDrop(Point pt, int widget) override { if (!this->editable) return; @@ -1411,7 +1409,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - virtual void OnMouseDrag(Point pt, int widget) + void OnMouseDrag(Point pt, int widget) override { if (!this->editable) return; @@ -1461,7 +1459,7 @@ private: { if (!this->avails.NeedRebuild()) return; - this->avails.Clear(); + this->avails.clear(); for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) { bool found = false; @@ -1469,7 +1467,7 @@ private: if (found) continue; if (_settings_client.gui.newgrf_show_old_versions) { - *this->avails.Append() = c; + this->avails.push_back(c); } else { const GRFConfig *best = FindGRFConfig(c->ident.grfid, HasBit(c->flags, GCF_INVALID) ? FGCM_NEWEST : FGCM_NEWEST_VALID); /* @@ -1480,22 +1478,24 @@ private: * show that NewGRF!. */ if (best->version == 0 || best->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum)) { - *this->avails.Append() = c; + this->avails.push_back(c); } } } this->avails.Filter(this->string_filter); - this->avails.Compact(); + this->avails.shrink_to_fit(); this->avails.RebuildDone(); this->avails.Sort(); if (this->avail_sel != NULL) { - this->avail_pos = this->avails.FindIndex(this->avail_sel); - if (this->avail_pos < 0) this->avail_sel = NULL; + this->avail_pos = find_index(this->avails, this->avail_sel); + if (this->avail_pos == -1) { + this->avail_sel = NULL; + } } - this->vscroll2->SetCount(this->avails.Length()); // Update the scrollbar + this->vscroll2->SetCount(this->avails.size()); // Update the scrollbar } /** @@ -1536,7 +1536,7 @@ private: /* Select next (or previous, if last one) item in the list. */ int new_pos = this->avail_pos + 1; - if (new_pos >= (int)this->avails.Length()) new_pos = this->avail_pos - 1; + if (new_pos >= (int)this->avails.size()) new_pos = this->avail_pos - 1; this->avail_pos = new_pos; if (new_pos >= 0) this->avail_sel = this->avails[new_pos]; @@ -1546,7 +1546,6 @@ private: } }; -#if defined(ENABLE_NETWORK) /** * Show the content list window with all missing grfs from the given list. * @param list The list of grfs to check for missing / not exactly matching ones. @@ -1564,11 +1563,10 @@ void ShowMissingContentWindow(const GRFConfig *list) strecpy(ci->name, c->GetName(), lastof(ci->name)); ci->unique_id = BSWAP32(c->ident.grfid); memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum)); - *cv.Append() = ci; + cv.push_back(ci); } - ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF); + ShowNetworkContentListWindow(cv.size() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF); } -#endif Listing NewGRFWindow::last_sorting = {false, 0}; Filtering NewGRFWindow::last_filtering = {false, 0}; @@ -1612,7 +1610,7 @@ public: this->editable = true; // Temporary setting, 'real' value is set in SetupSmallestSize(). } - virtual void SetupSmallestSize(Window *w, bool init_array) + void SetupSmallestSize(Window *w, bool init_array) override { /* Copy state flag from the window. */ assert(dynamic_cast(w) != NULL); @@ -1655,7 +1653,7 @@ public: this->smallest_y = ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y); } - virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override { this->StoreSizePosition(sizing, x, y, given_width, given_height); @@ -1774,7 +1772,7 @@ public: } } - virtual NWidgetCore *GetWidgetFromPos(int x, int y) + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL; @@ -1784,7 +1782,7 @@ public: return nw; } - virtual void Draw(const Window *w) + void Draw(const Window *w) override { if (this->editable) this->avs->Draw(w); this->acs->Draw(w); @@ -2063,7 +2061,7 @@ struct SavePresetWindow : public Window { GetGRFPresetList(&this->presets); this->selected = -1; if (initial_text != NULL) { - for (uint i = 0; i < this->presets.Length(); i++) { + for (uint i = 0; i < this->presets.size(); i++) { if (!strcmp(initial_text, this->presets[i])) { this->selected = i; break; @@ -2079,7 +2077,7 @@ struct SavePresetWindow : public Window { this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR); this->FinishInitNested(0); - this->vscroll->SetCount(this->presets.Length()); + this->vscroll->SetCount(this->presets.size()); this->SetFocusedWidget(WID_SVP_EDITBOX); if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text); } @@ -2088,24 +2086,24 @@ struct SavePresetWindow : 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_SVP_PRESET_LIST: { resize->height = FONT_HEIGHT_NORMAL + 2U; size->height = 0; - for (uint i = 0; i < this->presets.Length(); i++) { + for (uint i = 0; i < this->presets.size(); i++) { Dimension d = GetStringBoundingBox(this->presets[i]); size->width = max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT); resize->height = max(resize->height, d.height); } - size->height = ClampU(this->presets.Length(), 5, 20) * resize->height + 1; + size->height = ClampU(this->presets.size(), 5, 20) * resize->height + 1; break; } } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2115,7 +2113,7 @@ struct SavePresetWindow : public Window { int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; uint y = r.top + WD_FRAMERECT_TOP; uint min_index = this->vscroll->GetPosition(); - uint max_index = min(min_index + this->vscroll->GetCapacity(), this->presets.Length()); + uint max_index = min(min_index + this->vscroll->GetCapacity(), this->presets.size()); for (uint i = min_index; i < max_index; i++) { if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE); @@ -2129,12 +2127,12 @@ struct SavePresetWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_SVP_PRESET_LIST: { uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SVP_PRESET_LIST); - if (row < this->presets.Length()) { + if (row < this->presets.size()) { this->selected = row; this->presetname_editbox.text.Assign(this->presets[row]); this->SetWidgetDirty(WID_SVP_PRESET_LIST); @@ -2156,7 +2154,7 @@ struct SavePresetWindow : public Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SVP_PRESET_LIST); } @@ -2211,7 +2209,7 @@ struct ScanProgressWindow : public Window { free(last_name); } - 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_SP_PROGRESS_BAR: { @@ -2234,7 +2232,7 @@ struct ScanProgressWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_SP_PROGRESS_BAR: { diff --git a/src/newgrf_house.h b/src/newgrf_house.h index f54246be10..6cd0880524 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -44,9 +44,9 @@ struct HouseScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - /* virtual */ uint32 GetTriggers() const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32 GetTriggers() const override; }; /** @@ -79,9 +79,9 @@ struct HouseResolverObject : public ResolverObject { CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0, bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); - /* virtual */ ~HouseResolverObject(); + ~HouseResolverObject(); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return this->house_scope; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index de388c0234..457b06f675 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -308,16 +308,22 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout case 0x6A: case 0x6B: case 0x6C: - case 0x6D: { + case 0x6D: + case 0x70: + case 0x71: { CargoID cargo = GetCargoTranslation(parameter, this->ro.grffile); int index = this->industry->GetCargoProducedIndex(cargo); if (index < 0) return 0; // invalid cargo - if (variable == 0x69) return this->industry->produced_cargo_waiting[index]; - if (variable == 0x6A) return this->industry->this_month_production[index]; - if (variable == 0x6B) return this->industry->this_month_transported[index]; - if (variable == 0x6C) return this->industry->last_month_production[index]; - if (variable == 0x6D) return this->industry->last_month_transported[index]; - NOT_REACHED(); + switch (variable) { + case 0x69: return this->industry->produced_cargo_waiting[index]; + case 0x6A: return this->industry->this_month_production[index]; + case 0x6B: return this->industry->this_month_transported[index]; + case 0x6C: return this->industry->last_month_production[index]; + case 0x6D: return this->industry->last_month_transported[index]; + case 0x70: return this->industry->production_rate[index]; + case 0x71: return this->industry->last_month_pct_transported[index]; + default: NOT_REACHED(); + } } @@ -605,6 +611,17 @@ void IndustryProductionCallback(Industry *ind, int reason) if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break; const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup; + if (group->version == 0xFF) { + /* Result was marked invalid on load, display error message */ + SetDParamStr(0, spec->grf_prop.grffile->filename); + SetDParam(1, spec->name); + SetDParam(2, ind->location.tile); + ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK, WL_WARNING); + + /* abort the function early, this error isn't critical and will allow the game to continue to run */ + break; + } + bool deref = (group->version >= 1); if (group->version < 2) { diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index fa809fcd73..2fa8f7d36b 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -34,10 +34,10 @@ struct IndustriesScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - /* virtual */ uint32 GetTriggers() const; - /* virtual */ void StorePSA(uint pos, int32 value); + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32 GetTriggers() const override; + void StorePSA(uint pos, int32 value) override; }; /** Resolver for industries. */ @@ -51,7 +51,7 @@ struct IndustriesResolverObject : public ResolverObject { TownScopeResolver *GetTown(); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &industries_scope; diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index 6051c1062b..8b72932333 100644 --- a/src/newgrf_industrytiles.h +++ b/src/newgrf_industrytiles.h @@ -32,9 +32,9 @@ struct IndustryTileScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - /* virtual */ uint32 GetTriggers() const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32 GetTriggers() const override; }; /** Resolver for industry tiles. */ @@ -45,7 +45,7 @@ struct IndustryTileResolverObject : public ResolverObject { IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &indtile_scope; diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 43c8de031c..1ab351be91 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -116,8 +116,8 @@ struct ObjectScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; }; /** A resolver object to be used with feature 0F spritegroups. */ @@ -129,7 +129,7 @@ struct ObjectResolverObject : public ResolverObject { CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0); ~ObjectResolverObject(); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 8421844717..c57be5b6cc 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -139,12 +139,13 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) { /* No rail type table present, return rail type as-is */ - if (grffile == NULL || grffile->railtype_list.Length() == 0) return railtype; + if (grffile == NULL || grffile->railtype_list.size() == 0) return railtype; /* Look for a matching rail type label in the table */ RailTypeLabel label = GetRailTypeInfo(railtype)->label; - int index = grffile->railtype_list.FindIndex(label); - if (index >= 0) return index; + + int idx = find_index(grffile->railtype_list, label); + if (idx >= 0) return idx; /* If not found, return as invalid */ return 0xFF; diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index 5fadcd2ab5..829c166cb8 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -32,8 +32,8 @@ struct RailTypeScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetRandomBits() const override; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; }; /** Resolver object for rail types. */ @@ -42,7 +42,7 @@ struct RailTypeResolverObject : public ResolverObject { RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &this->railtype_scope; @@ -50,7 +50,7 @@ struct RailTypeResolverObject : public ResolverObject { } } - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = NULL); diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp index 0cc113d9df..c37d6b4ed4 100644 --- a/src/newgrf_sound.cpp +++ b/src/newgrf_sound.cpp @@ -22,7 +22,7 @@ #include "safeguards.h" -static SmallVector _sounds; +static std::vector _sounds; /** @@ -32,7 +32,7 @@ static SmallVector _sounds; */ SoundEntry *AllocateSound(uint num) { - SoundEntry *sound = _sounds.Append(num); + SoundEntry *sound = grow(_sounds, num); MemSetT(sound, 0, num); return sound; } @@ -40,7 +40,7 @@ SoundEntry *AllocateSound(uint num) void InitializeSoundPool() { - _sounds.Clear(); + _sounds.clear(); /* Copy original sound data to the pool */ SndCopyToPool(); @@ -49,14 +49,14 @@ void InitializeSoundPool() SoundEntry *GetSound(SoundID index) { - if (index >= _sounds.Length()) return NULL; + if (index >= _sounds.size()) return NULL; return &_sounds[index]; } uint GetNumSounds() { - return _sounds.Length(); + return _sounds.size(); } diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 6f038fd138..2db78f6bad 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -277,7 +277,7 @@ struct TileLayoutSpriteGroup : SpriteGroup { struct IndustryProductionSpriteGroup : SpriteGroup { IndustryProductionSpriteGroup() : SpriteGroup(SGT_INDUSTRY_PRODUCTION) {} - uint8 version; + uint8 version; ///< Production callback version used, or 0xFF if marked invalid uint8 num_input; ///< How many subtract_input values are valid int16 subtract_input[INDUSTRY_NUM_INPUTS]; ///< Take this much of the input cargo (can be negative, is indirect in cb version 1+) CargoID cargo_input[INDUSTRY_NUM_INPUTS]; ///< Which input cargoes to take from (only cb version 2) diff --git a/src/newgrf_station.h b/src/newgrf_station.h index caeafb994e..2daa64cf15 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -44,10 +44,10 @@ struct StationScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetTriggers() const; + uint32 GetRandomBits() const override; + uint32 GetTriggers() const override; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; }; /** Station resolver. */ @@ -61,7 +61,7 @@ struct StationResolverObject : public ResolverObject { TownScopeResolver *GetTown(); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: @@ -78,7 +78,7 @@ struct StationResolverObject : public ResolverObject { } } - /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; + const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; }; enum StationClassID { diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 51844d7dee..513378615e 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -168,9 +168,9 @@ static byte _currentLangID = GRFLX_ENGLISH; ///< by default, english is used. */ int LanguageMap::GetMapping(int newgrf_id, bool gender) const { - const SmallVector &map = gender ? this->gender_map : this->case_map; - for (const Mapping *m = map.Begin(); m != map.End(); m++) { - if (m->newgrf_id == newgrf_id) return m->openttd_id; + const std::vector &map = gender ? this->gender_map : this->case_map; + for (const Mapping &m : map) { + if (m.newgrf_id == newgrf_id) return m.openttd_id; } return -1; } @@ -183,9 +183,9 @@ int LanguageMap::GetMapping(int newgrf_id, bool gender) const */ int LanguageMap::GetReverseMapping(int openttd_id, bool gender) const { - const SmallVector &map = gender ? this->gender_map : this->case_map; - for (const Mapping *m = map.Begin(); m != map.End(); m++) { - if (m->openttd_id == openttd_id) return m->newgrf_id; + const std::vector &map = gender ? this->gender_map : this->case_map; + for (const Mapping &m : map) { + if (m.openttd_id == openttd_id) return m.newgrf_id; } return -1; } @@ -195,8 +195,8 @@ struct UnmappedChoiceList : ZeroedMemoryAllocator { /** Clean everything up. */ ~UnmappedChoiceList() { - for (SmallPair *p = this->strings.Begin(); p < this->strings.End(); p++) { - free(p->second); + for (SmallPair p : this->strings) { + free(p.second); } } diff --git a/src/newgrf_text.h b/src/newgrf_text.h index 033967d307..141e1536f1 100644 --- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -57,9 +57,9 @@ struct LanguageMap { * the genders/cases/plural OpenTTD IDs to the NewGRF's internal IDs. In this * case a NewGRF developer/translator might want a different translation for * both cases. Thus we are basically implementing a multi-map. */ - SmallVector gender_map; ///< Mapping of NewGRF and OpenTTD IDs for genders. - SmallVector case_map; ///< Mapping of NewGRF and OpenTTD IDs for cases. - int plural_form; ///< The plural form used for this language. + std::vector gender_map; ///< Mapping of NewGRF and OpenTTD IDs for genders. + std::vector case_map; ///< Mapping of NewGRF and OpenTTD IDs for cases. + int plural_form; ///< The plural form used for this language. int GetMapping(int newgrf_id, bool gender) const; int GetReverseMapping(int openttd_id, bool gender) const; diff --git a/src/newgrf_town.h b/src/newgrf_town.h index 3376816c9c..fcf1c4d445 100644 --- a/src/newgrf_town.h +++ b/src/newgrf_town.h @@ -64,7 +64,7 @@ struct TownResolverObject : public ResolverObject { TownResolverObject(const struct GRFFile *grffile, Town *t, bool readonly); - /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { switch (scope) { case VSG_SCOPE_SELF: return &town_scope; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index b79418c899..59c75eb514 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -308,13 +308,13 @@ struct NewsWindow : Window { GfxFillRect(r.left, r.bottom, r.right, r.bottom, PC_BLACK); } - 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 = { 0, _screen.height }; return pt; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { StringID str = STR_NULL; switch (widget) { @@ -365,12 +365,12 @@ struct NewsWindow : Window { *size = maxdim(*size, d); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_N_DATE) SetDParam(0, this->ni->date); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_N_CAPTION: @@ -427,7 +427,7 @@ struct NewsWindow : 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_N_CLOSEBOX: @@ -466,7 +466,7 @@ struct NewsWindow : Window { } } - virtual EventState OnKeyPress(WChar key, uint16 keycode) + EventState OnKeyPress(WChar key, uint16 keycode) override { if (keycode == WKC_SPACE) { /* Don't continue. */ @@ -481,7 +481,7 @@ struct NewsWindow : 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; /* The chatbar has notified us that is was either created or closed */ @@ -490,7 +490,7 @@ struct NewsWindow : Window { this->SetWindowTop(newtop); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { int count = this->timer.CountElapsed(delta_ms); if (count > 0) { @@ -1024,7 +1024,7 @@ struct MessageHistoryWindow : Window { this->OnInvalidateData(0); } - 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_MH_BACKGROUND) { this->line_height = FONT_HEIGHT_NORMAL + 2; @@ -1040,13 +1040,13 @@ struct MessageHistoryWindow : Window { } } - virtual void OnPaint() + void OnPaint() override { this->OnInvalidateData(0); this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_MH_BACKGROUND || _total_news == 0) return; @@ -1081,13 +1081,13 @@ struct MessageHistoryWindow : 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; this->vscroll->SetCount(_total_news); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget == WID_MH_BACKGROUND) { NewsItem *ni = _latest_news; @@ -1102,7 +1102,7 @@ struct MessageHistoryWindow : Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_MH_BACKGROUND); } diff --git a/src/object_base.h b/src/object_base.h index 47e5a7f94c..228eeaa2dc 100644 --- a/src/object_base.h +++ b/src/object_base.h @@ -92,6 +92,6 @@ struct ClearedObjectArea { }; ClearedObjectArea *FindClearedObject(TileIndex tile); -extern SmallVector _cleared_object_areas; +extern std::vector _cleared_object_areas; #endif /* OBJECT_BASE_H */ diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 343cf05887..4d7750491f 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -508,7 +508,7 @@ static void ReallyClearObjectTile(Object *o) delete o; } -SmallVector _cleared_object_areas; +std::vector _cleared_object_areas; /** * Find the entry in _cleared_object_areas which occupies a certain tile. @@ -519,9 +519,8 @@ ClearedObjectArea *FindClearedObject(TileIndex tile) { TileArea ta = TileArea(tile, 1, 1); - const ClearedObjectArea *end = _cleared_object_areas.End(); - for (ClearedObjectArea *coa = _cleared_object_areas.Begin(); coa != end; coa++) { - if (coa->area.Intersects(ta)) return coa; + for (ClearedObjectArea &coa : _cleared_object_areas) { + if (coa.area.Intersects(ta)) return &coa; } return NULL; @@ -596,9 +595,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) break; } - ClearedObjectArea *cleared_area = _cleared_object_areas.Append(); - cleared_area->first_tile = tile; - cleared_area->area = ta; + _cleared_object_areas.push_back({tile, ta}); if (flags & DC_EXEC) ReallyClearObjectTile(o); diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 8aabcfdc46..6684566f15 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -99,7 +99,7 @@ public: this->GetWidget(WID_BO_OBJECT_MATRIX)->SetCount(4); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_BO_OBJECT_NAME: { @@ -120,7 +120,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_BO_CLASS_LIST: { @@ -210,7 +210,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (GB(widget, 0, 16)) { case WID_BO_CLASS_LIST: { @@ -382,12 +382,12 @@ public: this->SetDirty(); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (GB(widget, 0, 16)) { case WID_BO_CLASS_LIST: { @@ -415,13 +415,13 @@ public: } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { DoCommandP(tile, ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index)->Index(), _selected_object_view, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform); } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->UpdateButtons(_selected_object_class, -1, _selected_object_view); } diff --git a/src/openttd.cpp b/src/openttd.cpp index 71a5b845a0..af851b0d4c 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -202,7 +202,6 @@ static void ShowHelp() " -e = Start Editor\n" " -g [savegame] = Start new/save game immediately\n" " -G seed = Set random seed\n" -#if defined(ENABLE_NETWORK) " -n [ip:port#company]= Join network game\n" " -p password = Password to join server\n" " -P password = Password to join company\n" @@ -211,7 +210,6 @@ static void ShowHelp() #if !defined(_WIN32) " -f = Fork into the background (dedicated only)\n" #endif -#endif /* ENABLE_NETWORK */ " -I graphics_set = Force the graphics set (see below)\n" " -S sounds_set = Force the sounds set (see below)\n" " -M music_set = Force the music set (see below)\n" @@ -351,9 +349,7 @@ static void ShutdownGame() /* Uninitialize variables that are allocated dynamically */ GamelogReset(); -#ifdef ENABLE_NETWORK free(_config_file); -#endif LinkGraphSchedule::Clear(); ClearTraceRestrictMapping(); @@ -498,7 +494,6 @@ struct AfterNewGRFScan : NewGRFScanCallback { Game::Uninitialize(true); AI::Uninitialize(true); - CheckConfig(); LoadFromHighScore(); LoadHotkeysFromConfig(); WindowDesc::LoadFromConfig(); @@ -512,13 +507,11 @@ struct AfterNewGRFScan : NewGRFScanCallback { if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear; if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed; -#if defined(ENABLE_NETWORK) if (dedicated_host != NULL) { _network_bind_list.Clear(); - *_network_bind_list.Append() = stredup(dedicated_host); + _network_bind_list.push_back(stredup(dedicated_host)); } if (dedicated_port != 0) _settings_client.network.server_port = dedicated_port; -#endif /* ENABLE_NETWORK */ /* initialize the ingame console */ IConsoleInit(); @@ -528,7 +521,6 @@ struct AfterNewGRFScan : NewGRFScanCallback { /* Make sure _settings is filled with _settings_newgame if we switch to a game directly */ if (_switch_mode != SM_NONE) MakeNewgameSettingsLive(); -#ifdef ENABLE_NETWORK if (_network_available && network_conn != NULL) { const char *port = NULL; const char *company = NULL; @@ -554,7 +546,6 @@ struct AfterNewGRFScan : NewGRFScanCallback { _switch_mode = SM_NONE; NetworkClientConnectGame(NetworkAddress(network_conn, rport), join_as, join_server_password, join_company_password); } -#endif /* ENABLE_NETWORK */ /* After the scan we're not used anymore. */ delete this; @@ -574,7 +565,6 @@ static const OptionData _options[] = { GETOPT_SHORT_VALUE('s'), GETOPT_SHORT_VALUE('v'), GETOPT_SHORT_VALUE('b'), -#if defined(ENABLE_NETWORK) GETOPT_SHORT_OPTVAL('D'), GETOPT_SHORT_OPTVAL('n'), GETOPT_SHORT_VALUE('l'), @@ -583,7 +573,6 @@ static const OptionData _options[] = { #if !defined(_WIN32) GETOPT_SHORT_NOVAL('f'), #endif -#endif /* ENABLE_NETWORK */ GETOPT_SHORT_VALUE('r'), GETOPT_SHORT_VALUE('t'), GETOPT_SHORT_OPTVAL('d'), @@ -618,13 +607,11 @@ int openttd_main(int argc, char *argv[]) /* AfterNewGRFScan sets save_config to true after scanning completed. */ bool save_config = false; AfterNewGRFScan *scanner = new AfterNewGRFScan(&save_config); -#if defined(ENABLE_NETWORK) bool dedicated = false; char *debuglog_conn = NULL; extern bool _dedicated_forks; _dedicated_forks = false; -#endif /* ENABLE_NETWORK */ _game_mode = GM_MENU; _switch_mode = SM_MENU; @@ -643,7 +630,6 @@ int openttd_main(int argc, char *argv[]) case 's': free(sounddriver); sounddriver = stredup(mgo.opt); break; case 'v': free(videodriver); videodriver = stredup(mgo.opt); break; case 'b': free(blitter); blitter = stredup(mgo.opt); break; -#if defined(ENABLE_NETWORK) case 'D': free(musicdriver); free(sounddriver); @@ -678,7 +664,6 @@ int openttd_main(int argc, char *argv[]) case 'P': scanner->join_company_password = mgo.opt; break; -#endif /* ENABLE_NETWORK */ case 'r': ParseResolution(&resolution, mgo.opt); break; case 't': scanner->startyear = atoi(mgo.opt); break; case 'd': { @@ -770,14 +755,12 @@ int openttd_main(int argc, char *argv[]) DeterminePaths(argv[0]); TarScanner::DoScan(TarScanner::BASESET); -#if defined(ENABLE_NETWORK) if (dedicated) DEBUG(net, 0, "Starting dedicated version %s", _openttd_revision); if (_dedicated_forks && !dedicated) _dedicated_forks = false; #if defined(UNIX) /* We must fork here, or we'll end up without some resources we need (like sockets) */ if (_dedicated_forks) DedicatedFork(); -#endif #endif LoadFromConfig(true); @@ -855,7 +838,6 @@ int openttd_main(int argc, char *argv[]) NetworkStartUp(); // initialize network-core -#if defined(ENABLE_NETWORK) if (debuglog_conn != NULL && _network_available) { const char *not_used = NULL; const char *port = NULL; @@ -868,7 +850,6 @@ int openttd_main(int argc, char *argv[]) NetworkStartDebugLog(NetworkAddress(debuglog_conn, rport)); } -#endif /* ENABLE_NETWORK */ if (!HandleBootstrap()) { ShutdownGame(); @@ -973,12 +954,10 @@ exit_normal: delete scanner; -#ifdef ENABLE_NETWORK extern FILE *_log_fd; if (_log_fd != NULL) { fclose(_log_fd); } -#endif /* ENABLE_NETWORK */ return ret; } @@ -1030,13 +1009,11 @@ static void MakeNewGameDone() InitializeRailGUI(); -#ifdef ENABLE_NETWORK /* We are the server, we start a new company (not dedicated), * so set the default password *if* needed. */ if (_network_server && !StrEmpty(_settings_client.network.default_company_pass)) { NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass); } -#endif /* ENABLE_NETWORK */ if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); @@ -1115,7 +1092,6 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, case SL_OK: return true; case SL_REINIT: -#ifdef ENABLE_NETWORK if (_network_dedicated) { /* * We need to reinit a network map... @@ -1131,7 +1107,6 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, /* We can't load the intro game as server, so disconnect first. */ NetworkDisconnect(); } -#endif /* ENABLE_NETWORK */ switch (ogm) { default: @@ -1148,7 +1123,6 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, void SwitchToMode(SwitchMode new_mode) { -#ifdef ENABLE_NETWORK /* If we are saving something, the network stays in his current state */ if (new_mode != SM_SAVE_GAME) { /* If the network is active, make it not-active */ @@ -1177,7 +1151,7 @@ void SwitchToMode(SwitchMode new_mode) } } } -#endif /* ENABLE_NETWORK */ + /* Make sure all AI controllers are gone at quitting game */ if (new_mode != SM_SAVE_GAME) AI::KillAll(); @@ -1188,11 +1162,9 @@ void SwitchToMode(SwitchMode new_mode) case SM_RESTARTGAME: // Restart --> 'Random game' with current settings case SM_NEWGAME: // New Game --> 'Random game' -#ifdef ENABLE_NETWORK if (_network_server) { seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "Random Map"); } -#endif /* ENABLE_NETWORK */ MakeNewGame(false, new_mode == SM_NEWGAME); break; @@ -1218,21 +1190,17 @@ void SwitchToMode(SwitchMode new_mode) IConsoleCmdExec("exec scripts/game_start.scr 0"); /* Decrease pause counter (was increased from opening load dialog) */ DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE); -#ifdef ENABLE_NETWORK if (_network_server) { seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); } -#endif /* ENABLE_NETWORK */ } break; } case SM_START_HEIGHTMAP: // Load a heightmap and start a new game from it -#ifdef ENABLE_NETWORK if (_network_server) { seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title); } -#endif /* ENABLE_NETWORK */ MakeNewGame(true, true); break; @@ -1312,10 +1280,10 @@ void CheckCaches(bool force_check) } /* Check the town caches. */ - SmallVector old_town_caches; + std::vector old_town_caches; Town *t; FOR_ALL_TOWNS(t) { - MemCpyT(old_town_caches.Append(), &t->cache); + old_town_caches.push_back(t->cache); } extern void RebuildTownCaches(); @@ -1324,26 +1292,26 @@ void CheckCaches(bool force_check) uint i = 0; FOR_ALL_TOWNS(t) { - if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) { + if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) { DEBUG(desync, 0, "town cache mismatch: town %i", (int)t->index); } i++; } /* Check company infrastructure cache. */ - SmallVector old_infrastructure; + std::vector old_infrastructure; Company *c; - FOR_ALL_COMPANIES(c) MemCpyT(old_infrastructure.Append(), &c->infrastructure); + FOR_ALL_COMPANIES(c) old_infrastructure.push_back(c->infrastructure); extern void AfterLoadCompanyStats(); AfterLoadCompanyStats(); i = 0; FOR_ALL_COMPANIES(c) { - if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) { + if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) { DEBUG(desync, 0, "infrastructure cache mismatch: company %i", (int)c->index); char buffer[4096]; - old_infrastructure.Get(i)->Dump(buffer, lastof(buffer)); + old_infrastructure[i].Dump(buffer, lastof(buffer)); DEBUG(desync, 0, "Previous:\n%s", buffer); c->infrastructure.Dump(buffer, lastof(buffer)); DEBUG(desync, 0, "Recalculated:\n%s", buffer); @@ -1649,10 +1617,8 @@ static void DoAutosave() void GameLoop() { if (_game_mode == GM_BOOTSTRAP) { -#ifdef ENABLE_NETWORK /* Check for UDP stuff */ if (_network_available) NetworkBackgroundLoop(); -#endif InputLoop(); return; } @@ -1675,7 +1641,6 @@ void GameLoop() IncreaseSpriteLRU(); InteractiveRandom(); -#ifdef ENABLE_NETWORK /* Check for UDP stuff */ if (_network_available) NetworkBackgroundLoop(); @@ -1691,9 +1656,6 @@ void GameLoop() /* Singleplayer */ StateGameLoop(); } -#else - StateGameLoop(); -#endif /* ENABLE_NETWORK */ if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); diff --git a/src/order_backup.cpp b/src/order_backup.cpp index c144e100af..2aec5962dc 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -194,11 +194,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, * but compiled it. A network client has its own variable for the unique * client/user identifier. Finally if networking isn't compiled in the * default is just plain and simple: 0. */ -#ifdef ENABLE_NETWORK uint32 user = _networking && !_network_server ? _network_own_client_id : CLIENT_ID_SERVER; -#else - uint32 user = 0; -#endif OrderBackup *ob; FOR_ALL_ORDER_BACKUPS(ob) { @@ -268,6 +264,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, for (Order *order = ob->orders; order != NULL; order = order->next) { OrderType ot = order->GetType(); if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue; + if (ot == OT_GOTO_DEPOT && hangar && !IsHangarTile(ob->tile)) continue; // Not an aircraft? Can't have a hangar order. if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION; if (ot == type && order->GetDestination() == destination) { /* Remove the order backup! If a station/depot gets removed, we can't/shouldn't restore those broken orders. */ diff --git a/src/order_base.h b/src/order_base.h index e1a7be8bfa..78f40cb227 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -99,7 +99,7 @@ public: Order *next; ///< Pointer to next order. If NULL, end of list - Order() : refit_cargo(CT_NO_REFIT), max_speed(UINT16_MAX) {} + Order() : flags(0), refit_cargo(CT_NO_REFIT), max_speed(UINT16_MAX) {} ~Order(); Order(uint32 packed); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 60dcedbca8..047c1c6116 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -2299,7 +2299,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool FOR_ALL_VEHICLES(v) { Order *order = &v->current_order; if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type && - v->current_order.GetDestination() == destination) { + (!hangar || v->type == VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) { order->MakeDummy(); SetWindowDirty(WC_VEHICLE_VIEW, v->index); } @@ -2310,6 +2310,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool RemoveVehicleOrdersIf(v, [&](const Order *o) { OrderType ot = o->GetType(); if (ot == OT_GOTO_DEPOT && (o->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) return false; + if (ot == OT_GOTO_DEPOT && hangar && v->type != VEH_AIRCRAFT) return false; // Not an aircraft? Can't have a hangar order. if (ot == OT_IMPLICIT || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION; return (ot == type && o->GetDestination() == destination); }); diff --git a/src/order_gui.cpp b/src/order_gui.cpp index d4f60a6ec3..6cc475ca82 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1452,7 +1452,7 @@ public: } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) OVERRIDE + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_O_OCCUPANCY_LIST: @@ -1500,7 +1500,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) OVERRIDE + void OnInvalidateData(int data = 0, bool gui_scope = true) override { VehicleOrderID from = INVALID_VEH_ORDER_ID; VehicleOrderID to = INVALID_VEH_ORDER_ID; @@ -1770,7 +1770,7 @@ public: this->SetDirty(); } - virtual void OnPaint() OVERRIDE + void OnPaint() override { if (this->vehicle->owner != _local_company) { this->selected_order = -1; // Disable selection any selected row at a competitor order window. @@ -1780,7 +1780,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const OVERRIDE + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_O_ORDER_LIST: @@ -1873,7 +1873,7 @@ public: } } - virtual void SetStringParameters(int widget) const OVERRIDE + void SetStringParameters(int widget) const override { switch (widget) { case WID_O_COND_VALUE: { @@ -1916,7 +1916,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) OVERRIDE + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_O_ORDER_LIST: { @@ -2085,9 +2085,9 @@ public: DropDownList *list = new DropDownList(); for (size_t i = 0; i < _sorted_standard_cargo_specs_size; ++i) { const CargoSpec *cs = _sorted_cargo_specs[i]; - *list->Append() = new DropDownListStringItem(cs->name, cs->Index(), false); + list->push_back(new DropDownListStringItem(cs->name, cs->Index(), false)); } - if (list->Length() == 0) { + if (list->size() == 0) { delete list; return; } @@ -2102,7 +2102,7 @@ public: case WID_O_COND_VARIABLE: { DropDownList *list = new DropDownList(); for (uint i = 0; i < lengthof(_order_conditional_variable); i++) { - *list->Append() = new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false); + list->push_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false)); } ShowDropDownList(this, list, this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE); break; @@ -2148,7 +2148,7 @@ public: } } - virtual void OnQueryTextFinished(char *str) OVERRIDE + void OnQueryTextFinished(char *str) override { if (this->query_text_widget == WID_O_COND_VALUE && !StrEmpty(str)) { VehicleOrderID sel = this->OrderGetSel(); @@ -2176,7 +2176,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) OVERRIDE + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_O_NON_STOP: @@ -2227,7 +2227,7 @@ public: } } - virtual void OnDragDrop(Point pt, int widget) OVERRIDE + void OnDragDrop(Point pt, int widget) override { switch (widget) { case WID_O_ORDER_LIST: { @@ -2260,7 +2260,7 @@ public: } } - virtual EventState OnHotkey(int hotkey) OVERRIDE + EventState OnHotkey(int hotkey) override { if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED; @@ -2281,7 +2281,7 @@ public: return ES_HANDLED; } - virtual void OnPlaceObject(Point pt, TileIndex tile) OVERRIDE + void OnPlaceObject(Point pt, TileIndex tile) override { if (this->goto_type == OPOS_GOTO) { const Order cmd = GetOrderCmdFromTile(this->vehicle, tile); @@ -2294,7 +2294,7 @@ public: } } - virtual bool OnVehicleSelect(const Vehicle *v) OVERRIDE + bool OnVehicleSelect(const Vehicle *v) override { /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet. * We disallow copying orders of other vehicles if we already have at least one order entry @@ -2312,7 +2312,7 @@ public: return true; } - virtual void OnPlaceObjectAbort() OVERRIDE + void OnPlaceObjectAbort() override { this->goto_type = OPOS_NONE; this->SetWidgetDirty(WID_O_GOTO); @@ -2324,7 +2324,7 @@ public: } } - virtual void OnMouseDrag(Point pt, int widget) OVERRIDE + void OnMouseDrag(Point pt, int widget) override { if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) { /* An order is dragged.. */ @@ -2344,7 +2344,7 @@ public: } } - virtual void OnResize() OVERRIDE + void OnResize() override { /* Update the scroll bar */ this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST); diff --git a/src/os/macosx/crashlog_osx.cpp b/src/os/macosx/crashlog_osx.cpp index bcb1032cdd..36d5f608d3 100644 --- a/src/os/macosx/crashlog_osx.cpp +++ b/src/os/macosx/crashlog_osx.cpp @@ -52,7 +52,7 @@ class CrashLogOSX : public CrashLog { char filename_save[MAX_PATH]; ///< Path of crash.sav char filename_screenshot[MAX_PATH]; ///< Path of crash.(png|bmp|pcx) - /* virtual */ char *LogOSVersion(char *buffer, const char *last) const + char *LogOSVersion(char *buffer, const char *last) const override { int ver_maj, ver_min, ver_bug; GetMacOSVersion(&ver_maj, &ver_min, &ver_bug); @@ -71,7 +71,7 @@ class CrashLogOSX : public CrashLog { ); } - /* virtual */ char *LogError(char *buffer, const char *last, const char *message) const + char *LogError(char *buffer, const char *last, const char *message) const override { return buffer + seprintf(buffer, last, "Crash reason:\n" @@ -83,7 +83,7 @@ class CrashLogOSX : public CrashLog { ); } - /* virtual */ char *LogStacktrace(char *buffer, const char *last) const + char *LogStacktrace(char *buffer, const char *last) const override { /* As backtrace() is only implemented in 10.5 or later, * we're rolling our own here. Mostly based on diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 1c5d558855..e14ca4183b 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -65,7 +65,7 @@ public: }; /** A single line worth of VisualRuns. */ - class CoreTextLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { + class CoreTextLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { public: CoreTextLine(CTLineRef line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff) { @@ -75,18 +75,18 @@ public: /* Extract font information for this run. */ CFRange chars = CTRunGetStringRange(run); - FontMap::const_iterator map = fontMapping.Begin(); - while (map < fontMapping.End() - 1 && map->first <= chars.location) map++; + auto map = fontMapping.begin(); + while (map < fontMapping.end() - 1 && map->first <= chars.location) map++; - *this->Append() = new CoreTextVisualRun(run, map->second, buff); + this->push_back(new CoreTextVisualRun(run, map->second, buff)); } CFRelease(line); } virtual int GetLeading() const; virtual int GetWidth() const; - virtual int CountRuns() const { return this->Length(); } - virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + virtual int CountRuns() const { return this->size(); } + virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { @@ -137,8 +137,8 @@ static CTRunDelegateCallbacks _sprite_font_callback = { if (length == 0) return NULL; /* Can't layout our in-built sprite fonts. */ - for (FontMap::const_iterator i = fontMapping.Begin(); i != fontMapping.End(); i++) { - if (i->second->fc->IsBuiltInFont()) return NULL; + for (const auto &i : fontMapping) { + if (i.second->fc->IsBuiltInFont()) return NULL; } /* Make attributed string with embedded font information. */ @@ -152,31 +152,31 @@ static CTRunDelegateCallbacks _sprite_font_callback = { /* Apply font and colour ranges to our string. This is important to make sure * that we get proper glyph boundaries on style changes. */ int last = 0; - for (FontMap::const_iterator i = fontMapping.Begin(); i != fontMapping.End(); i++) { - if (i->first - last == 0) continue; + for (const auto &i : fontMapping) { + if (i.first - last == 0) continue; - if (_font_cache[i->second->fc->GetSize()] == NULL) { + if (_font_cache[i.second->fc->GetSize()] == NULL) { /* Cache font information. */ - CFStringRef font_name = CFStringCreateWithCString(kCFAllocatorDefault, i->second->fc->GetFontName(), kCFStringEncodingUTF8); - _font_cache[i->second->fc->GetSize()] = CTFontCreateWithName(font_name, i->second->fc->GetFontSize(), NULL); + CFStringRef font_name = CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName(), kCFStringEncodingUTF8); + _font_cache[i.second->fc->GetSize()] = CTFontCreateWithName(font_name, i.second->fc->GetFontSize(), NULL); CFRelease(font_name); } - CFAttributedStringSetAttribute(str, CFRangeMake(last, i->first - last), kCTFontAttributeName, _font_cache[i->second->fc->GetSize()]); + CFAttributedStringSetAttribute(str, CFRangeMake(last, i.first - last), kCTFontAttributeName, _font_cache[i.second->fc->GetSize()]); - CGColorRef color = CGColorCreateGenericGray((uint8)i->second->colour / 255.0f, 1.0f); // We don't care about the real colours, just that they are different. - CFAttributedStringSetAttribute(str, CFRangeMake(last, i->first - last), kCTForegroundColorAttributeName, color); + CGColorRef color = CGColorCreateGenericGray((uint8)i.second->colour / 255.0f, 1.0f); // We don't care about the real colours, just that they are different. + CFAttributedStringSetAttribute(str, CFRangeMake(last, i.first - last), kCTForegroundColorAttributeName, color); CGColorRelease(color); /* Install a size callback for our special sprite glyphs. */ - for (ssize_t c = last; c < i->first; c++) { + for (ssize_t c = last; c < i.first; c++) { if (buff[c] >= SCC_SPRITE_START && buff[c] <= SCC_SPRITE_END) { - CTRunDelegateRef del = CTRunDelegateCreate(&_sprite_font_callback, (void *)(size_t)(buff[c] | (i->second->fc->GetSize() << 24))); + CTRunDelegateRef del = CTRunDelegateCreate(&_sprite_font_callback, (void *)(size_t)(buff[c] | (i.second->fc->GetSize() << 24))); CFAttributedStringSetAttribute(str, CFRangeMake(c, 1), kCTRunDelegateAttributeName, del); CFRelease(del); } } - last = i->first; + last = i.first; } CFAttributedStringEndEditing(str); @@ -243,8 +243,8 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font int CoreTextParagraphLayout::CoreTextLine::GetLeading() const { int leading = 0; - for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) { - leading = max(leading, (*run)->GetLeading()); + for (const CoreTextVisualRun * const &run : *this) { + leading = max(leading, run->GetLeading()); } return leading; @@ -256,11 +256,11 @@ int CoreTextParagraphLayout::CoreTextLine::GetLeading() const */ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const { - if (this->Length() == 0) return 0; + if (this->size() == 0) return 0; int total_width = 0; - for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) { - total_width += (*run)->GetAdvance(); + for (const CoreTextVisualRun * const &run : *this) { + total_width += run->GetAdvance(); } return total_width; diff --git a/src/os/unix/crashlog_unix.cpp b/src/os/unix/crashlog_unix.cpp index a07403d160..a44151bb82 100644 --- a/src/os/unix/crashlog_unix.cpp +++ b/src/os/unix/crashlog_unix.cpp @@ -140,7 +140,7 @@ class CrashLogUnix : public CrashLog { void *signal_instruction_ptr; #endif - /* virtual */ char *LogOSVersion(char *buffer, const char *last) const + char *LogOSVersion(char *buffer, const char *last) const override { struct utsname name; if (uname(&name) < 0) { @@ -160,7 +160,7 @@ class CrashLogUnix : public CrashLog { ); } - /* virtual */ char *LogOSVersionDetail(char *buffer, const char *last) const + char *LogOSVersionDetail(char *buffer, const char *last) const override { struct utsname name; if (uname(&name) < 0) return buffer; @@ -177,7 +177,7 @@ class CrashLogUnix : public CrashLog { return buffer; } - /* virtual */ char *LogError(char *buffer, const char *last, const char *message) const + char *LogError(char *buffer, const char *last, const char *message) const override { buffer += seprintf(buffer, last, "Crash reason:\n" @@ -247,7 +247,7 @@ class CrashLogUnix : public CrashLog { * * Also log GDB information if available */ - /* virtual */ char *LogRegisters(char *buffer, const char *last) const + char *LogRegisters(char *buffer, const char *last) const { buffer = LogGdbInfo(buffer, last); @@ -387,7 +387,7 @@ class CrashLogUnix : public CrashLog { * Note that GCC complains about 'buffer' being clobbered by the longjmp. * This is not an issue as we save/restore it explicitly, so silence the warning. */ - /* virtual */ char *LogStacktrace(char *buffer, const char *last) const + char *LogStacktrace(char *buffer, const char *last) const override { buffer += seprintf(buffer, last, "Stacktrace:\n"); diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 1471d95942..0fc345cdba 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -31,9 +31,6 @@ #include "../../safeguards.h" -static const uint MAX_SYMBOL_LEN = 512; -static const uint MAX_FRAMES = 64; - /* printf format specification for 32/64-bit addresses. */ #ifdef _M_AMD64 #define PRINTF_PTR "0x%016IX" @@ -48,14 +45,14 @@ class CrashLogWindows : public CrashLog { /** Information about the encountered exception */ EXCEPTION_POINTERS *ep; - /* virtual */ char *LogOSVersion(char *buffer, const char *last) const; - /* virtual */ char *LogError(char *buffer, const char *last, const char *message) const; - /* virtual */ char *LogStacktrace(char *buffer, const char *last) const; - /* virtual */ char *LogRegisters(char *buffer, const char *last) const; - /* virtual */ char *LogModules(char *buffer, const char *last) const; + char *LogOSVersion(char *buffer, const char *last) const override; + char *LogError(char *buffer, const char *last, const char *message) const override; + char *LogStacktrace(char *buffer, const char *last) const override; + char *LogRegisters(char *buffer, const char *last) const override; + char *LogModules(char *buffer, const char *last) const override; public: #if defined(_MSC_VER) || defined(WITH_DBGHELP) - /* virtual */ int WriteCrashDump(char *filename, const char *filename_last) const; + int WriteCrashDump(char *filename, const char *filename_last) const override; char *AppendDecodedStacktrace(char *buffer, const char *last) const; #else char *AppendDecodedStacktrace(char *buffer, const char *last) const { return buffer; } @@ -329,6 +326,9 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod) #if defined(_MSC_VER) || defined(WITH_DBGHELP) #if defined(_MSC_VER) +static const uint MAX_SYMBOL_LEN = 512; +static const uint MAX_FRAMES = 64; + #pragma warning(disable:4091) #endif #include diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index ce61537b2b..5cba9a3d8b 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -106,12 +106,12 @@ public: }; /** A single line worth of VisualRuns. */ - class UniscribeLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { + class UniscribeLine : public AutoDeleteSmallVector, public ParagraphLayouter::Line { public: virtual int GetLeading() const; virtual int GetWidth() const; - virtual int CountRuns() const { return this->Length(); } - virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + virtual int CountRuns() const { return this->size(); } + virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { @@ -282,8 +282,8 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF if (length == 0) return NULL; /* Can't layout our in-built sprite fonts. */ - for (FontMap::const_iterator i = fontMapping.Begin(); i != fontMapping.End(); i++) { - if (i->second->fc->IsBuiltInFont()) return NULL; + for (auto const &pair : fontMapping) { + if (pair.second->fc->IsBuiltInFont()) return NULL; } /* Itemize text. */ @@ -296,12 +296,12 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF int cur_pos = 0; std::vector::iterator cur_item = items.begin(); - for (FontMap::const_iterator i = fontMapping.Begin(); i != fontMapping.End(); i++) { - while (cur_pos < i->first && cur_item != items.end() - 1) { + for (auto const &i : fontMapping) { + while (cur_pos < i.first && cur_item != items.end() - 1) { /* Add a range that spans the intersection of the remaining item and font run. */ - int stop_pos = min(i->first, (cur_item + 1)->iCharPos); + int stop_pos = min(i.first, (cur_item + 1)->iCharPos); assert(stop_pos - cur_pos > 0); - ranges.push_back(UniscribeRun(cur_pos, stop_pos - cur_pos, i->second, cur_item->a)); + ranges.push_back(UniscribeRun(cur_pos, stop_pos - cur_pos, i.second, cur_item->a)); /* Shape the range. */ if (!UniscribeShapeRun(buff, ranges.back())) { @@ -424,7 +424,7 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF if (!UniscribeShapeRun(this->text_buffer, run)) return NULL; } - *line->Append() = new UniscribeVisualRun(run, cur_pos); + line->push_back(new UniscribeVisualRun(run, cur_pos)); cur_pos += run.total_advance; } @@ -448,8 +448,8 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF int UniscribeParagraphLayout::UniscribeLine::GetLeading() const { int leading = 0; - for (const UniscribeVisualRun * const *run = this->Begin(); run != this->End(); run++) { - leading = max(leading, (*run)->GetLeading()); + for (const UniscribeVisualRun *run : *this) { + leading = max(leading, run->GetLeading()); } return leading; @@ -462,8 +462,8 @@ int UniscribeParagraphLayout::UniscribeLine::GetLeading() const int UniscribeParagraphLayout::UniscribeLine::GetWidth() const { int length = 0; - for (const UniscribeVisualRun * const *run = this->Begin(); run != this->End(); run++) { - length += (*run)->GetAdvance(); + for (const UniscribeVisualRun *run : *this) { + length += run->GetAdvance(); } return length; diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 61eb1d7a00..b396e8f4fc 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -94,12 +94,12 @@ struct OskWindow : public Window { this->SetWidgetLoweredState(WID_OSK_CAPS, HasBit(_keystate, KEYS_CAPS)); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_OSK_CAPTION) SetDParam(0, this->caption); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget < WID_OSK_LETTERS) return; @@ -110,7 +110,7 @@ struct OskWindow : public Window { TC_BLACK); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { /* clicked a letter */ if (widget >= WID_OSK_LETTERS) { @@ -192,21 +192,21 @@ struct OskWindow : public Window { } } - virtual void OnEditboxChanged(int widget) + void OnEditboxChanged(int widget) override { this->SetWidgetDirty(WID_OSK_TEXT); this->parent->OnEditboxChanged(this->text_btn); this->parent->SetWidgetDirty(this->text_btn); } - virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; this->SetWidgetDirty(WID_OSK_TEXT); this->parent->SetWidgetDirty(this->text_btn); } - virtual void OnFocusLost(Window *newly_focused_window) + void OnFocusLost(Window *newly_focused_window) override { VideoDriver::GetInstance()->EditBoxLostFocus(); delete this; diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp deleted file mode 100644 index 44469e1067..0000000000 --- a/src/pathfinder/opf/opf_ship.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file opf_ship.cpp Implementation of the oldest supported ship pathfinder. */ - -#include "../../stdafx.h" -#include "../../tunnelbridge_map.h" -#include "../../tunnelbridge.h" -#include "../../ship.h" -#include "../../station_base.h" -#include "../../core/random_func.hpp" - -#include "../../safeguards.h" - -struct RememberData { - uint16 cur_length; - byte depth; - Track last_choosen_track; -}; - -struct TrackPathFinder { - TileIndex skiptile; - StationID dest_station; - TileIndex dest_coords; - uint best_bird_dist; - uint best_length; - RememberData rd; - TrackdirByte the_dir; -}; - -static bool ShipTrackFollower(TileIndex tile, TrackPathFinder *pfs, uint length) -{ - /* Found dest? */ - if (pfs->dest_station != INVALID_STATION) { - if (Station::Get(pfs->dest_station)->IsDockingTile(tile)) { - pfs->best_bird_dist = 0; - - pfs->best_length = minu(pfs->best_length, length); - return true; - } - } else if (tile == pfs->dest_coords) { - pfs->best_bird_dist = 0; - - pfs->best_length = minu(pfs->best_length, length); - return true; - } - - /* Skip this tile in the calculation */ - if (tile != pfs->skiptile) { - pfs->best_bird_dist = minu(pfs->best_bird_dist, DistanceMaxPlusManhattan(pfs->dest_coords, tile)); - } - - return false; -} - -static void TPFModeShip(TrackPathFinder *tpf, TileIndex tile, DiagDirection direction) -{ - if (IsTileType(tile, MP_TUNNELBRIDGE)) { - /* wrong track type */ - if (GetTunnelBridgeTransportType(tile) != TRANSPORT_WATER) return; - - DiagDirection dir = GetTunnelBridgeDirection(tile); - /* entering tunnel / bridge? */ - if (dir == direction) { - TileIndex endtile = GetOtherTunnelBridgeEnd(tile); - - tpf->rd.cur_length += GetTunnelBridgeLength(tile, endtile) + 1; - - tile = endtile; - } else { - /* leaving tunnel / bridge? */ - if (ReverseDiagDir(dir) != direction) return; - } - } - - /* This addition will sometimes overflow by a single tile. - * The use of TILE_MASK here makes sure that we still point at a valid - * tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail. */ - tile = TILE_MASK(tile + TileOffsByDiagDir(direction)); - - if (++tpf->rd.cur_length > 50) return; - - TrackBits bits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0)) & DiagdirReachesTracks(direction); - if (bits == TRACK_BIT_NONE) return; - - assert(TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY()); - - bool only_one_track = true; - do { - Track track = RemoveFirstTrack(&bits); - if (bits != TRACK_BIT_NONE) only_one_track = false; - RememberData rd = tpf->rd; - - /* Change direction 4 times only */ - if (!only_one_track && track != tpf->rd.last_choosen_track) { - if (++tpf->rd.depth > 4) { - tpf->rd = rd; - return; - } - tpf->rd.last_choosen_track = track; - } - - tpf->the_dir = TrackEnterdirToTrackdir(track, direction); - - if (!ShipTrackFollower(tile, tpf, tpf->rd.cur_length)) { - TPFModeShip(tpf, tile, TrackdirToExitdir(tpf->the_dir)); - } - - tpf->rd = rd; - } while (bits != TRACK_BIT_NONE); -} - -static void OPFShipFollowTrack(TileIndex tile, DiagDirection direction, TrackPathFinder *tpf) -{ - assert(IsValidDiagDirection(direction)); - - /* initialize path finder variables */ - tpf->rd.cur_length = 0; - tpf->rd.depth = 0; - tpf->rd.last_choosen_track = INVALID_TRACK; - - ShipTrackFollower(tile, tpf, 0); - TPFModeShip(tpf, tile, direction); -} - -/** Directions to search towards given track bits and the ship's enter direction. */ -extern const DiagDirection _ship_search_directions[6][4] = { - { DIAGDIR_NE, INVALID_DIAGDIR, DIAGDIR_SW, INVALID_DIAGDIR }, - { INVALID_DIAGDIR, DIAGDIR_SE, INVALID_DIAGDIR, DIAGDIR_NW }, - { INVALID_DIAGDIR, DIAGDIR_NE, DIAGDIR_NW, INVALID_DIAGDIR }, - { DIAGDIR_SE, INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SW }, - { DIAGDIR_NW, DIAGDIR_SW, INVALID_DIAGDIR, INVALID_DIAGDIR }, - { INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SE, DIAGDIR_NE }, -}; - -/** Track to "direction (& 3)" mapping. */ -static const byte _pick_shiptrack_table[6] = {DIR_NE, DIR_SE, DIR_E, DIR_E, DIR_N, DIR_N}; - -static uint FindShipTrack(const Ship *v, TileIndex tile, DiagDirection dir, TrackBits bits, TileIndex skiptile, Track *track) -{ - TrackPathFinder pfs; - uint best_bird_dist = 0; - uint best_length = 0; - byte ship_dir = v->direction & 3; - - pfs.dest_station = v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.GetDestination() : INVALID_STATION; - pfs.dest_coords = v->dest_tile; - pfs.skiptile = skiptile; - - Track best_track = INVALID_TRACK; - - assert(bits != TRACK_BIT_NONE); - do { - Track i = RemoveFirstTrack(&bits); - - pfs.best_bird_dist = UINT_MAX; - pfs.best_length = UINT_MAX; - - OPFShipFollowTrack(tile, _ship_search_directions[i][dir], &pfs); - - if (best_track != INVALID_TRACK) { - if (pfs.best_bird_dist != 0) { - /* neither reached the destination, pick the one with the smallest bird dist */ - if (pfs.best_bird_dist > best_bird_dist) goto bad; - if (pfs.best_bird_dist < best_bird_dist) goto good; - } else { - if (pfs.best_length > best_length) goto bad; - if (pfs.best_length < best_length) goto good; - } - - /* if we reach this position, there's two paths of equal value so far. - * pick one randomly. */ - uint r = GB(Random(), 0, 8); - if (_pick_shiptrack_table[i] == ship_dir) r += 80; - if (_pick_shiptrack_table[best_track] == ship_dir) r -= 80; - if (r <= 127) goto bad; - } -good:; - best_track = i; - best_bird_dist = pfs.best_bird_dist; - best_length = pfs.best_length; -bad:; - - } while (bits != TRACK_BIT_NONE); - - *track = best_track; - return best_bird_dist; -} - -/** - * Finds the best track to choose on the next tile and - * returns INVALID_TRACK when it is better to reverse. - * @param v The ship. - * @param tile The tile we are about to enter. - * @param enterdir The direction entering the tile. - * @param tracks The tracks available on new tile. - * @param[out] path_found Whether a path has been found. - * @return Best track on next tile or INVALID_TRACK when better to reverse. - */ -Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found) -{ - assert(IsValidDiagDirection(enterdir)); - - TileIndex tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir)); - Track track; - - /* Let's find out how far it would be if we would reverse first */ - uint rev_dist = UINT_MAX; // distance if we reverse - Track cur_track = TrackdirToTrack(v->GetVehicleTrackdir()); // track on the current tile - DiagDirection rev_enterdir = ReverseDiagDir(enterdir); - TrackBits rev_tracks = TrackStatusToTrackBits(GetTileTrackStatus(tile2, TRANSPORT_WATER, 0)) & - DiagdirReachesTracks(rev_enterdir); - - if (HasTrack(rev_tracks, cur_track)) { - rev_dist = FindShipTrack(v, tile2, rev_enterdir, TrackToTrackBits(cur_track), tile, &track); - if (rev_dist != UINT_MAX) rev_dist++; // penalty for reversing - } - - /* And if we would not reverse? */ - uint dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track); - - /* Due to the way this pathfinder works we cannot determine whether we're lost or not. */ - path_found = true; - if (dist <= rev_dist) return track; - return INVALID_TRACK; // We could better reverse -} diff --git a/src/pathfinder/opf/opf_ship.h b/src/pathfinder/opf/opf_ship.h deleted file mode 100644 index 62668b206a..0000000000 --- a/src/pathfinder/opf/opf_ship.h +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file opf_ship.h Original pathfinder for ships; very simple. */ - -#ifndef OPF_SHIP_H -#define OPF_SHIP_H - -#include "../../direction_type.h" -#include "../../tile_type.h" -#include "../../track_type.h" -#include "../../vehicle_type.h" - -/** - * Finds the best path for given ship using OPF. - * @param v the ship that needs to find a path - * @param tile the tile to find the path from (should be next tile the ship is about to enter) - * @param enterdir diagonal direction which the ship will enter this new tile from - * @param tracks available tracks on the new tile (to choose from) - * @param path_found [out] Whether a path has been found (true) or has been guessed (false) - * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found - */ -Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found); - -#endif /* OPF_SHIP_H */ diff --git a/src/programmable_signals.cpp b/src/programmable_signals.cpp index 654bb22ecb..d57d609e08 100644 --- a/src/programmable_signals.cpp +++ b/src/programmable_signals.cpp @@ -178,14 +178,14 @@ void SignalStateCondition::SetSignal(TileIndex tile, Trackdir track) SignalInstruction::SignalInstruction(SignalProgram *prog, SignalOpcode op) : opcode(op), previous(NULL), program(prog) { - *program->instructions.Append() = this; + program->instructions.push_back(this); } SignalInstruction::~SignalInstruction() { - SignalInstruction** pthis = program->instructions.Find(this); - assert(pthis != program->instructions.End()); - program->instructions.Erase(pthis); + auto pthis = std::find(program->instructions.begin(), program->instructions.end(), this); + assert(pthis != program->instructions.end()); + program->instructions.erase(pthis); } void SignalInstruction::Insert(SignalInstruction *before_insn) @@ -416,9 +416,7 @@ SignalState RunSignalProgram(SignalReference ref, uint num_exits, uint num_green void RemoveProgramDependencies(SignalReference dependency_target, SignalReference signal_to_update) { SignalProgram *prog = GetSignalProgram(signal_to_update); - for (SignalInstruction **b = prog->instructions.Begin(), **i = b, **e = prog->instructions.End(); - i != e; i++) { - SignalInstruction *insn = *i; + for (SignalInstruction *insn : prog->instructions) { if (insn->Opcode() == PSO_IF) { SignalIf* ifi = static_cast(insn); if (ifi->condition->ConditionCode() == PSC_SIGNAL_STATE) { @@ -437,11 +435,9 @@ void RemoveProgramDependencies(SignalReference dependency_target, SignalReferenc void SignalProgram::DebugPrintProgram() { DEBUG(misc, 5, "Program %p listing", this); - for (SignalInstruction **b = this->instructions.Begin(), **i = b, **e = this->instructions.End(); - i != e; i++) - { - SignalInstruction *insn = *i; - DEBUG(misc, 5, " %ld: Opcode %d, prev %d", long(i - b), int(insn->Opcode()), + for (size_t i = 0; i < this->instructions.size(); i++) { + SignalInstruction *insn = this->instructions[i]; + DEBUG(misc, 5, " %d: Opcode %d, prev %d", int(i), int(insn->Opcode()), int(insn->Previous() ? insn->Previous()->Id() : -1)); } } @@ -475,7 +471,7 @@ CommandCost CmdInsertSignalInstruction(TileIndex tile, DoCommandFlag flags, uint SignalProgram *prog = GetExistingSignalProgram(SignalReference(tile, track)); if (!prog) return_cmd_error(STR_ERR_PROGSIG_NOT_THERE); - if (instruction_id >= prog->instructions.Length()) + if (instruction_id >= prog->instructions.size()) return_cmd_error(STR_ERR_PROGSIG_INVALID_INSTRUCTION); bool exec = (flags & DC_EXEC) != 0; @@ -550,7 +546,7 @@ CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint if (!prog) return_cmd_error(STR_ERR_PROGSIG_NOT_THERE); - if (instruction_id > prog->instructions.Length()) + if (instruction_id > prog->instructions.size()) return_cmd_error(STR_ERR_PROGSIG_INVALID_INSTRUCTION); bool exec = (flags & DC_EXEC) != 0; @@ -672,7 +668,7 @@ CommandCost CmdRemoveSignalInstruction(TileIndex tile, DoCommandFlag flags, uint if (!prog) return_cmd_error(STR_ERR_PROGSIG_NOT_THERE); - if (instruction_id > prog->instructions.Length()) + if (instruction_id > prog->instructions.size()) return_cmd_error(STR_ERR_PROGSIG_INVALID_INSTRUCTION); bool exec = (flags & DC_EXEC) != 0; diff --git a/src/programmable_signals.h b/src/programmable_signals.h index d69b4b352c..513bdffaeb 100644 --- a/src/programmable_signals.h +++ b/src/programmable_signals.h @@ -26,7 +26,7 @@ struct SignalVM; class SignalInstruction; class SignalSpecial; -typedef SmallVector InstructionList; +typedef std::vector InstructionList; enum SignalProgramMgmtCode { SPMC_REMOVE, ///< Remove program @@ -79,7 +79,7 @@ public: /// Get the Id of this instruction inline int Id() const // Const cast is safe (perculiarity of SmallVector) - { return program->instructions.FindIndex(const_cast(this)); } + { return find_index(program->instructions, const_cast(this)); } /// Insert this instruction, placing it before @p before_insn virtual void Insert(SignalInstruction *before_insn); diff --git a/src/programmable_signals_gui.cpp b/src/programmable_signals_gui.cpp index 6a26410845..aef4b4f38e 100644 --- a/src/programmable_signals_gui.cpp +++ b/src/programmable_signals_gui.cpp @@ -209,7 +209,7 @@ struct GuiInstruction { uint indent; }; -typedef SmallVector GuiInstructionList; +typedef std::vector GuiInstructionList; class ProgramWindow: public Window { public: @@ -555,14 +555,12 @@ public: int y = r.top + WD_FRAMERECT_TOP; int line_height = this->GetWidget(PROGRAM_WIDGET_INSTRUCTION_LIST)->resize_y; - int no = this->vscroll->GetPosition(); - - for (const GuiInstruction *i = instructions.Begin() + no, *e = instructions.End(); - i != e; ++i, no++) { + for (int no = this->vscroll->GetPosition(); no < (int) instructions.size(); no++) { + const GuiInstruction &i = instructions[no]; /* Don't draw anything if it extends past the end of the window. */ if (!this->vscroll->IsVisible(no)) break; - DrawInstructionString(i->insn, y, no == this->selected_instruction, i->indent, r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT); + DrawInstructionString(i.insn, y, no == this->selected_instruction, i.indent, r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT); y += line_height; } } @@ -593,7 +591,7 @@ private: SignalInstruction *GetSelected() const { if (this->selected_instruction == -1 - || this->selected_instruction >= int(this->instructions.Length())) + || this->selected_instruction >= int(this->instructions.size())) return NULL; return this->instructions[this->selected_instruction].insn; @@ -613,13 +611,13 @@ private: sel += this->vscroll->GetPosition(); - return (sel <= int(this->instructions.Length()) && sel >= 0) ? sel : -1; + return (sel <= int(this->instructions.size()) && sel >= 0) ? sel : -1; } void RebuildInstructionList() { - uint old_len = this->instructions.Length(); - this->instructions.Clear(); + uint old_len = this->instructions.size(); + this->instructions.clear(); SignalInstruction *insn = program->first_instruction; uint indent = 0; @@ -629,7 +627,8 @@ private: case PSO_FIRST: case PSO_LAST: { SignalSpecial *s = static_cast(insn); - GuiInstruction *gi = this->instructions.Append(); + this->instructions.emplace_back(); + GuiInstruction *gi = &(this->instructions.back()); gi->insn = s; gi->indent = indent; insn = s->next; @@ -638,7 +637,8 @@ private: case PSO_IF: { SignalIf *i = static_cast(insn); - GuiInstruction *gi = this->instructions.Append(); + this->instructions.emplace_back(); + GuiInstruction *gi = &(this->instructions.back()); gi->insn = i; gi->indent = indent++; insn = i->if_true; @@ -647,7 +647,8 @@ private: case PSO_IF_ELSE: { SignalIf::PseudoInstruction *p = static_cast(insn); - GuiInstruction *gi = this->instructions.Append(); + this->instructions.emplace_back(); + GuiInstruction *gi = &(this->instructions.back()); gi->insn = p; gi->indent = indent - 1; insn = p->block->if_false; @@ -656,7 +657,8 @@ private: case PSO_IF_ENDIF: { SignalIf::PseudoInstruction *p = static_cast(insn); - GuiInstruction *gi = this->instructions.Append(); + this->instructions.emplace_back(); + GuiInstruction *gi = &(this->instructions.back()); gi->insn = p; gi->indent = --indent; insn = p->block->after; @@ -665,7 +667,8 @@ private: case PSO_SET_SIGNAL: { SignalSet *s = static_cast(insn); - GuiInstruction *gi = this->instructions.Append(); + this->instructions.emplace_back(); + GuiInstruction *gi = &(this->instructions.back()); gi->insn = s; gi->indent = indent; insn = s->next; @@ -676,8 +679,8 @@ private: } } while (insn); - this->vscroll->SetCount(this->instructions.Length()); - if (this->instructions.Length() != old_len) + this->vscroll->SetCount(this->instructions.size()); + if (this->instructions.size() != old_len) selected_instruction = -1; UpdateButtonState(); } diff --git a/src/rail.cpp b/src/rail.cpp index 48ceea4195..30b7ba982d 100644 --- a/src/rail.cpp +++ b/src/rail.cpp @@ -400,7 +400,7 @@ RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels) /* Test if any rail type defines the label as an alternate. */ for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) { const RailtypeInfo *rti = GetRailTypeInfo(r); - if (rti->alternate_labels.Contains(label)) return r; + if (std::find(rti->alternate_labels.begin(), rti->alternate_labels.end(), label) != rti->alternate_labels.end()) return r; } } diff --git a/src/rail.h b/src/rail.h index b67e28990f..a4c6ef2df8 100644 --- a/src/rail.h +++ b/src/rail.h @@ -118,7 +118,7 @@ enum RailFenceOffset { }; /** List of rail type labels. */ -typedef SmallVector RailTypeLabelList; +typedef std::vector RailTypeLabelList; /** * This struct contains all the info that is needed to draw and construct tracks. diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 4fffb0e7c7..81865bc80a 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -49,7 +49,7 @@ #include "safeguards.h" /** Helper type for lists/vectors of trains */ -typedef SmallVector TrainList; +typedef std::vector TrainList; RailtypeInfo _railtypes[RAILTYPE_END]; RailType _sorted_railtypes[RAILTYPE_END]; @@ -166,7 +166,7 @@ RailType AllocateRailType(RailTypeLabel label) /* Set up new rail type */ *rti = _original_railtypes[RAILTYPE_RAIL]; rti->label = label; - rti->alternate_labels.Clear(); + rti->alternate_labels.clear(); /* Make us compatible with ourself. */ rti->powered_railtypes = (RailTypes)(1LL << rt); @@ -1976,7 +1976,7 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data) if (v->type != VEH_TRAIN) return NULL; TrainList *affected_trains = static_cast(data); - affected_trains->Include(Train::From(v)->First()); + include(*affected_trains, Train::From(v)->First()); return NULL; } @@ -2048,7 +2048,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 continue; } - SmallVector vehicles_affected; + std::vector vehicles_affected; auto find_train_reservations = [&vehicles_affected, &totype](TileIndex tile, TrackBits reserved) { Track track; @@ -2057,7 +2057,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 if (v != NULL && !HasPowerOnRail(v->railtype, totype)) { /* No power on new rail type, reroute. */ FreeTrainTrackReservation(v); - *vehicles_affected.Append() = v; + vehicles_affected.push_back(v); } } }; @@ -2208,15 +2208,15 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 break; } - for (uint i = 0; i < vehicles_affected.Length(); ++i) { + for (uint i = 0; i < vehicles_affected.size(); ++i) { TryPathReserve(vehicles_affected[i], true); } } if (flags & DC_EXEC) { /* Railtype changed, update trains as when entering different track */ - for (Train **v = affected_trains.Begin(); v != affected_trains.End(); v++) { - (*v)->ConsistChanged(CCF_TRACK); + for (Train *v : affected_trains) { + v->ConsistChanged(CCF_TRACK); } } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index a67b8bb724..4804bc1f5f 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -498,7 +498,7 @@ struct BuildRailToolbarWindow : 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; @@ -567,7 +567,7 @@ struct BuildRailToolbarWindow : Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_RAT_CAPTION) { const RailtypeInfo *rti = GetRailTypeInfo(this->railtype); @@ -581,7 +581,7 @@ struct BuildRailToolbarWindow : Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget == WID_RAT_POLYRAIL) { Dimension d = GetSpriteSize(SPR_BLOT); @@ -590,7 +590,7 @@ struct BuildRailToolbarWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget < WID_RAT_BUILD_NS) return; @@ -716,7 +716,7 @@ struct BuildRailToolbarWindow : Window { if (_ctrl_pressed) RailToolbar_CtrlChanged(this); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection @@ -730,7 +730,7 @@ struct BuildRailToolbarWindow : Window { return this->Window::OnHotkey(hotkey); } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (this->last_user_action) { case WID_RAT_BUILD_NS: @@ -792,7 +792,7 @@ struct BuildRailToolbarWindow : Window { } } - virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) + void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { /* no dragging if you have pressed the convert button */ if (FindWindowById(WC_BUILD_SIGNAL, 0) != NULL && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return; @@ -800,7 +800,7 @@ struct BuildRailToolbarWindow : Window { 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) { @@ -853,7 +853,7 @@ struct BuildRailToolbarWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); this->DisableWidget(WID_RAT_REMOVE); @@ -867,13 +867,13 @@ struct BuildRailToolbarWindow : Window { DeleteWindowByClass(WC_BUILD_BRIDGE); } - virtual void OnPlacePresize(Point pt, TileIndex tile) + void OnPlacePresize(Point pt, TileIndex tile) override { DoCommand(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - virtual EventState OnCTRLStateChange() + EventState OnCTRLStateChange() override { /* do not toggle Remove button by Ctrl when placing station */ if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) && !this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) && RailToolbar_CtrlChanged(this)) return ES_HANDLED; @@ -1114,7 +1114,7 @@ public: DeleteWindowById(WC_SELECT_STATION, 0); } - virtual void OnPaint() + void OnPaint() override { bool newstations = _railstation.newstations; const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : NULL; @@ -1166,7 +1166,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_BRAS_NEWST_LIST: { @@ -1223,7 +1223,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { DrawPixelInfo tmp_dpi; @@ -1297,14 +1297,14 @@ public: } } - virtual void OnResize() + void OnResize() override { if (this->vscroll != NULL) { // New stations available. this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST); } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_BRAS_SHOW_NEWST_TYPE) { const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type); @@ -1312,7 +1312,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (GB(widget, 0, 16)) { case WID_BRAS_PLATFORM_DIR_X: @@ -1488,7 +1488,7 @@ public: } } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { CheckRedrawStationCoverage(this); } @@ -1654,7 +1654,7 @@ public: _program_signal_button = false; } - virtual void OnInit() + void OnInit() override { /* Calculate maximum signal sprite size. */ this->sig_sprite_size.width = 0; @@ -1674,7 +1674,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 { if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) { /* Two digits for signals density. */ @@ -1685,7 +1685,7 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_BS_DRAG_SIGNALS_DENSITY_LABEL: @@ -1694,7 +1694,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { /* Extract signal from widget number. */ @@ -1722,7 +1722,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_BS_SEMAPHORE_NORM: @@ -1801,7 +1801,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; this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_button); @@ -1891,7 +1891,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); } - 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 (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; @@ -1899,14 +1899,14 @@ struct BuildRailDepotWindow : public PickerWindowBase { size->height = ScaleGUITrad(48) + 2; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; DrawTrainDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BRAD_DEPOT_NE: @@ -1980,7 +1980,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { matrix->SetClicked(_cur_waypoint_type); } - 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_BRW_WAYPOINT_MATRIX: @@ -1999,7 +1999,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (GB(widget, 0, 16)) { case WID_BRW_WAYPOINT: { @@ -2014,7 +2014,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (GB(widget, 0, 16)) { case WID_BRW_WAYPOINT: { @@ -2200,7 +2200,7 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) if (all_option) { DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false); - *list->Append() = item; + list->push_back(item); } Dimension d = { 0, 0 }; @@ -2231,7 +2231,7 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) } item->SetParam(0, rti->strings.menu_text); item->SetParam(1, rti->max_speed); - *list->Append() = item; + list->push_back(item); } return list; } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 00cd37fc8a..bf836df221 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -335,7 +335,7 @@ struct BuildRoadToolbarWindow : 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; @@ -403,7 +403,7 @@ struct BuildRoadToolbarWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { _remove_button_clicked = false; _one_way_button_clicked = false; @@ -483,13 +483,13 @@ struct BuildRoadToolbarWindow : Window { if (_ctrl_pressed) RoadToolbar_CtrlChanged(this); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection return Window::OnHotkey(hotkey); } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { _remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE); _one_way_button_clicked = this->IsWidgetLowered(WID_ROT_ONE_WAY); @@ -543,7 +543,7 @@ struct BuildRoadToolbarWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); this->SetWidgetsDisabledState(true, @@ -560,7 +560,7 @@ struct BuildRoadToolbarWindow : Window { DeleteWindowByClass(WC_BUILD_BRIDGE); } - virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) + void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { /* Here we update the end tile flags * of the road placement actions. @@ -603,7 +603,7 @@ struct BuildRoadToolbarWindow : Window { 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) { @@ -659,13 +659,13 @@ struct BuildRoadToolbarWindow : Window { } } - virtual void OnPlacePresize(Point pt, TileIndex tile) + void OnPlacePresize(Point pt, TileIndex tile) override { DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - virtual EventState OnCTRLStateChange() + EventState OnCTRLStateChange() override { if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED; return ES_NOT_HANDLED; @@ -874,7 +874,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { this->FinishInitNested(TRANSPORT_ROAD); } - 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 (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; @@ -882,14 +882,14 @@ struct BuildRoadDepotWindow : public PickerWindowBase { size->height = ScaleGUITrad(48) + 2; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; DrawRoadDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BROD_DEPOT_NW: @@ -979,7 +979,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { DeleteWindowById(WC_SELECT_STATION, 0); } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -1007,7 +1007,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { } } - 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 (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return; @@ -1015,7 +1015,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { size->height = ScaleGUITrad(48) + 2; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return; @@ -1023,7 +1023,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { StationPickerDrawSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BROS_STATION_NE: @@ -1054,7 +1054,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { } } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { CheckRedrawStationCoverage(this); } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index a6b1ad51fd..c7334b9505 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2071,7 +2071,7 @@ bool AfterLoadGame() if (_settings_game.pf.yapf.ship_use_yapf) { _settings_game.pf.pathfinder_for_ships = VPF_YAPF; } else { - _settings_game.pf.pathfinder_for_ships = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF); + _settings_game.pf.pathfinder_for_ships = VPF_NPF; } } @@ -2414,14 +2414,14 @@ bool AfterLoadGame() /* Animated tiles would sometimes not be actually animated or * in case of old savegames duplicate. */ - extern SmallVector _animated_tiles; + extern std::vector _animated_tiles; - for (TileIndex *tile = _animated_tiles.Begin(); tile < _animated_tiles.End(); /* Nothing */) { + for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) { /* Remove if tile is not animated */ bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == NULL; /* and remove if duplicate */ - for (TileIndex *j = _animated_tiles.Begin(); !remove && j < tile; j++) { + for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) { remove = *tile == *j; } @@ -3243,10 +3243,10 @@ bool AfterLoadGame() * So, make articulated parts catch up. */ RoadVehicle *v; bool roadside = _settings_game.vehicle.road_side == 1; - SmallVector skip_frames; + std::vector skip_frames; FOR_ALL_ROADVEHICLES(v) { if (!v->IsFrontEngine()) continue; - skip_frames.Clear(); + skip_frames.clear(); TileIndex prev_tile = v->tile; uint prev_tile_skip = 0; uint cur_skip = 0; @@ -3258,24 +3258,24 @@ bool AfterLoadGame() cur_skip = prev_tile_skip; } - uint *this_skip = skip_frames.Append(); - *this_skip = prev_tile_skip; + /*C++17: uint &this_skip = */ skip_frames.push_back(prev_tile_skip); + uint &this_skip = skip_frames.back(); /* The following 3 curves now take longer than before */ switch (u->state) { case 2: cur_skip++; - if (u->frame <= (roadside ? 9 : 5)) *this_skip = cur_skip; + if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip; break; case 4: cur_skip++; - if (u->frame <= (roadside ? 5 : 9)) *this_skip = cur_skip; + if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip; break; case 5: cur_skip++; - if (u->frame <= (roadside ? 4 : 2)) *this_skip = cur_skip; + if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip; break; default: @@ -3285,9 +3285,12 @@ bool AfterLoadGame() while (cur_skip > skip_frames[0]) { RoadVehicle *u = v; RoadVehicle *prev = NULL; - for (uint *it = skip_frames.Begin(); it != skip_frames.End(); ++it, prev = u, u = u->Next()) { + for (uint sf : skip_frames) { extern bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev); - if (*it >= cur_skip) IndividualRoadVehicleController(u, prev); + if (sf >= cur_skip) IndividualRoadVehicleController(u, prev); + + prev = u; + u = u->Next(); } cur_skip--; } @@ -3560,6 +3563,13 @@ bool AfterLoadGame() FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != NULL) ind->neutral_station->industry = ind; } + if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS) && !SlXvIsFeaturePresent(XSLFI_CHUNNEL, 2)) { + /* Update water class for trees. */ + for (TileIndex t = 0; t < map_size; t++) { + if (IsTileType(t, MP_TREES)) SetWaterClass(t, GetTreeGround(t) == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID); + } + } + /* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */ Station::RecomputeCatchmentForAll(); @@ -3666,14 +3676,6 @@ bool AfterLoadGame() } } - if (!SlXvIsFeaturePresent(XSLFI_CHUNNEL, 2)) { - for (TileIndex t = 0; t < map_size; t++) { - if (IsTileType(t, MP_TREES)) { - SetWaterClass(t, GetTreeDensity(t) == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID); - } - } - } - if (SlXvIsFeatureMissing(XSLFI_SAVEGAME_UNIQUE_ID)) { /* Generate a random id for savegames that didn't have one */ /* We keep id 0 for old savegames that don't have an id */ diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index c54c4724ab..f82950c50f 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -18,15 +18,15 @@ #include "../safeguards.h" -extern SmallVector _animated_tiles; +extern std::vector _animated_tiles; /** * Save the ANIT chunk. */ static void Save_ANIT() { - SlSetLength(_animated_tiles.Length() * sizeof(*_animated_tiles.Begin())); - SlArray(_animated_tiles.Begin(), _animated_tiles.Length(), SLE_UINT32); + SlSetLength(_animated_tiles.size() * sizeof(_animated_tiles.front())); + SlArray(_animated_tiles.data(), _animated_tiles.size(), SLE_UINT32); } /** @@ -42,15 +42,15 @@ static void Load_ANIT() for (int i = 0; i < 256; i++) { if (anim_list[i] == 0) break; - *_animated_tiles.Append() = anim_list[i]; + _animated_tiles.push_back(anim_list[i]); } return; } - uint count = (uint)SlGetFieldLength() / sizeof(*_animated_tiles.Begin()); - _animated_tiles.Clear(); - _animated_tiles.Append(count); - SlArray(_animated_tiles.Begin(), count, SLE_UINT32); + uint count = (uint)SlGetFieldLength() / sizeof(_animated_tiles.front()); + _animated_tiles.clear(); + _animated_tiles.resize(_animated_tiles.size() + count); + SlArray(_animated_tiles.data(), count, SLE_UINT32); } /** diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index 5221d1bbdc..891e307834 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -177,20 +177,21 @@ static const SaveLoad _engine_id_mapping_desc[] = { static void Save_EIDS() { - const EngineIDMapping *end = _engine_mngr.End(); uint index = 0; - for (EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) { + for (EngineIDMapping &eid : _engine_mngr) { SlSetArrayIndex(index); - SlObject(eid, _engine_id_mapping_desc); + SlObject(&eid, _engine_id_mapping_desc); + index++; } } static void Load_EIDS() { - _engine_mngr.Clear(); + _engine_mngr.clear(); while (SlIterateArray() != -1) { - EngineIDMapping *eid = _engine_mngr.Append(); + /*C++17: EngineIDMapping *eid = &*/ _engine_mngr.emplace_back(); + EngineIDMapping *eid = &_engine_mngr.back(); SlObject(eid, _engine_id_mapping_desc); } } diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 325ae1c9d4..cffff5018d 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -132,7 +132,7 @@ static const SaveLoad _game_language_string[] = { static void SaveReal_GSTR(LanguageStrings *ls) { _game_saveload_string = ls->language; - _game_saveload_strings = ls->lines.Length(); + _game_saveload_strings = ls->lines.size(); SlObject(NULL, _game_language_header); for (uint i = 0; i < _game_saveload_strings; i++) { @@ -153,14 +153,14 @@ static void Load_GSTR() LanguageStrings *ls = new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : ""); for (uint i = 0; i < _game_saveload_strings; i++) { SlObject(NULL, _game_language_string); - *ls->lines.Append() = stredup(_game_saveload_string != NULL ? _game_saveload_string : ""); + ls->lines.push_back(stredup(_game_saveload_string != NULL ? _game_saveload_string : "")); } - *_current_data->raw_strings.Append() = ls; + _current_data->raw_strings.push_back(ls); } /* If there were no strings in the savegame, set GameStrings to NULL */ - if (_current_data->raw_strings.Length() == 0) { + if (_current_data->raw_strings.size() == 0) { delete _current_data; _current_data = NULL; return; @@ -174,7 +174,7 @@ static void Save_GSTR() { if (_current_data == NULL) return; - for (uint i = 0; i < _current_data->raw_strings.Length(); i++) { + for (uint i = 0; i < _current_data->raw_strings.size(); i++) { SlSetArrayIndex(i); SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]); } diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp index 3b898a3b87..dd71f1c3e7 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -17,7 +17,7 @@ #include "../safeguards.h" -static SmallVector _railtype_list; +static std::vector _railtype_list; /** * Test if any saved rail type labels are different to the currently loaded @@ -26,7 +26,7 @@ static SmallVector _railtype_list; */ static bool NeedRailTypeConversion() { - for (uint i = 0; i < _railtype_list.Length(); i++) { + for (uint i = 0; i < _railtype_list.size(); i++) { if ((RailType)i < RAILTYPE_END) { const RailtypeInfo *rti = GetRailTypeInfo((RailType)i); if (rti->label != _railtype_list[i]) return true; @@ -42,13 +42,13 @@ static bool NeedRailTypeConversion() void AfterLoadLabelMaps() { if (NeedRailTypeConversion()) { - SmallVector railtype_conversion_map; + std::vector railtype_conversion_map; - for (uint i = 0; i < _railtype_list.Length(); i++) { + for (uint i = 0; i < _railtype_list.size(); i++) { RailType r = GetRailTypeByLabel(_railtype_list[i]); if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN; - *railtype_conversion_map.Append() = r; + railtype_conversion_map.push_back(r); } for (TileIndex t = 0; t < MapSize(); t++) { @@ -81,7 +81,7 @@ void AfterLoadLabelMaps() } } - _railtype_list.Clear(); + _railtype_list.clear(); } /** Container for a label for SaveLoad system */ @@ -108,13 +108,13 @@ static void Save_RAIL() static void Load_RAIL() { - _railtype_list.Clear(); + _railtype_list.clear(); LabelObject lo; while (SlIterateArray() != -1) { SlObject(&lo, _label_object_desc); - *_railtype_list.Append() = (RailTypeLabel)lo.label; + _railtype_list.push_back((RailTypeLabel)lo.label); } } diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index 02c417c05c..9c9a967901 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -58,11 +58,11 @@ void GetLinkGraphJobDayLengthScaleAfterLoad(LinkGraphJob *lgj) */ const SaveLoad *GetLinkGraphJobDesc() { - static SmallVector saveloads; + static std::vector saveloads; static const char *prefix = "linkgraph."; /* Build the SaveLoad array on first call and don't touch it later on */ - if (saveloads.Length() == 0) { + if (saveloads.size() == 0) { size_t offset_gamesettings = cpp_offsetof(GameSettings, linkgraph); size_t offset_component = cpp_offsetof(LinkGraphJob, settings); @@ -76,7 +76,7 @@ const SaveLoad *GetLinkGraphJobDesc() char *&address = reinterpret_cast(sl.address); address -= offset_gamesettings; address += offset_component; - *(saveloads.Append()) = sl; + saveloads.push_back(sl); } desc = GetSettingDescription(++setting); } @@ -90,8 +90,8 @@ const SaveLoad *GetLinkGraphJobDesc() int i = 0; do { - *(saveloads.Append()) = job_desc[i++]; - } while (saveloads[saveloads.Length() - 1].cmd != SL_END); + saveloads.push_back(job_desc[i++]); + } while (saveloads[saveloads.size() - 1].cmd != SL_END); } return &saveloads[0]; diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 976f18726e..f4a2f7730b 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -491,7 +491,7 @@ static inline uint RemapOrderIndex(uint x) return _savegame_type == SGT_TTO ? (x - 0x1AC4) / 2 : (x - 0x1C18) / 2; } -extern SmallVector _animated_tiles; +extern std::vector _animated_tiles; extern char *_old_name_array; static uint32 _old_town_index; @@ -651,7 +651,7 @@ static bool LoadOldAnimTileList(LoadgameState *ls, int num) /* The first zero in the loaded array indicates the end of the list. */ for (int i = 0; i < 256; i++) { if (anim_list[i] == 0) break; - *_animated_tiles.Append() = anim_list[i]; + _animated_tiles.push_back(anim_list[i]); } return true; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index cafb3f54ae..40a15834a1 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2117,7 +2117,7 @@ struct FileReader : LoadFilter { _sl.sf = NULL; } - /* virtual */ size_t Read(byte *buf, size_t size) + size_t Read(byte *buf, size_t size) override { /* We're in the process of shutting down, i.e. in "failure" mode. */ if (this->file == NULL) return 0; @@ -2125,7 +2125,7 @@ struct FileReader : LoadFilter { return fread(buf, 1, size, this->file); } - /* virtual */ void Reset() + void Reset() override { clearerr(this->file); if (fseek(this->file, this->begin, SEEK_SET)) { @@ -2155,7 +2155,7 @@ struct FileWriter : SaveFilter { _sl.sf = NULL; } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { /* We're in the process of shutting down, i.e. in "failure" mode. */ if (this->file == NULL) return; @@ -2163,7 +2163,7 @@ struct FileWriter : SaveFilter { if (fwrite(buf, 1, size, this->file) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE); } - /* virtual */ void Finish() + void Finish() override { if (this->file != NULL) fclose(this->file); this->file = NULL; @@ -2191,7 +2191,7 @@ struct LZOLoadFilter : LoadFilter { if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor"); } - /* virtual */ size_t Read(byte *buf, size_t ssize) + size_t Read(byte *buf, size_t ssize) override { assert(ssize >= LZO_BUFFER_SIZE); @@ -2239,7 +2239,7 @@ struct LZOSaveFilter : SaveFilter { if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor"); } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { const lzo_bytep in = buf; /* Buffer size is from the LZO docs plus the chunk header size. */ @@ -2278,7 +2278,7 @@ struct NoCompLoadFilter : LoadFilter { { } - /* virtual */ size_t Read(byte *buf, size_t size) + size_t Read(byte *buf, size_t size) override { return this->chain->Read(buf, size); } @@ -2295,7 +2295,7 @@ struct NoCompSaveFilter : SaveFilter { { } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { this->chain->Write(buf, size); } @@ -2329,7 +2329,7 @@ struct ZlibLoadFilter : LoadFilter { inflateEnd(&this->z); } - /* virtual */ size_t Read(byte *buf, size_t size) + size_t Read(byte *buf, size_t size) override { this->z.next_out = buf; this->z.avail_out = (uint)size; @@ -2408,12 +2408,12 @@ struct ZlibSaveFilter : SaveFilter { } while (this->z.avail_in || !this->z.avail_out); } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { this->WriteLoop(buf, size, 0); } - /* virtual */ void Finish() + void Finish() override { this->WriteLoop(NULL, 0, Z_FINISH); this->chain->Finish(); @@ -2458,7 +2458,7 @@ struct LZMALoadFilter : LoadFilter { lzma_end(&this->lzma); } - /* virtual */ size_t Read(byte *buf, size_t size) + size_t Read(byte *buf, size_t size) override { this->lzma.next_out = buf; this->lzma.avail_out = size; @@ -2527,12 +2527,12 @@ struct LZMASaveFilter : SaveFilter { } while (this->lzma.avail_in || !this->lzma.avail_out); } - /* virtual */ void Write(byte *buf, size_t size) + void Write(byte *buf, size_t size) override { this->WriteLoop(buf, size, LZMA_RUN); } - /* virtual */ void Finish() + void Finish() override { this->WriteLoop(NULL, 0, LZMA_FINISH); this->chain->Finish(); diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 5fb986e32c..1a813b17a2 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -299,6 +299,8 @@ enum SaveLoadVersion : uint16 { SLV_SERVE_NEUTRAL_INDUSTRIES, ///< 210 PR#7234 Company stations can serve industries with attached neutral stations. SLV_ROADVEH_PATH_CACHE, ///< 211 PR#7261 Add path cache for road vehicles. + SLV_REMOVE_OPF, ///< 212 PR#7245 Remove OPF. + SLV_TREES_WATER_CLASS, ///< 213 PR#7405 WaterClass update for tree tiles. SL_MAX_VERSION, ///< Highest possible saveload version }; diff --git a/src/saveload/signal_sl.cpp b/src/saveload/signal_sl.cpp index 173b484f9f..4162b379ca 100644 --- a/src/saveload/signal_sl.cpp +++ b/src/saveload/signal_sl.cpp @@ -123,10 +123,8 @@ static void Save_SPRG() WriteVLI(b, prog->tile); WriteVLI(b, prog->track); - WriteVLI(b, prog->instructions.Length()); - for(SignalInstruction **j = prog->instructions.Begin(), **je = prog->instructions.End(); - j != je; ++j) { - SignalInstruction *insn = *j; + WriteVLI(b, prog->instructions.size()); + for (SignalInstruction *insn : prog->instructions) { WriteVLI(b, insn->Opcode()); if(insn->Opcode() != PSO_FIRST) WriteVLI(b, insn->Previous()->Id()); @@ -190,26 +188,26 @@ struct Fixup { SignalInstruction **ptr; }; -typedef SmallVector FixupList; +typedef std::vector FixupList; template static void MakeFixup(FixupList &l, T *&ir, uint id, SignalOpcode op = PSO_INVALID) { ir = reinterpret_cast(id); - new(l.Append()) Fixup(reinterpret_cast(&ir), op); + l.emplace_back(reinterpret_cast(&ir), op); } static void DoFixups(FixupList &l, InstructionList &il) { - for(Fixup *i = l.Begin(), *e = l.End(); i != e; ++i) { - uint id = reinterpret_cast(*i->ptr); - if(id >= il.Length()) + for (Fixup &i : l) { + uint id = reinterpret_cast(*(i.ptr)); + if (id >= il.size()) NOT_REACHED(); - *i->ptr = il[id]; + *(i.ptr) = il[id]; - if(i->type != PSO_INVALID && (*i->ptr)->Opcode() != i->type) { - DEBUG(sl, 0, "Expected Id %d to be %d, but was in fact %d", id, i->type, (*i->ptr)->Opcode()); + if (i.type != PSO_INVALID && (*(i.ptr))->Opcode() != i.type) { + DEBUG(sl, 0, "Expected Id %d to be %d, but was in fact %d", id, i.type, (*(i.ptr))->Opcode()); NOT_REACHED(); } } diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index ae74d812b1..1670864676 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -42,7 +42,7 @@ struct OldWaypoint { }; /** Temporary array with old waypoints. */ -static SmallVector _old_waypoints; +static std::vector _old_waypoints; /** * Update the waypoint orders to get the new waypoint ID. @@ -52,10 +52,10 @@ static void UpdateWaypointOrder(Order *o) { if (!o->IsType(OT_GOTO_WAYPOINT)) return; - for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { - if (wp->index != o->GetDestination()) continue; + for (OldWaypoint &wp : _old_waypoints) { + if (wp.index != o->GetDestination()) continue; - o->SetDestination((DestinationID)wp->new_index); + o->SetDestination((DestinationID)wp.new_index); return; } } @@ -71,47 +71,47 @@ void MoveWaypointsToBaseStations() * id which was stored in m4 is now saved as a grf/id reference in the * waypoint struct. */ if (IsSavegameVersionBefore(SLV_17)) { - for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { - if (wp->delete_ctr != 0) continue; // The waypoint was deleted + for (OldWaypoint &wp : _old_waypoints) { + if (wp.delete_ctr != 0) continue; // The waypoint was deleted /* Waypoint indices were not added to the map prior to this. */ - _m[wp->xy].m2 = (StationID)wp->index; + _m[wp.xy].m2 = (StationID)wp.index; - if (HasBit(_m[wp->xy].m3, 4)) { - wp->spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(_m[wp->xy].m4 + 1); + if (HasBit(_m[wp.xy].m3, 4)) { + wp.spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(_m[wp.xy].m4 + 1); } } } else { /* As of version 17, we recalculate the custom graphic ID of waypoints * from the GRF ID / station index. */ - for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { + for (OldWaypoint &wp : _old_waypoints) { StationClass* stclass = StationClass::Get(STAT_CLASS_WAYP); for (uint i = 0; i < stclass->GetSpecCount(); i++) { const StationSpec *statspec = stclass->GetSpec(i); - if (statspec != NULL && statspec->grf_prop.grffile->grfid == wp->grfid && statspec->grf_prop.local_id == wp->localidx) { - wp->spec = statspec; + if (statspec != NULL && statspec->grf_prop.grffile->grfid == wp.grfid && statspec->grf_prop.local_id == wp.localidx) { + wp.spec = statspec; break; } } } } - if (!Waypoint::CanAllocateItem(_old_waypoints.Length())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING); + if (!Waypoint::CanAllocateItem(_old_waypoints.size())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING); /* All saveload conversions have been done. Create the new waypoints! */ - for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { - Waypoint *new_wp = new Waypoint(wp->xy); - new_wp->town = wp->town; - new_wp->town_cn = wp->town_cn; - new_wp->name = wp->name; + for (OldWaypoint &wp : _old_waypoints) { + Waypoint *new_wp = new Waypoint(wp.xy); + new_wp->town = wp.town; + new_wp->town_cn = wp.town_cn; + new_wp->name = wp.name; new_wp->delete_ctr = 0; // Just reset delete counter for once. - new_wp->build_date = wp->build_date; - new_wp->owner = wp->owner; + new_wp->build_date = wp.build_date; + new_wp->owner = wp.owner; new_wp->string_id = STR_SV_STNAME_WAYPOINT; - TileIndex t = wp->xy; - if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp->index) { + TileIndex t = wp.xy; + if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp.index) { /* The tile might've been reserved! */ bool reserved = !IsSavegameVersionBefore(SLV_100) && HasBit(_m[t].m5, 4); @@ -122,13 +122,13 @@ void MoveWaypointsToBaseStations() SetRailStationReservation(t, reserved); - if (wp->spec != NULL) { - SetCustomStationSpecIndex(t, AllocateSpecToStation(wp->spec, new_wp, true)); + if (wp.spec != NULL) { + SetCustomStationSpecIndex(t, AllocateSpecToStation(wp.spec, new_wp, true)); } new_wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE); } - wp->new_index = new_wp->index; + wp.new_index = new_wp->index; } /* Update the orders of vehicles */ @@ -146,7 +146,8 @@ void MoveWaypointsToBaseStations() UpdateWaypointOrder(&v->current_order); } - _old_waypoints.Reset(); + _old_waypoints.clear(); + _old_waypoints.shrink_to_fit(); } static const SaveLoad _old_waypoint_desc[] = { @@ -172,12 +173,13 @@ static const SaveLoad _old_waypoint_desc[] = { static void Load_WAYP() { /* Precaution for when loading failed and it didn't get cleared */ - _old_waypoints.Clear(); + _old_waypoints.clear(); int index; while ((index = SlIterateArray()) != -1) { - OldWaypoint *wp = _old_waypoints.Append(); + /*C++17: OldWaypoint *wp = &*/ _old_waypoints.emplace_back(); + OldWaypoint *wp = &_old_waypoints.back(); memset(wp, 0, sizeof(*wp)); wp->index = index; @@ -187,27 +189,27 @@ static void Load_WAYP() static void Ptrs_WAYP() { - for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { - SlObject(wp, _old_waypoint_desc); + for (OldWaypoint &wp : _old_waypoints) { + SlObject(&wp, _old_waypoint_desc); if (IsSavegameVersionBefore(SLV_12)) { - wp->town_cn = (wp->string_id & 0xC000) == 0xC000 ? (wp->string_id >> 8) & 0x3F : 0; - wp->town = ClosestTownFromTile(wp->xy, UINT_MAX); + wp.town_cn = (wp.string_id & 0xC000) == 0xC000 ? (wp.string_id >> 8) & 0x3F : 0; + wp.town = ClosestTownFromTile(wp.xy, UINT_MAX); } else if (IsSavegameVersionBefore(SLV_122)) { /* Only for versions 12 .. 122 */ - if (!Town::IsValidID(wp->town_index)) { + if (!Town::IsValidID(wp.town_index)) { /* Upon a corrupted waypoint we'll likely get here. The next step will be to * loop over all Ptrs procs to NULL the pointers. However, we don't know * whether we're in the NULL or "normal" Ptrs proc. So just clear the list * of old waypoints we constructed and then this waypoint (and the other * possibly corrupt ones) will not be queried in the NULL Ptrs proc run. */ - _old_waypoints.Clear(); + _old_waypoints.clear(); SlErrorCorrupt("Referencing invalid Town"); } - wp->town = Town::Get(wp->town_index); + wp.town = Town::Get(wp.town_index); } if (IsSavegameVersionBefore(SLV_84)) { - wp->name = CopyFromOldName(wp->string_id); + wp.name = CopyFromOldName(wp.string_id); } } } diff --git a/src/script/api/ai/ai_vehicle.hpp.sq b/src/script/api/ai/ai_vehicle.hpp.sq index 0eb21ed672..dbd0096ada 100644 --- a/src/script/api/ai/ai_vehicle.hpp.sq +++ b/src/script/api/ai/ai_vehicle.hpp.sq @@ -122,6 +122,8 @@ void SQAIVehicle_Register(Squirrel *engine) SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsInDepot, "IsInDepot", 2, ".i"); SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i"); SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicle, "BuildVehicle", 3, ".ii"); + SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicleWithRefit, "BuildVehicleWithRefit", 4, ".iii"); + SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::GetBuildWithRefitCapacity, "GetBuildWithRefitCapacity", 4, ".iii"); SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::CloneVehicle, "CloneVehicle", 4, ".iib"); SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagon, "MoveWagon", 5, ".iiii"); SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii"); diff --git a/src/script/api/game/game_vehicle.hpp.sq b/src/script/api/game/game_vehicle.hpp.sq index 3dc9fe67ad..15a007046e 100644 --- a/src/script/api/game/game_vehicle.hpp.sq +++ b/src/script/api/game/game_vehicle.hpp.sq @@ -123,6 +123,8 @@ void SQGSVehicle_Register(Squirrel *engine) SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsInDepot, "IsInDepot", 2, ".i"); SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i"); SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicle, "BuildVehicle", 3, ".ii"); + SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicleWithRefit, "BuildVehicleWithRefit", 4, ".iii"); + SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::GetBuildWithRefitCapacity, "GetBuildWithRefitCapacity", 4, ".iii"); SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::CloneVehicle, "CloneVehicle", 4, ".iib"); SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagon, "MoveWagon", 5, ".iiii"); SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii"); diff --git a/src/script/api/script_admin.cpp b/src/script/api/script_admin.cpp index f66d9fc8a8..7a0fe627a3 100644 --- a/src/script/api/script_admin.cpp +++ b/src/script/api/script_admin.cpp @@ -135,7 +135,6 @@ std::string json; ScriptAdmin::MakeJSON(vm, -1, SQUIRREL_MAX_DEPTH, json); -#ifdef ENABLE_NETWORK if (json.length() > NETWORK_GAMESCRIPT_JSON_LENGTH) { ScriptLog::Error("You are trying to send a table that is too large to the AdminPort. No data sent."); sq_pushinteger(vm, 0); @@ -143,7 +142,6 @@ } NetworkAdminGameScript(json.c_str()); -#endif /* ENABLE_NETWORK */ sq_pushinteger(vm, 1); return 1; diff --git a/src/script/api/script_client.cpp b/src/script/api/script_client.cpp index 771a0ae4ec..855ad86a0b 100644 --- a/src/script/api/script_client.cpp +++ b/src/script/api/script_client.cpp @@ -16,7 +16,6 @@ #include "../../safeguards.h" -#ifdef ENABLE_NETWORK /** * Finds NetworkClientInfo given client-identifier, * is used by other methods to resolve client-identifier. @@ -29,46 +28,29 @@ static NetworkClientInfo *FindClientInfo(ScriptClient::ClientID client) if (!_networking) return NULL; return NetworkClientInfo::GetByClientID((::ClientID)client); } -#endif /* static */ ScriptClient::ClientID ScriptClient::ResolveClientID(ScriptClient::ClientID client) { -#ifdef ENABLE_NETWORK return (FindClientInfo(client) == NULL ? ScriptClient::CLIENT_INVALID : client); -#else - return CLIENT_INVALID; -#endif } /* static */ char *ScriptClient::GetName(ScriptClient::ClientID client) { -#ifdef ENABLE_NETWORK NetworkClientInfo *ci = FindClientInfo(client); if (ci == NULL) return NULL; return stredup(ci->client_name); -#else - return NULL; -#endif } /* static */ ScriptCompany::CompanyID ScriptClient::GetCompany(ScriptClient::ClientID client) { -#ifdef ENABLE_NETWORK NetworkClientInfo *ci = FindClientInfo(client); if (ci == NULL) return ScriptCompany::COMPANY_INVALID; return (ScriptCompany::CompanyID)ci->client_playas; -#else - return ScriptCompany::COMPANY_INVALID; -#endif } /* static */ ScriptDate::Date ScriptClient::GetJoinDate(ScriptClient::ClientID client) { -#ifdef ENABLE_NETWORK NetworkClientInfo *ci = FindClientInfo(client); if (ci == NULL) return ScriptDate::DATE_INVALID; return (ScriptDate::Date)ci->join_date; -#else - return ScriptDate::DATE_INVALID; -#endif } diff --git a/src/script/api/script_clientlist.cpp b/src/script/api/script_clientlist.cpp index 2f7a19a9ff..dbbbce0ec4 100644 --- a/src/script/api/script_clientlist.cpp +++ b/src/script/api/script_clientlist.cpp @@ -19,18 +19,15 @@ ScriptClientList::ScriptClientList() { -#ifdef ENABLE_NETWORK if (!_networking) return; NetworkClientInfo *ci; FOR_ALL_CLIENT_INFOS(ci) { this->AddItem(ci->client_id); } -#endif } ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID company) { -#ifdef ENABLE_NETWORK if (!_networking) return; CompanyID c; if (company == ScriptCompany::COMPANY_SPECTATOR) { @@ -45,5 +42,4 @@ ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID comp FOR_ALL_CLIENT_INFOS(ci) { if (ci->client_playas == c) this->AddItem(ci->client_id); } -#endif } diff --git a/src/script/api/script_game.cpp b/src/script/api/script_game.cpp index c24757a3cc..3e26174885 100644 --- a/src/script/api/script_game.cpp +++ b/src/script/api/script_game.cpp @@ -39,9 +39,5 @@ /* static */ bool ScriptGame::IsMultiplayer() { -#ifdef ENABLE_NETWORK return _network_server; -#else - return false; -#endif } diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index c183b75834..54312cd9d4 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -137,12 +137,8 @@ { EnforcePrecondition(false, ScriptGame::IsMultiplayer()); EnforcePrecondition(false, ScriptClient::ResolveClientID(client) != ScriptClient::CLIENT_INVALID); -#ifdef ENABLE_NETWORK ClientIndex c = NetworkClientInfo::GetByClientID((::ClientID)client)->index; return DoQuestion(uniqueid, c, true, question, type, buttons); -#else - return false; -#endif } /* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid) diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index adeec4afc7..4f9d6862af 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -303,10 +303,8 @@ ScriptObject::ActiveInstance::~ActiveInstance() /* Are we only interested in the estimate costs? */ bool estimate_only = GetDoCommandMode() != NULL && !GetDoCommandMode()(); -#ifdef ENABLE_NETWORK /* Only set p2 when the command does not come from the network. */ if (GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = UINT32_MAX; -#endif SCOPE_INFO_FMT([=], "ScriptObject::DoCommand: tile: %X (%d x %d), p1: 0x%X, p2: 0x%X, company: %s, cmd: 0x%X (%s), estimate_only: %d", tile, TileX(tile), TileY(tile), p1, p2, scope_dumper().CompanyInfo(_current_company), cmd, GetCommandName(cmd), estimate_only); diff --git a/src/script/api/script_text.hpp b/src/script/api/script_text.hpp index e591560247..a734fd7df8 100644 --- a/src/script/api/script_text.hpp +++ b/src/script/api/script_text.hpp @@ -45,7 +45,7 @@ public: RawText(const char *text); ~RawText(); - /* virtual */ const char *GetEncodedText() { return this->text; } + const char *GetEncodedText() override { return this->text; } private: const char *text; }; diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index a1cb1fc8d5..313aa6305f 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -61,21 +61,44 @@ return v->IsGroundVehicle() ? v->GetGroundVehicleCache()->cached_total_length : -1; } -/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id) +/* static */ VehicleID ScriptVehicle::_BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo) { - EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY); + EnforcePrecondition(VEHICLE_INVALID, ScriptObject::GetCompany() != OWNER_DEITY); EnforcePrecondition(VEHICLE_INVALID, ScriptEngine::IsBuildable(engine_id)); + EnforcePrecondition(VEHICLE_INVALID, cargo == CT_INVALID || ScriptCargo::IsValidCargo(cargo)); ::VehicleType type = ::Engine::Get(engine_id)->type; EnforcePreconditionCustomError(VEHICLE_INVALID, !ScriptGameSettings::IsDisabledVehicleType((ScriptVehicle::VehicleType)type), ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED); - if (!ScriptObject::DoCommand(depot, engine_id, 0, ::GetCmdBuildVeh(type), NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID; + if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, ::GetCmdBuildVeh(type), NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID; /* In case of test-mode, we return VehicleID 0 */ return 0; } +/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id) +{ + return _BuildVehicleInternal(depot, engine_id, CT_INVALID); +} + +/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo) +{ + EnforcePrecondition(VEHICLE_INVALID, ScriptCargo::IsValidCargo(cargo)); + return _BuildVehicleInternal(depot, engine_id, cargo); +} + +/* static */ int ScriptVehicle::GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo) +{ + if (!ScriptEngine::IsBuildable(engine_id)) return -1; + if (!ScriptCargo::IsValidCargo(cargo)) return -1; + + ::VehicleType type = ::Engine::Get(engine_id)->type; + + CommandCost res = ::DoCommand(depot, engine_id | (cargo << 24), 0, DC_QUERY_COST, ::GetCmdBuildVeh(type)); + return res.Succeeded() ? _returned_refit_capacity : -1; +} + /* static */ VehicleID ScriptVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders) { EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY); diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index f6b22c204d..d027e12435 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -320,6 +320,41 @@ public: */ static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id); + /** + * Builds a vehicle with the given engine at the given depot and refits it to the given cargo. + * @param depot The depot where the vehicle will be build. + * @param engine_id The engine to use for this vehicle. + * @param cargo The cargo to refit to. + * @pre The tile at depot has a depot that can build the engine and + * is owned by you. + * @pre ScriptEngine::IsBuildable(engine_id). + * @pre ScriptCargo::IsValidCargo(cargo). + * @game @pre Valid ScriptCompanyMode active in scope. + * @exception ScriptVehicle::ERR_VEHICLE_TOO_MANY + * @exception ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED + * @exception ScriptVehicle::ERR_VEHICLE_WRONG_DEPOT + * @return The VehicleID of the new vehicle, or an invalid VehicleID when + * it failed. Check the return value using IsValidVehicle. In test-mode + * 0 is returned if it was successful; any other value indicates failure. + * @note In Test Mode it means you can't assign orders yet to this vehicle, + * as the vehicle isn't really built yet. Build it for real first before + * assigning orders. + */ + static VehicleID BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo); + + /** + * Gets the capacity of a vehicle built at the given depot with the given engine and refitted to the given cargo. + * @param depot The depot where the vehicle will be build. + * @param engine_id The engine to use for this vehicle. + * @param cargo The cargo to refit to. + * @pre The tile at depot has a depot that can build the engine and + * is owned by you. + * @pre ScriptEngine::IsBuildable(engine_id). + * @pre ScriptCargo::IsValidCargo(cargo). + * @return The capacity the vehicle will have when refited. + */ + static int GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo); + /** * Clones a vehicle at the given depot, copying or cloning its orders. * @param depot The depot where the vehicle will be build. @@ -563,6 +598,11 @@ public: static uint GetMaximumOrderDistance(VehicleID vehicle_id); private: + /** + * Internal function used by BuildVehicle(WithRefit). + */ + static VehicleID _BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo); + /** * Internal function used by SellWagon(Chain). */ diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp index b95c6e366d..47ff2ee5f9 100644 --- a/src/script/script_info.cpp +++ b/src/script/script_info.cpp @@ -26,8 +26,8 @@ ScriptInfo::~ScriptInfo() free((*it).name); free((*it).description); if (it->labels != NULL) { - for (LabelMapping::iterator it2 = (*it).labels->Begin(); it2 != (*it).labels->End(); it2++) { - free(it2->second); + for (auto &lbl_map : *(*it).labels) { + free(lbl_map.second); } delete it->labels; } diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index fe6d41cf92..168a852a51 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -18,11 +18,9 @@ #include "script_scanner.hpp" #include "script_info.hpp" -#if defined(ENABLE_NETWORK) #include "../network/network_content.h" #include "../3rdparty/md5/md5.h" #include "../tar_type.h" -#endif /* ENABLE_NETWORK */ #include "../safeguards.h" @@ -180,8 +178,6 @@ char *ScriptScanner::GetConsoleList(char *p, const char *last, bool newest_only) return p; } -#if defined(ENABLE_NETWORK) - /** Helper for creating a MD5sum of all files within of a script. */ struct ScriptFileChecksumCreator : FileScanner { byte md5sum[16]; ///< The final md5sum. @@ -287,5 +283,3 @@ const char *ScriptScanner::FindMainScript(const ContentInfo *ci, bool md5sum) } return NULL; } - -#endif /* ENABLE_NETWORK */ diff --git a/src/script/script_scanner.hpp b/src/script/script_scanner.hpp index 50dad02ad2..7fecf6eb29 100644 --- a/src/script/script_scanner.hpp +++ b/src/script/script_scanner.hpp @@ -77,7 +77,7 @@ public: */ const char *FindMainScript(const ContentInfo *ci, bool md5sum); - /* 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; /** * Rescan the script dir. diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index 22d738d4f7..10f04f945a 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -29,10 +29,10 @@ namespace SQConvert { * comes out of scope. Useful to make sure you can use stredup(), * without leaking memory. */ - struct SQAutoFreePointers : SmallVector { + struct SQAutoFreePointers : std::vector { ~SQAutoFreePointers() { - for (uint i = 0; i < this->items; i++) free(this->data[i]); + for (void * p : *this) free(p); } }; @@ -117,7 +117,7 @@ namespace SQConvert { sq_getstring(vm, -1, &tmp); char *tmp_str = stredup(tmp); sq_poptop(vm); - *ptr->Append() = (void *)tmp_str; + ptr->push_back((void *)tmp_str); str_validate(tmp_str, tmp_str + strlen(tmp_str)); return tmp_str; } @@ -132,12 +132,12 @@ namespace SQConvert { sq_pushobject(vm, obj); sq_pushnull(vm); - SmallVector data; + std::vector data; while (SQ_SUCCEEDED(sq_next(vm, -2))) { SQInteger tmp; if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) { - *data.Append() = (int32)tmp; + data.push_back((int32)tmp); } else { sq_pop(vm, 4); throw sq_throwerror(vm, "a member of an array used as parameter to a function is not numeric"); @@ -147,11 +147,11 @@ namespace SQConvert { } sq_pop(vm, 2); - Array *arr = (Array*)MallocT(sizeof(Array) + sizeof(int32) * data.Length()); - arr->size = data.Length(); - memcpy(arr->array, data.Begin(), sizeof(int32) * data.Length()); + Array *arr = (Array*)MallocT(sizeof(Array) + sizeof(int32) * data.size()); + arr->size = data.size(); + memcpy(arr->array, data.data(), sizeof(int32) * data.size()); - *ptr->Append() = arr; + ptr->push_back(arr); return arr; } diff --git a/src/settings.cpp b/src/settings.cpp index a57e6204a6..f7b6933834 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -455,13 +455,30 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val) case SLE_VAR_U16: case SLE_VAR_I32: { /* Override the minimum value. No value below sdb->min, except special value 0 */ - if (!(sdb->flags & SGF_0ISDISABLED) || val != 0) val = Clamp(val, sdb->min, sdb->max); + if (!(sdb->flags & SGF_0ISDISABLED) || val != 0) { + if (!(sdb->flags & SGF_MULTISTRING)) { + /* Clamp value-type setting to its valid range */ + val = Clamp(val, sdb->min, sdb->max); + } else if (val < sdb->min || val > (int32)sdb->max) { + /* Reset invalid discrete setting (where different values change gameplay) to its default value */ + val = (int32)(size_t)sdb->def; + } + } break; } case SLE_VAR_U32: { /* Override the minimum value. No value below sdb->min, except special value 0 */ - uint min = ((sdb->flags & SGF_0ISDISABLED) && (uint)val <= (uint)sdb->min) ? 0 : sdb->min; - WriteValue(ptr, SLE_VAR_U32, (int64)ClampU(val, min, sdb->max)); + uint32 uval = (uint32)val; + if (!(sdb->flags & SGF_0ISDISABLED) || uval != 0) { + if (!(sdb->flags & SGF_MULTISTRING)) { + /* Clamp value-type setting to its valid range */ + uval = ClampU(uval, sdb->min, sdb->max); + } else if (uval < (uint)sdb->min || uval > sdb->max) { + /* Reset invalid discrete setting to its default value */ + uval = (uint32)(size_t)sdb->def; + } + } + WriteValue(ptr, SLE_VAR_U32, (int64)uval); return; } case SLE_VAR_I64: @@ -717,7 +734,7 @@ static void IniLoadSettingList(IniFile *ini, const char *grpname, StringList *li list->Clear(); for (const IniItem *item = group->item; item != NULL; item = item->next) { - if (item->name != NULL) *list->Append() = stredup(item->name); + if (item->name != NULL) list->push_back(stredup(item->name)); } } @@ -737,8 +754,8 @@ static void IniSaveSettingList(IniFile *ini, const char *grpname, StringList *li if (group == NULL || list == NULL) return; group->Clear(); - for (char **iter = list->Begin(); iter != list->End(); iter++) { - group->GetItem(*iter, true)->SetValue(""); + for (char *iter : *list) { + group->GetItem(iter, true)->SetValue(""); } } @@ -1436,8 +1453,6 @@ static bool DayLengthChanged(int32 p1) return true; } -#ifdef ENABLE_NETWORK - static bool UpdateClientName(int32 p1) { NetworkUpdateClientName(); @@ -1469,9 +1484,6 @@ static bool UpdateClientConfigValues(int32 p1) return true; } -#endif /* ENABLE_NETWORK */ - - /* End - Callback Functions */ /* Begin - GUI order callbacks */ @@ -1816,11 +1828,9 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP proc(ini, _currency_settings,"currency", &_custom_currency); proc(ini, _company_settings, "company", &_settings_client.company); -#ifdef ENABLE_NETWORK proc_list(ini, "server_bind_addresses", &_network_bind_list); proc_list(ini, "servers", &_network_host_list); proc_list(ini, "bans", &_network_ban_list); -#endif /* ENABLE_NETWORK */ } } @@ -1896,7 +1906,7 @@ void GetGRFPresetList(GRFPresetList *list) IniGroup *group; for (group = ini->group; group != NULL; group = group->next) { if (strncmp(group->name, "preset-", 7) == 0) { - *list->Append() = stredup(group->name + 7); + list->push_back(stredup(group->name + 7)); } } @@ -2120,7 +2130,6 @@ void SetDefaultCompanySettings(CompanyID cid) } } -#if defined(ENABLE_NETWORK) /** * Sync all company settings in a multiplayer game. */ @@ -2136,7 +2145,6 @@ void SyncCompanySettings() if (old_value != new_value) NetworkSendCommand(0, i, new_value, CMD_CHANGE_COMPANY_SETTING, NULL, NULL, _local_company, 0); } } -#endif /* ENABLE_NETWORK */ /** * Get the index in the _company_settings array of a setting @@ -2771,18 +2779,6 @@ static void Save_PATX() SaveSettingsPatx(_settings, &_settings_game); } -void CheckConfig() -{ - /* - * Increase old default values for pf_maxdepth and pf_maxlength - * to support big networks. - */ - if (_settings_newgame.pf.opf.pf_maxdepth == 16 && _settings_newgame.pf.opf.pf_maxlength == 512) { - _settings_newgame.pf.opf.pf_maxdepth = 48; - _settings_newgame.pf.opf.pf_maxlength = 4096; - } -} - extern const ChunkHandler _setting_chunk_handlers[] = { { 'OPTS', NULL, Load_OPTS, NULL, NULL, CH_RIFF}, { 'PATS', Save_PATS, Load_PATS, NULL, Check_PATS, CH_RIFF}, diff --git a/src/settings_func.h b/src/settings_func.h index 3b3387b5fd..a16c31c207 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -24,14 +24,13 @@ void IConsoleListSettings(const char *prefilter); void LoadFromConfig(bool minimal = false); void SaveToConfig(); -void CheckConfig(); void IniLoadWindowSettings(IniFile *ini, const char *grpname, void *desc); void IniSaveWindowSettings(IniFile *ini, const char *grpname, void *desc); /* Functions to load and save NewGRF settings to a separate * configuration file, used for presets. */ -typedef AutoFreeSmallVector GRFPresetList; +typedef AutoFreeSmallVector GRFPresetList; void GetGRFPresetList(GRFPresetList *list); struct GRFConfig *LoadGRFPresetFromConfig(const char *config_name); @@ -41,10 +40,6 @@ void DeleteGRFPresetFromConfig(const char *config_name); uint GetCompanySettingIndex(const char *name); void SetDefaultCompanySettings(CompanyID cid); -#if defined(ENABLE_NETWORK) void SyncCompanySettings(); -#else /* ENABLE_NETWORK */ -static inline void SyncCompanySettings() {} -#endif /* ENABLE_NETWORK */ #endif /* SETTINGS_FUNC_H */ diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 20592e6a7a..491a8742b6 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -129,7 +129,7 @@ static DropDownList *BuildSetDropDownList(int *selected_index, bool allow_select DropDownList *list = new DropDownList(); for (int i = 0; i < n; i++) { - *list->Append() = new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)); + list->push_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i))); } return list; @@ -152,7 +152,7 @@ struct BaseSetTextfileWindow : public TextfileWindow { this->LoadTextfile(textfile, BASESET_DIR); } - /* virtual */ void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, content_type); @@ -213,13 +213,13 @@ struct GameOptionsWindow : Window { /* Add non-custom currencies; sorted naturally */ for (uint i = 0; i < CURRENCY_END; items++, i++) { if (i == CURRENCY_CUSTOM) continue; - *list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i)); + list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i))); } - QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc); + QSortT(list->data(), list->size(), DropDownListStringItem::NatSortFunc); /* Append custom currency at the end */ - *list->Append() = new DropDownListItem(-1, false); // separator line - *list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)); + list->push_back(new DropDownListItem(-1, false)); // separator line + list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM))); break; } @@ -237,7 +237,7 @@ struct GameOptionsWindow : Window { } for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) { - *list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i)); + list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i))); } break; } @@ -251,22 +251,22 @@ struct GameOptionsWindow : Window { /* Add and sort newgrf townnames generators */ for (int i = 0; i < _nb_grf_names; i++) { int result = _nb_orig_names + i; - *list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0); + list->push_back(new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0)); } - QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc); + QSortT(list->data(), list->size(), DropDownListStringItem::NatSortFunc); - int newgrf_size = list->Length(); + int newgrf_size = list->size(); /* Insert newgrf_names at the top of the list */ if (newgrf_size > 0) { - *list->Append() = new DropDownListItem(-1, false); // separator line + list->push_back(new DropDownListItem(-1, false)); // separator line newgrf_size++; } /* Add and sort original townnames generators */ for (int i = 0; i < _nb_orig_names; i++) { - *list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0); + list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0)); } - QSortT(list->Begin() + newgrf_size, list->Length() - newgrf_size, DropDownListStringItem::NatSortFunc); + QSortT(list->data() + newgrf_size, list->size() - newgrf_size, DropDownListStringItem::NatSortFunc); break; } @@ -275,18 +275,18 @@ struct GameOptionsWindow : Window { *selected_index = _settings_client.gui.autosave; const StringID *items = _autosave_dropdown; for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) { - *list->Append() = new DropDownListStringItem(*items, i, false); + list->push_back(new DropDownListStringItem(*items, i, false)); } break; } case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown list = new DropDownList(); - for (uint i = 0; i < _languages.Length(); i++) { + for (uint i = 0; i < _languages.size(); i++) { if (&_languages[i] == _current_language) *selected_index = i; - *list->Append() = new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false); + list->push_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false)); } - QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc); + QSortT(list->data(), list->size(), DropDownListStringItem::NatSortFunc); break; } @@ -296,7 +296,7 @@ struct GameOptionsWindow : Window { list = new DropDownList(); *selected_index = GetCurRes(); for (int i = 0; i < _num_resolutions; i++) { - *list->Append() = new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false); + list->push_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false)); } break; @@ -305,7 +305,7 @@ struct GameOptionsWindow : Window { *selected_index = ZOOM_LVL_OUT_4X - _gui_zoom; const StringID *items = _gui_zoom_dropdown; for (int i = 0; *items != INVALID_STRING_ID; items++, i++) { - *list->Append() = new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i); + list->push_back(new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i)); } break; } @@ -315,7 +315,7 @@ struct GameOptionsWindow : Window { *selected_index = ZOOM_LVL_OUT_4X - _font_zoom; const StringID *items = _font_zoom_dropdown; for (int i = 0; *items != INVALID_STRING_ID; items++, i++) { - *list->Append() = new DropDownListStringItem(*items, i, false); + list->push_back(new DropDownListStringItem(*items, i, false)); } break; } @@ -339,7 +339,7 @@ struct GameOptionsWindow : Window { return list; } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break; @@ -358,7 +358,7 @@ struct GameOptionsWindow : Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_GO_BASE_GRF_DESCRIPTION: @@ -378,7 +378,7 @@ struct GameOptionsWindow : 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_GO_BASE_GRF_DESCRIPTION: @@ -432,11 +432,11 @@ struct GameOptionsWindow : Window { DropDownList *list = this->BuildDropDownList(widget, &selected); if (list != NULL) { /* Find the biggest item for the default size. */ - for (const DropDownListItem * const *it = list->Begin(); it != list->End(); it++) { + for (const DropDownListItem * const ddli : *list) { Dimension string_dim; - int width = (*it)->Width(); + int width = ddli->Width(); string_dim.width = width + padding.width; - string_dim.height = (*it)->Height(width) + padding.height; + string_dim.height = ddli->Height(width) + padding.height; *size = maxdim(*size, string_dim); } delete list; @@ -445,7 +445,7 @@ struct GameOptionsWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) { if (BaseGraphics::GetUsedSet() == NULL) return; @@ -508,7 +508,7 @@ struct GameOptionsWindow : Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: // Currency @@ -589,7 +589,7 @@ struct GameOptionsWindow : Window { * @param data Information about the changed data. @see GameOptionsInvalidationData * @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; this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen); @@ -1984,7 +1984,7 @@ struct GameSettingsWindow : Window { this->InvalidateData(); } - 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_GS_OPTIONSPANEL: @@ -2019,7 +2019,7 @@ struct GameSettingsWindow : Window { } } - virtual void OnPaint() + void OnPaint() override { if (this->closing_dropdown) { this->closing_dropdown = false; @@ -2060,7 +2060,7 @@ struct GameSettingsWindow : Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -2090,22 +2090,22 @@ struct GameSettingsWindow : Window { * we don't want to allow comparing with new game's settings. */ bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame; - *list->Append() = new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled); + list->push_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled)); } break; case WID_GS_TYPE_DROPDOWN: list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false); - *list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false); - *list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false); - *list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false); + list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false)); + list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false)); + list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false)); + list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false)); break; } return list; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_GS_OPTIONSPANEL: { @@ -2155,7 +2155,7 @@ struct GameSettingsWindow : Window { this->last_clicked = pe; } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_GS_EXPAND_ALL: @@ -2258,7 +2258,7 @@ struct GameSettingsWindow : Window { for (int i = sdb->min; i <= (int)sdb->max; i++) { int val = sd->orderproc ? sd->orderproc(i - sdb->min) : i; assert_msg(val >= sdb->min && val <= (int)sdb->max, "min: %d, max: %d, val: %d", sdb->min, sdb->max, val); - *list->Append() = new DropDownListStringItem(sdb->str_val + val - sdb->min, val, false); + list->push_back(new DropDownListStringItem(sdb->str_val + val - sdb->min, val, false)); } ShowDropDownListAt(this, list, value, -1, wi_rect, COLOUR_ORANGE, true); @@ -2345,7 +2345,7 @@ struct GameSettingsWindow : Window { } } - virtual void OnTimeout() + void OnTimeout() override { if (this->clicked_entry != NULL) { // On timeout, release any depressed buttons this->clicked_entry->SetButtons(0); @@ -2354,7 +2354,7 @@ struct GameSettingsWindow : Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { /* The user pressed cancel */ if (str == NULL) return; @@ -2384,7 +2384,7 @@ struct GameSettingsWindow : Window { this->SetDirty(); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -2428,7 +2428,7 @@ struct GameSettingsWindow : Window { } } - virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close) + void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override { if (widget >= 0) { /* Normally the default implementation of OnDropdownClose() takes care of @@ -2447,7 +2447,7 @@ struct GameSettingsWindow : 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; @@ -2477,7 +2477,7 @@ struct GameSettingsWindow : Window { this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded); } - virtual void OnEditboxChanged(int wid) + void OnEditboxChanged(int wid) override { if (wid == WID_GS_FILTER) { this->filter.string.SetFilterTerm(this->filter_editbox.text.buf); @@ -2490,7 +2490,7 @@ struct GameSettingsWindow : Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET); } @@ -2634,7 +2634,7 @@ struct CustomCurrencyWindow : Window { this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break; @@ -2652,7 +2652,7 @@ struct CustomCurrencyWindow : 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) { /* Set the appropriate width for the edit 'buttons' */ @@ -2671,7 +2671,7 @@ struct CustomCurrencyWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { int line = 0; int len = 0; @@ -2753,7 +2753,7 @@ struct CustomCurrencyWindow : Window { this->SetDirty(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; @@ -2785,7 +2785,7 @@ struct CustomCurrencyWindow : Window { SetButtonState(); } - virtual void OnTimeout() + void OnTimeout() override { this->SetDirty(); } diff --git a/src/settings_type.h b/src/settings_type.h index ea68b0c303..0e808de2d6 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -202,11 +202,9 @@ struct GUISettings { uint8 station_gui_group_order; ///< the order of grouping cargo entries in the station gui uint8 station_gui_sort_by; ///< sort cargo entries in the station gui by station name or amount uint8 station_gui_sort_order; ///< the sort order of entries in the station gui - ascending or descending -#ifdef ENABLE_NETWORK uint16 network_chat_box_width_pct; ///< width of the chat box in percent uint8 network_chat_box_height; ///< height of the chat box in lines uint16 network_chat_timeout; ///< timeout of chat messages in seconds -#endif uint8 developer; ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2) bool show_date_in_logs; ///< whether to show dates in console logs @@ -285,7 +283,6 @@ struct NewsSettings { /** All settings related to the network. */ struct NetworkSettings { -#ifdef ENABLE_NETWORK uint16 sync_freq; ///< how often do we check whether we are still in-sync uint8 frame_freq; ///< how often do we send commands to the clients uint16 commands_per_frame; ///< how many commands may be sent each frame_freq frames? @@ -325,8 +322,6 @@ struct NetworkSettings { char last_host[NETWORK_HOSTNAME_LENGTH]; ///< IP address of the last joined server uint16 last_port; ///< port of the last joined server bool no_http_content_downloads; ///< do not do content downloads over HTTP -#else /* ENABLE_NETWORK */ -#endif }; /** Settings related to the creation of games. */ @@ -410,12 +405,6 @@ struct ScriptSettings { uint32 script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend }; -/** Settings related to the old pathfinder. */ -struct OPFSettings { - uint16 pf_maxlength; ///< maximum length when searching for a train route for new pathfinder - byte pf_maxdepth; ///< maximum recursion depth when searching for a train route for new pathfinder -}; - /** Settings related to the new pathfinder. */ struct NPFSettings { /** @@ -504,7 +493,6 @@ struct PathfinderSettings { byte wait_for_pbs_path; ///< how long to wait for a path reservation. byte path_backoff_interval; ///< ticks between checks for a free path. - OPFSettings opf; ///< pathfinder settings for the old pathfinder NPFSettings npf; ///< pathfinder settings for the new pathfinder YAPFSettings yapf; ///< pathfinder settings for the yet another pathfinder }; diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp index d8d76a4d64..bf41161b41 100644 --- a/src/settingsgen/settingsgen.cpp +++ b/src/settingsgen/settingsgen.cpp @@ -103,7 +103,7 @@ public: /** Clear the temporary storage. */ void Clear() { - this->output_buffer.Clear(); + this->output_buffer.clear(); } /** @@ -116,14 +116,15 @@ public: if (length == 0) length = strlen(text); if (length > 0 && this->BufferHasRoom()) { - int stored_size = this->output_buffer[this->output_buffer.Length() - 1].Add(text, length); + int stored_size = this->output_buffer[this->output_buffer.size() - 1].Add(text, length); length -= stored_size; text += stored_size; } while (length > 0) { - OutputBuffer *block = this->output_buffer.Append(); - block->Clear(); // Initialize the new block. - int stored_size = block->Add(text, length); + /*C++17: OutputBuffer &block =*/ this->output_buffer.emplace_back(); + OutputBuffer &block = this->output_buffer.back(); + block.Clear(); // Initialize the new block. + int stored_size = block.Add(text, length); length -= stored_size; text += stored_size; } @@ -135,8 +136,8 @@ public: */ void Write(FILE *out_fp) const { - for (const OutputBuffer *out_data = this->output_buffer.Begin(); out_data != this->output_buffer.End(); out_data++) { - out_data->Write(out_fp); + for (const OutputBuffer &out_data : output_buffer) { + out_data.Write(out_fp); } } @@ -147,11 +148,11 @@ private: */ bool BufferHasRoom() const { - uint num_blocks = this->output_buffer.Length(); + uint num_blocks = this->output_buffer.size(); return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom(); } - typedef SmallVector OutputBufferVector; ///< Vector type for output buffers. + typedef std::vector OutputBufferVector; ///< Vector type for output buffers. OutputBufferVector output_buffer; ///< Vector of blocks containing the stored output. }; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 8e6a0f7989..e58e1a7e4b 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -30,7 +30,6 @@ #include "sound_func.h" #include "ai/ai.hpp" #include "game/game.hpp" -#include "pathfinder/opf/opf_ship.h" #include "engine_base.h" #include "company_base.h" #include "infrastructure_func.h" @@ -42,6 +41,16 @@ #include "safeguards.h" +/** Directions to search towards given track bits and the ship's enter direction. */ +const DiagDirection _ship_search_directions[6][4] = { + { DIAGDIR_NE, INVALID_DIAGDIR, DIAGDIR_SW, INVALID_DIAGDIR }, + { INVALID_DIAGDIR, DIAGDIR_SE, INVALID_DIAGDIR, DIAGDIR_NW }, + { INVALID_DIAGDIR, DIAGDIR_NE, DIAGDIR_NW, INVALID_DIAGDIR }, + { DIAGDIR_SE, INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SW }, + { DIAGDIR_NW, DIAGDIR_SW, INVALID_DIAGDIR, INVALID_DIAGDIR }, + { INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SE, DIAGDIR_NE }, +}; + /** * Determine the effective #WaterClass for a ship travelling on a tile. * @param tile Tile of interest @@ -178,7 +187,6 @@ static void CheckIfShipNeedsService(Vehicle *v) uint max_distance; switch (_settings_game.pf.pathfinder_for_ships) { - case VPF_OPF: max_distance = 12; break; case VPF_NPF: max_distance = _settings_game.pf.npf.maximum_go_to_depot_penalty / NPF_TILE_LENGTH; break; case VPF_YAPF: max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH; break; default: NOT_REACHED(); @@ -377,9 +385,7 @@ static bool CheckShipLeaveDepot(Ship *v) if (north_tracks && south_tracks) { /* Ask pathfinder for best direction */ bool reverse = false; - bool path_found; switch (_settings_game.pf.pathfinder_for_ships) { - case VPF_OPF: reverse = OPFShipChooseTrack(v, north_neighbour, north_dir, north_tracks, path_found) == INVALID_TRACK; break; // OPF always allows reversing case VPF_NPF: reverse = NPFShipCheckReverse(v); break; case VPF_YAPF: reverse = YapfShipCheckReverse(v); break; default: NOT_REACHED(); @@ -512,7 +518,6 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr } switch (_settings_game.pf.pathfinder_for_ships) { - case VPF_OPF: track = OPFShipChooseTrack(v, tile, enterdir, tracks, path_found); break; case VPF_NPF: track = NPFShipChooseTrack(v, path_found); break; case VPF_YAPF: track = YapfShipChooseTrack(v, tile, enterdir, tracks, path_found, v->path); break; default: NOT_REACHED(); @@ -534,8 +539,7 @@ static inline TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir, Tr { TrackBits tracks = GetTileShipTrackStatus(tile) & DiagdirReachesTracks(dir); - /* Do not remove 90 degree turns for OPF, as it isn't able to find paths taking it into account. */ - if (_settings_game.pf.forbid_90_deg && _settings_game.pf.pathfinder_for_ships != VPF_OPF) tracks &= ~TrackCrossesTracks(TrackdirToTrack(trackdir)); + if (_settings_game.pf.forbid_90_deg) tracks &= ~TrackCrossesTracks(TrackdirToTrack(trackdir)); return tracks; } diff --git a/src/signal.cpp b/src/signal.cpp index 237cc9d8b1..c05abea3f0 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -26,7 +26,7 @@ #include "safeguards.h" /// List of signals dependent upon this one -typedef SmallVector SignalDependencyList; +typedef std::vector SignalDependencyList; /// Map of dependencies. The key identifies the signal, /// the value is a list of all of the signals which depend upon that signal. @@ -825,21 +825,21 @@ void AddSignalDependency(SignalReference on, SignalReference dep) { assert(GetTileOwner(on.tile) == GetTileOwner(dep.tile)); SignalDependencyList &dependencies = _signal_dependencies[on]; - (*dependencies.Append()) = dep; + dependencies.push_back(dep); } void RemoveSignalDependency(SignalReference on, SignalReference dep) { SignalDependencyList &dependencies = _signal_dependencies[on]; - SignalReference *ob = dependencies.Find(dep); + auto ob = std::find(dependencies.begin(), dependencies.end(), dep); // Destroying both signals in same command - if(ob == dependencies.End()) - return; + if (ob == dependencies.end()) return; - dependencies.Erase(ob); - if (dependencies.Length() == 0) + dependencies.erase(ob); + if (dependencies.size() == 0) { _signal_dependencies.erase(on); + } } void FreeSignalDependencies() @@ -853,13 +853,12 @@ static void MarkDependencidesForUpdate(SignalReference on) if (f == _signal_dependencies.end()) return; SignalDependencyList &dependencies = f->second; - for (SignalReference *i = dependencies.Begin(), *e = dependencies.End(); - i != e; ++i) { - assert(GetTileOwner(i->tile) == GetTileOwner(on.tile)); + for (const SignalReference &i : dependencies) { + assert(GetTileOwner(i.tile) == GetTileOwner(on.tile)); - Trackdir td = TrackToTrackdir(i->track); - _globset.Add(i->tile, TrackdirToExitdir(td)); - _globset.Add(i->tile, TrackdirToExitdir(ReverseTrackdir(td))); + Trackdir td = TrackToTrackdir(i.track); + _globset.Add(i.tile, TrackdirToExitdir(td)); + _globset.Add(i.tile, TrackdirToExitdir(ReverseTrackdir(td))); } } @@ -900,9 +899,9 @@ void CheckRemoveSignal(TileIndex tile, Track track) if (i != e) { SignalDependencyList &dependencies = i->second; - for (SignalReference *ir = dependencies.Begin(), *er = dependencies.End(); ir != er; ++ir) { - assert(GetTileOwner(ir->tile) == GetTileOwner(tile)); - NotifyRemovingDependentSignal(thisRef, *ir); + for (const SignalReference &ir : dependencies) { + assert(GetTileOwner(ir.tile) == GetTileOwner(tile)); + NotifyRemovingDependentSignal(thisRef, ir); } _signal_dependencies.erase(i); diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 69fde2559f..ea6c680c30 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -58,6 +58,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (!StrEmpty(text)) { si->name = stredup(text); } + si->UpdateVirtCoord(); _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeSign(si->index)); InvalidateWindowData(WC_SIGN_LIST, 0, 0); _new_sign_id = si->index; @@ -99,6 +100,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } } else { // Delete sign if (flags & DC_EXEC) { + si->sign.MarkDirty(); _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeSign(si->index)); delete si; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 56af6e6655..cab19c22f8 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -60,14 +60,14 @@ struct SignList { DEBUG(misc, 3, "Building sign list"); - this->signs.Clear(); + this->signs.clear(); const Sign *si; - FOR_ALL_SIGNS(si) *this->signs.Append() = si; + FOR_ALL_SIGNS(si) this->signs.push_back(si); this->signs.SetFilterState(true); this->FilterSignList(); - this->signs.Compact(); + this->signs.shrink_to_fit(); this->signs.RebuildDone(); } @@ -166,7 +166,7 @@ struct SignListWindow : Window, SignList { this->BuildSortSignList(); } - virtual void OnInit() + void OnInit() override { /* Default sign name, used if Sign::name is NULL. */ GetString(SignList::default_name, STR_DEFAULT_SIGN_NAME, lastof(SignList::default_name)); @@ -190,13 +190,13 @@ struct SignListWindow : Window, SignList { this->InvalidateData(); } - virtual void OnPaint() + void OnPaint() override { if (!this->IsShaded() && this->signs.NeedRebuild()) this->BuildSortSignList(); this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_SIL_LIST: { @@ -228,12 +228,12 @@ struct SignListWindow : Window, SignList { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount()); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_SIL_LIST: { @@ -246,7 +246,7 @@ struct SignListWindow : Window, SignList { } case WID_SIL_FILTER_ENTER_BTN: - if (this->signs.Length() >= 1) { + if (this->signs.size() >= 1) { const Sign *si = this->signs[0]; ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); } @@ -260,12 +260,12 @@ struct SignListWindow : Window, SignList { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } - 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_SIL_LIST: { @@ -286,7 +286,7 @@ struct SignListWindow : Window, SignList { } } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { switch (hotkey) { case SLHK_FOCUS_FILTER_BOX: @@ -301,7 +301,7 @@ struct SignListWindow : Window, SignList { return ES_HANDLED; } - virtual void OnEditboxChanged(int widget) + void OnEditboxChanged(int widget) override { if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf); } @@ -310,13 +310,13 @@ struct SignListWindow : Window, SignList { { if (this->signs.NeedRebuild()) { this->BuildSignsList(); - this->vscroll->SetCount(this->signs.Length()); + this->vscroll->SetCount(this->signs.size()); this->SetWidgetDirty(WID_SIL_CAPTION); } this->SortSignsList(); } - virtual void OnHundredthTick() + void OnHundredthTick() override { this->BuildSortSignList(); this->SetDirty(); @@ -327,7 +327,7 @@ struct SignListWindow : Window, SignList { * @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 { /* When there is a filter string, we always need to rebuild the list even if * the amount of signs in total is unchanged, as the subset of signs that is @@ -471,7 +471,7 @@ struct SignWindow : Window, SignList { /* Search through the list for the current sign, excluding * - the first sign if we want the previous sign or * - the last sign if we want the next sign */ - uint end = this->signs.Length() - (next ? 1 : 0); + uint end = this->signs.size() - (next ? 1 : 0); for (uint i = next ? 0 : 1; i < end; i++) { if (this->cur_sign == this->signs[i]->index) { /* We've found the current sign, so return the sign before/after it */ @@ -479,10 +479,10 @@ struct SignWindow : Window, SignList { } } /* If we haven't found the current sign by now, return the last/first sign */ - return this->signs[next ? 0 : this->signs.Length() - 1]; + return next ? this->signs.front() : this->signs.back(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_QES_CAPTION: @@ -491,7 +491,7 @@ struct SignWindow : Window, SignList { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_QES_PREVIOUS: diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 094af4a0a6..1779cc5a3f 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1662,7 +1662,7 @@ public: this->smallmap_window = NULL; } - virtual void SetupSmallestSize(Window *w, bool init_array) + void SetupSmallestSize(Window *w, bool init_array) override { NWidgetBase *display = this->head; NWidgetBase *bar = display->next; @@ -1680,7 +1680,7 @@ public: this->resize_y = min(display->resize_y, bar->resize_y); } - virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override { this->pos_x = x; this->pos_y = y; @@ -1704,7 +1704,7 @@ public: bar->AssignSizePosition(ST_RESIZE, x, y + display_height, given_width, bar_height, rtl); } - virtual NWidgetCore *GetWidgetFromPos(int x, int y) + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL; for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) { @@ -1714,7 +1714,7 @@ public: return NULL; } - virtual void Draw(const Window *w) + void Draw(const Window *w) override { for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) child_wid->Draw(w); } diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 3899cd0086..f15df19ebf 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -46,7 +46,7 @@ struct TunnelBridgeToMap { TileIndex from_tile; TileIndex to_tile; }; -typedef SmallVector TunnelBridgeToMapVector; +typedef std::vector TunnelBridgeToMapVector; void BuildIndustriesLegend(); void ShowSmallMap(); @@ -205,17 +205,17 @@ public: void SmallMapCenterOnCurrentPos(); Point GetStationMiddle(const Station *st) const; - virtual void SetStringParameters(int widget) const; - virtual void OnInit(); - virtual void OnPaint(); - virtual void DrawWidget(const Rect &r, int widget) const; - virtual void OnClick(Point pt, int widget, int click_count); - virtual void OnInvalidateData(int data = 0, bool gui_scope = true); - virtual bool OnRightClick(Point pt, int widget); - virtual void OnMouseWheel(int wheel); - virtual void OnRealtimeTick(uint delta_ms); - virtual void OnScroll(Point delta); - virtual void OnMouseOver(Point pt, int widget); + void SetStringParameters(int widget) const override; + void OnInit() override; + void OnPaint() override; + void DrawWidget(const Rect &r, int widget) const override; + void OnClick(Point pt, int widget, int click_count) override; + void OnInvalidateData(int data = 0, bool gui_scope = true) override; + bool OnRightClick(Point pt, int widget) override; + void OnMouseWheel(int wheel) override; + void OnRealtimeTick(uint delta_ms) override; + void OnScroll(Point delta) override; + void OnMouseOver(Point pt, int widget) override; void TakeScreenshot(); void ScreenshotCallbackHandler(void *buf, uint y, uint pitch, uint n); diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 1a30c3b1a8..f5036903be 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -47,7 +47,7 @@ struct Filtering { * @tparam F Type of data fed as additional value to the filter function. @see FilterFunction */ template -class GUIList : public SmallVector { +class GUIList : public std::vector { public: typedef int CDECL SortFunction(const T*, const T*); ///< Signature of sort function. typedef bool CDECL FilterFunction(const T*, F); ///< Signature of filter function. @@ -67,7 +67,7 @@ protected: */ bool IsSortable() const { - return (this->data != NULL && this->items >= 2); + return std::vector::size() >= 2; } /** @@ -240,7 +240,7 @@ public: { this->flags ^= VL_DESC; - if (this->IsSortable()) MemReverseT(this->data, this->items); + if (this->IsSortable()) MemReverseT(std::vector::data(), std::vector::size()); } /** @@ -270,11 +270,11 @@ public: if (this->flags & VL_FIRST_SORT) { CLRBITS(this->flags, VL_FIRST_SORT); - QSortT(this->data, this->items, compare, desc); + QSortT(std::vector::data(), std::vector::size(), compare, desc); return true; } - GSortT(this->data, this->items, compare, desc); + GSortT(std::vector::data(), std::vector::size(), compare, desc); return true; } @@ -337,13 +337,12 @@ public: if (!(this->flags & VL_FILTER)) return false; bool changed = false; - for (uint iter = 0; iter < this->items;) { - T *item = &this->data[iter]; - if (!decide(item, filter_data)) { - this->Erase(item); + for (auto it = std::vector::begin(); it != std::vector::end(); /* Nothing */) { + if (!decide(&*it, filter_data)) { + it = std::vector::erase(it); changed = true; } else { - iter++; + it++; } } diff --git a/src/sound/allegro_s.h b/src/sound/allegro_s.h index e0a247f7b3..255be66c74 100644 --- a/src/sound/allegro_s.h +++ b/src/sound/allegro_s.h @@ -17,12 +17,12 @@ /** Implementation of the allegro sound driver. */ class SoundDriver_Allegro : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param); - /* virtual */ void Stop(); + void Stop(); - /* virtual */ void MainLoop(); - /* virtual */ const char *GetName() const { return "allegro"; } + void MainLoop(); + const char *GetName() const { return "allegro"; } }; /** Factory for the allegro sound driver. */ diff --git a/src/sound/cocoa_s.h b/src/sound/cocoa_s.h index 7010914258..dd2d740204 100644 --- a/src/sound/cocoa_s.h +++ b/src/sound/cocoa_s.h @@ -16,16 +16,16 @@ class SoundDriver_Cocoa : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); - /* virtual */ const char *GetName() const { return "cocoa"; } + void Stop() override; + const char *GetName() const override { return "cocoa"; } }; class FSoundDriver_Cocoa : public DriverFactoryBase { public: FSoundDriver_Cocoa() : DriverFactoryBase(Driver::DT_SOUND, 10, "cocoa", "Cocoa Sound Driver") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_Cocoa(); } + Driver *CreateInstance() const override { return new SoundDriver_Cocoa(); } }; #endif /* SOUND_COCOA_H */ diff --git a/src/sound/null_s.h b/src/sound/null_s.h index b2acd90937..ca9adb546a 100644 --- a/src/sound/null_s.h +++ b/src/sound/null_s.h @@ -17,17 +17,17 @@ /** Implementation of the null sound driver. */ class SoundDriver_Null : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param) { return NULL; } + const char *Start(const char * const *param) override { return NULL; } - /* virtual */ void Stop() { } - /* virtual */ const char *GetName() const { return "null"; } + void Stop() override { } + const char *GetName() const override { return "null"; } }; /** Factory for the null sound driver. */ class FSoundDriver_Null : public DriverFactoryBase { public: FSoundDriver_Null() : DriverFactoryBase(Driver::DT_SOUND, 1, "null", "Null Sound Driver") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_Null(); } + Driver *CreateInstance() const override { return new SoundDriver_Null(); } }; #endif /* SOUND_NULL_H */ diff --git a/src/sound/sdl_s.h b/src/sound/sdl_s.h index 544ce2070d..2d36b46297 100644 --- a/src/sound/sdl_s.h +++ b/src/sound/sdl_s.h @@ -17,17 +17,17 @@ /** Implementation of the SDL sound driver. */ class SoundDriver_SDL : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); - /* virtual */ const char *GetName() const { return "sdl"; } + void Stop() override; + const char *GetName() const override { return "sdl"; } }; /** Factory for the SDL sound driver. */ class FSoundDriver_SDL : public DriverFactoryBase { public: FSoundDriver_SDL() : DriverFactoryBase(Driver::DT_SOUND, 5, "sdl", "SDL Sound Driver") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_SDL(); } + Driver *CreateInstance() const override { return new SoundDriver_SDL(); } }; #endif /* SOUND_SDL_H */ diff --git a/src/sound/win32_s.h b/src/sound/win32_s.h index c6c8e8d149..a0d53a2dae 100644 --- a/src/sound/win32_s.h +++ b/src/sound/win32_s.h @@ -17,17 +17,17 @@ /** Implementation of the sound driver for Windows. */ class SoundDriver_Win32 : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); - /* virtual */ const char *GetName() const { return "win32"; } + void Stop() override; + const char *GetName() const override { return "win32"; } }; /** Factory for the sound driver for Windows. */ class FSoundDriver_Win32 : public DriverFactoryBase { public: FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 9, "win32", "Win32 WaveOut Sound Driver") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_Win32(); } + Driver *CreateInstance() const override { return new SoundDriver_Win32(); } }; #endif /* SOUND_WIN32_H */ diff --git a/src/sound/xaudio2_s.h b/src/sound/xaudio2_s.h index 2385f49ee2..f3525251cf 100644 --- a/src/sound/xaudio2_s.h +++ b/src/sound/xaudio2_s.h @@ -17,17 +17,17 @@ /** Implementation of the XAudio2 sound driver. */ class SoundDriver_XAudio2 : public SoundDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); - /* virtual */ const char *GetName() const { return "xaudio2"; } + void Stop() override; + const char *GetName() const override { return "xaudio2"; } }; /** Factory for the XAudio2 sound driver. */ class FSoundDriver_XAudio2 : public DriverFactoryBase { public: FSoundDriver_XAudio2() : DriverFactoryBase(Driver::DT_SOUND, 10, "xaudio2", "XAudio2 Sound Driver") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_XAudio2(); } + Driver *CreateInstance() const override { return new SoundDriver_XAudio2(); } }; #endif /* SOUND_XAUDIO2_H */ diff --git a/src/station.cpp b/src/station.cpp index 3771784dde..f674e69873 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -211,7 +211,7 @@ RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy) { if (this->facilities == FACIL_NONE) { - this->xy = facil_xy; + this->MoveSign(facil_xy); this->random_bits = Random(); } this->facilities |= new_facility_bit; diff --git a/src/station_base.h b/src/station_base.h index f09a63bb09..8703df243d 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -495,12 +495,14 @@ public: void MarkTilesDirty(bool cargo_change) const; - void UpdateVirtCoord(); + void UpdateVirtCoord() override; + + void MoveSign(TileIndex new_xy) override; void AfterStationTileSetChange(bool adding, StationType type); - /* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const; - /* virtual */ uint GetPlatformLength(TileIndex tile) const; + uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override; + uint GetPlatformLength(TileIndex tile) const override; void RecomputeCatchment(); static void RecomputeCatchmentForAll(); @@ -521,7 +523,7 @@ public: return this->catchment_tiles.HasTile(tile); } - /* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const + inline bool TileBelongsToRailStation(TileIndex tile) const override { return IsRailStationTile(tile) && GetStationIndex(tile) == this->index; } @@ -534,9 +536,9 @@ public: bool IsDockingTile(TileIndex tile) const; bool IsWithinRangeOfDockingTile(TileIndex tile, uint max_distance) const; - /* virtual */ uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const; + uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override; - /* virtual */ void GetTileArea(TileArea *ta, StationType type) const; + void GetTileArea(TileArea *ta, StationType type) const override; }; #define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 9a9eecb369..619c7173c6 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -431,6 +431,23 @@ void Station::UpdateVirtCoord() SetWindowDirty(WC_STATION_VIEW, this->index); } +/** + * Move the station main coordinate somewhere else. + * @param new_xy new tile location of the sign + */ +void Station::MoveSign(TileIndex new_xy) +{ + if (this->xy == new_xy) return; + + _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeStation(this->index)); + _station_kdtree.Remove(this->index); + + this->BaseStation::MoveSign(new_xy); + + _station_kdtree.Insert(this->index); + _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->index)); +} + /** Update the virtual coords needed to draw the station sign for all stations. */ void UpdateAllStationVirtCoords() { @@ -674,14 +691,7 @@ static void UpdateStationSignCoord(BaseStation *st) /* clamp sign coord to be inside the station rect */ TileIndex new_xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom)); - if (new_xy != st->xy) { - _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeStation(st->index)); - _station_kdtree.Remove(st->index); - st->xy = new_xy; - _station_kdtree.Insert(st->index); - _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(st->index)); - st->UpdateVirtCoord(); - } + st->MoveSign(new_xy); if (!Station::IsExpected(st)) return; Station *full_station = Station::From(st); @@ -910,7 +920,7 @@ CommandCost IsRailStationBridgeAboveOk(TileIndex tile, const StationSpec *statsp * @param numtracks Number of platforms. * @return The cost in case of success, or an error code if it failed. */ -static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, SmallVector &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks) +static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks) { CommandCost cost(EXPENSES_CONSTRUCTION); int allowed_z = -1; @@ -965,7 +975,7 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl if (HasBit(GetRailReservationTrackBits(tile_cur), track)) { Train *v = GetTrainForReservation(tile_cur, track); if (v != NULL) { - *affected_vehicles.Append() = v; + affected_vehicles.push_back(v); } } CommandCost ret = DoCommand(tile_cur, 0, track, flags, CMD_REMOVE_SINGLE_RAIL); @@ -1380,7 +1390,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 /* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */ StationID est = INVALID_STATION; - SmallVector affected_vehicles; + std::vector affected_vehicles; const StationSpec *statspec = StationClass::Get(spec_class)->GetSpec(spec_index); @@ -1473,7 +1483,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 /* Check for trains having a reservation for this tile. */ Train *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile))); if (v != NULL) { - *affected_vehicles.Append() = v; + affected_vehicles.push_back(v); FreeTrainReservation(v); } } @@ -1523,7 +1533,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta } while (--numtracks); - for (uint i = 0; i < affected_vehicles.Length(); ++i) { + for (uint i = 0; i < affected_vehicles.size(); ++i) { /* Restore reservations of trains. */ RestoreTrainReservation(affected_vehicles[i]); } @@ -1635,7 +1645,7 @@ restart: * @return the number of cleared tiles or an error. */ template -CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail) +CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail) { /* Count of the number of tiles removed */ int quantity = 0; @@ -1675,7 +1685,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector &affected } if (flags & DC_EXEC) { - bool already_affected = affected_stations.Include(st); + bool already_affected = include(affected_stations, st); if (!already_affected) ZoningMarkDirtyStationCoverageArea(st); /* read variables before the station tile is removed */ @@ -1711,8 +1721,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector &affected if (quantity == 0) return error.Failed() ? error : CommandCost(STR_ERROR_THERE_IS_NO_STATION); - for (T **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) { - T *st = *stp; + for (T *st : affected_stations) { /* now we need to make the "spanned" area of the railway station smaller * if we deleted something at the edges. @@ -1750,14 +1759,13 @@ CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint3 if (start >= MapSize() || end >= MapSize()) return CMD_ERROR; TileArea ta(start, end); - SmallVector affected_stations; + std::vector affected_stations; CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_STATION_RAIL], HasBit(p2, 0)); if (ret.Failed()) return ret; /* Do all station specific functions here. */ - for (Station **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) { - Station *st = *stp; + for (Station *st : affected_stations) { if (st->train_station.tile == INVALID_TILE) SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS); st->MarkTilesDirty(false); @@ -1785,7 +1793,7 @@ CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint if (start >= MapSize() || end >= MapSize()) return CMD_ERROR; TileArea ta(start, end); - SmallVector affected_stations; + std::vector affected_stations; return RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_WAYPOINT_RAIL], HasBit(p2, 0)); } @@ -1818,7 +1826,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost) TILE_AREA_LOOP(tile, ta) { /* only remove tiles that are actually train station tiles */ if (st->TileBelongsToRailStation(tile)) { - SmallVector affected_stations; // dummy + std::vector affected_stations; // dummy CommandCost ret = RemoveFromRailBaseStation(TileArea(tile, 1, 1), affected_stations, flags, removal_cost, false); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -3758,7 +3766,7 @@ void DeleteStaleLinks(Station *from) /* Have all vehicles refresh their next hops before deciding to * remove the node. */ OrderList *l; - SmallVector vehicles; + std::vector vehicles; FOR_ALL_ORDER_LISTS(l) { bool found_from = false; bool found_to = false; @@ -3773,11 +3781,11 @@ void DeleteStaleLinks(Station *from) } } if (!found_to || !found_from) continue; - *(vehicles.Append()) = l->GetFirstSharedVehicle(); + vehicles.push_back(l->GetFirstSharedVehicle()); } - Vehicle **iter = vehicles.Begin(); - while (iter != vehicles.End()) { + auto iter = vehicles.begin(); + while (iter != vehicles.end()) { Vehicle *v = *iter; LinkRefresher::Run(v, false); // Don't allow merging. Otherwise lg might get deleted. @@ -3791,10 +3799,10 @@ void DeleteStaleLinks(Station *from) *iter = next_shared; ++iter; } else { - vehicles.Erase(iter); + iter = vehicles.erase(iter); } - if (iter == vehicles.End()) iter = vehicles.Begin(); + if (iter == vehicles.end()) iter = vehicles.begin(); } } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index f565b40201..11b1f70f69 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -180,7 +180,7 @@ protected: DEBUG(misc, 3, "Building station list for company %d", owner); - this->stations.Clear(); + this->stations.clear(); const Station *st; FOR_ALL_STATIONS(st) { @@ -191,23 +191,23 @@ protected: if (st->goods[j].HasRating()) { num_waiting_cargo++; // count number of waiting cargo if (HasBit(this->cargo_filter, j)) { - *this->stations.Append() = st; + this->stations.push_back(st); break; } } } /* stations without waiting cargo */ if (num_waiting_cargo == 0 && this->include_empty) { - *this->stations.Append() = st; + this->stations.push_back(st); } } } } - this->stations.Compact(); + this->stations.shrink_to_fit(); this->stations.RebuildDone(); - this->vscroll->SetCount(this->stations.Length()); // Update the scrollbar + this->vscroll->SetCount(this->stations.size()); // Update the scrollbar } /** Sort stations by their name */ @@ -339,7 +339,7 @@ public: this->last_sorting = this->stations.GetListing(); } - 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_STL_SORTBY: { @@ -395,7 +395,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { this->BuildStationsList((Owner)this->window_number); this->SortStationsList(); @@ -403,7 +403,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_STL_SORTBY: @@ -413,7 +413,7 @@ public: case WID_STL_LIST: { bool rtl = _current_text_dir == TD_RTL; - int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length()); + int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size()); int y = r.top + WD_FRAMERECT_TOP; for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner const Station *st = this->stations[i]; @@ -487,7 +487,7 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_STL_CAPTION) { SetDParam(0, this->window_number); @@ -495,12 +495,12 @@ 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_STL_LIST: { uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL); - if (id_v >= this->stations.Length()) return; // click out of list bound + if (id_v >= this->stations.size()) return; // click out of list bound const Station *st = this->stations[id_v]; /* do not check HasStationInUse - it is slow and may be invalid */ @@ -611,7 +611,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (this->stations.SortType() != index) { this->stations.SetSortType(index); @@ -623,7 +623,7 @@ public: } } - virtual void OnGameTick() + void OnGameTick() override { if (this->stations.NeedResort()) { DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number); @@ -631,7 +631,7 @@ public: } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } @@ -641,7 +641,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 */ @@ -1367,7 +1367,7 @@ struct StationViewWindow : public Window { data->Update(count); } - 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_SV_WAITING: @@ -1391,7 +1391,7 @@ struct StationViewWindow : public Window { } } - virtual void OnPaint() + void OnPaint() override { const Station *st = Station::Get(this->window_number); CargoDataEntry cargo; @@ -1447,7 +1447,7 @@ struct StationViewWindow : public Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { const Station *st = Station::Get(this->window_number); SetDParam(0, st->index); @@ -1882,7 +1882,7 @@ struct StationViewWindow : public Window { this->SetWidgetDirty(WID_SV_WAITING); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_SV_WAITING: @@ -2048,7 +2048,7 @@ struct StationViewWindow : public Window { this->SetDirty(); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (widget == WID_SV_SORT_BY) { this->SelectSortBy(index); @@ -2057,14 +2057,14 @@ struct StationViewWindow : public Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), NULL, str); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SV_WAITING, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } @@ -2074,7 +2074,7 @@ struct StationViewWindow : public Window { * @param data Information about the changed data. If it's a valid cargo ID, invalidate the cargo 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) { if (data >= 0 && data < NUM_CARGO) { @@ -2127,8 +2127,8 @@ struct TileAndStation { StationID station; ///< StationID }; -static SmallVector _deleted_stations_nearby; -static SmallVector _stations_nearby_list; +static std::vector _deleted_stations_nearby; +static std::vector _stations_nearby_list; /** * Add station on this tile to _stations_nearby_list if it's fully within the @@ -2143,11 +2143,11 @@ static bool AddNearbyStation(TileIndex tile, void *user_data) TileArea *ctx = (TileArea *)user_data; /* First check if there were deleted stations here */ - for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) { - TileAndStation *ts = _deleted_stations_nearby.Get(i); + for (uint i = 0; i < _deleted_stations_nearby.size(); i++) { + auto ts = _deleted_stations_nearby.begin() + i; if (ts->tile == tile) { - *_stations_nearby_list.Append() = _deleted_stations_nearby[i].station; - _deleted_stations_nearby.Erase(ts); + _stations_nearby_list.push_back(_deleted_stations_nearby[i].station); + _deleted_stations_nearby.erase(ts); i--; } } @@ -2161,10 +2161,10 @@ static bool AddNearbyStation(TileIndex tile, void *user_data) if (!T::IsValidID(sid)) return false; T *st = T::Get(sid); - if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false; + if (st->owner != _local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end()) return false; if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST).Succeeded()) { - *_stations_nearby_list.Append() = sid; + _stations_nearby_list.push_back(sid); } return false; // We want to include *all* nearby stations @@ -2184,8 +2184,8 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join) { TileArea ctx = ta; - _stations_nearby_list.Clear(); - _deleted_stations_nearby.Clear(); + _stations_nearby_list.clear(); + _deleted_stations_nearby.clear(); /* Check the inside, to return, if we sit on another station */ TILE_AREA_LOOP(t, ta) { @@ -2198,9 +2198,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join) if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) { /* Include only within station spread (yes, it is strictly less than) */ if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) { - TileAndStation *ts = _deleted_stations_nearby.Append(); - ts->tile = st->xy; - ts->station = st->index; + _deleted_stations_nearby.push_back({st->xy, st->index}); /* Add the station when it's within where we're going to build */ if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) && @@ -2260,13 +2258,13 @@ struct SelectStationWindow : Window { this->OnInvalidateData(0); } - 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_JS_PANEL) return; /* Determine the widest string */ Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION); - for (uint i = 0; i < _stations_nearby_list.Length(); i++) { + for (uint i = 0; i < _stations_nearby_list.size(); i++) { const T *st = T::Get(_stations_nearby_list[i]); SetDParam(0, st->index); SetDParam(1, st->facilities); @@ -2280,7 +2278,7 @@ struct SelectStationWindow : Window { *size = d; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_JS_PANEL) return; @@ -2290,7 +2288,7 @@ struct SelectStationWindow : Window { y += this->resize.step_height; } - for (uint i = max(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += this->resize.step_height) { + for (uint i = max(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) { /* Don't draw anything if it extends past the end of the window. */ if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break; @@ -2301,7 +2299,7 @@ struct SelectStationWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget != WID_JS_PANEL) return; @@ -2309,7 +2307,7 @@ struct SelectStationWindow : Window { bool distant_join = (st_index > 0); if (distant_join) st_index--; - if (distant_join && st_index >= _stations_nearby_list.Length()) return; + if (distant_join && st_index >= _stations_nearby_list.size()) return; /* Insert station to be joined into stored command */ SB(this->select_station_cmd.p2, 16, 16, @@ -2322,7 +2320,7 @@ struct SelectStationWindow : Window { DeleteWindowById(WC_SELECT_STATION, 0); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (_thd.dirty & 2) { _thd.dirty &= ~2; @@ -2330,7 +2328,7 @@ struct SelectStationWindow : Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_JS_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } @@ -2340,11 +2338,11 @@ struct SelectStationWindow : 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; FindStationsNearby(this->area, true); - this->vscroll->SetCount(_stations_nearby_list.Length() + 1); + this->vscroll->SetCount(_stations_nearby_list.size() + 1); this->SetDirty(); } }; @@ -2389,7 +2387,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta) * If adjacent-stations is disabled and we are building next to a station, do not show the selection window. * but join the other station immediately. */ const T *st = FindStationsNearby(ta, false); - return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0); + return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.size() == 0); } /** diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 6eac3ab33d..7a760d0ffa 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -99,18 +99,18 @@ struct StatusBarWindow : Window { PositionStatusbar(this); } - 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 = { 0, _screen.height - sm_height }; return pt; } - virtual void FindWindowPlacementAndResize(int def_width, int def_height) + void FindWindowPlacementAndResize(int def_width, int def_height) override { Window::FindWindowPlacementAndResize(_toolbar_width, def_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 { Dimension d; switch (widget) { @@ -137,7 +137,7 @@ struct StatusBarWindow : Window { *size = maxdim(d, *size); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_S_LEFT: @@ -196,7 +196,7 @@ struct StatusBarWindow : 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; switch (data) { @@ -212,7 +212,7 @@ struct StatusBarWindow : 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_S_MIDDLE: ShowLastNewsMessage(); break; @@ -221,7 +221,7 @@ struct StatusBarWindow : Window { } } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (_pause_mode != PM_UNPAUSED) return; diff --git a/src/stdafx.h b/src/stdafx.h index d3aca8ec94..07cd701401 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -238,15 +238,6 @@ #endif /* defined(_MSC_VER) */ -#if defined(DOS) - /* The DOS port does not have all signals/signal functions. */ - #define strsignal(sig) "" - /* Use 'no floating point' for bus errors; SIGBUS does not exist - * for DOS, SIGNOFP for other platforms. So it's fairly safe - * to interchange those. */ - #define SIGBUS SIGNOFP -#endif - /* NOTE: the string returned by these functions is only valid until the next * call to the same function and is not thread- or reentrancy-safe */ #if !defined(STRGEN) && !defined(SETTINGSGEN) @@ -449,10 +440,7 @@ const char *assert_tile_info(uint32 tile); #define assert_tile(expression, tile) #endif -#if defined(__DJGPP__) - /* DJGPP doesn't have C++ conformant _stricmp... */ - #define _stricmp stricmp -#elif defined(OPENBSD) +#if defined(OPENBSD) /* OpenBSD uses strcasecmp(3) */ #define _stricmp strcasecmp #endif diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 003843310e..5679bbdc6b 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -52,16 +52,16 @@ protected: void BuildStoryPageList() { if (this->story_pages.NeedRebuild()) { - this->story_pages.Clear(); + this->story_pages.clear(); const StoryPage *p; FOR_ALL_STORY_PAGES(p) { if (this->IsPageAvailable(p)) { - *this->story_pages.Append() = p; + this->story_pages.push_back(p); } } - this->story_pages.Compact(); + this->story_pages.shrink_to_fit(); this->story_pages.RebuildDone(); } @@ -78,19 +78,19 @@ protected: void BuildStoryPageElementList() { if (this->story_page_elements.NeedRebuild()) { - this->story_page_elements.Clear(); + this->story_page_elements.clear(); const StoryPage *p = GetSelPage(); if (p != NULL) { const StoryPageElement *pe; FOR_ALL_STORY_PAGE_ELEMENTS(pe) { if (pe->page == p->index) { - *this->story_page_elements.Append() = pe; + this->story_page_elements.push_back(pe); } } } - this->story_page_elements.Compact(); + this->story_page_elements.shrink_to_fit(); this->story_page_elements.RebuildDone(); } @@ -130,8 +130,7 @@ protected: int GetSelPageNum() const { int page_number = 0; - for (const StoryPage *const*iter = this->story_pages.Begin(); iter != this->story_pages.End(); iter++) { - const StoryPage *p = *iter; + for (const StoryPage *p : this->story_pages) { if (p->index == this->selected_page_id) { return page_number; } @@ -148,7 +147,7 @@ protected: /* Verify that the selected page exist. */ if (!_story_page_pool.IsValidID(this->selected_page_id)) return false; - return (*this->story_pages.Begin())->index == this->selected_page_id; + return this->story_pages.front()->index == this->selected_page_id; } /** @@ -159,8 +158,8 @@ protected: /* Verify that the selected page exist. */ if (!_story_page_pool.IsValidID(this->selected_page_id)) return false; - if (this->story_pages.Length() <= 1) return true; - const StoryPage *last = *(this->story_pages.End() - 1); + if (this->story_pages.size() <= 1) return true; + const StoryPage *last = this->story_pages.back(); return last->index == this->selected_page_id; } @@ -195,8 +194,7 @@ protected: /* Find the last available page which is previous to the current selected page. */ const StoryPage *last_available; last_available = NULL; - for (const StoryPage *const*iter = this->story_pages.Begin(); iter != this->story_pages.End(); iter++) { - const StoryPage *p = *iter; + for (const StoryPage *p : this->story_pages) { if (p->index == this->selected_page_id) { if (last_available == NULL) return; // No previous page available. this->SetSelectedPage(last_available->index); @@ -214,12 +212,12 @@ protected: if (!_story_page_pool.IsValidID(this->selected_page_id)) return; /* Find selected page. */ - for (const StoryPage *const*iter = this->story_pages.Begin(); iter != this->story_pages.End(); iter++) { + for (auto iter = this->story_pages.begin(); iter != this->story_pages.end(); iter++) { const StoryPage *p = *iter; if (p->index == this->selected_page_id) { /* Select the page after selected page. */ iter++; - if (iter != this->story_pages.End()) { + if (iter != this->story_pages.end()) { this->SetSelectedPage((*iter)->index); } return; @@ -234,8 +232,7 @@ protected: { DropDownList *list = new DropDownList(); uint16 page_num = 1; - for (const StoryPage *const*iter = this->story_pages.Begin(); iter != this->story_pages.End(); iter++) { - const StoryPage *p = *iter; + for (const StoryPage *p : this->story_pages) { bool current_page = p->index == this->selected_page_id; DropDownListStringItem *item = NULL; if (p->title != NULL) { @@ -248,12 +245,12 @@ protected: item = str_item; } - *list->Append() = item; + list->push_back(item); page_num++; } /* Check if list is empty. */ - if (list->Length() == 0) { + if (list->size() == 0) { delete list; list = NULL; } @@ -353,8 +350,7 @@ protected: uint height = GetHeadHeight(max_width); /* Body */ - for (const StoryPageElement **iter = this->story_page_elements.Begin(); iter != this->story_page_elements.End(); iter++) { - const StoryPageElement *pe = *iter; + for (const StoryPageElement *pe : this->story_page_elements) { height += element_vertical_dist; height += GetPageElementHeight(*pe, max_width); } @@ -444,8 +440,8 @@ public: */ void UpdatePrevNextDisabledState() { - this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.Length() == 0 || this->IsFirstPageSelected()); - this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.Length() == 0 || this->IsLastPageSelected()); + this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.size() == 0 || this->IsFirstPageSelected()); + this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.size() == 0 || this->IsLastPageSelected()); this->SetWidgetDirty(WID_SB_PREV_PAGE); this->SetWidgetDirty(WID_SB_NEXT_PAGE); } @@ -463,7 +459,7 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_SB_SEL_PAGE: { @@ -482,7 +478,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { /* Detect if content has changed height. This can happen if a * multi-line text contains eg. {COMPANY} and that company is @@ -497,7 +493,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_SB_PAGE_PANEL) return; @@ -532,8 +528,7 @@ public: y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, STR_STORY_BOOK_TITLE, TC_BLACK, SA_TOP | SA_HOR_CENTER); /* Page elements */ - for (const StoryPageElement *const*iter = this->story_page_elements.Begin(); iter != this->story_page_elements.End(); iter++) { - const StoryPageElement *const pe = *iter; + for (const StoryPageElement *const pe : this->story_page_elements) { y_offset += line_height; // margin to previous element switch (pe->type) { @@ -563,7 +558,7 @@ public: _cur_dpi = old_dpi; } - 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_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; @@ -575,7 +570,7 @@ public: case WID_SB_SEL_PAGE: { /* Get max title width. */ - for (uint16 i = 0; i < this->story_pages.Length(); i++) { + for (uint16 i = 0; i < this->story_pages.size(); i++) { const StoryPage *s = this->story_pages[i]; if (s->title != NULL) { @@ -606,13 +601,13 @@ public: } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SB_PAGE_PANEL, WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM); this->vscroll->SetCount(this->GetContentHeight()); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_SB_SEL_PAGE: { @@ -620,7 +615,7 @@ public: if (list != NULL) { /* Get the index of selected page. */ int selected = 0; - for (uint16 i = 0; i < this->story_pages.Length(); i++) { + for (uint16 i = 0; i < this->story_pages.size(); i++) { const StoryPage *p = this->story_pages[i]; if (p->index == this->selected_page_id) break; selected++; @@ -650,8 +645,7 @@ public: /* Detect if a page element was clicked. */ uint y = head_height; uint element_vertical_dist = FONT_HEIGHT_NORMAL; - for (const StoryPageElement *const*iter = this->story_page_elements.Begin(); iter != this->story_page_elements.End(); iter++) { - const StoryPageElement *const pe = *iter; + for (const StoryPageElement *const pe : this->story_page_elements) { y += element_vertical_dist; // margin row @@ -667,7 +661,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (widget != WID_SB_SEL_PAGE) return; @@ -682,7 +676,7 @@ public: * >= 0 Id of the page that needs to be refreshed. If it is not the current page, nothing happens. * @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; @@ -694,7 +688,7 @@ public: this->BuildStoryPageList(); /* Was the last page removed? */ - if (this->story_pages.Length() == 0) { + if (this->story_pages.size() == 0) { this->selected_generic_title[0] = '\0'; } @@ -702,14 +696,14 @@ public: if (!_story_page_pool.IsValidID(this->selected_page_id)) { this->selected_page_id = INVALID_STORY_PAGE; } - if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.Length() > 0) { + if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.size() > 0) { /* No page is selected, but there exist at least one available. * => Select first page. */ this->SetSelectedPage(this->story_pages[0]->index); } - this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.Length() == 0); + this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.size() == 0); this->SetWidgetDirty(WID_SB_SEL_PAGE); this->UpdatePrevNextDisabledState(); } else if (data >= 0 && this->selected_page_id == data) { diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 11e6b8dbde..5b361430f5 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -115,14 +115,14 @@ struct FileStringReader : StringReader { fclose(this->fh); } - /* virtual */ char *ReadLine(char *buffer, const char *last) + char *ReadLine(char *buffer, const char *last) override { return fgets(buffer, ClampToU16(last - buffer + 1), this->fh); } - /* virtual */ void HandlePragma(char *str); + void HandlePragma(char *str) override; - /* virtual */ void ParseFile() + void ParseFile() override { this->StringReader::ParseFile(); diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 8d46b1b271..f0dc03aa0b 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -235,14 +235,14 @@ static ParsedCommandStruct _cur_pcs; static int _cur_argidx; /** The buffer for writing a single string. */ -struct Buffer : SmallVector { +struct Buffer : std::vector { /** * Convenience method for adding a byte. * @param value The value to add. */ void AppendByte(byte value) { - *this->Append() = value; + this->push_back(value); } /** @@ -252,19 +252,19 @@ struct Buffer : SmallVector { void AppendUtf8(uint32 value) { if (value < 0x80) { - *this->Append() = value; + this->push_back(value); } else if (value < 0x800) { - *this->Append() = 0xC0 + GB(value, 6, 5); - *this->Append() = 0x80 + GB(value, 0, 6); + this->push_back(0xC0 + GB(value, 6, 5)); + this->push_back(0x80 + GB(value, 0, 6)); } else if (value < 0x10000) { - *this->Append() = 0xE0 + GB(value, 12, 4); - *this->Append() = 0x80 + GB(value, 6, 6); - *this->Append() = 0x80 + GB(value, 0, 6); + this->push_back(0xE0 + GB(value, 12, 4)); + this->push_back(0x80 + GB(value, 6, 6)); + this->push_back(0x80 + GB(value, 0, 6)); } else if (value < 0x110000) { - *this->Append() = 0xF0 + GB(value, 18, 3); - *this->Append() = 0x80 + GB(value, 12, 6); - *this->Append() = 0x80 + GB(value, 6, 6); - *this->Append() = 0x80 + GB(value, 0, 6); + this->push_back(0xF0 + GB(value, 18, 3)); + this->push_back(0x80 + GB(value, 12, 6)); + this->push_back(0x80 + GB(value, 6, 6)); + this->push_back(0x80 + GB(value, 0, 6)); } else { strgen_warning("Invalid unicode value U+0x%X", value); } @@ -1029,14 +1029,14 @@ void LanguageWriter::WriteLang(const StringData &data) for (c = casep; c != NULL; c = c->next) { buffer.AppendByte(c->caseidx); /* Make some space for the 16-bit length */ - uint pos = buffer.Length(); + uint pos = buffer.size(); buffer.AppendByte(0); buffer.AppendByte(0); /* Write string */ PutCommandString(&buffer, c->string); buffer.AppendByte(0); // terminate with a zero /* Fill in the length */ - uint size = buffer.Length() - (pos + 2); + uint size = buffer.size() - (pos + 2); buffer[pos + 0] = GB(size, 8, 8); buffer[pos + 1] = GB(size, 0, 8); } @@ -1044,9 +1044,9 @@ void LanguageWriter::WriteLang(const StringData &data) if (cmdp != NULL) PutCommandString(&buffer, cmdp); - this->WriteLength(buffer.Length()); - this->Write(buffer.Begin(), buffer.Length()); - buffer.Clear(); + this->WriteLength(buffer.size()); + this->Write(buffer.data(), buffer.size()); + buffer.clear(); } } } diff --git a/src/string.cpp b/src/string.cpp index 34856fcdad..71cc76973a 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -710,8 +710,8 @@ class IcuStringIterator : public StringIterator icu::BreakIterator *char_itr; ///< ICU iterator for characters. icu::BreakIterator *word_itr; ///< ICU iterator for words. - SmallVector utf16_str; ///< UTF-16 copy of the string. - SmallVector utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string. + std::vector utf16_str; ///< UTF-16 copy of the string. + std::vector utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string. public: IcuStringIterator() : char_itr(NULL), word_itr(NULL) @@ -720,8 +720,8 @@ public: this->char_itr = icu::BreakIterator::createCharacterInstance(icu::Locale(_current_language != NULL ? _current_language->isocode : "en"), status); this->word_itr = icu::BreakIterator::createWordInstance(icu::Locale(_current_language != NULL ? _current_language->isocode : "en"), status); - *this->utf16_str.Append() = '\0'; - *this->utf16_to_utf8.Append() = 0; + this->utf16_str.push_back('\0'); + this->utf16_to_utf8.push_back(0); } virtual ~IcuStringIterator() @@ -738,29 +738,29 @@ public: * for word break iterators (especially for CJK languages) in combination * with UTF-8 input. As a work around we have to convert the input to * UTF-16 and create a mapping back to UTF-8 character indices. */ - this->utf16_str.Clear(); - this->utf16_to_utf8.Clear(); + this->utf16_str.clear(); + this->utf16_to_utf8.clear(); while (*s != '\0') { size_t idx = s - string_base; WChar c = Utf8Consume(&s); if (c < 0x10000) { - *this->utf16_str.Append() = (UChar)c; + this->utf16_str.push_back((UChar)c); } else { /* Make a surrogate pair. */ - *this->utf16_str.Append() = (UChar)(0xD800 + ((c - 0x10000) >> 10)); - *this->utf16_str.Append() = (UChar)(0xDC00 + ((c - 0x10000) & 0x3FF)); - *this->utf16_to_utf8.Append() = idx; + this->utf16_str.push_back((UChar)(0xD800 + ((c - 0x10000) >> 10))); + this->utf16_str.push_back((UChar)(0xDC00 + ((c - 0x10000) & 0x3FF))); + this->utf16_to_utf8.push_back(idx); } - *this->utf16_to_utf8.Append() = idx; + this->utf16_to_utf8.push_back(idx); } - *this->utf16_str.Append() = '\0'; - *this->utf16_to_utf8.Append() = s - string_base; + this->utf16_str.push_back('\0'); + this->utf16_to_utf8.push_back(s - string_base); UText text = UTEXT_INITIALIZER; UErrorCode status = U_ZERO_ERROR; - utext_openUChars(&text, this->utf16_str.Begin(), this->utf16_str.Length() - 1, &status); + utext_openUChars(&text, this->utf16_str.data(), this->utf16_str.size() - 1, &status); this->char_itr->setText(&text, status); this->word_itr->setText(&text, status); this->char_itr->first(); @@ -771,7 +771,7 @@ public: { /* Convert incoming position to an UTF-16 string index. */ uint utf16_pos = 0; - for (uint i = 0; i < this->utf16_to_utf8.Length(); i++) { + for (uint i = 0; i < this->utf16_to_utf8.size(); i++) { if (this->utf16_to_utf8[i] == pos) { utf16_pos = i; break; diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index 6045c19ef4..88eb5f28ad 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -28,7 +28,8 @@ static const WChar STATE_QUOTE2 = '"'; */ void StringFilter::SetFilterTerm(const char *str) { - this->word_index.Reset(); + this->word_index.clear(); + this->word_index.shrink_to_fit(); this->word_matches = 0; free(this->filter_buffer); @@ -75,9 +76,8 @@ void StringFilter::SetFilterTerm(const char *str) /* Add to word */ if (word == NULL) { - word = this->word_index.Append(); - word->start = dest; - word->match = false; + /*C++17: word = &*/ this->word_index.push_back({dest, false}); + word = &this->word_index.back(); } memcpy(dest, pos, len); @@ -91,9 +91,8 @@ void StringFilter::SetFilterTerm(const char *str) void StringFilter::ResetState() { this->word_matches = 0; - const WordState *end = this->word_index.End(); - for (WordState *it = this->word_index.Begin(); it != end; ++it) { - it->match = false; + for (WordState &ws : this->word_index) { + ws.match = false; } } @@ -110,11 +109,10 @@ void StringFilter::AddLine(const char *str) if (str == NULL) return; bool match_case = this->case_sensitive != NULL && *this->case_sensitive; - const WordState *end = this->word_index.End(); - for (WordState *it = this->word_index.Begin(); it != end; ++it) { - if (!it->match) { - if ((match_case ? strstr(str, it->start) : strcasestr(str, it->start)) != NULL) { - it->match = true; + for (WordState &ws : this->word_index) { + if (!ws.match) { + if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) != NULL) { + ws.match = true; this->word_matches++; } } diff --git a/src/stringfilter_type.h b/src/stringfilter_type.h index f78b133cb4..5ba8e876b6 100644 --- a/src/stringfilter_type.h +++ b/src/stringfilter_type.h @@ -39,7 +39,7 @@ private: }; const char *filter_buffer; ///< Parsed filter string. Words separated by 0. - SmallVector word_index; ///< Word index and filter state. + std::vector word_index; ///< Word index and filter state. uint word_matches; ///< Summary of filter state: Number of words matched. const bool *case_sensitive; ///< Match case-sensitively (usually a static variable). @@ -58,7 +58,7 @@ public: * Check whether any filter words were entered. * @return true if no words were entered. */ - bool IsEmpty() const { return this->word_index.Length() == 0; } + bool IsEmpty() const { return this->word_index.size() == 0; } void ResetState(); void AddLine(const char *str); @@ -68,7 +68,7 @@ public: * Get the matching state of the current item. * @return true if matched. */ - bool GetState() const { return this->word_matches == this->word_index.Length(); } + bool GetState() const { return this->word_matches == this->word_index.size(); } }; #endif /* STRINGFILTER_TYPE_H */ diff --git a/src/strings.cpp b/src/strings.cpp index d35d6bf87e..3cddcbba47 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -37,9 +37,7 @@ #include "unit_conversion.h" #include "tracerestrict.h" #include "game/game_text.hpp" -#ifdef ENABLE_NETWORK -# include "network/network_content_gui.h" -#endif /* ENABLE_NETWORK */ +#include "network/network_content_gui.h" #include #include "table/strings.h" @@ -80,7 +78,10 @@ int64 StringParameters::GetInt64(WChar type) return 0; } if (this->type != NULL) { - assert(this->type[this->offset] == 0 || this->type[this->offset] == type); + if (this->type[this->offset] != 0 && this->type[this->offset] != type) { + DEBUG(misc, 0, "Trying to read string parameter with wrong type"); + return 0; + } this->type[this->offset] = type; } return this->data[this->offset++]; @@ -122,7 +123,8 @@ void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size) */ void SetDParamMaxDigits(uint n, uint count, FontSize size) { - uint front, next; + uint front = 0; + uint next = 0; GetBroadestDigit(&front, &next, size); uint64 val = count > 1 ? front : next; for (; count > 1; count--) { @@ -1663,8 +1665,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg } } - int64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; - StringParameters tmp_params(args_array); + uint64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; + WChar types_array[] = {0, SCC_TOWN_NAME, SCC_NUM}; + StringParameters tmp_params(args_array, 3, types_array); buff = GetStringWithArgs(buff, str, &tmp_params, last); } break; @@ -1941,11 +1944,7 @@ static char *GetSpecialNameString(char *buff, int ind, StringParameters *args, c NOT_REACHED(); } -#ifdef ENABLE_NETWORK extern void SortNetworkLanguages(); -#else /* ENABLE_NETWORK */ -static inline void SortNetworkLanguages() {} -#endif /* ENABLE_NETWORK */ /** * Check whether the header is a valid header for OpenTTD. @@ -2081,9 +2080,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang) SortIndustryTypes(); BuildIndustriesLegend(); SortNetworkLanguages(); -#ifdef ENABLE_NETWORK BuildContentTypeStringList(); -#endif /* ENABLE_NETWORK */ InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Build vehicle window. InvalidateWindowClassesData(WC_TRAINS_LIST); // Train group window. InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);// Trace restrict slots window. @@ -2145,8 +2142,8 @@ int CDECL StringIDSorter(const StringID *a, const StringID *b) */ const LanguageMetadata *GetLanguage(byte newgrflangid) { - for (const LanguageMetadata *lang = _languages.Begin(); lang != _languages.End(); lang++) { - if (newgrflangid == lang->newgrflangid) return lang; + for (const LanguageMetadata &lang : _languages) { + if (newgrflangid == lang.newgrflangid) return ⟨ } return NULL; @@ -2201,7 +2198,7 @@ static void GetLanguageList(const char *path) } else if (GetLanguage(lmd.newgrflangid) != NULL) { DEBUG(misc, 3, "%s's language ID is already known", lmd.file); } else { - *_languages.Append() = lmd; + _languages.push_back(lmd); } } closedir(dir); @@ -2221,7 +2218,7 @@ void InitializeLanguagePacks() FioAppendDirectory(path, lastof(path), sp, LANG_DIR); GetLanguageList(path); } - if (_languages.Length() == 0) usererror("No available language packs (invalid versions?)"); + if (_languages.size() == 0) usererror("No available language packs (invalid versions?)"); /* Acquire the locale of the current system */ const char *lang = GetCurrentLocale("LC_MESSAGES"); @@ -2229,22 +2226,22 @@ void InitializeLanguagePacks() const LanguageMetadata *chosen_language = NULL; ///< Matching the language in the configuration file or the current locale const LanguageMetadata *language_fallback = NULL; ///< Using pt_PT for pt_BR locale when pt_BR is not available - const LanguageMetadata *en_GB_fallback = _languages.Begin(); ///< Fallback when no locale-matching language has been found + const LanguageMetadata *en_GB_fallback = _languages.data(); ///< Fallback when no locale-matching language has been found /* Find a proper language. */ - for (const LanguageMetadata *lng = _languages.Begin(); lng != _languages.End(); lng++) { + for (const LanguageMetadata &lng : _languages) { /* We are trying to find a default language. The priority is by * configuration file, local environment and last, if nothing found, * English. */ - const char *lang_file = strrchr(lng->file, PATHSEPCHAR) + 1; + const char *lang_file = strrchr(lng.file, PATHSEPCHAR) + 1; if (strcmp(lang_file, _config_language_file) == 0) { - chosen_language = lng; + chosen_language = &lng; break; } - if (strcmp (lng->isocode, "en_GB") == 0) en_GB_fallback = lng; - if (strncmp(lng->isocode, lang, 5) == 0) chosen_language = lng; - if (strncmp(lng->isocode, lang, 2) == 0) language_fallback = lng; + if (strcmp (lng.isocode, "en_GB") == 0) en_GB_fallback = &lng; + if (strncmp(lng.isocode, lang, 5) == 0) chosen_language = &lng; + if (strncmp(lng.isocode, lang, 2) == 0) language_fallback = &lng; } /* We haven't found the language in the config nor the one in the locale. @@ -2301,18 +2298,18 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { uint i; ///< Iterator for the primary language tables. uint j; ///< Iterator for the secondary language tables. - /* virtual */ void Reset() + void Reset() override { this->i = 0; this->j = 0; } - /* virtual */ FontSize DefaultSize() + FontSize DefaultSize() override { return FS_NORMAL; } - /* virtual */ const char *NextString() + const char *NextString() override { if (this->i >= TEXT_TAB_END) return NULL; @@ -2327,12 +2324,12 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { return ret; } - /* virtual */ bool Monospace() + bool Monospace() override { return false; } - /* virtual */ void SetFontNames(FreeTypeSettings *settings, const char *font_name) + void SetFontNames(FreeTypeSettings *settings, const char *font_name) override { #ifdef WITH_FREETYPE strecpy(settings->small.font, font_name, lastof(settings->small.font)); diff --git a/src/subsidy.cpp b/src/subsidy.cpp index eac81e3624..2b851048b4 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -564,7 +564,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, /* Remember all towns near this station (at least one house in its catchment radius) * which are destination of subsidised path. Do that only if needed */ - SmallVector towns_near; + std::vector towns_near; if (!st->rect.IsEmpty()) { Subsidy *s; FOR_ALL_SUBSIDIES(s) { @@ -577,7 +577,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, for (TileIndex tile = it; tile != INVALID_TILE; tile = ++it) { if (!IsTileType(tile, MP_HOUSE)) continue; const Town *t = Town::GetByTile(tile); - if (t->cache.part_of_subsidy & POS_DST) towns_near.Include(t); + if (t->cache.part_of_subsidy & POS_DST) include(towns_near, t); } break; } @@ -601,9 +601,9 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, } break; case ST_TOWN: - for (const Town * const *tp = towns_near.Begin(); tp != towns_near.End(); tp++) { - if (s->dst == (*tp)->index) { - assert((*tp)->cache.part_of_subsidy & POS_DST); + for (const Town *tp : towns_near) { + if (s->dst == tp->index) { + assert(tp->cache.part_of_subsidy & POS_DST); subsidised = true; if (!s->IsAwarded()) s->AwardTo(company); } diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 50ea39e39b..0155a74e9d 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -38,7 +38,7 @@ struct SubsidyListWindow : Window { this->OnInvalidateData(0); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget != WID_SUL_PANEL) return; @@ -129,7 +129,7 @@ struct SubsidyListWindow : Window { return 3 + num_awarded + num_not_awarded; } - 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_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); @@ -142,7 +142,7 @@ struct SubsidyListWindow : Window { *size = maxdim(*size, d); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_SUL_PANEL) return; @@ -204,7 +204,7 @@ struct SubsidyListWindow : Window { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SUL_PANEL); } @@ -214,7 +214,7 @@ struct SubsidyListWindow : 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; this->vscroll->SetCount(this->CountLines()); diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini index c16e66c074..94e22072f1 100644 --- a/src/table/gameopt_settings.ini +++ b/src/table/gameopt_settings.ini @@ -22,9 +22,7 @@ static const char *_autosave_interval = "off|monthly|quarterly|half year|yearly" static const char *_roadsides = "left|right"; static const char *_savegame_date = "long|short|iso"; static const char *_savegame_overwrite_confirm = "no|different|not same|yes"; -#ifdef ENABLE_NETWORK static const char *_server_langs = "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN"; -#endif /* ENABLE_NETWORK */ static const char *_osk_activation = "disabled|double|single|immediately"; static const char *_settings_profiles = "easy|medium|hard"; static const char *_news_display = "off|summarized|full"; diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index e737259872..07cf1748d9 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -69,15 +69,15 @@ static const NIVariable _niv_vehicles[] = { }; class NIHVehicle : public NIHelper { - bool IsInspectable(uint index) const { return true; } - bool ShowExtraInfoOnly(uint index) const { return Vehicle::Get(index)->GetGRF() == NULL; } - uint GetParent(uint index) const { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); } - const void *GetInstance(uint index)const { return Vehicle::Get(index); } - const void *GetSpec(uint index) const { return Vehicle::Get(index)->GetEngine(); } - void SetStringParameters(uint index) const { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); } - uint32 GetGRFID(uint index) const { return Vehicle::Get(index)->GetGRFID(); } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return true; } + bool ShowExtraInfoOnly(uint index) const override { return Vehicle::Get(index)->GetGRF() == NULL; } + uint GetParent(uint index) const override { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); } + const void *GetInstance(uint index)const override { return Vehicle::Get(index); } + const void *GetSpec(uint index) const override { return Vehicle::Get(index)->GetEngine(); } + void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); } + uint32 GetGRFID(uint index) const override { return Vehicle::Get(index)->GetGRFID(); } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { Vehicle *v = Vehicle::Get(index); VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_CACHED); @@ -146,14 +146,14 @@ static const NIVariable _niv_stations[] = { }; class NIHStation : public NIHelper { - bool IsInspectable(uint index) const { return GetStationSpec(index) != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); } - const void *GetInstance(uint index)const { return NULL; } - const void *GetSpec(uint index) const { return GetStationSpec(index); } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return GetStationSpec(index) != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); } + const void *GetInstance(uint index)const override { return NULL; } + const void *GetSpec(uint index) const override { return GetStationSpec(index); } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index, INVALID_RAILTYPE); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -211,14 +211,14 @@ static const NIVariable _niv_house[] = { }; class NIHHouse : public NIHelper { - bool IsInspectable(uint index) const { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); } - const void *GetInstance(uint index)const { return NULL; } - const void *GetSpec(uint index) const { return HouseSpec::Get(GetHouseType(index)); } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); } + const void *GetInstance(uint index)const override { return NULL; } + const void *GetSpec(uint index) const override { return HouseSpec::Get(GetHouseType(index)); } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -261,14 +261,14 @@ static const NIVariable _niv_industrytiles[] = { }; class NIHIndustryTile : public NIHelper { - bool IsInspectable(uint index) const { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); } - const void *GetInstance(uint index)const { return NULL; } - const void *GetSpec(uint index) const { return GetIndustryTileSpec(GetIndustryGfx(index)); } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); } + const void *GetInstance(uint index)const override { return NULL; } + const void *GetSpec(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index)); } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -360,23 +360,23 @@ static const NIVariable _niv_industries[] = { }; class NIHIndustry : public NIHelper { - bool IsInspectable(uint index) const { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); } - const void *GetInstance(uint index)const { return Industry::Get(index); } - const void *GetSpec(uint index) const { return GetIndustrySpec(Industry::Get(index)->type); } - void SetStringParameters(uint index) const { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); } + const void *GetInstance(uint index)const override { return Industry::Get(index); } + const void *GetSpec(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type); } + void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { Industry *i = Industry::Get(index); IndustriesResolverObject ro(i->location.tile, i, i->type); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); } - uint GetPSASize(uint index, uint32 grfid) const { return cpp_lengthof(PersistentStorage, storage); } + uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); } - const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const + const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override { const Industry *i = (const Industry *)this->GetInstance(index); if (i->psa == NULL) return NULL; @@ -425,14 +425,14 @@ static const NIVariable _niv_objects[] = { }; class NIHObject : public NIHelper { - bool IsInspectable(uint index) const { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); } - const void *GetInstance(uint index)const { return Object::GetByTile(index); } - const void *GetSpec(uint index) const { return ObjectSpec::GetByTile(index); } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); } + const void *GetInstance(uint index)const override { return Object::GetByTile(index); } + const void *GetSpec(uint index) const override { return ObjectSpec::GetByTile(index); } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -459,14 +459,14 @@ static const NIVariable _niv_railtypes[] = { }; class NIHRailType : public NIHelper { - bool IsInspectable(uint index) const { return true; } - uint GetParent(uint index) const { return UINT32_MAX; } - const void *GetInstance(uint index)const { return NULL; } - const void *GetSpec(uint index) const { return NULL; } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); } - uint32 GetGRFID(uint index) const { return 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return true; } + uint GetParent(uint index) const override { return UINT32_MAX; } + const void *GetInstance(uint index)const override { return NULL; } + const void *GetSpec(uint index) const override { return NULL; } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); } + uint32 GetGRFID(uint index) const override { return 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { /* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype. * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */ @@ -495,14 +495,14 @@ static const NICallback _nic_airporttiles[] = { }; class NIHAirportTile : public NIHelper { - bool IsInspectable(uint index) const { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; } - uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); } - const void *GetInstance(uint index)const { return NULL; } - const void *GetSpec(uint index) const { return AirportTileSpec::Get(GetAirportGfx(index)); } - void SetStringParameters(uint index) const { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } - uint32 GetGRFID(uint index) const { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; } + uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); } + const void *GetInstance(uint index)const override { return NULL; } + const void *GetSpec(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index)); } + void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } + uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -533,22 +533,22 @@ static const NIVariable _niv_towns[] = { }; class NIHTown : public NIHelper { - bool IsInspectable(uint index) const { return Town::IsValidID(index); } - uint GetParent(uint index) const { return UINT32_MAX; } - const void *GetInstance(uint index)const { return Town::Get(index); } - const void *GetSpec(uint index) const { return NULL; } - void SetStringParameters(uint index) const { this->SetSimpleStringParameters(STR_TOWN_NAME, index); } - uint32 GetGRFID(uint index) const { return 0; } - bool PSAWithParameter() const { return true; } - uint GetPSASize(uint index, uint32 grfid) const { return cpp_lengthof(PersistentStorage, storage); } - - /* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const + bool IsInspectable(uint index) const override { return Town::IsValidID(index); } + uint GetParent(uint index) const override { return UINT32_MAX; } + const void *GetInstance(uint index)const override { return Town::Get(index); } + const void *GetSpec(uint index) const override { return NULL; } + void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_TOWN_NAME, index); } + uint32 GetGRFID(uint index) const override { return 0; } + bool PSAWithParameter() const override { return true; } + uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); } + + uint Resolve(uint index, uint var, uint param, bool *avail) const override { TownResolverObject ro(NULL, Town::Get(index), true); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); } - const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const + const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override { Town *t = Town::Get(index); diff --git a/src/table/settings.ini b/src/table/settings.ini index e51c6496d2..dbb99cb490 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -50,7 +50,6 @@ static bool DayLengthChanged(int32 p1); static bool SimulatedWormholeSignalsChanged(int32 p1); static bool EnableSingleVehSharedOrderGuiChanged(int32 p1); -#ifdef ENABLE_NETWORK static bool UpdateClientName(int32 p1); static bool UpdateServerPassword(int32 p1); static bool UpdateRconPassword(int32 p1); @@ -59,7 +58,6 @@ static bool CheckSharingRail(int32 p1); static bool CheckSharingRoad(int32 p1); static bool CheckSharingWater(int32 p1); static bool CheckSharingAir(int32 p1); -#endif /* ENABLE_NETWORK */ /* End - Callback Functions for the various settings */ /* Begin - GUI order callbacks */ @@ -1132,12 +1130,12 @@ type = SLE_UINT8 from = SLV_87 guiflags = SGF_MULTISTRING def = 2 -min = 0 +min = 1 max = 2 interval = 1 str = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS strhelp = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_HELPTEXT -strval = STR_CONFIG_SETTING_PATHFINDER_OPF +strval = STR_CONFIG_SETTING_PATHFINDER_NPF proc = InvalidateShipPathCache cat = SC_EXPERT @@ -2277,23 +2275,10 @@ max = 255 cat = SC_EXPERT ## -[SDT_VAR] -base = GameSettings -var = pf.opf.pf_maxlength -type = SLE_UINT16 -def = 4096 -min = 64 -max = 65535 -cat = SC_EXPERT - -[SDT_VAR] -base = GameSettings -var = pf.opf.pf_maxdepth -type = SLE_UINT8 -def = 48 -min = 4 -max = 255 -cat = SC_EXPERT +; Used to be pf.opf.pf_maxlength & pf.opf.pf_maxdepth +[SDT_NULL] +length = 3 +to = SLV_REMOVE_OPF ## [SDT_VAR] @@ -4719,7 +4704,6 @@ strhelp = STR_CONFIG_SETTING_NEWS_GENERAL_INFORMATION_HELPTEXT strval = STR_CONFIG_SETTING_NEWS_MESSAGES_OFF [SDTC_VAR] -ifdef = ENABLE_NETWORK var = gui.network_chat_box_width_pct type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4729,7 +4713,6 @@ max = 100 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = gui.network_chat_box_height type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4739,7 +4722,6 @@ max = 255 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = gui.network_chat_timeout type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4749,7 +4731,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.sync_freq type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NOT_IN_CONFIG | SLF_NO_NETWORK_SYNC @@ -4760,7 +4741,6 @@ max = 100 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.frame_freq type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NOT_IN_CONFIG | SLF_NO_NETWORK_SYNC @@ -4771,7 +4751,6 @@ max = 100 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.commands_per_frame type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4782,7 +4761,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_commands_in_queue type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4793,7 +4771,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.bytes_per_frame type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4804,7 +4781,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.bytes_per_frame_burst type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4815,7 +4791,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_init_time type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4826,7 +4801,6 @@ max = 32000 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_join_time type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4836,7 +4810,6 @@ min = 0 max = 32000 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_download_time type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4846,7 +4819,6 @@ min = 0 max = 32000 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_password_time type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4856,7 +4828,6 @@ min = 0 max = 32000 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_lag_time type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4866,14 +4837,12 @@ min = 0 max = 32000 [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.pause_on_join flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC guiflags = SGF_NETWORK_ONLY def = true [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.server_port type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4884,7 +4853,6 @@ max = 65535 cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.server_admin_port type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4895,7 +4863,6 @@ max = 65535 cat = SC_EXPERT [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.server_admin_chat flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC guiflags = SGF_NETWORK_ONLY @@ -4903,14 +4870,12 @@ def = true cat = SC_EXPERT [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.server_advertise flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC guiflags = SGF_NETWORK_ONLY def = false [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.lan_internet type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4920,7 +4885,6 @@ min = 0 max = 1 [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.client_name type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4929,7 +4893,6 @@ proc = UpdateClientName cat = SC_BASIC [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.server_password type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4939,7 +4902,6 @@ proc = UpdateServerPassword cat = SC_BASIC [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.rcon_password type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4949,7 +4911,6 @@ proc = UpdateRconPassword cat = SC_BASIC [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.admin_password type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4958,14 +4919,12 @@ def = NULL cat = SC_BASIC [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.default_company_pass type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = NULL [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.server_name type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4974,14 +4933,12 @@ def = NULL cat = SC_BASIC [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.connect_to_ip type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = NULL [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.network_id type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -4989,14 +4946,12 @@ guiflags = SGF_NETWORK_ONLY def = NULL [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.autoclean_companies flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC guiflags = SGF_NETWORK_ONLY def = false [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.autoclean_unprotected type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5006,7 +4961,6 @@ min = 0 max = 240 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.autoclean_protected type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5016,7 +4970,6 @@ min = 0 max = 240 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.autoclean_novehicles type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5026,7 +4979,6 @@ min = 0 max = 240 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_companies type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5038,7 +4990,6 @@ proc = UpdateClientConfigValues cat = SC_BASIC [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_clients type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5049,7 +5000,6 @@ max = MAX_CLIENTS cat = SC_BASIC [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.max_spectators type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5061,7 +5011,6 @@ proc = UpdateClientConfigValues cat = SC_BASIC [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.restart_game_year type = SLE_INT32 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5072,7 +5021,6 @@ max = MAX_YEAR interval = 1 [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.min_active_clients type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5082,7 +5030,6 @@ min = 0 max = MAX_CLIENTS [SDTC_OMANY] -ifdef = ENABLE_NETWORK var = network.server_lang type = SLE_UINT8 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5093,7 +5040,6 @@ full = _server_langs cat = SC_BASIC [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.reload_cfg flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC guiflags = SGF_NETWORK_ONLY @@ -5101,7 +5047,6 @@ def = false cat = SC_EXPERT [SDTC_STR] -ifdef = ENABLE_NETWORK var = network.last_host type = SLE_STRB flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5109,7 +5054,6 @@ def = """" cat = SC_EXPERT [SDTC_VAR] -ifdef = ENABLE_NETWORK var = network.last_port type = SLE_UINT16 flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC @@ -5119,7 +5063,6 @@ max = UINT16_MAX cat = SC_EXPERT [SDTC_BOOL] -ifdef = ENABLE_NETWORK var = network.no_http_content_downloads flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index 77de26a9dd..2f57f7497a 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -194,7 +194,7 @@ private: GUIGroupList groups; ///< List of groups uint unitnumber_digits; - SmallVector indents; ///< Indentation levels + std::vector indents; ///< Indentation levels short matrixContentLeftMargin; int bottom_matrix_item_size = 0; @@ -323,7 +323,7 @@ public: /* Show the selected railtype in the pulldown menu */ this->GetWidget(TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN)->widget_data = (this->sel_railtype == INVALID_RAILTYPE) ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(this->sel_railtype)->strings.replace_text; - if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.Length())) { + if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.size())) { this->vscroll[2]->SetCount(24); } else { const TemplateVehicle *tmp = this->templates[this->selected_template_index]; @@ -360,7 +360,7 @@ public: switch (widget) { case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REUSE: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size())) { uint32 template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_REUSE_DEPOT_VEHICLES, NULL); @@ -368,7 +368,7 @@ public: break; } case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_KEEP: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size())) { uint32 template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_KEEP_REMAINING_VEHICLES, NULL); @@ -376,7 +376,7 @@ public: break; } case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REFIT: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size())) { uint32 template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_REFIT_AS_TEMPLATE, NULL); @@ -384,7 +384,7 @@ public: break; } case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_OLD_ONLY: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size())) { uint32 template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_TMPL_REPLACE_OLD_ONLY, NULL); @@ -398,7 +398,7 @@ public: break; } case TRW_WIDGET_TMPL_BUTTONS_EDIT: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size())) { editInProgress = true; TemplateVehicle *sel = TemplateVehicle::Get(((this->templates)[selected_template_index])->index); ShowTemplateCreateWindow(sel, &editInProgress); @@ -419,7 +419,7 @@ public: break; } case TRW_WIDGET_TMPL_BUTTONS_DELETE: - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length()) && !editInProgress) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size()) && !editInProgress) { uint32 template_index = ((this->templates)[selected_template_index])->index; @@ -436,9 +436,9 @@ public: break; case TRW_WIDGET_TOP_MATRIX: { uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_TOP_MATRIX]->pos_y) / (WD_MATRIX_TOP + FONT_HEIGHT_NORMAL+ WD_MATRIX_BOTTOM) ) + this->vscroll[0]->GetPosition(); - if (newindex == this->selected_group_index || newindex >= this->groups.Length()) { + if (newindex == this->selected_group_index || newindex >= this->groups.size()) { this->selected_group_index = -1; - } else if (newindex < this->groups.Length()) { + } else if (newindex < this->groups.size()) { this->selected_group_index = newindex; } this->UpdateButtonState(); @@ -446,17 +446,17 @@ public: } case TRW_WIDGET_BOTTOM_MATRIX: { uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_BOTTOM_MATRIX]->pos_y) / this->bottom_matrix_item_size) + this->vscroll[1]->GetPosition(); - if (newindex == this->selected_template_index || newindex >= templates.Length()) { + if (newindex == this->selected_template_index || newindex >= templates.size()) { this->selected_template_index = -1; - } else if (newindex < templates.Length()) { + } else if (newindex < templates.size()) { this->selected_template_index = newindex; } this->UpdateButtonState(); break; } case TRW_WIDGET_START: { - if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length()) && - (this->selected_group_index >= 0) && (this->selected_group_index < (short)this->groups.Length())) { + if ((this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size()) && + (this->selected_group_index >= 0) && (this->selected_group_index < (short)this->groups.size())) { uint32 tv_index = ((this->templates)[selected_template_index])->index; int current_group_index = (this->groups)[this->selected_group_index]->index; @@ -466,7 +466,7 @@ public: break; } case TRW_WIDGET_STOP: - if ((this->selected_group_index < 0) || (this->selected_group_index >= (short)this->groups.Length())) { + if ((this->selected_group_index < 0) || (this->selected_group_index >= (short)this->groups.size())) { return; } @@ -540,7 +540,7 @@ public: TemplateReplacement *tr = GetTemplateReplacementByGroupID(gid); if (!tr) return -1; - for (uint32 i = 0; i < this->templates.Length(); ++i) { + for (uint32 i = 0; i < this->templates.size(); ++i) { if (templates[i]->index == tr->sel_template) { return i; } @@ -550,11 +550,11 @@ public: void AddParents(GUIGroupList *source, GroupID parent, int indent) { - for (const Group **g = source->Begin(); g != source->End(); g++) { - if ((*g)->parent == parent) { - *this->groups.Append() = *g; - *this->indents.Append() = indent; - AddParents(source, (*g)->index, indent + 1); + for (const Group *g : *source) { + if (g->parent == parent) { + this->groups.push_back(g); + this->indents.push_back(indent); + AddParents(source, g->index, indent + 1); } } } @@ -586,15 +586,15 @@ public: { if (!this->groups.NeedRebuild()) return; - this->groups.Clear(); - this->indents.Clear(); + this->groups.clear(); + this->indents.clear(); GUIGroupList list; const Group *g; FOR_ALL_GROUPS(g) { if (g->owner == owner && g->vehicle_type == VEH_TRAIN) { - *list.Append() = g; + list.push_back(g); } } @@ -603,9 +603,9 @@ public: AddParents(&list, INVALID_GROUP, 0); - this->groups.Compact(); + this->groups.shrink_to_fit(); this->groups.RebuildDone(); - this->vscroll[0]->SetCount(groups.Length()); + this->vscroll[0]->SetCount(groups.size()); } void DrawAllGroupsFunction(const Rect &r) const @@ -613,7 +613,7 @@ public: int left = r.left + WD_MATRIX_LEFT; int right = r.right - WD_MATRIX_RIGHT; int y = r.top; - int max = min(this->vscroll[0]->GetPosition() + this->vscroll[0]->GetCapacity(), this->groups.Length()); + int max = min(this->vscroll[0]->GetPosition() + this->vscroll[0]->GetCapacity(), this->groups.size()); /* Then treat all groups defined by/for the current company */ for (int i = this->vscroll[0]->GetPosition(); i < max; ++i) { @@ -663,7 +663,7 @@ public: int y = r.top; Scrollbar *draw_vscroll = vscroll[1]; - uint max = min(draw_vscroll->GetPosition() + draw_vscroll->GetCapacity(), this->templates.Length()); + uint max = min(draw_vscroll->GetPosition() + draw_vscroll->GetCapacity(), this->templates.size()); const TemplateVehicle *v; for (uint i = draw_vscroll->GetPosition(); i < max; ++i) { @@ -724,7 +724,7 @@ public: void DrawTemplateInfo(const Rect &r) const { - if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.Length())) { + if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.size())) { return; } @@ -777,8 +777,8 @@ public: void UpdateButtonState() { - bool selected_ok = (this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length()); - bool group_ok = (this->selected_group_index >= 0) && (this->selected_group_index < (short)this->groups.Length()); + bool selected_ok = (this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.size()); + bool group_ok = (this->selected_group_index >= 0) && (this->selected_group_index < (short)this->groups.size()); short g_id = -1; if (group_ok) { diff --git a/src/tbtr_template_vehicle_func.cpp b/src/tbtr_template_vehicle_func.cpp index d936dc2cef..f811f5a64c 100644 --- a/src/tbtr_template_vehicle_func.cpp +++ b/src/tbtr_template_vehicle_func.cpp @@ -91,17 +91,17 @@ void tbtr_debug_pvt (const Train *printme) void BuildTemplateGuiList(GUITemplateList *list, Scrollbar *vscroll, Owner oid, RailType railtype) { - list->Clear(); + list->clear(); const TemplateVehicle *tv; FOR_ALL_TEMPLATES(tv) { if (tv->owner == oid && (tv->IsPrimaryVehicle() || tv->IsFreeWagonChain()) && TemplateVehicleContainsEngineOfRailtype(tv, railtype)) { - *list->Append() = tv; + list->push_back(tv); } } list->RebuildDone(); - if (vscroll) vscroll->SetCount(list->Length()); + if (vscroll) vscroll->SetCount(list->size()); } Money CalculateOverallTemplateCost(const TemplateVehicle *tv) diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index c1ffd8c81d..b8492bbf90 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -174,7 +174,7 @@ struct TerraformToolbarWindow : Window { { } - virtual void OnInit() + void OnInit() override { /* Don't show the place object button when there are no objects to place. */ NWidgetStacked *show_object = this->GetWidget(WID_TT_SHOW_PLACE_OBJECT); @@ -182,7 +182,7 @@ struct TerraformToolbarWindow : Window { SetWidgetDisabledState(WID_TT_BUY_LAND, _settings_game.construction.purchase_land_permitted == 0); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget < WID_TT_BUTTONS_START) return; @@ -234,7 +234,7 @@ struct TerraformToolbarWindow : Window { } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (this->last_user_action) { case WID_TT_LOWER_LAND: // Lower land button @@ -281,19 +281,19 @@ struct TerraformToolbarWindow : 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 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 = GetToolbarAlignedWindowPosition(sm_width); pt.y += sm_height; return pt; } - 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) { @@ -312,7 +312,7 @@ struct TerraformToolbarWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); } @@ -579,7 +579,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { this->last_user_action = WIDGET_LIST_END; } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -588,7 +588,7 @@ struct ScenarioEditorLandscapeGenerationWindow : 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_ETT_DOTS) return; @@ -596,7 +596,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { size->height = max(size->height, ScaleGUITrad(31)); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_ETT_DOTS) return; @@ -613,7 +613,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } while (--n); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget < WID_ETT_BUTTONS_START) return; @@ -683,7 +683,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } } - virtual void OnTimeout() + void OnTimeout() override { for (uint i = WID_ETT_START; i < this->nested_array_size; i++) { if (i == WID_ETT_BUTTONS_START) i = WID_ETT_BUTTONS_END; // skip the buttons @@ -694,7 +694,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (this->last_user_action) { case WID_ETT_DEMOLISH: // Demolish aka dynamite button @@ -725,12 +725,12 @@ struct ScenarioEditorLandscapeGenerationWindow : 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) { @@ -748,7 +748,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); this->SetDirty(); diff --git a/src/texteff.cpp b/src/texteff.cpp index ee5ce592b4..5e8c749858 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -37,7 +37,7 @@ struct TextEffect : public ViewportSign { } }; -static SmallVector _text_effects; ///< Text effects are stored there +static std::vector _text_effects; ///< Text effects are stored there /* Text Effects */ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode) @@ -45,23 +45,23 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text if (_game_mode == GM_MENU) return INVALID_TE_ID; TextEffectID i; - for (i = 0; i < _text_effects.Length(); i++) { + for (i = 0; i < _text_effects.size(); i++) { if (_text_effects[i].string_id == INVALID_STRING_ID) break; } - if (i == _text_effects.Length()) _text_effects.Append(); + if (i == _text_effects.size()) _text_effects.emplace_back(); - TextEffect *te = _text_effects.Get(i); + TextEffect &te = _text_effects[i]; /* Start defining this object */ - te->string_id = msg; - te->duration = duration; - te->params_1 = GetDParam(0); - te->params_2 = GetDParam(1); - te->mode = mode; + te.string_id = msg; + te.duration = duration; + te.params_1 = GetDParam(0); + te.params_2 = GetDParam(1); + te.mode = mode; /* Make sure we only dirty the new area */ - te->width_normal = 0; - te->UpdatePosition(center, y, msg); + te.width_normal = 0; + te.UpdatePosition(center, y, msg); return i; } @@ -69,7 +69,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text void UpdateTextEffect(TextEffectID te_id, StringID msg) { /* Update details */ - TextEffect *te = _text_effects.Get(te_id); + TextEffect *te = _text_effects.data() + te_id; if (msg == te->string_id && GetDParam(0) == te->params_1) return; te->string_id = msg; te->params_1 = GetDParam(0); @@ -89,26 +89,26 @@ void MoveAllTextEffects(uint delta_ms) uint count = texteffecttimer.CountElapsed(delta_ms); if (count == 0) return; - const TextEffect *end = _text_effects.End(); - for (TextEffect *te = _text_effects.Begin(); te != end; te++) { - if (te->string_id == INVALID_STRING_ID) continue; - if (te->mode != TE_RISING) continue; + for (TextEffect &te : _text_effects) { + if (te.string_id == INVALID_STRING_ID) continue; + if (te.mode != TE_RISING) continue; - if (te->duration < count) { - te->Reset(); + if (te.duration < count) { + te.Reset(); continue; } - te->MarkDirty(ZOOM_LVL_OUT_8X); - te->duration -= count; - te->top -= count * ZOOM_LVL_BASE; - te->MarkDirty(ZOOM_LVL_OUT_8X); + te.MarkDirty(ZOOM_LVL_OUT_8X); + te.duration -= count; + te.top -= count * ZOOM_LVL_BASE; + te.MarkDirty(ZOOM_LVL_OUT_8X); } } void InitTextEffects() { - _text_effects.Reset(); + _text_effects.clear(); + _text_effects.shrink_to_fit(); } void DrawTextEffects(DrawPixelInfo *dpi) @@ -116,11 +116,10 @@ void DrawTextEffects(DrawPixelInfo *dpi) /* Don't draw the text effects when zoomed out a lot */ if (dpi->zoom > ZOOM_LVL_OUT_8X) return; - const TextEffect *end = _text_effects.End(); - for (TextEffect *te = _text_effects.Begin(); te != end; te++) { - if (te->string_id == INVALID_STRING_ID) continue; - if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) { - ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, STR_NULL, te->params_1, te->params_2); + for (TextEffect &te : _text_effects) { + if (te.string_id == INVALID_STRING_ID) continue; + if (te.mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) { + ViewportAddString(dpi, ZOOM_LVL_OUT_8X, &te, te.string_id, te.string_id - 1, STR_NULL, te.params_1, te.params_2); } } } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 3480a2aef2..b4911a9682 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -86,7 +86,7 @@ uint TextfileWindow::GetContentHeight() int max_width = this->GetWidget(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT; uint height = 0; - for (uint i = 0; i < this->lines.Length(); i++) { + for (uint i = 0; i < this->lines.size(); i++) { height += GetStringHeight(this->lines[i], max_width, FS_MONO); } @@ -113,10 +113,10 @@ void TextfileWindow::SetupScrollbars() this->hscroll->SetCount(0); } else { uint max_length = 0; - for (uint i = 0; i < this->lines.Length(); i++) { + for (uint i = 0; i < this->lines.size(); i++) { max_length = max(max_length, GetStringBoundingBox(this->lines[i], FS_MONO).width); } - this->vscroll->SetCount(this->lines.Length() * FONT_HEIGHT_MONO); + this->vscroll->SetCount(this->lines.size() * FONT_HEIGHT_MONO); this->hscroll->SetCount(max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT); } @@ -152,7 +152,7 @@ void TextfileWindow::SetupScrollbars() int line_height = FONT_HEIGHT_MONO; int y_offset = -this->vscroll->GetPosition(); - for (uint i = 0; i < this->lines.Length(); i++) { + for (uint i = 0; i < this->lines.size(); i++) { if (IsWidgetLowered(WID_TF_WRAPTEXT)) { y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO); } else { @@ -184,7 +184,7 @@ void TextfileWindow::SetupScrollbars() /* virtual */ const char *TextfileWindow::NextString() { - if (this->search_iterator >= this->lines.Length()) return NULL; + if (this->search_iterator >= this->lines.size()) return NULL; return this->lines[this->search_iterator++]; } @@ -319,7 +319,7 @@ static void Xunzip(byte **bufp, size_t *sizep) { if (textfile == NULL) return; - this->lines.Clear(); + this->lines.clear(); /* Get text from file */ size_t filesize; @@ -365,11 +365,11 @@ static void Xunzip(byte **bufp, size_t *sizep) str_validate(p, this->text + filesize, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE); /* Split the string on newlines. */ - *this->lines.Append() = p; + this->lines.push_back(p); for (; *p != '\0'; p++) { if (*p == '\n') { *p = '\0'; - *this->lines.Append() = p + 1; + this->lines.push_back(p + 1); } } diff --git a/src/textfile_gui.h b/src/textfile_gui.h index 9495fa3f08..b572fe09ca 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -21,28 +21,32 @@ const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filenam /** Window for displaying a textfile */ struct TextfileWindow : public Window, MissingGlyphSearcher { - TextfileType file_type; ///< Type of textfile to view. - Scrollbar *vscroll; ///< Vertical scrollbar. - Scrollbar *hscroll; ///< Horizontal scrollbar. - char *text; ///< Lines of text from the NewGRF's textfile. - SmallVector lines; ///< #text, split into lines in a table with lines. - uint search_iterator; ///< Iterator for the font check search. + TextfileType file_type; ///< Type of textfile to view. + Scrollbar *vscroll; ///< Vertical scrollbar. + Scrollbar *hscroll; ///< Horizontal scrollbar. + char *text; ///< Lines of text from the NewGRF's textfile. + std::vector lines; ///< #text, split into lines in a table with lines. + uint search_iterator; ///< Iterator for the font check search. static const int TOP_SPACING = WD_FRAMETEXT_TOP; ///< Additional spacing at the top of the #WID_TF_BACKGROUND widget. static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM; ///< Additional spacing at the bottom of the #WID_TF_BACKGROUND widget. TextfileWindow(TextfileType file_type); - virtual ~TextfileWindow(); - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize); - virtual void OnClick(Point pt, int widget, int click_count); - virtual void DrawWidget(const Rect &r, int widget) const; - virtual void OnResize(); - virtual void Reset(); - virtual FontSize DefaultSize(); - virtual const char *NextString(); - virtual bool Monospace(); - virtual void SetFontNames(FreeTypeSettings *settings, const char *font_name); + ~TextfileWindow(); + + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override; + void OnClick(Point pt, int widget, int click_count) override; + void DrawWidget(const Rect &r, int widget) const override; + void OnResize() override; + + void Reset() override; + FontSize DefaultSize() override; + const char *NextString() override; + bool Monospace() override; + void SetFontNames(FreeTypeSettings *settings, const char *font_name) override; + virtual void LoadTextfile(const char *textfile, Subdirectory dir); + private: uint GetContentHeight(); void SetupScrollbars(); diff --git a/src/thread/thread_os2.cpp b/src/thread/thread_os2.cpp index 41ae19ab38..d2251a9462 100644 --- a/src/thread/thread_os2.cpp +++ b/src/thread/thread_os2.cpp @@ -41,13 +41,13 @@ public: thread = _beginthread(stThreadProc, NULL, 1048576, this); } - /* virtual */ bool Exit() + bool Exit() override { _endthread(); return true; } - /* virtual */ void Join() + void Join() override { DosWaitThread(&this->thread, DCWW_WAIT); this->thread = 0; @@ -106,13 +106,13 @@ public: DosCreateEventSem(NULL, &event, 0, FALSE); } - /* virtual */ ~ThreadMutex_OS2() + ~ThreadMutex_OS2() override { DosCloseMutexSem(mutex); DosCloseEventSem(event); } - /* virtual */ void BeginCritical(bool allow_recursive = false) + void BeginCritical(bool allow_recursive = false) override { /* os2 mutex is recursive by itself */ DosRequestMutexSem(mutex, (unsigned long) SEM_INDEFINITE_WAIT); @@ -120,14 +120,14 @@ public: if (!allow_recursive && this->recursive_count != 1) NOT_REACHED(); } - /* virtual */ void EndCritical(bool allow_recursive = false) + void EndCritical(bool allow_recursive = false) override { if (!allow_recursive && this->recursive_count != 1) NOT_REACHED(); this->recursive_count--; DosReleaseMutexSem(mutex); } - /* virtual */ void WaitForSignal() + void WaitForSignal() override { assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise? this->EndCritical(); @@ -135,7 +135,7 @@ public: this->BeginCritical(); } - /* virtual */ void SendSignal() + void SendSignal() override { DosPostEventSem(event); } diff --git a/src/thread/thread_pthread.cpp b/src/thread/thread_pthread.cpp index a6aeb521f4..44d3242d25 100644 --- a/src/thread/thread_pthread.cpp +++ b/src/thread/thread_pthread.cpp @@ -46,14 +46,14 @@ public: pthread_create(&this->thread, NULL, &stThreadProc, this); } - /* virtual */ bool Exit() + bool Exit() override { assert(pthread_self() == this->thread); /* For now we terminate by throwing an error, gives much cleaner cleanup */ throw OTTDThreadExitSignal(); } - /* virtual */ void Join() + void Join() override { /* You cannot join yourself */ assert(pthread_self() != this->thread); @@ -130,7 +130,7 @@ public: pthread_cond_init(&this->condition, NULL); } - /* virtual */ ~ThreadMutex_pthread() + ~ThreadMutex_pthread() override { int err = pthread_cond_destroy(&this->condition); assert(err != EBUSY); @@ -143,7 +143,7 @@ public: return this->owner == pthread_self(); } - /* virtual */ void BeginCritical(bool allow_recursive = false) + void BeginCritical(bool allow_recursive = false) override { /* pthread mutex is not recursive by itself */ if (this->IsOwnedByCurrentThread()) { @@ -157,7 +157,7 @@ public: this->recursive_count++; } - /* virtual */ void EndCritical(bool allow_recursive = false) + void EndCritical(bool allow_recursive = false) override { assert(this->IsOwnedByCurrentThread()); if (!allow_recursive && this->recursive_count != 1) NOT_REACHED(); @@ -168,7 +168,7 @@ public: assert(err == 0); } - /* virtual */ void WaitForSignal() + void WaitForSignal() override { uint old_recursive_count = this->recursive_count; this->recursive_count = 0; @@ -179,7 +179,7 @@ public: this->recursive_count = old_recursive_count; } - /* virtual */ void SendSignal() + void SendSignal() override { int err = pthread_cond_signal(&this->condition); assert(err == 0); diff --git a/src/thread/thread_win32.cpp b/src/thread/thread_win32.cpp index c7831040b0..7f91cba6cd 100644 --- a/src/thread/thread_win32.cpp +++ b/src/thread/thread_win32.cpp @@ -56,7 +56,7 @@ public: ResumeThread(this->thread); } - /* virtual */ ~ThreadObject_Win32() + ~ThreadObject_Win32() override { if (this->thread != NULL) { CloseHandle(this->thread); @@ -64,14 +64,14 @@ public: } } - /* virtual */ bool Exit() + bool Exit() override { assert(GetCurrentThreadId() == this->id); /* For now we terminate by throwing an error, gives much cleaner cleanup */ throw OTTDThreadExitSignal(); } - /* virtual */ void Join() + void Join() override { /* You cannot join yourself */ assert(GetCurrentThreadId() != this->id); @@ -133,13 +133,13 @@ public: this->event = CreateEvent(NULL, FALSE, FALSE, NULL); } - /* virtual */ ~ThreadMutex_Win32() + ~ThreadMutex_Win32() override { DeleteCriticalSection(&this->critical_section); CloseHandle(this->event); } - /* virtual */ void BeginCritical(bool allow_recursive = false) + void BeginCritical(bool allow_recursive = false) override { /* windows mutex is recursive by itself */ EnterCriticalSection(&this->critical_section); @@ -147,14 +147,14 @@ public: if (!allow_recursive && this->recursive_count != 1) NOT_REACHED(); } - /* virtual */ void EndCritical(bool allow_recursive = false) + void EndCritical(bool allow_recursive = false) override { if (!allow_recursive && this->recursive_count != 1) NOT_REACHED(); this->recursive_count--; LeaveCriticalSection(&this->critical_section); } - /* virtual */ void WaitForSignal() + void WaitForSignal() override { assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise? this->EndCritical(); @@ -162,7 +162,7 @@ public: this->BeginCritical(); } - /* virtual */ void SendSignal() + void SendSignal() override { SetEvent(this->event); } diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index a52c7688d7..25bb510f72 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -407,28 +407,26 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, DateTicksScaled start_date_scaled = (_settings_game.economy.day_length_factor * (((DateTicksScaled)_date * DAY_TICKS) + _date_fract + (DateTicksScaled)(int32)p2)) + sub_ticks; if (flags & DC_EXEC) { - SmallVector vehs; + std::vector vehs; if (timetable_all) { for (Vehicle *w = v->orders.list->GetFirstSharedVehicle(); w != NULL; w = w->NextShared()) { - *vehs.Append() = w; + vehs.push_back(w); } } else { - *vehs.Append() = v; + vehs.push_back(v); } int total_duration = v->orders.list->GetTimetableTotalDuration(); - int num_vehs = vehs.Length(); + int num_vehs = vehs.size(); if (num_vehs >= 2) { - QSortT(vehs.Begin(), vehs.Length(), &VehicleTimetableSorter); + QSortT(vehs.data(), vehs.size(), &VehicleTimetableSorter); } - int base = vehs.FindIndex(v); + int idx = vehs.begin() - std::find(vehs.begin(), vehs.end(), v); - for (Vehicle **viter = vehs.Begin(); viter != vehs.End(); viter++) { - int idx = (viter - vehs.Begin()) - base; - Vehicle *w = *viter; + for (Vehicle *w : vehs) { w->lateness_counter = 0; ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED); @@ -440,6 +438,7 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, w->timetable_start = tt_start / _settings_game.economy.day_length_factor; w->timetable_start_subticks = tt_start % _settings_game.economy.day_length_factor; SetWindowDirty(WC_VEHICLE_TIMETABLE, w->index); + ++idx; } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 9de31f19da..81aa91a248 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -230,7 +230,7 @@ struct TimetableWindow : Window { return (travelling && v->lateness_counter < 0); } - 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_VT_ARRIVAL_DEPARTURE_PANEL: @@ -272,7 +272,7 @@ struct TimetableWindow : 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 { switch (data) { case VIWD_AUTOREPLACE: @@ -348,7 +348,7 @@ struct TimetableWindow : Window { return ES_NOT_HANDLED; } - virtual void OnPaint() + void OnPaint() override { const Vehicle *v = this->vehicle; int selected = this->sel_index; @@ -429,7 +429,7 @@ struct TimetableWindow : Window { this->DrawWidgets(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_VT_CAPTION: SetDParam(0, this->vehicle->index); break; @@ -437,7 +437,7 @@ struct TimetableWindow : Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { const Vehicle *v = this->vehicle; int selected = this->sel_index; @@ -704,7 +704,7 @@ struct TimetableWindow : Window { return v->index | (order_number << 20) | (mtf << 28) | (clear ? 1 << 31 : 0); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { const Vehicle *v = this->vehicle; @@ -877,8 +877,8 @@ struct TimetableWindow : Window { ((!(order->IsType(OT_GOTO_STATION) || (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_HALT))) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL)); DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_TIMETABLE_LEAVE_NORMAL, OLT_NORMAL, leave_type_disabled); - *list->Append() = new DropDownListStringItem(STR_TIMETABLE_LEAVE_EARLY, OLT_LEAVE_EARLY, leave_type_disabled); + list->push_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_NORMAL, OLT_NORMAL, leave_type_disabled)); + list->push_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_EARLY, OLT_LEAVE_EARLY, leave_type_disabled)); ShowDropDownList(this, list, order != NULL ? order->GetLeaveType() : -1, WID_VT_EXTRA); break; } @@ -887,7 +887,7 @@ struct TimetableWindow : Window { this->SetDirty(); } - virtual void OnDropdownSelect(int widget, int index) OVERRIDE + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_VT_EXTRA: { @@ -903,7 +903,7 @@ struct TimetableWindow : Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; @@ -954,7 +954,7 @@ struct TimetableWindow : Window { } } - virtual void OnResize() + void OnResize() override { /* Update the scroll bar */ this->vscroll->SetCapacityFromWidget(this, WID_VT_TIMETABLE_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index ae6b726233..6ae57b6b0f 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -129,12 +129,12 @@ public: this->lock_size = GetSpriteSize(SPR_LOCK); } - bool Selectable() const + bool Selectable() const override { return true; } - uint Width() const + uint Width() const override { CompanyID company = (CompanyID)this->result; SetDParam(0, company); @@ -142,12 +142,12 @@ public: return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6; } - uint Height(uint width) const + uint Height(uint width) const override { return max(max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL); } - 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 { CompanyID company = (CompanyID)this->result; bool rtl = _current_text_dir == TD_RTL; @@ -160,11 +160,9 @@ public: int lock_offset = (bottom - top - lock_size.height) / 2; DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset); -#ifdef ENABLE_NETWORK if (NetworkCompanyIsPassworded(company)) { DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset); } -#endif SetDParam(0, company); SetDParam(1, company); @@ -207,7 +205,7 @@ static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count { DropDownList *list = new DropDownList(); for (int i = 0; i < count; i++) { - *list->Append() = new DropDownListStringItem(string + i, i, false); + list->push_back(new DropDownListStringItem(string + i, i, false)); } PopupMainToolbMenu(w, widget, list, 0); } @@ -230,32 +228,30 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0) switch (widget) { case WID_TN_COMPANIES: -#ifdef ENABLE_NETWORK if (!_networking) break; /* Add the client list button for the companies menu */ - *list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false); + list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false)); if (_local_company == COMPANY_SPECTATOR) { - *list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()); + list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached())); } else { - *list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached()); + list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached())); } -#endif /* ENABLE_NETWORK */ break; case WID_TN_STORY: - *list->Append() = new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false); + list->push_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false)); break; case WID_TN_GOAL: - *list->Append() = new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false); + list->push_back(new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false)); break; } for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { if (!Company::IsValidID(c)) continue; - *list->Append() = new DropDownListCompanyItem(c, false, HasBit(grey, c)); + list->push_back(new DropDownListCompanyItem(c, false, HasBit(grey, c))); } PopupMainToolbMenu(w, widget, list, _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company); @@ -330,25 +326,25 @@ enum OptionMenuEntries { static CallBackFunction ToolbarOptionsClick(Window *w) { DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false); - *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false); + list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false)); + list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false)); /* Changes to the per-AI settings don't get send from the server to the clients. Clients get * the settings once they join but never update it. As such don't show the window at all * to network clients. */ - if (!_networking || _network_server) *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false); - *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false); - *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_ZONING, OME_ZONING, false); - *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false); - *list->Append() = new DropDownListItem(-1, false); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)); - *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)); + if (!_networking || _network_server) list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false)); + list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false)); + list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_ZONING, OME_ZONING, false)); + list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false)); + list->push_back(new DropDownListItem(-1, false)); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES))); + list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS))); ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); @@ -479,11 +475,11 @@ enum MapMenuEntries { static CallBackFunction ToolbarMapClick(Window *w) { DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_PLAN_LIST, MME_SHOW_PLANS, false); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_PLAN_LIST, MME_SHOW_PLANS, false)); PopupMainToolbMenu(w, WID_TN_SMALL_MAP, list, 0); return CBF_NONE; } @@ -491,11 +487,11 @@ static CallBackFunction ToolbarMapClick(Window *w) static CallBackFunction ToolbarScenMapTownDir(Window *w) { DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false); - *list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false); - *list->Append() = new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false); - *list->Append() = new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS, false)); + list->push_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false)); + list->push_back(new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false)); + list->push_back(new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false)); PopupMainToolbMenu(w, WID_TE_SMALL_MAP, list, 0); return CBF_NONE; } @@ -623,7 +619,6 @@ static CallBackFunction ToolbarCompaniesClick(Window *w) */ static CallBackFunction MenuClickCompany(int index) { -#ifdef ENABLE_NETWORK if (_networking) { switch (index) { case CTMN_CLIENT_LIST: @@ -648,7 +643,6 @@ static CallBackFunction MenuClickCompany(int index) return CBF_NONE; } } -#endif /* ENABLE_NETWORK */ ShowCompany((CompanyID)index); return CBF_NONE; } @@ -916,7 +910,7 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w) DropDownList *list = new DropDownList(); /* Road is always visible and available. */ - *list->Append() = new DropDownListIconItem(SPR_IMG_ROAD_X_DIR, PAL_NONE, STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false); + list->push_back(new DropDownListIconItem(SPR_IMG_ROAD_X_DIR, PAL_NONE, STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false)); /* Tram is only visible when there will be a tram, and available when that has been introduced. */ Engine *e; @@ -924,7 +918,7 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w) if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue; if (!HasBit(e->info.misc_flags, EF_ROAD_TRAM)) continue; - *list->Append() = new DropDownListIconItem(SPR_IMG_TRAMWAY_X_DIR, PAL_NONE, STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM)); + list->push_back(new DropDownListIconItem(SPR_IMG_TRAMWAY_X_DIR, PAL_NONE, STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM))); break; } ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true); @@ -1351,7 +1345,7 @@ public: return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN; } - void SetupSmallestSize(Window *w, bool init_array) + void SetupSmallestSize(Window *w, bool init_array) override { this->smallest_x = 0; // Biggest child this->smallest_y = 0; // Biggest child @@ -1384,7 +1378,7 @@ public: _toolbar_width = nbuttons * this->smallest_x; } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); @@ -1447,7 +1441,7 @@ public: } } - /* virtual */ void Draw(const Window *w) + void Draw(const Window *w) override { /* Draw brown-red toolbar bg. */ GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED); @@ -1462,7 +1456,7 @@ public: } } - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y) + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL; @@ -1489,7 +1483,7 @@ public: /** Container for the 'normal' main toolbar */ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { - /* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const + const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { static const uint SMALLEST_ARRANGEMENT = 14; static const uint BIGGEST_ARRANGEMENT = 20; @@ -1812,7 +1806,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { uint panel_widths[2]; ///< The width of the two panels (the text panel and date panel) - void SetupSmallestSize(Window *w, bool init_array) + void SetupSmallestSize(Window *w, bool init_array) override { this->NWidgetToolbarContainer::SetupSmallestSize(w, init_array); @@ -1827,7 +1821,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { } } - /* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const + const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { static const byte arrange_all[] = { WID_TE_PAUSE, @@ -2017,12 +2011,12 @@ struct MainToolbarWindow : Window { this->timer.SetInterval(MILLISECONDS_PER_TICK); } - virtual void FindWindowPlacementAndResize(int def_width, int def_height) + void FindWindowPlacementAndResize(int def_width, int def_height) override { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } - virtual void OnPaint() + void OnPaint() override { /* If spectator, disable all construction buttons * ie : Build road, rail, ships, airports and landscaping @@ -2040,18 +2034,18 @@ struct MainToolbarWindow : Window { this->DrawWidgets(); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { CallBackFunction cbf = _menu_clicked_procs[widget](index); if (cbf != CBF_NONE) _last_started_action = cbf; } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { switch (hotkey) { case MTHK_PAUSE: ToolbarPauseClick(this); break; @@ -2090,9 +2084,7 @@ struct MainToolbarWindow : Window { case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break; case MTHK_TERRAFORM: ShowTerraformToolbar(); break; case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break; -#ifdef ENABLE_NETWORK case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break; -#endif case MTHK_SIGN_LIST: ShowSignList(); break; case MTHK_PLAN_LIST: ShowPlansWindow(); break; default: return ES_NOT_HANDLED; @@ -2100,7 +2092,7 @@ struct MainToolbarWindow : Window { return ES_HANDLED; } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (_last_started_action) { case CBF_PLACE_SIGN: @@ -2115,12 +2107,12 @@ struct MainToolbarWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { _last_started_action = CBF_NONE; } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (!this->timer.Elapsed(delta_ms)) return; this->timer.SetInterval(MILLISECONDS_PER_TICK); @@ -2136,7 +2128,7 @@ struct MainToolbarWindow : Window { } } - virtual void OnTimeout() + void OnTimeout() override { /* We do not want to automatically raise the pause, fast forward and * switchbar buttons; they have to stay down when pressed etc. */ @@ -2153,7 +2145,7 @@ struct MainToolbarWindow : 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 (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TN_ZOOM_IN, WID_TN_ZOOM_OUT); @@ -2204,9 +2196,7 @@ static Hotkey maintoolbar_hotkeys[] = { Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS), Hotkey('L', "terraform", MTHK_TERRAFORM), Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT), -#ifdef ENABLE_NETWORK Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST), -#endif Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST), Hotkey('P', "plan_list", MTHK_PLAN_LIST), HOTKEY_LIST_END @@ -2356,12 +2346,12 @@ struct ScenarioEditorToolbarWindow : Window { this->timer.SetInterval(MILLISECONDS_PER_TICK); } - virtual void FindWindowPlacementAndResize(int def_width, int def_height) + void FindWindowPlacementAndResize(int def_width, int def_height) override { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } - virtual void OnPaint() + void OnPaint() override { this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= MIN_YEAR); this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= MAX_YEAR); @@ -2369,7 +2359,7 @@ struct ScenarioEditorToolbarWindow : Window { this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_TE_DATE: @@ -2390,7 +2380,7 @@ struct ScenarioEditorToolbarWindow : 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_TE_SPACER: @@ -2405,14 +2395,14 @@ struct ScenarioEditorToolbarWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (_game_mode == GM_MENU) return; CallBackFunction cbf = _scen_toolbar_button_procs[widget](this); if (cbf != CBF_NONE) _last_started_action = cbf; } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { /* The map button is in a different location on the scenario * editor toolbar, so we need to adjust for it. */ @@ -2422,7 +2412,7 @@ struct ScenarioEditorToolbarWindow : Window { if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { CallBackFunction cbf = CBF_NONE; switch (hotkey) { @@ -2454,7 +2444,7 @@ struct ScenarioEditorToolbarWindow : Window { return ES_HANDLED; } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { switch (_last_started_action) { case CBF_PLACE_SIGN: @@ -2469,19 +2459,19 @@ struct ScenarioEditorToolbarWindow : Window { } } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { _last_started_action = CBF_NONE; } - virtual void OnTimeout() + void OnTimeout() override { this->SetWidgetsLoweredState(false, WID_TE_DATE_BACKWARD, WID_TE_DATE_FORWARD, WIDGET_LIST_END); this->SetWidgetDirty(WID_TE_DATE_BACKWARD); this->SetWidgetDirty(WID_TE_DATE_FORWARD); } - virtual void OnRealtimeTick(uint delta_ms) + void OnRealtimeTick(uint delta_ms) override { if (!this->timer.Elapsed(delta_ms)) return; this->timer.SetInterval(MILLISECONDS_PER_TICK); @@ -2502,13 +2492,13 @@ struct ScenarioEditorToolbarWindow : 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 (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { /* Was 'cancel' pressed? */ if (str == NULL) return; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 4aa776e9de..4c25bc1d7c 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -3735,7 +3735,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold) } static bool _town_rating_test = false; ///< If \c true, town rating is in test-mode. -static SmallMap _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode. +static SmallMap _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode. /** * Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings. @@ -3747,7 +3747,7 @@ void SetTownRatingTestMode(bool mode) static int ref_count = 0; // Number of times test-mode is switched on. if (mode) { if (ref_count == 0) { - _town_test_ratings.Clear(); + _town_test_ratings.clear(); } ref_count++; } else { diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 484c32ebee..cdf87f506c 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -105,7 +105,7 @@ public: this->vscroll->SetCapacity((this->GetWidget(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL); } - virtual void OnPaint() + void OnPaint() override { int numact; uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town); @@ -186,12 +186,12 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_TA_CAPTION) SetDParam(0, this->window_number); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_TA_ACTION_INFO: @@ -226,7 +226,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_TA_ACTION_INFO: { @@ -260,7 +260,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_TA_COMMAND_LIST: { @@ -283,7 +283,7 @@ public: } } - virtual void OnHundredthTick() + void OnHundredthTick() override { this->SetDirty(); } @@ -327,12 +327,12 @@ public: this->SetWidgetDisabledState(WID_TV_CHANGE_NAME, _networking && !_network_server); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_TV_INFO) return; @@ -418,7 +418,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_TV_CENTER_VIEW: // scroll to location @@ -457,7 +457,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_TV_INFO: @@ -507,7 +507,7 @@ public: } } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_TV_VIEWPORT); @@ -522,7 +522,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; /* Called when setting station noise or required cargoes have changed, in order to resize the window */ @@ -530,7 +530,7 @@ public: this->ResizeWindowAsNeeded(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; @@ -656,16 +656,16 @@ private: void BuildSortTownList() { if (this->towns.NeedRebuild()) { - this->towns.Clear(); + this->towns.clear(); const Town *t; FOR_ALL_TOWNS(t) { - *this->towns.Append() = t; + this->towns.push_back(t); } - this->towns.Compact(); + this->towns.shrink_to_fit(); this->towns.RebuildDone(); - this->vscroll->SetCount(this->towns.Length()); // Update scrollbar as well. + this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well. } /* Always sort the towns. */ this->last_town = NULL; @@ -739,7 +739,7 @@ public: this->FinishInitNested(0); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_TD_WORLD_POPULATION: @@ -762,7 +762,7 @@ public: return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_TD_SORT_ORDER: @@ -772,7 +772,7 @@ public: case WID_TD_LIST: { int n = 0; int y = r.top + WD_FRAMERECT_TOP; - if (this->towns.Length() == 0) { // No towns available. + if (this->towns.size() == 0) { // No towns available. DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE); break; } @@ -784,7 +784,7 @@ public: int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0); int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT; - for (uint i = this->vscroll->GetPosition(); i < this->towns.Length(); i++) { + for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) { const Town *t = this->towns[i]; assert(t->xy != INVALID_TILE); @@ -810,7 +810,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_TD_SORT_ORDER: { @@ -832,7 +832,7 @@ public: } case WID_TD_LIST: { Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE); - for (uint i = 0; i < this->towns.Length(); i++) { + for (uint i = 0; i < this->towns.size(); i++) { const Town *t = this->towns[i]; assert(t != NULL); @@ -862,7 +862,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_TD_SORT_ORDER: // Click on sort order button @@ -885,7 +885,7 @@ public: case WID_TD_LIST: { // Click on Town Matrix uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP); - if (id_v >= this->towns.Length()) return; // click out of town bounds + if (id_v >= this->towns.size()) return; // click out of town bounds const Town *t = this->towns[id_v]; assert(t != NULL); @@ -899,7 +899,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { if (widget != WID_TD_SORT_CRITERIA) return; @@ -910,19 +910,19 @@ public: } } - virtual void OnPaint() + void OnPaint() override { if (this->towns.NeedRebuild()) this->BuildSortTownList(); this->DrawWidgets(); } - virtual void OnHundredthTick() + void OnHundredthTick() override { this->BuildSortTownList(); this->SetDirty(); } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST); } @@ -932,7 +932,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 */ @@ -1135,7 +1135,7 @@ public: if (success && !_shift_pressed) this->RandomTownName(); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_TF_NEW_TOWN: @@ -1180,12 +1180,12 @@ public: } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { this->ExecuteFoundTownCommand(tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown); } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); this->UpdateButtons(false); @@ -1196,7 +1196,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; this->UpdateButtons(true); @@ -1216,9 +1216,9 @@ void ShowFoundTownWindow() AllocateWindowDescFront(&_found_town_desc, 0); } -class GUIHouseList : public SmallVector { +class GUIHouseList : public std::vector { protected: - SmallVector house_sets; ///< list of house sets, each item points the first house of the set in the houses array + std::vector house_sets; ///< list of house sets, each item points the first house of the set in the houses array static int CDECL HouseSorter(const HouseID *a, const HouseID *b) { @@ -1243,17 +1243,17 @@ protected: public: GUIHouseList() { - *this->house_sets.Append() = 0; // terminator + this->house_sets.push_back(0); // terminator } inline HouseID GetHouseAtOffset(uint house_set, uint house_offset) const { - return *this->Get(this->house_sets[house_set] + house_offset); + return (*this)[this->house_sets[house_set] + house_offset]; } uint NumHouseSets() const { - return this->house_sets.Length() - 1; // last item is a terminator + return this->house_sets.size() - 1; // last item is a terminator } uint NumHousesInHouseSet(uint house_set) const @@ -1303,7 +1303,7 @@ public: void Build() { /* collect items */ - this->Clear(); + this->clear(); for (HouseID house = 0; house < NUM_HOUSES; house++) { const HouseSpec *hs = HouseSpec::Get(house); /* is the house enabled? */ @@ -1320,25 +1320,25 @@ public: if (hs->min_year > hs->max_year) continue; /* add the house */ - *this->Append() = house; + this->push_back(house); } /* arrange items */ - QSortT(this->Begin(), this->Length(), HouseSorter); + QSortT(this->data(), this->size(), HouseSorter); /* list house sets */ - this->house_sets.Clear(); + this->house_sets.clear(); const GRFFile *last_set = NULL; - for (uint i = 0; i < this->Length(); i++) { + for (uint i = 0; i < this->size(); i++) { const HouseSpec *hs = HouseSpec::Get((*this)[i]); /* add house set */ - if (this->house_sets.Length() == 0 || last_set != hs->grf_prop.grffile) { + if (this->house_sets.size() == 0 || last_set != hs->grf_prop.grffile) { last_set = hs->grf_prop.grffile; - *this->house_sets.Append() = i; + this->house_sets.push_back(i); } } /* put a terminator on the list to make counting easier */ - *this->house_sets.Append() = this->Length(); + this->house_sets.push_back(this->size()); } }; @@ -1358,7 +1358,7 @@ protected: this->house_set = 0; this->house_offset = 0; - if (this->house_list.Length() == 0) { // no houses at all? + if (this->house_list.size() == 0) { // no houses at all? _cur_house = INVALID_HOUSE_ID; this->display_house = _cur_house; return; @@ -1444,9 +1444,9 @@ public: STR_HOUSE_BUILD_CUSTOM_CAPTION : STR_HOUSE_BUILD_CAPTION; /* hide widgets if we have no houses to show */ - this->SetShaded(this->house_list.Length() == 0); + this->SetShaded(this->house_list.size() == 0); - if (this->house_list.Length() != 0) { + if (this->house_list.size() != 0) { /* show the list of house sets if we have at least 2 items to show */ this->GetWidget(WID_HP_HOUSE_SETS_SEL)->SetDisplayedPlane(this->house_list.NumHouseSets() > 1 ? 0 : SZSP_NONE); /* set number of items in the list of house sets */ @@ -1804,7 +1804,7 @@ struct SelectTownWindow : Window { { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_ST_SCROLLBAR); - this->vscroll->SetCount(this->towns.Length()); + this->vscroll->SetCount(this->towns.size()); this->FinishInitNested(); } @@ -1814,7 +1814,7 @@ struct SelectTownWindow : Window { /* Determine the widest string */ Dimension d = { 0, 0 }; - for (uint i = 0; i < this->towns.Length(); i++) { + for (uint i = 0; i < this->towns.size(); i++) { SetDParam(0, this->towns[i]); d = maxdim(d, GetStringBoundingBox(STR_SELECT_TOWN_LIST_ITEM)); } @@ -1844,7 +1844,7 @@ struct SelectTownWindow : Window { if (widget != WID_ST_PANEL) return; uint pos = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ST_PANEL, WD_FRAMERECT_TOP); - if (pos >= this->towns.Length()) return; + if (pos >= this->towns.size()) return; /* Place a house */ SB(this->cmd.p1, 16, 16, this->towns[pos]); @@ -1916,13 +1916,13 @@ static void PlaceProc_House(TileIndex tile) if (dist >= best_dist) continue; best_dist = dist; best_zone = town_zone; - towns.Clear(); + towns.clear(); } - *towns.Append() = t->index; + towns.push_back(t->index); } } - if (towns.Length() == 0) { + if (towns.size() == 0) { ShowErrorMessage(STR_ERROR_CAN_T_BUILD_HOUSE_HERE, STR_ERROR_BUILDING_NOT_ALLOWED_IN_THIS_TOWN_ZONE, WL_INFO); return; } diff --git a/src/town_type.h b/src/town_type.h index ef7f5b027d..057a7c97c0 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -18,7 +18,7 @@ typedef uint16 TownID; struct Town; -typedef SmallVector TownList; +typedef std::vector TownList; /** Supported initial town sizes */ enum TownSize { diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index b11b7031e3..68451723cc 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -481,7 +481,7 @@ static DropDownList *GetGroupDropDownList(Owner owner, GroupID group_id, int &se const Group *g; FOR_ALL_GROUPS(g) { if (g->owner == owner && g->vehicle_type == VEH_TRAIN) { - *list.Append() = g; + list.push_back(g); } } @@ -492,14 +492,14 @@ static DropDownList *GetGroupDropDownList(Owner owner, GroupID group_id, int &se selected = -1; if (group_id == DEFAULT_GROUP) selected = DEFAULT_GROUP; - *dlist->Append() = new DropDownListStringItem(STR_GROUP_DEFAULT_TRAINS, DEFAULT_GROUP, false); + dlist->push_back(new DropDownListStringItem(STR_GROUP_DEFAULT_TRAINS, DEFAULT_GROUP, false)); - for (size_t i = 0; i < list.Length(); ++i) { + for (size_t i = 0; i < list.size(); ++i) { const Group *g = list[i]; if (group_id == g->index) selected = group_id; DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_GROUP_NAME, g->index, false); item->SetParam(0, g->index); - *dlist->Append() = item; + dlist->push_back(item); } return dlist; @@ -523,11 +523,11 @@ DropDownList *GetSlotDropDownList(Owner owner, TraceRestrictSlotID slot_id, int const TraceRestrictSlot *slot; FOR_ALL_TRACE_RESTRICT_SLOTS(slot) { if (slot->owner == owner) { - *list.Append() = slot; + list.push_back(slot); } } - if (list.Length() == 0) return NULL; + if (list.size() == 0) return NULL; list.ForceResort(); list.Sort(&SlotNameSorter); @@ -535,12 +535,12 @@ DropDownList *GetSlotDropDownList(Owner owner, TraceRestrictSlotID slot_id, int DropDownList *dlist = new DropDownList(); selected = -1; - for (size_t i = 0; i < list.Length(); ++i) { + for (size_t i = 0; i < list.size(); ++i) { const TraceRestrictSlot *s = list[i]; if (slot_id == s->index) selected = slot_id; DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_TRACE_RESTRICT_SLOT_NAME, s->index, false); item->SetParam(0, s->index); - *dlist->Append() = item; + dlist->push_back(item); } return dlist; @@ -2550,10 +2550,10 @@ private: Company *c; FOR_ALL_COMPANIES(c) { - *(list->Append()) = MakeCompanyDropDownListItem(c->index); + list->push_back(MakeCompanyDropDownListItem(c->index)); if (c->index == value) missing_ok = true; } - *(list->Append()) = new DropDownListStringItem(STR_TRACE_RESTRICT_UNDEFINED_COMPANY, INVALID_COMPANY, false); + list->push_back(new DropDownListStringItem(STR_TRACE_RESTRICT_UNDEFINED_COMPANY, INVALID_COMPANY, false)); if (INVALID_COMPANY == value) missing_ok = true; assert(missing_ok == true); @@ -2845,18 +2845,18 @@ private: { if (!this->slots.NeedRebuild()) return; - this->slots.Clear(); + this->slots.clear(); const TraceRestrictSlot *slot; FOR_ALL_TRACE_RESTRICT_SLOTS(slot) { if (slot->owner == owner) { - *(this->slots.Append()) = slot; + this->slots.push_back(slot); } } this->slots.ForceResort(); this->slots.Sort(&SlotNameSorter); - this->slots.Compact(); + this->slots.shrink_to_fit(); this->slots.RebuildDone(); } @@ -3066,8 +3066,8 @@ public: this->BuildSlotList(this->owner); - this->slot_sb->SetCount(this->slots.Length()); - this->vscroll->SetCount(this->vehicles.Length()); + this->slot_sb->SetCount(this->slots.size()); + this->vscroll->SetCount(this->vehicles.size()); /* Disable the slot specific function when we select all vehicles */ this->SetWidgetsDisabledState(this->vli.index == ALL_TRAINS_TRACE_RESTRICT_SLOT_ID || _local_company != this->vli.company, @@ -3103,7 +3103,7 @@ public: case WID_TRSL_LIST_SLOTS: { int y1 = r.top + WD_FRAMERECT_TOP; - int max = min(this->slot_sb->GetPosition() + this->slot_sb->GetCapacity(), this->slots.Length()); + int max = min(this->slot_sb->GetPosition() + this->slot_sb->GetCapacity(), this->slots.size()); for (int i = this->slot_sb->GetPosition(); i < max; ++i) { const TraceRestrictSlot *slot = this->slots[i]; @@ -3162,7 +3162,7 @@ public: case WID_TRSL_LIST_SLOTS: { // Matrix Slot uint id_s = this->slot_sb->GetScrolledRowFromWidget(pt.y, this, WID_TRSL_LIST_SLOTS, 0, this->tiny_step_height); - if (id_s >= this->slots.Length()) return; + if (id_s >= this->slots.size()) return; this->slot_sel = this->vli.index = this->slots[id_s]->index; @@ -3173,7 +3173,7 @@ public: case WID_TRSL_LIST_VEHICLE: { // Matrix Vehicle uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TRSL_LIST_VEHICLE); - if (id_v >= this->vehicles.Length()) return; // click out of list bound + if (id_v >= this->vehicles.size()) return; // click out of list bound const Vehicle *v = this->vehicles[id_v]; if (VehicleClicked(v)) break; @@ -3230,7 +3230,7 @@ public: this->SetDirty(); uint id_s = this->slot_sb->GetScrolledRowFromWidget(pt.y, this, WID_TRSL_LIST_SLOTS, 0, this->tiny_step_height); - if (id_s >= this->slots.Length()) return; // click out of list bound + if (id_s >= this->slots.size()) return; // click out of list bound if (_ctrl_pressed) { // remove from old group @@ -3247,7 +3247,7 @@ public: this->SetDirty(); uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TRSL_LIST_VEHICLE); - if (id_v >= this->vehicles.Length()) return; // click out of list bound + if (id_v >= this->vehicles.size()) return; // click out of list bound const Vehicle *v = this->vehicles[id_v]; if (!VehicleClicked(v) && vindex == v->index) { @@ -3331,7 +3331,7 @@ public: case WID_TRSL_LIST_SLOTS: { // ... the list of slots. uint id_s = this->slot_sb->GetScrolledRowFromWidget(pt.y, this, WID_TRSL_LIST_SLOTS, 0, this->tiny_step_height); - if (id_s < this->slots.Length()) new_slot_over = this->slots[id_s]->index; + if (id_s < this->slots.size()) new_slot_over = this->slots[id_s]->index; break; } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 1e063b69c6..9d4d39e2a2 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1036,7 +1036,7 @@ static Train *FindGoodVehiclePos(const Train *src) } /** Helper type for lists/vectors of trains */ -typedef SmallVector TrainList; +typedef std::vector TrainList; /** * Make a backup of a train into a train list. @@ -1045,7 +1045,7 @@ typedef SmallVector TrainList; */ static void MakeTrainBackup(TrainList &list, Train *t) { - for (; t != NULL; t = t->Next()) *list.Append() = t; + for (; t != NULL; t = t->Next()) list.push_back(t); } /** @@ -1055,12 +1055,11 @@ static void MakeTrainBackup(TrainList &list, Train *t) static void RestoreTrainBackup(TrainList &list) { /* No train, nothing to do. */ - if (list.Length() == 0) return; + if (list.size() == 0) return; Train *prev = NULL; /* Iterate over the list and rebuild it. */ - for (Train **iter = list.Begin(); iter != list.End(); iter++) { - Train *t = *iter; + for (Train *t : list) { if (prev != NULL) { prev->SetNext(t); } else if (t->Previous() != NULL) { @@ -5309,19 +5308,25 @@ Train* CmdBuildVirtualRailVehicle(EngineID eid, bool lax_engine_check, StringID * Build a virtual train vehicle. * @param tile unused * @param flags type of operation - * @param p1 the engine ID to build + * @param p1 various bitstuffed data + * bits 0-15: vehicle type being built. + * bits 24-31: refit cargo type. * @param p2 unused * @param text unused * @return the cost of this operation or an error */ CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - EngineID eid = p1; + EngineID eid = GB(p1, 0, 16); if (!IsEngineBuildable(eid, VEH_TRAIN, _current_company)) { return_cmd_error(STR_ERROR_RAIL_VEHICLE_NOT_AVAILABLE + VEH_TRAIN); } + /* Validate the cargo type. */ + CargoID cargo = GB(p1, 24, 8); + if (cargo >= NUM_CARGO && cargo != CT_INVALID) return CMD_ERROR; + bool should_execute = (flags & DC_EXEC) != 0; if (should_execute) { @@ -5332,12 +5337,10 @@ CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint return_cmd_error(err); } - if (text && text[0] == 'R') { - CargoID cargo = text[1]; - if (cargo >= NUM_CARGO) return CMD_ERROR; + if (cargo != CT_INVALID) { CargoID default_cargo = Engine::Get(eid)->GetDefaultCargoType(); if (default_cargo != cargo) { - CommandCost refit_res = CmdRefitVehicle(tile, flags, train->index, cargo | (1 << 5), NULL); + CommandCost refit_res = CmdRefitVehicle(tile, flags, train->index, cargo, NULL); if (!refit_res.Succeeded()) return refit_res; } } diff --git a/src/train_gui.cpp b/src/train_gui.cpp index c7ee02a0ce..dccd7ad2de 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -177,13 +177,19 @@ struct CargoSummaryItem { { return this->cargo != other.cargo || this->subtype != other.subtype; } + + /** Used by std::find() and similar functions */ + inline bool operator == (const CargoSummaryItem &other) const + { + return !(this->cargo != other.cargo); + } }; static const uint TRAIN_DETAILS_MIN_INDENT = 32; ///< Minimum indent level in the train details window static const uint TRAIN_DETAILS_MAX_INDENT = 72; ///< Maximum indent level in the train details window; wider than this and we start on a new line /** Container for the cargo summary information. */ -typedef SmallVector CargoSummary; +typedef std::vector CargoSummary; /** Reused container of cargo details */ static CargoSummary _cargo_summary; @@ -319,7 +325,7 @@ static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int */ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary) { - summary->Clear(); + summary->clear(); do { if (!v->GetEngine()->CanCarryCargo()) continue; @@ -328,9 +334,10 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su new_item.subtype = GetCargoSubtypeText(v); if (new_item.cargo == INVALID_CARGO && new_item.subtype == STR_EMPTY) continue; - CargoSummaryItem *item = summary->Find(new_item); - if (item == summary->End()) { - item = summary->Append(); + auto item = std::find(summary->begin(), summary->end(), new_item); + if (item == summary->end()) { + summary->emplace_back(); + item = summary->end() - 1; item->cargo = new_item.cargo; item->subtype = new_item.subtype; item->capacity = 0; @@ -388,7 +395,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab) } else { for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) { GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary); - num += max(1u, _cargo_summary.Length()); + num += max(1u, (unsigned)_cargo_summary.size()); uint length = GetLengthOfArticulatedVehicle(v); if (length > TRAIN_DETAILS_MAX_INDENT) num++; @@ -458,7 +465,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po dx = 0; } - uint num_lines = max(1u, _cargo_summary.Length()); + uint num_lines = max(1u, (unsigned)_cargo_summary.size()); for (uint i = 0; i < num_lines;) { int sprite_width = max(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3; int data_left = left + (rtl ? 0 : sprite_width); @@ -470,7 +477,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po } switch (det_tab) { case TDW_TAB_CARGO: - if (i < _cargo_summary.Length()) { + if (i < _cargo_summary.size()) { TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py); } else { DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE); @@ -482,7 +489,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po break; case TDW_TAB_CAPACITY: - if (i < _cargo_summary.Length()) { + if (i < _cargo_summary.size()) { TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py); } else { SetDParam(0, STR_EMPTY); @@ -495,7 +502,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po } if (det_tab != 1 || line_number >= (Train::From(v)->IsWagon() ? 0 : 2)) { line_number = 0; - i++; + i++; } else { line_number++; } diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 0d8d535744..0a566ff700 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -35,13 +35,13 @@ public: this->InitNested(window_number); } - virtual void OnPaint() + void OnPaint() override { this->OnInvalidateData(0); // Must be sure that the widgets show the transparency variable changes, also when we use shortcuts. this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_TT_SIGNS: @@ -70,7 +70,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { if (_ctrl_pressed) { @@ -105,7 +105,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 { Point pt = GetToolbarAlignedWindowPosition(sm_width); pt.y += 2 * (sm_height - this->GetWidget(WID_TT_BUTTONS)->current_y); @@ -117,7 +117,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; for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 246b329616..e91ee56f4c 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -70,7 +70,7 @@ public: return 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_BT_TYPE_11 && widget <= WID_BT_TYPE_34) { Dimension d = GetMaxTreeSpriteSize(); @@ -88,7 +88,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget < WID_BT_TYPE_11 || widget > WID_BT_TYPE_34 || widget - WID_BT_TYPE_11 >= this->count) return; @@ -97,7 +97,7 @@ public: DrawSprite(_tree_sprites[i].sprite, _tree_sprites[i].pal, (r.left + r.right) / 2 + WD_FRAMERECT_LEFT, r.bottom - 7); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BT_TYPE_11: case WID_BT_TYPE_12: case WID_BT_TYPE_13: case WID_BT_TYPE_14: @@ -131,17 +131,17 @@ public: } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + void OnPlaceObject(Point pt, TileIndex tile) override { VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_PLANT_TREES); } - 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_PLANT_TREES) { DoCommandP(end_tile, this->tree_to_plant, start_tile, @@ -152,13 +152,13 @@ public: /** * Initialize the window data */ - virtual void OnInit() + void OnInit() override { this->base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; this->count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; } - virtual void OnPlaceObjectAbort() + void OnPlaceObjectAbort() override { this->RaiseButtons(); } diff --git a/src/tree_map.h b/src/tree_map.h index a291d563a3..e524f825fb 100644 --- a/src/tree_map.h +++ b/src/tree_map.h @@ -277,6 +277,7 @@ static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, { SetTileType(t, MP_TREES); SetTileOwner(t, OWNER_NONE); + SetWaterClass(t, ground == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID); _m[t].m2 = ground << 6 | density << 4 | 0; _m[t].m3 = type; _m[t].m4 = 0 << 5 | 0 << 2; diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index b172a965c7..5570856aca 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -889,9 +889,8 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, * Do this for all tiles (like trees), not only objects. */ ClearedObjectArea *coa = FindClearedObject(end_tile); if (coa == NULL) { - coa = _cleared_object_areas.Append(); - coa->first_tile = end_tile; - coa->area = TileArea(end_tile, 1, 1); + /*C++17: coa = &*/ _cleared_object_areas.push_back({end_tile, TileArea(end_tile, 1, 1)}); + coa = &_cleared_object_areas.back(); } /* Hide the tile from the terraforming command */ @@ -907,8 +906,9 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, * Deliberately clear the coa pointer to avoid leaving dangling pointers which could * inadvertently be dereferenced. */ - assert(coa >= _cleared_object_areas.Begin() && coa < _cleared_object_areas.End()); - size_t coa_index = coa - _cleared_object_areas.Begin(); + ClearedObjectArea *begin = _cleared_object_areas.data(); + assert(coa >= begin && coa < begin + _cleared_object_areas.size()); + size_t coa_index = coa - begin; assert(coa_index < UINT_MAX); // more than 2**32 cleared areas would be a bug in itself coa = NULL; @@ -1162,7 +1162,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) /* read this value before actual removal of bridge */ Owner owner = GetTileOwner(tile); int height = GetBridgeHeight(tile); - SmallVector vehicles_affected; + std::vector vehicles_affected; if (rail) { auto find_train_reservations = [&vehicles_affected](TileIndex tile) { @@ -1172,7 +1172,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) Train *v = GetTrainForReservation(tile, track); if (v != NULL) { FreeTrainTrackReservation(v); - *vehicles_affected.Append() = v; + vehicles_affected.push_back(v); } } }; @@ -1222,7 +1222,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) notify_track_change(tile, direction, tile_tracks); notify_track_change(endtile, ReverseDiagDir(direction), endtile_tracks); - for (uint i = 0; i < vehicles_affected.Length(); ++i) { + for (uint i = 0; i < vehicles_affected.size(); ++i) { TryPathReserve(vehicles_affected[i], true); } } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d8c0f4801a..fed3fe2649 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -808,19 +808,20 @@ void ResetVehicleColourMap() * List of vehicles that should check for autoreplace this tick. * Mapping of vehicle -> leave depot immediately after autoreplace. */ -typedef SmallMap AutoreplaceMap; +typedef SmallMap AutoreplaceMap; static AutoreplaceMap _vehicles_to_autoreplace; /** * List of vehicles that are issued for template replacement this tick. * Mapping is {vehicle : leave depot after replacement} */ -typedef SmallMap TemplateReplacementMap; +typedef SmallMap TemplateReplacementMap; static TemplateReplacementMap _vehicles_to_templatereplace; void InitializeVehicles() { - _vehicles_to_autoreplace.Reset(); + _vehicles_to_autoreplace.clear(); + _vehicles_to_autoreplace.shrink_to_fit(); ResetVehicleHash(); } @@ -1227,8 +1228,8 @@ void VehicleTickMotion(Vehicle *v, Vehicle *front) void CallVehicleTicks() { - _vehicles_to_autoreplace.Clear(); - _vehicles_to_templatereplace.Clear(); + _vehicles_to_autoreplace.clear(); + _vehicles_to_templatereplace.clear(); _vehicles_to_pay_repair.clear(); _vehicles_to_sell.clear(); @@ -1346,8 +1347,8 @@ void CallVehicleTicks() /* do Template Replacement */ Backup tmpl_cur_company(_current_company, FILE_LINE); - for (TemplateReplacementMap::iterator it = _vehicles_to_templatereplace.Begin(); it != _vehicles_to_templatereplace.End(); it++) { - Train *t = it->first; + for (auto &it : _vehicles_to_templatereplace) { + Train *t = it.first; SCOPE_INFO_FMT([t], "CallVehicleTicks: template replace: %s", scope_dumper().VehicleInfo(t)); @@ -1360,9 +1361,9 @@ void CallVehicleTicks() tmpl_cur_company.Change(t->owner); - bool stayInDepot = it->second; + bool stayInDepot = it.second; - it->first->vehstatus |= VS_STOPPED; + t->vehstatus |= VS_STOPPED; CommandCost res = DoCommand(t->tile, t->index, stayInDepot ? 1 : 0, DC_EXEC, CMD_TEMPLATE_REPLACE_VEHICLE); if (res.Succeeded()) { @@ -1390,8 +1391,8 @@ void CallVehicleTicks() /* do Auto Replacement */ Backup cur_company(_current_company, FILE_LINE); - for (AutoreplaceMap::iterator it = _vehicles_to_autoreplace.Begin(); it != _vehicles_to_autoreplace.End(); it++) { - v = it->first; + for (auto &it : _vehicles_to_autoreplace) { + v = it.first; /* Autoreplace needs the current company set as the vehicle owner */ cur_company.Change(v->owner); @@ -1402,7 +1403,7 @@ void CallVehicleTicks() /* Start vehicle if we stopped them in VehicleEnteredDepotThisTick() * We need to stop them between VehicleEnteredDepotThisTick() and here or we risk that * they are already leaving the depot again before being replaced. */ - if (it->second) v->vehstatus &= ~VS_STOPPED; + if (it.second) v->vehstatus &= ~VS_STOPPED; /* Store the position of the effect as the vehicle pointer will become invalid later */ int x = v->x_pos; @@ -1995,8 +1996,11 @@ void AgeVehicle(Vehicle *v) /* Don't warn about non-primary or not ours vehicles or vehicles that are crashed */ if (v->Previous() != NULL || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0) return; + const Company *c = Company::Get(v->owner); /* Don't warn if a renew is active */ - if (Company::Get(v->owner)->settings.engine_renew && v->GetEngine()->company_avail != 0) return; + if (c->settings.engine_renew && v->GetEngine()->company_avail != 0) return; + /* Don't warn if a replacement is active */ + if (EngineHasReplacementForCompany(c, v->engine_type, v->group_id)) return; StringID str; if (age == -DAYS_IN_LEAP_YEAR) { @@ -3929,10 +3933,10 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles) for (; u != NULL && num_vehicles > 0; num_vehicles--) { do { /* Include current vehicle in the selection. */ - set.Include(u->index); + include(set, u->index); /* If the vehicle is multiheaded, add the other part too. */ - if (u->IsMultiheaded()) set.Include(u->other_multiheaded_part->index); + if (u->IsMultiheaded()) include(set, u->other_multiheaded_part->index); u = u->Next(); } while (u != NULL && u->IsArticulatedPart()); diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 0bfeab654e..54982b5bd6 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -81,9 +81,10 @@ static CommandCost GetRefitCost(const Vehicle *v, EngineID engine_type, CargoID * @param flags for command * @param p1 various bitstuffed data * bits 0-15: vehicle type being built. - * bits 16-31: vehicle type specific bits passed on to the vehicle build functions. + * bits 16-23: vehicle type specific bits passed on to the vehicle build functions. + * bits 24-31: refit cargo type. * @param p2 User - * @param text used for combined build and refit command + * @param text unused * @return the cost of this operation or an error */ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text, uint32 binary_length) @@ -103,11 +104,18 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint EngineID eid = GB(p1, 0, 16); if (!IsEngineBuildable(eid, type, _current_company)) return_cmd_error(STR_ERROR_RAIL_VEHICLE_NOT_AVAILABLE + type); + /* Validate the cargo type. */ + CargoID cargo = GB(p1, 24, 8); + if (cargo >= NUM_CARGO && cargo != CT_INVALID) return CMD_ERROR; + const Engine *e = Engine::Get(eid); CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost()); /* Engines without valid cargo should not be available */ - if (e->GetDefaultCargoType() == CT_INVALID) return CMD_ERROR; + CargoID default_cargo = e->GetDefaultCargoType(); + if (default_cargo == CT_INVALID) return CMD_ERROR; + + bool refitting = cargo != CT_INVALID && cargo != default_cargo; /* Check whether the number of vehicles we need to build can be built according to pool space. */ uint num_vehicles; @@ -126,65 +134,57 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint UnitID unit_num = (flags & DC_AUTOREPLACE || (type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON)) ? 0 : GetFreeUnitNumber(type); if (unit_num == UINT16_MAX) return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME); - Vehicle *v; + /* If we are refitting we need to temporarily purchase the vehicle to be able to + * test it. */ + DoCommandFlag subflags = flags; + if (refitting) subflags |= DC_EXEC; + + Vehicle *v = NULL; switch (type) { - case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, flags, e, GB(p1, 16, 16), &v)); break; - case VEH_ROAD: value.AddCost(CmdBuildRoadVehicle(tile, flags, e, GB(p1, 16, 16), &v)); break; - case VEH_SHIP: value.AddCost(CmdBuildShip (tile, flags, e, GB(p1, 16, 16), &v)); break; - case VEH_AIRCRAFT: value.AddCost(CmdBuildAircraft (tile, flags, e, GB(p1, 16, 16), &v)); break; + case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break; + case VEH_ROAD: value.AddCost(CmdBuildRoadVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break; + case VEH_SHIP: value.AddCost(CmdBuildShip (tile, subflags, e, GB(p1, 24, 8), &v)); break; + case VEH_AIRCRAFT: value.AddCost(CmdBuildAircraft (tile, subflags, e, GB(p1, 24, 8), &v)); break; default: NOT_REACHED(); // Safe due to IsDepotTile() } - if (value.Succeeded() && flags & DC_EXEC) { - v->unitnumber = unit_num; - v->value = value.GetCost(); - - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); - InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0); - SetWindowDirty(WC_COMPANY, _current_company); - if (IsLocalCompany()) { - InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the auto replace window (must be called before incrementing num_engines) + if (value.Succeeded()) { + if (refitting || (flags & DC_EXEC)) { + v->unitnumber = unit_num; + v->value = value.GetCost(); } - GroupStatistics::CountEngine(v, 1); - GroupStatistics::UpdateAutoreplace(_current_company); - - if (v->IsPrimaryVehicle()) { - GroupStatistics::CountVehicle(v, 1); - OrderBackup::Restore(v, p2); + if (refitting) { + value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo, NULL)); + } else { + /* Fill in non-refitted capacities */ + _returned_refit_capacity = e->GetDisplayDefaultCapacity(&_returned_mail_refit_capacity); } - } - if (value.Succeeded() && binary_length == 2 && text && text[0] == 'R') { - CargoID cargo = text[1]; - if (cargo >= NUM_CARGO) return CMD_ERROR; - CargoID default_cargo = e->GetDefaultCargoType(); - if (default_cargo != cargo) { - if (flags & DC_EXEC) { - value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo, NULL)); - } else { - bool auto_refit_allowed = false; - value.AddCost(GetRefitCost(NULL, eid, cargo, 0, &auto_refit_allowed)); - if (type == VEH_TRAIN || type == VEH_ROAD) { - std::vector engine_ids; - GetArticulatedPartsEngineIDs(eid, false, engine_ids); - for (size_t i = 0; i < engine_ids.size(); i++) { - value.AddCost(GetRefitCost(NULL, engine_ids[i], cargo, 0, &auto_refit_allowed)); - } - } - if (type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_MULTIHEAD) { - value.AddCost(GetRefitCost(NULL, eid, cargo, 0, &auto_refit_allowed)); - } + if (flags & DC_EXEC) { + InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0); + SetWindowDirty(WC_COMPANY, _current_company); + if (IsLocalCompany()) { + InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the auto replace window (must be called before incrementing num_engines) } } - /* Since we can't estimate the cost of build and refitting a vehicle accurately we must - * check whether the company has enough money manually. */ - if (!CheckCompanyHasMoney(value)) { - if (flags & DC_EXEC) { - /* The vehicle has already been bought, so now it must be sold again. */ - DoCommand(tile, v->index, 0, flags, GetCmdSellVeh(type)); + + if (refitting || (flags & DC_EXEC)) { + GroupStatistics::CountEngine(v, 1); + GroupStatistics::UpdateAutoreplace(_current_company); + + if (v->IsPrimaryVehicle()) { + GroupStatistics::CountVehicle(v, 1); + OrderBackup::Restore(v, p2); } } + + + /* If we are not in DC_EXEC undo everything */ + if (refitting && (flags & DC_EXEC) == 0) { + DoCommand(0, v->index, 0, DC_EXEC, GetCmdSellVeh(v)); + } } return value; @@ -357,8 +357,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, v = v->First(); } - static SmallVector refit_result; - refit_result.Clear(); + std::vector refit_result; v->InvalidateNewGRFCacheOfChain(); byte actual_subtype = new_subtype; @@ -366,7 +365,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, /* Reset actual_subtype for every new vehicle */ if (!v->IsArticulatedPart()) actual_subtype = new_subtype; - if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue; + if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end() && !only_this) continue; const Engine *e = v->GetEngine(); if (!e->CanCarryCargo()) continue; @@ -428,32 +427,28 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, * - We have to call the refit cost callback with the pre-refit configuration of the chain because we want refit and * autorefit to behave the same, and we need its result for auto_refit_allowed. */ - RefitResult *result = refit_result.Append(); - result->v = v; - result->capacity = amount; - result->mail_capacity = mail_capacity; - result->subtype = actual_subtype; + refit_result.push_back({v, amount, mail_capacity, actual_subtype}); } if (flags & DC_EXEC) { /* Store the result */ - for (RefitResult *result = refit_result.Begin(); result != refit_result.End(); result++) { - Vehicle *u = result->v; - u->refit_cap = (u->cargo_type == new_cid) ? min(result->capacity, u->refit_cap) : 0; + for (RefitResult &result : refit_result) { + Vehicle *u = result.v; + u->refit_cap = (u->cargo_type == new_cid) ? min(result.capacity, u->refit_cap) : 0; if (u->cargo.TotalCount() > u->refit_cap) u->cargo.Truncate(u->cargo.TotalCount() - u->refit_cap); u->cargo_type = new_cid; - u->cargo_cap = result->capacity; - u->cargo_subtype = result->subtype; + u->cargo_cap = result.capacity; + u->cargo_subtype = result.subtype; if (u->type == VEH_AIRCRAFT) { Vehicle *w = u->Next(); - w->refit_cap = min(w->refit_cap, result->mail_capacity); - w->cargo_cap = result->mail_capacity; + w->refit_cap = min(w->refit_cap, result.mail_capacity); + w->cargo_cap = result.mail_capacity; if (w->cargo.TotalCount() > w->refit_cap) w->cargo.Truncate(w->cargo.TotalCount() - w->refit_cap); } } } - refit_result.Clear(); + refit_result.clear(); _returned_refit_capacity = total_capacity; _returned_mail_refit_capacity = total_mail_capacity; return cost; @@ -686,7 +681,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 BuildDepotVehicleList(vli.vtype, tile, &list, NULL); } - for (uint i = 0; i < list.Length(); i++) { + for (uint i = 0; i < list.size(); i++) { const Vehicle *v = list[i]; if (!!(v->vehstatus & VS_STOPPED) != do_start) continue; @@ -725,7 +720,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 CommandCost last_error = CMD_ERROR; bool had_success = false; - for (uint i = 0; i < list.Length(); i++) { + for (uint i = 0; i < list.size(); i++) { CommandCost ret = DoCommand(tile, list[i]->index | (1 << 20), 0, flags, sell_command); if (ret.Succeeded()) { cost.AddCost(ret); @@ -759,7 +754,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &list, &list, true); - for (uint i = 0; i < list.Length(); i++) { + for (uint i = 0; i < list.size(); i++) { const Vehicle *v = list[i]; /* Ensure that the vehicle completely in the depot */ @@ -1373,7 +1368,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint DoCommandFlag build_flags = flags; if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE; - CommandCost cost = DoCommand(tile, v->engine_type | (1 << 16), 0, build_flags, GetCmdBuildVeh(v)); + CommandCost cost = DoCommand(tile, v->engine_type | (1 << 16) | (CT_INVALID << 24), 0, build_flags, GetCmdBuildVeh(v)); if (cost.Failed()) { /* Can't build a part, then sell the stuff we already made; clear up the mess */ @@ -1510,7 +1505,7 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, DepotCommand depo /* Send all the vehicles to a depot */ bool had_success = false; - for (uint i = 0; i < list.Length(); i++) { + for (uint i = 0; i < list.size(); i++) { const Vehicle *v = list[i]; CommandCost ret = DoCommand(v->tile, v->index | depot_flags, 0, flags, GetCmdSendToDepot(vli.vtype)); diff --git a/src/vehicle_func.h b/src/vehicle_func.h index a91e6c9f05..0aeb01b37a 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -177,7 +177,7 @@ bool CanVehicleUseStation(const Vehicle *v, const struct Station *st); void ReleaseDisastersTargetingVehicle(VehicleID vehicle); -typedef SmallVector VehicleSet; +typedef std::vector VehicleSet; void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles); void CheckCargoCapacity(Vehicle *v); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index e134a59a74..603a5396fc 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -145,8 +145,8 @@ const StringID BaseVehicleListWindow::vehicle_depot_sell_name[] = { uint GetUnitNumberDigits(VehicleList &vehicles) { uint unitnumber = 0; - for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) { - unitnumber = max(unitnumber, (*v)->unitnumber); + for (const Vehicle *v : vehicles) { + unitnumber = max(unitnumber, v->unitnumber); } if (unitnumber >= 10000) return 5; @@ -174,7 +174,7 @@ void BaseVehicleListWindow::BuildVehicleList() this->unitnumber_digits = GetUnitNumberDigits(this->vehicles); this->vehicles.RebuildDone(); - this->vscroll->SetCount(this->vehicles.Length()); + this->vscroll->SetCount(this->vehicles.size()); } /** Cargo filter functions */ @@ -268,10 +268,10 @@ void BaseVehicleListWindow::SetCargoFilterArray() void BaseVehicleListWindow::FilterVehicleList() { this->vehicles.Filter(this->cargo_filter[this->cargo_filter_criteria]); - if (0 == this->vehicles.Length()) { + if (0 == this->vehicles.size()) { // no vehicle passed through the filter, invalidate the previously selected vehicle this->vehicle_sel = INVALID_VEHICLE; - } else if (this->vehicle_sel != INVALID_VEHICLE && !this->vehicles.Contains(Vehicle::Get(this->vehicle_sel))) { // previously selected engine didn't pass the filter, remove selection + } else if (this->vehicle_sel != INVALID_VEHICLE && std::find(this->vehicles.begin(), this->vehicles.end(), Vehicle::Get(this->vehicle_sel)) == this->vehicles.end()) { // previously selected engine didn't pass the filter, remove selection this->vehicle_sel = INVALID_VEHICLE; } } @@ -328,7 +328,7 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo */ bool BaseVehicleListWindow::ShouldShowActionDropdownList() const { - return this->vehicles.Length() != 0 || (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features); + return this->vehicles.size() != 0 || (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features); } /** @@ -341,30 +341,30 @@ DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autorepla StringID change_order_str, bool show_create_group, bool consider_top_level) { DropDownList *list = new DropDownList(); - bool disable = this->vehicles.Length() == 0; + bool disable = this->vehicles.size() == 0; bool mass_action_disable = disable || (_settings_client.gui.disable_top_veh_list_mass_actions && consider_top_level); - if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable); + if (show_autoreplace) list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable)); if (show_autoreplace && show_template_replace) { - *list->Append() = new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, disable); + list->push_back(new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, disable)); } - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, mass_action_disable); - *list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, mass_action_disable); - if (_settings_client.gui.show_depot_sell_gui) *list->Append() = new DropDownListStringItem(this->vehicle_depot_sell_name[this->vli.vtype], ADI_DEPOT_SELL, mass_action_disable); - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, mass_action_disable); + list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, mass_action_disable)); + list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, mass_action_disable)); + if (_settings_client.gui.show_depot_sell_gui) list->push_back(new DropDownListStringItem(this->vehicle_depot_sell_name[this->vli.vtype], ADI_DEPOT_SELL, mass_action_disable)); + list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, mass_action_disable)); if (show_group) { - *list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable); - *list->Append() = new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, disable); + list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable)); + list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, disable)); } if (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features) { - *list->Append() = new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false); + list->push_back(new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false)); } if (change_order_str != 0) { - *list->Append() = new DropDownListStringItem(change_order_str, ADI_CHANGE_ORDER, false); + list->push_back(new DropDownListStringItem(change_order_str, ADI_CHANGE_ORDER, false)); } if (show_create_group) { - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CREATE_GROUP, ADI_CREATE_GROUP, false); + list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CREATE_GROUP, ADI_CREATE_GROUP, false)); } return list; @@ -383,8 +383,8 @@ void BaseVehicleListWindow::SortVehicleList() void DepotSortList(VehicleList *list) { - if (list->Length() < 2) return; - QSortT(list->Begin(), list->Length(), &VehicleNumberSorter); + if (list->size() < 2) return; + QSortT(list->data(), list->size(), &VehicleNumberSorter); } /** draw the vehicle profit button in the vehicle list window. */ @@ -423,17 +423,17 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t v_for = v_for->GetFirstEnginePart(); /* Create a list of subtypes used by the various parts of v_for */ - static SmallVector subtypes; - subtypes.Clear(); + static std::vector subtypes; + subtypes.clear(); for (; v_from != NULL; v_from = v_from->HasArticulatedPart() ? v_from->GetNextArticulatedPart() : NULL) { const Engine *e_from = v_from->GetEngine(); if (!e_from->CanCarryCargo() || !HasBit(e_from->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue; - subtypes.Include(GetCargoSubtypeText(v_from)); + include(subtypes, GetCargoSubtypeText(v_from)); } byte ret_refit_cyc = 0; bool success = false; - if (subtypes.Length() > 0) { + if (subtypes.size() > 0) { /* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */ for (Vehicle *v = v_for; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) { const Engine *e = v->GetEngine(); @@ -457,7 +457,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t StringID subtype = GetCargoSubtypeText(v); if (subtype == STR_EMPTY) break; - if (!subtypes.Contains(subtype)) continue; + if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end()) continue; /* We found something matching. */ ret_refit_cyc = refit_cyc; @@ -532,7 +532,7 @@ struct RefitOption { } }; -typedef SmallVector SubtypeList; ///< List of refit subtypes associated to a cargo. +typedef std::vector SubtypeList; ///< List of refit subtypes associated to a cargo. /** * Draw the list of available refit options for a consist and highlight the selected refit option (if any). @@ -562,7 +562,7 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int /* Draw the list of subtypes for each cargo, and find the selected refit option (by its position). */ for (uint i = 0; current < pos + rows && i < NUM_CARGO; i++) { - for (uint j = 0; current < pos + rows && j < list[i].Length(); j++) { + for (uint j = 0; current < pos + rows && j < list[i].size(); j++) { const RefitOption &refit = list[i][j]; /* Hide subtypes if sel[0] does not match */ @@ -574,11 +574,11 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int continue; } - if (list[i].Length() > 1) { + if (list[i].size() > 1) { if (refit.subtype != 0xFF) { /* Draw tree lines */ int ycenter = y + FONT_HEIGHT_NORMAL / 2; - GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].Length() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour); + GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour); GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour); } else { /* Draw expand/collapse icon */ @@ -622,7 +622,7 @@ struct RefitWindow : public Window { */ void BuildRefitList() { - for (uint i = 0; i < NUM_CARGO; i++) this->list[i].Clear(); + for (uint i = 0; i < NUM_CARGO; i++) this->list[i].clear(); Vehicle *v = Vehicle::Get(this->window_number); /* Check only the selected vehicles. */ @@ -630,7 +630,7 @@ struct RefitWindow : public Window { GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles); do { - if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index)) continue; + if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end()) continue; const Engine *e = v->GetEngine(); CargoTypes cmask = e->info.refit_mask; byte callback_mask = e->info.callback_mask; @@ -651,13 +651,10 @@ struct RefitWindow : public Window { continue; } - bool first_vehicle = this->list[current_index].Length() == 0; + bool first_vehicle = this->list[current_index].size() == 0; if (first_vehicle) { /* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */ - RefitOption *option = this->list[current_index].Append(); - option->cargo = cid; - option->subtype = 0xFF; - option->string = STR_EMPTY; + this->list[current_index].push_back({cid, 0xFF, STR_EMPTY}); } /* Check the vehicle's callback mask for cargo suffixes. @@ -689,16 +686,16 @@ struct RefitWindow : public Window { option.cargo = cid; option.subtype = refit_cyc; option.string = subtype; - this->list[current_index].Include(option); + include(this->list[current_index], option); } else { /* Intersect the subtypes of earlier vehicles with the subtypes of this vehicle */ if (subtype == STR_EMPTY) { /* No more subtypes for this vehicle, delete all subtypes >= refit_cyc */ SubtypeList &l = this->list[current_index]; /* 0xFF item is in front, other subtypes are sorted. So just truncate the list in the right spot */ - for (uint i = 1; i < l.Length(); i++) { + for (uint i = 1; i < l.size(); i++) { if (l[i].subtype >= refit_cyc) { - l.Resize(i); + l.resize(i); break; } } @@ -707,10 +704,10 @@ struct RefitWindow : public Window { /* Check whether the subtype matches with the subtype of earlier vehicles. */ uint pos = 1; SubtypeList &l = this->list[current_index]; - while (pos < l.Length() && l[pos].subtype != refit_cyc) pos++; - if (pos < l.Length() && l[pos].string != subtype) { + while (pos < l.size() && l[pos].subtype != refit_cyc) pos++; + if (pos < l.size() && l[pos].string != subtype) { /* String mismatch, remove item keeping the order */ - l.ErasePreservingOrder(pos); + l.erase(l.begin() + pos); } } } @@ -738,7 +735,7 @@ struct RefitWindow : public Window { uint row = 0; for (uint i = 0; i < NUM_CARGO; i++) { - for (uint j = 0; j < this->list[i].Length(); j++) { + for (uint j = 0; j < this->list[i].size(); j++) { const RefitOption &refit = this->list[i][j]; /* Hide subtypes if sel[0] does not match */ @@ -763,7 +760,7 @@ struct RefitWindow : public Window { uint row = 0; for (uint i = 0; i < NUM_CARGO; i++) { - for (uint j = 0; j < this->list[i].Length(); j++) { + for (uint j = 0; j < this->list[i].size(); j++) { const RefitOption &refit = this->list[i][j]; /* Hide subtypes if sel[0] does not match */ @@ -792,7 +789,7 @@ struct RefitWindow : public Window { if (this->sel[0] < 0) return NULL; SubtypeList &l = this->list[this->sel[0]]; - if ((uint)this->sel[1] >= l.Length()) return NULL; + if ((uint)this->sel[1] >= l.size()) return NULL; return &l[this->sel[1]]; } @@ -835,7 +832,7 @@ struct RefitWindow : public Window { } } - virtual void OnFocus(Window *previously_focused_window) + void OnFocus(Window *previously_focused_window) override { if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) { if (this->window_number != INVALID_VEHICLE) { @@ -846,7 +843,7 @@ struct RefitWindow : public Window { } } - virtual void OnFocusLost(Window *newly_focused_window) + void OnFocusLost(Window *newly_focused_window) override { if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) { if (this->window_number != INVALID_VEHICLE) { @@ -857,7 +854,7 @@ struct RefitWindow : public Window { } } - virtual void OnInit() + void OnInit() override { if (this->cargo != NULL) { /* Store the RefitOption currently in use. */ @@ -869,7 +866,7 @@ struct RefitWindow : public Window { this->sel[1] = 0; this->cargo = NULL; for (uint i = 0; this->cargo == NULL && i < NUM_CARGO; i++) { - for (uint j = 0; j < list[i].Length(); j++) { + for (uint j = 0; j < list[i].size(); j++) { if (list[i][j] == current_refit_option) { this->sel[0] = i; this->sel[1] = j; @@ -887,7 +884,7 @@ struct RefitWindow : public Window { } } - virtual void OnPaint() + void OnPaint() override { /* Determine amount of items for scroller. */ if (this->hscroll != NULL) this->hscroll->SetCount(this->vehicle_width); @@ -908,7 +905,7 @@ struct RefitWindow : public Window { this->DrawWidgets(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_VR_MATRIX: @@ -926,7 +923,7 @@ struct RefitWindow : public Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_VR_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); } @@ -978,7 +975,7 @@ struct RefitWindow : public Window { } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { @@ -999,14 +996,15 @@ struct RefitWindow : public Window { for (Train *u = Train::From(v); u != NULL; u = u->Next()) { /* Start checking. */ - if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) { + const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end(); + if (contained && left == INT32_MIN) { left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin; width = 0; } /* Draw a selection. */ - if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) { - if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) { + if ((!contained || u->Next() == NULL) && left != INT32_MIN) { + if (u->Next() == NULL && contained) { int current_width = u->GetDisplayImageWidth(); width += current_width; x += current_width; @@ -1060,7 +1058,7 @@ struct RefitWindow : 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 { switch (data) { case VIWD_AUTOREPLACE: // Autoreplace replaced the vehicle; selected_vehicle became invalid. @@ -1082,7 +1080,7 @@ struct RefitWindow : public Window { /* Check the width of all cargo information strings. */ for (uint i = 0; i < NUM_CARGO; i++) { - for (uint j = 0; j < this->list[i].Length(); j++) { + for (uint j = 0; j < this->list[i].size(); j++) { StringID string = this->GetCapacityString(&list[i][j]); if (string != INVALID_STRING_ID) { Dimension dim = GetStringBoundingBox(string); @@ -1168,7 +1166,7 @@ struct RefitWindow : public Window { } } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1213,7 +1211,7 @@ struct RefitWindow : public Window { } } - virtual void OnMouseDrag(Point pt, int widget) + void OnMouseDrag(Point pt, int widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1226,7 +1224,7 @@ struct RefitWindow : public Window { } } - virtual void OnDragDrop(Point pt, int widget) + void OnDragDrop(Point pt, int widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1239,7 +1237,7 @@ struct RefitWindow : public Window { } } - virtual void OnResize() + void OnResize() override { this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS); this->vscroll->SetCapacityFromWidget(this, WID_VR_MATRIX); @@ -1660,7 +1658,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left; int y = r.top; - uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.Length()); + uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size()); for (uint i = this->vscroll->GetPosition(); i < max; ++i) { const Vehicle *v = this->vehicles[i]; @@ -1877,7 +1875,7 @@ public: *this->sorting = this->vehicles.GetListing(); } - 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_VL_LIST: @@ -1915,7 +1913,7 @@ public: } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_VL_AVAILABLE_VEHICLES: @@ -1929,7 +1927,7 @@ public: case WID_VL_CAPTION: { switch (this->vli.type) { case VL_SHARED_ORDERS: // Shared Orders - if (this->vehicles.Length() == 0) { + if (this->vehicles.size() == 0) { /* We can't open this window without vehicles using this order * and we should close the window when deleting the order. */ NOT_REACHED(); @@ -1962,7 +1960,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { switch (widget) { case WID_VL_SORT_ORDER: @@ -1976,7 +1974,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { this->BuildVehicleList(); this->SortVehicleList(); @@ -1996,7 +1994,7 @@ public: if (this->owner == _local_company) { this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD); this->SetWidgetDisabledState(WID_VL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList()); - this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || (this->vli.type == VL_STANDARD && _settings_client.gui.disable_top_veh_list_mass_actions), + this->SetWidgetsDisabledState(this->vehicles.size() == 0 || (this->vli.type == VL_STANDARD && _settings_client.gui.disable_top_veh_list_mass_actions), WID_VL_STOP_ALL, WID_VL_START_ALL, WIDGET_LIST_END); @@ -2010,7 +2008,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_VL_SORT_ORDER: // Flip sorting method ascending/descending @@ -2029,7 +2027,7 @@ public: case WID_VL_LIST: { // Matrix to show vehicles uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST); - if (id_v >= this->vehicles.Length()) return; // click out of list bound + if (id_v >= this->vehicles.size()) return; // click out of list bound const Vehicle *v = this->vehicles[id_v]; if (!VehicleClicked(v)) ShowVehicleViewWindow(v); @@ -2055,7 +2053,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_VL_SORT_BY_PULLDOWN: @@ -2110,7 +2108,7 @@ public: this->SetDirty(); } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { DoCommandP(0, this->window_number, 0, CMD_CREATE_GROUP_FROM_LIST | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), NULL, str); } @@ -2159,7 +2157,7 @@ public: } } - virtual void OnGameTick() + void OnGameTick() override { if (this->vehicles.NeedResort()) { StationID station = (this->vli.type == VL_STATION_LIST) ? this->vli.index : INVALID_STATION; @@ -2169,7 +2167,7 @@ public: } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_VL_LIST); } @@ -2179,7 +2177,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 && HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) { /* Needs to be done in command-scope, so everything stays valid */ @@ -2192,7 +2190,7 @@ public: if (data == 0) { /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */ this->vehicles.ForceRebuild(); - if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.Length() == 1) { + if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.size() == 1) { delete this; return; } @@ -2391,7 +2389,7 @@ struct VehicleDetailsWindow : 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 (data == VIWD_AUTOREPLACE) { /* Autoreplace replaced the vehicle. @@ -2452,7 +2450,7 @@ struct VehicleDetailsWindow : Window { return HasBit(Train::From(v)->flags, VRF_HAVE_SLOT); } - 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_VD_TOP_DETAILS: { @@ -2584,12 +2582,12 @@ struct VehicleDetailsWindow : Window { } } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_VD_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -2760,7 +2758,7 @@ struct VehicleDetailsWindow : Window { } /** Repaint vehicle details window. */ - virtual void OnPaint() + void OnPaint() override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -2785,7 +2783,7 @@ struct VehicleDetailsWindow : 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_VD_RENAME_VEHICLE: { // rename @@ -2833,7 +2831,7 @@ struct VehicleDetailsWindow : Window { } } - virtual void OnDropdownSelect(int widget, int index) + void OnDropdownSelect(int widget, int index) override { switch (widget) { case WID_VD_SERVICE_INTERVAL_DROPDOWN: { @@ -2847,14 +2845,14 @@ struct VehicleDetailsWindow : Window { } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), NULL, str); } - virtual void OnResize() + void OnResize() override { NWidgetCore *nwi = this->GetWidget(WID_VD_MATRIX); if (nwi != NULL) { @@ -3200,7 +3198,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 { const Vehicle *v = Vehicle::Get(this->window_number); switch (widget) { @@ -3222,7 +3220,7 @@ public: } } - virtual void OnPaint() + void OnPaint() override { const Vehicle *v = Vehicle::Get(this->window_number); bool is_localcompany = v->owner == _local_company; @@ -3242,7 +3240,7 @@ public: this->DrawWidgets(); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget != WID_VV_CAPTION) return; @@ -3250,7 +3248,7 @@ public: SetDParam(0, v->index); } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_VV_START_STOP) return; @@ -3403,7 +3401,7 @@ public: DrawString(text_left + lowered, text_right + lowered, r.top + WD_FRAMERECT_TOP + lowered, str, TC_FROMSTRING, SA_HOR_CENTER); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -3439,10 +3437,10 @@ public: if (_ctrl_pressed) { OrderDepotActionFlags flags = v->current_order.GetDepotActionType() & (ODATFB_HALT | ODATFB_SELL); DropDownList *list = new DropDownList(); - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, DEPOT_SERVICE | DEPOT_DONT_CANCEL, !flags); - *list->Append() = new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_name[v->type], DEPOT_DONT_CANCEL, flags == ODATFB_HALT); - *list->Append() = new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_sell_name[v->type], DEPOT_SELL | DEPOT_DONT_CANCEL, flags == (ODATFB_HALT | ODATFB_SELL)); - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, DEPOT_CANCEL, false); + list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, DEPOT_SERVICE | DEPOT_DONT_CANCEL, !flags)); + list->push_back(new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_name[v->type], DEPOT_DONT_CANCEL, flags == ODATFB_HALT)); + list->push_back(new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_sell_name[v->type], DEPOT_SELL | DEPOT_DONT_CANCEL, flags == (ODATFB_HALT | ODATFB_SELL))); + list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, DEPOT_CANCEL, false)); ShowDropDownList(this, list, -1, widget, 0, true); } else { DoCommandP(v->tile, v->index | DEPOT_CANCEL, 0, GetCmdSendToDepot(v)); @@ -3486,7 +3484,6 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) OVERRIDE { switch (widget) { @@ -3551,7 +3548,7 @@ public: } } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_VV_VIEWPORT); @@ -3594,7 +3591,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 == VIWD_AUTOREPLACE) { /* Autoreplace replaced the vehicle. @@ -3605,12 +3602,12 @@ public: this->UpdateButtonStatus(); } - virtual bool IsNewGRFInspectable() const + bool IsNewGRFInspectable() const override { return ::IsNewGRFInspectable(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number); } - virtual void ShowNewGRFInspectWindow() const + void ShowNewGRFInspectWindow() const override { ::ShowNewGRFInspectWindow(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number); } diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 895a14b2c7..3b261e7cfe 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -38,7 +38,15 @@ enum VehicleInvalidateWindowData { VIWD_AUTOREPLACE = -4, ///< Autoreplace replaced the vehicle. }; -int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number); +/** Extra information about refitted cargo and capacity */ +struct TestedEngineDetails { + Money cost; ///< Refit cost + CargoID cargo; ///< Cargo type + uint16 capacity; ///< Cargo capacity + uint16 mail_capacity; ///< Mail capacity if available +}; + +int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te); void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE); void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip = 0); diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 0251ae62a5..df1e58b957 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -60,7 +60,7 @@ static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a n /** Pathfinding option states */ enum VehiclePathFinders { - VPF_OPF = 0, ///< The Original PathFinder (only for ships) + // Original PathFinder (OPF) used to be 0 VPF_NPF = 1, ///< New PathFinder VPF_YAPF = 2, ///< Yet Another PathFinder }; diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 005e52a74f..6237b088f5 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -71,8 +71,8 @@ bool VehicleListIdentifier::UnpackIfValid(uint32 data) */ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons) { - engines->Clear(); - if (wagons != NULL && wagons != engines) wagons->Clear(); + engines->clear(); + if (wagons != NULL && wagons != engines) wagons->clear(); const Vehicle *v; FOR_ALL_VEHICLES(v) { @@ -86,7 +86,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine if (t->IsArticulatedPart() || t->IsRearDualheaded()) continue; if (t->track != TRACK_BIT_DEPOT) continue; if (wagons != NULL && t->First()->IsFreeWagon()) { - if (individual_wagons || t->IsFreeWagon()) *wagons->Append() = t; + if (individual_wagons || t->IsFreeWagon()) wagons->push_back(t); continue; } break; @@ -99,13 +99,13 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine if (!v->IsPrimaryVehicle()) continue; - *engines->Append() = v; + engines->push_back(v); } /* Ensure the lists are not wasting too much space. If the lists are fresh * (i.e. built within a command) then this will actually do nothing. */ - engines->Compact(); - if (wagons != NULL && wagons != engines) wagons->Compact(); + engines->shrink_to_fit(); + if (wagons != NULL && wagons != engines) wagons->shrink_to_fit(); } /** @@ -116,14 +116,14 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine */ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli) { - list->Clear(); + list->clear(); const Vehicle *v; auto fill_all_vehicles = [&]() { FOR_ALL_VEHICLES(v) { if (!HasBit(v->subtype, GVSF_VIRTUAL) && v->type == vli.vtype && v->owner == vli.company && v->IsPrimaryVehicle()) { - *list->Append() = v; + list->push_back(v); } } }; @@ -137,7 +137,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli FOR_VEHICLE_ORDERS(v, order) { if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) && order->GetDestination() == vli.index) { - *list->Append() = v; + list->push_back(v); break; } } @@ -151,7 +151,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli if (v == NULL || v->type != vli.vtype || !v->IsPrimaryVehicle()) return false; for (; v != NULL; v = v->NextShared()) { - *list->Append() = v; + list->push_back(v); } break; @@ -160,7 +160,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli FOR_ALL_VEHICLES(v) { if (!HasBit(v->subtype, GVSF_VIRTUAL) && v->type == vli.vtype && v->IsPrimaryVehicle() && v->owner == vli.company && GroupIsInGroup(v->group_id, vli.index)) { - *list->Append() = v; + list->push_back(v); } } break; @@ -179,7 +179,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli FOR_VEHICLE_ORDERS(v, order) { if (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) && order->GetDestination() == vli.index) { - *list->Append() = v; + list->push_back(v); break; } } @@ -194,7 +194,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(vli.index); if (slot == NULL) return false; for (VehicleID id : slot->occupants) { - *list->Append() = Vehicle::Get(id); + list->push_back(Vehicle::Get(id)); } } break; @@ -202,13 +202,13 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli case VL_SINGLE_VEH: { v = Vehicle::GetIfValid(vli.index); - if (v != NULL) *list->Append() = v; + if (v != NULL) list->push_back(v); break; } default: return false; } - list->Compact(); + list->shrink_to_fit(); return true; } diff --git a/src/vehiclelist.h b/src/vehiclelist.h index 09bb4358fe..88b5ebb231 100644 --- a/src/vehiclelist.h +++ b/src/vehiclelist.h @@ -54,7 +54,7 @@ struct VehicleListIdentifier { }; /** A list of vehicles. */ -typedef SmallVector VehicleList; +typedef std::vector VehicleList; bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier); void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false); diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 960d7fb7c8..53a42393ee 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -440,12 +440,6 @@ const char *VideoDriver_Allegro::Start(const char * const *parm) signal(SIGSEGV, NULL); #endif -#if defined(DOS) - /* Force DOS builds to ALWAYS use full screen as - * it can't do windowed. */ - _fullscreen = true; -#endif - GetVideoModes(); if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) { return "Failed to set up Allegro video"; @@ -461,7 +455,7 @@ void VideoDriver_Allegro::Stop() if (--_allegro_instance_count == 0) allegro_exit(); } -#if defined(UNIX) || defined(__OS2__) || defined(DOS) +#if defined(UNIX) || defined(__OS2__) # include /* gettimeofday */ static uint32 GetTime() @@ -548,9 +542,6 @@ bool VideoDriver_Allegro::ChangeResolution(int w, int h) bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen) { -#ifdef DOS - return false; -#else _fullscreen = fullscreen; GetVideoModes(); // get the list of available video modes if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) { @@ -559,7 +550,6 @@ bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen) return false; } return true; -#endif } bool VideoDriver_Allegro::AfterBlitterChange() diff --git a/src/video/allegro_v.h b/src/video/allegro_v.h index a770635da0..f68ce5781d 100644 --- a/src/video/allegro_v.h +++ b/src/video/allegro_v.h @@ -17,30 +17,30 @@ /** The allegro video driver. */ class VideoDriver_Allegro : public VideoDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; - /* virtual */ void MainLoop(); + void MainLoop() override; - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; - /* virtual */ bool ToggleFullscreen(bool fullscreen); + bool ToggleFullscreen(bool fullscreen) override; - /* virtual */ bool AfterBlitterChange(); + bool AfterBlitterChange() override; - /* virtual */ bool ClaimMousePointer(); + bool ClaimMousePointer() override; - /* virtual */ const char *GetName() const { return "allegro"; } + const char *GetName() const override { return "allegro"; } }; /** Factory for the allegro video driver. */ class FVideoDriver_Allegro : public DriverFactoryBase { public: FVideoDriver_Allegro() : DriverFactoryBase(Driver::DT_VIDEO, 4, "allegro", "Allegro Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_Allegro(); } + Driver *CreateInstance() const override { return new VideoDriver_Allegro(); } }; #endif /* VIDEO_ALLEGRO_H */ diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index 564daefe0f..2614eef537 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -16,10 +16,10 @@ class VideoDriver_Cocoa : public VideoDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; /** Stop the video driver */ - /* virtual */ void Stop(); + void Stop() override; /** Mark dirty a screen region * @param left x-coordinate of left border @@ -27,44 +27,44 @@ public: * @param width width or dirty rectangle * @param height height of dirty rectangle */ - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; /** Programme main loop */ - /* virtual */ void MainLoop(); + void MainLoop() override; /** Change window resolution * @param w New window width * @param h New window height * @return Whether change was successful */ - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; /** Set a new window mode * @param fullscreen Whether to set fullscreen mode or not * @return Whether changing the screen mode was successful */ - /* virtual */ bool ToggleFullscreen(bool fullscreen); + bool ToggleFullscreen(bool fullscreen) override; /** Callback invoked after the blitter was changed. * @return True if no error. */ - /* virtual */ bool AfterBlitterChange(); + bool AfterBlitterChange() override; /** * An edit box lost the input focus. Abort character compositing if necessary. */ - /* virtual */ void EditBoxLostFocus(); + void EditBoxLostFocus() override; /** Return driver name * @return driver name */ - /* virtual */ const char *GetName() const { return "cocoa"; } + const char *GetName() const override { return "cocoa"; } }; class FVideoDriver_Cocoa : public DriverFactoryBase { public: FVideoDriver_Cocoa() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_Cocoa(); } + Driver *CreateInstance() const override { return new VideoDriver_Cocoa(); } }; diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 3b053c7d64..58d7d04e0b 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -11,8 +11,6 @@ #include "../stdafx.h" -#ifdef ENABLE_NETWORK - #include "../gfx_func.h" #include "../network/network.h" #include "../network/network_internal.h" @@ -316,5 +314,3 @@ void VideoDriver_Dedicated::MainLoop() } } } - -#endif /* ENABLE_NETWORK */ diff --git a/src/video/dedicated_v.h b/src/video/dedicated_v.h index 0c1477d66d..bdf873c3d7 100644 --- a/src/video/dedicated_v.h +++ b/src/video/dedicated_v.h @@ -17,19 +17,19 @@ /** The dedicated server video driver. */ class VideoDriver_Dedicated : public VideoDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; - /* virtual */ void MainLoop(); + void MainLoop() override; - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; - /* virtual */ bool ToggleFullscreen(bool fullscreen); - /* virtual */ const char *GetName() const { return "dedicated"; } - /* virtual */ bool HasGUI() const { return false; } + bool ToggleFullscreen(bool fullscreen) override; + const char *GetName() const override { return "dedicated"; } + bool HasGUI() const override { return false; } }; /** Factory for the dedicated server video driver. */ @@ -43,7 +43,7 @@ public: static const int PRIORITY = 0; #endif FVideoDriver_Dedicated() : DriverFactoryBase(Driver::DT_VIDEO, PRIORITY, "dedicated", "Dedicated Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_Dedicated(); } + Driver *CreateInstance() const override { return new VideoDriver_Dedicated(); } }; #endif /* VIDEO_DEDICATED_H */ diff --git a/src/video/null_v.h b/src/video/null_v.h index 9e04e177ef..a3b2cb5a81 100644 --- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -20,26 +20,26 @@ private: uint ticks; ///< Amount of ticks to run. public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; - /* virtual */ void MainLoop(); + void MainLoop() override; - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; - /* virtual */ bool ToggleFullscreen(bool fullscreen); - /* virtual */ const char *GetName() const { return "null"; } - /* virtual */ bool HasGUI() const { return false; } + bool ToggleFullscreen(bool fullscreen) override; + const char *GetName() const override { return "null"; } + bool HasGUI() const override { return false; } }; /** Factory the null video driver. */ class FVideoDriver_Null : public DriverFactoryBase { public: FVideoDriver_Null() : DriverFactoryBase(Driver::DT_VIDEO, 0, "null", "Null Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_Null(); } + Driver *CreateInstance() const override { return new VideoDriver_Null(); } }; #endif /* VIDEO_NULL_H */ diff --git a/src/video/sdl_v.h b/src/video/sdl_v.h index 8855c3566e..cafdbbc614 100644 --- a/src/video/sdl_v.h +++ b/src/video/sdl_v.h @@ -17,27 +17,27 @@ /** The SDL video driver. */ class VideoDriver_SDL : public VideoDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; - /* virtual */ void MainLoop(); + void MainLoop() override; - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; - /* virtual */ bool ToggleFullscreen(bool fullscreen); + bool ToggleFullscreen(bool fullscreen) override; - /* virtual */ bool AfterBlitterChange(); + bool AfterBlitterChange() override; - /* virtual */ void AcquireBlitterLock(); + void AcquireBlitterLock() override; - /* virtual */ void ReleaseBlitterLock(); + void ReleaseBlitterLock() override; - /* virtual */ bool ClaimMousePointer(); + bool ClaimMousePointer() override; - /* virtual */ const char *GetName() const { return "sdl"; } + const char *GetName() const override { return "sdl"; } private: int PollEvent(); bool CreateMainSurface(uint w, uint h); @@ -48,7 +48,7 @@ private: class FVideoDriver_SDL : public DriverFactoryBase { public: FVideoDriver_SDL() : DriverFactoryBase(Driver::DT_VIDEO, 5, "sdl", "SDL Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_SDL(); } + Driver *CreateInstance() const override { return new VideoDriver_SDL(); } }; #endif /* VIDEO_SDL_H */ diff --git a/src/video/win32_v.h b/src/video/win32_v.h index 7609d0422d..aa6bb7c0d5 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -17,29 +17,29 @@ /** The video driver for windows. */ class VideoDriver_Win32 : public VideoDriver { public: - /* virtual */ const char *Start(const char * const *param); + const char *Start(const char * const *param) override; - /* virtual */ void Stop(); + void Stop() override; - /* virtual */ void MakeDirty(int left, int top, int width, int height); + void MakeDirty(int left, int top, int width, int height) override; - /* virtual */ void MainLoop(); + void MainLoop() override; - /* virtual */ bool ChangeResolution(int w, int h); + bool ChangeResolution(int w, int h) override; - /* virtual */ bool ToggleFullscreen(bool fullscreen); + bool ToggleFullscreen(bool fullscreen) override; - /* virtual */ bool AfterBlitterChange(); + bool AfterBlitterChange() override; - /* virtual */ void AcquireBlitterLock(); + void AcquireBlitterLock() override; - /* virtual */ void ReleaseBlitterLock(); + void ReleaseBlitterLock() override; - /* virtual */ bool ClaimMousePointer(); + bool ClaimMousePointer() override; - /* virtual */ void EditBoxLostFocus(); + void EditBoxLostFocus() override; - /* virtual */ const char *GetName() const { return "win32"; } + const char *GetName() const override { return "win32"; } bool MakeWindow(bool full_screen); }; @@ -48,7 +48,7 @@ public: class FVideoDriver_Win32 : public DriverFactoryBase { public: FVideoDriver_Win32() : DriverFactoryBase(Driver::DT_VIDEO, 10, "win32", "Win32 GDI Video Driver") {} - /* virtual */ Driver *CreateInstance() const { return new VideoDriver_Win32(); } + Driver *CreateInstance() const override { return new VideoDriver_Win32(); } }; #endif /* VIDEO_WIN32_H */ diff --git a/src/viewport.cpp b/src/viewport.cpp index 9a928c0b71..d8170e240b 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -166,10 +166,10 @@ enum SpriteCombineMode { SPRITE_COMBINE_ACTIVE, ///< %Sprite combining is active. #AddSortableSpriteToDraw outputs child sprites. }; -typedef SmallVector TileSpriteToDrawVector; -typedef SmallVector StringSpriteToDrawVector; -typedef SmallVector ParentSpriteToDrawVector; -typedef SmallVector ChildScreenSpriteToDrawVector; +typedef std::vector TileSpriteToDrawVector; +typedef std::vector StringSpriteToDrawVector; +typedef std::vector ParentSpriteToDrawVector; +typedef std::vector ChildScreenSpriteToDrawVector; typedef std::vector > RankOrderTypeList; typedef std::map RouteStepsMap; @@ -193,15 +193,15 @@ struct LineSnapPoint : Point { uint8 dirs; ///< Allowed line directions, set of #Direction bits. }; -typedef SmallVector LineSnapPoints; ///< Set of snapping points +typedef std::vector LineSnapPoints; ///< Set of snapping points /** Coordinates of a polyline track made of 2 connected line segments. */ struct PolylineInfo { Point start; ///< The point where the first segment starts (as given in LineSnapPoint). Direction first_dir; ///< Direction of the first line segment. - uint first_len; ///< Length of the first segment - number of track pieces. + uint first_len; ///< size of the first segment - number of track pieces. Direction second_dir; ///< Direction of the second line segment. - uint second_len; ///< Length of the second segment - number of track pieces. + uint second_len; ///< size of the second segment - number of track pieces. }; /** Data structure storing rendering information */ @@ -607,13 +607,14 @@ static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y, { assert((image & SPRITE_MASK) < MAX_SPRITES); - TileSpriteToDraw *ts = _vd.tile_sprites_to_draw.Append(); - ts->image = image; - ts->pal = pal; - ts->sub = sub; + /*C++17: TileSpriteToDraw &ts = */ _vd.tile_sprites_to_draw.emplace_back(); + TileSpriteToDraw &ts = _vd.tile_sprites_to_draw.back(); + ts.image = image; + ts.pal = pal; + ts.sub = sub; Point pt = RemapCoords(x, y, z); - ts->x = pt.x + extra_offs_x; - ts->y = pt.y + extra_offs_y; + ts.x = pt.x + extra_offs_x; + ts.y = pt.y + extra_offs_y; } /** @@ -706,7 +707,7 @@ void OffsetGroundSprite(int x, int y) } /* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */ - if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.Length() - 1; + if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.size() - 1; _vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_LVL_BASE; _vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_LVL_BASE; @@ -735,8 +736,8 @@ static void AddCombinedSprite(SpriteID image, PaletteID pal, int x, int y, int z pt.y + spr->y_offs + spr->height <= _vd.dpi.top) return; - const ParentSpriteToDraw *pstd = _vd.parent_sprites_to_draw.End() - 1; - AddChildSpriteScreen(image, pal, pt.x - pstd->left, pt.y - pstd->top, false, sub, false); + const ParentSpriteToDraw &pstd = _vd.parent_sprites_to_draw.back(); + AddChildSpriteScreen(image, pal, pt.x - pstd.left, pt.y - pstd.top, false, sub, false); } /** @@ -816,29 +817,30 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, return; } - ParentSpriteToDraw *ps = _vd.parent_sprites_to_draw.Append(); - ps->x = tmp_x; - ps->y = tmp_y; + /*C++17: ParentSpriteToDraw &ps = */ _vd.parent_sprites_to_draw.emplace_back(); + ParentSpriteToDraw &ps = _vd.parent_sprites_to_draw.back(); + ps.x = tmp_x; + ps.y = tmp_y; - ps->left = tmp_left; - ps->top = tmp_top; + ps.left = tmp_left; + ps.top = tmp_top; - ps->image = image; - ps->pal = pal; - ps->sub = sub; - ps->xmin = x + bb_offset_x; - ps->xmax = x + max(bb_offset_x, w) - 1; + ps.image = image; + ps.pal = pal; + ps.sub = sub; + ps.xmin = x + bb_offset_x; + ps.xmax = x + max(bb_offset_x, w) - 1; - ps->ymin = y + bb_offset_y; - ps->ymax = y + max(bb_offset_y, h) - 1; + ps.ymin = y + bb_offset_y; + ps.ymax = y + max(bb_offset_y, h) - 1; - ps->zmin = z + bb_offset_z; - ps->zmax = z + max(bb_offset_z, dz) - 1; + ps.zmin = z + bb_offset_z; + ps.zmax = z + max(bb_offset_z, dz) - 1; - ps->comparison_done = false; - ps->first_child = -1; + ps.comparison_done = false; + ps.first_child = -1; - _vd.last_child = &ps->first_child; + _vd.last_child = &ps.first_child; if (_vd.combine_sprites == SPRITE_COMBINE_PENDING) _vd.combine_sprites = SPRITE_COMBINE_ACTIVE; } @@ -936,35 +938,37 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran pal = PALETTE_TO_TRANSPARENT; } - *_vd.last_child = _vd.child_screen_sprites_to_draw.Length(); + *_vd.last_child = _vd.child_screen_sprites_to_draw.size(); - ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); - cs->image = image; - cs->pal = pal; - cs->sub = sub; - cs->x = scale ? x * ZOOM_LVL_BASE : x; - cs->y = scale ? y * ZOOM_LVL_BASE : y; - cs->next = -1; + /*C++17: ChildScreenSpriteToDraw &cs = */ _vd.child_screen_sprites_to_draw.emplace_back(); + ChildScreenSpriteToDraw &cs = _vd.child_screen_sprites_to_draw.back(); + cs.image = image; + cs.pal = pal; + cs.sub = sub; + cs.x = scale ? x * ZOOM_LVL_BASE : x; + cs.y = scale ? y * ZOOM_LVL_BASE : y; + cs.next = -1; /* Append the sprite to the active ChildSprite list. * If the active ParentSprite is a foundation, update last_foundation_child as well. * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */ - if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs->next; - if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs->next; - _vd.last_child = &cs->next; + if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs.next; + if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs.next; + _vd.last_child = &cs.next; } static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width) { assert(width != 0); - StringSpriteToDraw *ss = _vd.string_sprites_to_draw.Append(); - ss->string = string; - ss->x = x; - ss->y = y; - ss->params[0] = params_1; - ss->params[1] = params_2; - ss->width = width; - ss->colour = colour; + /*C++17: StringSpriteToDraw &ss = */ _vd.string_sprites_to_draw.emplace_back(); + StringSpriteToDraw &ss = _vd.string_sprites_to_draw.back(); + ss.string = string; + ss.x = x; + ss.y = y; + ss.params[0] = params_1; + ss.params[1] = params_2; + ss.width = width; + ss.colour = colour; } @@ -1508,9 +1512,8 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv) { - const TileSpriteToDraw *tsend = tstdv->End(); - for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) { - DrawSpriteViewport(ts->image, ts->pal, ts->x, ts->y, ts->sub); + for (const TileSpriteToDraw &ts : *tstdv) { + DrawSpriteViewport(ts.image, ts.pal, ts.x, ts.y, ts.sub); } } @@ -1523,8 +1526,8 @@ static bool ViewportSortParentSpritesChecker() /** Sort parent sprites pointer array */ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) { - ParentSpriteToDraw **psdvend = psdv->End(); - ParentSpriteToDraw **psd = psdv->Begin(); + auto psdvend = psdv->end(); + auto psd = psdv->begin(); while (psd != psdvend) { ParentSpriteToDraw *ps = *psd; @@ -1535,7 +1538,7 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) ps->comparison_done = true; - for (ParentSpriteToDraw **psd2 = psd + 1; psd2 != psdvend; psd2++) { + for (auto psd2 = psd + 1; psd2 != psdvend; psd2++) { ParentSpriteToDraw *ps2 = *psd2; if (ps2->comparison_done) continue; @@ -1570,7 +1573,7 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) /* Move ps2 in front of ps */ ParentSpriteToDraw *temp = ps2; - for (ParentSpriteToDraw **psd3 = psd2; psd3 > psd; psd3--) { + for (auto psd3 = psd2; psd3 > psd; psd3--) { *psd3 = *(psd3 - 1); } *psd = temp; @@ -1580,14 +1583,12 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const ChildScreenSpriteToDrawVector *csstdv) { - const ParentSpriteToDraw * const *psd_end = psd->End(); - for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { - const ParentSpriteToDraw *ps = *it; + for (const ParentSpriteToDraw *ps : *psd) { if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSpriteViewport(ps->image, ps->pal, ps->x, ps->y, ps->sub); int child_idx = ps->first_child; while (child_idx >= 0) { - const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx); + const ChildScreenSpriteToDraw *cs = csstdv->data() + child_idx; child_idx = cs->next; DrawSpriteViewport(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); } @@ -1600,9 +1601,7 @@ static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const */ static void ViewportDrawBoundingBoxes(const ParentSpriteToSortVector *psd) { - const ParentSpriteToDraw * const *psd_end = psd->End(); - for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { - const ParentSpriteToDraw *ps = *it; + for (const ParentSpriteToDraw *ps : *psd) { Point pt1 = RemapCoords(ps->xmax + 1, ps->ymax + 1, ps->zmax + 1); // top front corner Point pt2 = RemapCoords(ps->xmin , ps->ymax + 1, ps->zmax + 1); // top left corner Point pt3 = RemapCoords(ps->xmax + 1, ps->ymin , ps->zmax + 1); // top right corner @@ -1632,15 +1631,16 @@ static void ViewportMapStoreBridgeTunnel(const ViewPort * const vp, const TileIn /* Check if already stored */ TunnelBridgeToMapVector * const tbtmv = tile_is_tunnel ? &_vd.tunnel_to_map : &_vd.bridge_to_map; - TunnelBridgeToMap *tbtm = tbtmv->Begin(); - const TunnelBridgeToMap * const tbtm_end = tbtmv->End(); + TunnelBridgeToMap *tbtm = tbtmv->data(); + const TunnelBridgeToMap * const tbtm_end = tbtmv->data() + tbtmv->size(); while (tbtm != tbtm_end) { if (tile == tbtm->from_tile || tile == tbtm->to_tile) return; tbtm++; } /* It's a new one, add it to the list */ - tbtm = tbtmv->Append(); + tbtmv->emplace_back(); + tbtm = &(tbtmv->back()); TileIndex other_end = GetOtherTunnelBridgeEnd(tile); /* ensure deterministic ordering, to avoid render flicker */ @@ -1655,15 +1655,15 @@ static void ViewportMapStoreBridgeTunnel(const ViewPort * const vp, const TileIn void ViewportMapClearTunnelCache() { - _vd.tunnel_to_map.Clear(); + _vd.tunnel_to_map.clear(); } void ViewportMapInvalidateTunnelCacheByTile(const TileIndex tile) { TunnelBridgeToMapVector * const tbtmv = &_vd.tunnel_to_map; - for (TunnelBridgeToMap *tbtm = tbtmv->Begin(); tbtm != tbtmv->End(); tbtm++) { + for (auto tbtm = tbtmv->begin(); tbtm != tbtmv->end(); tbtm++) { if (tbtm->from_tile == tile || tbtm->to_tile == tile) { - tbtmv->Erase(tbtm); + tbtmv->erase(tbtm); tbtm--; } } @@ -1693,38 +1693,37 @@ static void ViewportDrawDirtyBlocks() static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *sstdv) { - const StringSpriteToDraw *ssend = sstdv->End(); - for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) { + for (const StringSpriteToDraw &ss : *sstdv) { TextColour colour = TC_BLACK; - bool small = HasBit(ss->width, 15); - int w = GB(ss->width, 0, 15); - int x = UnScaleByZoom(ss->x, zoom); - int y = UnScaleByZoom(ss->y, zoom); + bool small = HasBit(ss.width, 15); + int w = GB(ss.width, 0, 15); + int x = UnScaleByZoom(ss.x, zoom); + int y = UnScaleByZoom(ss.y, zoom); int h = VPSM_TOP + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + VPSM_BOTTOM; - SetDParam(0, ss->params[0]); - SetDParam(1, ss->params[1]); + SetDParam(0, ss.params[0]); + SetDParam(1, ss.params[1]); - if (ss->colour != INVALID_COLOUR) { + if (ss.colour != INVALID_COLOUR) { /* Do not draw signs nor station names if they are set invisible */ - if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) continue; + if (IsInvisibilitySet(TO_SIGNS) && ss.string != STR_WHITE_SIGN) continue; - if (IsTransparencySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) { + if (IsTransparencySet(TO_SIGNS) && ss.string != STR_WHITE_SIGN) { /* Don't draw the rectangle. * Real colours need the TC_IS_PALETTE_COLOUR flag. * Otherwise colours from _string_colourmap are assumed. */ - colour = (TextColour)_colour_gradient[ss->colour][6] | TC_IS_PALETTE_COLOUR; + colour = (TextColour)_colour_gradient[ss.colour][6] | TC_IS_PALETTE_COLOUR; } else { /* Draw the rectangle if 'transparent station signs' is off, * or if we are drawing a general text sign (STR_WHITE_SIGN). */ DrawFrameRect( - x, y, x + w, y + h, ss->colour, + x, y, x + w, y + h, ss.colour, IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE ); } } - DrawString(x + VPSM_LEFT, x + w - 1 - VPSM_RIGHT, y + VPSM_TOP, ss->string, colour, SA_HOR_CENTER); + DrawString(x + VPSM_LEFT, x + w - 1 - VPSM_RIGHT, y + VPSM_TOP, ss.string, colour, SA_HOR_CENTER); } } @@ -2254,13 +2253,11 @@ static inline void ViewportMapStoreBridgeAboveTile(const ViewPort * const vp, co if (!_settings_client.gui.show_bridges_on_map) return; /* Check existing stored bridges */ - TunnelBridgeToMap *tbtm = _vd.bridge_to_map.Begin(); - TunnelBridgeToMap *tbtm_end = _vd.bridge_to_map.End(); - for (; tbtm != tbtm_end; ++tbtm) { - if (!IsBridge(tbtm->from_tile)) continue; + for (const TunnelBridgeToMap &tbtm : _vd.bridge_to_map) { + if (!IsBridge(tbtm.from_tile)) continue; - TileIndex from = tbtm->from_tile; - TileIndex to = tbtm->to_tile; + TileIndex from = tbtm.from_tile; + TileIndex to = tbtm.to_tile; if (TileX(from) == TileX(to) && TileX(from) == TileX(tile)) { if (TileY(from) > TileY(to)) std::swap(from, to); if (TileY(from) <= TileY(tile) && TileY(tile) <= TileY(to)) return; /* already covered */ @@ -2521,12 +2518,11 @@ void ViewportMapDraw(const ViewPort * const vp) } while (++j < h); /* Render tunnels */ - if (_settings_client.gui.show_tunnels_on_map && _vd.tunnel_to_map.Length() != 0) { - const TunnelBridgeToMap * const tbtm_end = _vd.tunnel_to_map.End(); - for (const TunnelBridgeToMap *tbtm = _vd.tunnel_to_map.Begin(); tbtm != tbtm_end; tbtm++) { // For each tunnel - const int tunnel_z = GetTileZ(tbtm->from_tile) * TILE_HEIGHT; - const Point pt_from = RemapCoords(TileX(tbtm->from_tile) * TILE_SIZE, TileY(tbtm->from_tile) * TILE_SIZE, tunnel_z); - const Point pt_to = RemapCoords(TileX(tbtm->to_tile) * TILE_SIZE, TileY(tbtm->to_tile) * TILE_SIZE, tunnel_z); + if (_settings_client.gui.show_tunnels_on_map && _vd.tunnel_to_map.size() != 0) { + for (const TunnelBridgeToMap &tbtm : _vd.tunnel_to_map) { // For each tunnel + const int tunnel_z = GetTileZ(tbtm.from_tile) * TILE_HEIGHT; + const Point pt_from = RemapCoords(TileX(tbtm.from_tile) * TILE_SIZE, TileY(tbtm.from_tile) * TILE_SIZE, tunnel_z); + const Point pt_to = RemapCoords(TileX(tbtm.to_tile) * TILE_SIZE, TileY(tbtm.to_tile) * TILE_SIZE, tunnel_z); /* check if tunnel is wholly outside redrawing area */ const int x_from = UnScaleByZoomLower(pt_from.x - _vd.dpi.left, _vd.dpi.zoom); @@ -2536,15 +2532,14 @@ void ViewportMapDraw(const ViewPort * const vp) const int y_to = UnScaleByZoomLower(pt_to.y - _vd.dpi.top, _vd.dpi.zoom); if ((y_from < 0 && y_to < 0) || (y_from > h && y_to > h)) continue; - ViewportMapDrawBridgeTunnel(vp, tbtm, tunnel_z, true, w, h, blitter); + ViewportMapDrawBridgeTunnel(vp, &tbtm, tunnel_z, true, w, h, blitter); } } /* Render bridges */ - if (_settings_client.gui.show_bridges_on_map && _vd.bridge_to_map.Length() != 0) { - const TunnelBridgeToMap * const tbtm_end = _vd.bridge_to_map.End(); - for (const TunnelBridgeToMap *tbtm = _vd.bridge_to_map.Begin(); tbtm != tbtm_end; tbtm++) { // For each bridge - ViewportMapDrawBridgeTunnel(vp, tbtm, (GetBridgeHeight(tbtm->from_tile) - 1) * TILE_HEIGHT, false, w, h, blitter); + if (_settings_client.gui.show_bridges_on_map && _vd.bridge_to_map.size() != 0) { + for (const TunnelBridgeToMap &tbtm : _vd.bridge_to_map) { // For each bridge + ViewportMapDrawBridgeTunnel(vp, &tbtm, (GetBridgeHeight(tbtm.from_tile) - 1) * TILE_HEIGHT, false, w, h, blitter); } } } @@ -2600,11 +2595,10 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom DrawTextEffects(&_vd.dpi); - if (_vd.tile_sprites_to_draw.Length() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); + if (_vd.tile_sprites_to_draw.size() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); - ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End(); - for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) { - *_vd.parent_sprites_to_sort.Append() = it; + for (auto &psd : _vd.parent_sprites_to_draw) { + _vd.parent_sprites_to_sort.push_back(&psd); } _vp_sprite_sorter(&_vd.parent_sprites_to_sort); @@ -2629,7 +2623,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom } if (_settings_client.gui.show_vehicle_route) ViewportMapDrawVehicleRoute(vp); - if (_vd.string_sprites_to_draw.Length() != 0) { + if (_vd.string_sprites_to_draw.size() != 0) { /* translate to world coordinates */ dp.left = UnScaleByZoom(_vd.dpi.left, zoom); dp.top = UnScaleByZoom(_vd.dpi.top, zoom); @@ -2640,12 +2634,12 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom _cur_dpi = old_dpi; - _vd.bridge_to_map.Clear(); - _vd.string_sprites_to_draw.Clear(); - _vd.tile_sprites_to_draw.Clear(); - _vd.parent_sprites_to_draw.Clear(); - _vd.parent_sprites_to_sort.Clear(); - _vd.child_screen_sprites_to_draw.Clear(); + _vd.bridge_to_map.clear(); + _vd.string_sprites_to_draw.clear(); + _vd.tile_sprites_to_draw.clear(); + _vd.parent_sprites_to_draw.clear(); + _vd.parent_sprites_to_sort.clear(); + _vd.child_screen_sprites_to_draw.clear(); } /** @@ -3815,12 +3809,17 @@ void UpdateTileSelection() * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip * @param close_cond Condition for closing this tooltip. */ -static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_LEFT_CLICK) +static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_NONE) { if (!_settings_client.gui.measure_tooltip) return; GuiShowTooltips(_thd.GetCallbackWnd(), str, paramcount, params, close_cond); } +static void HideMeasurementTooltips() +{ + DeleteWindowById(WC_TOOLTIPS, 0); +} + /** highlighting tiles while only going over them with the mouse */ void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process) { @@ -3881,7 +3880,11 @@ void VpSetPresizeRange(TileIndex from, TileIndex to) _thd.next_drawstyle = HT_RECT; /* show measurement only if there is any length to speak of */ - if (distance > 1) ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance, _settings_client.gui.hover_delay_ms == 0 ? TCC_NEXT_LOOP : TCC_HOVER); + if (distance > 1) { + ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance); + } else { + HideMeasurementTooltips(); + } } static void VpStartPreSizing() @@ -4044,7 +4047,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t return (int)(h1 - h0) * TILE_HEIGHT_STEP; } -static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_LEFT_CLICK, bool show_single_tile_length = false) +static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_NONE, bool show_single_tile_length = false) { static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF}; @@ -4478,10 +4481,10 @@ static HighLightStyle CalcPolyrailDrawstyle(Point pt, bool dragging) if (_current_snap_lock.x != -1) { snap_point = FindBestPolyline(pt, &_current_snap_lock, 1, &line); } else if (snap_mode == RSM_SNAP_TO_TILE) { - snap_point = FindBestPolyline(pt, _tile_snap_points.Begin(), _tile_snap_points.Length(), &line); + snap_point = FindBestPolyline(pt, _tile_snap_points.data(), _tile_snap_points.size(), &line); } else { assert(snap_mode == RSM_SNAP_TO_RAIL); - snap_point = FindBestPolyline(pt, _rail_snap_points.Begin(), _rail_snap_points.Length(), &line); + snap_point = FindBestPolyline(pt, _rail_snap_points.data(), _rail_snap_points.size(), &line); } if (snap_point == NULL) return HT_NONE; // no match @@ -4646,7 +4649,7 @@ calc_heightdiff_single_direction:; params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP; params[index++] = heightdiff; //Show always the measurement tooltip - GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_LEFT_CLICK); + GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_NONE); break; } @@ -4768,6 +4771,7 @@ EventState VpHandlePlaceSizingDrag() if (GetRailSnapMode() == RSM_SNAP_TO_TILE) SetRailSnapMode(RSM_NO_SNAP); if (_thd.drawstyle == HT_NONE) return ES_HANDLED; } + HideMeasurementTooltips(); w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); return ES_HANDLED; @@ -4806,7 +4810,10 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC * this function might in some cases reset the newly set object to * place or not properly reset the original selection. */ _thd.window_class = WC_INVALID; - if (w != NULL) w->OnPlaceObjectAbort(); + if (w != NULL) { + w->OnPlaceObjectAbort(); + HideMeasurementTooltips(); + } } /* Mark the old selection dirty, in case the selection shape or colour changes */ @@ -4917,12 +4924,8 @@ CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, ui if (_local_company != (CompanyID)p2) return CommandCost(); break; case VST_CLIENT: -#ifdef ENABLE_NETWORK if (_network_own_client_id != (ClientID)p2) return CommandCost(); break; -#else - return CommandCost(); -#endif default: return CMD_ERROR; } @@ -4979,12 +4982,11 @@ void StoreRailPlacementEndpoints(TileIndex start_tile, TileIndex end_tile, Track LineSnapPoint snap_start = LineSnapPointAtRailTrackEndpoint(start_tile, TrackdirToExitdir(exit_trackdir_at_start), bidirectional_exit); LineSnapPoint snap_end = LineSnapPointAtRailTrackEndpoint(end_tile, TrackdirToExitdir(exit_trackdir_at_end), bidirectional_exit); /* Find if we already had these coordinates before. */ - LineSnapPoint *snap; bool had_start = false; bool had_end = false; - for (snap = _rail_snap_points.Begin(); snap != _rail_snap_points.End(); snap++) { - had_start |= (snap->x == snap_start.x && snap->y == snap_start.y); - had_end |= (snap->x == snap_end.x && snap->y == snap_end.y); + for (const LineSnapPoint &snap : _rail_snap_points) { + had_start |= (snap.x == snap_start.x && snap.y == snap_start.y); + had_end |= (snap.x == snap_end.x && snap.y == snap_end.y); } /* Create new snap point set. */ if (had_start && had_end) { @@ -4992,9 +4994,9 @@ void StoreRailPlacementEndpoints(TileIndex start_tile, TileIndex end_tile, Track SetRailSnapMode(RSM_NO_SNAP); } else { /* include only new points */ - _rail_snap_points.Clear(); - if (!had_start) *_rail_snap_points.Append() = snap_start; - if (!had_end) *_rail_snap_points.Append() = snap_end; + _rail_snap_points.clear(); + if (!had_start) _rail_snap_points.push_back(snap_start); + if (!had_end) _rail_snap_points.push_back(snap_end); SetRailSnapMode(RSM_SNAP_TO_RAIL); } } @@ -5007,8 +5009,8 @@ bool CurrentlySnappingRailPlacement() static RailSnapMode GetRailSnapMode() { - if (_rail_snap_mode == RSM_SNAP_TO_TILE && _tile_snap_points.Length() == 0) return RSM_NO_SNAP; - if (_rail_snap_mode == RSM_SNAP_TO_RAIL && _rail_snap_points.Length() == 0) return RSM_NO_SNAP; + if (_rail_snap_mode == RSM_SNAP_TO_TILE && _tile_snap_points.size() == 0) return RSM_NO_SNAP; + if (_rail_snap_mode == RSM_SNAP_TO_RAIL && _rail_snap_points.size() == 0) return RSM_NO_SNAP; return _rail_snap_mode; } @@ -5023,26 +5025,26 @@ static void SetRailSnapMode(RailSnapMode mode) static TileIndex GetRailSnapTile() { - if (_tile_snap_points.Length() == 0) return INVALID_TILE; + if (_tile_snap_points.size() == 0) return INVALID_TILE; return TileVirtXY(_tile_snap_points[DIAGDIR_NE].x, _tile_snap_points[DIAGDIR_NE].y); } static void SetRailSnapTile(TileIndex tile) { - _tile_snap_points.Clear(); + _tile_snap_points.clear(); if (tile == INVALID_TILE) return; for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { - LineSnapPoint *point = _tile_snap_points.Append(); - *point = LineSnapPointAtRailTrackEndpoint(tile, dir, false); - point->dirs = ROR(point->dirs, DIRDIFF_REVERSE); + _tile_snap_points.push_back(LineSnapPointAtRailTrackEndpoint(tile, dir, false)); + LineSnapPoint &point = _tile_snap_points.back(); + point.dirs = ROR(point.dirs, DIRDIFF_REVERSE); } } void ResetRailPlacementSnapping() { _rail_snap_mode = RSM_NO_SNAP; - _tile_snap_points.Clear(); - _rail_snap_points.Clear(); + _tile_snap_points.clear(); + _rail_snap_points.clear(); _current_snap_lock.x = -1; } diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index cfbbfd742d..ce2d5c7322 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -86,7 +86,7 @@ public: this->viewport->map_type = (ViewportMapType) _settings_client.gui.default_viewport_map_mode; } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { switch (widget) { case WID_EV_CAPTION: @@ -96,7 +96,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_EV_ZOOM_IN: DoZoomInOutWindow(ZOOM_IN, this); break; @@ -126,7 +126,7 @@ public: } } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_EV_VIEWPORT); @@ -134,7 +134,7 @@ public: } } - virtual void OnScroll(Point delta) + void OnScroll(Point delta) override { this->viewport->scrollpos_x += ScaleByZoom(delta.x, this->viewport->zoom); this->viewport->scrollpos_y += ScaleByZoom(delta.y, this->viewport->zoom); @@ -142,7 +142,7 @@ public: this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; } - virtual void OnMouseWheel(int wheel) + void OnMouseWheel(int wheel) override { if (_ctrl_pressed) { /* Cycle through the drawing modes */ @@ -168,7 +168,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; /* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */ diff --git a/src/viewport_sprite_sorter.h b/src/viewport_sprite_sorter.h index 324ece3020..24241565e7 100644 --- a/src/viewport_sprite_sorter.h +++ b/src/viewport_sprite_sorter.h @@ -41,7 +41,7 @@ struct ParentSpriteToDraw { bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites }; -typedef SmallVector ParentSpriteToSortVector; +typedef std::vector ParentSpriteToSortVector; /** Type for method for checking whether a viewport sprite sorter exists. */ typedef bool (*VpSorterChecker)(); diff --git a/src/viewport_sprite_sorter_sse4.cpp b/src/viewport_sprite_sorter_sse4.cpp index fb78c51c86..212ff12e68 100644 --- a/src/viewport_sprite_sorter_sse4.cpp +++ b/src/viewport_sprite_sorter_sse4.cpp @@ -29,8 +29,8 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv) { const __m128i mask_ptest = _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0); - ParentSpriteToDraw ** const psdvend = psdv->End(); - ParentSpriteToDraw **psd = psdv->Begin(); + auto const psdvend = psdv->end(); + auto psd = psdv->begin(); while (psd != psdvend) { ParentSpriteToDraw * const ps = *psd; @@ -41,7 +41,7 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv) ps->comparison_done = true; - for (ParentSpriteToDraw **psd2 = psd + 1; psd2 != psdvend; psd2++) { + for (auto psd2 = psd + 1; psd2 != psdvend; psd2++) { ParentSpriteToDraw * const ps2 = *psd2; if (ps2->comparison_done) continue; @@ -85,7 +85,7 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv) /* Move ps2 in front of ps */ ParentSpriteToDraw * const temp = ps2; - for (ParentSpriteToDraw **psd3 = psd2; psd3 > psd; psd3--) { + for (auto psd3 = psd2; psd3 > psd; psd3--) { *psd3 = *(psd3 - 1); } *psd = temp; diff --git a/src/waypoint_base.h b/src/waypoint_base.h index 8d544a3b99..c11c2f2b2f 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -25,23 +25,23 @@ struct Waypoint FINAL : SpecializedStation { Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation(tile) { } ~Waypoint(); - void UpdateVirtCoord(); + void UpdateVirtCoord() override; - /* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const + inline bool TileBelongsToRailStation(TileIndex tile) const override { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index; } - /* virtual */ uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const; + uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override; - /* virtual */ void GetTileArea(TileArea *ta, StationType type) const; + void GetTileArea(TileArea *ta, StationType type) const override; - /* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const + uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override { return 1; } - /* virtual */ uint GetPlatformLength(TileIndex tile) const + uint GetPlatformLength(TileIndex tile) const override { return 1; } diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index d13df9a6a7..cde6d5e474 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -82,12 +82,12 @@ public: DeleteWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, this->owner, this->window_number).Pack(), false); } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_W_CAPTION) SetDParam(0, this->wp->index); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_W_CENTER_VIEW: // scroll to location @@ -118,7 +118,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; /* You can only change your own waypoints */ @@ -129,7 +129,7 @@ public: ScrollWindowToTile(this->GetCenterTile(), this, true); } - virtual void OnResize() + void OnResize() override { if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget(WID_W_VIEWPORT); @@ -140,7 +140,7 @@ public: } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str == NULL) return; diff --git a/src/widget_type.h b/src/widget_type.h index 33fb8bce08..0467630c9d 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -293,11 +293,11 @@ public: inline void SetDisabled(bool disabled); inline bool IsDisabled() const; - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); - /* virtual */ bool IsHighlighted() const; - /* virtual */ TextColour GetHighlightColour() const; - /* virtual */ void SetHighlighted(TextColour highlight_colour); + void FillNestedArray(NWidgetBase **array, uint length) override; + NWidgetCore *GetWidgetFromPos(int x, int y) override; + bool IsHighlighted() const override; + TextColour GetHighlightColour() const override; + void SetHighlighted(TextColour highlight_colour) override; NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget. Colours colour; ///< Colour of this widget. @@ -371,12 +371,12 @@ public: ~NWidgetContainer(); void Add(NWidgetBase *wid); - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); + void FillNestedArray(NWidgetBase **array, uint length) override; /** Return whether the container is empty. */ inline bool IsEmpty() { return head == NULL; } - /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp); + NWidgetBase *GetWidgetOfType(WidgetType tp) override; protected: NWidgetBase *head; ///< Pointer to first widget in container. @@ -408,12 +408,12 @@ public: void SetIndex(int index); - void SetupSmallestSize(Window *w, bool init_array); - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl); - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); + void SetupSmallestSize(Window *w, bool init_array) override; + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void FillNestedArray(NWidgetBase **array, uint length) override; - /* virtual */ void Draw(const Window *w); - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); + void Draw(const Window *w) override; + NWidgetCore *GetWidgetFromPos(int x, int y) override; void SetDisplayedPlane(int plane); @@ -437,8 +437,8 @@ public: void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); - /* virtual */ void Draw(const Window *w); - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); + void Draw(const Window *w) override; + NWidgetCore *GetWidgetFromPos(int x, int y) override; protected: NWidContainerFlags flags; ///< Flags of the container. @@ -500,12 +500,12 @@ public: void SetCount(int count); void SetScrollbar(Scrollbar *sb); - void SetupSmallestSize(Window *w, bool init_array); - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl); - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); + void SetupSmallestSize(Window *w, bool init_array) override; + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void FillNestedArray(NWidgetBase **array, uint length) override; - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); - /* virtual */ void Draw(const Window *w); + NWidgetCore *GetWidgetFromPos(int x, int y) override; + void Draw(const Window *w) override; protected: int index; ///< If non-negative, index in the #Window::nested_array. Colours colour; ///< Colour of this widget. @@ -530,12 +530,12 @@ class NWidgetSpacer : public NWidgetResizeBase { public: NWidgetSpacer(int length, int height); - void SetupSmallestSize(Window *w, bool init_array); - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); + void SetupSmallestSize(Window *w, bool init_array) override; + void FillNestedArray(NWidgetBase **array, uint length) override; - /* virtual */ void Draw(const Window *w); - /* virtual */ void SetDirty(const Window *w) const; - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); + void Draw(const Window *w) override; + void SetDirty(const Window *w) const override; + NWidgetCore *GetWidgetFromPos(int x, int y) override; }; /** @@ -550,14 +550,14 @@ public: void Add(NWidgetBase *nwid); void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); - void SetupSmallestSize(Window *w, bool init_array); - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl); + void SetupSmallestSize(Window *w, bool init_array) override; + void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; - /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); + void FillNestedArray(NWidgetBase **array, uint length) override; - /* virtual */ void Draw(const Window *w); - /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); - /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp); + void Draw(const Window *w) override; + NWidgetCore *GetWidgetFromPos(int x, int y) override; + NWidgetBase *GetWidgetOfType(WidgetType tp) override; private: NWidgetPIPContainer *child; ///< Child widget. @@ -576,8 +576,8 @@ class NWidgetViewport : public NWidgetCore { public: NWidgetViewport(int index); - /* virtual */ void SetupSmallestSize(Window *w, bool init_array); - /* virtual */ void Draw(const Window *w); + void SetupSmallestSize(Window *w, bool init_array) override; + void Draw(const Window *w) override; void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom); void UpdateViewportCoordinates(Window *w); @@ -751,8 +751,8 @@ class NWidgetScrollbar : public NWidgetCore, public Scrollbar { public: NWidgetScrollbar(WidgetType tp, Colours colour, int index); - /* virtual */ void SetupSmallestSize(Window *w, bool init_array); - /* virtual */ void Draw(const Window *w); + void SetupSmallestSize(Window *w, bool init_array) override; + void Draw(const Window *w) override; static void InvalidateDimensionCache(); static Dimension GetVerticalDimension(); @@ -771,8 +771,8 @@ class NWidgetLeaf : public NWidgetCore { public: NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip); - /* virtual */ void SetupSmallestSize(Window *w, bool init_array); - /* virtual */ void Draw(const Window *w); + void SetupSmallestSize(Window *w, bool init_array) override; + void Draw(const Window *w) override; bool ButtonHit(const Point &pt); diff --git a/src/widgets/build_vehicle_widget.h b/src/widgets/build_vehicle_widget.h index 7d1cd1cb19..ae548587e2 100644 --- a/src/widgets/build_vehicle_widget.h +++ b/src/widgets/build_vehicle_widget.h @@ -26,8 +26,6 @@ enum BuildVehicleWidgets { WID_BV_SHOW_HIDE, ///< Button to hide or show the selected engine. WID_BV_BUILD_SEL, ///< Build button. WID_BV_RENAME, ///< Rename button. - WID_BV_BUILD_REFIT, - WID_BV_BUILD_REFIT_SEL, }; #endif /* WIDGETS_BUILD_VEHICLE_WIDGET_H */ diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 217a843b9c..9966d30e70 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -152,7 +152,7 @@ struct DropdownWindow : Window { DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll, DropDownSyncFocus sync_parent_focus) : Window(&_dropdown_desc) { - assert(list->Length() > 0); + assert(list->size() > 0); this->position = position; this->parent_wnd_class = parent->window_class; @@ -178,14 +178,13 @@ struct DropdownWindow : Window { /* Total length of list */ int list_height = 0; - for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) { - const DropDownListItem *item = *it; + for (const DropDownListItem *item : *list) { list_height += item->Height(items_width); } /* Capacity is the average number of items visible */ - this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height); - this->vscroll->SetCount((uint16)list->Length()); + this->vscroll->SetCapacity(size.height * (uint16)list->size() / list_height); + this->vscroll->SetCount((uint16)list->size()); this->parent_button = button; this->list = list; @@ -235,13 +234,10 @@ struct DropdownWindow : Window { int width = nwi->current_x - 4; int pos = this->vscroll->GetPosition(); - const DropDownList *list = this->list; - - for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) { + for (const DropDownListItem *item : *this->list) { /* Skip items that are scrolled up */ if (--pos >= 0) continue; - const DropDownListItem *item = *it; int item_height = item->Height(width); if (y < item_height) { @@ -264,8 +260,7 @@ struct DropdownWindow : Window { int y = r.top + 2; int pos = this->vscroll->GetPosition(); - for (const DropDownListItem * const *it = this->list->Begin(); it != this->list->End(); ++it) { - const DropDownListItem *item = *it; + for (const DropDownListItem *item : *this->list) { int item_height = item->Height(r.right - r.left + 1); /* Skip items that are scrolled up */ @@ -410,8 +405,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b /* Total height of list */ uint height = 0; - for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) { - const DropDownListItem *item = *it; + for (const DropDownListItem *item : *list) { height += item->Height(width); if (auto_width) max_item_width = max(max_item_width, item->Width() + 5); } @@ -439,7 +433,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b /* If the dropdown doesn't fully fit, we need a dropdown. */ if (height > available_height) { scroll = true; - uint avg_height = height / list->Length(); + uint avg_height = height / list->size(); /* Check at least there is space for one item. */ assert(available_height >= avg_height); @@ -530,12 +524,12 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt for (uint i = 0; strings[i] != INVALID_STRING_ID; i++) { if (i >= 32 || !HasBit(hidden_mask, i)) { - *list->Append() = new DropDownListStringItem(strings[i], i, i < 32 && HasBit(disabled_mask, i)); + list->push_back(new DropDownListStringItem(strings[i], i, i < 32 && HasBit(disabled_mask, i))); } } /* No entries in the list? */ - if (list->Length() == 0) { + if (list->size() == 0) { delete list; return; } diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index c419095313..4e3352eb6c 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -51,9 +51,9 @@ public: DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} - virtual bool Selectable() const { return true; } - virtual uint Width() const; - virtual void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const; + bool Selectable() const override { return true; } + uint Width() const override; + void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override; virtual StringID String() const { return this->string; } static int CDECL NatSortFunc(const DropDownListItem * const *first, const DropDownListItem * const *second); @@ -68,8 +68,8 @@ public: DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} - virtual StringID String() const; - virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; } + StringID String() const override; + void SetParam(uint index, uint64 value) { decode_params[index] = value; } }; /** @@ -81,7 +81,7 @@ public: DropDownListCharStringItem(const char *raw_string, int result, bool masked) : DropDownListStringItem(STR_JUST_RAW_STRING, result, masked), raw_string(raw_string) {} - virtual StringID String() const; + StringID String() const override; }; /** @@ -105,7 +105,7 @@ public: /** * A drop down list is a collection of drop down list items. */ -typedef AutoDeleteSmallVector DropDownList; +typedef AutoDeleteSmallVector DropDownList; void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE); diff --git a/src/widgets/group_widget.h b/src/widgets/group_widget.h index 501411812d..a9bba84a7d 100644 --- a/src/widgets/group_widget.h +++ b/src/widgets/group_widget.h @@ -34,9 +34,6 @@ enum GroupListWidgets { WID_GL_DELETE_GROUP, ///< Delete group button. WID_GL_RENAME_GROUP, ///< Rename group button. WID_GL_LIVERY_GROUP, ///< Group livery button. - WID_GL_COLLAPSE_EXPAND_GROUP, ///< Collapse/expand group button. - WID_GL_COLLAPSE_ALL_GROUPS, ///< Collapse all groups button. - WID_GL_EXPAND_ALL_GROUPS, ///< Expand all groups button. WID_GL_REPLACE_PROTECTION, ///< Replace protection button. WID_GL_INFO, ///< Group info. }; diff --git a/src/window.cpp b/src/window.cpp index f434288af6..be0e4e5842 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -88,7 +88,7 @@ SpecialMouseMode _special_mouse_mode; ///< Mode of the mouse. * List of all WindowDescs. * This is a pointer to ensure initialisation order with the various static WindowDesc instances. */ -static SmallVector *_window_descs = NULL; +static std::vector *_window_descs = NULL; /** Config file to store WindowDesc */ char *_windows_file; @@ -111,13 +111,13 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi default_width_trad(def_width_trad), default_height_trad(def_height_trad) { - if (_window_descs == NULL) _window_descs = new SmallVector(); - *_window_descs->Append() = this; + if (_window_descs == NULL) _window_descs = new std::vector(); + _window_descs->push_back(this); } WindowDesc::~WindowDesc() { - _window_descs->Erase(_window_descs->Find(this)); + _window_descs->erase(std::find(_window_descs->begin(), _window_descs->end(), this)); } /** @@ -147,9 +147,9 @@ void WindowDesc::LoadFromConfig() { IniFile *ini = new IniFile(); ini->LoadFromDisk(_windows_file, NO_DIRECTORY); - for (WindowDesc **it = _window_descs->Begin(); it != _window_descs->End(); ++it) { - if ((*it)->ini_key == NULL) continue; - IniLoadWindowSettings(ini, (*it)->ini_key, *it); + for (WindowDesc *wd : *_window_descs) { + if (wd->ini_key == NULL) continue; + IniLoadWindowSettings(ini, wd->ini_key, wd); } delete ini; } @@ -169,13 +169,13 @@ static int CDECL DescSorter(WindowDesc * const *a, WindowDesc * const *b) void WindowDesc::SaveToConfig() { /* Sort the stuff to get a nice ini file on first write */ - QSortT(_window_descs->Begin(), _window_descs->Length(), DescSorter); + QSortT(_window_descs->data(), _window_descs->size(), DescSorter); IniFile *ini = new IniFile(); ini->LoadFromDisk(_windows_file, NO_DIRECTORY); - for (WindowDesc **it = _window_descs->Begin(); it != _window_descs->End(); ++it) { - if ((*it)->ini_key == NULL) continue; - IniSaveWindowSettings(ini, (*it)->ini_key, *it); + for (WindowDesc *wd : *_window_descs) { + if (wd->ini_key == NULL) continue; + IniSaveWindowSettings(ini, wd->ini_key, wd); } ini->SaveToDisk(_windows_file); delete ini; @@ -333,8 +333,8 @@ Scrollbar *Window::GetScrollbar(uint widnum) */ const QueryString *Window::GetQueryString(uint widnum) const { - const SmallMap::Pair *query = this->querystrings.Find(widnum); - return query != this->querystrings.End() ? query->second : NULL; + auto query = this->querystrings.Find(widnum); + return query != this->querystrings.end() ? query->second : NULL; } /** @@ -773,16 +773,17 @@ static void DispatchRightClickEvent(Window *w, int x, int y) NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y); if (wid == NULL) return; + Point pt = { x, y }; + /* No widget to handle, or the window is not interested in it. */ if (wid->index >= 0) { - Point pt = { x, y }; if (w->OnRightClick(pt, wid->index)) return; } /* Right-click close is enabled and there is a closebox */ if (_settings_client.gui.right_mouse_wnd_close && w->nested_root->GetWidgetOfType(WWT_CLOSEBOX)) { delete w; - } else if (_settings_client.gui.hover_delay_ms == 0 && wid->tool_tip != 0) { + } else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) { GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK); } } @@ -800,8 +801,10 @@ static void DispatchHoverEvent(Window *w, int x, int y) /* No widget to handle */ if (wid == NULL) return; + Point pt = { x, y }; + /* Show the tooltip if there is any */ - if (wid->tool_tip != 0) { + if (!w->OnTooltip(pt, wid->index, TCC_HOVER) && wid->tool_tip != 0) { GuiShowTooltips(w, wid->tool_tip); return; } @@ -809,7 +812,6 @@ static void DispatchHoverEvent(Window *w, int x, int y) /* Widget has no index, so the window is not interested in it. */ if (wid->index < 0) return; - Point pt = { x, y }; w->OnHover(pt, wid->index); } @@ -1949,8 +1951,8 @@ static void DecreaseWindowCounters() } /* Handle editboxes */ - for (SmallMap::Pair *it = w->querystrings.Begin(); it != w->querystrings.End(); ++it) { - it->second->HandleEditBox(w, it->first); + for (SmallMap::Pair &pair : w->querystrings) { + pair.second->HandleEditBox(w, pair.first); } w->OnMouseLoop(); @@ -3056,7 +3058,7 @@ void HandleMouseEvents() Blitter *blitter = BlitterFactory::GetCurrentBlitter(); _newgrf_debug_sprite_picker.clicked_pixel = blitter->MoveTo(_screen.dst_ptr, _cursor.pos.x, _cursor.pos.y); _newgrf_debug_sprite_picker.click_time = _realtime_tick; - _newgrf_debug_sprite_picker.sprites.Clear(); + _newgrf_debug_sprite_picker.sprites.clear(); _newgrf_debug_sprite_picker.mode = SPM_REDRAW; MarkWholeScreenDirty(); } else { @@ -3156,13 +3158,11 @@ void UpdateWindows() CallWindowRealtimeTickEvent(delta_ms); -#ifdef ENABLE_NETWORK static GUITimer network_message_timer = GUITimer(1); if (network_message_timer.Elapsed(delta_ms)) { network_message_timer.SetInterval(1000); NetworkChatMessageLoop(); } -#endif Window *w; @@ -3282,7 +3282,7 @@ void Window::InvalidateData(int data, bool gui_scope) this->SetDirty(); if (!gui_scope) { /* Schedule GUI-scope invalidation for next redraw. */ - *this->scheduled_invalidation_data.Append() = data; + this->scheduled_invalidation_data.push_back(data); } this->OnInvalidateData(data, gui_scope); } @@ -3292,10 +3292,11 @@ void Window::InvalidateData(int data, bool gui_scope) */ void Window::ProcessScheduledInvalidations() { - for (int *data = this->scheduled_invalidation_data.Begin(); this->window_class != WC_INVALID && data != this->scheduled_invalidation_data.End(); data++) { - this->OnInvalidateData(*data, true); + for (int data : this->scheduled_invalidation_data) { + if (this->window_class == WC_INVALID) break; + this->OnInvalidateData(data, true); } - this->scheduled_invalidation_data.Clear(); + this->scheduled_invalidation_data.clear(); } /** @@ -3483,10 +3484,9 @@ void ReInitAllWindows() FOR_ALL_WINDOWS_FROM_BACK(w) { w->ReInit(); } -#ifdef ENABLE_NETWORK + void NetworkReInitChatBoxSize(); NetworkReInitChatBoxSize(); -#endif /* Make sure essential parts of all windows are visible */ RelocateAllWindows(_cur_resolution.width, _cur_resolution.height); diff --git a/src/window_gui.h b/src/window_gui.h index e6b23f2bf2..c6b732e184 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -277,6 +277,15 @@ struct ViewportData : ViewPort { struct QueryString; +/* misc_gui.cpp */ +enum TooltipCloseCondition { + TCC_RIGHT_CLICK, + TCC_HOVER, + TCC_NONE, + TCC_HOVER_VIEWPORT, + TCC_NEXT_LOOP, +}; + struct WindowBase { WindowBase *z_front; ///< The window in front of us in z-order. WindowBase *z_back; ///< The window behind us in z-order. @@ -324,7 +333,7 @@ protected: void InitializePositionSize(int x, int y, int min_width, int min_height); virtual void FindWindowPlacementAndResize(int def_width, int def_height); - SmallVector scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls. + std::vector scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls. public: Window(WindowDesc *desc); @@ -677,12 +686,20 @@ public: virtual bool OnRightClick(Point pt, int widget) { return false; } /** - * The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip. + * The mouse is hovering over a widget in the window, perform an action for it. * @param pt The point where the mouse is hovering. * @param widget The widget where the mouse is hovering. */ virtual void OnHover(Point pt, int widget) {} + /** + * Event to display a custom tooltip. + * @param pt The point where the mouse is located. + * @param widget The widget where the mouse is located. + * @return True if the event is handled, false if it is ignored. + */ + virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) { return false; } + /** * An 'object' is being dragged at the provided position, highlight the target if possible. * @param pt The point inside the window that the mouse hovers over. @@ -918,15 +935,6 @@ Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_e void RelocateAllWindows(int neww, int newh); -/* misc_gui.cpp */ -enum TooltipCloseCondition { - TCC_RIGHT_CLICK, - TCC_LEFT_CLICK, - TCC_HOVER, - TCC_HOVER_VIEWPORT, - TCC_NEXT_LOOP, -}; - void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER); /* widget.cpp */