*SetBit(_me[t].m7, 4) -- is this still free? Are devs willing to sacrifice that bit in the map array for traffic lights? If not how else should it be stored?
According to the files in the docs folder, yes. However I have noticed that sometimes when loading old games/maps (eg.Cindini Map) trafficlights are added to roads rather randomly.
I fixed that in afterload.cpp ... I have not yet noticed this behaviour when loading games made after the patch is included.
*ClearAllTrafficLights() -- This is called when trafficlights setting is set from true to false midgame. It looks a bit as if it could be broken for multiplayer (only executed on server), not sure though. Should be checked.
I can not test multiplayer games. I will disable changing the settings for clients in a later version.
*I feel the "towns build traffic lights during road construction" setting does not make too much sense without the "random road construction" patch I made originally as part of this patch, but split off later. Because without that, towns will only ever have road construction if a player funds it. So either take that feature out or also add the random road construction back into the patch. Unfortunately, this adds new problems: road constructions happen on all roads roads near/inside a town, also player owned ones. With the random road construction + traffic lights patches, players complain that towns will do road construction and place traffic lights on players' "highways" that happen to be too close to the town...
In vanilla OpenTTD, nobody complains about that fact, because (I reckon) the fund road construction option is really really rarely used.
Problem is that it's not trivial to fix. Allow towns only to do road construction on self-owned roads? Bad idea because towns grow into roads placed by players, but never "annex" those roads, so such a mechanic would be needed first. This on the other hand could lead to new griefing possibilities in multiplayer.
So all in all this is opening a can of worms...
(note that my knowledge about implementation of e.g. the roadworks in OpenTTD is from back when I did these patches, so stuff may be different now than how I remember it)
Something to think about indeed ... I left it in for the moment.
* I don't know if devs agree with my idea and/or its implementation of the traffic light consists (adjacent tiles with traffic lights placed on them are merged to one big crossing) at all. I thought I was pretty clever with how I implemented them back then
However looking at it now I'm not fully satisfied, there may be better ways of implementing them.
I like this feature of the patch, so much in fact that I have extended it to allow for 3 by 3 roadgrids to be synchronised too.
To not upset the Devs
, I have also included an option where one can select how far trafficlights look to be synchronised. Minimum setting is 0 so it can be disabled completely.
* devs would maybe want newgrf control over more than the sprites (which would come with properly including them in openttd.grf), say tl phases controllable via newgrf callbacks, or such.
The goal is to have the sprites in the source ... but will that still allow to select the type of signals one wants to use? Devs could pick the version they prefer and add those?
Anyway I am not comfortable with all those grf callbacks (yet) so I will not be adding that code, if needed, for the moment.
* Maybe take out the hardcoded offsets for left-and-right roadside, specify the sprites relative to tile normally. Double the amount of sprites to have left-side-driving and right-side-driving variants (e.g. for half-arc-type TLs that bend over the road, the current offset scheme won't do).
Not comfortable with that neither ... I could use some help here ... Is Someone present?
Unfortunately I'm not really interested in picking up work on this patch again, but if anyone else is (well ChillCore, you're already at it it seems), be my guest
No problem. I had to recompile your grf(s) with DOS sprites for the patch to work correctly with current trunk.
Would you mind linking to them from the first post and is it OK if I continue using your thread? Or would you rather have me creating a new one to avoid confusion?
Final question: I have not added a lisence to the grfs because I could not find which one you want(ed) to use. Would it be OK for me to add the GPL lisence, same version as OpenTTD?
Thank you for the many usefull coments Roujin, below is what I have changed so far.
I think I'll just jump in and express my support for any continued development of this patch, I think it can make the game more interesting, fun and, dare I say it, realistic!
Enoy the attached version. Do grab the recompiled GRF(s) you will need them to avoid pinky sprites.
- Added a new file -> trafficlight.h (I have put the arrays here that are used by the patch).
- Added headers to the new files -> mentioning that OpenTTD's source is GPL.
- Little bit of coding style in the documentation.
- Trafficlight can now look 4 tiles away for synchronising themselves (square).
- Added option to select the distance trafficlights look for synchronising themselves (min is 0 -> no synchronising), max is 4 -> for 3 by 3 road grids))
- Added two more error messages (building trafficlights is disabled and building them on town roads is disabled).
- STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD -> STR_ERROR_TRAFFIC_LIGHTS_NOT_ALLOWED_ON_TOWN_ROADS
- Removed the debugging code.
- Recompiled the GRF(s) with DOS sprites and removed debugging sprite.
- The sprites are re-introduced in the old way so most likely when sprites are added to openttd.grf there is no need for adjustments.
- Savegamecode adjusted to ini files where needed.
- TL_SV instead of 200 in savegamecode.
- When loading older savegames loop over the entire map and remove all trafficlights that ay be present (I do not know i this bug was present in a version before I bumped the patch)