Patch: Counting died passengers

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Patch: Counting died passengers

Post by Mister_X »

I'm playing OpenTTD for many years, and want to add some improvements to the game.

My first one is a very small one to understand how the game works and try to apply the coding syntax correctly.
Crash.patch
(2.64 KiB) Downloaded 119 times
Is this a good start?
And what to do next?
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: Patch: Counting died passengers

Post by Hyronymus »

Sadly I lack any skill to apply a patch but the subject you choose is actually a nice one: the death toll could affect company rating.
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Messages

Post by Mister_X »

I made another small patch which makes to changes for displaying messages.

1.
When you click at a summary message, the full message appears. After closing this message, the message is still visible in the status bar. Sometimes it cost a lot of seconds before the next message is vissible.
After applying this patch, the message will be removed from the status bar and the next message will be visible directly.

2.
When a lot of messages are in the que to display, the latest messages aren't showed anymore because they are very old. (for example: When removing a road piece, a lot of vehicle lost messages will come up.)
After applying this patch, a third menu option is available in the News menu to skip all pending messages.

In the file strings.h the line static const StringID STR_NEWS_MENU_MESSAGE_SKIP_NEXT_MESSAGES = 0x15C; should be added, but I couln't make a patch for this file.
And apply both patch files:
Messages a.patch
(1.63 KiB) Downloaded 60 times
Messages b.patch
(2.35 KiB) Downloaded 59 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Messages

Post by planetmaker »

Mister_X wrote:I made another small patch which makes to changes for displaying messages.

1.
When you click at a summary message, the full message appears. After closing this message, the message is still visible in the status bar. Sometimes it cost a lot of seconds before the next message is vissible.
After applying this patch, the message will be removed from the status bar and the next message will be visible directly.

2.
When a lot of messages are in the que to display, the latest messages aren't showed anymore because they are very old. (for example: When removing a road piece, a lot of vehicle lost messages will come up.)
After applying this patch, a third menu option is available in the News menu to skip all pending messages.

In the file strings.h the line static const StringID STR_NEWS_MENU_MESSAGE_SKIP_NEXT_MESSAGES = 0x15C; should be added, but I couln't make a patch for this file.
And apply both patch files:
Messages a.patch
Messages b.patch
strings.h is not edited manually. Just add your string to src/lang/english.txt and use it. strgen will take care of strings.h upon compilation.
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Re: Patch: Counting died passengers

Post by Mister_X »

Ah, I understand. Now It's clear why this file wasn't synchronized with SVN. :)
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Show area

Post by Mister_X »

I've a new patch. :)

The button "Area" is added onto the town window. This will show all tiles where the town is the local authority from.
The button "Area" is added onto the station window also. This will show the catchment area for acceptance for goods and passengers.
Show area.patch
(27.07 KiB) Downloaded 57 times
If you have some suggestions, please let me know. :)
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: Patch: Counting died passengers

Post by Lord Aro »

Adding a new byte into the map array to do this seems...wrong. very wrong.

Also, can you make your patches without spaces in the filenames? Makes it a bit easier for us unix types to apply :)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Re: Patch: Counting died passengers

Post by Mister_X »

Lord Aro wrote:Adding a new byte into the map array to do this seems...wrong. very wrong.
I didn't like to add an extra variable there, but I read the file landscape_grid.html, and no bit was left which wasn't used by any tile type.
To not slow down the current game speed a search loop isn't a good idea, I think. So I need a global variable which is accessible when drawing the sprite.
Do you have a better idea to solve this issue?


OK, next time I don't use spaces in the file names. :)


Edit:
In landscape_grid.html I see that for each tile type at least one bit is available.
It is desirable to place this bit dependent on the tile type at different locations in the map?
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Patch: Counting died passengers

Post by adf88 »

Mister_X wrote:Do you have a better idea to solve this issue?
You have a set of rectangles and circles. Tiles are inside or outside them - perform this hit test on-demend, don't pre-calculate values for all tiles. When you have to decide whether to draw a tile highlight or not, then just check whether the tile is contained by any of rectangles/circles, something like this:

Code: Select all

for (uint i = 0; i < areas_to_highlight.Length(); i++) {
    if (areas_to_highlight[i].Contains(tile)) {
        DrawTileCoverage(i, tile);
        break;
    }
}
Optionally you can cache only some amount of hit test results and/or use better algorithms to perform the hit test. However, I see no point in doing so. Simple linear search will be fast enough until you want to show coverage for all stations/towns. Otherwise it may turn out that something better is required.
Last edited by planetmaker on 05 Nov 2013 21:33, edited 1 time in total.
Reason: PHP style means dark blue on black - hardly readable, thus removed
:] don't worry, be happy and checkout my patches
Mister_X
Engineer
Engineer
Posts: 54
Joined: 27 Apr 2005 18:40
Location: The Netherlands

Re: Patch: Counting died passengers

Post by Mister_X »

You are right. I tought that the process to draw the tiles was very slow, so I wouldn't make the draw process more slower than needed. Now I see that this process is fast enough to do an extra loop.
Your suggestion to do a raw rectangle check first is a good point. I added this into the patch and removed the extra byte in the map array. :)
ShowArea_V2.patch
(22.85 KiB) Downloaded 62 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 27 guests