Commit Graph

20858 Commits

Author SHA1 Message Date
Rubidium a47de4b2ab Cleanup: remove DRAW_STRING_BUFFER constant 2023-06-06 18:08:11 +02:00
Rubidium 96fef9f643 Codechange: allocate enough memory to layout the strings 2023-06-06 18:08:11 +02:00
Rubidium 1fa432ca92 Codechange: replace C-style string building with C++-style building 2023-06-06 18:08:11 +02:00
Rubidium ca1e34c121 Codechange: use std::string to build ScriptText's encoded text 2023-06-06 18:07:54 +02:00
Rubidium e32f0aa20b Cleanup: minimum string length for town name generator is not needed anymore 2023-06-05 23:26:12 +02:00
Rubidium edb21620ea Cleanup: remove unneeded checks on remaining buffer size 2023-06-05 23:26:12 +02:00
Rubidium affceea0ae Codechange: switch StringBuilder to use std::string as backend 2023-06-05 23:26:12 +02:00
Rubidium ce8933d63e Add: std::back_insert_iterator<std::string> Utf8Encode function 2023-06-05 23:26:12 +02:00
Rubidium 55dfca1936 Codechange: replace seprintf with C++ style formatting 2023-06-05 23:25:59 +02:00
Rubidium fbd71a9d72 Codechange: replace C-style string processing with C++-style for the listing callbacks 2023-06-05 23:25:49 +02:00
translators 433ec6b5bd Update: Translations from eints
korean: 2 changes by telk5093
russian: 2 changes by Ln-Wolf
finnish: 2 changes by hpiirai
turkish: 2 changes by EndChapter
french: 2 changes by glx22
portuguese: 2 changes by azulcosta
2023-06-05 18:42:37 +00:00
PeterN 64d6ad50f9
Codechange: Split GetItem with GetOrCreateItem. (#10952)
`IniGroup::GetItem()` returns nullptr if the item does not exist, but does not if the create parameter is set to true. Resolve CodeQL warnings with `GetOrCreateItem()` which returns a reference to the item instead.
2023-06-05 18:29:52 +00:00
Patric Stout 3b1407d240
Feature: allow to do a hostile takeover of an AI company (in singleplayer) (#10914)
With the removal of the share-system, you could no longer make an
AI disappear in a single player game. At least, not without going
into the console.
2023-06-05 19:32:22 +02:00
PeterN f814c86389
Codechange: Reorganise hotkey initialisation. (#10951)
Hotkeys are now initialized inline, and use std::vector instead of
separate static C-arrays and std::string instead of char *. The list end
marker is no longer required.
2023-06-05 18:12:30 +01:00
rubidium42 921f5afc4d Codechange: Apply suggestions from code review 2023-06-05 17:07:39 +02:00
Rubidium 2dd2b698d2 Codechange: convert C-style GetTownName API to std::string returning API 2023-06-05 17:07:39 +02:00
Rubidium 14915526ad Cleanup: remove stre-style GetString 2023-06-05 11:23:31 +02:00
Patric Stout 772729cc7d
Fix: when syncing width of GUI items, take padding into account (#10915) 2023-06-05 10:27:04 +02:00
Rubidium 15c75e6f45 Codechange: use std::array and std::string for high scores 2023-06-04 23:49:43 +02:00
Rubidium c158089eff Codechange: use C++ style methods to combine a Utf8Encoded character and a formatted string 2023-06-04 23:32:02 +02:00
PeterN 6ae6b65edb
Cleanup: Remove doubled statements. (#10944) 2023-06-04 21:54:44 +01:00
Rubidium a4bf45729a Change: move string validation (and assignment) to textbuf 2023-06-04 21:43:07 +02:00
Rubidium 4e39a58c59 Codechange: let town name generation use StringBuilder 2023-06-04 21:42:59 +02:00
translators 6a5ab4a9fb Update: Translations from eints
french: 3 changes by glx22
2023-06-04 18:57:10 +00:00
Rubidium 820fe8c621 Codechange: use std::string and concatenation when combining multiple formatted strings 2023-06-04 20:47:41 +02:00
Patric Stout 07add7a96e
Fix: [Win32] position window in center of workspace of primary display (#10942) 2023-06-04 18:38:16 +00:00
PeterN 83a318edcf
Fix dec7ff6b0c: Dropdowns would close if their tooltip appeared. (#10939)
Solution is to not focus any tooltips, so that the dropdown doesn't lose focus. Tooltips don't accept any input so this does not change their behaviour.
2023-06-04 18:15:24 +00:00
rubidium42 bfcb027cb9
Fix 2dffa7d: fmt::format_to copies the iterator, so some text does not remain during formatting (#10940) 2023-06-04 19:55:47 +02:00
Rubidium 6a519f5d89 Cleanup: strecat has no uses anymore 2023-06-04 19:45:42 +02:00
Bernard Teo 2c667b1773
Doc: Fix spelling error in ScriptTileList::RemoveRectangle (#10937) 2023-06-04 17:45:18 +00:00
Patric Stout caa0474d30
Fix: crash with tooltip on low resolution screens (#10933) 2023-06-04 16:28:58 +00:00
Rubidium 36aaa9d683 Codechange: let GetStringWithArgs use StringBuilder 2023-06-04 18:00:23 +02:00
Jonathan G Rennison ec7f9f63f6 Feature: Add coverage button to waypoint window 2023-06-04 16:54:48 +01:00
Jonathan G Rennison d7bf6b2c07 Feature: Highlight waypoint tiles when adjacent or distant joining 2023-06-04 16:54:48 +01:00
Jonathan G Rennison 84b53213af Codechange: Refactor viewport catchment overlay change handling 2023-06-04 16:54:48 +01:00
Patric Stout 0f3dd9c796
Fix: crash when window can't be placed on low resolution screens. (#10932)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2023-06-04 15:39:57 +00:00
Patric Stout c43a23cea8
Fix: crash when not even a single row fits for dropdowns on low resolution screens (#10934) 2023-06-04 15:07:18 +00:00
PeterN ee2d0745e9
Fix #10502: Refit engine before attaching free wagons. (#10926)
Caused by incorrect order of operations when buying a train engine with refit and attaching free wagons.
2023-06-04 15:57:36 +01:00
Rubidium 87ccff16b5 Codechange: use std::string for the screenshot name/path 2023-06-04 16:53:10 +02:00
Patric Stout 0e56a73fb8
Fix: disable hardware acceleration when GPU driver crashed the game last attempt (#10928) 2023-06-04 14:40:17 +00:00
Rubidium 556b44713e Codechange: use std::string for midi filenames 2023-06-04 15:57:05 +02:00
Rubidium 84037d4a57 Codechange: use std::string for parameters in the dbg_helpers 2023-06-04 15:56:53 +02:00
Rubidium 2dffa7d0c6 Codechange: let FormatString use StringBuilder 2023-06-04 15:06:52 +02:00
Rubidium 993f90b6a0 Codechange: let GenerateDefaultSaveName return std::string 2023-06-04 14:11:13 +02:00
PeterN ac1d042550
Remove: obsolete NewGRF text unprinting. (#10884)
Co-authored-by: Rubidium <rubidium@openttd.org>
2023-06-04 13:14:56 +02:00
Patric Stout 6b1c38e303
Fix 3effb893: mention GSAsyncMode in changelog (#10924) 2023-06-04 11:10:22 +00:00
Rubidium c384d829fe Codechange: let number formatting use StringBuilder 2023-06-04 12:24:37 +02:00
Rubidium ed51cf117a Add: helper output iterator for formatting strings 2023-06-04 12:24:37 +02:00
Jonathan G Rennison 3effb8931c
Add: [Script] GSAsyncMode to set async mode of gamescript commands (#10913)
In asynchronous mode, don't wait for result of executed command,
just fire-and-forget, and return estimated cost/result
2023-06-04 11:15:35 +02:00
Patric Stout 5821194ad1
Add: [Linux] change default scroll mode to non-mouse-lock (#10920)
Wayland doesn't support mouse warping, X11 only for native
systems (so not for remote desktop, WSLg, etc), and emscripten
neither without complications. All these cannot offer a
mouse-lock.
2023-06-04 00:10:21 +00:00
Patric Stout 0d840b4570 Codechange: remove queue_wrap / last_position from mouse movement
No backend uses it anymore, so also no longer any need to support
it.
2023-06-04 00:40:56 +02:00
Patric Stout e83f244750 Codechange: simplify UpdateCursorPositionRelative
The function is only called with fix_at=true, so don't support
the other cases.
2023-06-04 00:40:56 +02:00
Patric Stout a969a78f81 Fix: [SDL] unify the way X11 and Wayland handle mouse events
Basically, we drop RelativeMode completely, and use the same trick
as used by the Windows driver: read all motion events till the last
one, and use that as value.
2023-06-04 00:40:56 +02:00
PeterN 8a2d550904
Codechange: Use std::reverse instead of custom implementation. (#10918) 2023-06-03 23:25:01 +01:00
Jonathan G Rennison a2c0e6aa18
Fix #10831: Level crossing parts left barred after crossing tile removal (#10874) 2023-06-03 23:04:24 +02:00
Patric Stout cd751a598a
Fix: Wayland crash on startup due to Pango also using FontConfig (#10916)
Basically, we haven't been a good neighbour. Turns out you shouldn't
actually call FcFini when you are done, as some library might still
want to use FontConfig. And they use a shared instance for their
administration.

The idea is that you call FcInit once, and use FcConfigReference
after that to get an instance, you can release. This entry is
ref-counted, and things happen automatically based on that.

At least, I think.
2023-06-03 19:09:02 +00:00
Patric Stout 21adfa7567
Fix: track "memory installed" for surveys less precisely (#10910)
It turns out, for Windows and Linux having the exact memory allows
for easy tracing of an individual. That is exactly against the idea
of the survey. And honestly, we don't need this precision.
2023-06-03 19:07:56 +00:00
translators 7d6aff3a34 Update: Translations from eints
french: 16 changes by ottdfevr
2023-06-03 18:42:31 +00:00
Rubidium d68b5c9162 Codechange: replace buffer + strecpy with std::string for getting clipboard contents 2023-06-03 20:14:33 +02:00
Rubidium 35f7f7e8dc Codechange: use std::string for executing the console aliases 2023-06-03 18:15:55 +02:00
Peter Nelson 2e62682f73 Codechange: Close dropdowns by class instead of id. 2023-06-03 14:17:05 +01:00
Peter Nelson 2511649938 Codechange: Use window parent association for dropdowns.
This replaces the separate window class and number properties, and
allows the window system to close dropdowns automatically.
2023-06-03 14:17:05 +01:00
Peter Nelson dec7ff6b0c Fix: Make dropdowns self-close when losing focus. 2023-06-03 14:17:05 +01:00
PeterN a5a3a07005
Fix: GRF Parameters not displayed due to scope issue. (#10911)
Move params so it is still in scope when the text is actually drawn.
2023-06-03 11:07:59 +00:00
Rubidium 513ede7669 Codechange: use C++ strings/paths to resolve links in tars 2023-06-02 21:06:24 +02:00
Rubidium 0ab7bc7a2b Codechange: use fmt::format to create type prefixed driver names 2023-06-02 18:05:41 +02:00
Rubidium 37a3fc4df3 Codechange: replace strstr with more appropriate function 2023-06-02 17:11:08 +02:00
Rubidium 53f83c31b0 Codechange: use std::string to return the debug level information 2023-06-02 17:07:18 +02:00
Rubidium 10e12154f5 Fix: false positive warning in fmt library (backport ef55d4f of upstream fmt) 2023-06-02 11:57:23 +02:00
Rubidium 802d6cb509 Fix: memory leak when parsing (strgen) commands by moving to C++ containers 2023-06-02 11:57:23 +02:00
Rubidium 4f94655cc2 Codechange: use vector/unorder_map over custom implementation 2023-06-02 11:57:23 +02:00
Rubidium 234a143ee5 Codechange: use std::string for LangString over C-style strings 2023-06-02 11:57:23 +02:00
Rubidium f372373e6f Codechange: use std::string/vector for language cases over manual management 2023-06-02 11:57:23 +02:00
Rubidium 6eb51666bc Codechange: use C++ file APIs for writing language files 2023-06-02 11:57:23 +02:00
PeterN 0b663f709d
Codechange: Sprite mapping for objects doesn't involve cargo types. (#10905)
Objects have a default sprite group and an optional purchase list sprite
group. There is no need to pretend that these are cargo IDs.
2023-06-02 08:25:13 +00:00
Jonathan G Rennison cdb3a6288b Codechange: Remove unused CapacitiesMap typedef from struct Vehicle 2023-06-01 22:48:47 +02:00
Patric Stout 9eda419f9b
Fix 646a7e62: recalc_time was not scaled properly (#10901)
This caused "runtime" to underflow or, if you are lucky, hit an
assert in ScaleToMonthly when it hits zero. But mostly underflow.
2023-06-01 12:21:33 +00:00
translators b5b004e518 Update: Translations from eints
ukrainian: 117 changes by alextov
2023-05-31 18:42:26 +00:00
Rubidium f29606fd14 Codechange: use std::string to cache engine/group/vehicle names 2023-05-31 19:31:09 +02:00
Rubidium d9f8a4c380 Codechange: use std::string GetString variant 2023-05-31 19:31:09 +02:00
Rubidium 324c43eeb2 Codechange: let FiosGetDiskFreeSpace only return disk space and split FiosGetCurrentPath off 2023-05-31 10:56:33 +02:00
Rubidium f2e704b9a7 Codechange: use std::string for FiosIsRoot 2023-05-31 10:56:33 +02:00
Rubidium 13789d1703 Codechange: use std::string for FiosIsValidFile 2023-05-31 10:56:33 +02:00
PeterN 1ff0dc11d8
Fix: Land info window maximum width was not scaled. (#10894) 2023-05-31 08:54:39 +00:00
Patric Stout 0302e6f168
Codechange: initialize all values of ICURun on construction (#10892) 2023-05-30 19:17:30 +00:00
translators c8b70e4877 Update: Translations from eints
ukrainian: 53 changes by alextov
portuguese (brazilian): 1 change by ericandradex
2023-05-30 18:40:56 +00:00
translators e1203c3a48 Update: Translations from eints
esperanto: 51 changes by legoscia
2023-05-29 18:39:22 +00:00
PeterN d086f288cd
Codechange: Remove duplicated includes. (#10888)
These are now included by stdafx.h so don't need to be included again.
2023-05-29 14:29:00 +01:00
PeterN 702194cfef
Change: Cargo flow legend only shows defined cargo. (#10872)
This removes the large mostly-empty grid of cargo buttons when not using a complex industry set.
2023-05-29 06:48:43 +01:00
translators c9c6721a47 Update: Translations from eints
esperanto: 44 changes by legoscia
2023-05-28 18:42:42 +00:00
Peter Nelson bae1897826 Change: Include font style in font name for Freetype. 2023-05-27 20:40:25 +01:00
Peter Nelson 9976293c1e Codechange: Return fontcache font name as std::string. 2023-05-27 20:40:25 +01:00
translators 90fdf17e39 Update: Translations from eints
esperanto: 28 changes by legoscia
2023-05-27 18:40:39 +00:00
Loïc Guilloux c880157518
Fix: Check max member count in squirrel classes (#10883)
Manual cherry-pick from 23a0620658
2023-05-27 16:09:21 +00:00
PeterN 8ea9c1a133
Fix #10880: Crash in object window due to incorrect parameter order. (#10881) 2023-05-26 21:29:52 +00:00
PeterN 876871157f
Fix: Ask FontConfig for the face index when opening fonts. (#10878)
This allows selection of the correct face in truetype fonts containing
multiple faces.
2023-05-26 18:56:13 +00:00
PeterN 101e4e54a1
Fix d9a04ba446: Ensure MD5Hash is initialized. (#10876)
Not all instances need to be initialized as often they are copied or
written to, but doing all ensures no surprises.

Move the ^= operator to MD5Hash while we're at it.
2023-05-26 18:17:54 +00:00
Jonathan G Rennison ba11467c02 Fix: Rail waypoint selection window not closed
When rail toolbar or rail waypoint build windows closed
2023-05-26 08:41:13 +02:00
PeterN 584faaf064
Change: Reorganise industry accept/produce arrays. (#10853)
Use a array of struct for each cargo instead of an array for each statistic.
This makes iterating for acceptance and production much simpler.
pct_transported is now calculated when needed.
2023-05-25 21:25:46 +01:00
Loïc Guilloux db3b086a52
Fix #10867, 8b93e45: Squirrel compile error exception type changed (#10869) 2023-05-25 12:46:27 +02:00
Rubidium b133328737 Codechange: use std::string over strecat to create the RV capacity string 2023-05-25 05:43:00 +02:00
Rubidium 4fdde00e25 Codechange: use std::string to create the GRF parameter list 2023-05-25 05:43:00 +02:00
Rubidium fbab94eabb Codechange: use std::string to create error message about external files 2023-05-25 05:43:00 +02:00
Rubidium 30b9e02dd9 Codechange: replace crashlog filenames with std::string in Crashlog 2023-05-25 05:42:10 +02:00
Rubidium 19304bd3d5 Codechange: replace seprintf with fmt::format for filling the crash log data 2023-05-25 05:42:10 +02:00
Rubidium f4b0ac2bd4 Codechange: use std::string for formatting settings 2023-05-24 22:42:01 +02:00
translators 1412ea48ed Update: Translations from eints
esperanto: 268 changes by legoscia
2023-05-24 18:40:52 +00:00
Peter Nelson 09408e8e46 Codechange: Add IsCargoAccepted/Produced() helpers. 2023-05-24 17:34:11 +01:00
Peter Nelson 633f19419d Codechange: Make more use of GetCargoAccepted/ProducedIndex(). 2023-05-24 17:34:11 +01:00
Rubidium 29b20718ba Codechange: use Tthis instead of StrongTypedef, so ==/= does not compare/assign different strong typedefs 2023-05-23 20:46:32 +02:00
translators 9f0e406a51 Update: Translations from eints
esperanto: 18 changes by legoscia
2023-05-23 18:41:14 +00:00
Peter Nelson 8931e90302 Cleanup: No need to cound actual cargo to get scroll count. 2023-05-23 19:07:36 +01:00
Peter Nelson f177ce7c9a Codechange: Base CargoArray off std::array.
This avoids needing to define array accessors and allows use of
default value initialization.
2023-05-23 19:07:36 +01:00
Peter Nelson 74e42e39a8 Codechange: Use CargoArray::GetCount() 2023-05-23 19:07:36 +01:00
Peter Nelson 76516d7f70 Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Peter Nelson c4ca6a0f74 Codechange: Rename IsCargo..Valid to IsValidCargo..
This better fits our naming pattern for this type of function.
2023-05-22 20:43:40 +01:00
translators e2827d0e9c Update: Translations from eints
galician: 41 changes by pvillaverde
esperanto: 95 changes by legoscia
portuguese (brazilian): 18 changes by ericandradex
2023-05-22 18:40:22 +00:00
Rubidium a19a43a4f7 Codechange: use fmt::format and time conversions over "custom" implementation 2023-05-22 15:36:09 +02:00
Rubidium eb635b85bb Fix: work around GCC compiler bug #105120 in fmt
The fmt code pushes a pragma option, and later pops is. The intrinsics code
interacts with it via the __OPTIMIZE__ macro. This has been set by the pragma
option push, but not unset/reset to the original with the pop.
Since the pragma is only used for the GCC compiler (not Clang, not MSVC, not
ICC) and in debug mode, just remove the whole pragma handling for it.
2023-05-22 14:42:18 +02:00
Rubidium 187fa3f214 Codechange: update to fmt 10.0.0 and add formatting support for chrono and std types 2023-05-22 14:42:18 +02:00
Rubidium 6f2f38b3ed Codechange: fmt (and std::format) do explicitly not support enums out-of-the-box
That it works for the version we have packaged it pure coincidence, as that is
one of the few versions that due to a bug allow it. So add the appropriate
template specialisations to support it out-of-the-box within OpenTTD.
2023-05-22 14:42:18 +02:00
PeterN bc45c3f66c
Change: Remember waypoint filter string. (#10857) 2023-05-22 08:03:20 +01:00
Rubidium 63d9bb93b8 Codechange: migrate from C-style GetString to C++-style GetString 2023-05-21 21:17:12 +02:00
Rubidium 1a179cb297 Codechange: use GetString + StrMakeValid to pass string without colours/font sizes to Debug 2023-05-21 21:17:12 +02:00
Rubidium 00695c29de Codechange: simplify news string drawing by using StrMakeValid to replaces newlines with spaces 2023-05-21 21:17:12 +02:00
translators 9610705f46 Update: Translations from eints
esperanto: 52 changes by legoscia
2023-05-21 18:40:42 +00:00
axet 60540f7df6 Change: Allow dedicated server to use threaded saves. (#10787)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2023-05-21 19:55:12 +02:00
Rubidium 2efd88d513 Cleanup: version of strgen/settingsgen was always $Revision$, so remove it 2023-05-21 19:39:09 +02:00
Rubidium 2dbd974d4c Codechange: prevent using (f)printf/(f)puts over fmt::print 2023-05-21 15:12:02 +02:00
Rubidium 411379f587 Codechange: replace puts with fmt::print 2023-05-21 15:12:02 +02:00
Rubidium 275ebf4509 Codechange: replace fprintf(<FILE*> with fmt::print(<FILE*> 2023-05-21 15:12:02 +02:00
Rubidium c518293135 Codechange: replace printf with fmt::print 2023-05-21 15:12:02 +02:00
Tyler Trahan d57046e7ec
Change: Use "Via-Destination-Source" as default station cargodist display (#10851) 2023-05-21 08:57:14 -04:00
Patric Stout 0850193a38
Fix: survey result on crash only worked on Linux (#10855)
Every OS-specific crashlog handler has their own MakeCrashLog
in some form. In result, only Linux was calling the generic one.
2023-05-21 12:57:32 +02:00
translators 98dffc3157 Update: Translations from eints
catalan: 12 changes by J0anJosep
esperanto: 678 changes by legoscia
2023-05-20 18:39:31 +00:00
Rubidium 3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02:00
Rubidium 80d8c01814 Codechange: replace std::vector + duplicate preventing include with std::set 2023-05-20 16:53:10 +02:00
Rubidium 07860e67e2 Codechange: use fmt::format_to to format the help message 2023-05-20 16:50:03 +02:00
Loïc Guilloux 8d2a0a7da4
Fix #10846: [Squirrel] Ensure sqvector size does not overflow (#10848) 2023-05-20 14:43:22 +00:00
PeterN 0cbbfd3eae
Codechange: Use display list instead of exclude list for file window. (#10845)
This simplifies retrieving the correct data for each row when data is
filtered. The background FileList is left intact so that savegame data
does not have to be rescanned when the filter is changed, and sorting
still remains the task of the background FileList.
2023-05-19 21:19:00 +00:00
translators cdb184f53b Update: Translations from eints
catalan: 14 changes by J0anJosep
dutch: 14 changes by Afoklala
2023-05-19 18:39:30 +00:00
Peter Nelson 6b87fe6540 Codechange: Use std::array for GRF(File|Config) parameters.
This simplifies comparison, copying and assignment operations.
2023-05-19 16:53:56 +01:00
Peter Nelson c23aae96a2 Codechange: Use std::array instead of C array for automatic deep-copies. 2023-05-19 16:53:56 +01:00
Rubidium acec34a0fe Cleanup: remove MD5SumToString in lieu of FormatArrayAsHex 2023-05-19 11:24:44 +02:00
Rubidium d9a04ba446 Codechange: make the MD5 hash/digest/checksum variables a std::array 2023-05-19 11:24:44 +02:00
Peter Nelson 7934418133 Codechange: Remove comment alignment from GRFConfig. 2023-05-18 20:48:37 +01:00
Peter Nelson f14479d27d Codechange: Use std::optional for GRF Parameter list. 2023-05-18 20:48:37 +01:00
Peter Nelson c51a7f629e Codechange: GRFParameterInfo no longer needs deep-copy constructor. 2023-05-18 20:48:37 +01:00
translators fd26658558 Update: Translations from eints
russian: 2 changes by Ln-Wolf
2023-05-18 18:41:14 +00:00
Peter Nelson 91e140c722 Codechange: Use unique_ptr for fios company properties.
This is the data used to show company names in the saveload window.
2023-05-18 12:18:30 +01:00
Peter Nelson bf8f24f9a8 Codechange: Use unique_ptr for text layout font mapping.
This must stay a pointer as the value passed to other structures.
2023-05-18 12:18:30 +01:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Peter Nelson 72018badff Codechange: Swap SocketList map key/value around.
This map is used store socket and address together, and, other than
checking that the address does not already have a socket, the data layout
does not seem particularly important.

However, as address is the key, technically it should not be modified,
and address may self-modify itself during comparisons.
2023-05-18 12:18:30 +01:00
Peter Nelson f454ec8d63 Fix: Don't rely on static initialization to set up sprite font caches.
The order of static initialization is undefined, so this can cause initalization
before relevant caches are initializations.
2023-05-18 12:18:30 +01:00
translators 418888ac23 Update: Translations from eints
romanian: 11 changes by bnegrut
turkish: 14 changes by densxd
2023-05-17 18:40:23 +00:00
Peter Nelson 83f2ad500e Codechange: stdarg.h include not needed as cstdarg is included. 2023-05-17 10:14:41 +01:00
Peter Nelson 56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
translators a5cf362886 Update: Translations from eints
english (au): 14 changes by krysclarke
english (us): 14 changes by 2TallTyler
vietnamese: 14 changes by KhoiCanDev
korean: 19 changes by telk5093
italian: 14 changes by Rivarossi
russian: 14 changes by Ln-Wolf
finnish: 14 changes by hpiirai
danish: 22 changes by bscargo
portuguese: 14 changes by azulcosta
polish: 14 changes by pAter-exe
2023-05-16 18:41:59 +00:00
Rubidium e9c03f0dad Cleanup: remnants of C-style strings in saveload 2023-05-16 18:32:52 +02:00
Rubidium 52a7c69974 Codechange: rework Gamelog changes from union to classes 2023-05-16 18:32:52 +02:00
translators 389b66bd16 Update: Translations from eints 2023-05-15 18:40:31 +00:00
PeterN 40f567d464
Fix #10811: Crash getting row from non-resizable widget. (#10833)
GetScrolled*FromWidget took line height from the widget's resize_y value,
however not all widgets are resizable, resulting in a division-by-zero.

Allow passing line height explicitly in cases where a widget is not
resizable.
2023-05-15 18:57:50 +01:00
PeterN e4fd9d41d3
Codechange: Use std::any_of() (#10830)
When the result of std::find_if is compared only with end()
then '!= end()' is replaced with any_of().

Just... there's only one.
2023-05-14 23:18:52 +01:00
Patric Stout 199e41c762
Codechange: use default dtor instead of empty (#10826) 2023-05-14 23:31:03 +02:00
Patric Stout 7634553d22 Feature: opt-in survey when exiting a game
On first start-up, the game will ask if you want to participate
in our automated survey. You have to opt-in, and can easily opt-out
(via the Options) at any time.

When opt-in, whenever you exit a game, a JSON blob will be send
to the survey server hosted by OpenTTD. This JSON blob contains
information that gives a global picture of the game just played:
- What settings were used
- How many humans vs AIs
- How long the game has been played
- Basic information about the OS / CPU

All this information is kept very generic, so there is no
chance we send private information to our survey server.
Nothing in the JSON blob could identify you as a person; it
mostly tells about the game played. At any time you can see
what the JSON blob includes, by pressing the "Preview Survey
Results" button in-game.
2023-05-14 23:22:02 +02:00
Rubidium 62fda0f505 Codechange: remove manual allocation/free for SQ_instance 2023-05-14 22:54:10 +02:00
Rubidium f9b5bc7ee6 Cleanup: the need for SQAutoFreePointers has gone 2023-05-14 22:54:10 +02:00
Rubidium d9e93edc8b Codechange: replace 'const char *' script API parameters with std::string 2023-05-14 22:54:10 +02:00
Rubidium b1b578f988 Cleanup: stredup-ing string variant for calling scripts 2023-05-14 22:54:10 +02:00
Rubidium ab51175db2 Codechange: use std::string for script config 2023-05-14 22:54:10 +02:00
Rubidium bbcb55ebc9 Codechange: use std::string as script API return type 2023-05-14 22:54:10 +02:00
Rubidium b24a6bb8f3 Codechange: use std::string for script log calls 2023-05-14 22:54:10 +02:00
Rubidium 77177f7e8b Add: support for std::string parameters in the script API 2023-05-14 22:54:10 +02:00
Rubidium 98972a0748 Codechange: use C++ strings for constructing script file paths 2023-05-14 22:54:10 +02:00
Rubidium 20ff0bccd7 Codechange: use std::string to store script GUI's break string 2023-05-14 22:54:10 +02:00
Rubidium 48825e1a8e Codechange: rewrite script string-to-settings conversion to C++ 2023-05-14 22:54:10 +02:00
Rubidium 552d2f71a2 Codechange: use std::string for script library category 2023-05-14 22:54:10 +02:00
Rubidium e035705239 Codechange: introduce and use std::string variant of sq_throwerror 2023-05-14 22:54:10 +02:00
Rubidium 3453c03a17 Codechange: use fmt::format to create dummy scripts 2023-05-14 22:54:10 +02:00
Rubidium 9f2fc860ad Codechange: use std::optional<std::string> for changing the script over char * 2023-05-14 22:54:10 +02:00
Rubidium 0fd9eb0faa Codechange: use std::string for script info/library finding 2023-05-14 22:54:10 +02:00
Rubidium a30f7c83bd Codechange: use std::string for script names to load 2023-05-14 22:54:10 +02:00
Rubidium 9b0123ab66 Codechange: use std::string for script API versions 2023-05-14 22:54:10 +02:00
Rubidium 3d8d99ba11 Add: method to call script functions with std::string 2023-05-14 22:54:10 +02:00
Rubidium 4a6fdc8293 Fix: multiplication result converted to larger type
Technically unlikely to happen, though uint16 * uint16 get promoted to int and
then stored as uint64; similarly uint * uint16 remains uint and gets stored as
uint64. In both cases the value can get truncated before the change to uint64.
2023-05-14 22:09:58 +02:00
PeterN 4894da67da
Codechange: Pass bridge type instead of display row to BuildBridge. (#10828) 2023-05-14 19:12:26 +00:00
translators a8daf91eea Update: Translations from eints
vietnamese: 4 changes by KhoiCanDev
hungarian: 74 changes by PstasDev
turkish: 4 changes by densxd
2023-05-14 18:40:47 +00:00
Patric Stout 8493719cf4
Fix: padding miscalculated for the network-relay and bootstrap-question GUI (#10827) 2023-05-14 15:32:45 +00:00
PeterN 9eb0cca93a
Fix #10823, Fix #10811: Order list has end marker row. (#10825) 2023-05-14 13:04:59 +01:00
PeterN 64930c343a
Codechange: Pass reference instead of pointer to GUI*Lists. (#10822)
Pointer-avoidance.
2023-05-14 09:17:44 +01:00
PeterN 23ce42ad91
Codechange: Use std::move for bridge list. (#10821)
This follows the pattern for dropdown lists, and avoids new/delete and pointers.
2023-05-14 08:22:09 +01:00
PeterN 385b25df63
Fix #10819, Fix #10811: GetVehicleFromDepotWndPt used widget- instead of window-relative positions. (#10820)
Pass window-relative positions instead, and adjust for relative positions where needed within the function itself. This simplifies calling code.
2023-05-13 22:18:36 +00:00
PeterN 07473bfd2e
Fix: Don't use a loop to test if classid is valid. (#10818)
Additionally the Object class test was broken.
2023-05-13 21:27:32 +00:00
Patric Stout 1fe7bbba8a
Codechange: rework NewGRFProfiler to use ticks instead of calendar-days (#10815)
We are planning to allow things like freezing the calendar, which
makes this variable a bit problemetic. So instead, suggest to the
user how many ticks there are in a calendar day, and let them figure
out how many ticks they want.

Additionally, use a TimeoutTimer for this, instead of an end-date
variable which is checked in an IntervalTimer.
2023-05-13 23:17:11 +02:00
Rubidium a372c59483 Codechange: replace C-style (stredup) chat completion with std::string_view 2023-05-13 22:33:27 +02:00
translators e1b653137f Update: Translations from eints
finnish: 4 changes by hpiirai
2023-05-13 18:41:08 +00:00
Peter Nelson a92755de81 Codechange: Use iterator erase pattern. 2023-05-13 19:18:01 +01:00
Peter Nelson 4a64064c57 Codechange: Make NEW_STATION an actual item in join station list.
Add NEW_STATION to the nearby station list to indicate that a new
station should be built. This removes special-casing for a non-existant
list item and keeps the list count and scrollbar count the same.
2023-05-13 19:18:01 +01:00
Patric Stout d54660184a
Fix: NewGRF Profile didn't stop if there were no events yet (#10816)
This meant you could have the following situation:
- You start a profile on a GRF with no events, for N days.
- The days pass, the profile should stop. It doesn't.
- The profile will never stop, even if the GRF start generating events.
- There is no real way to discover this, so .. byebye memory? :)
2023-05-13 18:23:23 +02:00
Peter Nelson 531d1ae8bc Codechange: Use GetScrolled(Row/Item)FromWidget in more places.
In many instances the clicked row position is 'manually' calculated
instead of using the GetScrolledRowFromWidget helper function, with
variations on checks. Replace with the two helpers where possible.
2023-05-12 21:45:32 +01:00