City Influence Area Patch
Moderator: OpenTTD Developers
City Influence Area Patch
Today I started working on my first patch. I thought : let's start with someting easy:
The City Outline, described here.
My first results are promissing, see the attached patch.
Current "features"
A new button in the city window, "Radius", when clicked on it will bulldoze all the tiles in the city influence radius. Be sure to have enough money to do this (it could make it "Plant Trees" but the effect is not as clear as with bulldoze)
The reason to bulldoze is simple: I don't know how to outline/select/lightup a set of tiles. Further more the tiles are in a odd shape, for instance if more towns are close together. Any hint are welcome!
--edit: Changed the Bulldoze-action into Farmfences, little less agressive.
Sideaffects: Fence will disappear in desert and snow areas
But keep in mind, not all is done yet
--edit 2:
Done!
My first real patch is done! There is now an extra button in the city window. It toggles the display of the influence array of that city. The area is marked with blu squares (like the capture area of stations).
The City Outline, described here.
My first results are promissing, see the attached patch.
Current "features"
A new button in the city window, "Radius", when clicked on it will bulldoze all the tiles in the city influence radius. Be sure to have enough money to do this (it could make it "Plant Trees" but the effect is not as clear as with bulldoze)
The reason to bulldoze is simple: I don't know how to outline/select/lightup a set of tiles. Further more the tiles are in a odd shape, for instance if more towns are close together. Any hint are welcome!
--edit: Changed the Bulldoze-action into Farmfences, little less agressive.
Sideaffects: Fence will disappear in desert and snow areas
But keep in mind, not all is done yet
--edit 2:
Done!
My first real patch is done! There is now an extra button in the city window. It toggles the display of the influence array of that city. The area is marked with blu squares (like the capture area of stations).
- Attachments
-
- CityRadius.diff
- This patch adds an extra button in the city radius window, that toggles the display of the city influence array in the map.
- (6.55 KiB) Downloaded 295 times
Last edited by Dribbel on 15 Jul 2004 04:04, edited 2 times in total.
Programmeren is makkelijker als je denkt - Dutch pun
[url=callto://zoekdribbel][/url]
[url=callto://zoekdribbel][/url]
red border sounds ok toominime wrote:He probably had that as an initial step in development, to see if it finds the tiles correctly.
Anyway, how about highlighting them with that red border, similar to how an invalid tile (for example when building tunnel in the wrong place, or when something prevents you from lowering terrain..)?
btw how can location be "Czech rep./Canada" Did the Czechs conquer Canada? Or did Canada steal the Czech rep.? Since they want to steal a Danish Island, I will expect everything from them
Indeed the bulldozing is to check if i got the right tiles More friendly is to place trees, or no action at all. Framfences is a good idea, for now, far less destructive, --> Check the new patch above.
The problem with the red-square is that the current code only suports ONE red-square at the time, as far as i know. The white squares I haven't figured out yet, but the seem only to appear in line/rectangles and not in odd-shaped figures. I have to do some more research (read: code exploration) on that. I can't even make a simple white square appear in or near the city :'(
If any one has any (coding) ideas on the white squares, please tell me
The problem with the red-square is that the current code only suports ONE red-square at the time, as far as i know. The white squares I haven't figured out yet, but the seem only to appear in line/rectangles and not in odd-shaped figures. I have to do some more research (read: code exploration) on that. I can't even make a simple white square appear in or near the city :'(
If any one has any (coding) ideas on the white squares, please tell me
Last edited by Dribbel on 13 Jul 2004 01:55, edited 1 time in total.
Programmeren is makkelijker als je denkt - Dutch pun
[url=callto://zoekdribbel][/url]
[url=callto://zoekdribbel][/url]
- minime
- Transport Coordinator
- Posts: 339
- Joined: 18 Jan 2004 10:02
- Skype: dan.masek
- Location: Prague, Czech Republic
- Contact:
I suppose we could nip a little piece of their land, it's not like they don't have enough
The truth is, I'm from the first, did my uni at the second (which is when I made this account) and am going back shortly, so either one can apply, depending on the time of the year. And I couldn't really be bothered to change it.
The truth is, I'm from the first, did my uni at the second (which is when I made this account) and am going back shortly, so either one can apply, depending on the time of the year. And I couldn't really be bothered to change it.
It seems that the white/red square are linked to mouse events. Decoupling them is a hell of a job.
An other solution is to create an overlay data structure. This is also lots of work, but when done properly, it can be used for many more cool yet-to-be-thought-of features!
I'll see if i can pull this one off. I'ts quite a challenge But what the heck it's summer holidays and the weather is Terrible :'( (note the capital T)
An other solution is to create an overlay data structure. This is also lots of work, but when done properly, it can be used for many more cool yet-to-be-thought-of features!
I'll see if i can pull this one off. I'ts quite a challenge But what the heck it's summer holidays and the weather is Terrible :'( (note the capital T)
Programmeren is makkelijker als je denkt - Dutch pun
[url=callto://zoekdribbel][/url]
[url=callto://zoekdribbel][/url]
- Mad Dog McKill
- President
- Posts: 911
- Joined: 13 Nov 2002 10:24
- Location: Singapore but originally Moscow
I hope so.. but its a pity that many patches are put aside or are forgot about...
I am sure that there many more such small and useful patches
I am sure that there many more such small and useful patches
OT: By FIREMARK: "Limitation disturbs me very sprites. Goes it throw out limitation?"
My Last.fm Profile
My Facebook Profile
My Last.fm Profile
My Facebook Profile
Thanks Dribble, I like this patch a lot, its very useful. Clearly, the performance problem in your for-loop had to be fixed, so I took a moment (a lot longer than I had anticipated) and did.
Change this bit...
...into this:
and it's all snappy!
Glad I found those xx_TILE_LOOP macro's. I had been doing a lot of unnecessary work up to then.
I'm completely new to TortoiseSVN and patch/diff, but I'll try and make a new patch out of this.
edit That wasn't too hard. Patch against revision 120 is attached.
Change this bit...
Code: Select all
//Check all the tiles, hmm could be more efficient:
// Look up all the tiles in all directions with
// distance < _patches.dist_local_authority and check those
for(tile=0; tile!=TILES_X*TILES_Y; tile++) {
found = ClosestTownFromTile(tile, _patches.dist_local_authority);
if (found != NULL && found->index == index){
// Now to create an overlay for all tiles...
SetMapExtraBits2(tile, on);
MarkTileDirtyByTile(tile);
}
}
Code: Select all
int pdla = _patches.dist_local_authority;
int x = max(0, GET_TILE_X(t->xy) - pdla); // town_center x - authority radius
int y = max(0, GET_TILE_Y(t->xy) - pdla); // town_center y - authority radius
// loop from (town_center - radius) to (town_center + radius)
BEGIN_TILE_LOOP(tile, 2*pdla, 2*pdla, TILE_XY(x,y))
found = ClosestTownFromTile(tile, pdla);
if (found != NULL && found->index == index)
{
SetMapExtraBits2(tile,on);
MarkTileDirtyByTile(tile);
}
END_TILE_LOOP(tile, 2*pdla, 2*pdla, TILE_XY(x,y))
Glad I found those xx_TILE_LOOP macro's. I had been doing a lot of unnecessary work up to then.
I'm completely new to TortoiseSVN and patch/diff, but I'll try and make a new patch out of this.
edit That wasn't too hard. Patch against revision 120 is attached.
- Attachments
-
- CityRadius.diff
- Patch against SVN rev120, adding the CityRadius patch with the improved algorithm.
- (7.35 KiB) Downloaded 246 times
I'm on windows... I made the patch . Seriously though, I'd send you an exe but it'd be of no use to you. I can't compile with ZLIB support (long story), can't address that problem (same story) and therefore none of my builds support the savegame format.CSL wrote:Wow that's really nice
Would someone please compile the nightly build with this patch and upload the compiled version here?
Many thanks...I am using Windows...can't apply this patch
The patch needs to be rewritten anyway. It should run right in the map tile rendering loop, saving lots of memory and quite a bit of CPU time as well. It's not fit to be merged into the main branch as it is.
You can learn how to do that on the wiki:CSL wrote:Would someone please compile the nightly build with this patch and upload the compiled version here?
http://openttd.rulez.org/wiki2/index.ph ... evelopment
"Set fashion, not follow. Spit vitriol, not swallow" - Marilyn Manson
Any chance for this to be in the NEXT nightly build? I'd appreciate it much and there's a lot of steps to "patch" my openttd...(download the source, install TortoiseSVN, follow the steps to patch it, install cygwin/msvs, follow the steps to compile it)...It's just A LOT to ask newbies to do who dont know anything about programming or compiling....
I don't see why this WOULDN'T be included in a nightly, it would be great to use this instead of using the query tool in the dark lol
I don't see why this WOULDN'T be included in a nightly, it would be great to use this instead of using the query tool in the dark lol
No chance for the next nightly, no. Like Doc Oc said, it's not ready to be added to SVN. It is still too complicated implemented and eats up too much memory and CPU cycles. But I'm confident that it will make it into SVN eventually.
"There's a readme that comes with the source. I suggest you read it."
- Korenn
- Korenn
Wow many thanks!mdhowe wrote:You can learn how to do that on the wiki:CSL wrote:Would someone please compile the nightly build with this patch and upload the compiled version here?
http://openttd.rulez.org/wiki2/index.ph ... evelopment
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 20 guests