Miroslav Remák has proposed merging lp:~widelands-dev/widelands/improve-restool into lp:widelands.
Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/improve-restool/+merge/289305 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/improve-restool into lp:widelands.
=== modified file 'src/editor/tools/editor_action_args.h' --- src/editor/tools/editor_action_args.h 2016-01-16 12:55:14 +0000 +++ src/editor/tools/editor_action_args.h 2016-03-16 21:48:13 +0000 @@ -51,7 +51,14 @@ int32_t change_by; // resources, hight change tools std::list<Widelands::Field::Height> origHights; // change hight tool uint8_t cur_res, set_to; // resources change tools - std::list<uint8_t> orgRes, orgResT; // resources set tool + + struct ResourceState { + Widelands::FCoords location; + uint8_t idx; + uint8_t amount; + }; + + std::list<ResourceState> orgRes; // resources set tool std::list<const Widelands::BobDescr *> obob_type, nbob_type; // bob change tools std::list<std::string> oimmov_types; // immovable change tools std::list<int32_t> nimmov_types; // immovable change tools === modified file 'src/editor/tools/editor_decrease_resources_tool.cc' --- src/editor/tools/editor_decrease_resources_tool.cc 2016-03-15 04:53:13 +0000 +++ src/editor/tools/editor_decrease_resources_tool.cc 2016-03-16 21:48:13 +0000 @@ -50,11 +50,15 @@ if (amount < 0) amount = 0; - args->orgResT.push_back(mr.location().field->get_resources()); - args->orgRes.push_back(mr.location().field->get_resources_amount()); - if (mr.location().field->get_resources() == args->cur_res && map->is_resource_valid(world, mr.location(), args->cur_res)) { + + args->orgRes.push_back(EditorActionArgs::ResourceState{ + mr.location(), + mr.location().field->get_resources(), + mr.location().field->get_resources_amount() + }); + map->initialize_resources(mr.location(), args->cur_res, amount); } === modified file 'src/editor/tools/editor_history.cc' --- src/editor/tools/editor_history.cc 2016-01-28 05:24:34 +0000 +++ src/editor/tools/editor_history.cc 2016-03-16 21:48:13 +0000 @@ -47,7 +47,6 @@ nimmov_types.clear(); oimmov_types.clear(); orgRes.clear(); - orgResT.clear(); origHights.clear(); origTerrainType.clear(); terrainType.clear(); === modified file 'src/editor/tools/editor_increase_resources_tool.cc' --- src/editor/tools/editor_increase_resources_tool.cc 2016-03-15 04:53:13 +0000 +++ src/editor/tools/editor_increase_resources_tool.cc 2016-03-16 21:48:13 +0000 @@ -47,12 +47,16 @@ if (amount > max_amount) amount = max_amount; - args->orgResT.push_back(mr.location().field->get_resources()); - args->orgRes.push_back(mr.location().field->get_resources_amount()); - if ((mr.location().field->get_resources() == args->cur_res || !mr.location().field->get_resources_amount()) && map->is_resource_valid(world, mr.location(), args->cur_res)) { + + args->orgRes.push_back(EditorActionArgs::ResourceState{ + mr.location(), + mr.location().field->get_resources(), + mr.location().field->get_resources_amount() + }); + map->initialize_resources(mr.location(), args->cur_res, amount); } } while (mr.advance(*map)); === modified file 'src/editor/tools/editor_set_resources_tool.cc' --- src/editor/tools/editor_set_resources_tool.cc 2016-01-14 22:09:24 +0000 +++ src/editor/tools/editor_set_resources_tool.cc 2016-03-16 21:48:13 +0000 @@ -47,8 +47,12 @@ amount = max_amount; if (map->is_resource_valid(world, mr.location(), args->cur_res)) { - args->orgResT.push_back(mr.location().field->get_resources()); - args->orgRes.push_back(mr.location().field->get_resources_amount()); + args->orgRes.push_back(EditorActionArgs::ResourceState{ + mr.location(), + mr.location().field->get_resources(), + mr.location().field->get_resources_amount() + }); + map->initialize_resources(mr.location(), args->cur_res, amount); } } while (mr.advance(*map)); @@ -57,17 +61,12 @@ int32_t EditorSetResourcesTool::handle_undo_impl(const Widelands::World& world, - Widelands::NodeAndTriangle<Widelands::Coords> center, + Widelands::NodeAndTriangle<Widelands::Coords> /* center */, EditorInteractive& /* parent */, EditorActionArgs* args, Widelands::Map* map) { - Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr - (*map, - Widelands::Area<Widelands::FCoords> - (map->get_fcoords(center.node), args->sel_radius)); - std::list<uint8_t>::iterator ir = args->orgRes.begin(), it = args->orgResT.begin(); - do { - int32_t amount = *ir; + for (const auto & res : args->orgRes) { + int32_t amount = res.amount; int32_t max_amount = world.get_resource(args->cur_res)->max_amount(); if (amount < 0) @@ -75,13 +74,11 @@ if (amount > max_amount) amount = max_amount; - map->initialize_resources(mr.location(), *it, amount); - ++ir; - ++it; - } while (mr.advance(*map)); + map->initialize_resources(res.location, res.idx, amount); + } + args->orgRes.clear(); - args->orgResT.clear(); - return mr.radius(); + return args->sel_radius; } EditorActionArgs EditorSetResourcesTool::format_args_impl(EditorInteractive & parent)
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp