Commit Graph

67 Commits

Author SHA1 Message Date
frosch
6faa667644 Codechange: Remove global GetRegister(), instead return 100+ registers directly from GetXxxCallback(). 2025-05-06 22:24:41 +02:00
frosch
f59cf73b88 Codechange: Access temporary storage through ResolverObject during sprite layout preprocessing. 2025-05-06 22:24:41 +02:00
frosch
85be7a4d92 Codechange: Access temporary storage through ResolverObject during Resolve. 2025-05-06 22:24:41 +02:00
frosch
74030a63e6 Codechange: Move SpriteLayoutProcessor's operations closer to the ResolverObject. 2025-05-06 22:24:41 +02:00
frosch
8bbfbd0347 Codechange: Move spritelayout preprocessing to a separate class, which owns the heap allocations involved. 2025-05-06 18:30:42 +02:00
frosch
d9c43e7fda Codechange: Make TileLayoutSpriteGroup::ProcessRegisters return a DrawTileSpriteSpan on the stack, instead of a reference to a global. 2025-05-06 18:30:42 +02:00
frosch
010b944173 Codechange: Move SpriteGroup cast from callers into Resolve. 2025-04-29 10:35:10 +02:00
frosch
30b1eb6e5f
Fix: [NewGRF] The result of Action123 evaluation affected rerandomisation in a weird corner case. (#14139)
Rerandomisation does not care about the Resolve result.
But we skipped it, in case of 'invalid SpriteGroup reference'.
2025-04-28 23:24:42 +02:00
Peter Nelson
2c4897c2cd
Codechange: Use EnumBitSet for HouseZones. (#14137) 2025-04-28 20:27:43 +01:00
frosch
0f1ef96ca1 Codechange: Road stops do not use RealSpriteGroup, ResolveReal is never called. 2025-04-28 20:49:20 +02:00
frosch
41a20e512d Codechange: Use proper enum type to index sprite groups in VariableGRFFileProps. 2025-04-27 19:50:51 +02:00
frosch
f62f728187
Codechange: Move usage of ResolverObjects to newgrf_xxx.cpp (#14116) 2025-04-26 20:53:50 +02:00
frosch
d3ae6bc9a8
Fix: [NewGRF] For animation-triggers which do not supply a cargo-type in var18, the var18 bits should remain empty. (#14091) 2025-04-26 14:44:07 +02:00
frosch
bc0eaf9ac4 Codechange: Allow passing waypoints to Trigger(Station|RoadStop)Randomisation. 2025-04-24 09:19:43 +02:00
frosch
6f056283f2
Fix: [NewGRF] For roadstop multi-tile-animation-triggers, the upper 16 bits were not the same for all tiles. (#14084) 2025-04-23 19:26:09 +02:00
frosch
d7ddea4032
Codechange: Turn AnimationTrigger enums into enum classes. (#14067) 2025-04-21 20:53:31 +02:00
frosch
61a0a520f6
Codechange: Unify random trigger enums and turn them into enum classes. (#14066) 2025-04-21 20:03:34 +02:00
frosch
f399b8eb29 Codechange: Unify naming of NewGRF animation callbacks. 2025-04-21 19:06:13 +02:00
frosch
264abfafe6 Codechange: Rename storage of random triggers to include the term 'random'. 2025-04-21 19:06:13 +02:00
frosch
2a62eea005
Codefix: Comment style. (#14064) 2025-04-21 17:25:09 +02:00
frosch
cde350dc01 Codechange: Replace macros GENERAL_SPRITE_COLOUR and COMPANY_SPRITE_COLOUR with functions GetColourPalette and GetCompanyPalette. 2025-04-18 23:41:37 +02:00
Peter Nelson
9f94cadd68
Codefix: GRF-local cargo id is not a CargoType. (#13888) 2025-03-25 17:12:43 +00:00
Peter Nelson
3503082f19 Codechange: Move template class implementation includes.
These are now placed at the bottom of the including files include list.
2025-03-21 12:53:40 +00:00
Peter Nelson
2909a14374 Codechange: Include table/strings.h in files that use StringIDs.
Be consistent with how and where the file is incldued.
2025-03-21 12:53:40 +00:00
Peter Nelson
8f14894024 Add: NewGRF Badges. 2025-02-16 22:24:25 +00:00
Peter Nelson
ff7eb996e6
Codechange: Use variable storage for GrfProps with cargo-type groups. (#13557)
Slots are only allocated when used instead of being reserved.

Array-based GrfProps are still used when the number of options is more limited.
2025-02-14 18:30:17 +00:00
Peter Nelson
75387b9e2b Codechange: Use EnumBitSet for StationFacility. 2025-02-13 18:03:13 +00:00
Jonathan G Rennison
d06b371254 Cleanup: Fix various spelling errors 2025-02-12 22:44:51 +01:00
Peter Nelson
c31494a413 Codechange: Use EnumBitSet for RoadStopDrawModes. 2025-02-04 18:52:08 +00:00
Peter Nelson
17f6da413d Codechange: Use EnumBitSet for RoadStopSpecFlags. 2025-02-04 18:52:08 +00:00
Peter Nelson
40aeedeade Codechange: Use EnumBitSet for callback masks. 2025-01-31 17:08:24 +00:00
Rubidium
e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +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
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
Peter Nelson
e73d6fcaac Codechange: Store grfid with entity grfprops.
This allows using the grfid without having to dereference the grffile pointer.

Uses no extra storage as it fits within otherwise wasted padding space.
2024-12-05 18:17:58 +00:00
Jonathan G Rennison
d5ff6b4156
Fix 8d62a8f0: Road stop variable 6B crashing for road stop preview in GUI (#12930) 2024-09-06 11:14:34 +01:00
Peter Nelson
1ff35cb6f9 Codechange: Don't mark animated tiles dirty if frame is not changed.
If animation is continued but the animation frame has not changed then there is no need to mark the tile for refresh.

Loosely backport from JGRPP.
2024-08-13 20:04:44 +01:00
Jonathan G Rennison
a43dacd988 Add: NewGRF custom road waypoint support 2024-06-24 22:12:08 +02:00
Jonathan G Rennison
9c84e5df3f Add: Road waypoint functionality 2024-06-24 22:12:08 +02:00
Loïc Guilloux
29ce013eda
Codechange: Pass avail(able) as reference instead of pointer since they are never nullptr (#12696) 2024-05-18 17:04:16 +02:00
Peter Nelson
d2c8b476b5 Codechange: Add functions to test if a station/roadstop class is a waypoint.
This is now checked by class label instead of by index.
2024-05-11 02:12:41 +01:00
Peter Nelson
9f8c9724be Codechange: Add station/roadstop class labels for DFLT/WAYP.
This avoids repeating the same multichar literal value.
2024-05-11 02:12:41 +01:00
Peter Nelson
774f811217
Codechange: Use std::optional for town parent scope resolver. (#12530)
When resolving NewGRF, the parent town_scope is lazily initialised as it does not always need to be used.

Replace the manually managed pointer with std::optional to simplify. Using std::optional avoids extra memory allocation.
2024-04-18 22:14:16 +01:00
Peter Nelson
77f27e0804 Change: Expose NewGRF classes and specs as spans and simplify iteration.
This replaces some index-based loops with range loops.
2024-04-09 21:46:59 +01:00
Peter Nelson
668186ca5b
Codechange: Remove macros involved with NewGRFClass. (#12363)
Use direct class instantiation instead.
2024-03-23 21:55:50 +00:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Peter Nelson
8172e25273
Codechange: Use range-for when iterating station speclists. (#12212)
This replaces indexed access.
2024-03-03 16:41:02 +00:00
Peter Nelson
278c3a7db1 Codechange: Use reference instead of copy of NewGRF speclist item. 2024-03-02 21:16:15 +00:00
Peter Nelson
4ffe1da540
Fix: NewGRF roadstops were ignored if only in default class. (#12089)
If a NewGRF defines roadstops in the default class and no other classes are defined, they would be ignored and not selectable.
2024-02-14 19:21:13 +00:00