Commit Graph
648 Commits
Author SHA1 Message Date
Peter NelsonandPeterN 633f19419d Codechange: Make more use of GetCargoAccepted/ProducedIndex(). 2023-05-24 17:34:11 +01:00
Peter NelsonandPeterN 76516d7f70 Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Rubidiumandrubidium42 63d9bb93b8 Codechange: migrate from C-style GetString to C++-style GetString 2023-05-21 21:17:12 +02:00
Peter NelsonandPeterN 56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
Patric StoutandGitHub 199e41c762 Codechange: use default dtor instead of empty (#10826) 2023-05-14 23:31:03 +02:00
Rubidiumandrubidium42 f9b5bc7ee6 Cleanup: the need for SQAutoFreePointers has gone 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 d9e93edc8b Codechange: replace 'const char *' script API parameters with std::string 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 bbcb55ebc9 Codechange: use std::string as script API return type 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 b24a6bb8f3 Codechange: use std::string for script log calls 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 e035705239 Codechange: introduce and use std::string variant of sq_throwerror 2023-05-14 22:54:10 +02:00
Peter NelsonandMichael Lutz 726d05b22b Fix: Don't list unavailable road types for game scripts. 2023-05-12 21:03:13 +02:00
Peter NelsonandPeterN e6740046ee Codechange: Use range-for iteration. 2023-05-11 07:58:55 +01:00
Rubidiumandrubidium42 12085d088c Cleanup: remove obsolete string_compare_type 2023-05-09 23:14:48 +02:00
Rubidiumandrubidium42 bc389a86c9 Codechange: use std::string as std::map key, instead of stredup string 2023-05-09 23:14:48 +02:00
Peter NelsonandMichael Lutz 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
Rubidiumandrubidium42 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
Rubidiumandrubidium42 fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 2023-05-06 21:26:13 +02:00
PeterNandGitHub 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 TrahanandGitHub 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 StoutandGitHub 7aa2b9ab0a Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Rubidiumandrubidium42 8f24901843 Codechange: replace printf with PRINTF macros by fmt::format for scripts 2023-04-24 17:51:25 +02:00
SamuXarickandrubidium42 f8b5661d28 Change: Allow GS access to ScriptGroup functions 2023-04-17 17:59:16 +02:00
SamuXarickandrubidium42 f225f36c3d Change: Allow GS access to ScriptGameSettings.IsDisabledVehicleType 2023-04-17 17:59:16 +02:00
SamuXarickandrubidium42 fd26a44c9e Change: Allow GS access to more ScriptCompany functions 2023-04-17 17:59:16 +02:00
Andyandrubidium42 8b1960a41c Change: Allow GS access to more ScriptOrder functions 2023-04-17 17:59:16 +02:00
PeterNandGitHub 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 PigottandPeterN 6fc28d649e Cleanup: Unused alloca definitions and includes 2023-04-15 16:57:00 +01:00
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
glx22andLoïc Guilloux 3a48d6e60f Fix 991a797: [Script] Allow STRINGN consumption to be different than expected 2023-04-08 00:14:12 +02:00
Peter NelsonandPeterN 82c70ed3b8 Change: Expose ObjectSpec vector to simplify iteration. 2023-04-02 22:42:38 +01:00
Peter NelsonandPeterN 1f46f080f0 Codechange: Store objectspecs in std::vector instead of flat array. 2023-04-02 22:42:38 +01:00
Rubidiumandrubidium42 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
Rubidiumandrubidium42 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
Rubidiumandrubidium42 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
Rubidiumandrubidium42 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
Rubidiumandrubidium42 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
Rubidiumandrubidium42 3287acd114 Fix 13528bfcd0: bank balance command allows int64, GS was limited to int32 2023-03-07 23:20:04 +01:00
Rubidiumandrubidium42 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
Rubidiumandrubidium42 cada2ca310 Add: GSCompanyMode::IsValid and IsDeity, and precondition enforcement helpers 2023-03-06 22:34:09 +01:00
glx22andLoïc Guilloux ca149447d7 Codechange: Use SQInteger for generic numbers in script_window 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux f752d96125 Codechange: Use SQInteger for generic numbers in script_vehicle 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux 4e48bf2e16 Codechange: Use SQInteger for generic numbers in script_town 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux 18fe0a4046 Codechange: Use SQInteger for generic numbers in script_tilelist 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux cada18a6f8 Codechange: Use SQInteger for generic numbers in script_tile 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux 07b73a8c02 Codechange: Use SQInteger for generic numbers in script_subsidy 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux cd80b31d19 Codechange: Use SQInteger for generic numbers in script_storypage 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux a9a55f2153 Codechange: Use SQInteger for generic numbers in script_station 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux 446ebaa6b9 Codechange: Use SQInteger for generic numbers in script_road 2023-03-06 00:32:12 +01:00
glx22andLoïc Guilloux 4f6a2f31b5 Codechange: Use SQInteger for generic numbers in script_rail 2023-03-06 00:32:12 +01:00