Wednesday 17 May 2017

TrafficControl: Refactoring the Train::move() Function (3)

The refactoring task is done now, according to the state model I described before.

Most of the refactoring was done in the tcTrain method. I found some redundant code, that I've been able to remove.

I also found a bug: The variable nextTrack, that records the ID of the next track the train should select was never reset. Later, when the train arrived at a station, the value of that parameter made the program need to search for suitable tracks twice, instead of once. The end result was the same, so the bug wasn't visible.

The next step in the implementation will be to add tracks to the QML map.

No comments:

Post a Comment