TBTR: Fix various formatting and const issues

pull/737/head
Jonathan G Rennison 3 weeks ago
parent 4546c37ee2
commit 6a292f9f58

@ -303,9 +303,8 @@ TBTRDiffFlags TrainTemplateDifference(const Train *t, const TemplateVehicle *tv)
void BreakUpRemainders(Train *t) void BreakUpRemainders(Train *t)
{ {
while (t != nullptr) { while (t != nullptr) {
Train *move;
if (HasBit(t->subtype, GVSF_ENGINE)) { if (HasBit(t->subtype, GVSF_ENGINE)) {
move = t; Train *move = t;
t = t->Next(); t = t->Next();
DoCommand(move->tile, move->index | (1 << 22), INVALID_VEHICLE, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); DoCommand(move->tile, move->index | (1 << 22), INVALID_VEHICLE, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
NeutralizeStatus(move); NeutralizeStatus(move);
@ -315,19 +314,12 @@ void BreakUpRemainders(Train *t)
} }
} }
/* Make sure the real train wagon has the right cargo */
void CopyWagonStatus(TemplateVehicle *from, Train *to)
{
to->cargo_type = from->cargo_type;
to->cargo_subtype = from->cargo_subtype;
}
uint CountTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *tv) uint CountTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *tv)
{ {
uint count = 0; uint count = 0;
if (tv == nullptr) return count; if (tv == nullptr) return count;
for (Train *t : Train::IterateFrontOnly()) { for (const Train *t : Train::IterateFrontOnly()) {
if (t->IsPrimaryVehicle() && t->group_id == g_id && TrainTemplateDifference(t, tv) != TBTRDF_NONE) { if (t->IsPrimaryVehicle() && t->group_id == g_id && TrainTemplateDifference(t, tv) != TBTRDF_NONE) {
count++; count++;
} }
@ -336,7 +328,7 @@ uint CountTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *
} }
/* Refit each vehicle in t as is in tv, assume t and tv contain the same types of vehicles */ /* Refit each vehicle in t as is in tv, assume t and tv contain the same types of vehicles */
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags) CommandCost CmdRefitTrainFromTemplate(Train *t, const TemplateVehicle *tv, DoCommandFlag flags)
{ {
CommandCost cost(t->GetExpenseType(false)); CommandCost cost(t->GetExpenseType(false));
@ -353,7 +345,7 @@ CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFl
} }
/* Set unit direction of each vehicle in t as is in tv, assume t and tv contain the same types of vehicles */ /* Set unit direction of each vehicle in t as is in tv, assume t and tv contain the same types of vehicles */
CommandCost CmdSetTrainUnitDirectionFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags) CommandCost CmdSetTrainUnitDirectionFromTemplate(Train *t, const TemplateVehicle *tv, DoCommandFlag flags)
{ {
CommandCost cost(t->GetExpenseType(false)); CommandCost cost(t->GetExpenseType(false));
@ -373,7 +365,7 @@ CommandCost CmdSetTrainUnitDirectionFromTemplate(Train *t, TemplateVehicle *tv,
* actually moving vehicles around to work properly. * actually moving vehicles around to work properly.
* We do this worst-cast test instead. * We do this worst-cast test instead.
*/ */
CommandCost TestBuyAllTemplateVehiclesInChain(TemplateVehicle *tv, TileIndex tile) CommandCost TestBuyAllTemplateVehiclesInChain(const TemplateVehicle *tv, TileIndex tile)
{ {
CommandCost cost(EXPENSES_NEW_VEHICLES); CommandCost cost(EXPENSES_NEW_VEHICLES);

@ -44,10 +44,10 @@ struct TemplateDepotVehicles {
uint CountTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *tv); uint CountTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *tv);
CommandCost TestBuyAllTemplateVehiclesInChain(TemplateVehicle *tv, TileIndex tile); CommandCost TestBuyAllTemplateVehiclesInChain(const TemplateVehicle *tv, TileIndex tile);
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags); CommandCost CmdRefitTrainFromTemplate(Train *t, const TemplateVehicle *tv, DoCommandFlag flags);
CommandCost CmdSetTrainUnitDirectionFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags); CommandCost CmdSetTrainUnitDirectionFromTemplate(Train *t, const TemplateVehicle *tv, DoCommandFlag flags);
void BreakUpRemainders(Train *t); void BreakUpRemainders(Train *t);
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type); bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type);

@ -1321,7 +1321,7 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3
template_vehicle->name = std::move(name); template_vehicle->name = std::move(name);
} }
// Make sure our replacements still point to the correct thing. /* Make sure our replacements still point to the correct thing. */
if (old_ID != INVALID_VEHICLE && old_ID != template_vehicle->index) { if (old_ID != INVALID_VEHICLE && old_ID != template_vehicle->index) {
bool reindex = false; bool reindex = false;
for (TemplateReplacement *tr : TemplateReplacement::Iterate()) { for (TemplateReplacement *tr : TemplateReplacement::Iterate()) {

Loading…
Cancel
Save