New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: NewGRF road stops #10144
Add: NewGRF road stops #10144
Conversation
Test GRF with very ugly graphics |
1dd9d9b
to
c4dd2d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick initial skim...
c4dd2d5
to
7d2a390
Compare
e2af225
to
7d9f480
Compare
/** | ||
* Helper class for a unified approach to NewGRF animation. | ||
* @tparam Tbase Instantiation of this class. | ||
* @tparam Tspec NewGRF specification related to the animated tile. | ||
* @tparam Tobj Object related to the animated tile. | ||
* @tparam Textra Custom extra callback data. | ||
* @tparam GetCallback The callback function pointer. | ||
* @tparam Tframehelper The animation frame get/set helper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It breaks the indentation. :)
@@ -4707,6 +4708,131 @@ static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int pro | |||
return ret; | |||
} | |||
|
|||
/** | |||
* Ignore properties for roadstops |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Ignore properties for roadstops | |
* Ignore properties for roadstops. |
Although the period seems to be used mixed at the end of sentences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the other comments in this file and the wider codebase
GUIRoadStopClassList roadstop_classes; ///< Available road stop classes. | ||
StringFilter string_filter; ///< Filter for available road stop classes. | ||
QueryString filter_editbox; ///< Filter editbox. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are mixed signals above whether the comments should be aligned or not. :)
7d9f480
to
e675907
Compare
e675907
to
8fe2f52
Compare
I'm not liable to compile this any time soon for this implementation, but I've coded up Fridaemons warehouses as roadstops in NML over here: https://github.com/reldred/re_foars Code is nothing fancy, but removing the JGRPP specific code it should, I'm told, compile fine. I know I haven't specified a license in the repo, but it inherits GPLv2 by virtue of Fridaemons sprites. |
re_foars.zip |
I triggered a release build for this PR, will be available on https://www.openttd.org/downloads/openttd-branches/pr10144/latest when done. |
src/newgrf_roadstop.h
Outdated
enum RoadStopClassID : byte { | ||
ROADSTOP_CLASS_BEGIN = 0, ///< The lowest valid value | ||
ROADSTOP_CLASS_DFLT = 0, ///< Default road stop class. | ||
ROADSTOP_CLASS_WAYP, ///< Waypoint class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are waypoints relevant for road? Reserved for future (and jgrpp) use I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Road waypoints is already implemented with custom road stops support in my branch.
Not reserving the class ID would make adding this to vanilla in future a bit less straightforward.
I am not precious about removing that if it isn't wanted though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reserving it is fine imho, maybe with a note in the comment.
src/newgrf_roadstop.h
Outdated
|
||
RoadStopScopeResolver(ResolverObject& ro, BaseStation* st, const RoadStopSpec *roadstopspec, TileIndex tile, RoadType roadtype, StationType type, uint8 view = 0) | ||
: ScopeResolver(ro), tile(tile), st(st), roadstopspec(roadstopspec), type(type), view(view), roadtype(roadtype) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
src/newgrf_roadstop.h
Outdated
RoadStopResolverObject(const RoadStopSpec* roadstopspec, BaseStation* st, TileIndex tile, RoadType roadtype, StationType type, uint8 view, CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0); | ||
~RoadStopResolverObject(); | ||
|
||
ScopeResolver* GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline before {
src/base_station_base.h
Outdated
|
||
TileArea train_station; ///< Tile area the train 'station' part covers | ||
StationRect rect; ///< NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions | ||
|
||
std::vector<TileIndex> custom_road_stop_tiles; ///< List of custom road stop tiles | ||
std::vector<uint16> custom_road_stop_data; ///< Custom road stop random bits (low) and animation byte (high) in same order as custom_road_stop_tiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better as a single vector containing a struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes saveload with the new system a bit less straightforward, I should be able to do that later though.
8fe2f52
to
f4de070
Compare
f4de070
to
e7b592e
Compare
The savegame format has changed since the last update of this PR as per comments above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not completely reviewed, just some naming ideas.
src/newgrf_roadstop.cpp
Outdated
return specindex < st->roadstop_speclist.size() ? st->roadstop_speclist[specindex].spec : nullptr; | ||
} | ||
|
||
int AllocateRoadStopSpecToStation(const RoadStopSpec *statspec, BaseStation *st, bool exec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllocateSpecToRoadStop
might be less wordy?
src/newgrf_roadstop.cpp
Outdated
return i; | ||
} | ||
|
||
void DeallocateRoadStopSpecFromStation(BaseStation *st, byte specindex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, DeallocateSpecFromRoadStop
?
src/newgrf_roadstop.cpp
Outdated
* Update the cached animation trigger bitmask for a station. | ||
* @param st Station to update. | ||
*/ | ||
void StationUpdateRoadStopCachedTriggers(BaseStation *st) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RoadStopUpdateCachedTriggers
?
e7b592e
to
8cd073f
Compare
8cd073f
to
27676a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things, but nothing merge-blocking
/* Road type */ | ||
case 0x43: return get_road_type_variable(RTT_ROAD); | ||
|
||
/* Tram type */ | ||
case 0x44: return get_road_type_variable(RTT_TRAM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be tempted to use fallthrough & a RoadTramType rtt = 0x43 ? RTT_ROAD : RTT_TRAM
variable personally, but eh
/** Sort classes by RoadStopClassID. */ | ||
static bool RoadStopClassIDSorter(RoadStopClassID const &a, RoadStopClassID const &b) | ||
{ | ||
return a < b; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this function even needed? Seems pretty trivial...
bool IsInspectable(uint index) const override { return GetRoadStopSpec(index) != nullptr; } | ||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, BaseStation::GetByTile(index)->town->index); } | ||
const void *GetInstance(uint index)const override { return nullptr; } | ||
const void *GetSpec(uint index) const override { return GetRoadStopSpec(index); } | ||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } | ||
uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grffile->grfid : 0; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some unusual alignment here :)
Updated NewGRF spec status https://wiki.openttd.org/en/Development/NewGRF/Specification%20Status |
Plan for updating newgrf docs, based on https://jgrennison.github.io/OpenTTD-patches/newgrf-roadstops.html#a0roadstops This is based initially on the the list of differences in the description for this PR. I haven't read the actual diff or the subsequent review comments in this PR (can do if needed). Action 0
Action 1 Nothing needed specific to roadstops. Action 2 Roadstops entry in newgrf index page already links to relevant sprite layout page https://newgrf-specs.tt-wiki.net/wiki/Action2/Sprite_Layout No other action needed. Varaction 2
Random Action 2
Action 3 Roadstops entry in newgrf index page already links to relevant sprite layout page https://newgrf-specs.tt-wiki.net/wiki/Action3 No other action needed? |
Additions to the above: |
Motivation / Problem
Add NewGRF road stops.
Loosely based on #7955. but with various things added, removed, changed, fixed, etc. The NewGRF interfaces do not match.
Description
The implementation and NewGRF interface broadly matches the implementation in the JGR patchpack branch.
However various things have been removed as they are not applicable to this branch:
The interface is as described here, except without all the JGR patchpack specific stuff, as described above.
The feature is allocated to the ID: 0x14.
Specifically the following have been removed with respect to the above interface description:
The NML interface is described here, with the same set of items removed as listed above.
This corresponds to: RST_DRAW_FLAG_WAYPOINT_GROUND, RST_GENERAL_FLAG_NO_ONE_WAY_OVERLAY, minimum_bridge_height, disallowed_bridge_pillars, RST_TYPE_WAYPOINT, one_way_info, nearby_tile_one_way_info, nearby_tile_road/tram variables.
A branch which implements this can be found here: here (upstream-road-stops branch).
Limitations
This cannot be used with existing road stop GRFs which target the JGR patchpack branch.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.