Skip to content
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

WIP Feature: NewGRF Road Stops (Feature 14) #7955

Draft
wants to merge 1 commit into
base: master
from

Conversation

@spnda
Copy link
Contributor

@spnda spnda commented Jan 22, 2020

Hey all,
After 3 years of playing OpenTTD I very appreciated the addition of Road- and Tramtypes with NRT. Now, I feel like having the same bus and truck stops everywhere looks bad and plain. Now with Feature 14, this opens up the possibility of having custom bus and truck stops. I call this NotRoadStops or for short NRS. I would guess that this would be a very appreciated addition and would bring more customizability to the game.

Status

Currently I have Action0 and Action4 "done". There's still some properties that could be added to Action0. Action2 and Action3 are uncompleted, as I still don't really understand how they work yet :( I'll work on those tomorrow.
I have already updated the GUI for building bus and trucks stops. In this current build it is possible to select between classes and between different stops, though sprites are not shown correctly. I have tried to make it look like the Rail Station GUI, or atleast as far as I could. This is not done at all and might take me a bit longer to do aswell. I just want to put this draft here, to track my own progress (I have some checkmarks at the bottom) and have some feedback and reviews.

Properties & Writing GRFs

As of now, I only have properties 08 and 09 implemented. This feature has the ID 14. (There's still more to come like animations etc.)

  • 08: DWord; The Station's Class ID. This is the same system as for example Stations.
  • 09: Byte; The Station's "type". There's 2 different types.
    • 00: Passenger, this stop is available to both bus and tram stops.
    • 01: Freight, this stop is available to both truck and freight tram stops.
    • 02: All, this stop is available to all 4 road stops.

Progress Tracking

I'm constantly posting new stuff on my discord server or on the r/OpenTTD discord.

  • Fix my own NFO code.
  • Action2 and Action3 for adding Sprites
  • Fix NRT compatibility
  • Fix and finish GUI
  • Sprite layouts and proper sprite rendering
  • Allow building of custom road stops
  • Add more Action0 properties
  • Update NML (seperate PR)

image

Test GRF File

examplegrf.zip

@spnda spnda changed the title Feature: NewGRF Road Stops (Feature 14) WIP Feature: NewGRF Road Stops (Feature 14) Jan 22, 2020
@James103
Copy link
Contributor

@James103 James103 commented Jan 22, 2020

Do you want the interface to be similar to that for NewGRF rail station building (near-exact same layout in case of trams, or similar layout with 6 buttons in 3x2 layout for roads)? If so, that would be fine and ideal by me.

@spnda
Copy link
Contributor Author

@spnda spnda commented Jan 23, 2020

Do you want the interface to be similar to that for NewGRF rail station building (near-exact same layout in case of trams, or similar layout with 6 buttons in 3x2 layout for roads)? If so, that would be fine and ideal by me.

I'm trying to come as close as I can to the rail station building GUI. Of course I can't do this new GUI exactly the same, though it will only have slight changes. Trams will of course only have 2 directions selectable while busses and trucks have 6 views to select from.

On another note, I will upload a test GRF file today... I think I might have made some mistakes in the NFO code of that file, therefore it isn't showing in the build menus...

@nielsmh nielsmh added the NewGRF label Jan 24, 2020
@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented Jan 24, 2020

Check if you need to bump the savegame version, even if you don't require any conversion to the new map data. Basically, that an OTTD version without NRS can load a savegame with NRS without anything breaking.

@spnda spnda force-pushed the spnda:roadstops branch from fb41d4e to feb306e Feb 2, 2020
@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 6, 2020

So, I've thought instead of having the trams just use bus and truck stations, give them their own stops. That way there'd be Bus, Truck, Tram and Freight Tram Stations.
This could allow for a bit more realism or variety, if someone wanted to have different stops for their trams entirely.
Is this a good idea or should it just be left as is, as a user can switch between the stations anyway?

@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented Feb 6, 2020

I think that's definitely one of the things requested, stations specific for trams or roads.
Also consider whether you're shooting too low and should support special multi-tile stations with custom movements, and perhaps diagonal platforms support.

@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 6, 2020

I kinda feel like having the stops differentiated by passenger or freight stops might be better, so that bus stops can also be used as tram stops.
I don't know, maybe we should have them split up for bus/trucks/trams/freight trams, but that would mean that a GRF might have to define multiple stations. For that, we could have a stop have define flags to be mapped onto one, some or all stops.

@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 6, 2020

There's now 6 different types of RoadStops, I guess. These types define if the RoadStop is available for multiple different combinations. I've listed them in the first post. I think this is quite a optimal solution to this.

@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 16, 2020

As I have been stuck on this for ~9 days now, I'll ask all here.
In my DrawRoadStopTile function (newgrf_roadstop.cpp) I just can't figure out how to draw the sprites from the NewGRF. I have checked my variables and they seem correct. I see ground_relocation/relocation have the value of the beginning of the sprite sheet I want to use as sprites. I'm pretty much completely lost here...
I'll push my changes so far in a minute.

@spnda spnda force-pushed the spnda:roadstops branch from feb306e to 97c728a Feb 16, 2020
src/newgrf_roadstop.cpp Outdated Show resolved Hide resolved
@@ -503,7 +503,7 @@ uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable,
cargo += st->goods[cargo_type].cargo.TotalCount();
}
break;

This comment has been minimized.

@planetmaker

planetmaker Feb 17, 2020
Contributor

whitespace change / addition to EOL?

This comment has been minimized.

@spnda

spnda Feb 17, 2020
Author Contributor

I don't know where that's from. It's also a thing above and below that switch/case statement. Might be because of Visual Studio auto formatting files? Don't know.

@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 17, 2020

In my case relocation is 6A6B, or 27243, which points exactly to the beginning of my sprite sheets.

DrawRailTileSeqInGUI(x, y, sprites, total_offset, relocation, palette);

When passing relocation into where total_offset is passed now, I get a SpriteID ~37000, which is obviously completely off.

Do I need to maybe calculate another value? Do I need to call DrawSprite with another SpriteID? From what I see the DrawRailTileSeqInGUI() function takes a sequence of sprites and draws them, though they don't take the newgrf offset into account, which obviously needs to happen.

@spnda spnda force-pushed the spnda:roadstops branch from 97c728a to abfe065 Feb 28, 2020
@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 28, 2020

Just updated to post some newer code, which makes feature 14 use spritelayout.
Custom sprite drawing STILL doesn't work but I'll do a massive deep dive into it today.

@spnda spnda force-pushed the spnda:roadstops branch 3 times, most recently from 5fb03d2 to e27250c Jun 17, 2020
src/rev.cpp Outdated Show resolved Hide resolved
bool type = HasBit(p2, 0);
bool is_drive_through = HasBit(p2, 1);
RoadType rt = Extract<RoadType, 5, 6>(p2);
bool is_drive_through = HasBit(p2, 23);
RoadType rt = Extract<RoadType, 16, 6>(p2);
//RoadType rt = Extract<RoadType, 5, 6>(p2);
Comment on lines -1837 to +1840

This comment has been minimized.

@glx22

glx22 Jun 17, 2020
Contributor

I guess regression fails because the changes here are not applied to script API.

This comment has been minimized.

@spnda

spnda Jun 18, 2020
Author Contributor

In which way have these to be documented or implemented?

This comment has been minimized.

@nielsmh

nielsmh Jun 19, 2020
Contributor

The code in the script API implementation that packs the parameters is separate from the code in the GUI that packs the parameters. make sure the script API packs parameters the correctly. Probably this:
https://github.com/spnda/OpenTTD/blob/e27250c4ee38708c860d513ba09266b43dc8c173/src/script/api/script_road.cpp#L534-L559

@spnda spnda force-pushed the spnda:roadstops branch 2 times, most recently from 268383a to 99757b8 Jun 27, 2020
@spnda spnda force-pushed the spnda:roadstops branch from 99757b8 to ee919ad Aug 23, 2020
@spnda spnda marked this pull request as draft Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.