[patch] Programmable waypoints
Moderator: OpenTTD Developers
[patch] Programmable waypoints
This patch provides programmable waypoints. You define a set of criteria per waypoint, and each train that matches that criteria is either assigned a penaltie for crossing it or is denied access to that tile.
Ideas for this patch come from programmable signals in ttdpatch (it at least once was) and the colored trains patch.
Version 0.3: Loading of games is implemented. Loading/saving of the waypoint state not yet. Made a start with converting all RuleSet pointers to a mempool.
Version 0.4: Loading/saving of the game now works! I've tested multiplayer only a little bit (starting openttd twice on my computer) and it seems to work. Also see this post
Version 0.5: Cloning/sharing of rules between waypoints is now possible. New rule: current order. Select a station/waypoint/depot to match. I'm still working on groups. The code works, but the gui does not.
Version 0.6: It's now possible to make rules based on the group a vehicle is in (or not in). Updated to r11834. Due to a savegame-version update in trunk it's not possible to load savegames created with v0.5 or before.
Updated version so it compiles on windows.
The patch is against revision 11834Ideas for this patch come from programmable signals in ttdpatch (it at least once was) and the colored trains patch.
Version 0.3: Loading of games is implemented. Loading/saving of the waypoint state not yet. Made a start with converting all RuleSet pointers to a mempool.
Version 0.4: Loading/saving of the game now works! I've tested multiplayer only a little bit (starting openttd twice on my computer) and it seems to work. Also see this post
Version 0.5: Cloning/sharing of rules between waypoints is now possible. New rule: current order. Select a station/waypoint/depot to match. I'm still working on groups. The code works, but the gui does not.
Version 0.6: It's now possible to make rules based on the group a vehicle is in (or not in). Updated to r11834. Due to a savegame-version update in trunk it's not possible to load savegames created with v0.5 or before.
Updated version so it compiles on windows.
- Attachments
-
- progwaypoints.diff
- Programmable waypoints v0.6
- (61.57 KiB) Downloaded 809 times
Last edited by Yexo on 16 Jan 2008 12:42, edited 11 times in total.
Re: Programmable waypoints
Wonderful, can't wait for it to be released.
I am the Superior Intelligence
Re: Programmable waypoints
Looks like a neat idea Yexo! Sorry I can't help with the coding but I hope you stick with it and get a good feature out of it! 

Re: Programmable waypoints
Hmm, I would prefer the way like TTDP goes, is it possible to programm a signal instead of waypoints?
The problem of waypoints is, you can't place them everywhere and maybe there is no space left for it anyway...
Greets
Ammler
The problem of waypoints is, you can't place them everywhere and maybe there is no space left for it anyway...
Greets
Ammler
Town Names:


Still work in progress: OpenGFX or/and OpenSFX - Please help!
Re: Programmable waypoints
Atm, i ma coding themammler wrote:Hmm, I would prefer the way like TTDP goes, is it possible to programm a signal instead of waypoints?


