fix connecting multiple pipes to the refinery drain

install-platforms
Maikel de Vries 2018-01-13 15:28:07 +01:00
parent 6b797e300e
commit c3dfdc5894
3 changed files with 38 additions and 6 deletions

View File

@ -254,7 +254,8 @@ public func AddLineConnectionTo(object target, bool block_cutting)
line->SwitchConnection(this, target);
SetPipeLine(line);
line.BlockPipeCutting = block_cutting;
ScheduleCall(this, this.Enter, 1, nil, line); // delayed entrance, so that the message is still displayed above the clonk
// Delayed entrance, so that the message is still displayed above the clonk.
ScheduleCall(this, this.Enter, 1, nil, line);
return line;
}
else
@ -349,7 +350,7 @@ public func Report(string message)
var reporter = this;
var next = Contained();
while(next)
while (next)
{
reporter = next;
next = reporter->Contained();

View File

@ -243,8 +243,16 @@ public func DoSwapSourceDrain(object source, object drain)
public func FindAvailablePipe(object container, find_state)
{
for (var pipe in FindObjects(Find_ID(Pipe), Find_Container(container), find_state))
if (!this->~QueryConnectPipe(pipe, false))
return pipe;
{
if (this->~QueryConnectPipe(pipe, false))
continue;
// Because of the delayed entrance into the pipeline of 1 frame the pipe may still be considered available.
// Therefore check also there there exists no connection of the line to this object.
var line = pipe->GetConnectedLine();
if (line && line->IsConnectedTo(this, true))
continue;
return pipe;
}
return nil;
}

View File

@ -25,7 +25,14 @@ public func IsLiquidContainerForMaterial(string liquid)
public func QueryConnectPipe(object pipe, bool do_msg)
{
if (pipe->IsDrainPipe() || pipe->IsNeutralPipe())
return false;
{
// Also check if already connected to this refinery drain.
var line = pipe->GetConnectedLine();
if (!line)
return false;
if (!line->IsConnectedTo(this, true))
return false;
}
if (do_msg)
pipe->Report("$MsgPipeProhibited$");
return true;
@ -33,10 +40,26 @@ public func QueryConnectPipe(object pipe, bool do_msg)
public func OnPipeConnect(object pipe, string specific_pipe_state)
{
SetNeutralPipe(pipe);
SetDrainPipe(pipe);
pipe->SetDrainPipe();
pipe->Report("$MsgConnectedPipe$");
}
public func OnPipeDisconnect(object pipe)
{
var result = inherited(pipe, ...);
// There may be still drain pipes connected, selected one as the current drain pipe.
for (var line in FindObjects(Find_Func("IsConnectedTo", this)))
{
var new_pipe = line->GetPipeKit();
if (new_pipe == pipe || !new_pipe->IsDrainPipe())
continue;
SetDrainPipe(new_pipe);
break;
}
return result;
}
/*-- Interaction Interface --*/