From d2e8d205b90f37c151c7ef1f85f7f404585c6051 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 14 Jan 2016 19:09:34 +0000 Subject: [PATCH] Tracerestrict: Fix copying an unrestricted signal making an empty program. --- src/tracerestrict.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index caeb935acc..9100f1a8ae 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -1002,17 +1002,17 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag switch (type) { case TRDCT_PROG_COPY: { TraceRestrictRemoveProgramMapping(self); - TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true); - if (!prog) { - // allocation failed - return CMD_ERROR; - } TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false); - if (source_prog) { + if (source_prog && !source_prog->items.empty()) { + TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true); + if (!prog) { + // allocation failed + return CMD_ERROR; + } prog->items = source_prog->items; // copy + prog->Validate(); } - prog->Validate(); break; }