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