Rubidium
c3d5e6d2a0
Codechange: Use EnumBitSet for DoCommandFlags
2025-02-14 00:28:57 +01:00
Peter Nelson
f309b90a1d
Codechange: Use EnumBitSet for Airport blocks.
2025-02-13 22:02:02 +00:00
Peter Nelson
75387b9e2b
Codechange: Use EnumBitSet for StationFacility.
2025-02-13 18:03:13 +00:00
Peter Nelson
7975145080
Codechange: Use EnumBitSet for TownActions. ( #13542 )
2025-02-13 18:02:39 +00:00
Jonathan G Rennison
d06b371254
Cleanup: Fix various spelling errors
2025-02-12 22:44:51 +01:00
Loïc Guilloux
7fbfaa1b54
Fix #13520 : [Script] doxygen ignored 'constexpr' constants ( #13523 )
2025-02-10 23:05:31 +01:00
Peter Nelson
687829fa14
Codechange: Use std::unique_ptr for ScriptList::sorter. ( #13517 )
...
Avoids manual pointer management.
2025-02-10 19:20:52 +00:00
Rubidium
ec492cb267
Codechange: make CompanyMask a BaseBitSet implementation
2025-02-09 19:24:51 +01:00
Rubidium
b9777269ce
Codechange: strongly type SignID
2025-02-09 18:05:01 +01:00
Rubidium
cd4482b5df
Codechange: make TownID an enum
2025-02-09 18:05:01 +01:00
Rubidium
cda9c2759e
Codechange: make SignID an enum
2025-02-09 18:05:01 +01:00
Rubidium
1e24b41f22
Codechange: strongly type GroupID
2025-02-09 16:52:21 +01:00
Rubidium
155d7de132
Codechange: change Source into a class with conversion helpers
...
A Source is either a CompanyID (Headquarters), IndustryID or TownID.
When making those types stronger a lot of casts would be needed, but
with these simple helpers the intent is shown more clearly.
2025-02-09 15:28:35 +01:00
Rubidium
3aa60fd479
Codechange: strongly type StoryPageID and StoryPageElementID
2025-02-09 15:07:29 +01:00
Rubidium
6c8915fdbc
Codechange: strongly type LeagueTableID and LeagueTableElementID
2025-02-09 15:07:29 +01:00
Rubidium
6aada55e96
Codechange: strongly type GoalID
2025-02-09 15:07:29 +01:00
Rubidium
07dd5bf01d
Codechange: support strongly typed pool element IDs in squirrel/saveload
2025-02-09 15:07:29 +01:00
Peter Nelson
dccc6185b9
Codechange: Change internal format of encoded strings to improve robustness and allow expansion. ( #13499 )
2025-02-09 12:45:50 +00:00
Rubidium
1193852007
Codechange: do not use ScriptCompany::CompanyID outside of the script API
2025-02-09 12:04:42 +01:00
Rubidium
4cda9f900d
Codechange: [Script] Use helper function over direct casting CompanyID
...
In the script's API `COMPANY_INVALID` has a value of -1, whereas the internal
game's `INVALID_COMPANY` has a value of 255. Since the script's API also has
a `COMPANY_SPECTATOR` with a value of 255, these enumerations cannot be easily
reconciled by casting. As such, replace all casts in the script API with
either ScriptCompany::FromScriptCompanyID or ScriptCompany::ToScriptCompanyID.
Also make clear whether CompanyID is ::CompanyID or ScriptCompany::CompanyID
by using either one of those over CompanyID in the script's API.
2025-02-08 23:42:19 +01:00
Loïc Guilloux
8ab3e9f0a3
Fix 3effb89
: [Script] Don't set CommandCallback for asynchronous commands ( #13501 )
2025-02-08 22:14:37 +00:00
Peter Nelson
d61b376998
Codechange: Use EnumBitSet for CargoClasses. ( #13491 )
2025-02-08 08:46:38 +00:00
Rubidium
5f41bc0279
Codechange: put SourceType and SourceID into Source struct
2025-02-08 06:37:23 +01:00
Peter Nelson
50b384032d
Codechange: Use EnumBitSet for IndustryControlFlags.
2025-02-07 22:01:59 +00:00
Peter Nelson
9a6fc4eb76
Codechange: Use enum class for NewsReferenceType.
2025-02-07 19:36:52 +00:00
Peter Nelson
ca75a8ce19
Codechange: Use enum class for NewsType.
2025-02-07 19:36:52 +00:00
Peter Nelson
2bb3f368e3
Codechange: Use EnumBitSet for IndustryBehaviours.
2025-02-07 12:30:06 +00:00
Rubidium
e937c4dcfd
Codechange: change DestinationID into class with conversion helpers
...
A DestinationID is either a DepotID or StationID, where the aircraft hangar
being conceptually a depot is actually a StationID. When making those types
stronger, a lot of casts would need to be added, but this shows the intent
much better.
2025-02-06 21:03:24 +01:00
SamuXarick
f5d43ffdf8
Change: [Script] GetWaypointID to return the StationID of any waypoint
...
Modified ScriptWaypoint::GetWaypointID to also return the StationID of any waypoint (including road waypoint).
2025-02-03 08:41:59 +01:00
Rubidium
5ffaf6cdb9
Fix: [Script] Wrong return value for failed preconditions Vehicle::CloneVehicle
2025-02-02 18:01:08 +01:00
Peter Nelson
6f52a977a8
Codechange: Use EnumBitSet for GRFConfigFlags.
...
This is renamed from `GCF_Flag` didn't match convention.
2025-02-02 10:49:45 +00:00
Peter Nelson
59354576d4
Codechange: Use EnumBitSet for LandscapeTypes and remove LandscapeID. ( #13436 )
2025-02-01 23:09:18 +00:00
Peter Nelson
c4c5028862
Codechange: Use EnumBitSet for SettingFlags. ( #13429 )
2025-02-01 15:46:51 +00:00
Rubidium
b6bdb97bed
Codechange: [Script] replace some enums with constexpr values of the internal type
2025-02-01 02:38:37 +01:00
Peter Nelson
5664b1e2f6
Codechange: Use std::vector for GRFConfig lists. ( #10835 )
...
This replaces the C-style custom managed linked-list and allows use of iterators etc.
2025-01-31 17:09:09 +00:00
Peter Nelson
f51627c76f
Codechange: Use EnumBitSet for DepotCommand(Flag)s.
2025-01-29 21:46:39 +00:00
Peter Nelson
5ef495da78
Codechange: Use EnumBitSet for GroupFlags.
2025-01-29 21:46:39 +00:00
Rubidium
4099acb946
Codechange: replace BSWAP32/BSWAP16 with std::byteswap
2025-01-28 19:22:12 +01:00
Rubidium
37a2d97c64
Doc: [Script] some IDs were not mentioned in script_types.hpp
2025-01-28 18:57:40 +01:00
Rubidium
1543b909dd
Codechange: use 'using' over 'typedef'
2025-01-28 18:57:40 +01:00
Rubidium
9a21ca31f8
Codechange: [Script] do not redefine types in the script API
...
Also move includes to the locations where they are actually used
2025-01-28 18:57:40 +01:00
Rubidium
45444f9666
Codechange: rename DECLARE_POSTFIX_INCREMENT to DECLARE_INCREMENT_DECREMENT_OPERATORS
2025-01-28 18:56:58 +01:00
Rubidium
d1e001f1c8
Codechange: make script and internal NEW_STATION have the same value
2025-01-28 18:17:05 +01:00
Rubidium
e894a5880c
Codechange: rename CargoID to CargoType and amend related variables/comments
2025-01-26 18:07:10 +01:00
Rubidium
b1ab1b9f06
Change: [Script] rename BridgeID to BridgeType in the script API
2025-01-22 22:23:38 +01:00
Peter Nelson
5f0e4cd646
Codechange: Make RoadStopType an enum class. ( #13340 )
2025-01-19 21:43:17 +00:00
Peter Nelson
4397aa3909
Codechange: Make StationType an enum class. ( #13339 )
2025-01-19 20:53:08 +00:00
Rubidium
b71a5158cf
Codechange: use INVALID_VEHICLE where that's more appropriate than e.g. vehicle 0
2025-01-19 17:10:21 +01:00
Rubidium
0aa9faf187
Codechange: use INVALID_TOWN instead of 0 to denote 'not applicable'
2025-01-19 16:54:42 +01:00
Peter Nelson
95f8fc983b
Codechange: Make GroupFlags an enum class. ( #13312 )
...
GF_END is 'reserved' in some Windows APIs. Instead of working around it, make GroupFlags an enum class.
2025-01-14 11:33:26 +00:00
Rubidium
29129e12fd
Add: [Script] Event for when a company's president name changes
2025-01-14 11:35:35 +01:00
Björn Wärmedal
9ab936f76b
Add: [Script] ScriptEventCompanyRename ( #12878 )
2025-01-14 09:24:28 +00:00
Loïc Guilloux
46f181c8a6
Fix #13299 : Merge IT_INVALID and INVALID_INDUSTRYTYPE ( #13300 )
...
* Fix #13299 : Merge IT_INVALID and INVALID_INDUSTRYTYPE
* Codefix: Use NUM_INDUSTRYTILES where it's intended
2025-01-10 01:17:11 +01:00
Peter Nelson
b653f875b0
Codechange: Space between template
and <
( #13278 )
...
Make it all consistent so it matches CODINGSTYLE.
2025-01-04 17:56:14 +00:00
Peter Nelson
810e442203
Codechange: Split GoodsEntry cargo and flows data to unique_ptr. ( #13058 )
...
This allows cargo packets and cargo flow data to be empty if not in use, which is the case for the majority of station goods entries, and data is allocated when needed.
This reduces the initial size of a Station from 9192 bytes to 2024 bytes (on 64 bit platforms), although an allocation of 120 bytes is made for each active cargo type at a station.
Based on similar changes in JGRPP.
2025-01-02 20:48:23 +00:00
Rubidium
fd7a883cbd
Codechange: make the StringIndex (within a StringTab) a strong type
2025-01-02 21:19:00 +01:00
Rubidium
c0df898ac5
Codechange: do not implicitly convert during assignment to StrongType
2025-01-01 21:32:51 +01:00
Rubidium
3956ed086a
Codechange: use Date/Year constructor explicitly
2025-01-01 16:25:32 +01:00
Rubidium
f55ba40b13
Codechange: use TileIndex constructor explicitly
2025-01-01 16:25:23 +01:00
Rubidium
fd5f6caed4
Codechange: use explicit TileIndex constructor for tile 0
2025-01-01 08:26:54 +01:00
Loïc Guilloux
d840152cb7
Codefix: [Script] incorrect end of class detection for doxygen ( #13204 )
2024-12-28 18:15:09 +00:00
Yakov Lipkovich
be02b54744
Doc: fix typo in script_vehicle.hpp ( #13177 )
2024-12-20 08:42:57 -05:00
rubidium42
ef76f0e758
Codechange: use default virtual destructors over empty destructors
2024-12-06 22:30:19 +10:00
Peter Nelson
3be0166801
Codechange: Use std::ranges::find where possible.
...
Replace `std::find(range.begin(), range.end(), ...)` with `std::ranges::find(range, ...)`.
2024-11-24 10:36:03 +00:00
Loïc Guilloux
681b1928b4
Fix #13110 : [Script] convert table keys to string when generating JSON ( #13113 )
2024-11-23 13:46:33 +01:00
Peter Nelson
653e5e8b63
Codechange: Use std::visit for formatting script strings.
2024-11-23 10:55:41 +00:00
Peter Nelson
d875ac8947
Add: const operator->() for ScirptObjectRef.
2024-11-23 10:55:41 +00:00
Peter Nelson
6d3adc6169
Codechange: Remove ZeroedMemoryAllocator from ScriptText. ( #13108 )
...
ScriptText is much simplified from its original design. Use member initialisation instead.
2024-11-20 22:16:14 +00:00
Rubidium
ea6aa4653a
Codechange: replace magic numbers with enumeration
2024-10-25 18:37:11 +02:00
Rubidium
4a4c77ff04
Codechange: use functions described in documentation, instead of related other functions
2024-10-25 18:37:11 +02:00
Rubidium
c9819f8957
Codechange: split GetRoadDir as bays have DiagDir and drive throughs have Axis
2024-10-24 20:40:32 +02:00
Peter Nelson
147ac56f11
Fix: ScriptTile::PlantTreeRectangle does not check that the end tile is in bounds. ( #13004 )
...
If the starting tile is near the edge of the map, the width and height could overflow the map boundary.
In some cases this might result in a different area being planted than expected.
2024-10-19 20:52:02 +01:00
Peter Nelson
8360fab18a
Codechange: Remove CCountedPtr.
...
This was originally generic and used by YAPF, but now it is used only by script objects.
CCountedPtr provided much more (untested) functionality than used.
ScriptObjectRef already exists for script objects and does the same thing, so use this instead.
2024-10-16 21:52:00 +01:00
Loïc Guilloux
d67963e616
Add: [Script] Include number of victims in ScriptEventVehicleCrashed ( #12861 )
2024-07-16 21:28:29 +02:00
Jonathan G Rennison
9c84e5df3f
Add: Road waypoint functionality
2024-06-24 22:12:08 +02:00
Peter Nelson
731c56d116
Codefix: Add missing const
inside script functions. ( #12794 )
...
Scripts do not modify items directly, marking them const enforces this.
2024-06-17 07:19:56 +01:00
Peter Nelson
d5671030b1
Codechange: Add NewGRFSpecsBase class to hold class/index information.
...
Standardises how the class index is stored in the spec, instead of relying ot the Spec structs having the same members.
This allows retrieving class_index and index without searching or using pointer arithmetic.
'cls_id' is renamed to 'class_index' to make it clearer that it is an index rather than the multichar label of the class.
2024-05-11 02:12:41 +01:00
frosch
dc22edc556
Doc: [Script] Extend API documentation on calendar- vs economy-time
2024-05-10 13:17:19 +01:00
frosch
04cc0c8125
Codechange: [Script] Document relation between ScriptErrorType and ErrorMessages enums
2024-05-10 13:17:19 +01:00
frosch
40e6230900
Codechange: Add main page to script API documentation
2024-05-10 13:17:19 +01:00
frosch
dfa2622153
Codechange: Unify naming of squirrel built-in types in Script API docs
2024-05-10 13:17:19 +01:00
frosch
e436e2ef40
Codefix: broken links and syntax issues in script API documentation
2024-05-10 13:17:19 +01:00
frosch
64e1f1d4d9
Codefix: Script API documentation about IDs was incomplete
2024-05-10 13:17:19 +01:00
frosch
4bf2dc3148
Codefix: Script API did not link simple types correctly
2024-05-10 13:17:19 +01:00
frosch
c1375cecf8
Codefix: [Script] script_types was excluded from API documentation
2024-05-10 13:17:19 +01:00
frosch
ffe76a0133
Update: Doxyfiles to doxygen 1.9.4
2024-05-10 13:17:19 +01:00
Peter Nelson
cf96d49ced
Codechange: Use vector for airport tile layouts. ( #12607 )
...
Simplify AirportSpec data by storing layout information together in a vector, instead of separate arrays.
This removes manual memory management and separate count members.
The default layouts will be copied instead of always referring to the originals.
2024-05-02 11:37:54 +00:00
Peter Nelson
a28ab8cac2
Codechange: Replace C-style casts to size_t with static_cast. ( #12455 )
...
* Codechange: Replace C-style casts to size_t with static_cast.
This touches only simple value-type casts.
* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX
Co-authored-by: Rubidium <rubidium@openttd.org>
2024-04-19 20:34:36 +01:00
frosch
907cb4fc53
Fix: [Script] ScriptSubsidy::GetExpireDate should return an economy-date ( #12372 )
2024-03-28 23:21:20 +01:00
glx22
02c00f3e3e
Change: [Script] Use economy time for ScriptDate
2024-03-23 21:17:40 +01:00
glx22
704e871a0e
Revert bbdbf9a
: ScriptTimeMode was not the best solution for economy/calendar support
2024-03-23 21:17:40 +01:00
Peter Nelson
ea74ca0a76
Fix #12347 : Crash attempting to find catchment tiles of a station with no catchment area. ( #12348 )
2024-03-23 13:03:59 +01:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
glx22
3a71f36393
Change: [Script] Match FormatString behaviour more closely
2024-03-09 12:15:03 +01:00
glx22
ae27ce12a7
Fix 0858377
: [Script] Don't output parameters more than once
2024-03-09 12:15:03 +01:00
Michael Lutz
8dda387f82
Codechange: Use std::tuple for slope functions with two return values
2024-03-08 18:08:55 +01:00
Loïc Guilloux
845b894fd8
Remove: [Script] random_deviation from setting description table ( #12221 )
2024-03-05 12:41:04 +01:00
Loïc Guilloux
f612bc6ee2
Fix bf4b6696
: [Script] Broken ScriptText circular reference detection ( #12187 )
2024-02-27 18:16:21 +01:00
Rubidium
a4d4301a0c
Codechange: We are heading to 15
2024-02-18 21:48:54 +01:00
SamuXarick
8584d1b5bb
Add: [Script] GetAirportNumHelipads ( #12085 )
...
Adds a function for Scripts to get the number of helipads of an airport type.
2024-02-14 21:38:32 +01:00