====================== G_ParseAnimationEvtFile Read a configuration file containing animation events models/players/kyle/animevents.cfg, etc This file's presence is not required ====================== */
| 790 | ====================== |
| 791 | */ |
| 792 | static |
| 793 | void 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 |
no test coverage detected