Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Apr 27, 2017 8:43 pm

All times are UTC




Post new topic  Reply to topic  [ 193 posts ]  Go to page 1 2 3 4 510 Next
Author Message
 Post subject: Traffic lights (r17455)
PostPosted: Sat Feb 16, 2008 9:50 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Released a new update for r17455.

Download here: r17455 (win32 binaries also in that post)

---
older post:

Traffic Lights v3 released (r12951)
Download here: r12951

Changelog:
Code:
Codechanges:
- The function for getting the current state of a traffic light tile now looks up what traffic light consist that
tile is in and synches the state with the northernmost tile of the consist (actually: lowest TileIndex) (v2.3)
- Moved traffic light code into own files (trafficlight_func.h, trafficlight_type.h and trafficlight.cpp) (v2.4)
Features:
- If the patch setting for traffic lights is turned off during game, all existing traffic lights
are now deleted permanently. (v2.2)
- Reintroduction of varying switching times. (now not all TLs are switching states simultanuously anymore) (v2.3)
- New patch setting to limit size of traffic light consists. Standard is 4, includes a "no limit" option (0). (v2.3)
Fixes:
- Too high CPU usage (v2.1)
- If traffic lights were turned off during game, it was impossible to remove
roads that had traffic lights on them previously. (v2.2)



---
older post:

Traffic Lights v2.1 released (r12905)
Download here: r12905

Changelog:
Fix:
- Traffic light tiles got marked "dirty" far too often, resulting in high CPU usage.

Traffic Lights v2 released! (r12812)

Download it here: r12812
Changelog:
Code:
Codechanges:
- added new patch setting allow_building_tls_on_town_roads. See Features. (v1.1)
- added new settings road_trafficlight_penalty (yapf) and npf_road_trafficlight_penalty. See Features. (v1.2)
Features:
- New patch option: allow building/removing traffic lights on town owned roads. (v1.1)
- The NPF and YAPF pathfinders now have penalties for traffic lights. They are set to 200 by default,
  you can tweak the settings in your openttd.cfg. (v1.2)
- A traffic light will now not be displayed on a side where there's a one way road so no vehicles can come from there [eye candy] (v1.3)
- Multi tile consists: multiple tiles with trafficlights adjacent to each other will result in one big traffic light junction.
  See examples below. (v1.3)
- The query tool (question mark) will now tell you that there's a traffic light on the road. (v1.4)

Known "Bug":
- you can make traffic lights "invisible" by making every road next to it one way facing away. Then there's no
  visual represenation that there are traffic lights on that tile. I don't really know how to adress that though..
  (who would do something like this, anyways?)

Multi tile consist examples
- |         : roads
< > ^ v     : one way roads
+           : crossing (with TL placed on it)

"crooked crossing":
   |
   |
--++--
  |
  |

"highway x normal road":
    ||
    ||
    v^
----++----
    v^
    ||
    ||

"highway crossing":
    ||
    ||
    v^
---<++<---
--->++>---
    v^
    ||
    ||


screenshot:
Attachment:
File comment: Traffic lights multi tile consists. New in version 2.
TL multi tile consists.png
TL multi tile consists.png [ 36.28 KiB | Viewed 46703 times ]


---
older post:

Traffic Lights v1 released! (r12628)
edit: update for r12733

sorry that it's not quite the newest revision, i'll update it soon.

Download it here: r12628 r12733

Changelog for v1:
Codechanges:
- traffic lights are now controlled by game ticks instead of saving their status to the map array.
This reduces map array usage from 3 bits to 1 bit. Now only highest bit of m1 is "borrowed". ;)
- this also kills the need of misusing the road construction bits for yellow state.
- created some tables to look up stuff instead of using switch cases.
- better savegame version handling
Changes:
- Now, all traffic lights are switched at the same time due to the internal changes.
I might do something to return this to previous behavior if it is requested.
- The random road construction feature was removed and moved to a seperate patch in alpha2.1.
Feature:
- Owner check. Now, you aren't allowed to build or remove traffic lights on opponents' or towns' roads any more.

---
older post:

Alpha 2 now available.
(rediff for r12436)

Most noticeable change: The traffic lights now actually have a purpose (other than eyecandy). Meaning the drivers will not just bluntly ignore them anymore ;)
Also there are some new features, but maybe you want to turn them off, so there are patch options for that now.

Due to the added patch options which are saved in savegames, there is no compatibility with savegames from previous versions of this patch.

reminder:
This patch needs a valid trafficlight.grf to work. You can find in this thread trafficlight_light.grf (works well with most roads), trafficlight_dark.grf (better for light roads like in TTRS) and trafficlight_wooden.grf (if you prefer brown ones). Please choose the one you like, put it into your data folder and rename it to trafficlight.grf

Download alpha 2 here: (r12276) | (r12318) | (r12436)

Changelog for alpha 2:
Codechange:
- Randomize TL placement over the first half of road construction (chance per TileLoop: 5%; total chance: about 33%)

Features:
- Tell road vehicles to stop at red lights (and yellow and red-yellow aswell)
- Patch setting to enable/disable TLs
- Patch setting to enable TLs built by towns while road construction
- Patch setting for random road construction in towns
- Patch setting for duration of green/red phase


Screenshot:
Attachment:
File comment: traffic lights at a road crossing with buses waiting
traffic lights buses.png
traffic lights buses.png [ 35.05 KiB | Viewed 50315 times ]


older post:
---
first public alpha! :D
After fixing a serious bug, I decided now that the patch is ready for a first alpha release ;)

Version alpha1.1

This patch needs a valid trafficlight.grf to work. I'm offering trafficlight_dark.grf and trafficlight_light.grf (thanks Soeb) to download, please choose the one you like, put it into your data folder and rename it to trafficlight.grf
Please note that this version is just eyecandy for now. Road vehicles will NOT stop at red lights. All other kinds of bug reports are welcome, though ;)

Downloads here

Changelog for version alpha1.1:
Fixes:
- Reset roadworks counter properly in some cases, like removing a TL in yellow state, or if road works start on a TL'ed tile
- Draw TLs also without full details and in far zoom level.
- Unexpected behavior in scedit. Therefore, TL transition is now deactivated in scedit.

Codechange:
- Savegame version bumped to 90 (because loading patched savegame with trunk will result in previously TL'ed tiles to have wrong owner "someone")
- TLs stop operation if their tile has roadworks.
- TLs are now displayed while road construction. All sides are set to red. (will be changed to colorless as soon as i have the sprite)
- Adapted new hold-CTRL code for removing trafficlights.
- Changed internals to allow seven states.
- Newly built traffic lights are turned OFF until TileLoop first happens for their tile.

Features:
- Towns build traffic lights on junctions after road construction with a chance (of currently 50%)
- New traffic light transition using six states: red/green, red/yellow, red-yellow/red, green/red, yellow/red and red/red-yellow

Screenshot for alpha1.1:



---
original post:

Hello again! 8)

If you're wondering why I didn't do any upgrades to my other patches lately, this is the reason. ;) I started a new patch project in order to learn some more about different parts of OpenTTD. I did learn a lot up until now, e.g. about sprites, the tilemap, animation of tiles and some more.
But enough about that for now, so what is this patch about?

This patch is aiming to introduce traffic lights, which can be placed on road junctions. Ideally ( :mrgreen: ), road vehicles will wait in front of a red light until it turns green. I don't really know if this will have any positive use on traffic, and I doubt it, as long as RVs are allowed to drive through each other on crossings etc. So i guess some of you will be rather objective towards this patch, as it seemingly makes the conditions for RVs only worse than they are now. :roll:

BUT, i have hope that some of you may like it, even just for its eyecandy-ness :P It might also bring a splash of (*yuk* ;)) realism if the towns will place a heap of traffic lights inside the town, so you'll maybe build roads around a town for your trucks to avoid the inner city where they would wait in front of red lights...