My patches: Day length (new concept), Conditional loading, Auto separation, Unload all adds Leave empty, Better statue placement (in trunk)
My abandoned patches: Speed limits for RVs, Day length (old concept)
My abandoned patches: Speed limits for RVs, Day length (old concept)
Re: Programmable waypoints
It's relatively easy to change this patch to work on signals instead of waypoints, but initially this was easier. So I'll first make this work and maybe I'll change it later to work on signals instead of waypoints.ammler wrote:Hmm, I would prefer the way like TTDP goes, is it possible to programm a signal instead of waypoints?
The problem of waypoints is, you can't place them everywhere and maybe there is no space left for it anyway...
Greets
Ammler
Re: Programmable waypoints
Just uploaded the first version of the patch. I would like comments about the gui/functionality. See first post for the patch.
Re: Programmable waypoints
Woa that looks awsome!
I think I'm going to test this patch tomorrow.
[EDIT]
[EDIT2]
Would it be possible to check things like cargo-type?
and stuff like that.
I think I'm going to test this patch tomorrow.
[EDIT]
(in english: You compare unsigned integers to signed integers quite often)/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »int GetRuleFromRuleWndPt(Window*, int)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:153: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »void RulesProc(Window*, WindowEvent*)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:330: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »CommandCost CmdChangeRule(TileIndex, uint32, uint32, uint32)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:459: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:463: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »CommandCost CmdRemoveRule(TileIndex, uint32, uint32, uint32)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:549: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:565: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:573: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
[EDIT2]
Would it be possible to check things like cargo-type?
Code: Select all
Cargo is only passengers
Code: Select all
Cargo is not passengers
Code: Select all
Cargo is amongst others passengers
AND
Cargo is not goods
Re: Programmable waypoints
I know, but this is only the first versionBuhmann wrote:Woa that looks awsome!
I think I'm going to test this patch tomorrow.
[EDIT]
(in english: You compare unsigned integers to signed integers quite often)/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »int GetRuleFromRuleWndPt(Window*, int)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:153: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »void RulesProc(Window*, WindowEvent*)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:330: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »CommandCost CmdChangeRule(TileIndex, uint32, uint32, uint32)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:459: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:463: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp: In function »CommandCost CmdRemoveRule(TileIndex, uint32, uint32, uint32)«:
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:549: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:565: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken
/home/thomas/OTTD-dev/test/trunk/src/progsignal.cpp:573: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken

