| 311 | |
| 312 | |
| 313 | void cCraftingRecipes::LoadRecipes(void) |
| 314 | { |
| 315 | LOGD("Loading crafting recipes from crafting.txt..."); |
| 316 | ClearRecipes(); |
| 317 | |
| 318 | // Load the crafting.txt file: |
| 319 | cFile f; |
| 320 | if (!f.Open("crafting.txt", cFile::fmRead)) |
| 321 | { |
| 322 | LOGWARNING("Cannot open file \"crafting.txt\", no crafting recipes will be available!"); |
| 323 | return; |
| 324 | } |
| 325 | AString Everything; |
| 326 | f.ReadRestOfFile(Everything); |
| 327 | f.Close(); |
| 328 | |
| 329 | // Split it into lines, then process each line as a single recipe: |
| 330 | AStringVector Split = StringSplit(Everything, "\n"); |
| 331 | int LineNum = 1; |
| 332 | for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr, ++LineNum) |
| 333 | { |
| 334 | // Remove anything after a '#' sign and trim away the whitespace: |
| 335 | AString Recipe = TrimString(itr->substr(0, itr->find('#'))); |
| 336 | if (Recipe.empty()) |
| 337 | { |
| 338 | // Empty recipe |
| 339 | continue; |
| 340 | } |
| 341 | AddRecipeLine(LineNum, Recipe); |
| 342 | } // for itr - Split[] |
| 343 | LOG("Loaded " SIZE_T_FMT " crafting recipes", m_Recipes.size()); |
| 344 | } |
| 345 | |
| 346 | |
| 347 |
nothing calls this directly
no test coverage detected