Now after the introduction, the obligatory teaser screen shot ;) Note that it's only eye candy up until now, RVs will just ignore any traffic lights :lol:


Implemented Features:
- Store traffic lights in tile map (m1 bit 5-7 for those interested, I know, meh, but it's so cramped :/)
- Sprites for all 4 directions and all 4 states (red, red-yellow, green, yellow).
- Individually placed traffic lights, depending on junction (3-way, 4-way...)
- consistency check for removing roads (no traffic lights allowed on straight road or curve
- state transistion: switch to yellow/red-yellow every TileLoop, go on to green/red 16 AnimateTiles later (uses the road construction bits for counting)
- driving side support: the traffic lights will be on the driving side specified in the options window


Currently unimplemented, but planned:
- teach pathfinder to stop at red lights
- don't place traffic light at a one way road leading away from the junction
- chained multi tile junction consists
- only owner of road tile may place/remove TLs
- towns place their own TLs
... some more I don't recall right now ;)

---
okay, that's basically it. Here's the sprites I used (drawn myself):


if you want you can supply me with some better ones ;) or just post what you think about the idea and so on...

edit: removed old images


Attachments:
File comment: Traffic lights in action ;)
different states can be seen here, including "OFF" while road construction.

traffic lights screenshot 1.png
traffic lights screenshot 1.png [ 70.76 KiB | Viewed 51437 times ]

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Last edited by Roujin on Mon Sep 07, 2009 3:18 pm, edited 29 times in total.
Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 12:28 am 
Offline
Director
Director

Joined: Fri Jan 05, 2007 3:50 pm
Posts: 611
Location: Poland
Suggestion for future: add 'Fund traffic lights system' to local authority options.

Looks nice, even as an eyecandy.


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 12:59 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Oct 01, 2004 3:28 pm
Posts: 313
And another suggestion for the rather far future:
Make it possible for 2 road vehicles to crash at a junction WITHOUT traffic lights, and decrease this chance by a GREAT amount if there are traffic lights... So you would have a reason to place them :-)

Looks good!


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 1:09 am 
Offline
Traffic Manager
Traffic Manager

Joined: Sat Jun 05, 2004 12:22 pm
Posts: 170
thats a nice feature, it sure livens up the towns even more :)

and having road vehicles crash at crossings would be nice and realistic, especially if traffic lights would reduce this occurrance a lot. it just needs to be tested how much gameplay would be affected. as of now, road vehicles arent exactly getting a lot of benefits, so this might get even worse then. but time will tell, I suppose :)


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 11:28 am 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Thanks for your answers so far..

Quote:
Suggestion for future: add 'Fund traffic lights system' to local authority options.


I already thought a bit how traffic lights on town roads should be handled. In my opinion, towns should build them on their own, maybe more in the inner zones than in the outer ones.
About adding/removing traffic lights on town owned roads as a player, i'm not really sure.. maybe you shouldn't be allowed to do that directly but only with a local authority option like you suggested. But in this case, i'd rather reuse/enhance the "road construction" option. Say, after a road crossing tile had road construction, with a certain given chance the town will place traffic lights on it. So the road construction funding option will include (probably) more traffic lights for the town.

Quote:
And another suggestion for the rather far future:
Make it possible for 2 road vehicles to crash at a junction WITHOUT traffic lights, and decrease this chance by a GREAT amount if there are traffic lights... So you would have a reason to place them :-)


yes, road vehicles being able to crash into each other is veeeeeeery far away right not, I actually doubt I'll be doing this. I think it would need a rewrite of about half of the game :P :P
Something more likely (maybe) is to make the roadvehs follow some sort of rules of traffic on normal crossings. e.g. right one drives before left one. If I were able to implement something like this i guess the traffic lights would actually be useful compared to normal crossings.


