forked from Mirrors/openclonk
fix connecting multiple pipes to the refinery drain
parent
6b797e300e
commit
c3dfdc5894
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 --*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue