MCPcopy Create free account
hub / github.com/BSVino/DoubleAction / ParseOneCriterion

Method ParseOneCriterion

mp/src/game/server/AI_ResponseSystem.cpp:2335–2416  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: Input : *criterion - -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2333// Input : *criterion -
2334//-----------------------------------------------------------------------------
2335int CResponseSystem::ParseOneCriterion( const char *criterionName )
2336{
2337 char key[ 128 ];
2338 char value[ 128 ];
2339
2340 Criteria newCriterion;
2341
2342 bool gotbody = false;
2343
2344 while ( TokenWaiting() || !gotbody )
2345 {
2346 ParseToken();
2347
2348 // Oops, part of next definition
2349 if( IsRootCommand() )
2350 {
2351 Unget();
2352 break;
2353 }
2354
2355 if ( !Q_stricmp( token, "{" ) )
2356 {
2357 gotbody = true;
2358
2359 while ( 1 )
2360 {
2361 ParseToken();
2362 if ( !Q_stricmp( token, "}" ) )
2363 break;
2364
2365 // Look up subcriteria index
2366 int idx = m_Criteria.Find( token );
2367 if ( idx != m_Criteria.InvalidIndex() )
2368 {
2369 newCriterion.subcriteria.AddToTail( idx );
2370 }
2371 else
2372 {
2373 ResponseWarning( "Skipping unrecongized subcriterion '%s' in '%s'\n", token, criterionName );
2374 }
2375 }
2376 continue;
2377 }
2378 else if ( !Q_stricmp( token, "required" ) )
2379 {
2380 newCriterion.required = true;
2381 }
2382 else if ( !Q_stricmp( token, "weight" ) )
2383 {
2384 ParseToken();
2385 newCriterion.weight.SetFloat( (float)atof( token ) );
2386 }
2387 else
2388 {
2389 Assert( newCriterion.subcriteria.Count() == 0 );
2390
2391 // Assume it's the math info for a non-subcriteria resposne
2392 Q_strncpy( key, token, sizeof( key ) );

Callers

nothing calls this directly

Calls 12

AssertFunction · 0.85
IsSubCriteriaTypeMethod · 0.80
TokenWaitingFunction · 0.70
ParseTokenFunction · 0.70
UngetFunction · 0.70
CopyStringFunction · 0.70
FindMethod · 0.45
InvalidIndexMethod · 0.45
AddToTailMethod · 0.45
SetFloatMethod · 0.45
CountMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected