Code:
SignalProgram::AddLink
SignalProgram::RemoveLink
SignalProgram::ClearAllLinks
Perhaps substitute "Link" with "Input" in these method names. It does seem to fit better with the concepts of your patch.
Code:
+/**
+ * The main command for editing a signal program.
+ * @param tile The tile which contains the edited signal.
+ * @param flags Internal command handler stuff.
+ * @param p1 Bitstuffed items
+ * - p1 = (bit 0-2) - The Track part of the signal program tile.
+ * - p1 = (bit 3-5) - Subcommand to execute.
+ * - p1 = (bit 6-7) - The value to set to the signal program.
+ * @param p2 Target SignalReference for linking of two signals
+ * @return the cost of this operation (which is free), or an error
+ */
+CommandCost CmdProgramLogicSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
+{
+ Track track = (Track) GB(p1, 0, 3);
+ uint32 sub_cmd = GB(p1, 3, 3);
+ uint32 value = GB(p1, 6, 2);
+
...
+
+ if (sub_cmd == 1) {
Perhaps define an enum for the sub_cmd parameter and use the Extract<> method instead of GB so that we get a compiler error if the enum is extended (and the Extract-definition) without updating the command procedure.
Code:
-extern const uint16 SAVEGAME_VERSION = 185; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
In the final version of your patch, only increment the savegame version with one step.
AI APII notice that your patch do not yet address AI support. This is something that in general should be separated into a second patch in a patch queue. Eg. please consider to add it, but use HG queues or the Git equivalent to separate AI support into a separate .patch file as AI support include quite a few bit of generated code which will create a somewhat long patch on itself.
That said, for your initial patch, you should run src/script/api/generate_widget.sh to update the GSWindow class which include references to all widgets in the game.
All files related to AI (and Game Script) API is located in src/script. Eg. add code to src/script/api/script_rail.*, document API additions in src/script/api/ai_changelog.cpp, run src/script/api/squirrel_export.sh to generate some new glue code. If it makes sense, programming signals can possible be included all in AIRail, but it may need also new API classes for the API to make sense. Maybe there should be a AIProgrammingSignalList that list all tiles that contain a programming signal.
_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)