45° rotated rectangle clearing / leveling patch
Moderator: OpenTTD Developers
- NukeBuster
- Traffic Manager
- Posts: 222
- Joined: 04 Jan 2006 18:16
- Location: Alphen aan den Rijn, The Netherlands
- Contact:
The compiler warnings about viewport.cpp are now fixed, Thanks to Eddi(irc, don't know forum nick.)
Please test this patch. Also please give me some feedback on the code.
Patched against r10414
Please test this patch. Also please give me some feedback on the code.
Patched against r10414
- Attachments
-
- diagonal_demolish_and_leveling_r10414_177.patch
- (21.76 KiB) Downloaded 159 times
NukeBuster
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
-
- Engineer
- Posts: 11
- Joined: 17 Jan 2007 12:06
- belugas
- OpenTTD Developer
- Posts: 1507
- Joined: 05 Apr 2005 01:48
- Location: Deep down the deepest blue
- Contact:
A patch, in this context, means a difference on the source code level. Not an executable that can modify the binary of the 0.5.2.r_a_s_robin wrote:Is there anyway to apply this patch to 0.5.2?
I'm not a code expert but i have seen that some copy-paste tool could just be installed without compiling or anything like that. Maybe something like that is possible for this great patch as well?
So, no, this cannot be applied without a full recompilation of the code-source of 0.5.2.
Furthermore, 0.5.2 is an older version of the code, still written in C, while this patch is aimed for C++ in trunk. So, unless the author adapt it for the 0.5.2 environnement, not a chance.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
-
- Engineer
- Posts: 11
- Joined: 17 Jan 2007 12:06
- belugas
- OpenTTD Developer
- Posts: 1507
- Joined: 05 Apr 2005 01:48
- Location: Deep down the deepest blue
- Contact:
When we decide it can be included in trunk.r_a_s_robin wrote:When will it be in the nightly versions?
When we think it is ready for trunk.
When we are sure it will not break anything.
When we'll have time to evaluate the code and
when we'll have time to merge it.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
- NukeBuster
- Traffic Manager
- Posts: 222
- Joined: 04 Jan 2006 18:16
- Location: Alphen aan den Rijn, The Netherlands
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
- Attachments
-
- diagonal_demolish_and_leveling_r10644.patch
- (21.58 KiB) Downloaded 147 times
NukeBuster
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
- belugas
- OpenTTD Developer
- Posts: 1507
- Joined: 05 Apr 2005 01:48
- Location: Deep down the deepest blue
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
Little note :
could very well be cleaner with
Another note :
could be made the same as
If you see what i mean
Watch out, there are roaming tabs here and there
I still like that patch
Code: Select all
+ if (((fx >= 0 && xx <= fx && xx >= 0) || (fx < 0 && xx >= fx && xx <= 0)) &&
+ ((fy >= 0 && yy <= fy && yy >= 0) || (fy < 0 && yy >= fy && yy <= 0))) {
+ return true;
+ } else {
+ return false;
Code: Select all
+ return ((fx >= 0 && xx <= fx && xx >= 0) || (fx < 0 && xx >= fx && xx <= 0)) &&
+ ((fy >= 0 && yy <= fy && yy >= 0) || (fy < 0 && yy >= fy && yy <= 0));
Code: Select all
ex >= sx ? x += 1 : x -= 1;
Code: Select all
curh += (curh > h) ? -1 : 1;
Watch out, there are roaming tabs here and there
I still like that patch
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
- NukeBuster
- Traffic Manager
- Posts: 222
- Joined: 04 Jan 2006 18:16
- Location: Alphen aan den Rijn, The Netherlands
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
I've implemented your coding suggestions and am looking through the code to eliminate all the instances.
There is one thing troubeling me, there are 3 or 4 parts in the code that are almost the same... I'm looking into if it is worth making a function.
There is one thing troubeling me, there are 3 or 4 parts in the code that are almost the same... I'm looking into if it is worth making a function.
NukeBuster
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Re: 45° rotated rectangle clearing / leveling patch
Definitely. Though if it is called often, it may possibly be worthy to declare it as inline function, which will essentially instruct the compliler to fut the function code directly where the function was called, saving the call.NukeBuster wrote:I've implemented your coding suggestions and am looking through the code to eliminate all the instances.
There is one thing troubeling me, there are 3 or 4 parts in the code that are almost the same... I'm looking into if it is worth making a function.
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- belugas
- OpenTTD Developer
- Posts: 1507
- Joined: 05 Apr 2005 01:48
- Location: Deep down the deepest blue
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
Might be a big inline... We are not too fund of big inline functions...
And definitively not macros too
And definitively not macros too
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Re: 45° rotated rectangle clearing / leveling patch
Well, if it is big, then make it ordinary function - not inline. Basically, the difference in source is just having/not having inline keyword (+ some conventions that inline functions have to be in headers, non-inline not (only declaration should be there), which can be solved by simply moving the function around :)), though the generated binary is then quite different fopr inline/non-inline case;)
Inline is good for very small functions like "return m[x].something" where the call overhead would be large.
Inline is good for very small functions like "return m[x].something" where the call overhead would be large.
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- NukeBuster
- Traffic Manager
- Posts: 222
- Joined: 04 Jan 2006 18:16
- Location: Alphen aan den Rijn, The Netherlands
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
The function will replace code in viewport.cpp, landscape.cpp and cmd_clear.cpp in which file should the function reside?
NukeBuster
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Re: 45° rotated rectangle clearing / leveling patch
Depends on what the function does - it should be put near "similar" functions. If unsure, I'd stick the function body probably in landscape.cpp, and its declaration in landscape.h as I think it would be probably the correct place for it. It can be easily moved if necessary, after all :)
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Re: 45° rotated rectangle clearing / leveling patch
Is this patch network-compatible with vanilla nightly?
Re: 45° rotated rectangle clearing / leveling patch
As I looked in the patch - since it modifies the network protocol for leveling and clearing area by adding flag for dialognal clear ... no. Unfortunately, it is not network compatible - i.e. both you and server either need to have or have not the patch.mamuf wrote:Is this patch network-compatible with vanilla nightly?
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- NukeBuster
- Traffic Manager
- Posts: 222
- Joined: 04 Jan 2006 18:16
- Location: Alphen aan den Rijn, The Netherlands
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
Thanks for the help on the function. I am still looking into that.
Updated the patch to the latest nightly(r10684). No new features or big code changes were added.
Updated the patch to the latest nightly(r10684). No new features or big code changes were added.
- Attachments
-
- diagonal_demolish_and_leveling_r10684.patch
- (21.54 KiB) Downloaded 175 times
NukeBuster
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !
OpenTTD patch(es): Password at join
- belugas
- OpenTTD Developer
- Posts: 1507
- Joined: 05 Apr 2005 01:48
- Location: Deep down the deepest blue
- Contact:
Re: 45° rotated rectangle clearing / leveling patch
Looks really better
But indeed, still that code duplication that is irritating (not your fault, by the way)...
But indeed, still that code duplication that is irritating (not your fault, by the way)...
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Re: 45° rotated rectangle clearing / leveling patch
Shorter yes - I dunno about "cleaner" though - his code makes the return value obviously a boolean, and your code is a bit less obvious.could very well be cleaner with
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
Re: 45° rotated rectangle clearing / leveling patch
belugas wrote:Little note :could very well be cleaner withCode: Select all
+ if (((fx >= 0 && xx <= fx && xx >= 0) || (fx < 0 && xx >= fx && xx <= 0)) && + ((fy >= 0 && yy <= fy && yy >= 0) || (fy < 0 && yy >= fy && yy <= 0))) { + return true; + } else { + return false;
Code: Select all
+ return ((fx >= 0 && xx <= fx && xx >= 0) || (fx < 0 && xx >= fx && xx <= 0)) && + ((fy >= 0 && yy <= fy && yy >= 0) || (fy < 0 && yy >= fy && yy <= 0));
What's the return value of || or && ? Obviously boolean, since they're logic operators, so no need for the if. Everything else is just cosmetics i think.CobraA1 wrote: Shorter yes - I dunno about "cleaner" though - his code makes the return value obviously a boolean, and your code is a bit less obvious.
Who is online
Users browsing this forum: No registered users and 8 guests