MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / SetFromStringStrict

Method SetFromStringStrict

src/common/steamid.cpp:232–477  ·  view source on GitHub ↗

SetFromString allows many partially-correct strings, constraining how we might be able to change things in the future. SetFromStringStrict requires the exact string forms that we support and is preferred when the caller knows it's safe to be strict. Returns whether the string parsed correctly. The ID may still be invalid even if the string parsed correctly. If the string didn't parse correctly th

Source from the content-addressed store, hash-verified

230// still be invalid even if the string parsed correctly.
231// If the string didn't parse correctly the ID will always be invalid.
232bool CSteamID::SetFromStringStrict( const char *pchSteamID, EUniverse eDefaultUniverse )
233{
234 uint nAccountID = 0;
235 uint nInstance = 1;
236 uint unMaxVal = 2;
237 EUniverse eUniverse = eDefaultUniverse;
238 EAccountType eAccountType = k_EAccountTypeIndividual;
239 char chPrefix;
240 bool bBracket = false;
241 bool bValid = true;
242 uint64 unVal[3];
243 const char *pchEnd;
244
245 // Start invalid.
246 Clear();
247
248 if ( !pchSteamID )
249 {
250 return false;
251 }
252
253 if ( *pchSteamID == '[' )
254 {
255 pchSteamID++;
256 bBracket = true;
257 }
258
259 chPrefix = *pchSteamID;
260 switch( chPrefix )
261 {
262 case 'A':
263 // This is test only
264 eAccountType = k_EAccountTypeAnonGameServer;
265 unMaxVal = 3;
266 break;
267
268 case 'a':
269 // This is test only
270 eAccountType = k_EAccountTypeAnonUser;
271 nInstance = 0;
272 unMaxVal = 3;
273 break;
274
275 case 'G':
276 eAccountType = k_EAccountTypeGameServer;
277 break;
278
279 case 'C':
280 eAccountType = k_EAccountTypeContentServer;
281 break;
282
283 case 'g':
284 eAccountType = k_EAccountTypeClan;
285 nInstance = 0;
286 break;
287
288 case 'c':
289 eAccountType = k_EAccountTypeChat;

Callers 1

SetFromStringMethod · 0.80

Calls 2

ClearFunction · 0.85
DecimalToUint64Function · 0.85

Tested by

no test coverage detected