Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Tue Nov 13, 2018 11:35 pm

All times are UTC




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Oct 27, 2013 9:40 am 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
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.

Attachment:
Crash.patch [2.64 KiB]
Downloaded 100 times


Is this a good start?
And what to do next?


Top
   
PostPosted: Sun Oct 27, 2013 10:00 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13178
Location: The Netherlands
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.

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
 Post subject: Messages
PostPosted: Wed Oct 30, 2013 1:54 pm 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
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:
Attachment:
Messages a.patch [1.63 KiB]
Downloaded 36 times

Attachment:
Messages b.patch [2.35 KiB]
Downloaded 35 times


Top
   
 Post subject: Re: Messages
PostPosted: Wed Oct 30, 2013 3:00 pm 
Online
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9049
Location: Sol d
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:
Attachment:
Messages a.patch

Attachment:
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.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Wed Oct 30, 2013 7:45 pm 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
Ah, I understand. Now It's clear why this file wasn't synchronized with SVN. :)


Top
   
 Post subject: Show area
PostPosted: Sun Nov 03, 2013 1:48 pm 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
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.

Attachment:
Show area.patch [27.07 KiB]
Downloaded 38 times

If you have some suggestions, please let me know. :)


Top
   
PostPosted: Sun Nov 03, 2013 4:09 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2364
Location: Location, Location
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


Top
   
PostPosted: Sun Nov 03, 2013 6:08 pm 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
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?


Top
   
PostPosted: Mon Nov 04, 2013 2:38 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Mon Jan 14, 2008 3:51 pm
Posts: 644
Location: PL
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:
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.

_________________
:] don't worry, be happy and checkout my patches


Last edited by planetmaker on Tue Nov 05, 2013 9:33 pm, edited 1 time in total.
PHP style means dark blue on black - hardly readable, thus removed


Top
   
PostPosted: Tue Nov 05, 2013 9:24 pm 
Offline
Engineer
Engineer

Joined: Wed Apr 27, 2005 6:40 pm
Posts: 51
Location: The Netherlands
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. :)

Attachment:
ShowArea_V2.patch [22.85 KiB]
Downloaded 43 times


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.