Make OtherSteamID64 less costly

This commit is contained in:
JustArchi
2015-10-31 03:50:08 +01:00
parent 411f796fab
commit 2545e7bbf3
5 changed files with 14 additions and 9 deletions

View File

@@ -200,7 +200,7 @@ namespace ArchiSteamFarm {
SteamClient.Connect(); SteamClient.Connect();
IsRunning = true; IsRunning = true;
Task.Run(() => HandleCallbacks()); Task.Run(() => HandleCallbacks());
} }
internal void Stop() { internal void Stop() {
@@ -210,7 +210,7 @@ namespace ArchiSteamFarm {
SteamClient.Disconnect(); SteamClient.Disconnect();
IsRunning = false; IsRunning = false;
} }
internal void Shutdown() { internal void Shutdown() {
Stop(); Stop();

View File

@@ -74,13 +74,13 @@ namespace ArchiSteamFarm {
foreach (HtmlNode badgesPageNode in badgesPageNodes) { foreach (HtmlNode badgesPageNode in badgesPageNodes) {
string steamLink = badgesPageNode.GetAttributeValue("href", null); string steamLink = badgesPageNode.GetAttributeValue("href", null);
if (steamLink == null) { if (steamLink == null) {
Logging.LogGenericWarning(Bot.BotName, "Couldn't get steamLink for one of the games: " + badgesPageNode.OuterHtml); Logging.LogGenericError(Bot.BotName, "Couldn't get steamLink for one of the games: " + badgesPageNode.OuterHtml);
continue; continue;
} }
uint appID = (uint) Utilities.OnlyNumbers(steamLink); uint appID = (uint) Utilities.OnlyNumbers(steamLink);
if (appID == 0) { if (appID == 0) {
Logging.LogGenericWarning(Bot.BotName, "Couldn't get appID for one of the games: " + badgesPageNode.OuterHtml); Logging.LogGenericError(Bot.BotName, "Couldn't get appID for one of the games: " + badgesPageNode.OuterHtml);
continue; continue;
} }

View File

@@ -55,9 +55,14 @@ namespace ArchiSteamFarm {
internal bool from_real_time_trade { get; set; } internal bool from_real_time_trade { get; set; }
// Extra // Extra
private ulong _OtherSteamID64 = 0;
internal ulong OtherSteamID64 { internal ulong OtherSteamID64 {
get { // This is quite costly, consider getting only once get {
return new SteamID((uint) accountid_other, EUniverse.Public, EAccountType.Individual).ConvertToUInt64(); if (_OtherSteamID64 == 0 && accountid_other != 0) {
_OtherSteamID64 = new SteamID((uint) accountid_other, EUniverse.Public, EAccountType.Individual).ConvertToUInt64();
}
return _OtherSteamID64;
} }
} }
} }

View File

@@ -75,11 +75,11 @@ namespace ArchiSteamFarm {
return; return;
} }
ulong steamID = tradeOffer.OtherSteamID64; ulong otherSteamID = tradeOffer.OtherSteamID64;
bool success = false; bool success = false;
bool tradeAccepted = false; bool tradeAccepted = false;
if (tradeOffer.items_to_give.Count == 0 || steamID == Bot.SteamMasterID) { if (tradeOffer.items_to_give.Count == 0 || otherSteamID == Bot.SteamMasterID) {
tradeAccepted = true; tradeAccepted = true;
success = await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false); success = await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
} else { } else {

View File

@@ -5,7 +5,7 @@
<!-- Master switch to turn account on and off, set to "true" after you're done --> <!-- Master switch to turn account on and off, set to "true" after you're done -->
<!-- TIP: This bot instance won't run unless below switch is set to "true" --> <!-- TIP: This bot instance won't run unless below switch is set to "true" -->
<Enabled type="bool" value="true"/> <Enabled type="bool" value="false"/>
<!-- This is your steam login, the one you use for logging in to steam --> <!-- This is your steam login, the one you use for logging in to steam -->
<!-- TIP: You can use "null" if you wish to enter login on every startup --> <!-- TIP: You can use "null" if you wish to enter login on every startup -->