MCPcopy Create free account
hub / github.com/cuberite/cuberite / LoadRecipes

Method LoadRecipes

src/CraftingRecipes.cpp:313–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312
313void 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

Callers

nothing calls this directly

Calls 10

StringSplitFunction · 0.85
TrimStringFunction · 0.85
LOGFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
emptyMethod · 0.80
sizeMethod · 0.80
OpenMethod · 0.45
ReadRestOfFileMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected