diff --git a/source_lists/wesnoth b/source_lists/wesnoth index 0e185a36674a..c3f347acc25c 100644 --- a/source_lists/wesnoth +++ b/source_lists/wesnoth @@ -380,6 +380,7 @@ units/formula_manager.cpp units/frame.cpp units/helper.cpp units/id.cpp +units/make.cpp units/map.cpp units/race.cpp units/types.cpp diff --git a/src/units/make.cpp b/src/units/make.cpp new file mode 100644 index 000000000000..c422decb162d --- /dev/null +++ b/src/units/make.cpp @@ -0,0 +1,26 @@ +/* + Copyright (C) 2014 - 2017 by Chris Beck + Part of the Battle for Wesnoth Project http://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#include "units/ptr.hpp" +#include "units/unit.hpp" + +unit_ptr make_unit_ptr(const config& cfg, bool use_traits, const vconfig* vcfg){ + return { new unit(cfg, use_traits, vcfg) }; +} +unit_ptr make_unit_ptr(const unit_type& t, int side, bool real_unit, unit_race::GENDER gender){ + return { new unit(t, side, real_unit, gender) }; +} +unit_ptr make_unit_ptr(const unit& u){ + return { new unit(u) }; +} diff --git a/src/units/make.hpp b/src/units/make.hpp new file mode 100644 index 000000000000..897664b73707 --- /dev/null +++ b/src/units/make.hpp @@ -0,0 +1,22 @@ +/* + Copyright (C) 2014 - 2017 by Chris Beck + Part of the Battle for Wesnoth Project http://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#include "units/race.hpp" +class config; +class unit_type; +class vconfig; + +unit_ptr make_unit_ptr(const config& cfg, bool use_traits = false, const vconfig* vcfg = nullptr); +unit_ptr make_unit_ptr(const unit_type& t, int side, bool real_unit, unit_race::GENDER gender = unit_race::NUM_GENDERS); +unit_ptr make_unit_ptr(const unit& u);