Routing Restriction (Programmable waypoint) / Virtual group

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
Gedemon
Traffic Manager
Traffic Manager
Posts: 150
Joined: 29 Apr 2004 21:53

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by Gedemon »

nycom, would it be a lot of work to make a version compatible with tracksharing ?

(ie : all trains should follow rules for a waypoint, not only the waypoint owner's trains)
zypa
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 30 Mar 2006 12:05
Location: Germany
Contact:

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by zypa »

Is this patch still in development?
It is a really useful patch. It would be a pitty if it will be really outdated in some weeks...
MacJariel
Engineer
Engineer
Posts: 1
Joined: 29 May 2008 10:44

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by MacJariel »

I found a bug. When you click on the waypoint gui window and miss any widget the game terminates:

Code: Select all

Error: NOT_REACHED triggered at line 83 of /usr/local/src/games/openttd/openttd-svn-routing-restriction/src/waypoint_gui.cpp
There is a simple fix: comment that line 83 in waypoint_gui.cpp.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by planetmaker »

MacJariel wrote:I found a bug. When you click on the waypoint gui window and miss any widget the game terminates:

Code: Select all

Error: NOT_REACHED triggered at line 83 of /usr/local/src/games/openttd/openttd-svn-routing-restriction/src/waypoint_gui.cpp
There is a simple fix: comment that line 83 in waypoint_gui.cpp.
That certainly is no fix, but a dirty hack. The lines which contain "NOT_REACHED" are parts of case or switch statements where all possibilities are handled before - and something went wrong, if they're reached. Basically commenting out this line is a fixing the symptoms rather than the cause.
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by richk67 »

Ah... commenting out. The "I dont understand it, and cannot debug it, so hide it and maybe it will go away." approach.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by Roujin »

Actually in this case, i'd say it is the right fix.
The author didn't handle all the widgets in the switchcase, only those that do something special. Thus the rest (like, background panel) gets handled by "default:", and thus, it shouldn't have NOT_REACHED().

Now the other way would be adding all missing widgets, with just a break; and then leave the NOT_REACHED() for default.
But why not let default handle all other widgets, for which nothing should happen?
* @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
zombie
Traffic Manager
Traffic Manager
Posts: 153
Joined: 19 May 2005 22:19
Location: Germany

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by zombie »

Hi.

That's quite easy to answer: If you add a widget and forget handling it you get the error message on testing your modifications and you know where to add the code.

Kind regards

Zombie
OpenTTD: OpenTTD-Wiki
OpenTTDCoop: Blog, Wiki
My favorite patches: cargo destinations, shared infrastructure
Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by Splatman »

Updated to r13310, I have removed the default: NOT_REACHED(); to match the style of other OnClick() functions in the game.

I haven't done extensive testing, but it seems to work.

EDIT: Scrap that I forgot to include the extra files in the patch will upload a fixed version later.
nycom
Engineer
Engineer
Posts: 62
Joined: 14 Nov 2005 13:14
Location: Paris, France

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by nycom »

Patch updated (cf first post)
nautre125
Engineer
Engineer
Posts: 74
Joined: 04 Feb 2008 10:58
Location: Strasbourg, France

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by nautre125 »

Would it be possible to implement programmable signals ? having signals that turn red if the oncoming trains doesn't match the conditions. I didn't looked into your code but the principle of programmable waypoints makes me think of the TTDP feature: programmable signals.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by Roujin »

zombie wrote:Hi.

That's quite easy to answer: If you add a widget and forget handling it you get the error message on testing your modifications and you know where to add the code.

Kind regards

Zombie
Uhmm.. yeah, makes sense.
Still kind of arkward imo adding special cases for all the widgets only to tell it to do nothing with them.

In the long run you're right though..
* @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
Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by Splatman »

I've found a bug, when you try to save multiline rules in multiplayer the game gets stuck in an infinite loop on a DoCommandP in rule_gui.cpp it seems to be the following lines

Code: Select all

while (rs->GetNumCriteria() < this->num_criteria)
    DoCommandP(0, rs->index, 0, NULL, CMD_ADD_CRITERIA | CMD_MSG(STR_RULE_CAN_T_ADD_CRITERIA));
while (rs->GetNumCriteria() > this->num_criteria)
    DoCommandP(0, rs->index, rs->GetNumCriteria() - 1, NULL, CMD_DELETE_CRITERIA | CMD_MSG(STR_RULE_CAN_T_DELETE_CRITERIA));
It gets stuck on the fist DoCommandP. This seems to be because the Command is queued, but can't ever execute because the while loop is still running.
sir_schwick
Engineer
Engineer
Posts: 22
Joined: 26 Jul 2008 03:09

Re: Routing Restriction (Programmable waypoint) / Virtual group

Post by sir_schwick »

Any chance you or somebody closely related is going to extend the rule options to other forms of transport? This patch is extremely useful and time saving, but would be ultra useful for quickly grouping road vehicles. Excellent work!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 1 guest