Reputation: 25392
So the code that I've been using to get a user's Steam ID is:
CSteamID uid = SteamUser()->GetSteamID();
uint64 pid = uid.ConvertToUint64();
std::ostringstream sin;
sin << pid;
std::string s = sin.str();
return s.c_str();
This works just fine, but when a user is not logged into Steam, this crashes.
Access violation - code c0000005 (first/second chance not available)
Does Steam provide a function that I can use to check if the user is logged in before running code that depends on the user being logged in? Or is there some sort of try/catch block I can use here to make sure that this does not break and return false if the user is not logged in?
Upvotes: 4
Views: 1738
Reputation: 25392
Thanks to @Lightning Racis in Orbit. A simple nullptr check fixed it.
if(SteamUser() == nullptr)
return false;
Upvotes: 1