TBTR: Refactor template replacement code

Adjust conditions for re-using existing engines in depot
Reduce cost of searching for existing engines in depot
Reduce cost of vehicle chain membership tests
Improve replacement command error handling
Tidy up code in general
This commit is contained in:
Jonathan G Rennison
2023-03-22 00:15:25 +00:00
parent 5d5e005c5d
commit 1707f74d60
9 changed files with 218 additions and 234 deletions

View File

@@ -658,7 +658,7 @@ public:
/* Draw the number of trains that still need to be treated by the currently selected template replacement */
if (tid != INVALID_TEMPLATE) {
const TemplateVehicle *tv = TemplateVehicle::Get(tid);
const int num_trains = NumTrainsNeedTemplateReplacement(g_id, tv);
const uint num_trains = CountsTrainsNeedingTemplateReplacement(g_id, tv);
// Draw number
SetDParam(0, num_trains);
int inner_right = DrawString(col2 + ScaleGUITrad(4), right - ScaleGUITrad(4), text_y, STR_JUST_INT, num_trains ? TC_ORANGE : TC_GREY, SA_RIGHT);