[Patch] Measuring tools

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
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2013
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

[Patch] Measuring tools

Post by Wolf01 » 10 Jul 2010 18:14

Here I made a patch to measure distances, it's like a ruler.
The idea comes from "elho" who entered the chat and wanted to know the air distance of 2 stations...

The patch is complete, it has some bugs like the "height difference" not being removed when measuring a plain area and a problem of refresh of the distance when the tile is one, oh and the sprites for the button and the mouse and the drawing area which should not be highlighted, but only a stepped line or maybe just the start tile and the tile under the mouse.
Nothing that couldn't be fixed...

The distance from the edge and the height from the sea level are measured for the tile under the mouse.
Attachments
measurement_r20106.diff
(6.52 KiB) Downloaded 377 times
measuring_tools.png
measuring_tools.png (25.58 KiB) Viewed 10912 times

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Measuring tools

Post by Lord Aro » 10 Jul 2010 18:38

The numbers shown don't seem to add up properly...
how are they calculated?
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

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4748
Joined: 09 Sep 2007 05:03
Location: home

Re: [Patch] Measuring tools

Post by Alberth » 10 Jul 2010 19:14

Lord Aro wrote:how are they calculated?
Use the source, lord!

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Measuring tools

Post by Lord Aro » 10 Jul 2010 19:22

aahh, but...
it's in linux-line-ending-enter-thingys and i can't be bothered to decipher it... :P
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

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Measuring tools

Post by Zuu » 10 Jul 2010 21:13

Get a real text editor instead of notepad. Even Wordpad that is shipped with Windows can read and understand unix line endings.

Do not tell us that you edit NoAI .nut files with Notepad.... :roll: If that is the case, I recommend you look for something better. Even Notepad++ should give you some pretty advanced features compared to MS Notepad.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Wolf01
Tycoon
Tycoon
Posts: 2013
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: [Patch] Measuring tools

Post by Wolf01 » 10 Jul 2010 22:35

Zuu wrote:Get a real text editor instead of notepad. Even Wordpad that is shipped with Windows can read and understand unix line endings.
I'm sorry but I wasn't of the right mood to use Notepad++ and make, so I used VS2005 to do it...
Lord Aro wrote:The numbers shown don't seem to add up properly...
how are they calculated?
The manhattan distance is the sum of height and width of the rectangle excluded the start tile, the bird fly distance is something of magic, but it should be the euclidean distance (the rectangle diagonal)
The height difference is the same of the other tools, and is the difference from the start tile height and the end tile height.
The height from sea level is the height from the sea level of the tile under your mouse.
If you add up the number correctly, you will get that the start tile has an height of 450m = 400-(-50) <- the start tile is above the end tile so you need to subtract the negative value, and "- * - = +"

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Measuring tools

Post by Lord Aro » 11 Jul 2010 04:27

Zuu wrote: Do not tell us that you edit NoAI .nut files with Notepad.... :roll: If that is the case, I recommend you look for something better. Even Notepad++ should give you some pretty advanced features compared to MS Notepad.
No no no no no...
i only use notepad when using windows, as i regularly can't use anything else (school + no admin rights)
i generally don't like the look of wordpad so i don't use it. i might now. :lol:
i didn't know that notepad was the only program that couldn't read unix line-endings
oh well :roll:
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

User avatar
FooBar
Tycoon
Tycoon
Posts: 6559
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: [Patch] Measuring tools

Post by FooBar » 11 Jul 2010 09:56

Notepad++ is also available in portable edition, so you can bring that to places where you can't install anything: http://portableapps.com/apps/developmen ... p_portable

And compared to any other text editor, Windows Notepad indeed is a piece of crap.

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Measuring tools

Post by Lord Aro » 11 Jul 2010 10:10

ok, ok, i was wrong to use windows notepad
enough off-topic, talk about the patch :!:

(@FooBar - at school i can only run approved programs, i.e. programs they themselves have installed, so it wouldn't work there anyway)
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

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2658
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Measuring tools

Post by ChillCore » 29 Jul 2010 22:40

Hello Wolf01,

Here are a few bugs that were spotted when playing with my patchpack by Moriarty, I have checked with your clean patch bumped to trunk and can confirm them.
While bumping I had to only remove the "true" from the one conflicting line to keep your patch going. (r20240 at time of writing.)
Some of these bugs might probably already be known by you judging by the first post, anyway here they are.
Moriarty wrote: a) The "- Measurement tool" has issues. If you click and do NOT drag but just hold the mouse in place, it starts randomly flickering through numbers for manhatten distances and "bird fly distance".
b) The measurement tool also shows the results of the last measurement if you click but don't drag. Surely it should start with NO results.
Also I noticed a few other things when testing.

- If you have just generated a map and you use the measurement tool on one tile the height from sea sometimes give some weird results. eg. height = 32 meters while the height difference per tile is 50 meters ... very strange.
- Also when measuring on a flat piece of land the height difference is always reported as "50 meters" or "-50 meters" but never 0, except if you have just started the game then it reports 0 meters as it should.

Also attached a screenshot that displays the weird behaviour mentioned above, it is taken while selecting 1 tile and holding it there.

Regards,
ChillCore.

Edit:
Another little bug reported by thetzar.
The "R" shortcut is already used for the removal tool and will prevent the removal tool to be selected by means of the shortcut.
Please ignore, if this is not the case in your clean patch as I have not yet tested this ...
Attachments
After having generated the second game.png
After having generated the second game.png (20.1 KiB) Viewed 10589 times
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

User avatar
Wolf01
Tycoon
Tycoon
Posts: 2013
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: [Patch] Measuring tools

Post by Wolf01 » 04 Aug 2010 13:46

Yes I was aware of those bugs, but consider that this was only a "draft" patch to catch the attention of some other volunteer to bring it on and improve it
I only put the idea and some code to share my needs with others, if somebody wants it, it's here and it's GPL :P

User avatar
Vaulter
Traffic Manager
Traffic Manager
Posts: 185
Joined: 21 Dec 2004 05:35
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Contact:

Re: [Patch] Measuring tools

Post by Vaulter » 31 Jul 2011 10:23

Wolf01 wrote:Yes I was aware of those bugs, but consider that this was only a "draft" patch to catch the attention of some other volunteer to bring it on and improve it
I only put the idea and some code to share my needs with others, if somebody wants it, it's here and it's GPL :P
here is fixed patch with proper initializing to catch those bugs
Attachments
measurement.r22604M.patch
(9.53 KiB) Downloaded 163 times

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Measuring tools

Post by Lord Aro » 15 Feb 2012 18:12

Hey all,

I updated the patch to r23948, and fixed the bugs (unrelated to Vaulter's patch above, didn't see it :))
Attachments
measurement_tool.diff
(6.64 KiB) Downloaded 283 times
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

bcmpinc
Engineer
Engineer
Posts: 19
Joined: 18 Nov 2008 00:10

Re: [Patch] Measuring tools

Post by bcmpinc » 10 Jul 2013 23:25

Updated patch to r25578. Based on vaulters measurement.r22604M.patch.
Attachments
measurement-tool.r25578.patch
(10.05 KiB) Downloaded 281 times

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests