Skip to content
Permalink
Browse files

Merge pull request #554 from scholtzm/OnTradeSuccessAndTimeoutFix

OnTradeSuccess and timeout fix
  • Loading branch information...
Jessecar96 committed Mar 21, 2014
2 parents 5b03ad5 + e2a031e commit e9095e0352abbcfbc3696072ad63f9984dda894d
Showing with 17 additions and 14 deletions.
  1. +0 −2 SteamBot/SimpleUserHandler.cs
  2. +0 −2 SteamBot/SteamTradeDemoHandler.cs
  3. +13 −10 SteamTrade/Trade.cs
  4. +4 −0 SteamTrade/TradeManager.cs
@@ -105,8 +105,6 @@ public override void OnTradeAccept()
Log.Warn ("The trade might have failed, but we can't be sure.");
}
}

OnTradeClose ();
}

public bool Validate ()
@@ -215,8 +215,6 @@ public override void OnTradeAccept()

Log.Success ("Trade Complete!");
}

OnTradeClose ();
}

public bool Validate ()
@@ -132,6 +132,11 @@ public Inventory MyInventory
/// </summary>
public bool HasTradeCompletedOk { get; private set; }

/// <summary>
/// Gets a value indicating if the remote trading partner accepted the trade.
/// </summary>
public bool OtherUserAccepted { get; private set; }

#endregion

#region Public Events
@@ -529,8 +534,15 @@ public bool Poll ()
throw new TradeException("The trade version does not match. Aborting.");
}

var events = status.GetAllEvents();
// Update Local Variables
if (status.them != null)
{
OtherIsReady = status.them.ready == 1;
MeIsReady = status.me.ready == 1;
OtherUserAccepted = status.them.confirmed == 1;
}

var events = status.GetAllEvents();
foreach (var tradeEvent in events)
{
if (eventList.Contains(tradeEvent))
@@ -556,11 +568,9 @@ public bool Poll ()
FireOnUserRemoveItem(tradeEvent);
break;
case TradeEventType.UserSetReady:
OtherIsReady = true;
OnUserSetReady(true);
break;
case TradeEventType.UserSetUnReady:
OtherIsReady = false;
OnUserSetReady(false);
break;
case TradeEventType.UserAccept:
@@ -576,13 +586,6 @@ public bool Poll ()
}
}

// Update Local Variables
if (status.them != null)
{
OtherIsReady = status.them.ready == 1;
MeIsReady = status.me.ready == 1;
}

if (status.logpos != 0)
{
session.LogPos = status.logpos;
@@ -323,6 +323,10 @@ public void StartTradeThread (Trade trade)

private bool CheckTradeTimeout (Trade trade)
{
// User has accepted the trade. Disregard time out.
if (trade.OtherUserAccepted)
return false;

var now = DateTime.Now;

DateTime actionTimeout = lastOtherActionTime.AddSeconds (MaxActionGapSec);

0 comments on commit e9095e0

Please sign in to comment.
You can’t perform that action at this time.