Routefinding/pathfinding restrictions

Got an idea for a new feature in TTDPatch? Post it here.

Moderator: TTDPatch Moderators

Post Reply
User avatar
JGR
Tycoon
Tycoon
Posts: 2604
Joined: 08 Aug 2005 13:46
Location: Ipswich

Routefinding/pathfinding restrictions

Post by JGR »

I have a suggestion.

Would it be feasible for the pathfinding/routefinding code to check for each tile it "follows" whether a "restiction" bit is set; and if so to only treat the tile as crossable if the vehicle for which the routefinder is currently operating satisfies a requirement encoded in a seperate table.
A binary tree based upon the tile's coordinates could be looked up, to lookup the requirement object, if the tile's bit is set.
This would eliminate the need for another landscape array with indexes to the appropiate restriction object.
Restrictions which I am thinking of are:
  • Train length/number of carriages
    Current destination
    Vehicle horsepower
    Vehicle max speed
    Vehicle ID
    Vehicle Type (Train: steam,diesel,electric,mono,maglev...)
Use of these variables with comparison operators:
<,>,<=,>=,==,!=

Possibly any combination of the above using logical operators:
or,and,xor.

As in the following pseudocode.

Btree
WORD xycoord
WORD restriction object id
DWORD PTR less
DWORD PTR more

Restriction Object
BYTE type (enum: 0-unused,1-5 rules: <,>,<=,>=,==,!=, 6-8 logical operators: and,or,xor.)
BYTE variable id
union {
WORD var1 (vehicle id/value/etc)
WORD restriction object id 1
}
union {
WORD var2
WORD restriction object id 2
}

ID's looked up via table

In pathfinder/routefinder:

test BYTE [array],bit
jnz checkrule
checkruleallowed:

save registers and perform check Somehere Else,

UI could be using a window similar to the route window.

However, as I'm not currently on my home machine, I will have to set up the environment before I could start coding, (with possibly a starter).
Finally,where would the best location in the executable for a patch to be inserted, or would it be possible to modify existing pathfinder modification patches, (pathsig.asm?)

Just a suggestion, I could code it if it is feasible.
User avatar
eis_os
TTDPatch Developer
TTDPatch Developer
Posts: 3603
Joined: 07 Mar 2003 13:10
Location: Germany
Contact:

Post by eis_os »

You can can contact me via irc (#tycoon @ quakenet) or patchman...
Übs changes the pathfinder algorithm so it it's called again to reserve the path. So it sits actually on top of it. Josef can give you more informations on that point.

To get a proper pathfinder quite a few things need to be changed. There is actually not on place where you can just put a new pathfinder in... if you want to work on it, simple contact me for more details...

(Actually the whole pathfinder loop needs to changed)
TTDPatch dev in retirement ... Search a grf, try Grf Crawler 0.9 - now with even faster details view and new features...
Image
Post Reply

Return to “Suggestions”

Who is online

Users browsing this forum: No registered users and 19 guests