Show station catchment area with right mouse button.
Moderator: OpenTTD Developers
Show station catchment area with right mouse button.
Now, it's possible to view a station catchment area when clicking with the right button on the station.
Code should be feature complete, but some refactoring needs to be done... I just got a headache trying to figure out the correct numbers for SetTileSelectBigSize function
Screenshot here:
http://plaes.org/files/2006-Q4/ottd-sta ... t-area.png
[edit]Changed left to right
Code should be feature complete, but some refactoring needs to be done... I just got a headache trying to figure out the correct numbers for SetTileSelectBigSize function
Screenshot here:
http://plaes.org/files/2006-Q4/ottd-sta ... t-area.png
[edit]Changed left to right
- Attachments
-
- leftclick-show-station-spread-hack-v3.diff
- Feature complete, but some refactoring todo...
- (6.09 KiB) Downloaded 298 times
Last edited by plaes on 28 Aug 2007 14:06, edited 3 times in total.
i have tried to show station catchement spread aswell but i gave up and achived what i was looking for a different way. Instead i displayed what industries there were around the station in the station window. this was done by useing the industries(that produce cargo(even if the cargo produce amount is 0)) to tell the station that they are there instead of the station looking for them. This is a realivity small patch which i want to release with my fully funtional industry directory for stations but i have been haveing never ending problems with it.
i think you should name this tile spread instead of station spread as i got the wrong idea when you said station spread
i think you should name this tile spread instead of station spread as i got the wrong idea when you said station spread
I just took a quick look in that function. It's not a tiny function, so half of it would be a lot of duplicated code. I think it would be better to write a function to contain the code both functions need. Having only one piece of code for each functionality will make the functionality consistent. It will prevent the issues we had like when building vehicles, the player had to own the tile (depot) the vehicle is build in, but that check was skipped for trains. If we had a single piece of code to verify such data, such inconsistence would not show up.prissi wrote:Maybe you should have a look at UpdateStationAcceptance() in station_cmd.c
It would also be nice if somebody takes the time to write good comments in UpdateStationAcceptance() as it leaves room for improvement.
I like this feature, but it have to be done right
Well, I updated the patch, so it now should be feature complete
Code: Select all
* UpdateStationArea was refactored, some of the code was used to create a new GetStationArea function.
* Moved ottd_Rectangle definition to the station.h (btw, the name sucks ;))
* FindCatchmentRadius and GetStationArea functions are now public f-s in station_cmd.c
Re: Show station catchment area with left mouse button.
I have updated the patch so it would apply and compile with latest svn.
- Attachments
-
- leftclick-show-station-spread-hack-v4.diff
- (5.51 KiB) Downloaded 191 times
Re: Show station catchment area with left mouse button.
Works with irregular stations and combined train+bus+whatever stations too, I hope?
Re: Show station catchment area with left mouse button.
I like your patch! Just one thing that really should be done better: the malloc. A better approach would be:
and call it like:
No malloc, no need for free(), clean and simple You might also want to upload it to http://bugs.openttd.org Nice work!
Code: Select all
ottd_Rectangle *GetStationArea(Station *st, ottd_Rectangle *area) { }
Code: Select all
{
ottd_Rectangle area;
GetStationArea(st, &area);
}
The only thing necessary for the triumph of evil is for good men to do nothing.
Re: Show station catchment area with left mouse button.
Im not entirely sure how the current system works for working out the cargo acceptance tiles, but it looks from your patch that if you have a string of bus depots attached to an Intercontinental, you would get intercontinental sized catchment area around each tile of the station.
I was intending working on this at some point to handle the irregular shape airports, whose current catchment area is just the basic rectangle.
I was intending working on this at some point to handle the irregular shape airports, whose current catchment area is just the basic rectangle.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Re: Show station catchment area with left mouse button.
Do you plan to have an irregular catchment areas on your airports? IMHO better solution would be circular/oval catchment areas with center located somewhere near main terminal.
Re: Show station catchment area with left mouse button.
The big problem with catchment areas is that they are not properly defined. They are calculated one way in UpdateStationAcceptance (as the big bounding rectangle in this patch) but this is not the same as the effective area for a station to receive cargo from producing industries, which is done from the industry's point of view, and can result in an irregular shaped area that is effectively the union of the rectangles for each of the station's tiles, which is a little more work to calculate from the station's point of view. This means that with an irregular station, one could have a factory which accepts cargo from the station, but can't deliver to it.
Re: Show station catchment area with left mouse button.
Are you sure, that this approach would be better? IMHO, current version makes it easier to check whether the area is either invalid (NULL) or valid...TrueLight wrote:I like your patch! Just one thing that really should be done better: the malloc. A better approach would be:
and call it like:Code: Select all
ottd_Rectangle *GetStationArea(Station *st, ottd_Rectangle *area) { }
No malloc, no need for free(), clean and simple You might also want to upload it to http://bugs.openttd.org Nice work!Code: Select all
{ ottd_Rectangle area; GetStationArea(st, &area); }
Re: Show station catchment area with left mouse button.
You can still return NULL (or make it a bool function and return false if you prefer).
No-one's more important than the earthworm.
Re: Show station catchment area with left mouse button.
Code: Select all
v5:
o Implemented TrueLights malloc/free removal thanks to the tip from Maedhros
- Attachments
-
- leftclick-show-station-spread-hack-v5.diff
- (5.45 KiB) Downloaded 155 times
- Sir A. Boey
- Transport Coordinator
- Posts: 299
- Joined: 17 Nov 2006 17:40
- Location: Everywhere and nowhere
Re: Show station catchment area with left mouse button.
Fabulous Patch...
I always wanted to see the catchment area of a station this because I sometimes found new industries
right next to a station but sometimes I've build them to far, so this is (2 me) a perfect sollution...
Tnx great work...
I always wanted to see the catchment area of a station this because I sometimes found new industries
right next to a station but sometimes I've build them to far, so this is (2 me) a perfect sollution...
Tnx great work...
_____________# If you believe in it, you can achieve it" # ____________
__________________# Check out My Closed Platform #___________________
- Sir A. Boey
- Transport Coordinator
- Posts: 299
- Joined: 17 Nov 2006 17:40
- Location: Everywhere and nowhere
Re: Show station catchment area with left mouse button.
Hello,
I've asked Chrissicom to take a look at your diff if it would be possible to input this
into his ChrisIN (with your permission that is) and here's what he had to say about that...
[Don't know if I'm alowed to quote other players in a different Thread but here it is anyway]
[quote]Chrissicom wrote: "Have you tested this patch yet? Does it only show the station catchment area when having the button still clicked or is a single short click enough and then the catchment is shown until when... ? I think the problem is that left click is also used to open the station info window so maybe using right click (I think it's unused on stations) would be a good solution."[/quote]
Greetz
I've asked Chrissicom to take a look at your diff if it would be possible to input this
into his ChrisIN (with your permission that is) and here's what he had to say about that...
[Don't know if I'm alowed to quote other players in a different Thread but here it is anyway]
[quote]Chrissicom wrote: "Have you tested this patch yet? Does it only show the station catchment area when having the button still clicked or is a single short click enough and then the catchment is shown until when... ? I think the problem is that left click is also used to open the station info window so maybe using right click (I think it's unused on stations) would be a good solution."[/quote]
Greetz
_____________# If you believe in it, you can achieve it" # ____________
__________________# Check out My Closed Platform #___________________
Re: Show station catchment area with left mouse button.
Hum.. You discovered the only flaw in the patch descriptionSir A. Boey wrote:Hello,
I've asked Chrissicom to take a look at your diff if it would be possible to input this
into his ChrisIN (with your permission that is) and here's what he had to say about that...
[Don't know if I'm alowed to quote other players in a different Thread but here it is anyway]
GreetzChrissicom wrote: "Have you tested this patch yet? Does it only show the station catchment area when having the button still clicked or is a single short click enough and then the catchment is shown until when... ? I think the problem is that left click is also used to open the station info window so maybe using right click (I think it's unused on stations) would be a good solution."
It should be right button not left...
-
- Route Supervisor
- Posts: 415
- Joined: 07 Oct 2004 10:05
Re: Show station catchment area with right mouse button.
Hehe even better I already wondered where a left button is specified in the source. Just one more question, how did you create the .diff file because I can't read it with TortoiseSVN so I would have to "inject" the code manually.
Re: Show station catchment area with right mouse button.
I'm using git (specifically git-svn) stuff to do development in my local branch (so I can make in-between commits).
But I have no idea why tortoisesvn doesn't like the patch
But I have no idea why tortoisesvn doesn't like the patch
Who is online
Users browsing this forum: No registered users and 55 guests