MCPcopy Create free account
hub / github.com/JACoders/OpenJK / G_ParseAnimationFile

Function G_ParseAnimationFile

code/game/NPC_stats.cpp:879–1028  ·  view source on GitHub ↗

====================== G_ParseAnimationFile Read a configuration file containing animation coutns and rates models/players/visor/animation.cfg, etc ====================== */

Source from the content-addressed store, hash-verified

877======================
878*/
879qboolean G_ParseAnimationFile(int glaIndex, const char *skeletonName, int fileIndex)
880{
881 char text[80000];
882 int len = 0;
883 const char *token = 0;
884 float fps = 0;
885 const char* text_p = text;
886 int animNum = 0;
887 animation_t* animations = level.knownAnimFileSets[fileIndex].animations;
888 char skeletonPath[MAX_QPATH];
889
890
891 // Read In The File To The Text Buffer, Make Sure Everything Is Safe To Continue
892 //-------------------------------------------------------------------------------
893 Com_sprintf(skeletonPath, MAX_QPATH, "models/players/%s/%s.cfg", skeletonName, skeletonName);
894 len = gi.RE_GetAnimationCFG(skeletonPath, text, sizeof(text));
895 if ( len <= 0 )
896 {
897 Com_sprintf(skeletonPath, MAX_QPATH, "models/players/%s/animation.cfg", skeletonName);
898 len = gi.RE_GetAnimationCFG(skeletonPath, text, sizeof(text));
899 if ( len <= 0 )
900 {
901 return qfalse;
902 }
903 }
904 if ( len >= (int)(sizeof( text ) - 1) )
905 {
906 G_Error( "G_ParseAnimationFile: File %s too long\n (%d > %d)", skeletonName, len, sizeof( text ) - 1);
907 return qfalse;
908 }
909
910
911
912 // Read In Each Token
913 //--------------------
914 COM_BeginParseSession();
915 while(1)
916 {
917 token = COM_Parse( &text_p );
918
919 // If No Token, We've Reached The End Of The File
920 //------------------------------------------------
921 if ( !token || !token[0])
922 {
923 break;
924 }
925
926 // Get The Anim Number Converted From The First Token
927 //----------------------------------------------------
928 animNum = GetIDForString(animTable, token);
929 if(animNum == -1)
930 {
931#ifndef FINAL_BUILD
932 if (strcmp(token,"ROOT"))
933 {
934 Com_Printf(S_COLOR_RED"WARNING: Unknown token %s in %s\n", token, skeletonPath);
935 }
936#endif

Callers 1

G_ParseAnimFileSetFunction · 0.70

Calls 9

COM_EndParseSessionFunction · 0.85
G_ErrorFunction · 0.70
Com_PrintfFunction · 0.70
SpewDebugStuffToFileFunction · 0.70
Com_sprintfFunction · 0.50
COM_BeginParseSessionFunction · 0.50
COM_ParseFunction · 0.50
GetIDForStringFunction · 0.50
COM_ParseExtFunction · 0.50

Tested by

no test coverage detected