Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
* Fixed server crash on garbage collection after map switch.
* Delimit each kill log message with linefeed.
  • Loading branch information
tuokri committed Jul 4, 2020
1 parent 1972292 commit 2594546
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
32 changes: 11 additions & 21 deletions Classes/BufferedTcpLink.uc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ var int OutputQueueLen;
// var string InputQueue;
// var int InputQueueLen;

var bool bEOF;
// var bool bEOF;
var bool bAcceptNewData;

// var string CRLF;
// var string CR;
// var string LF;
var string LF;

function PreBeginPlay()
{
Expand All @@ -43,10 +43,10 @@ final function ResetBuffer()
OutputBufferTail = 0;
// CRLF = Chr(10) $ Chr(13);
// CR = Chr(13);
// LF = Chr(10);
bEOF = False;
LF = Chr(10);
// bEOF = False;
bAcceptNewData = True;
LinkMode = MODE_Line;
LinkMode = Mode_Text;
ReceiveMode = RMODE_Manual;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ final function bool SendEOF()
NewTail = (NewTail + 1) % `TCP_BUFFER_SIZE;
if (NewTail == OutputBufferHead)
{
// `log("[BufferedTcpLink]: output buffer overrun");
`log("[BufferedTcpLink]: output buffer overrun");
return False;
}
OutputBuffer[OutputBufferTail] = 0;
Expand Down Expand Up @@ -174,7 +174,7 @@ function bool SendBufferedData(string Text)
NewTail = (NewTail + 1) % `TCP_BUFFER_SIZE;
if (NewTail == OutputBufferHead)
{
// `log("[BufferedTcpLink]: output buffer overrun");
`log("[BufferedTcpLink]: output buffer overrun");
return False;
}
OutputBuffer[OutputBufferTail] = Asc(Mid(Text, i, 1));
Expand All @@ -195,30 +195,20 @@ final function DoBufferQueueIO()

if (IsConnected())
{
// Output data.
OutputQueueLen = 0;
OutputQueue = "";
NewHead = OutputBufferHead;
while ((OutputQueueLen < 255) && (NewHead != OutputBufferTail))
{
// Put some more stuff in the output queue.
if (OutputBuffer[NewHead] != 0)
{
OutputQueue = OutputQueue $ Chr(OutputBuffer[NewHead]);
OutputQueueLen++;
}
else
{
bEOF = True;
}

OutputQueue = OutputQueue $ Chr(OutputBuffer[NewHead]);
OutputQueueLen++;
NewHead = (NewHead + 1) % `TCP_BUFFER_SIZE;
}

if (OutputQueueLen > 0)
{
// BytesSent = SendText(OutputQueue $ "");
SendText(OutputQueue $ "");
// BytesSent = SendText(OutputQueue);
SendText(OutputQueue);
OutputBufferHead = NewHead; // (OutputBufferHead + BytesSent) % `TCP_BUFFER_SIZE;
// `log("Sent " $ BytesSent $ " bytes >>" $ OutputQueue $ "<<");
}
Expand Down
15 changes: 6 additions & 9 deletions Classes/TKLMutator.uc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ final function CloseWriter()
Writer.Logf("--- KillLog End: " $ TimeStamp() $ " ---");
Writer.CloseFile();
Writer.Destroy();
Writer = None;
}
}
Expand All @@ -198,7 +197,6 @@ final function CloseLink()
bLinkEnabled = False;
TKLMTLC.Close();
TKLMTLC.Destroy();
TKLMTLC = None;
}
}
Expand All @@ -224,13 +222,12 @@ final function CleanUp()
CloseLink();
}
// TODO: for some reason this isn't being called.
function ModifyMatchWon(out byte out_WinningTeam, out byte out_WinCondition, optional out byte out_RoundWinningTeam)
{
`log("[TKLMutator]: ModifyMatchWon()");
CleanUp();
super.ModifyMatchWon(out_WinningTeam, out_WinCondition, out_RoundWinningTeam);
}
// function ModifyMatchWon(out byte out_WinningTeam, out byte out_WinCondition, optional out byte out_RoundWinningTeam)
// {
// `log("[TKLMutator]: ModifyMatchWon()");
// CleanUp();
// super.ModifyMatchWon(out_WinningTeam, out_WinCondition, out_RoundWinningTeam);
// }
event Destroyed()
{
Expand Down
7 changes: 6 additions & 1 deletion Classes/TKLMutatorTcpLinkClient.uc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ event PreBeginPlay()
{
FirstTimeConfig();
SaveConfig();
super.PreBeginPlay();
}

final function ResolveServer()
Expand Down Expand Up @@ -79,6 +80,8 @@ event PostBeginPlay()
}

ResolveServer();

super.PostBeginPlay();
}

event Resolved(IpAddr Addr)
Expand Down Expand Up @@ -114,6 +117,7 @@ event ResolveFailed()
event Opened()
{
`log("[TKLMutatorTcpLinkClient]: connection opened");
bAcceptNewData = True;
}

event Closed()
Expand All @@ -126,6 +130,7 @@ event Closed()
else
{
`log("[TKLMutatorTcpLinkClient]: connection closed");
bAcceptNewData = False;
}
}

Expand All @@ -141,7 +146,7 @@ function bool SendBufferedData(string Text)
// {
// `log("[TKLMutatorTcpLinkClient]: attempting to queue data but connection is not open");
// }
Text = UniqueRS2ServerId $ Text;
Text = UniqueRS2ServerId $ Text $ LF;
return super.SendBufferedData(Text);
}

Expand Down

0 comments on commit 2594546

Please sign in to comment.