| 4078 | } |
| 4079 | |
| 4080 | void NPC_LoadParms( void ) |
| 4081 | { |
| 4082 | int len, totallen, npcExtFNLen, fileCnt, i; |
| 4083 | char *buffer, *holdChar, *marker; |
| 4084 | char npcExtensionListBuf[2048]; // The list of file names read in |
| 4085 | |
| 4086 | //gi.Printf( "Parsing ext_data/npcs/*.npc definitions\n" ); |
| 4087 | |
| 4088 | //set where to store the first one |
| 4089 | totallen = 0; |
| 4090 | marker = NPCParms; |
| 4091 | marker[0] = '\0'; |
| 4092 | |
| 4093 | //now load in the .npc definitions |
| 4094 | fileCnt = gi.FS_GetFileList("ext_data/npcs", ".npc", npcExtensionListBuf, sizeof(npcExtensionListBuf) ); |
| 4095 | |
| 4096 | holdChar = npcExtensionListBuf; |
| 4097 | for ( i = 0; i < fileCnt; i++, holdChar += npcExtFNLen + 1 ) |
| 4098 | { |
| 4099 | npcExtFNLen = strlen( holdChar ); |
| 4100 | |
| 4101 | //gi.Printf( "Parsing %s\n", holdChar ); |
| 4102 | |
| 4103 | len = gi.FS_ReadFile( va( "ext_data/npcs/%s", holdChar), (void **) &buffer ); |
| 4104 | |
| 4105 | if ( len == -1 ) |
| 4106 | { |
| 4107 | gi.Printf( "NPC_LoadParms: error reading file %s\n", holdChar ); |
| 4108 | } |
| 4109 | else |
| 4110 | { |
| 4111 | if ( totallen && *(marker-1) == '}' ) |
| 4112 | {//don't let previous file end on a } because that must be a stand-alone token |
| 4113 | strcat( marker, " " ); |
| 4114 | totallen++; |
| 4115 | marker++; |
| 4116 | } |
| 4117 | len = COM_Compress( buffer ); |
| 4118 | |
| 4119 | if ( totallen + len >= MAX_NPC_DATA_SIZE ) { |
| 4120 | G_Error( "NPC_LoadParms: ran out of space before reading %s\n(you must make the .npc files smaller)", holdChar ); |
| 4121 | } |
| 4122 | strcat( marker, buffer ); |
| 4123 | gi.FS_FreeFile( buffer ); |
| 4124 | |
| 4125 | totallen += len; |
| 4126 | marker += len; |
| 4127 | } |
| 4128 | } |
| 4129 | } |
no test coverage detected