---
Thanks for your input, please keep it coming ;)
By the way, are you interested in a release for testing, even if it's only eye candy for now?

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 12:02 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Oct 07, 2007 3:10 pm
Posts: 277
Location: Prague, Czech Republic
Maybe like that?
For what is third sprite?

@EDIT: Notice I changed yellow with green.


Attachments:
trafficlights.png
trafficlights.png [ 1.66 KiB | Viewed 52352 times ]

_________________
Soeb

-- This user is inactive here, to contact me, please send me an e-mail. I'm always willing to answer any questions about graphic coding (or any other stuff I might know about in ottd), though my information might be quite outdated. --
Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 6:13 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Thanks for the sprites Soeb. :)

The third one is for testing/debug... i've made a new debug category called tl (for traffic lights), if you set it to at least 2, tiles with traffic lights will be framed by this yellow frame thing. Idea clearly stolen from PBS, I know ;)
I started with a single tile overlayed instead of every signal on its own. Now this tile is kind of obsolete, but maybe it will be useful for debugging something so I left it in, but you only see it when you set "debug_level tl=2" in the console (or start openttd with "openttd -d tl=2").

Now about your sprites: (before testing them I had to rearrange the order, because I coded it in the order I used... well i could have changed the order in the code as well, but meh :P)

I started with black-greyish lights first as well but i thought it might be not very visible if they are in front of a road because they're (dark) grey aswell. So I settled with brown.
But I've tested yours now, and they do quite well with a lot of grfs (including original). Only with the TTRS roads, it's a bit hard to see them.

However, I noticed you replaced the glowing green light with a darker one, and I suggest reverting this as in game, it doesn't stand out really from the lots of other greens used. For example the icon doesn't stand out much from the toolbar (or did you intend to show a red-yellow traffic light in the icon, instead of all three illuminated?), and the actual traffic lights (esp. the backwards facing ones) don't stand out much compared to the lots of grass and other green stuff in game...
The light green I originally used is iirc also the same brightness as the green of the train signals.

Okay, image attached here: showing what the third sprite is for and showing the low difference of the green in the icon to the toolbar green.
Attachment:
File comment: traffic lights debug mode
traffic lights debug.png
traffic lights debug.png [ 38.96 KiB | Viewed 52179 times ]

Images in next post to illustrate how your TLs look with different road sets.

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 6:18 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Now a little comparison of your sprites with different road sets:

original and OpenGFX:
Attachment:
File comment: Soeb's TLs with original gfx / OpenGFX
TL_Soeb_sprites_orig_OpenGFX.png
TL_Soeb_sprites_orig_OpenGFX.png [ 53.95 KiB | Viewed 52176 times ]


TTRS roads #1 and #2:
Attachment:
File comment: Soeb's TLs with TTRS
TL_Soeb_sprites_TTRS.png
TL_Soeb_sprites_TTRS.png [ 54.39 KiB | Viewed 52157 times ]


North American roads and Japan roads: (Japan has left side driving, of course :lol: )
Attachment:
File comment: Soeb's TLs with North American roads / Japan roads
TL_Soeb_sprites_NA_Japan.png
TL_Soeb_sprites_NA_Japan.png [ 54.54 KiB | Viewed 52095 times ]


Just in case you want to tweak them a bit.. :) Really I like them and they're definately nicer than mine; only the green I'd change to the one I had. ;)

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 7:34 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Oct 07, 2007 3:10 pm
Posts: 277
Location: Prague, Czech Republic
Now I see what it needs. Tomorrow I'll make it a little darker so it's more visible in game.

_________________
Soeb

-- This user is inactive here, to contact me, please send me an e-mail. I'm always willing to answer any questions about graphic coding (or any other stuff I might know about in ottd), though my information might be quite outdated. --


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 9:06 pm 
Offline
Chairman
Chairman
User avatar

Joined: Sun Jul 01, 2007 10:33 pm
Posts: 822
Location: Manchester, UK
I've just had a quick scan of the posts, and thought.

What if people, like myself, have RVs driving on the left hand side ?

