Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Balance64 to WalletInfoCallback #607

Merged
merged 2 commits into from
Nov 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SteamKit2/SteamKit2/Steam/Handlers/SteamUser/Callbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,25 @@ public sealed class WalletInfoCallback : CallbackMsg
/// Gets the currency code for this wallet.
/// </summary>
public ECurrencyCode Currency { get; private set; }

/// <summary>
/// Gets the balance of the wallet, in cents.
/// Gets the balance of the wallet as a 32-bit integer, in cents.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that stating data type in the doc is a bit excessive and unneeded, but I wanted to point out the difference between those two for people that might not recall at first. I think it's OK in this case where consumer might wonder which one to use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know what actually happens to this field when an account has a balance of $42m?

Copy link
Member

@xPaw xPaw Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it in USD or users currency?

Because with vietnamese dong a game can cost 1.300.000₫ which is 130000000 cents.

This https://store.steampowered.com/sub/252061/?cc=vn costs 1359250000 cents in dong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well do we know what happens in that scenario too?

Copy link
Member

@xPaw xPaw Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue, but I pointed it out to ease the checking it out if anyone wants to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check myself but very likely it caps at int.MaxValue and stays there. This would be the solution that makes the most sense in terms of backwards compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JustArchi Just saw your comment - yeah, but it's Valve. I'd be quite unsurprised if it's just the lower 32 bits of the actual balance, and wraps around to the negatives.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaakov-h you're totally right and it also wouldn't shock me, but I'm not rich enough to check 😀.

And BTW yes, this balance is in local currency (ECurrencyCode) which is user's local currency, if supported by Steam. It counts from full cents or other smallest monetary value.

/// </summary>
public int Balance { get; private set; }

/// <summary>
/// Gets the balance of the wallet as a 64-bit integer, in cents.
/// </summary>
public long LongBalance { get; private set; }


internal WalletInfoCallback( CMsgClientWalletInfoUpdate wallet )
{
HasWallet = wallet.has_wallet;

Currency = ( ECurrencyCode )wallet.currency;
Balance = wallet.balance;
LongBalance = wallet.balance64;
}
}

Expand Down