Tracerestrict: Fix copying an unrestricted signal making an empty program.

This commit is contained in:
Jonathan G Rennison
2016-01-14 19:09:34 +00:00
parent 20a015e9d3
commit d2e8d205b9

View File

@@ -1002,17 +1002,17 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
switch (type) {
case TRDCT_PROG_COPY: {
TraceRestrictRemoveProgramMapping(self);
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
if (source_prog && !source_prog->items.empty()) {
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true);
if (!prog) {
// allocation failed
return CMD_ERROR;
}
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
if (source_prog) {
prog->items = source_prog->items; // copy
}
prog->Validate();
}
break;
}