Jonathan G Rennison
3b18877b87
Fix #11629 : AirportGetNearestTown for rotated airports ( #11631 )
...
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
2023-12-28 21:43:05 +00:00
Peter Nelson
33ff64ef74
Codechange: Simplify ConvertDateToYMD by returning YearMonthDay instead of outputting to a pointer. ( #11637 )
2023-12-28 21:34:08 +00:00
Loïc Guilloux
2d3af14181
Add: Horizontal scroll for script debug log ( #11597 )
2023-12-20 22:50:03 +01:00
Peter Nelson
0ca4b4e146
Change: Allow opening multiple script debug windows by holding Ctrl.
2023-12-20 20:39:07 +00:00
Tyler Trahan
e8d2ebb016
Fix: Add missing includes to timers from script implementation files ( #11604 )
2023-12-19 14:09:46 +00:00
SamuXarick
fddcaef74a
Codechange: Use town zone constants instead of magic numbers
2023-12-18 22:12:43 +01:00
Loïc Guilloux
7726f8f245
Fix: [Script] Properly store the previous AsyncMode state ( #11587 )
2023-12-14 21:29:44 +00:00
Peter Nelson
bbf3028f89
Fix #11585 : Crash when cleaning AI/GS with nested AsyncMode.
...
Do not throw sanity check when in_shutdown is true. This is also applied to
ExecMode and TestMode as they follow the same pattern.
2023-12-14 20:54:31 +00:00
Peter Nelson
c0ea0589b4
Fix: AirportGetNearestTown incorrectly assumed first TileIterator result was origin. ( #11565 )
...
Not all TileIterators are equal, and some do not start at the top-corner, so the perimeter check was wrong. As the caller already has thie origin tile, use that instead.
2023-12-09 09:47:41 +00:00
Peter Nelson
7b0afec11f
Codechange: Use max_element to find highest cargo amount.
2023-11-28 22:30:48 +00:00
Peter Nelson
3f853d8003
Codechange: Use range-for to simplify getting first non-zero value.
...
This reduces indexed array access.
2023-11-28 22:30:48 +00:00
Peter Nelson
ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. ( #11445 )
...
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +00:00
Peter Nelson
9602de474d
Codechange: Use iterators and/or range-for on cargo related loops.
2023-10-19 17:03:25 +01:00
Peter Nelson
49dae08a3b
Codechange: Add missing override specifiers.
2023-09-25 21:27:45 +01:00
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Patric Stout
ba67f39db6
Codechange: vendor the nlohmann-json library ( #11290 )
2023-09-13 16:11:34 +02:00
PeterN
acd7d3c913
Codechange: Rename *Railtype* to *RailType* for consistency. ( #11287 )
2023-09-11 08:55:12 +00:00
Tyler Trahan
701a61c9af
Codechange: Delete date_type.h
2023-09-10 08:40:25 -04:00
Tyler Trahan
77173a6a10
Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes
2023-09-10 08:40:25 -04:00
Tyler Trahan
fca2b37726
Codechange: Move Ticks into their own class
2023-09-10 08:40:25 -04:00
Patric Stout
30172fc037
Codechange: cleanup CargoPacket in terms of variable/function names ( #11278 )
...
Over the years, things got reused and changed, making the current
names somewhat unclear in what they actually mean and do.
2023-09-09 23:21:21 +02:00
Patric Stout
00f13282a9
Codechange: keep how we convert string <-> JSON private ( #11269 )
2023-09-08 19:03:10 +02:00
Patric Stout
5f9b8aaa95
Codechange: [Script] use nlohmann for Squirrel <-> JSON conversion ( #11251 )
2023-09-06 13:14:12 +02:00
Michael Lutz
0089323542
Add: [Script] Custom news message text for industry SetProductionLevel.
2023-09-02 16:20:59 +02:00
Michael Lutz
1c56991213
Add: [Script] Game script control of industry production level.
2023-09-02 16:20:59 +02:00
Patric Stout
7afd686541
Codechange: add tests for GS <-> AdminPort JSON conversion ( #11252 )
...
While at it, fix a bug where booleans were made integers.
2023-08-31 19:38:15 +00:00
Patric Stout
993e7be707
Fix: [Script] GSAdmin.Send() could generate invalid JSON ( #11250 )
2023-08-31 16:52:52 +00:00
Joan Josep
5e6b5d981f
Codechange: Use existing functions in GetMonthlyInfrastructureCosts. ( #11237 )
2023-08-27 22:12:44 +02:00
Patric Stout
07730584d7
Codechange: make explicit when a TileIndex is cast to its basetype ( #11190 )
...
This prevents people accidentially assigning a TileIndex to a Date
or any other type they shouldn't.
2023-08-15 18:12:05 +02:00
Patric Stout
299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed ( #10761 )
2023-08-12 18:14:21 +00:00
Andy
ce9305a5ee
Add: [Script] GSIndustry.GetConstructionDate() method ( #11145 )
2023-07-20 20:35:37 +02:00
Rubidium
eaae0bb5e7
Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
...
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Rubidium
af9b9327af
Codechange: do not keep local variable for temporary string parameters
2023-07-03 18:08:03 +02:00
Rubidium
78f5d58dc6
Codechange: use std::string without const as return
...
Otherwise some compilers, e.g. MSVC, do not pick up that these are temporaries
and as such it will pass the temporaries to `const std::string &` instead of
the wanted `std::string &&`
2023-07-03 18:08:03 +02:00
PeterN
2a2443dd01
Feature: Create group of vehicles from manage vehicle list button. ( #10890 )
2023-06-18 20:48:04 +01:00
Rubidium
d4c2043294
Codechange: remove a number of unneeded c_str() calls
2023-06-15 22:14:45 +02:00
Loïc Guilloux
1cd49bf5e5
Fix ca1e34c: [Script] Wrong value printed for {RAW_STRING} ( #11011 )
2023-06-14 22:07:11 +00:00
mrmbernardi
35ef6c1723
Feature: [GS] Goal destination can be updated ( #10817 )
2023-06-08 18:00:31 +01:00
Rubidium
2ae7367024
Codechange: replace StrMakeValidInPlace with StrValid
2023-06-08 18:29:44 +02:00
Rubidium
ca1e34c121
Codechange: use std::string to build ScriptText's encoded text
2023-06-06 18:07:54 +02: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
Bernard Teo
2c667b1773
Doc: Fix spelling error in ScriptTileList::RemoveRectangle ( #10937 )
2023-06-04 17:45:18 +00:00
Patric Stout
6b1c38e303
Fix 3effb893: mention GSAsyncMode in changelog ( #10924 )
2023-06-04 11:10:22 +00: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
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
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
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
Peter Nelson
76516d7f70
Codechange: Use IsValidCargoID/IsValidCargoType.
...
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Rubidium
63d9bb93b8
Codechange: migrate from C-style GetString to C++-style GetString
2023-05-21 21:17:12 +02:00
Peter Nelson
56085be9bd
Codechange: Move includes for common STL headers to stdafx.
2023-05-17 10:14:41 +01:00
Patric Stout
199e41c762
Codechange: use default dtor instead of empty ( #10826 )
2023-05-14 23:31:03 +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
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
e035705239
Codechange: introduce and use std::string variant of sq_throwerror
2023-05-14 22:54:10 +02:00
Peter Nelson
726d05b22b
Fix: Don't list unavailable road types for game scripts.
2023-05-12 21:03:13 +02:00
Peter Nelson
e6740046ee
Codechange: Use range-for iteration.
2023-05-11 07:58:55 +01:00
Rubidium
12085d088c
Cleanup: remove obsolete string_compare_type
2023-05-09 23:14:48 +02:00
Rubidium
bc389a86c9
Codechange: use std::string as std::map key, instead of stredup string
2023-05-09 23:14:48 +02:00
Peter Nelson
bf9caa425b
Change: Units-system can convert from N to kN, don't preconvert.
...
This allows force to passed as is and avoid premature rounding.
The AI function "GetMaxTractiveEffort" still needs to return kN to avoid breaking the API.
2023-05-09 23:02:51 +02:00
Rubidium
68ff3fd062
Change: include fmt.h C++ headers in stdafx.h
...
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Rubidium
fb856e16c1
Codechange: replace some min/clamp constructs to ClampTo
2023-05-06 21:26:13 +02:00
PeterN
b67cf7f94a
Change: Replace ScriptLog data array with std::deque. ( #10770 )
...
Due to cyclic header dependency this requires moving the data types used
by ScriptLog out of the ScriptLog class.
2023-05-06 14:54:58 +00:00
Tyler Trahan
6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar ( #10753 )
2023-05-04 13:14:12 +00:00
Tyler Trahan
930f0a16d8
Codechange: Define Date/Year/Month/Day within TimerGameCalendar class
2023-04-26 07:14:03 -04:00
Patric Stout
7aa2b9ab0a
Codechange: move all date-related variables inside the timer ( #10706 )
2023-04-24 15:56:01 +00:00
Rubidium
8f24901843
Codechange: replace printf with PRINTF macros by fmt::format for scripts
2023-04-24 17:51:25 +02:00
SamuXarick
f8b5661d28
Change: Allow GS access to ScriptGroup functions
2023-04-17 17:59:16 +02:00
SamuXarick
f225f36c3d
Change: Allow GS access to ScriptGameSettings.IsDisabledVehicleType
2023-04-17 17:59:16 +02:00
SamuXarick
fd26a44c9e
Change: Allow GS access to more ScriptCompany functions
2023-04-17 17:59:16 +02:00
Andy
8b1960a41c
Change: Allow GS access to more ScriptOrder functions
2023-04-17 17:59:16 +02:00
PeterN
e97bf271dc
Codechange: Make SpriteType, CargoSortType, SourceType and ScriptType enum classes. ( #10663 )
...
This avoids a (soft) namespace conflict between the four ST_* enums.
2023-04-16 20:00:55 +01:00
Charles Pigott
6fc28d649e
Cleanup: Unused alloca definitions and includes
2023-04-15 16:57:00 +01:00
dP
e2f1cd44dc
Change: Increase max cargo age and let min cargo payment approach zero. ( #10596 )
...
Co-authored-by: Michael Lutz <michi@icosahedron.de>
2023-04-10 12:34:28 +02:00
glx22
3a48d6e60f
Fix 991a797: [Script] Allow STRINGN consumption to be different than expected
2023-04-08 00:14:12 +02:00
Peter Nelson
82c70ed3b8
Change: Expose ObjectSpec vector to simplify iteration.
2023-04-02 22:42:38 +01:00
Peter Nelson
1f46f080f0
Codechange: Store objectspecs in std::vector instead of flat array.
2023-04-02 22:42:38 +01:00
Rubidium
1e4a89177e
Fix: crashes to desktop from game scripts when companies disappear
...
When a game script is in company mode, it pretends to be another company. When
that company disappear (bankruptcy/merger), the game script still uses that
company and it keeps calling functions as if it is that company.
For example, ScriptEngine::IsBuildable internally dereferences Company without
checks, causing a null dereference for any ScriptEngine function when called
from a company scope of a company that has disappeared.
Guard against this by extending the ScriptCompanyScope::IsValid check to also
check for the company still being active.
2023-03-08 22:33:47 +01:00
Rubidium
717f79ff22
Add: deity mode enforcement checks to functions with command or company access
...
Command functions are those that call ScriptObject::Command, and functions
with company access are any that call ScriptObject::GetCompany. This is a bit
over-protective, but having the check everywhere makes it easier to validate
that no check is missing automatically instead of by review.
2023-03-08 22:33:47 +01:00
Rubidium
8d443d1379
Add: company mode enforcement checks to functions with command or company access
...
Command functions are those that call ScriptObject::Command, and functions
with company access are any that call ScriptObject::GetCompany. This is a bit
over-protective, but having the check everywhere makes it easier to validate
that no check is missing automatically instead of by review.
2023-03-08 22:33:47 +01:00
Rubidium
534f2419ad
Add: precondition checks to functions that work with both valid company and deity
...
These are functions that either use ScriptObject::Command or ScriptObject::GetCompany.
This is a bit over-protective, but having the check everywhere makes it easier to
validate that no check is missing automatically instead of by review.
At this moment these checks will not do anything useful, as either IsValid or
IsDeity from ScriptCompanyMode returns true, but that will change later.
2023-03-08 22:33:47 +01:00
Rubidium
a79f97c022
Change: upon an invalid company mode, set ERR_PRECONDITION_INVALID_COMPANY instead of ERR_PRECONDITION_INVALID
2023-03-08 22:33:47 +01:00
Rubidium
3287acd114
Fix 13528bfcd0: bank balance command allows int64, GS was limited to int32
2023-03-07 23:20:04 +01:00
Rubidium
83946ca31d
Codechange: use GSCompanyMode::IsValid, IsDeity, and the precondition helpers
...
Direct 1:1 replacements in the code, and comments now refer to either
GSCompanyMode::IsValid or GSCompanyMode::IsDeity instead of several variations
on "company mode active" or "no company mode active".
2023-03-06 22:34:09 +01:00
Rubidium
cada2ca310
Add: GSCompanyMode::IsValid and IsDeity, and precondition enforcement helpers
2023-03-06 22:34:09 +01:00
glx22
ca149447d7
Codechange: Use SQInteger for generic numbers in script_window
2023-03-06 00:32:12 +01:00
glx22
f752d96125
Codechange: Use SQInteger for generic numbers in script_vehicle
2023-03-06 00:32:12 +01:00
glx22
4e48bf2e16
Codechange: Use SQInteger for generic numbers in script_town
2023-03-06 00:32:12 +01:00
glx22
18fe0a4046
Codechange: Use SQInteger for generic numbers in script_tilelist
2023-03-06 00:32:12 +01:00
glx22
cada18a6f8
Codechange: Use SQInteger for generic numbers in script_tile
2023-03-06 00:32:12 +01:00
glx22
07b73a8c02
Codechange: Use SQInteger for generic numbers in script_subsidy
2023-03-06 00:32:12 +01:00
glx22
cd80b31d19
Codechange: Use SQInteger for generic numbers in script_storypage
2023-03-06 00:32:12 +01:00
glx22
a9a55f2153
Codechange: Use SQInteger for generic numbers in script_station
2023-03-06 00:32:12 +01:00
glx22
446ebaa6b9
Codechange: Use SQInteger for generic numbers in script_road
2023-03-06 00:32:12 +01:00
glx22
4f6a2f31b5
Codechange: Use SQInteger for generic numbers in script_rail
2023-03-06 00:32:12 +01:00
glx22
cb2e76aae3
Codechange: Use SQInteger for generic numbers in script_priorityqueue
2023-03-06 00:32:12 +01:00
glx22
777b4d0987
Codechange: Use SQInteger for generic numbers in script_order
2023-03-06 00:32:12 +01:00
glx22
49ea69fdef
Codechange: Use SQInteger for generic numbers in script_objecttype
2023-03-06 00:32:12 +01:00