Hi folks. Recently I was intensively working on the patch and accomplished some nice new features like preview, copy/pasting stations and heights adjustment. I'll publish the patch when OTTD 1.3.0 will be released.
For now,
I have a question to devs. Could you give me some advice please? I'm struggling with a way how to alter the commands system.
Some tile contents can't be pasted by a single command. Rail waypoints for example. We have to place a track in order to build a waypoint. Also docks, ship depots and buoys come with the same problem - if not on water, canal has to be placed before we build them (it's the way the patch works). While I could just run one command after another, it sucks when it's about cost calculations (shift+click). We will get inaccurate results because the second command can fail (e.g building a rail waypoint will fail if the track is not yet there).
I would like to do something with this imperfection. There are 6 solutions coming to my mind:
- Do nothing. Let the cost calculation be inaccurate (I really dislike this approach).
- Add totally new commands doing the work in a single step (e.g. "build a waypoint along with the track")
- Add new switches (some p1/p2 bits) to existing commands directing them to do the work in a single step (e.g. p2 bit 16 of the CMD_BUILD_RAIL_WAYPOINT could direct the command to build the track if it's not present already)
- Make a new DoCommandFlag and pass it to commands when pasting. The flag would alter the way the command works:
- ignore some hindrances when not DC_EXEC'ing (e.g. ignore that there is no track when building a waypoint)
- do the work in a single step (e.g. place the track when building waypoint)
- Do cost calculations without calling commands (just reuse some pieces of commands code)
2, 3 and 4b is about making the work in a single step (by a single command) while 4a is not (4a is hack-ish a bit).
2 and 3 do alter "normal" command system (new features can be used even when not pasting) while 4a and 4b don't.
3 does alter current commands protocol, 2 doesn't (it just adds new commands).
5 seems to me not being the way it should be done
I'm wondering which way is the best. Any thoughts? Any new ideas?