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

Function G_ParseAnimationEvtFile

code/game/NPC_stats.cpp:792–868  ·  view source on GitHub ↗

====================== G_ParseAnimationEvtFile Read a configuration file containing animation events models/players/kyle/animevents.cfg, etc This file's presence is not required ====================== */

Source from the content-addressed store, hash-verified

790======================
791*/
792static
793void G_ParseAnimationEvtFile(int glaIndex, const char* eventsDirectory, int fileIndex, int iRealGLAIndex = -1, bool modelSpecific = false)
794{
795 int len;
796 const char* token;
797 char text[80000];
798 const char* text_p = text;
799 fileHandle_t f;
800 char eventsPath[MAX_QPATH];
801 int modelIndex = 0;
802
803 assert(fileIndex>=0 && fileIndex<MAX_ANIM_FILES);
804
805 const char *psAnimFileInternalName = (iRealGLAIndex == -1 ? NULL : gi.G2API_GetAnimFileInternalNameIndex( iRealGLAIndex ));
806 bool bIsFrameSkipped = (psAnimFileInternalName && strlen(psAnimFileInternalName)>5 && !Q_stricmp(&psAnimFileInternalName[strlen(psAnimFileInternalName)-5],"_skip"));
807
808 // Open The File, Make Sure It Is Safe
809 //-------------------------------------
810 Com_sprintf(eventsPath, MAX_QPATH, "models/players/%s/animevents.cfg", eventsDirectory);
811 len = cgi_FS_FOpenFile(eventsPath, &f, FS_READ);
812 if ( len <= 0 )
813 {//no file
814 return;
815 }
816 if ( len >= (int)(sizeof( text ) - 1) )
817 {
818 cgi_FS_FCloseFile( f );
819 CG_Printf( "File %s too long\n", eventsPath );
820 return;
821 }
822
823 // Read It To The Buffer, Close The File
824 //---------------------------------------
825 cgi_FS_Read( text, len, f );
826 text[len] = 0;
827 cgi_FS_FCloseFile( f );
828
829
830 // Get The Pointers To The Anim Event Arrays
831 //-------------------------------------------
832 animFileSet_t& afileset = level.knownAnimFileSets[fileIndex];
833 animevent_t *legsAnimEvents = afileset.legsAnimEvents;
834 animevent_t *torsoAnimEvents = afileset.torsoAnimEvents;
835 animation_t *animations = afileset.animations;
836
837
838 if (modelSpecific)
839 {
840 hstring modelName(eventsDirectory);
841 modelIndex = modelName.handle();
842 }
843
844
845 // read information for batches of sounds (UPPER or LOWER)
846 COM_BeginParseSession();
847 while ( 1 )
848 {
849 // Get base frame of sequence

Callers 1

G_ParseAnimFileSetFunction · 0.85

Calls 11

Q_stricmpFunction · 0.85
COM_EndParseSessionFunction · 0.85
ParseAnimationEvtBlockFunction · 0.70
Com_sprintfFunction · 0.50
cgi_FS_FOpenFileFunction · 0.50
cgi_FS_FCloseFileFunction · 0.50
CG_PrintfFunction · 0.50
cgi_FS_ReadFunction · 0.50
COM_BeginParseSessionFunction · 0.50
COM_ParseFunction · 0.50
handleMethod · 0.45

Tested by

no test coverage detected