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:
@@ -12,8 +12,8 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "window_gui.h"
|
||||
|
||||
#include "tbtr_template_vehicle.h"
|
||||
#include "3rdparty/cpp-btree/btree_set.h"
|
||||
|
||||
Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, uint32 user);
|
||||
|
||||
@@ -30,30 +30,28 @@ void SetupTemplateVehicleFromVirtual(TemplateVehicle *tmp, TemplateVehicle *prev
|
||||
|
||||
CommandCost CmdTemplateReplaceVehicle(Train*, bool, DoCommandFlag);
|
||||
|
||||
#ifdef _DEBUG
|
||||
// for testing
|
||||
void tbtr_debug_pat();
|
||||
void tbtr_debug_pav();
|
||||
void tbtr_debug_ptv(TemplateVehicle*);
|
||||
void tbtr_debug_pvt(const Train*);
|
||||
#endif
|
||||
TemplateVehicle *GetTemplateVehicleByGroupID(GroupID gid);
|
||||
TemplateVehicle *GetTemplateVehicleByGroupIDRecursive(GroupID gid);
|
||||
Train *ChainContainsEngine(EngineID eid, Train *chain);
|
||||
|
||||
TemplateVehicle* GetTemplateVehicleByGroupID(GroupID);
|
||||
TemplateVehicle* GetTemplateVehicleByGroupIDRecursive(GroupID);
|
||||
bool ChainContainsVehicle(Train*, Train*);
|
||||
Train* ChainContainsEngine(EngineID, Train*);
|
||||
Train* DepotContainsEngine(TileIndex, EngineID, Train*);
|
||||
struct TemplateDepotVehicles {
|
||||
btree::btree_set<VehicleID> vehicles;
|
||||
|
||||
int NumTrainsNeedTemplateReplacement(GroupID, const TemplateVehicle*);
|
||||
void Init(TileIndex tile);
|
||||
void RemoveVehicle(VehicleID id);
|
||||
Train* ContainsEngine(EngineID eid, Train *not_in);
|
||||
};
|
||||
|
||||
uint CountsTrainsNeedingTemplateReplacement(GroupID g_id, const TemplateVehicle *tv);
|
||||
|
||||
CommandCost TestBuyAllTemplateVehiclesInChain(TemplateVehicle *tv, TileIndex tile);
|
||||
|
||||
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag);
|
||||
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags);
|
||||
void BreakUpRemainders(Train *t);
|
||||
|
||||
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle*, RailType);
|
||||
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type);
|
||||
|
||||
void TransferCargoForTrain(Train*, Train*);
|
||||
void TransferCargoForTrain(Train *old_veh, Train *new_head);
|
||||
|
||||
void NeutralizeStatus(Train *t);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user