Page 1 of 1

[Patch] Measuring tools

Posted: 10 Jul 2010 18:14
by Wolf01
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.

Re: [Patch] Measuring tools

Posted: 10 Jul 2010 18:38
by Lord Aro
The numbers shown don't seem to add up properly...
how are they calculated?

Re: [Patch] Measuring tools

Posted: 10 Jul 2010 19:14
by Alberth
Lord Aro wrote:how are they calculated?
Use the source, lord!

Re: [Patch] Measuring tools

Posted: 10 Jul 2010 19:22
by Lord Aro
aahh, but...
it's in linux-line-ending-enter-thingys and i can't be bothered to decipher it... :P

Re: [Patch] Measuring tools

Posted: 10 Jul 2010 21:13
by Zuu
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.

Re: [Patch] Measuring tools

Posted: 10 Jul 2010 22:35
by Wolf01
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 "- * - = +"

Re: [Patch] Measuring tools

Posted: 11 Jul 2010 04:27
by Lord Aro
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:

Re: [Patch] Measuring tools

Posted: 11 Jul 2010 09:56
by FooBar
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.

Re: [Patch] Measuring tools

Posted: 11 Jul 2010 10:10
by Lord Aro
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)

Re: [Patch] Measuring tools

Posted: 29 Jul 2010 22:40
by ChillCore
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 ...

Re: [Patch] Measuring tools

Posted: 04 Aug 2010 13:46
by Wolf01
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

Re: [Patch] Measuring tools

Posted: 31 Jul 2011 10:23
by Vaulter
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

Re: [Patch] Measuring tools

Posted: 15 Feb 2012 18:12
by Lord Aro
Hey all,

I updated the patch to r23948, and fixed the bugs (unrelated to Vaulter's patch above, didn't see it :))

Re: [Patch] Measuring tools

Posted: 10 Jul 2013 23:25
by bcmpinc
Updated patch to r25578. Based on vaulters measurement.r22604M.patch.