As the screenys that have been posted, suggest to me, that traffic lights are set up for RVs driving on the right hand side.

Have you yet to think about this, once you have the patch running, in a stable state ?

If you've already answered this, forgive me, as I only quickly scanned the topic.

0004tom

_________________
Chogie DOT eu

Image


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Sun Feb 17, 2008 9:29 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
look at the "japan set" screenshot at the very bottom of my last post, it features traffic lights on the left side :)
in fact, they are automatically placed on the correct side, according to what driving side you set in the options menu :)

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 4:34 am 
Offline
Traffic Manager
Traffic Manager

Joined: Fri Jul 06, 2007 8:48 am
Posts: 130
Location: Wismar, Germany
I like the idea of cities building traffic lights all over the place and slowing down traffic... for a transport company, traffic lights are usually an obstraction. Stopping trucks from going through city centers would be one of the features, where some more realism couldn't hurt. Combined with speed limits for RVs (another thing that I hope will go into trunk some time), it could make highways much more interesting.
Of course crashes for RVs would also be cool, but I guess it's very hard to do... maybe in v1.0... along with collision for ships, balanced economy and a smart AI *daydreaming*

The graphics look pretty good. In my opinion, they could stay like they are in the latest screenshots.

_________________
halbmoki.tumblr.com <- my blog


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 9:22 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Oct 07, 2007 3:10 pm
Posts: 277
Location: Prague, Czech Republic
Here's a darker version. I hope it'll be more visible now.


Attachments:
trafficlights_dark.png
trafficlights_dark.png [ 1.66 KiB | Viewed 51745 times ]

_________________
Soeb

-- This user is inactive here, to contact me, please send me an e-mail. I'm always willing to answer any questions about graphic coding (or any other stuff I might know about in ottd), though my information might be quite outdated. --
Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 10:51 am 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
I think they do better on the TTRS roads, but a bit harder to see on the original ones as they are dark grey.. it's a problem we can't solve because some sets are lighter, some darker...

But as soon as I release a version of this, I could put both .grf files in the post, with lighter ones and darker ones so one can choose which one he wants according to what kind of roads he uses...

Could you maybe update this (darker one) and also the lighter one you posted before with some things for me?
- give the old, lighter one the lights colors (red, yellow, green) of the newer one
- add another TL for each direction with NO light glowing, I might include that on a crossing which has road works in progress. Currently TLs are not shown for this duration, but maybe it would be even nicer if they stay there, only deactivated.
- could you please sort the TLs for each direction in this order?: red, red-yellow, green, yellow, none (the new one)

That would be really nice 8)

---
Little update since yesterday:
some fixes, little codechange, and as a new feature: towns place TLs themselves on junctions after road works (with a given chance, currently 50%)

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 11:09 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2759
Really nice to see this progressing, it is a popular request!
I think it would be good to link this eyecandy to gameplay - so road vehicle crashes/traffic flow control would be very nice to see. If road vehicle crashes are implemented I think it would be good to have different severities of crash - road vehicles don't tend to crash as spectacularly as planes or trains! Minor crash = both vehicles break down, major crash = boom!

On a technical note what are the bits in the map array normally used for? It would make sense to store traffic lights for road in the same bits as signals for rail...

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 11:14 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Oct 07, 2007 3:10 pm
Posts: 277
Location: Prague, Czech Republic
OK. So here's all updated.


Attachments:
trafficlights.png
trafficlights.png [ 1.71 KiB | Viewed 51693 times ]
trafficlights_dark.png
trafficlights_dark.png [ 1.73 KiB | Viewed 51697 times ]

_________________
Soeb

-- This user is inactive here, to contact me, please send me an e-mail. I'm always willing to answer any questions about graphic coding (or any other stuff I might know about in ottd), though my information might be quite outdated. --
Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 2:14 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Zephyris wrote:
Really nice to see this progressing, it is a popular request!
I think it would be good to link this eyecandy to gameplay - so road vehicle crashes/traffic flow control would be very nice to see. If road vehicle crashes are implemented I think it would be good to have different severities of crash - road vehicles don't tend to crash as spectacularly as planes or trains! Minor crash = both vehicles break down, major crash = boom!

