----------------------------------------------------------------------------- Purpose: Initializes a steam ID from a string Input : pchSteamID - text representation of a Steam ID -----------------------------------------------------------------------------
| 63 | // Input : pchSteamID - text representation of a Steam ID |
| 64 | //----------------------------------------------------------------------------- |
| 65 | void CSteamID::SetFromString( const char *pchSteamID, EUniverse eDefaultUniverse ) |
| 66 | { |
| 67 | uint nAccountID = 0; |
| 68 | uint nInstance = 1; |
| 69 | EUniverse eUniverse = eDefaultUniverse; |
| 70 | EAccountType eAccountType = k_EAccountTypeIndividual; |
| 71 | const char *pchSteamIDString = pchSteamID; |
| 72 | CSteamID StrictID; |
| 73 | |
| 74 | StrictID.SetFromStringStrict( pchSteamID, eDefaultUniverse ); |
| 75 | |
| 76 | if ( *pchSteamID == '[' ) |
| 77 | pchSteamID++; |
| 78 | |
| 79 | // BUGBUG Rich use the Q_ functions |
| 80 | if ( *pchSteamID == 'A' || *pchSteamID == 'a' ) |
| 81 | { |
| 82 | // This is test only |
| 83 | if ( *pchSteamID == 'A' ) |
| 84 | eAccountType = k_EAccountTypeAnonGameServer; |
| 85 | else |
| 86 | { |
| 87 | eAccountType = k_EAccountTypeAnonUser; |
| 88 | nInstance = 0; |
| 89 | } |
| 90 | pchSteamID++; // skip the A |
| 91 | if (*pchSteamID == '-' || *pchSteamID == ':') |
| 92 | pchSteamID++; // skip the optional - or : |
| 93 | |
| 94 | if ( strchr( pchSteamID, '(' ) ) |
| 95 | sscanf( strchr( pchSteamID, '(' ), "(%u)", &nInstance ); |
| 96 | const char *pchColon = strchr( pchSteamID, ':' ); |
| 97 | if ( pchColon && *pchColon != 0 && strchr( pchColon+1, ':' )) |
| 98 | { |
| 99 | sscanf( pchSteamID, "%u:%u:%u", (uint*)&eUniverse, &nAccountID, &nInstance ); |
| 100 | } |
| 101 | else if ( pchColon ) |
| 102 | { |
| 103 | sscanf( pchSteamID, "%u:%u", (uint*)&eUniverse, &nAccountID ); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | sscanf( pchSteamID, "%u", &nAccountID ); |
| 108 | } |
| 109 | |
| 110 | if ( nAccountID == 0 ) |
| 111 | { |
| 112 | // i dont care what number you entered |
| 113 | CreateBlankAnonLogon(eUniverse); |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | InstancedSet( nAccountID, nInstance, eUniverse, eAccountType ); |
| 118 | } |
| 119 | // Catch cases where we're allowing sloppy input that we |
| 120 | // might not want to allow. |
| 121 | AssertMsg1( this->operator==( StrictID ), "Steam ID does not pass strict parsing: '%s'", pchSteamIDString ); |
| 122 | return; |
nothing calls this directly
no test coverage detected