================ idAASFileLocal::Load ================ */
| 1101 | ================ |
| 1102 | */ |
| 1103 | bool idAASFileLocal::Load( const idStr &fileName, unsigned int mapFileCRC ) { |
| 1104 | idLexer src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES ); |
| 1105 | idToken token; |
| 1106 | int depth; |
| 1107 | unsigned int c; |
| 1108 | |
| 1109 | name = fileName; |
| 1110 | crc = mapFileCRC; |
| 1111 | |
| 1112 | common->Printf( "[Load AAS]\n" ); |
| 1113 | common->Printf( "loading %s\n", name.c_str() ); |
| 1114 | |
| 1115 | if ( !src.LoadFile( name ) ) { |
| 1116 | return false; |
| 1117 | } |
| 1118 | |
| 1119 | if ( !src.ExpectTokenString( AAS_FILEID ) ) { |
| 1120 | common->Warning( "Not an AAS file: '%s'", name.c_str() ); |
| 1121 | return false; |
| 1122 | } |
| 1123 | |
| 1124 | if ( !src.ReadToken( &token ) || token != AAS_FILEVERSION ) { |
| 1125 | common->Warning( "AAS file '%s' has version %s instead of %s", name.c_str(), token.c_str(), AAS_FILEVERSION ); |
| 1126 | return false; |
| 1127 | } |
| 1128 | |
| 1129 | if ( !src.ExpectTokenType( TT_NUMBER, TT_INTEGER, &token ) ) { |
| 1130 | common->Warning( "AAS file '%s' has no map file CRC", name.c_str() ); |
| 1131 | return false; |
| 1132 | } |
| 1133 | |
| 1134 | c = token.GetUnsignedIntValue(); |
| 1135 | if ( mapFileCRC && c != mapFileCRC ) { |
| 1136 | common->Warning( "AAS file '%s' is out of date", name.c_str() ); |
| 1137 | return false; |
| 1138 | } |
| 1139 | |
| 1140 | // clear the file in memory |
| 1141 | Clear(); |
| 1142 | |
| 1143 | // parse the file |
| 1144 | while ( 1 ) { |
| 1145 | if ( !src.ReadToken( &token ) ) { |
| 1146 | break; |
| 1147 | } |
| 1148 | |
| 1149 | if ( token == "settings" ) { |
| 1150 | if ( !settings.FromParser( src ) ) { return false; } |
| 1151 | } |
| 1152 | else if ( token == "planes" ) { |
| 1153 | if ( !ParsePlanes( src ) ) { return false; } |
| 1154 | } |
| 1155 | else if ( token == "vertices" ) { |
| 1156 | if ( !ParseVertices( src ) ) { return false; } |
| 1157 | } |
| 1158 | else if ( token == "edges" ) { |
| 1159 | if ( !ParseEdges( src ) ) { return false; } |
| 1160 | } |
no test coverage detected