liquids: use unique_ptr properly

develop
lethosor 2018-04-05 02:15:32 -04:00
parent b6311ec6b8
commit e9457b9f65
1 changed files with 7 additions and 9 deletions

@ -408,34 +408,32 @@ command_result df_liquids_execute(color_ostream &out)
command_result df_liquids_execute(color_ostream &out, OperationMode &cur_mode, df::coord cursor)
{
// create brush type depending on old parameters
Brush *brush;
std::unique_ptr<Brush> brush;
switch (cur_mode.brush)
{
case B_POINT:
brush = new RectangleBrush(1,1,1,0,0,0);
brush.reset(new RectangleBrush(1,1,1,0,0,0));
break;
case B_RANGE:
brush = new RectangleBrush(cur_mode.size.x,cur_mode.size.y,cur_mode.size.z,0,0,0);
brush.reset(new RectangleBrush(cur_mode.size.x,cur_mode.size.y,cur_mode.size.z,0,0,0));
break;
case B_BLOCK:
brush = new BlockBrush();
brush.reset(new BlockBrush());
break;
case B_COLUMN:
brush = new ColumnBrush();
brush.reset(new ColumnBrush());
break;
case B_FLOOD:
brush = new FloodBrush(&Core::getInstance());
brush.reset(new FloodBrush(&Core::getInstance()));
break;
default:
// this should never happen!
out << "Old brushtype is invalid! Resetting to point brush.\n";
cur_mode.brush = B_POINT;
brush = new RectangleBrush(1,1,1,0,0,0);
brush.reset(new RectangleBrush(1,1,1,0,0,0));
}
std::auto_ptr<Brush> brush_ref(brush);
if (!Maps::IsValid())
{
out << "Can't see any DF map loaded." << endl;