mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Merge branch 'template_train_replacement-sx' into jgrpp
This commit is contained in:
commit
e95a24a4e9
@ -149,17 +149,6 @@ TemplateReplacement* GetTemplateReplacementByGroupID(GroupID gid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateReplacement* GetTemplateReplacementByTemplateID(TemplateID tid)
|
|
||||||
{
|
|
||||||
TemplateReplacement *tr;
|
|
||||||
FOR_ALL_TEMPLATE_REPLACEMENTS(tr) {
|
|
||||||
if (tr->Template() == tid) {
|
|
||||||
return tr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IssueTemplateReplacement(GroupID gid, TemplateID tid)
|
bool IssueTemplateReplacement(GroupID gid, TemplateID tid)
|
||||||
{
|
{
|
||||||
TemplateReplacement *tr = GetTemplateReplacementByGroupID(gid);
|
TemplateReplacement *tr = GetTemplateReplacementByGroupID(gid);
|
||||||
|
@ -199,7 +199,6 @@ struct TemplateReplacement : TemplateReplacementPool::PoolItem<&_template_replac
|
|||||||
};
|
};
|
||||||
|
|
||||||
TemplateReplacement* GetTemplateReplacementByGroupID(GroupID);
|
TemplateReplacement* GetTemplateReplacementByGroupID(GroupID);
|
||||||
TemplateReplacement* GetTemplateReplacementByTemplateID(TemplateID);
|
|
||||||
bool IssueTemplateReplacement(GroupID, TemplateID);
|
bool IssueTemplateReplacement(GroupID, TemplateID);
|
||||||
|
|
||||||
short deleteIllegalTemplateReplacements(GroupID);
|
short deleteIllegalTemplateReplacements(GroupID);
|
||||||
|
@ -4864,6 +4864,9 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3
|
|||||||
Train *remainder_chain = NULL;
|
Train *remainder_chain = NULL;
|
||||||
Train *tmp_chain = NULL;
|
Train *tmp_chain = NULL;
|
||||||
TemplateVehicle *tv = GetTemplateVehicleByGroupID(incoming->group_id);
|
TemplateVehicle *tv = GetTemplateVehicleByGroupID(incoming->group_id);
|
||||||
|
if (tv == NULL) {
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
EngineID eid = tv->engine_type;
|
EngineID eid = tv->engine_type;
|
||||||
|
|
||||||
CommandCost buy(EXPENSES_NEW_VEHICLES);
|
CommandCost buy(EXPENSES_NEW_VEHICLES);
|
||||||
|
@ -1224,10 +1224,12 @@ CommandCost CmdDeleteTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32
|
|||||||
bool should_execute = (flags & DC_EXEC) != 0;
|
bool should_execute = (flags & DC_EXEC) != 0;
|
||||||
|
|
||||||
if (should_execute) {
|
if (should_execute) {
|
||||||
// Remove a corresponding template replacement if existing
|
// Remove corresponding template replacements if existing
|
||||||
TemplateReplacement *tr = GetTemplateReplacementByTemplateID(del->index);
|
TemplateReplacement *tr;
|
||||||
if (tr != NULL) {
|
FOR_ALL_TEMPLATE_REPLACEMENTS(tr) {
|
||||||
delete tr;
|
if (tr->Template() == del->index) {
|
||||||
|
delete tr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete del;
|
delete del;
|
||||||
|
Loading…
Reference in New Issue
Block a user