1
0

Use std::auto_ptr

This commit is contained in:
Howaner 2014-08-31 22:04:52 +02:00
parent 0d392f53ed
commit af125d2a61

View File

@ -115,7 +115,7 @@ void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, unsigned int a_Line
Line.erase(Line.begin()); // Remove the beginning "!" Line.erase(Line.begin()); // Remove the beginning "!"
Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end()); Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end());
cItem * Item = new cItem(); std::auto_ptr<cItem> Item(new cItem);
int BurnTime; int BurnTime;
const AStringVector & Sides = StringSplit(Line, "="); const AStringVector & Sides = StringSplit(Line, "=");
@ -142,7 +142,7 @@ void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, unsigned int a_Line
// Add to fuel list: // Add to fuel list:
cFuel Fuel; cFuel Fuel;
Fuel.In = Item; Fuel.In = Item.release();
Fuel.BurnTime = BurnTime; Fuel.BurnTime = BurnTime;
m_pState->Fuel.push_back(Fuel); m_pState->Fuel.push_back(Fuel);
} }
@ -157,8 +157,8 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, unsigned int a_Li
Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end()); Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end());
int CookTime = 200; int CookTime = 200;
cItem * InputItem = new cItem(); std::auto_ptr<cItem> InputItem(new cItem());
cItem * OutputItem = new cItem(); std::auto_ptr<cItem> OutputItem(new cItem());
const AStringVector & Sides = StringSplit(Line, "="); const AStringVector & Sides = StringSplit(Line, "=");
if (Sides.size() != 2) if (Sides.size() != 2)
@ -194,8 +194,8 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, unsigned int a_Li
} }
cRecipe Recipe; cRecipe Recipe;
Recipe.In = InputItem; Recipe.In = InputItem.release();
Recipe.Out = OutputItem; Recipe.Out = OutputItem.release();
Recipe.CookTime = CookTime; Recipe.CookTime = CookTime;
m_pState->Recipes.push_back(Recipe); m_pState->Recipes.push_back(Recipe);
} }