Good idea, hadn't thought of that myself, but I'll try to implement it.[EDIT2]
Would it be possible to check things like cargo-type?Code: Select all
Cargo is only passengers
Code: Select all
Cargo is not passengers
and stuff like that.Code: Select all
Cargo is amongst others passengers AND Cargo is not goods
Re: Programmable waypoints
Would that be the same as:Buhmann wrote: [EDIT2]
Would it be possible to check things like cargo-type?and stuff like that.Code: Select all
Cargo is amongst others passengers
Code: Select all
Cargo includes passengers
Re: Programmable waypoints
That's how I interpretted it. The option will be like this:T-Unit wrote:Would that be the same as:Buhmann wrote: [EDIT2]
Would it be possible to check things like cargo-type?and stuff like that.Code: Select all
Cargo is amongst others passengers
?Code: Select all
Cargo includes passengers
Cargo (passengers) >= 0
AND
Cargo (mail) == 0
So that would match a train with passengers but only those that don't transport mail.
Re: Programmable waypoints
Yap, that's what I meant
But what is the unit for the length of the train?
But what is the unit for the length of the train?
Re: Programmable waypoints
1/8 or 1/16 of a tile. I'll have to fix that to be tile-length.Buhmann wrote:Yap, that's what I meant
But what is the unit for the length of the train?
I have updated the first post to include v0.2 of the patch. Amount of cargo is now one of the options and the compile-time warnings are gone.
Re: [patch] Programmable waypoints
You add three settings variables, and then tell the program that they should be present for save versions 33 through to SL_MAX_VERSION. Since they are not present, the save code cannot read the file. Increment the save version in saveload.cpp, and alter those three variables to be present from 83 onwards, and it should work. Any other variables added to the save will need similar treatment.Yexo wrote: Saving and loading of the state is not yet implemented. And for some reason that I can't find it won't load savegames created with the unmodified version.
Re: [patch] Programmable waypoints
Thank you, I fixed that. Can anyone tell me what block_size_bits in DECLARE_OLD_POOL is for?andrewas wrote:You add three settings variables, and then tell the program that they should be present for save versions 33 through to SL_MAX_VERSION. Since they are not present, the save code cannot read the file. Increment the save version in saveload.cpp, and alter those three variables to be present from 83 onwards, and it should work. Any other variables added to the save will need similar treatment.Yexo wrote: Saving and loading of the state is not yet implemented. And for some reason that I can't find it won't load savegames created with the unmodified version.
Re: [patch] Programmable waypoints
Just uploaded v0.4 of this patch. v0.4 is a diff against r11748. Loading/saving now works completely. With that, multiplayer should also work, but I haven't tested that much. In multiplayer, it's not possible to see the rules of other company's. You'll just get a "Not allowed to change name of waypoint" (or something like it) error.
I'd like to hear more ideas about possible rules. Currently the following is possible:
Maximum speed.
Train length (currently in 1/16 tile-length)
Horsepower
Train weight
The amount of cargo loaded (per cargo-type and total)
The maximum amount of cargo (per cargo-type and total)
True (always matches)
False (never matches)
For every rule, you're able to select </<=/==/>=/> and fill in a value. Multiple rules can be combined with and/or/xor/nand.
Ideas for new rules:
Next order (and pick a station to match)
Last order (and pick a station to match)
Number of days since last service,
Those are a bit more difficult to code, as I'll have to look how I can pick a station. But that'll be version 0.5
If you miss anything, please let me know.
I'd like to hear more ideas about possible rules. Currently the following is possible:
Maximum speed.
Train length (currently in 1/16 tile-length)
Horsepower
Train weight
The amount of cargo loaded (per cargo-type and total)
The maximum amount of cargo (per cargo-type and total)
True (always matches)
False (never matches)
For every rule, you're able to select </<=/==/>=/> and fill in a value. Multiple rules can be combined with and/or/xor/nand.
Ideas for new rules:
Next order (and pick a station to match)
Last order (and pick a station to match)
Number of days since last service,
Those are a bit more difficult to code, as I'll have to look how I can pick a station. But that'll be version 0.5
If you miss anything, please let me know.
- athanasios
- Tycoon
- Posts: 3138
- Joined: 23 Jun 2005 00:09
- Contact:
Re: [patch] Programmable waypoints
Type of cargo isn't in the list?
I don't know if the type of order the train has would be useful. Someone might think to give priority to "Transfer" as such cargo may travel longer distances.
Also what about checking if a train belongs to a specific Group?
Let us say we have 2 lines:
1: From city A to nearby city B (GroupX)
2: From city A to distant city C (GroupY)
Trains are identical. But I want to direct GroupX through a fast lane, as pay rates decrease by time.
Currently I have to use 2 waypoints or with the above option in your patch only 1.
I don't know if the type of order the train has would be useful. Someone might think to give priority to "Transfer" as such cargo may travel longer distances.
Also what about checking if a train belongs to a specific Group?
Let us say we have 2 lines:
1: From city A to nearby city B (GroupX)
2: From city A to distant city C (GroupY)
Trains are identical. But I want to direct GroupX through a fast lane, as pay rates decrease by time.
Currently I have to use 2 waypoints or with the above option in your patch only 1.
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
Re: [patch] Programmable waypoints
Might I suggest a wiki page, once this project matures, to explain how to use these to thicks like me who haven't got a clue about programming?
Re: [patch] Programmable waypoints
What exactly don't you understand? If you can't apply the diff read this post. If you have any question about how to create a set of rules to do something please ask hereAcerbus wrote:Might I suggest a wiki page, once this project matures, to explain how to use these to thicks like me who haven't got a clue about programming?

Well, type of cargo isn't in the list directly, but if you want to select a train with passengers and post, you can make a rule like this:athanasios wrote:Type of cargo isn't in the list?
Cargo loaded (passengers) > 0
AND
Cargo loaded (post) > 0
To select a non-goods train, simply do
Cargo capacity (goods) = 0
That's a good idea. I'll have to do some research about how to get the group a trains belongs to, but that shouldn't be too difficult. Expect it in one of the upcoming versionsI don't know if the type of order the train has would be useful. Someone might think to give priority to "Transfer" as such cargo may travel longer distances.
Also what about checking if a train belongs to a specific Group?
Let us say we have 2 lines:
1: From city A to nearby city B (GroupX)
2: From city A to distant city C (GroupY)
Trains are identical. But I want to direct GroupX through a fast lane, as pay rates decrease by time.
Currently I have to use 2 waypoints or with the above option in your patch only 1.

Re: [patch] Programmable waypoints
This particular case could be solved with the option "next order", couldn't it?
But different penalties for differen't groups would be wonderful, anyway
But different penalties for differen't groups would be wonderful, anyway

Who is online
Users browsing this forum: No registered users and 16 guests