For now load the INF data directly. Move back to asset later.
| 1227 | // For now load the INF data directly. |
| 1228 | // Move back to asset later. |
| 1229 | JBool inf_load(const char* levelName) |
| 1230 | { |
| 1231 | char levelPath[TFE_MAX_PATH]; |
| 1232 | strcpy(levelPath, levelName); |
| 1233 | strcat(levelPath, ".INF"); |
| 1234 | |
| 1235 | FilePath filePath; |
| 1236 | if (!TFE_Paths::getFilePath(levelPath, &filePath)) |
| 1237 | { |
| 1238 | TFE_System::logWrite(LOG_ERROR, "level_loadINF", "Cannot find level INF '%s'.", levelPath); |
| 1239 | return JFALSE; |
| 1240 | } |
| 1241 | FileStream file; |
| 1242 | if (!file.open(&filePath, Stream::MODE_READ)) |
| 1243 | { |
| 1244 | TFE_System::logWrite(LOG_ERROR, "level_loadINF", "Cannot open level INF '%s'.", levelPath); |
| 1245 | return JFALSE; |
| 1246 | } |
| 1247 | size_t len = file.getSize(); |
| 1248 | s_buffer.resize(len); |
| 1249 | file.readBuffer(s_buffer.data(), u32(len)); |
| 1250 | file.close(); |
| 1251 | |
| 1252 | TFE_Parser parser; |
| 1253 | size_t bufferPos = 0; |
| 1254 | parser.init(s_buffer.data(), s_buffer.size()); |
| 1255 | parser.enableBlockComments(); |
| 1256 | parser.addCommentString("//"); |
| 1257 | parser.convertToUpperCase(true); |
| 1258 | |
| 1259 | const char* line; |
| 1260 | line = parser.readLine(bufferPos); |
| 1261 | |
| 1262 | // Keep looping until the version is found. |
| 1263 | while (strncasecmp(line, "INF", 3) != 0 && line) |
| 1264 | { |
| 1265 | line = parser.readLine(bufferPos); |
| 1266 | } |
| 1267 | if (!line) |
| 1268 | { |
| 1269 | TFE_System::logWrite(LOG_ERROR, "level_loadINF", "Cannot find INF version."); |
| 1270 | return JFALSE; |
| 1271 | } |
| 1272 | |
| 1273 | f32 version; |
| 1274 | if (sscanf(line, "INF %f", &version) != 1) |
| 1275 | { |
| 1276 | TFE_System::logWrite(LOG_ERROR, "level_loadINF", "Cannot read INF version."); |
| 1277 | return JFALSE; |
| 1278 | } |
| 1279 | if (version != 1.0f) |
| 1280 | { |
| 1281 | TFE_System::logWrite(LOG_ERROR, "level_loadINF", "Incorrect INF version %f, should be 1.0.", version); |
| 1282 | return JFALSE; |
| 1283 | } |
| 1284 | |
| 1285 | // Keep looping until ITEMS is found. |
| 1286 | s32 itemCount = 0; |
no test coverage detected