Commit Graph

799 Commits

Author SHA1 Message Date
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
2023-05-07 20:25:44 +01:00
Rubidium fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 2023-05-06 21:26:13 +02:00
Rubidium 19ec4e8beb Codechange: replace ClampToI32/U16 with ClampTo<int32_t/uint16_t> 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
Rubidium 877349c13d Codechange: use std::string for text file name resolution 2023-05-05 08:54:29 +02:00
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 2023-05-04 13:14:12 +00:00
Rubidium 86786a7af6 Codechange: introduce StrEqualsIgnoreCase/StrCompareIgnoreCase to replace strcasecmp 2023-04-29 10:25:25 +02: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
Rubidium 8b93e45e22 Codechange: use string/fmt instead of printf for squirrel's PRINTFUNC 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
Patric Stout ed83c4b0da
Change: replace per-AI "start_date" with a global "competitors_interval" (#10653)
The per-AI "start_date" is a lot of custom code, and was rarely
used in the way it was meant.

While at it, also ported this part over to the new timer system.
2023-04-16 20:14:22 +02:00
Charles Pigott 6fc28d649e Cleanup: Unused alloca definitions and includes 2023-04-15 16:57:00 +01:00
Charles Pigott b282664242 Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives 2023-04-15 16:57:00 +01:00
Patric Stout 1ba4dcc924 Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
2023-04-15 13:58:55 +02:00
Peter Nelson e5af5907ec Change: Make all dropdown lists extend width if necessary.
This removes the auto_width parameter from ShowDropDown(At).
2023-04-13 20:57:47 +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
Loïc Guilloux e4c511d403
Fix #10578: Allow to select any version of AI/GS from GUI (#10604) 2023-04-07 19:33:07 +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
Loïc Guilloux 9642e87bc8
Fix: [Script] Access to enum/consts defined outside of main.nut (#10573) 2023-03-25 23:07:47 +01:00
PeterN 2d3250923c
Fix #10554: Let Scrollbar::SetPosition clamp instead of assert. (#10555) 2023-03-09 10:19:58 -05: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
glx22 0293fd41e5 Codechange: Use SQInteger for generic numbers in script_news 2023-03-06 00:32:12 +01:00