MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / LoadAnim

Method LoadAnim

neo/game/Camera.cpp:322–449  ·  view source on GitHub ↗

================ idCameraAnim::Load ================ */

Source from the content-addressed store, hash-verified

320================
321*/
322void idCameraAnim::LoadAnim( void ) {
323 int version;
324 idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS | LEXFL_NOSTRINGCONCAT );
325 idToken token;
326 int numFrames;
327 int numCuts;
328 int i;
329 idStr filename;
330 const char *key;
331
332 key = spawnArgs.GetString( "anim" );
333 if ( !key ) {
334 gameLocal.Error( "Missing 'anim' key on '%s'", name.c_str() );
335 }
336
337 filename = spawnArgs.GetString( va( "anim %s", key ) );
338 if ( !filename.Length() ) {
339 gameLocal.Error( "Missing 'anim %s' key on '%s'", key, name.c_str() );
340 }
341
342 filename.SetFileExtension( MD5_CAMERA_EXT );
343 if ( !parser.LoadFile( filename ) ) {
344 gameLocal.Error( "Unable to load '%s' on '%s'", filename.c_str(), name.c_str() );
345 }
346
347 cameraCuts.Clear();
348 cameraCuts.SetGranularity( 1 );
349 camera.Clear();
350 camera.SetGranularity( 1 );
351
352 parser.ExpectTokenString( MD5_VERSION_STRING );
353 version = parser.ParseInt();
354 if ( version != MD5_VERSION ) {
355 parser.Error( "Invalid version %d. Should be version %d\n", version, MD5_VERSION );
356 }
357
358 // skip the commandline
359 parser.ExpectTokenString( "commandline" );
360 parser.ReadToken( &token );
361
362 // parse num frames
363 parser.ExpectTokenString( "numFrames" );
364 numFrames = parser.ParseInt();
365 if ( numFrames <= 0 ) {
366 parser.Error( "Invalid number of frames: %d", numFrames );
367 }
368
369 // parse framerate
370 parser.ExpectTokenString( "frameRate" );
371 frameRate = parser.ParseInt();
372 if ( frameRate <= 0 ) {
373 parser.Error( "Invalid framerate: %d", frameRate );
374 }
375
376 // parse num cuts
377 parser.ExpectTokenString( "numCuts" );
378 numCuts = parser.ParseInt();
379 if ( ( numCuts < 0 ) || ( numCuts > numFrames ) ) {

Callers

nothing calls this directly

Calls 15

vaFunction · 0.85
GetStringMethod · 0.45
ErrorMethod · 0.45
c_strMethod · 0.45
LengthMethod · 0.45
LoadFileMethod · 0.45
ClearMethod · 0.45
SetGranularityMethod · 0.45
ExpectTokenStringMethod · 0.45
ParseIntMethod · 0.45
ReadTokenMethod · 0.45
SetNumMethod · 0.45

Tested by

no test coverage detected