mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Move and fix GetDelta Function
This commit is contained in:
parent
569b93da51
commit
8a14552e56
|
@ -68,6 +68,24 @@ namespace Sessions
|
|||
{
|
||||
}
|
||||
|
||||
s32 TCP_Session::GetDelta(u32 a, u32 b)
|
||||
{
|
||||
s64 delta = static_cast<s64>(a) - static_cast<s64>(b);
|
||||
if (delta > 0.5 * UINT_MAX)
|
||||
{
|
||||
delta = -static_cast<s64>(UINT_MAX) + a - b - 1;
|
||||
Console.Error("DEV9: TCP: [PS2] SequenceNumber Overflow Detected");
|
||||
Console.Error("DEV9: TCP: [PS2] New Data Offset: %d bytes", delta);
|
||||
}
|
||||
if (delta < -0.5 * UINT_MAX)
|
||||
{
|
||||
delta = UINT_MAX - b + a + 1;
|
||||
Console.Error("DEV9: TCP: [PS2] SequenceNumber Overflow Detected");
|
||||
Console.Error("DEV9: TCP: [PS2] New Data Offset: %d bytes", delta);
|
||||
}
|
||||
return delta;
|
||||
}
|
||||
|
||||
TCP_Packet* TCP_Session::CreateBasePacket(PayloadData* data)
|
||||
{
|
||||
//DevCon.WriteLn("Creating Base Packet");
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace Sessions
|
|||
|
||||
NumCheckResult CheckRepeatSYNNumbers(PacketReader::IP::TCP::TCP_Packet* tcp);
|
||||
NumCheckResult CheckNumbers(PacketReader::IP::TCP::TCP_Packet* tcp);
|
||||
u32 GetDelta(u32 parExpectedSeq, u32 parGotSeq);
|
||||
s32 GetDelta(u32 a, u32 b); //Returns a - b
|
||||
//Returns true if errored
|
||||
bool ErrorOnNonEmptyPacket(PacketReader::IP::TCP::TCP_Packet* tcp);
|
||||
|
||||
|
|
|
@ -308,7 +308,9 @@ namespace Sessions
|
|||
windowSize.store(tcp->windowSize << windowScale);
|
||||
|
||||
const NumCheckResult Result = CheckNumbers(tcp);
|
||||
//Check if we already have some of the data sent
|
||||
const uint delta = GetDelta(expectedSeqNumber, tcp->sequenceNumber);
|
||||
pxAssert(delta >= 0);
|
||||
//if (Result == NumCheckResult::GotOldData)
|
||||
//{
|
||||
// DevCon.WriteLn("[PS2] New Data Offset: %d bytes", delta);
|
||||
|
@ -464,17 +466,6 @@ namespace Sessions
|
|||
|
||||
return NumCheckResult::OK;
|
||||
}
|
||||
u32 TCP_Session::GetDelta(u32 parExpectedSeq, u32 parGotSeq)
|
||||
{
|
||||
u32 delta = parExpectedSeq - parGotSeq;
|
||||
if (delta > 0.5 * UINT_MAX)
|
||||
{
|
||||
delta = UINT_MAX - parExpectedSeq + parGotSeq;
|
||||
Console.Error("DEV9: TCP: [PS2] SequenceNumber Overflow Detected");
|
||||
Console.Error("DEV9: TCP: [PS2] New Data Offset: %d bytes", delta);
|
||||
}
|
||||
return delta;
|
||||
}
|
||||
bool TCP_Session::ErrorOnNonEmptyPacket(TCP_Packet* tcp)
|
||||
{
|
||||
NumCheckResult ResultFIN = CheckNumbers(tcp);
|
||||
|
|
Loading…
Reference in New Issue