On a technical note what are the bits in the map array normally used for? It would make sense to store traffic lights for road in the same bits as signals for rail...


As I mentioned before, crashes for RVs are not planned by me. Anyone else is free to have a go on that, though ;)

Normally all 8 bits in m1 are used for the owner of the tile, but seemingly only 5 bits are needed to specify the owner currently. Bits 5-7 will always be 0 (well, spectator is FF, but he shouldn't really own roads...). So I introduced checks in SetTileOwner and GetTileOwner if it's a road tile, and if it is only read and write in the lower 5 bits of m1 instead of whole m1. This leaves me with three bits which I use for "Has the tile TLs?" (bit 7) and "Which state have the traffic lights?" (bit 5-6) = 4 states

m1 is normally not for general use, but the map array for road tiles is absolutely cramped. (Check docs/landscape.html and/or docs/landscape_grid.html ) Every single bit is in use, for snow/desert indication, tropic zone indication, which border the roads have (clear, grass, paved, paved with trees and so on..), independant road layouts of three road types (road, tram, a reserved one), independant owners of these three types, which town it belongs to, which directions are forbidden (one way) and 4 bits used for counting when there are road works in progress.
I even re(mis)use the 4 bits of the road works counter for my yellow transition. As traffic lights are shut down anyways when there's road works, these two uses don't conflict with each other...

You see, I wouldn't have used the bits from m1, but there's literally nothing else free for use... okay, i could throw out the third road type and nobody would notice. Or increase the map array size. But I thought it would be the best way to use these three bits from m1...

---
Thanks for the updated sprites Soeb, the deactivated traffic lights while road construction are coded already, it's just using red lights (at all 4 sides) at the moment. I'll update my code to the new sprites now :)
Other stuff done today: adapted new CTRL-hold-code in trunk (lowers remove widget; displays red selector) and set drawing TLs to always, not only with full details on.

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 2:41 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Mon Dec 03, 2007 3:06 pm
Posts: 165
you could have 7 states in 3 bits if you need them, existance of tl is implicit if the bits are not 000

_________________
Gonozal_VIII patchpack


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 3:05 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Thanks for the tip Gonozal. Currently I have these four states:

Code:
Bits 5 6 |  NW  |  SW  |  SE  |  NE
     0 0 | red  | grn  | red  | grn 
     0 1 | r-y  | ylw  | r-y  | ylw 
     1 0 | grn  | red  | grn  | red 
     1 1 | ylw  | r-y  | ylw  | r-y 


If I do it like you say, i could extend it to the following:

Code:
Bits 5 6 7 |  NW  |  SW  |  SE  |  NE
     0 0 0 |  --- no traffic lights ---
     0 0 1 | off  | off  | off  | off
     0 1 0 | red  | grn  | red  | grn
     0 1 1 | red  | ylw  | red  | ylw
     1 0 0 | r-y  | red  | r-y  | red
     1 0 1 | grn  | red  | grn  | red
     1 1 0 | ylw  | red  | ylw  | red
     1 1 1 | red  | r-y  | red  | r-y


Then, 0 is used for no TLs, 1 for road construction (don't really need that because I can just check for road construction, but this makes stuff nicer) and the 2-7 are six states for the crossing. Maybe the transition will look even nicer with this, so thanks for the tip ;)

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: [WIP]Traffic lights
PostPosted: Mon Feb 18, 2008 3:23 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Wed Oct 08, 2003 2:07 pm
Posts: 322
This plus cars would be totally ace. Traffic!!!!!!!

_________________
Open source tycoon games
--
Free Gamer - open source and Free Software games
FreeGameDev forums - open source game development community


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 193 posts ]  Go to page 1 2 3 4 510 Next

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 4 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-2017 phpBB Limited

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