Skip to content

Commit

Permalink
Add make_unit_ptr functions in separate header, to avoid inclusion of…
Browse files Browse the repository at this point in the history
… unit.hpp
  • Loading branch information
AI0867 authored and GregoryLundberg committed Nov 30, 2017
1 parent e40807b commit 038aff0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions source_lists/wesnoth
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/units/make.cpp
@@ -0,0 +1,26 @@
/*
Copyright (C) 2014 - 2017 by Chris Beck <render787@gmail.com>
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) };
}
22 changes: 22 additions & 0 deletions src/units/make.hpp
@@ -0,0 +1,22 @@
/*
Copyright (C) 2014 - 2017 by Chris Beck <render787@gmail.com>
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);

0 comments on commit 038aff0

Please sign in to comment.