Merge pull request #716 from wesnoth/boost_trimming
Boost-related cleanups
This commit is contained in:
commit
24577e117d
326 changed files with 1477 additions and 4345 deletions
|
@ -327,7 +327,6 @@
|
|||
<Unit filename="../../src/filesystem_sdl.cpp" />
|
||||
<Unit filename="../../src/floating_label.cpp" />
|
||||
<Unit filename="../../src/floating_label.hpp" />
|
||||
<Unit filename="../../src/floating_point_emulation.hpp" />
|
||||
<Unit filename="../../src/floating_textbox.cpp" />
|
||||
<Unit filename="../../src/floating_textbox.hpp" />
|
||||
<Unit filename="../../src/font.cpp" />
|
||||
|
@ -873,7 +872,6 @@
|
|||
<Unit filename="../../src/random_new_synced.hpp" />
|
||||
<Unit filename="../../src/recall_list_manager.cpp" />
|
||||
<Unit filename="../../src/recall_list_manager.hpp" />
|
||||
<Unit filename="../../src/reference_counted_object.hpp" />
|
||||
<Unit filename="../../src/replay.cpp" />
|
||||
<Unit filename="../../src/replay.hpp" />
|
||||
<Unit filename="../../src/replay_controller.cpp" />
|
||||
|
|
|
@ -3021,18 +3021,6 @@
|
|||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Terrain\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Terrain\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\tests\floating_point_emulation.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">true</ExcludedFromBuild>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseDEBUG|Win32'">true</ExcludedFromBuild>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='ReleaseDEBUG|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Tests\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\tests\gui\fire_event.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">true</ExcludedFromBuild>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Tests\Gui\</ObjectFileName>
|
||||
|
@ -3945,7 +3933,6 @@
|
|||
<ClInclude Include="..\..\src\filechooser.hpp" />
|
||||
<ClInclude Include="..\..\src\filesystem.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_label.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_point_emulation.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_textbox.hpp" />
|
||||
<ClInclude Include="..\..\src\font.hpp" />
|
||||
<ClInclude Include="..\..\src\formatter.hpp" />
|
||||
|
@ -4268,7 +4255,6 @@
|
|||
<ClInclude Include="..\..\src\sdl\shader.hpp" />
|
||||
<ClInclude Include="..\..\src\sdl\utils.hpp" />
|
||||
<ClInclude Include="..\..\src\sdl\window.hpp" />
|
||||
<ClInclude Include="..\..\src\SDL_SavePNG\savepng.hpp" />
|
||||
<ClInclude Include="..\..\src\seed_rng.hpp" />
|
||||
<ClInclude Include="..\..\src\settings.hpp" />
|
||||
<ClInclude Include="..\..\src\show_dialog.hpp" />
|
||||
|
|
|
@ -959,9 +959,6 @@
|
|||
<ClCompile Include="..\..\src\tools\schema\tag.cpp">
|
||||
<Filter>tools\schema</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\tests\floating_point_emulation.cpp">
|
||||
<Filter>Tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\tests\main.cpp">
|
||||
<Filter>Tests</Filter>
|
||||
</ClCompile>
|
||||
|
@ -2520,9 +2517,6 @@
|
|||
<ClInclude Include="..\..\src\sdl\rect.hpp">
|
||||
<Filter>SDL</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\SDL_SavePNG\savepng.hpp">
|
||||
<Filter>SDL</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\sdl\shader.hpp">
|
||||
<Filter>SDL</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2761,7 +2755,6 @@
|
|||
<ClInclude Include="..\..\src\filechooser.hpp" />
|
||||
<ClInclude Include="..\..\src\filesystem.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_label.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_point_emulation.hpp" />
|
||||
<ClInclude Include="..\..\src\floating_textbox.hpp" />
|
||||
<ClInclude Include="..\..\src\font.hpp" />
|
||||
<ClInclude Include="..\..\src\format_time_summary.hpp" />
|
||||
|
|
|
@ -1982,7 +1982,6 @@
|
|||
B55999B90EC62181008DD061 /* replay_controller.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = replay_controller.cpp; sourceTree = "<group>"; };
|
||||
B55999BA0EC62181008DD061 /* replay.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = replay.hpp; sourceTree = "<group>"; };
|
||||
B55999BB0EC62181008DD061 /* replay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = replay.cpp; sourceTree = "<group>"; };
|
||||
B55999BC0EC62181008DD061 /* reference_counted_object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = reference_counted_object.hpp; sourceTree = "<group>"; };
|
||||
B55999BF0EC62181008DD061 /* race.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = race.hpp; sourceTree = "<group>"; };
|
||||
B55999C00EC62181008DD061 /* race.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = race.cpp; sourceTree = "<group>"; };
|
||||
B55999C10EC62181008DD061 /* preferences_display.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = preferences_display.hpp; sourceTree = "<group>"; };
|
||||
|
@ -3014,7 +3013,6 @@
|
|||
EC84245A18F30D9000FC1EEF /* random_new_synced.hpp */,
|
||||
EC1CB20619524AD600B0FA78 /* recall_list_manager.cpp */,
|
||||
EC1CB20719524AD600B0FA78 /* recall_list_manager.hpp */,
|
||||
B55999BC0EC62181008DD061 /* reference_counted_object.hpp */,
|
||||
B55999BB0EC62181008DD061 /* replay.cpp */,
|
||||
B55999BA0EC62181008DD061 /* replay.hpp */,
|
||||
B55999B90EC62181008DD061 /* replay_controller.cpp */,
|
||||
|
|
|
@ -1354,7 +1354,6 @@ if(ENABLE_TESTS)
|
|||
add_definitions(-DBOOST_TEST_DYN_LINK)
|
||||
|
||||
set(test_SRC
|
||||
tests/floating_point_emulation.cpp
|
||||
tests/gui/iterator.cpp
|
||||
tests/gui/fire_event.cpp
|
||||
tests/gui/test_drop_target.cpp
|
||||
|
|
|
@ -697,7 +697,6 @@ client_env.WesnothProgram("wesmage", wesmage_sources + [libwesnoth_core], have_c
|
|||
libtest_utils = test_env.Library("test_utils", test_utils_sources)
|
||||
|
||||
test_sources = Split("""
|
||||
tests/floating_point_emulation.cpp
|
||||
tests/gui/fire_event.cpp
|
||||
tests/gui/iterator.cpp
|
||||
tests/gui/test_drop_target.cpp
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "widgets/button.hpp" // for button
|
||||
|
||||
#include <algorithm> // for max
|
||||
#include <boost/scoped_ptr.hpp> // for scoped_ptr
|
||||
#include <map> // for map, map<>::mapped_type
|
||||
#include <ostream> // for operator<<, basic_ostream, etc
|
||||
|
||||
|
@ -207,7 +206,7 @@ void set_about(const config &cfg)
|
|||
*/
|
||||
void show_about(CVideo &video, const std::string &campaign)
|
||||
{
|
||||
boost::scoped_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
|
||||
std::unique_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
|
||||
surface& screen = video.getSurface();
|
||||
if (screen == nullptr) return;
|
||||
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
#include "variable.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
|
@ -644,10 +642,10 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
|
|||
const std::string event_name = is_recall ? "prerecall" : "prerecruit";
|
||||
LOG_NG << "firing " << event_name << " event\n";
|
||||
{
|
||||
res.get<0>() |= resources::game_events->pump().fire(event_name, current_loc, recruited_from);
|
||||
std::get<0>(res) |= resources::game_events->pump().fire(event_name, current_loc, recruited_from);
|
||||
}
|
||||
if ( !validate_recruit_iterator(new_unit_itor, current_loc) )
|
||||
return true;
|
||||
return std::make_tuple(true, 0, false);
|
||||
new_unit_itor->set_hidden(true);
|
||||
}
|
||||
preferences::encountered_units().insert(new_unit_itor->type_id());
|
||||
|
@ -665,29 +663,29 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
|
|||
|
||||
// Village capturing.
|
||||
if ( resources::gameboard->map().is_village(current_loc) ) {
|
||||
res.get<1>() = resources::gameboard->village_owner(current_loc) + 1;
|
||||
res.get<0>() |= actions::get_village(current_loc, new_unit_itor->side(), &res.get<2>());
|
||||
std::get<1>(res) = resources::gameboard->village_owner(current_loc) + 1;
|
||||
std::get<0>(res) |= actions::get_village(current_loc, new_unit_itor->side(), &std::get<2>(res));
|
||||
if ( !validate_recruit_iterator(new_unit_itor, current_loc) )
|
||||
return true;
|
||||
return std::make_tuple(true, 0, false);
|
||||
}
|
||||
|
||||
// Fog clearing.
|
||||
actions::shroud_clearer clearer;
|
||||
if ( !wml_triggered ) // To preserve current WML behavior.
|
||||
res.get<0>() |= clearer.clear_unit(current_loc, *new_unit_itor);
|
||||
std::get<0>(res) |= clearer.clear_unit(current_loc, *new_unit_itor);
|
||||
|
||||
if ( fire_event ) {
|
||||
const std::string event_name = is_recall ? "recall" : "recruit";
|
||||
LOG_NG << "firing " << event_name << " event\n";
|
||||
{
|
||||
res.get<0>() |= resources::game_events->pump().fire(event_name, current_loc, recruited_from);
|
||||
std::get<0>(res) |= resources::game_events->pump().fire(event_name, current_loc, recruited_from);
|
||||
}
|
||||
}
|
||||
|
||||
// "sighted" event(s).
|
||||
res.get<0>() |= clearer.fire_events();
|
||||
std::get<0>(res) |= clearer.fire_events();
|
||||
if ( new_unit_itor.valid() )
|
||||
res.get<0>() |= actions::actor_sighted(*new_unit_itor);
|
||||
std::get<0>(res) |= actions::actor_sighted(*new_unit_itor);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -710,10 +708,10 @@ void recruit_unit(const unit_type & u_type, int side_num, const map_location & l
|
|||
// an AI turn. The AI will not undo nor delay shroud updates.
|
||||
// (Undo stack processing is also suppressed when redoing a recruit.)
|
||||
if ( use_undo ) {
|
||||
resources::undo_stack->add_recruit(new_unit, loc, from, res.get<1>(), res.get<2>());
|
||||
resources::undo_stack->add_recruit(new_unit, loc, from, std::get<1>(res), std::get<2>(res));
|
||||
// Check for information uncovered or randomness used.
|
||||
|
||||
if ( res.get<0>() || !synced_context::can_undo()) {
|
||||
if ( std::get<0>(res) || !synced_context::can_undo()) {
|
||||
resources::undo_stack->clear();
|
||||
}
|
||||
}
|
||||
|
@ -759,8 +757,8 @@ bool recall_unit(const std::string & id, team & current_team,
|
|||
// an AI turn. The AI will not undo nor delay shroud updates.
|
||||
// (Undo stack processing is also suppressed when redoing a recall.)
|
||||
if ( use_undo ) {
|
||||
resources::undo_stack->add_recall(recall, loc, from, res.get<1>(), res.get<2>());
|
||||
if ( res.get<0>() || !synced_context::can_undo()) {
|
||||
resources::undo_stack->add_recall(recall, loc, from, std::get<1>(res), std::get<2>(res));
|
||||
if ( std::get<0>(res) || !synced_context::can_undo()) {
|
||||
resources::undo_stack->clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class vconfig;
|
|||
#include "map/location.hpp"
|
||||
#include "units/ptr.hpp"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -148,7 +148,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
|
|||
* through a call to recruit_location().
|
||||
* @returns true if an event (or fog clearing) has mutated the game state.
|
||||
*/
|
||||
typedef boost::tuple<bool /*event modified*/, int /*previous village owner side*/, bool /*capture bonus time*/> place_recruit_result;
|
||||
typedef std::tuple<bool /*event modified*/, int /*previous village owner side*/, bool /*capture bonus time*/> place_recruit_result;
|
||||
place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_location, const map_location& recruited_from,
|
||||
int cost, bool is_recall, bool show = false, bool fire_event = true, bool full_movement = false,
|
||||
bool wml_triggered = false);
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include "map/location.hpp"
|
||||
#include "units/ptr.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
namespace actions
|
||||
{
|
||||
/// base class for classes that clear srhoud (move/recruit/recall)
|
||||
|
|
|
@ -54,11 +54,6 @@
|
|||
#include "undo_update_shroud_action.hpp"
|
||||
|
||||
#include <algorithm> // for reverse
|
||||
#include <boost/intrusive_ptr.hpp> // for intrusive_ptr
|
||||
#include <boost/ptr_container/detail/static_move_ptr.hpp>
|
||||
#include <boost/ptr_container/detail/void_ptr_iterator.hpp>
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||
#include <cassert> // for assert
|
||||
#include <ostream> // for operator<<, basic_ostream, etc
|
||||
#include <set> // for set
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace {
|
|||
x2 = e.filter_loc2.x + 1; y2 = e.filter_loc2.y + 1;
|
||||
|
||||
int realx1 = 0, realy1 = 0, realx2 = 0, realy2 = 0;
|
||||
boost::scoped_ptr<scoped_xy_unit> u1, u2;
|
||||
std::unique_ptr<scoped_xy_unit> u1, u2;
|
||||
if(unit_ptr who = get_unit(e.uid1, e.id1)) {
|
||||
realx1 = who->get_location().x;
|
||||
realy1 = who->get_location().y;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "config.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace actions {
|
||||
class undo_list;
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
|
||||
#include "game_display.hpp" // for resources::screen
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#include "wml_separators.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include "addon/client.hpp"
|
||||
|
||||
static lg::log_domain log_config("config");
|
||||
|
@ -155,7 +153,7 @@ addon_op_result do_resolve_addon_dependencies(CVideo& v, addons_client& client,
|
|||
result.outcome = SUCCESS;
|
||||
result.wml_changed = false;
|
||||
|
||||
boost::scoped_ptr<cursor::setter> cursor_setter(new cursor::setter(cursor::WAIT));
|
||||
std::unique_ptr<cursor::setter> cursor_setter(new cursor::setter(cursor::WAIT));
|
||||
|
||||
// TODO: We don't currently check for the need to upgrade. I'll probably
|
||||
// work on that when implementing dependency tiers later.
|
||||
|
@ -609,7 +607,7 @@ sorted_addon_pointer_list sort_addons_list(addons_list& addons, ADDON_SORT sort,
|
|||
|
||||
void show_addons_manager_dialog(CVideo& v, addons_client& client, addons_list& addons, std::string& last_addon_id, bool& stay_in_ui, bool& wml_changed, addons_filter_state& filter)
|
||||
{
|
||||
boost::scoped_ptr<cursor::setter> cursor_setter(new cursor::setter(cursor::WAIT));
|
||||
std::unique_ptr<cursor::setter> cursor_setter(new cursor::setter(cursor::WAIT));
|
||||
|
||||
stay_in_ui = false;
|
||||
filter.changed = false;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "addon/validation.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const unsigned short default_campaignd_port = 15008;
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -383,7 +383,7 @@ bool move_result::test_route(const unit &un)
|
|||
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);///@todo 1.9: see_all -> false
|
||||
|
||||
//do an A*-search
|
||||
route_ = boost::shared_ptr<pathfind::plain_route>( new pathfind::plain_route(pathfind::a_star_search(un.get_location(), to_, 10000.0, &calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports)));
|
||||
route_ = std::shared_ptr<pathfind::plain_route>( new pathfind::plain_route(pathfind::a_star_search(un.get_location(), to_, 10000.0, &calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports)));
|
||||
if (route_->steps.empty()) {
|
||||
set_error(E_NO_ROUTE);
|
||||
return false;
|
||||
|
|
|
@ -196,7 +196,7 @@ private:
|
|||
const map_location from_;
|
||||
const map_location to_;
|
||||
bool remove_movement_;
|
||||
boost::shared_ptr<pathfind::plain_route> route_;
|
||||
std::shared_ptr<pathfind::plain_route> route_;
|
||||
map_location unit_location_;
|
||||
bool unreach_is_ok_;
|
||||
bool has_ambusher_;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "util.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include <boost/pointer_cast.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
|
@ -56,7 +55,7 @@ public:
|
|||
virtual const variant& get_variant() const = 0;
|
||||
|
||||
|
||||
virtual boost::shared_ptr<variant> get_variant_ptr() const = 0;
|
||||
virtual std::shared_ptr<variant> get_variant_ptr() const = 0;
|
||||
|
||||
|
||||
virtual void recalculate() const = 0;
|
||||
|
@ -139,7 +138,7 @@ public:
|
|||
return *get_variant_ptr();
|
||||
}
|
||||
|
||||
virtual boost::shared_ptr<variant> get_variant_ptr() const
|
||||
virtual std::shared_ptr<variant> get_variant_ptr() const
|
||||
{
|
||||
if (!valid_variant_) {
|
||||
if (!valid_) {
|
||||
|
@ -147,11 +146,11 @@ public:
|
|||
}
|
||||
|
||||
if (!valid_variant_ && valid_ ) {
|
||||
value_variant_ = boost::shared_ptr<variant>(new variant(variant_value_translator<T>::value_to_variant(this->get())));
|
||||
value_variant_ = std::shared_ptr<variant>(new variant(variant_value_translator<T>::value_to_variant(this->get())));
|
||||
valid_variant_ = true;
|
||||
} else if (!valid_variant_ && valid_lua_) {
|
||||
value_ = value_lua_->get();
|
||||
value_variant_ = boost::shared_ptr<variant>(new variant(variant_value_translator<T>::value_to_variant(this->get())));
|
||||
value_variant_ = std::shared_ptr<variant>(new variant(variant_value_translator<T>::value_to_variant(this->get())));
|
||||
valid_variant_ = true; // @note: temporary workaround
|
||||
} else {
|
||||
assert(valid_variant_);
|
||||
|
@ -163,7 +162,7 @@ public:
|
|||
virtual void recalculate() const = 0;
|
||||
|
||||
|
||||
virtual boost::shared_ptr<T> get_ptr() const
|
||||
virtual std::shared_ptr<T> get_ptr() const
|
||||
{
|
||||
if (!valid_) {
|
||||
if (!(valid_variant_ || valid_lua_)) {
|
||||
|
@ -172,7 +171,7 @@ public:
|
|||
|
||||
if (!valid_ ) {
|
||||
if (valid_variant_) {
|
||||
value_ = boost::shared_ptr<T>(new T(variant_value_translator<T>::variant_to_value(get_variant())));
|
||||
value_ = std::shared_ptr<T>(new T(variant_value_translator<T>::variant_to_value(get_variant())));
|
||||
valid_ = true;
|
||||
} else if (valid_lua_){
|
||||
value_ = value_lua_->get();
|
||||
|
@ -186,9 +185,9 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
mutable boost::shared_ptr<T> value_;
|
||||
mutable boost::shared_ptr<variant> value_variant_;
|
||||
mutable boost::shared_ptr< lua_object<T> > value_lua_;
|
||||
mutable std::shared_ptr<T> value_;
|
||||
mutable std::shared_ptr<variant> value_variant_;
|
||||
mutable std::shared_ptr< lua_object<T> > value_lua_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -219,14 +218,14 @@ class composite_aspect;
|
|||
template<typename T>
|
||||
class typesafe_known_aspect : public known_aspect {
|
||||
public:
|
||||
typesafe_known_aspect(const std::string &name, boost::shared_ptr< typesafe_aspect<T> > &where, aspect_map &aspects)
|
||||
typesafe_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect<T> > &where, aspect_map &aspects)
|
||||
: known_aspect(name), where_(where), aspects_(aspects)
|
||||
{
|
||||
}
|
||||
|
||||
void set(aspect_ptr a)
|
||||
{
|
||||
boost::shared_ptr< typesafe_aspect <T> > c = boost::dynamic_pointer_cast< typesafe_aspect<T> >(a);
|
||||
std::shared_ptr< typesafe_aspect <T> > c = std::dynamic_pointer_cast< typesafe_aspect<T> >(a);
|
||||
if (c) {
|
||||
assert (c->get_id()== this->get_name());
|
||||
where_ = c;
|
||||
|
@ -238,7 +237,7 @@ public:
|
|||
|
||||
virtual void add_facet(const config &cfg)
|
||||
{
|
||||
boost::shared_ptr< composite_aspect <T> > c = boost::dynamic_pointer_cast< composite_aspect<T> >(where_);
|
||||
std::shared_ptr< composite_aspect <T> > c = std::dynamic_pointer_cast< composite_aspect<T> >(where_);
|
||||
if (c) {
|
||||
assert (c->get_id()==this->get_name());
|
||||
c->add_facet(-1, cfg);
|
||||
|
@ -249,7 +248,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<typesafe_aspect <T> > &where_;
|
||||
std::shared_ptr<typesafe_aspect <T> > &where_;
|
||||
aspect_map &aspects_;
|
||||
|
||||
};
|
||||
|
@ -275,7 +274,7 @@ public:
|
|||
std::vector< aspect_ptr > default_aspects;
|
||||
engine::parse_aspect_from_config(*this,_default,parent_id_,std::back_inserter(default_aspects));
|
||||
if (!default_aspects.empty()) {
|
||||
typename aspect_type<T>::typesafe_ptr b = boost::dynamic_pointer_cast< typesafe_aspect<T> >(default_aspects.front());
|
||||
typename aspect_type<T>::typesafe_ptr b = std::dynamic_pointer_cast< typesafe_aspect<T> >(default_aspects.front());
|
||||
if (composite_aspect<T>* c = dynamic_cast<composite_aspect<T>*>(b.get())) {
|
||||
c->parent_id_ = parent_id_;
|
||||
}
|
||||
|
@ -296,7 +295,7 @@ public:
|
|||
std::vector<aspect_ptr> facets_base;
|
||||
engine::parse_aspect_from_config(*this,cfg,parent_id_,std::back_inserter(facets_base));
|
||||
for (aspect_ptr a : facets_base) {
|
||||
typename aspect_type<T>::typesafe_ptr b = boost::dynamic_pointer_cast< typesafe_aspect<T> > (a);
|
||||
typename aspect_type<T>::typesafe_ptr b = std::dynamic_pointer_cast< typesafe_aspect<T> > (a);
|
||||
if (composite_aspect<T>* c = dynamic_cast<composite_aspect<T>*>(b.get())) {
|
||||
c->parent_id_ = parent_id_;
|
||||
}
|
||||
|
@ -310,13 +309,13 @@ public:
|
|||
///@todo 1.9 optimize in case of an aspect which returns variant
|
||||
for (const typename aspect_type<T>::typesafe_ptr &f : make_pair(facets_.rbegin(),facets_.rend())) {
|
||||
if (f->active()) {
|
||||
this->value_ = boost::shared_ptr<T>(f->get_ptr());
|
||||
this->value_ = std::shared_ptr<T>(f->get_ptr());
|
||||
this->valid_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (default_) {
|
||||
this->value_ = boost::shared_ptr<T>(default_->get_ptr());
|
||||
this->value_ = std::shared_ptr<T>(default_->get_ptr());
|
||||
this->valid_ = true;
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +344,7 @@ public:
|
|||
engine::parse_aspect_from_config(*this,cfg,parent_id_,std::back_inserter(facets));
|
||||
int j=0;
|
||||
for (aspect_ptr a : facets) {
|
||||
typename aspect_type<T>::typesafe_ptr b = boost::dynamic_pointer_cast< typesafe_aspect<T> > (a);
|
||||
typename aspect_type<T>::typesafe_ptr b = std::dynamic_pointer_cast< typesafe_aspect<T> > (a);
|
||||
if (composite_aspect<T>* c = dynamic_cast<composite_aspect<T>*>(b.get())) {
|
||||
c->parent_id_ = parent_id_;
|
||||
}
|
||||
|
@ -377,7 +376,7 @@ public:
|
|||
: typesafe_aspect<T>(context, cfg, id)
|
||||
{
|
||||
this->name_ = "standard_aspect";
|
||||
boost::shared_ptr<T> value(new T(config_value_translator<T>::cfg_to_value(this->cfg_)));
|
||||
std::shared_ptr<T> value(new T(config_value_translator<T>::cfg_to_value(this->cfg_)));
|
||||
this->value_= value;
|
||||
LOG_STREAM(debug, aspect::log()) << "standard aspect has value: "<< std::endl << config_value_translator<T>::value_to_cfg(this->get()) << std::endl;
|
||||
}
|
||||
|
@ -415,7 +414,7 @@ template<typename T>
|
|||
class lua_aspect : public typesafe_aspect<T>
|
||||
{
|
||||
public:
|
||||
lua_aspect(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx)
|
||||
lua_aspect(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr<lua_ai_context>& l_ctx)
|
||||
: typesafe_aspect<T>(context, cfg, id)
|
||||
, handler_(), code_(), params_(cfg.child_or_empty("args"))
|
||||
{
|
||||
|
@ -433,7 +432,7 @@ public:
|
|||
// error
|
||||
return;
|
||||
}
|
||||
handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
}
|
||||
|
||||
void recalculate() const
|
||||
|
@ -454,7 +453,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
boost::shared_ptr<lua_ai_action_handler> handler_;
|
||||
std::shared_ptr<lua_ai_action_handler> handler_;
|
||||
std::string code_;
|
||||
const config params_;
|
||||
};
|
||||
|
@ -463,7 +462,7 @@ private:
|
|||
class aspect_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< aspect_factory > factory_ptr;
|
||||
typedef std::shared_ptr< aspect_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
@ -500,7 +499,7 @@ public:
|
|||
|
||||
aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id)
|
||||
{
|
||||
boost::shared_ptr<ASPECT> _a(new ASPECT(context,cfg,id));
|
||||
std::shared_ptr<ASPECT> _a(new ASPECT(context,cfg,id));
|
||||
aspect_ptr a = _a;
|
||||
a->on_create();
|
||||
return a;
|
||||
|
@ -509,7 +508,7 @@ public:
|
|||
|
||||
class lua_aspect_factory{
|
||||
public:
|
||||
typedef boost::shared_ptr< lua_aspect_factory > factory_ptr;
|
||||
typedef std::shared_ptr< lua_aspect_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
@ -521,7 +520,7 @@ public:
|
|||
return *aspect_factories;
|
||||
}
|
||||
|
||||
virtual aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx) = 0;
|
||||
virtual aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr<lua_ai_context>& l_ctx) = 0;
|
||||
|
||||
lua_aspect_factory( const std::string &name )
|
||||
{
|
||||
|
@ -540,9 +539,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx)
|
||||
aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr<lua_ai_context>& l_ctx)
|
||||
{
|
||||
boost::shared_ptr<ASPECT> _a(new ASPECT(context,cfg,id,l_ctx));
|
||||
std::shared_ptr<ASPECT> _a(new ASPECT(context,cfg,id,l_ctx));
|
||||
aspect_ptr a = _a;
|
||||
a->on_create();
|
||||
return a;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "ai/formula/ai.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace pathfind {
|
||||
|
@ -142,7 +141,7 @@ static component *find_component(component *root, const std::string &path, path_
|
|||
}
|
||||
|
||||
//match path elements in [modify_ai] tag
|
||||
boost::regex re("([^\\.^\\[]+)(\\[(\\d*)\\]|\\[([^\\]]+)\\]|())");
|
||||
boost::regex re(R"""(([^\.^\[]+)(\[(\d*)\]|\[([^\]]+)\]|()))""");
|
||||
int const sub_matches[] = {1,3,4};
|
||||
boost::sregex_token_iterator i(path.begin(), path.end(), re, sub_matches);
|
||||
boost::sregex_token_iterator j;
|
||||
|
@ -160,8 +159,8 @@ static component *find_component(component *root, const std::string &path, path_
|
|||
pe.position = -2;
|
||||
} else {
|
||||
try {
|
||||
pe.position = boost::lexical_cast<int>(position);
|
||||
} catch (boost::bad_lexical_cast){
|
||||
pe.position = lexical_cast<int>(position);
|
||||
} catch (bad_lexical_cast){
|
||||
pe.position = -2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,10 @@ class config;
|
|||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
//silence "inherits via dominance" warnings
|
||||
|
@ -53,7 +52,7 @@ struct path_element {
|
|||
};
|
||||
|
||||
class base_property_handler;
|
||||
typedef boost::shared_ptr<base_property_handler> property_handler_ptr;
|
||||
typedef std::shared_ptr<base_property_handler> property_handler_ptr;
|
||||
typedef std::map<std::string,property_handler_ptr> property_handler_map;
|
||||
|
||||
class component {
|
||||
|
|
|
@ -118,7 +118,7 @@ class engine_factory;
|
|||
class engine_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< engine_factory > factory_ptr;
|
||||
typedef std::shared_ptr< engine_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "units/filter.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -60,7 +59,7 @@ void goal::on_create()
|
|||
LOG_AI_GOAL << "side " << get_side() << " : " << " created goal with name=[" << cfg_["name"] << "]" << std::endl;
|
||||
}
|
||||
|
||||
void goal::on_create(boost::shared_ptr<ai::lua_ai_context>)
|
||||
void goal::on_create(std::shared_ptr<ai::lua_ai_context>)
|
||||
{
|
||||
unrecognized();
|
||||
}
|
||||
|
@ -134,8 +133,8 @@ void target_unit_goal::on_create()
|
|||
}
|
||||
if (const config::attribute_value *v = cfg_.get("value")) {
|
||||
try {
|
||||
value_ = boost::lexical_cast<double>(*v);
|
||||
} catch (boost::bad_lexical_cast){
|
||||
value_ = lexical_cast<double>(*v);
|
||||
} catch (bad_lexical_cast){
|
||||
ERR_AI_GOAL << "bad value of goal"<<std::endl;
|
||||
value_ = 0;
|
||||
}
|
||||
|
@ -181,15 +180,15 @@ void target_location_goal::on_create()
|
|||
}
|
||||
if (cfg_.has_attribute("value")) {
|
||||
try {
|
||||
value_ = boost::lexical_cast<double>(cfg_["value"]);
|
||||
} catch (boost::bad_lexical_cast){
|
||||
value_ = lexical_cast<double>(cfg_["value"]);
|
||||
} catch (bad_lexical_cast){
|
||||
ERR_AI_GOAL << "bad value of goal"<<std::endl;
|
||||
value_ = 0;
|
||||
}
|
||||
}
|
||||
const config &criteria = cfg_.child("criteria");
|
||||
if (criteria) {
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
filter_ptr_ = std::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,16 +229,16 @@ void protect_goal::on_create()
|
|||
}
|
||||
if (const config::attribute_value *v = cfg_.get("value")) {
|
||||
try {
|
||||
value_ = boost::lexical_cast<double>(*v);
|
||||
} catch (boost::bad_lexical_cast){
|
||||
value_ = lexical_cast<double>(*v);
|
||||
} catch (bad_lexical_cast){
|
||||
ERR_AI_GOAL << "bad value of protect_goal"<<std::endl;
|
||||
value_ = 0;
|
||||
}
|
||||
}
|
||||
if (const config::attribute_value *v = cfg_.get("protect_radius")) {
|
||||
try {
|
||||
radius_ = boost::lexical_cast<int>(*v);
|
||||
} catch (boost::bad_lexical_cast){
|
||||
radius_ = lexical_cast<int>(*v);
|
||||
} catch (bad_lexical_cast){
|
||||
ERR_AI_GOAL << "bad protection radius of protect_goal"<<std::endl;
|
||||
radius_ = 1;
|
||||
}
|
||||
|
@ -250,7 +249,7 @@ void protect_goal::on_create()
|
|||
}
|
||||
const config &criteria = cfg_.child("criteria");
|
||||
if (criteria) {
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
filter_ptr_ = std::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
}
|
||||
|
||||
|
||||
|
@ -340,15 +339,15 @@ lua_goal::lua_goal(readonly_context &context, const config &cfg)
|
|||
}
|
||||
}
|
||||
|
||||
void lua_goal::on_create(boost::shared_ptr<ai::lua_ai_context> l_ctx)
|
||||
void lua_goal::on_create(std::shared_ptr<ai::lua_ai_context> l_ctx)
|
||||
{
|
||||
handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
}
|
||||
|
||||
void lua_goal::add_targets(std::back_insert_iterator< std::vector< target > > target_list)
|
||||
{
|
||||
boost::shared_ptr< lua_object< std::vector < target > > > l_obj
|
||||
= boost::shared_ptr< lua_object< std::vector < target > > >(new lua_object< std::vector < target > >());
|
||||
std::shared_ptr< lua_object< std::vector < target > > > l_obj
|
||||
= std::shared_ptr< lua_object< std::vector < target > > >(new lua_object< std::vector < target > >());
|
||||
config c(cfg_.child_or_empty("args"));
|
||||
handler_->handle(c, true, l_obj);
|
||||
try {
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "ai/game_info.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
@ -65,7 +64,7 @@ public:
|
|||
|
||||
|
||||
virtual void on_create();
|
||||
virtual void on_create(boost::shared_ptr<ai::lua_ai_context>);
|
||||
virtual void on_create(std::shared_ptr<ai::lua_ai_context>);
|
||||
|
||||
|
||||
bool active() const;
|
||||
|
@ -120,7 +119,7 @@ private:
|
|||
{
|
||||
return value_;
|
||||
}
|
||||
boost::shared_ptr<terrain_filter> filter_ptr_;
|
||||
std::shared_ptr<terrain_filter> filter_ptr_;
|
||||
double value_;
|
||||
};
|
||||
|
||||
|
@ -142,7 +141,7 @@ private:
|
|||
return value_;
|
||||
}
|
||||
|
||||
boost::shared_ptr<terrain_filter> filter_ptr_;
|
||||
std::shared_ptr<terrain_filter> filter_ptr_;
|
||||
bool protect_unit_;
|
||||
int radius_;
|
||||
double value_;
|
||||
|
@ -170,18 +169,18 @@ class lua_goal : public goal {
|
|||
public:
|
||||
lua_goal(readonly_context& context, const config& cfg);
|
||||
virtual void add_targets(std::back_insert_iterator< std::vector< target > > target_list);
|
||||
void on_create(boost::shared_ptr<ai::lua_ai_context>);
|
||||
void on_create(std::shared_ptr<ai::lua_ai_context>);
|
||||
|
||||
private:
|
||||
std::string code_;
|
||||
boost::shared_ptr<lua_ai_action_handler> handler_;
|
||||
std::shared_ptr<lua_ai_action_handler> handler_;
|
||||
};
|
||||
|
||||
|
||||
class goal_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< goal_factory > factory_ptr;
|
||||
typedef std::shared_ptr< goal_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "config.hpp"
|
||||
#include "ai/composite/component.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ai{
|
||||
|
||||
template<typename T>
|
||||
|
@ -68,13 +70,13 @@ public:
|
|||
virtual std::vector< component* > handle_get_children() = 0;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr< base_property_handler > property_handler_ptr;
|
||||
typedef std::shared_ptr< base_property_handler > property_handler_ptr;
|
||||
|
||||
template<typename T>
|
||||
class vector_property_handler : public base_property_handler {
|
||||
public:
|
||||
typedef boost::shared_ptr<T> t_ptr;
|
||||
typedef std::vector< boost::shared_ptr<T> > t_ptr_vector;
|
||||
typedef std::shared_ptr<T> t_ptr;
|
||||
typedef std::vector< std::shared_ptr<T> > t_ptr_vector;
|
||||
|
||||
vector_property_handler(const std::string &property, t_ptr_vector &values, std::function<void(t_ptr_vector&, const config&)> &construction_factory)
|
||||
: factory_(construction_factory), property_(property), values_(values){}
|
||||
|
@ -218,7 +220,7 @@ private:
|
|||
template<typename T>
|
||||
class aspect_property_handler : public base_property_handler {
|
||||
public:
|
||||
typedef boost::shared_ptr<T> t_ptr;
|
||||
typedef std::shared_ptr<T> t_ptr;
|
||||
typedef std::map< std::string, t_ptr > aspect_map;
|
||||
|
||||
aspect_property_handler(const std::string &property, aspect_map &aspects, std::function<void(aspect_map&, const config&, std::string)> &construction_factory)
|
||||
|
@ -288,21 +290,21 @@ private:
|
|||
|
||||
|
||||
template<typename X>
|
||||
static void register_vector_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::vector< boost::shared_ptr<X> > &values, std::function<void(std::vector< boost::shared_ptr<X> >&, const config&)> construction_factory)
|
||||
static void register_vector_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::vector< std::shared_ptr<X> > &values, std::function<void(std::vector< std::shared_ptr<X> >&, const config&)> construction_factory)
|
||||
{
|
||||
property_handler_ptr handler_ptr = property_handler_ptr(new vector_property_handler<X>(property,values,construction_factory));
|
||||
property_handlers.insert(std::make_pair(property,handler_ptr));
|
||||
}
|
||||
|
||||
template<typename X>
|
||||
static void register_facets_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::vector< boost::shared_ptr<X> > &values, boost::shared_ptr<X>& def, std::function<void(std::vector< boost::shared_ptr<X> >&, const config&)> construction_factory)
|
||||
static void register_facets_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::vector< std::shared_ptr<X> > &values, std::shared_ptr<X>& def, std::function<void(std::vector< std::shared_ptr<X> >&, const config&)> construction_factory)
|
||||
{
|
||||
property_handler_ptr handler_ptr = property_handler_ptr(new facets_property_handler<X>(property,values,def,construction_factory));
|
||||
property_handlers.insert(std::make_pair(property,handler_ptr));
|
||||
}
|
||||
|
||||
template<typename X>
|
||||
static void register_aspect_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::map< std::string, boost::shared_ptr<X> > &aspects, std::function<void(std::map< std::string, boost::shared_ptr<X> >&, const config&, std::string)> construction_factory)
|
||||
static void register_aspect_property(std::map<std::string,property_handler_ptr> &property_handlers, const std::string &property, std::map< std::string, std::shared_ptr<X> > &aspects, std::function<void(std::map< std::string, std::shared_ptr<X> >&, const config&, std::string)> construction_factory)
|
||||
{
|
||||
property_handler_ptr handler_ptr = property_handler_ptr(new aspect_property_handler<X>(property,aspects,construction_factory));
|
||||
property_handlers.insert(std::make_pair(property,handler_ptr));
|
||||
|
|
|
@ -145,14 +145,14 @@ private:
|
|||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<candidate_action> candidate_action_ptr;
|
||||
typedef std::shared_ptr<candidate_action> candidate_action_ptr;
|
||||
|
||||
class candidate_action_factory;
|
||||
|
||||
class candidate_action_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< candidate_action_factory > factory_ptr;
|
||||
typedef std::shared_ptr< candidate_action_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
class stage_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< stage_factory > factory_ptr;
|
||||
typedef std::shared_ptr< stage_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
#include "formula/variant.hpp" // for variant
|
||||
|
||||
#include <algorithm> // for find, count, max, fill_n
|
||||
#include <boost/smart_ptr/intrusive_ptr.hpp> // for intrusive_ptr
|
||||
#include <boost/smart_ptr/shared_ptr.hpp> // for dynamic_pointer_cast, etc
|
||||
#include <cmath> // for sqrt
|
||||
#include <cstdlib> // for abs
|
||||
#include <ctime> // for time
|
||||
|
@ -179,9 +177,9 @@ synced_command_result_ptr readonly_context_impl::check_synced_command_action(con
|
|||
|
||||
|
||||
template<typename T>
|
||||
void readonly_context_impl::add_known_aspect(const std::string &name, boost::shared_ptr< typesafe_aspect <T> > &where)
|
||||
void readonly_context_impl::add_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect <T> > &where)
|
||||
{
|
||||
boost::shared_ptr< typesafe_known_aspect <T> > ka_ptr(new typesafe_known_aspect<T>(name,where,aspects_));
|
||||
std::shared_ptr< typesafe_known_aspect <T> > ka_ptr(new typesafe_known_aspect<T>(name,where,aspects_));
|
||||
known_aspects_.insert(make_pair(name,ka_ptr));
|
||||
}
|
||||
|
||||
|
|
|
@ -1498,7 +1498,7 @@ public:
|
|||
|
||||
private:
|
||||
template<typename T>
|
||||
void add_known_aspect(const std::string &name, boost::shared_ptr< typesafe_aspect <T> >& where);
|
||||
void add_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect <T> >& where);
|
||||
|
||||
const config cfg_;
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ void aspect_attacks_base::recalculate() const
|
|||
this->valid_ = true;
|
||||
}
|
||||
|
||||
boost::shared_ptr<attacks_vector> aspect_attacks_base::analyze_targets() const
|
||||
std::shared_ptr<attacks_vector> aspect_attacks_base::analyze_targets() const
|
||||
{
|
||||
const move_map& srcdst = get_srcdst();
|
||||
const move_map& dstsrc = get_dstsrc();
|
||||
const move_map& enemy_srcdst = get_enemy_srcdst();
|
||||
const move_map& enemy_dstsrc = get_enemy_dstsrc();
|
||||
|
||||
boost::shared_ptr<attacks_vector> res(new attacks_vector());
|
||||
std::shared_ptr<attacks_vector> res(new attacks_vector());
|
||||
unit_map& units_ = *resources::units;
|
||||
|
||||
std::vector<map_location> unit_locs;
|
||||
|
@ -428,7 +428,7 @@ bool aspect_attacks::is_allowed_enemy(const unit& u) const
|
|||
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
aspect_attacks_lua::aspect_attacks_lua(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx)
|
||||
aspect_attacks_lua::aspect_attacks_lua(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr<lua_ai_context>& l_ctx)
|
||||
: aspect_attacks_base(context, cfg, id)
|
||||
, handler_(), code_(), params_(cfg.child_or_empty("args"))
|
||||
{
|
||||
|
@ -446,7 +446,7 @@ aspect_attacks_lua::aspect_attacks_lua(readonly_context &context, const config &
|
|||
// error
|
||||
return;
|
||||
}
|
||||
handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(), *l_ctx));
|
||||
}
|
||||
|
||||
void aspect_attacks_lua::recalculate() const
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<attacks_vector> analyze_targets() const;
|
||||
std::shared_ptr<attacks_vector> analyze_targets() const;
|
||||
|
||||
void do_attack_analysis(const map_location& loc,
|
||||
const move_map& srcdst, const move_map& dstsrc,
|
||||
|
@ -73,20 +73,20 @@ public:
|
|||
virtual bool is_allowed_enemy(const unit& u) const;
|
||||
virtual config to_config() const;
|
||||
private:
|
||||
boost::shared_ptr<unit_filter> filter_own_, filter_enemy_;
|
||||
std::shared_ptr<unit_filter> filter_own_, filter_enemy_;
|
||||
};
|
||||
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
struct aspect_attacks_lua_filter {
|
||||
lua_State* lua;
|
||||
boost::shared_ptr<unit_filter> filter_own_, filter_enemy_;
|
||||
std::shared_ptr<unit_filter> filter_own_, filter_enemy_;
|
||||
int ref_own_, ref_enemy_;
|
||||
};
|
||||
|
||||
class aspect_attacks_lua : public ai_default_rca::aspect_attacks_base {
|
||||
public:
|
||||
aspect_attacks_lua(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx);
|
||||
aspect_attacks_lua(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr<lua_ai_context>& l_ctx);
|
||||
virtual ~aspect_attacks_lua() {}
|
||||
|
||||
virtual bool is_allowed_attacker(const unit& u) const;
|
||||
|
@ -94,8 +94,8 @@ public:
|
|||
virtual config to_config() const;
|
||||
virtual void recalculate() const;
|
||||
private:
|
||||
boost::shared_ptr<lua_ai_action_handler> handler_;
|
||||
mutable boost::shared_ptr<lua_object<aspect_attacks_lua_filter> > obj_;
|
||||
std::shared_ptr<lua_ai_action_handler> handler_;
|
||||
mutable std::shared_ptr<lua_object<aspect_attacks_lua_filter> > obj_;
|
||||
std::string code_;
|
||||
const config params_;
|
||||
};
|
||||
|
|
|
@ -25,10 +25,6 @@
|
|||
#include "utils/make_enum.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1600
|
||||
// SDL2 uses [dfi]vec.h which used to define EXPLICIT
|
||||
#undef EXPLICIT
|
||||
#endif
|
||||
#pragma warning(push)
|
||||
//silence "inherits via dominance" warnings
|
||||
#pragma warning(disable:4250)
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "wml_exception.hpp"
|
||||
#include "config_assign.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <cmath>
|
||||
|
||||
static lg::log_domain log_ai_recruitment("ai/recruitment");
|
||||
|
@ -1122,17 +1121,17 @@ void recruitment::simulate_attack(
|
|||
const std::vector<attack_type> attacker_weapons = attacker->attacks();
|
||||
const std::vector<attack_type> defender_weapons = defender->attacks();
|
||||
|
||||
boost::shared_ptr<attack_simulation> best_att_attack;
|
||||
std::shared_ptr<attack_simulation> best_att_attack;
|
||||
|
||||
// Let attacker choose weapon
|
||||
for (const attack_type& att_weapon : attacker_weapons) {
|
||||
boost::shared_ptr<attack_simulation> best_def_response;
|
||||
std::shared_ptr<attack_simulation> best_def_response;
|
||||
// Let defender choose weapon
|
||||
for (const attack_type& def_weapon : defender_weapons) {
|
||||
if (att_weapon.range() != def_weapon.range()) {
|
||||
continue;
|
||||
}
|
||||
boost::shared_ptr<attack_simulation> simulation(new attack_simulation(
|
||||
std::shared_ptr<attack_simulation> simulation(new attack_simulation(
|
||||
attacker, defender,
|
||||
attacker_defense, defender_defense,
|
||||
&att_weapon, &def_weapon, average_lawful_bonus_));
|
||||
|
@ -1802,9 +1801,9 @@ recruitment_aspect::recruitment_aspect(readonly_context &context, const config &
|
|||
for (config lim : parsed_cfg.child_range("limit")) {
|
||||
create_limit(limits_, lim);
|
||||
}
|
||||
std::function<void(std::vector<boost::shared_ptr<recruit_job> >&, const config&)> factory_jobs =
|
||||
std::function<void(std::vector<std::shared_ptr<recruit_job> >&, const config&)> factory_jobs =
|
||||
std::bind(&recruitment_aspect::create_job,*this,_1,_2);
|
||||
std::function<void(std::vector<boost::shared_ptr<recruit_limit> >&, const config&)> factory_limits =
|
||||
std::function<void(std::vector<std::shared_ptr<recruit_limit> >&, const config&)> factory_limits =
|
||||
std::bind(&recruitment_aspect::create_limit,*this,_1,_2);
|
||||
register_vector_property(property_handlers(), "recruit", jobs_, factory_jobs);
|
||||
register_vector_property(property_handlers(), "limit", limits_, factory_limits);
|
||||
|
@ -1812,18 +1811,18 @@ recruitment_aspect::recruitment_aspect(readonly_context &context, const config &
|
|||
|
||||
void recruitment_aspect::recalculate() const {
|
||||
config cfg;
|
||||
for (const boost::shared_ptr<recruit_job>& job : jobs_) {
|
||||
for (const std::shared_ptr<recruit_job>& job : jobs_) {
|
||||
cfg.add_child("recruit", job->to_config());
|
||||
}
|
||||
for (const boost::shared_ptr<recruit_limit>& lim : limits_) {
|
||||
for (const std::shared_ptr<recruit_limit>& lim : limits_) {
|
||||
cfg.add_child("limit", lim->to_config());
|
||||
}
|
||||
*this->value_ = cfg;
|
||||
this->valid_ = true;
|
||||
}
|
||||
|
||||
void recruitment_aspect::create_job(std::vector<boost::shared_ptr<recruit_job> > &jobs, const config &job) {
|
||||
boost::shared_ptr<recruit_job> job_ptr(new recruit_job(
|
||||
void recruitment_aspect::create_job(std::vector<std::shared_ptr<recruit_job> > &jobs, const config &job) {
|
||||
std::shared_ptr<recruit_job> job_ptr(new recruit_job(
|
||||
utils::split(job["type"]),
|
||||
job["leader_id"], job["id"],
|
||||
job["number"].to_int(-1), job["importance"].to_int(1),
|
||||
|
@ -1834,8 +1833,8 @@ void recruitment_aspect::create_job(std::vector<boost::shared_ptr<recruit_job> >
|
|||
jobs.push_back(job_ptr);
|
||||
}
|
||||
|
||||
void recruitment_aspect::create_limit(std::vector<boost::shared_ptr<recruit_limit> > &limits, const config &lim) {
|
||||
boost::shared_ptr<recruit_limit> lim_ptr(new recruit_limit(
|
||||
void recruitment_aspect::create_limit(std::vector<std::shared_ptr<recruit_limit> > &limits, const config &lim) {
|
||||
std::shared_ptr<recruit_limit> lim_ptr(new recruit_limit(
|
||||
utils::split(lim["type"]),
|
||||
lim["id"],
|
||||
lim["max"].to_int(0)
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "units/unit.hpp"
|
||||
#include "units/map.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -172,13 +171,13 @@ struct recruit_limit : public component {
|
|||
};
|
||||
|
||||
class recruitment_aspect : public standard_aspect<config> {
|
||||
std::vector<boost::shared_ptr<recruit_job> > jobs_;
|
||||
std::vector<boost::shared_ptr<recruit_limit> > limits_;
|
||||
std::vector<std::shared_ptr<recruit_job> > jobs_;
|
||||
std::vector<std::shared_ptr<recruit_limit> > limits_;
|
||||
public:
|
||||
recruitment_aspect(readonly_context &context, const config &cfg, const std::string &id);
|
||||
void recalculate() const;
|
||||
void create_job(std::vector<boost::shared_ptr<recruit_job> > &jobs, const config &job);
|
||||
void create_limit(std::vector<boost::shared_ptr<recruit_limit> > &limits, const config &lim);
|
||||
void create_job(std::vector<std::shared_ptr<recruit_job> > &jobs, const config &job);
|
||||
void create_limit(std::vector<std::shared_ptr<recruit_limit> > &limits, const config &lim);
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::set<cached_combat_value> > table_row;
|
||||
|
|
|
@ -54,9 +54,6 @@
|
|||
#include "ai/game_info.hpp" // for move_result_ptr, move_map, etc
|
||||
#include "candidates.hpp" // for base_candidate_action, etc
|
||||
|
||||
#include <boost/intrusive_ptr.hpp> // for intrusive_ptr
|
||||
#include <boost/lexical_cast.hpp> // for lexical_cast
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||
#include <cassert> // for assert
|
||||
#include <ctime> // for time
|
||||
#include <map> // for multimap<>::const_iterator, etc
|
||||
|
@ -114,7 +111,6 @@ formula_ai::formula_ai(readonly_context &context, const config &cfg)
|
|||
vars_(),
|
||||
function_table_(*this)
|
||||
{
|
||||
add_ref();
|
||||
init_readonly_context_proxy(context);
|
||||
LOG_AI << "creating new formula ai"<< std::endl;
|
||||
}
|
||||
|
@ -169,7 +165,6 @@ std::string formula_ai::evaluate(const std::string& formula_str)
|
|||
game_logic::formula f(formula_str, &function_table_);
|
||||
|
||||
game_logic::map_formula_callable callable(this);
|
||||
callable.add_ref();
|
||||
|
||||
//formula_debugger fdb;
|
||||
const variant v = f.evaluate(callable,nullptr);
|
||||
|
@ -533,7 +528,6 @@ variant formula_ai::execute_variant(const variant& var, ai_context &ai_, bool co
|
|||
*/
|
||||
|
||||
game_logic::map_formula_callable callable(this);
|
||||
callable.add_ref();
|
||||
|
||||
if(error != variant())
|
||||
callable.add("error", error);
|
||||
|
@ -936,7 +930,6 @@ bool formula_ai::can_reach_unit(map_location unit_A, map_location unit_B) const
|
|||
|
||||
void formula_ai::on_create(){
|
||||
//make sure we don't run out of refcount
|
||||
vars_.add_ref();
|
||||
|
||||
for(const config &func : cfg_.child_range("function"))
|
||||
{
|
||||
|
@ -980,7 +973,6 @@ void formula_ai::evaluate_candidate_action(ca_ptr fai_ca)
|
|||
bool formula_ai::execute_candidate_action(ca_ptr fai_ca)
|
||||
{
|
||||
game_logic::map_formula_callable callable(this);
|
||||
callable.add_ref();
|
||||
fai_ca->update_callable_map( callable );
|
||||
const_formula_ptr move_formula(fai_ca->get_action());
|
||||
return !make_action(move_formula, callable).is_empty();
|
||||
|
|
|
@ -77,7 +77,6 @@ candidate_action_with_filters::candidate_action_with_filters(
|
|||
variant candidate_action_with_filters::do_filtering(ai::formula_ai* ai, variant& input, game_logic::const_formula_ptr formula)
|
||||
{
|
||||
game_logic::map_formula_callable callable(static_cast<const formula_callable*>(ai));
|
||||
callable.add_ref();
|
||||
callable.add("input", input);
|
||||
|
||||
return formula::evaluate(formula, callable);
|
||||
|
@ -123,7 +122,6 @@ void move_candidate_action::evaluate(ai::formula_ai* ai, unit_map& units)
|
|||
for(variant_iterator i = filtered_units.begin() ; i != filtered_units.end() ; ++i)
|
||||
{
|
||||
game_logic::map_formula_callable callable(static_cast<const formula_callable*>(ai));
|
||||
callable.add_ref();
|
||||
callable.add("me", *i);
|
||||
|
||||
int res = execute_formula(eval_, callable, ai);
|
||||
|
@ -227,7 +225,6 @@ void attack_candidate_action::evaluate(ai::formula_ai* ai, unit_map& units)
|
|||
if( ai->can_reach_unit( my_unit_callalbe->get_location(), enemy_units_flt[enemy_unit]->get_location() )) {
|
||||
|
||||
game_logic::map_formula_callable callable(static_cast<const formula_callable*>(ai));
|
||||
callable.add_ref();
|
||||
callable.add("me", filtered_my_units[my_unit]);
|
||||
callable.add("target", filtered_enemy_units[enemy_unit]);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace game_logic {
|
|||
class base_candidate_action;
|
||||
|
||||
typedef std::map< std::string, game_logic::const_formula_ptr > candidate_action_filters;
|
||||
typedef boost::shared_ptr<game_logic::base_candidate_action> candidate_action_ptr;
|
||||
typedef std::shared_ptr<game_logic::base_candidate_action> candidate_action_ptr;
|
||||
|
||||
//every new candidate action type should be derived from this class
|
||||
//and should complete evaluate and update_callable_map methods
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
virtual void set_ai_context(ai_context *context);
|
||||
private:
|
||||
boost::shared_ptr<formula_ai> formula_ai_;
|
||||
std::shared_ptr<formula_ai> formula_ai_;
|
||||
};
|
||||
|
||||
} //end of namespace ai
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "formula/formula.hpp"
|
||||
#include "formula/function.hpp"
|
||||
#include "log.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
static lg::log_domain log_ai("ai/stage/side_formulas");
|
||||
#define LOG_AI LOG_STREAM(info, log_ai)
|
||||
|
@ -47,7 +46,6 @@ stage_side_formulas::~stage_side_formulas()
|
|||
bool stage_side_formulas::do_play_stage()
|
||||
{
|
||||
game_logic::map_formula_callable callable(&fai_);
|
||||
callable.add_ref();
|
||||
try {
|
||||
if (move_formula_) {
|
||||
while( !fai_.make_action(move_formula_,callable).is_empty() ) { }
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "resources.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "units/formula_manager.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
static lg::log_domain log_formula_ai("ai/stage/unit_formulas");
|
||||
#define LOG_AI LOG_STREAM(info, log_formula_ai)
|
||||
|
@ -67,7 +66,6 @@ bool stage_unit_formulas::do_play_stage()
|
|||
game_logic::const_formula_ptr priority_formula(fai_.create_optional_formula(i->formula_manager().get_priority_formula()));
|
||||
if (priority_formula) {
|
||||
game_logic::map_formula_callable callable(&fai_);
|
||||
callable.add_ref();
|
||||
callable.add("me", variant(new unit_callable(*i)));
|
||||
priority = (game_logic::formula::evaluate(priority_formula, callable)).as_int();
|
||||
} else {
|
||||
|
@ -101,7 +99,6 @@ bool stage_unit_formulas::do_play_stage()
|
|||
game_logic::const_formula_ptr formula(fai_.create_optional_formula(i->formula_manager().get_formula()));
|
||||
if (formula) {
|
||||
game_logic::map_formula_callable callable(&fai_);
|
||||
callable.add_ref();
|
||||
callable.add("me", variant(new unit_callable(*i)));
|
||||
fai_.make_action(formula, callable);
|
||||
} else {
|
||||
|
@ -124,7 +121,6 @@ bool stage_unit_formulas::do_play_stage()
|
|||
game_logic::const_formula_ptr loop_formula(fai_.create_optional_formula(i->formula_manager().get_loop_formula()));
|
||||
if (loop_formula) {
|
||||
game_logic::map_formula_callable callable(&fai_);
|
||||
callable.add_ref();
|
||||
callable.add("me", variant(new unit_callable(*i)));
|
||||
while ( !fai_.make_action(loop_formula, callable).is_empty() && i.valid() )
|
||||
{
|
||||
|
|
|
@ -20,13 +20,12 @@
|
|||
#ifndef AI_GAME_INFO_HPP_INCLUDED
|
||||
#define AI_GAME_INFO_HPP_INCLUDED
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "map/location.hpp"
|
||||
namespace pathfind {
|
||||
struct paths;
|
||||
}
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
class game_display;
|
||||
class gamemap;
|
||||
|
@ -51,7 +50,7 @@ typedef std::map<map_location,pathfind::paths> moves_map;
|
|||
|
||||
class ai_composite;
|
||||
|
||||
typedef boost::shared_ptr<ai_composite> ai_ptr;
|
||||
typedef std::shared_ptr<ai_composite> ai_ptr;
|
||||
|
||||
class attack_analysis;
|
||||
typedef std::vector<attack_analysis> attacks_vector;
|
||||
|
@ -73,8 +72,8 @@ class typesafe_aspect;
|
|||
|
||||
template<typename T>
|
||||
struct aspect_type {
|
||||
typedef boost::shared_ptr< typesafe_aspect<T> > typesafe_ptr;
|
||||
typedef std::vector< boost::shared_ptr< typesafe_aspect<T> > > typesafe_ptr_vector;
|
||||
typedef std::shared_ptr< typesafe_aspect<T> > typesafe_ptr;
|
||||
typedef std::vector< std::shared_ptr< typesafe_aspect<T> > > typesafe_ptr_vector;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -82,8 +81,8 @@ class typesafe_known_aspect;
|
|||
|
||||
template<typename T>
|
||||
struct known_aspect_type {
|
||||
typedef boost::shared_ptr< typesafe_known_aspect<T> > typesafe_ptr;
|
||||
typedef std::vector< boost::shared_ptr< typesafe_known_aspect<T> > > typesafe_ptr_vector;
|
||||
typedef std::shared_ptr< typesafe_known_aspect<T> > typesafe_ptr;
|
||||
typedef std::vector< std::shared_ptr< typesafe_known_aspect<T> > > typesafe_ptr_vector;
|
||||
};
|
||||
|
||||
class action_result;
|
||||
|
@ -95,21 +94,21 @@ class move_and_attack_result;
|
|||
class stopunit_result;
|
||||
class synced_command_result;
|
||||
|
||||
typedef boost::shared_ptr<action_result> action_result_ptr;
|
||||
typedef boost::shared_ptr<attack_result> attack_result_ptr;
|
||||
typedef boost::shared_ptr<recall_result> recall_result_ptr;
|
||||
typedef boost::shared_ptr<recruit_result> recruit_result_ptr;
|
||||
typedef boost::shared_ptr<move_result> move_result_ptr;
|
||||
typedef boost::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
|
||||
typedef boost::shared_ptr<stopunit_result> stopunit_result_ptr;
|
||||
typedef boost::shared_ptr<synced_command_result> synced_command_result_ptr;
|
||||
typedef std::shared_ptr<action_result> action_result_ptr;
|
||||
typedef std::shared_ptr<attack_result> attack_result_ptr;
|
||||
typedef std::shared_ptr<recall_result> recall_result_ptr;
|
||||
typedef std::shared_ptr<recruit_result> recruit_result_ptr;
|
||||
typedef std::shared_ptr<move_result> move_result_ptr;
|
||||
typedef std::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
|
||||
typedef std::shared_ptr<stopunit_result> stopunit_result_ptr;
|
||||
typedef std::shared_ptr<synced_command_result> synced_command_result_ptr;
|
||||
|
||||
typedef boost::shared_ptr< aspect > aspect_ptr;
|
||||
typedef boost::shared_ptr< candidate_action > candidate_action_ptr;
|
||||
typedef boost::shared_ptr< engine > engine_ptr;
|
||||
typedef boost::shared_ptr< goal > goal_ptr;
|
||||
typedef boost::shared_ptr< known_aspect > known_aspect_ptr;
|
||||
typedef boost::shared_ptr< stage > stage_ptr;
|
||||
typedef std::shared_ptr< aspect > aspect_ptr;
|
||||
typedef std::shared_ptr< candidate_action > candidate_action_ptr;
|
||||
typedef std::shared_ptr< engine > engine_ptr;
|
||||
typedef std::shared_ptr< goal > goal_ptr;
|
||||
typedef std::shared_ptr< known_aspect > known_aspect_ptr;
|
||||
typedef std::shared_ptr< stage > stage_ptr;
|
||||
|
||||
typedef std::map<std::string, aspect_ptr > aspect_map;
|
||||
typedef std::map<std::string, known_aspect_ptr > known_aspect_map;
|
||||
|
|
|
@ -136,16 +136,6 @@ void lua_ai_context::push_ai_table()
|
|||
lua_ai_load ctx(*this, false);
|
||||
}
|
||||
|
||||
static void push_location_key(lua_State* L, const map_location& loc)
|
||||
{
|
||||
// This should be factored out. The same function is defined in data/lua/location_set.lua
|
||||
// At this point, it is not clear, where this(hashing) function can be placed
|
||||
// Implemented it this way, to test the new version of the data structure
|
||||
// as requested from the users of LuaAI <Nephro>
|
||||
int hashed_index = (loc.x + 1) * 16384 + (loc.y + 1) + 2000;
|
||||
lua_pushinteger(L, hashed_index);
|
||||
}
|
||||
|
||||
static int transform_ai_action(lua_State *L, ai::action_result_ptr action_result)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
@ -679,12 +669,12 @@ static void push_move_map(lua_State *L, const move_map& m)
|
|||
|
||||
int index = 1;
|
||||
|
||||
|
||||
std::hash<map_location> lhash;
|
||||
|
||||
do
|
||||
{
|
||||
map_location key = it->first;
|
||||
push_location_key(L, key);
|
||||
lua_pushinteger(L, lhash(key));
|
||||
|
||||
lua_createtable(L, 0, 0);
|
||||
|
||||
|
@ -780,7 +770,7 @@ static int cfun_ai_recalculate_move_maps_enemy(lua_State *L)
|
|||
template<typename T>
|
||||
typesafe_aspect<T>* try_aspect_as(aspect_ptr p)
|
||||
{
|
||||
return boost::dynamic_pointer_cast<typesafe_aspect<T> >(p).get();
|
||||
return std::dynamic_pointer_cast<typesafe_aspect<T> >(p).get();
|
||||
}
|
||||
|
||||
static int impl_ai_aspect_get(lua_State* L)
|
||||
|
@ -822,11 +812,12 @@ static int impl_ai_aspect_get(lua_State* L)
|
|||
const unit_advancements_aspect& val = aspect->get();
|
||||
int my_side = luaW_getglobal(L, "ai", "side") - 1;
|
||||
lua_newtable(L);
|
||||
std::hash<map_location> lhash;
|
||||
for (unit_map::const_iterator u = resources::units->begin(); u != resources::units->end(); ++u) {
|
||||
if (!u.valid() || u->side() != my_side) {
|
||||
continue;
|
||||
}
|
||||
push_location_key(L, u->get_location());
|
||||
lua_pushinteger(L, lhash(u->get_location()));
|
||||
lua_push(L, val.get_advancements(u));
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
|
|
@ -15,19 +15,17 @@
|
|||
#ifndef AI_LUA_CORE_HPP
|
||||
#define AI_LUA_CORE_HPP
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
struct lua_State;
|
||||
class game_lua_kernel;
|
||||
class config;
|
||||
|
||||
|
||||
|
||||
namespace ai {
|
||||
|
||||
class engine_lua;
|
||||
class lua_object_base;
|
||||
typedef boost::shared_ptr<lua_object_base> lua_object_ptr;
|
||||
typedef std::shared_ptr<lua_object_base> lua_object_ptr;
|
||||
|
||||
/**
|
||||
* Proxy table for the AI context
|
||||
|
|
|
@ -50,7 +50,7 @@ static lg::log_domain log_ai_engine_lua("ai/engine/lua");
|
|||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
typedef boost::shared_ptr< lua_object<int> > lua_int_obj;
|
||||
typedef std::shared_ptr< lua_object<int> > lua_int_obj;
|
||||
|
||||
class lua_candidate_action_wrapper_base : public candidate_action {
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
boost::shared_ptr<int> result = l_obj->get();
|
||||
std::shared_ptr<int> result = l_obj->get();
|
||||
|
||||
return result ? *result : 0.0;
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<lua_ai_action_handler> evaluation_action_handler_;
|
||||
boost::shared_ptr<lua_ai_action_handler> execution_action_handler_;
|
||||
std::shared_ptr<lua_ai_action_handler> evaluation_action_handler_;
|
||||
std::shared_ptr<lua_ai_action_handler> execution_action_handler_;
|
||||
config serialized_evaluation_state_;
|
||||
};
|
||||
|
||||
|
@ -104,8 +104,8 @@ public:
|
|||
lua_candidate_action_wrapper( rca_context &context, const config &cfg, lua_ai_context &lua_ai_ctx)
|
||||
: lua_candidate_action_wrapper_base(context,cfg),evaluation_(cfg["evaluation"]),execution_(cfg["execution"])
|
||||
{
|
||||
evaluation_action_handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(evaluation_.c_str(),lua_ai_ctx));
|
||||
execution_action_handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(execution_.c_str(),lua_ai_ctx));
|
||||
evaluation_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(evaluation_.c_str(),lua_ai_ctx));
|
||||
execution_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(execution_.c_str(),lua_ai_ctx));
|
||||
}
|
||||
|
||||
virtual ~lua_candidate_action_wrapper() {}
|
||||
|
@ -137,8 +137,8 @@ public:
|
|||
std::string exec_code;
|
||||
generate_code(eval_code, exec_code);
|
||||
|
||||
evaluation_action_handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(eval_code.c_str(),lua_ai_ctx));
|
||||
execution_action_handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(exec_code.c_str(),lua_ai_ctx));
|
||||
evaluation_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(eval_code.c_str(),lua_ai_ctx));
|
||||
execution_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(exec_code.c_str(),lua_ai_ctx));
|
||||
}
|
||||
|
||||
virtual ~lua_candidate_action_wrapper_external() {}
|
||||
|
@ -211,7 +211,7 @@ public:
|
|||
lua_stage_wrapper( ai_context &context, const config &cfg, lua_ai_context &lua_ai_ctx )
|
||||
: stage(context,cfg),action_handler_(),code_(cfg["code"]),serialized_evaluation_state_(cfg.child_or_empty("args"))
|
||||
{
|
||||
action_handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(),lua_ai_ctx));
|
||||
action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(code_.c_str(),lua_ai_ctx));
|
||||
}
|
||||
|
||||
virtual ~lua_stage_wrapper()
|
||||
|
@ -238,7 +238,7 @@ public:
|
|||
return cfg;
|
||||
}
|
||||
private:
|
||||
boost::shared_ptr<lua_ai_action_handler> action_handler_;
|
||||
std::shared_ptr<lua_ai_action_handler> action_handler_;
|
||||
std::string code_;
|
||||
config serialized_evaluation_state_;
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
std::string code_;
|
||||
|
||||
//There is one lua engine per AI. So, it can hold state
|
||||
boost::shared_ptr<lua_ai_context> lua_ai_context_;
|
||||
std::shared_ptr<lua_ai_context> lua_ai_context_;
|
||||
|
||||
std::string get_engine_code(const config&) const;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "scripting/lua_common.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
#include <boost/smart_ptr/make_shared_object.hpp>
|
||||
#include "lua/lauxlib.h"
|
||||
|
||||
namespace ai {
|
||||
|
@ -39,9 +38,9 @@ namespace ai {
|
|||
template class lua_object<aspect_attacks_lua_filter>;
|
||||
|
||||
template <>
|
||||
boost::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n)
|
||||
std::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr<aspect_attacks_lua_filter> att(new aspect_attacks_lua_filter);
|
||||
std::shared_ptr<aspect_attacks_lua_filter> att(new aspect_attacks_lua_filter);
|
||||
att->lua = nullptr;
|
||||
att->ref_own_ = att->ref_enemy_ = -1;
|
||||
if(!lua_istable(L, n)) {
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "ai/default/contexts.hpp"
|
||||
#include "ai/lua/aspect_advancements.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -62,55 +61,55 @@ public:
|
|||
// empty
|
||||
}
|
||||
|
||||
boost::shared_ptr<T> get()
|
||||
std::shared_ptr<T> get()
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
void store(lua_State* L, int n)
|
||||
{
|
||||
this->value_ = boost::shared_ptr<T>(to_type(L, lua_absindex(L, n)));
|
||||
this->value_ = std::shared_ptr<T>(to_type(L, lua_absindex(L, n)));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// A group of functions that deal with the translation of the results to C++
|
||||
boost::shared_ptr<T> to_type(lua_State *, int)
|
||||
std::shared_ptr<T> to_type(lua_State *, int)
|
||||
{
|
||||
return boost::shared_ptr<T>();
|
||||
return std::shared_ptr<T>();
|
||||
}
|
||||
|
||||
boost::shared_ptr<T> value_;
|
||||
std::shared_ptr<T> value_;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<double> lua_object<double>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<double> lua_object<double>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<double>(new double(lua_tonumber(L, n)));
|
||||
return std::shared_ptr<double>(new double(lua_tonumber(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<std::string> lua_object<std::string>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<std::string> lua_object<std::string>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<std::string>(new std::string(lua_tostring(L, n)));
|
||||
return std::shared_ptr<std::string>(new std::string(lua_tostring(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<bool> lua_object<bool>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<bool> lua_object<bool>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<bool>(new bool(luaW_toboolean(L, n)));
|
||||
return std::shared_ptr<bool>(new bool(luaW_toboolean(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<int> lua_object<int>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<int> lua_object<int>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<int>(new int(lua_tointeger(L, n)));
|
||||
return std::shared_ptr<int>(new int(lua_tointeger(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr< std::vector<std::string> > lua_object< std::vector<std::string> >::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr< std::vector<std::string> > lua_object< std::vector<std::string> >::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr< std::vector<std::string> > v = boost::shared_ptr< std::vector<std::string> >(new std::vector<std::string>());
|
||||
std::shared_ptr< std::vector<std::string> > v = std::shared_ptr< std::vector<std::string> >(new std::vector<std::string>());
|
||||
int l = lua_rawlen(L, n);
|
||||
for (int i = 1; i < l + 1; ++i)
|
||||
{
|
||||
|
@ -125,30 +124,30 @@ inline boost::shared_ptr< std::vector<std::string> > lua_object< std::vector<std
|
|||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<config> lua_object<config>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<config> lua_object<config>::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr<config> cfg = boost::shared_ptr<config>(new config());
|
||||
std::shared_ptr<config> cfg = std::shared_ptr<config>(new config());
|
||||
luaW_toconfig(L, n, *cfg);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<terrain_filter> lua_object<terrain_filter>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<terrain_filter> lua_object<terrain_filter>::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr<config> cfg = boost::shared_ptr<config>(new config());
|
||||
boost::shared_ptr<vconfig> vcfg = boost::shared_ptr<vconfig>(new vconfig(*cfg));
|
||||
std::shared_ptr<config> cfg = std::shared_ptr<config>(new config());
|
||||
std::shared_ptr<vconfig> vcfg = std::shared_ptr<vconfig>(new vconfig(*cfg));
|
||||
if (!luaW_tovconfig(L, n, *vcfg)) {
|
||||
cfg->add_child("not");
|
||||
}
|
||||
vcfg->make_safe();
|
||||
boost::shared_ptr<terrain_filter> tf(new terrain_filter(*vcfg, resources::filter_con));
|
||||
std::shared_ptr<terrain_filter> tf(new terrain_filter(*vcfg, resources::filter_con));
|
||||
return tf;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<std::vector<target> > lua_object< std::vector<target> >::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<std::vector<target> > lua_object< std::vector<target> >::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr<std::vector<target> > targets = boost::shared_ptr<std::vector<target> >(new std::vector<target>());
|
||||
std::shared_ptr<std::vector<target> > targets = std::shared_ptr<std::vector<target> >(new std::vector<target>());
|
||||
std::back_insert_iterator< std::vector<target> > tg(*targets);
|
||||
int l = lua_rawlen(L, n);
|
||||
|
||||
|
@ -195,16 +194,16 @@ inline boost::shared_ptr<std::vector<target> > lua_object< std::vector<target> >
|
|||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<unit_advancements_aspect> lua_object<unit_advancements_aspect>::to_type(lua_State *L, int n)
|
||||
inline std::shared_ptr<unit_advancements_aspect> lua_object<unit_advancements_aspect>::to_type(lua_State *L, int n)
|
||||
{
|
||||
boost::shared_ptr<unit_advancements_aspect> uaa = boost::shared_ptr<unit_advancements_aspect>(new unit_advancements_aspect(L, n));
|
||||
std::shared_ptr<unit_advancements_aspect> uaa = std::shared_ptr<unit_advancements_aspect>(new unit_advancements_aspect(L, n));
|
||||
return uaa;
|
||||
}
|
||||
|
||||
// This one is too complex to define in the header.
|
||||
struct aspect_attacks_lua_filter;
|
||||
template <>
|
||||
boost::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n);
|
||||
std::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n);
|
||||
} // end of namespace ai
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ void holder::init( side_number side )
|
|||
default_ai_context_ = new default_ai_context_impl(*readwrite_context_,cfg_);
|
||||
}
|
||||
if (!this->ai_){
|
||||
ai_ = boost::shared_ptr<ai_composite>(new ai_composite(*default_ai_context_,cfg_));
|
||||
ai_ = std::shared_ptr<ai_composite>(new ai_composite(*default_ai_context_,cfg_));
|
||||
}
|
||||
|
||||
if (this->ai_) {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "global.hpp"
|
||||
#include "ai/game_info.hpp" // for side_number, ai_ptr
|
||||
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||
#include <deque> // for deque
|
||||
#include <map> // for map, map<>::value_compare
|
||||
#include <stack> // for stack
|
||||
|
@ -45,7 +44,7 @@ namespace events { class observer; }
|
|||
|
||||
namespace ai {
|
||||
|
||||
typedef boost::shared_ptr<ai_composite> composite_ai_ptr;
|
||||
typedef std::shared_ptr<ai_composite> composite_ai_ptr;
|
||||
|
||||
/**
|
||||
* Base class that holds the AI and current AI parameters.
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "ai/default/ca_move_to_targets.hpp"
|
||||
#include "ai/default/stage_rca.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr, etc
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "server/input_stream.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
namespace campaignd {
|
||||
|
@ -87,7 +86,7 @@ private:
|
|||
bool read_only_;
|
||||
int compress_level_; /**< Used for add-on archives. */
|
||||
|
||||
boost::scoped_ptr<input_stream> input_; /**< Server control socket. */
|
||||
std::unique_ptr<input_stream> input_; /**< Server control socket. */
|
||||
|
||||
std::map<std::string, std::string> hooks_;
|
||||
request_handlers_table handlers_;
|
||||
|
|
|
@ -33,22 +33,22 @@
|
|||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
// this class is needed since boost has some templated operators>> declared internally for tuples and we don't want them to interfere. Existence of such operator>> apparently causes program_options to cause the custom class somehow specially... well, the boost::tuple default operator>> format doesn't suit our needs anyway.
|
||||
class two_strings : public boost::tuple<std::string,std::string> {};
|
||||
class two_strings : public std::pair<std::string,std::string> {};
|
||||
|
||||
static void validate(boost::any& v, const std::vector<std::string>& values,
|
||||
two_strings*, int)
|
||||
{
|
||||
two_strings ret_val;
|
||||
if (values.size() != 2)
|
||||
two_strings ret_val;
|
||||
if (values.size() != 2) {
|
||||
#if BOOST_VERSION >= 104200
|
||||
throw po::validation_error(po::validation_error::invalid_option_value);
|
||||
#else
|
||||
throw po::validation_error("Invalid number of strings provided to option requiring exactly two of them.");
|
||||
#endif
|
||||
ret_val.get<0>() = values.at(0);
|
||||
ret_val.get<1>() = values.at(1);
|
||||
v = ret_val;
|
||||
}
|
||||
ret_val.first = values.at(0);
|
||||
ret_val.second = values.at(1);
|
||||
v = ret_val;
|
||||
}
|
||||
|
||||
bad_commandline_resolution::bad_commandline_resolution(const std::string& resolution)
|
||||
|
@ -403,8 +403,8 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
if (vm.count("preprocess"))
|
||||
{
|
||||
preprocess = true;
|
||||
preprocess_path = vm["preprocess"].as<two_strings>().get<0>();
|
||||
preprocess_target = vm["preprocess"].as<two_strings>().get<1>();
|
||||
preprocess_path = vm["preprocess"].as<two_strings>().first;
|
||||
preprocess_target = vm["preprocess"].as<two_strings>().second;
|
||||
}
|
||||
if (vm.count("preprocess-defines"))
|
||||
preprocess_defines = utils::split(vm["preprocess-defines"].as<std::string>(), ',');
|
||||
|
@ -420,14 +420,14 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
multiplayer_scenario = vm["scenario"].as<std::string>();
|
||||
if (vm.count("render-image"))
|
||||
{
|
||||
render_image = vm["render-image"].as<two_strings>().get<0>();
|
||||
render_image_dst = vm["render-image"].as<two_strings>().get<1>();
|
||||
render_image = vm["render-image"].as<two_strings>().first;
|
||||
render_image_dst = vm["render-image"].as<two_strings>().second;
|
||||
}
|
||||
if (vm.count("screenshot"))
|
||||
{
|
||||
screenshot = true;
|
||||
screenshot_map_file = vm["screenshot"].as<two_strings>().get<0>();
|
||||
screenshot_output_file = vm["screenshot"].as<two_strings>().get<1>();
|
||||
screenshot_map_file = vm["screenshot"].as<two_strings>().first;
|
||||
screenshot_output_file = vm["screenshot"].as<two_strings>().second;
|
||||
}
|
||||
if (vm.count("script"))
|
||||
script_file = vm["script"].as<std::string>();
|
||||
|
@ -484,8 +484,8 @@ void commandline_options::parse_log_domains_(const std::string &domains_string,
|
|||
for (const std::string& domain : domains)
|
||||
{
|
||||
if (!log)
|
||||
log = std::vector<boost::tuple<int, std::string> >();
|
||||
log->push_back(boost::tuple<int, std::string>(severity,domain));
|
||||
log = std::vector<std::pair<int, std::string> >();
|
||||
log->push_back(std::make_pair(severity, domain));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,13 +517,12 @@ void commandline_options::parse_resolution_ ( const std::string& resolution_stri
|
|||
throw bad_commandline_resolution(resolution_string);
|
||||
}
|
||||
|
||||
resolution = boost::tuple<int,int>(xres,yres);
|
||||
resolution = std::make_pair(xres, yres);
|
||||
}
|
||||
|
||||
std::vector<boost::tuple<unsigned int,std::string> > commandline_options::parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator)
|
||||
std::vector<std::pair<unsigned int,std::string> > commandline_options::parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator)
|
||||
{
|
||||
std::vector<boost::tuple<unsigned int,std::string> > vec;
|
||||
boost::tuple<unsigned int,std::string> elem;
|
||||
std::vector<std::pair<unsigned int,std::string> > vec;
|
||||
const std::string& expected_format
|
||||
= std::string() + "UINT" + separator + "STRING";
|
||||
|
||||
|
@ -541,17 +540,15 @@ std::vector<boost::tuple<unsigned int,std::string> > commandline_options::parse_
|
|||
throw bad_commandline_tuple(s, expected_format);
|
||||
}
|
||||
|
||||
elem.get<0>() = temp;
|
||||
elem.get<1>() = tokens[1];
|
||||
vec.push_back(elem);
|
||||
vec.push_back(std::make_pair(temp, tokens[1]));
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector<boost::tuple<unsigned int,std::string,std::string> > commandline_options::parse_to_uint_string_string_tuples_(const std::vector<std::string> &strings, char separator)
|
||||
std::vector<std::tuple<unsigned int,std::string,std::string> > commandline_options::parse_to_uint_string_string_tuples_(const std::vector<std::string> &strings, char separator)
|
||||
{
|
||||
std::vector<boost::tuple<unsigned int,std::string,std::string> > vec;
|
||||
boost::tuple<unsigned int,std::string,std::string> elem;
|
||||
std::vector<std::tuple<unsigned int,std::string,std::string> > vec;
|
||||
std::tuple<unsigned int,std::string,std::string> elem;
|
||||
const std::string& expected_format
|
||||
= std::string() + "UINT" + separator + "STRING" + separator + "STRING";
|
||||
|
||||
|
@ -568,9 +565,9 @@ std::vector<boost::tuple<unsigned int,std::string,std::string> > commandline_opt
|
|||
} catch (bad_lexical_cast &) {
|
||||
throw bad_commandline_tuple(s, expected_format);
|
||||
}
|
||||
elem.get<0>() = temp;
|
||||
elem.get<1>() = tokens[1];
|
||||
elem.get<2>() = tokens[2];
|
||||
std::get<0>(elem) = temp;
|
||||
std::get<1>(elem) = tokens[1];
|
||||
std::get<2>(elem) = tokens[2];
|
||||
vec.push_back(elem);
|
||||
}
|
||||
return vec;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
#include <boost/optional.hpp> // for optional
|
||||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/tuple/tuple.hpp> // for tuple
|
||||
#include <iosfwd> // for ostream
|
||||
#include <string> // for string
|
||||
#include <tuple>
|
||||
#include <vector> // for vector
|
||||
|
||||
class bad_commandline_resolution : public boost::program_options::error
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
boost::optional<std::string> language;
|
||||
/// Contains parsed arguments of --log-* (e.g. --log-debug).
|
||||
/// Vector of pairs (severity, log domain).
|
||||
boost::optional<std::vector<boost::tuple<int, std::string> > > log;
|
||||
boost::optional<std::vector<std::pair<int, std::string> > > log;
|
||||
/// Non-empty if --log-strict was given
|
||||
boost::optional<int> log_strict_level;
|
||||
/// Non-empty if --load was given on the command line. Savegame specified to load after start.
|
||||
|
@ -103,11 +103,11 @@ public:
|
|||
/// True if --multiplayer was given on the command line. Goes directly into multiplayer mode.
|
||||
bool multiplayer;
|
||||
/// Non-empty if --ai-config was given on the command line. Vector of pairs (side number, value). Dependent on --multiplayer.
|
||||
boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_ai_config;
|
||||
boost::optional<std::vector<std::pair<unsigned int, std::string> > > multiplayer_ai_config;
|
||||
/// Non-empty if --algorithm was given on the command line. Vector of pairs (side number, value). Dependent on --multiplayer.
|
||||
boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_algorithm;
|
||||
boost::optional<std::vector<std::pair<unsigned int, std::string> > > multiplayer_algorithm;
|
||||
/// Non-empty if --controller was given on the command line. Vector of pairs (side number, controller). Dependent on --multiplayer.
|
||||
boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_controller;
|
||||
boost::optional<std::vector<std::pair<unsigned int, std::string> > > multiplayer_controller;
|
||||
/// Non-empty if --era was given on the command line. Dependent on --multiplayer.
|
||||
boost::optional<std::string> multiplayer_era;
|
||||
/// True if --exit-at-and was given on the command line. Dependent on --multiplayer.
|
||||
|
@ -117,13 +117,13 @@ public:
|
|||
/// Non-empty if --label was given on the command line. Dependent on --multiplayer.
|
||||
boost::optional<std::string> multiplayer_label;
|
||||
/// Non-empty if --parm was given on the command line. Vector of pairs (side number, parm name, parm value). Dependent on --multiplayer.
|
||||
boost::optional<std::vector<boost::tuple<unsigned int, std::string, std::string> > > multiplayer_parm;
|
||||
boost::optional<std::vector<std::tuple<unsigned int, std::string, std::string> > > multiplayer_parm;
|
||||
/// Repeats specified by --multiplayer-repeat option. Repeats a multiplayer game after it is finished. Dependent on --multiplayer.
|
||||
boost::optional<unsigned int> multiplayer_repeat;
|
||||
/// Non-empty if --scenario was given on the command line. Dependent on --multiplayer.
|
||||
boost::optional<std::string> multiplayer_scenario;
|
||||
/// Non-empty if --side was given on the command line. Vector of pairs (side number, faction id). Dependent on --multiplayer.
|
||||
boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_side;
|
||||
boost::optional<std::vector<std::pair<unsigned int, std::string> > > multiplayer_side;
|
||||
/// Non-empty if --turns was given on the command line. Dependent on --multiplayer.
|
||||
boost::optional<std::string> multiplayer_turns;
|
||||
/// Max FPS specified by --max-fps option.
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
/// Target (output) path that was given to the --preprocess option.
|
||||
boost::optional<std::string> preprocess_target;
|
||||
/// Pair of AxB values specified after --resolution. Changes Wesnoth resolution.
|
||||
boost::optional<boost::tuple<int,int> > resolution;
|
||||
boost::optional<std::pair<int,int> > resolution;
|
||||
/// RNG seed specified by --rng-seed option. Initializes RNG with given seed.
|
||||
boost::optional<unsigned int> rng_seed;
|
||||
/// Non-empty if --server was given on the command line. Connects Wesnoth to specified server. If no server was specified afterwards, contains an empty string.
|
||||
|
@ -217,9 +217,9 @@ private:
|
|||
void parse_log_strictness (const std::string &severity);
|
||||
void parse_resolution_ (const std::string &resolution_string);
|
||||
/// A helper function splitting vector of strings of format unsigned int:string to vector of tuples (unsigned int,string)
|
||||
std::vector<boost::tuple<unsigned int,std::string> > parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
|
||||
std::vector<std::pair<unsigned int,std::string> > parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
|
||||
/// A helper function splitting vector of strings of format unsigned int:string:string to vector of tuples (unsigned int,string,string)
|
||||
std::vector<boost::tuple<unsigned int,std::string,std::string> > parse_to_uint_string_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
|
||||
std::vector<std::tuple<unsigned int,std::string,std::string> > parse_to_uint_string_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
|
||||
std::vector<std::string> args_;
|
||||
std::string args0_;
|
||||
boost::program_options::options_description all_;
|
||||
|
|
|
@ -421,7 +421,7 @@ bool config::attribute_value::equals(const std::string &str) const
|
|||
return *this == v;
|
||||
// if c["a"] = "1" then this solution would have resulted in c["a"] == "1" beeing false
|
||||
// because a["a"] is '1' and not '"1"'.
|
||||
// return boost::apply_visitor(std::bind( equality_visitor(), _1, boost::cref(str) ), value_);
|
||||
// return boost::apply_visitor(std::bind( equality_visitor(), _1, std::cref(str) ), value_);
|
||||
// that's why we don't use it.
|
||||
}
|
||||
|
||||
|
|
|
@ -38,16 +38,12 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "tstring.hpp"
|
||||
#include "utils/iterable_pair.hpp"
|
||||
|
@ -301,7 +297,7 @@ public:
|
|||
attribute_value &operator=(const std::string &v);
|
||||
attribute_value &operator=(const t_string &v);
|
||||
template<typename T>
|
||||
typename boost::enable_if<boost::is_base_of<enum_tag, T>, attribute_value &>::type operator=(const T &v)
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, attribute_value &>::type operator=(const T &v)
|
||||
{
|
||||
return operator=(T::enum_to_string(v));
|
||||
}
|
||||
|
@ -321,7 +317,7 @@ public:
|
|||
TODO: Fix this in c++11 using constexpr types.
|
||||
*/
|
||||
template<typename T>
|
||||
typename boost::enable_if<boost::is_base_of<enum_tag, T>, T>::type to_enum(const T &v) const
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, T>::type to_enum(const T &v) const
|
||||
{
|
||||
return T::string_to_enum(this->str(), v);
|
||||
}
|
||||
|
@ -346,12 +342,12 @@ public:
|
|||
// These function prevent t_string creation in case of c["a"] == "b" comparisons.
|
||||
// The templates are needed to prevent using these function in case of c["a"] == 0 comparisons.
|
||||
template<typename T>
|
||||
typename boost::enable_if<boost::is_same<const std::string, typename boost::add_const<T>::type>, bool>::type
|
||||
typename std::enable_if<std::is_same<const std::string, typename std::add_const<T>::type>::value, bool>::type
|
||||
friend operator==(const attribute_value &val, const T &str)
|
||||
{ return val.equals(str); }
|
||||
|
||||
template<typename T>
|
||||
typename boost::enable_if<boost::is_same<const char*, T>, bool>::type
|
||||
typename std::enable_if<std::is_same<const char*, T>::value, bool>::type
|
||||
friend operator==(const attribute_value &val, T str)
|
||||
{ return val.equals(std::string(str)); }
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#ifndef CONFIG_CACHE_HPP_INCLUDED
|
||||
#define CONFIG_CACHE_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "serialization/preprocessor.hpp"
|
||||
|
||||
|
@ -256,7 +256,7 @@ class fake_transaction : private boost::noncopyable
|
|||
{
|
||||
friend class config_cache;
|
||||
|
||||
typedef boost::scoped_ptr<config_cache_transaction> value_type;
|
||||
typedef std::unique_ptr<config_cache_transaction> value_type;
|
||||
value_type trans_;
|
||||
|
||||
fake_transaction() : trans_()
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
|
@ -34,8 +33,6 @@
|
|||
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
|
||||
using boost::uint32_t;
|
||||
|
||||
static lg::log_domain log_desktop("desktop");
|
||||
#define ERR_DU LOG_STREAM(err, log_desktop)
|
||||
#define LOG_DU LOG_STREAM(info, log_desktop)
|
||||
|
|
|
@ -61,8 +61,6 @@
|
|||
#include "gui/dialogs/network_transmission.hpp"
|
||||
#include "ai/lua/aspect_advancements.hpp"
|
||||
#include "wesnothd_connection.hpp"
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
//#ifdef _WIN32
|
||||
//#include "locale.h"
|
||||
|
@ -91,13 +89,13 @@ namespace
|
|||
class delete_recall_unit : public gui::dialog_button_action
|
||||
{
|
||||
public:
|
||||
delete_recall_unit(display& disp, gui::filter_textbox& filter, const boost::shared_ptr<std::vector<unit_const_ptr > >& units) : disp_(disp), filter_(filter), units_(units) {}
|
||||
delete_recall_unit(display& disp, gui::filter_textbox& filter, const std::shared_ptr<std::vector<unit_const_ptr > >& units) : disp_(disp), filter_(filter), units_(units) {}
|
||||
private:
|
||||
gui::dialog_button_action::RESULT button_pressed(int menu_selection);
|
||||
|
||||
display& disp_;
|
||||
gui::filter_textbox& filter_;
|
||||
boost::shared_ptr<std::vector<unit_const_ptr > > units_;
|
||||
std::shared_ptr<std::vector<unit_const_ptr > > units_;
|
||||
};
|
||||
|
||||
template<typename T> void dump(const T & units)
|
||||
|
@ -177,7 +175,7 @@ int advance_unit_dialog(const map_location &loc)
|
|||
|
||||
std::vector<std::string> lang_options;
|
||||
|
||||
boost::shared_ptr<std::vector<unit_const_ptr> > sample_units(boost::make_shared<std::vector<unit_const_ptr> >());
|
||||
std::shared_ptr<std::vector<unit_const_ptr> > sample_units(std::make_shared<std::vector<unit_const_ptr> >());
|
||||
for(std::vector<std::string>::const_iterator op = options.begin(); op != options.end(); ++op) {
|
||||
sample_units->push_back(::get_advanced_unit(*u, *op));
|
||||
const unit& type = *sample_units->back();
|
||||
|
@ -312,7 +310,7 @@ void show_unit_list(display& gui)
|
|||
items.push_back(heading);
|
||||
|
||||
std::vector<map_location> locations_list;
|
||||
boost::shared_ptr<std::vector<unit_const_ptr> > units_list = boost::make_shared<std::vector<unit_const_ptr> >();
|
||||
std::shared_ptr<std::vector<unit_const_ptr> > units_list = std::make_shared<std::vector<unit_const_ptr> >();
|
||||
|
||||
int selected = 0;
|
||||
|
||||
|
@ -461,9 +459,9 @@ int recruit_dialog(display& disp, std::vector< const unit_type* >& units, const
|
|||
|
||||
|
||||
#ifdef LOW_MEM
|
||||
int recall_dialog(display& disp, const boost::shared_ptr<std::vector< unit_const_ptr > > & units, int /*side*/, const std::string& title_suffix, const int team_recall_cost)
|
||||
int recall_dialog(display& disp, const std::shared_ptr<std::vector< unit_const_ptr > > & units, int /*side*/, const std::string& title_suffix, const int team_recall_cost)
|
||||
#else
|
||||
int recall_dialog(display& disp, const boost::shared_ptr<std::vector< unit_const_ptr > > & units, int side, const std::string& title_suffix, const int team_recall_cost)
|
||||
int recall_dialog(display& disp, const std::shared_ptr<std::vector< unit_const_ptr > > & units, int side, const std::string& title_suffix, const int team_recall_cost)
|
||||
#endif
|
||||
{
|
||||
std::vector<std::string> options, options_to_filter;
|
||||
|
@ -980,11 +978,11 @@ void unit_preview_pane::draw_contents()
|
|||
|
||||
units_list_preview_pane::units_list_preview_pane(unit_const_ptr u, TYPE type, bool on_left_side) :
|
||||
unit_preview_pane(nullptr, type, on_left_side),
|
||||
units_(boost::make_shared<const std::vector<unit_const_ptr> >(1, u))
|
||||
units_(std::make_shared<const std::vector<unit_const_ptr> >(1, u))
|
||||
{
|
||||
}
|
||||
|
||||
units_list_preview_pane::units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > &units,
|
||||
units_list_preview_pane::units_list_preview_pane(const std::shared_ptr<const std::vector<unit_const_ptr > > &units,
|
||||
const gui::filter_textbox* filter, TYPE type, bool on_left_side) :
|
||||
unit_preview_pane(filter, type, on_left_side),
|
||||
units_(units)
|
||||
|
@ -1025,10 +1023,9 @@ const unit_preview_pane::details units_list_preview_pane::get_details() const
|
|||
det.traits = utils::join(u.trait_names(), ", ");
|
||||
|
||||
// The triples are base name, male/female name, description.
|
||||
const std::vector<boost::tuple<t_string,t_string,t_string> > &abilities = u.ability_tooltips();
|
||||
for(std::vector<boost::tuple<t_string,t_string,t_string> >::const_iterator a = abilities.begin();
|
||||
a != abilities.end(); ++a) {
|
||||
det.abilities.push_back(a->get<1>());
|
||||
const std::vector<std::tuple<t_string,t_string,t_string> > &abilities = u.ability_tooltips();
|
||||
for(auto a : abilities) {
|
||||
det.abilities.push_back(std::get<1>(a));
|
||||
}
|
||||
|
||||
det.hitpoints = u.hitpoints();
|
||||
|
|
|
@ -52,7 +52,7 @@ void show_unit_list(display& gui);
|
|||
|
||||
int recruit_dialog(display& disp, std::vector<const unit_type*>& units, const std::vector<std::string>& items, int side, const std::string& title_suffix);
|
||||
|
||||
int recall_dialog(display& disp, const boost::shared_ptr<std::vector<unit_const_ptr > > & units, int side, const std::string& title_suffix, const int team_recall_cost);
|
||||
int recall_dialog(display& disp, const std::shared_ptr<std::vector<unit_const_ptr > > & units, int side, const std::string& title_suffix, const int team_recall_cost);
|
||||
|
||||
/** Show unit-stats in a side-pane to unit-list, recall-list, etc. */
|
||||
class unit_preview_pane : public gui::preview_pane
|
||||
|
@ -108,7 +108,7 @@ class units_list_preview_pane : public dialogs::unit_preview_pane
|
|||
{
|
||||
public:
|
||||
units_list_preview_pane(unit_const_ptr u, TYPE type = SHOW_ALL, bool left_side = true);
|
||||
units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > & units,
|
||||
units_list_preview_pane(const std::shared_ptr<const std::vector<unit_const_ptr > > & units,
|
||||
const gui::filter_textbox *filter = nullptr,
|
||||
TYPE type = SHOW_ALL, bool left_side = true);
|
||||
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
const details get_details() const;
|
||||
void process_event();
|
||||
|
||||
boost::shared_ptr<const std::vector<unit_const_ptr > > units_;
|
||||
std::shared_ptr<const std::vector<unit_const_ptr > > units_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void display::remove_single_overlay(const map_location& loc, const std::string&
|
|||
|
||||
|
||||
|
||||
display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::manager> wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) :
|
||||
display::display(const display_context * dc, CVideo& video, std::weak_ptr<wb::manager> wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) :
|
||||
video2::draw_layering(auto_join),
|
||||
dc_(dc),
|
||||
halo_man_(new halo::manager(*this)),
|
||||
|
@ -393,7 +393,7 @@ void display::set_team(size_t teamindex, bool show_everything)
|
|||
dont_show_all_ = false;
|
||||
}
|
||||
labels().recalculate_labels();
|
||||
if(boost::shared_ptr<wb::manager> w = wb_.lock())
|
||||
if(std::shared_ptr<wb::manager> w = wb_.lock())
|
||||
w->on_viewer_change(teamindex);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,6 @@ namespace wb {
|
|||
#include "overlay.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -78,7 +76,7 @@ class gamemap;
|
|||
class display : public filter_context, public video2::draw_layering
|
||||
{
|
||||
public:
|
||||
display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::manager> wb,
|
||||
display(const display_context * dc, CVideo& video, std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const config& theme_cfg, const config& level, bool auto_join=true);
|
||||
virtual ~display();
|
||||
|
@ -661,8 +659,8 @@ private:
|
|||
protected:
|
||||
//TODO sort
|
||||
const display_context * dc_;
|
||||
boost::scoped_ptr<halo::manager> halo_man_;
|
||||
boost::weak_ptr<wb::manager> wb_;
|
||||
std::unique_ptr<halo::manager> halo_man_;
|
||||
std::weak_ptr<wb::manager> wb_;
|
||||
|
||||
typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
|
||||
/// map of hexes where only one unit should be drawn, the one identified by the associated id string
|
||||
|
@ -774,8 +772,8 @@ protected:
|
|||
theme theme_;
|
||||
int zoom_;
|
||||
static int last_zoom_;
|
||||
boost::scoped_ptr<fake_unit_manager> fake_unit_man_;
|
||||
boost::scoped_ptr<terrain_builder> builder_;
|
||||
const std::unique_ptr<fake_unit_manager> fake_unit_man_;
|
||||
const std::unique_ptr<terrain_builder> builder_;
|
||||
surface minimap_;
|
||||
SDL_Rect minimap_location_;
|
||||
bool redrawMinimap_;
|
||||
|
@ -787,7 +785,7 @@ protected:
|
|||
double turbo_speed_;
|
||||
bool turbo_;
|
||||
bool invalidateGameStatus_;
|
||||
boost::scoped_ptr<map_labels> map_labels_;
|
||||
const std::unique_ptr<map_labels> map_labels_;
|
||||
reports * reports_object_;
|
||||
|
||||
/** Event raised when the map is being scrolled */
|
||||
|
|
|
@ -25,15 +25,12 @@
|
|||
#include "mp_ui_alerts.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL_video.h>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define ERR_NG LOG_STREAM(err, log_engine)
|
||||
|
||||
using boost::uint32_t;
|
||||
|
||||
namespace {
|
||||
const int chat_message_border = 5;
|
||||
const int chat_message_x = 10;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "chat_events.hpp"
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
int speaker_handle;
|
||||
int handle;
|
||||
boost::uint32_t created_at;
|
||||
uint32_t created_at;
|
||||
};
|
||||
|
||||
void prune_chat_messages(bool remove_all=false);
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "units/unit.hpp"
|
||||
#include "units/animation_component.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
namespace editor {
|
||||
|
||||
editor_action_unit* editor_action_unit::clone() const
|
||||
|
|
|
@ -1197,7 +1197,7 @@ void editor_controller::export_selection_coords()
|
|||
void editor_controller::perform_delete(editor_action* action)
|
||||
{
|
||||
if (action) {
|
||||
boost::scoped_ptr<editor_action> action_auto(action);
|
||||
const std::unique_ptr<editor_action> action_auto(action);
|
||||
context_manager_->get_map_context().perform_action(*action);
|
||||
}
|
||||
}
|
||||
|
@ -1205,7 +1205,7 @@ void editor_controller::perform_delete(editor_action* action)
|
|||
void editor_controller::perform_refresh_delete(editor_action* action, bool drag_part /* =false */)
|
||||
{
|
||||
if (action) {
|
||||
boost::scoped_ptr<editor_action> action_auto(action);
|
||||
const std::unique_ptr<editor_action> action_auto(action);
|
||||
context_manager_->perform_refresh(*action, drag_part);
|
||||
}
|
||||
}
|
||||
|
@ -1255,7 +1255,7 @@ void editor_controller::mouse_motion(int x, int y, const bool /*browse*/,
|
|||
//last undo action and the controller shouldn't add
|
||||
//anything to the undo stack (hence a different perform_ call)
|
||||
if (a != nullptr) {
|
||||
boost::scoped_ptr<editor_action> aa(a);
|
||||
const std::unique_ptr<editor_action> aa(a);
|
||||
if (partial) {
|
||||
context_manager_->get_map_context().perform_partial_action(*a);
|
||||
} else {
|
||||
|
|
|
@ -226,10 +226,10 @@ class editor_controller : public controller_base,
|
|||
editor::menu_type active_menu_;
|
||||
|
||||
/** Reports object. Must be initialized before the gui_ */
|
||||
boost::scoped_ptr<reports> reports_;
|
||||
const std::unique_ptr<reports> reports_;
|
||||
|
||||
/** The display object used and owned by the editor. */
|
||||
boost::scoped_ptr<editor_display> gui_;
|
||||
const std::unique_ptr<editor_display> gui_;
|
||||
|
||||
/** Pre-defined time of day lighting settings for the settings dialog */
|
||||
typedef std::map<std::string, std::pair<std::string ,std::vector<time_of_day> > > tods_map;
|
||||
|
@ -237,13 +237,13 @@ class editor_controller : public controller_base,
|
|||
|
||||
/* managers */
|
||||
public:
|
||||
boost::scoped_ptr<context_manager> context_manager_;
|
||||
const std::unique_ptr<context_manager> context_manager_;
|
||||
private:
|
||||
boost::scoped_ptr<editor_toolkit> toolkit_;
|
||||
std::unique_ptr<editor_toolkit> toolkit_;
|
||||
tooltips::manager tooltip_manager_;
|
||||
boost::scoped_ptr<font::floating_label_context> floating_label_manager_;
|
||||
std::unique_ptr<font::floating_label_context> floating_label_manager_;
|
||||
|
||||
boost::scoped_ptr<help::help_manager> help_manager_;
|
||||
std::unique_ptr<help::help_manager> help_manager_;
|
||||
|
||||
/** Quit main loop flag */
|
||||
bool do_quit_;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "terrain/builder.hpp"
|
||||
#include "units/map.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace wb {
|
||||
class manager;
|
||||
}
|
||||
|
@ -57,7 +55,7 @@ const display_context * get_dummy_display_context() {
|
|||
editor_display::editor_display(const display_context * dc, CVideo& video,
|
||||
reports & reports_object,
|
||||
const config& theme_cfg, const config& level)
|
||||
: display(dc, video, boost::shared_ptr<wb::manager>(), reports_object, theme_cfg, level)
|
||||
: display(dc, video, std::shared_ptr<wb::manager>(), reports_object, theme_cfg, level)
|
||||
, brush_locations_()
|
||||
{
|
||||
clear_screen();
|
||||
|
|
|
@ -1007,7 +1007,7 @@ void context_manager::switch_context(const int index, const bool force)
|
|||
|
||||
void context_manager::replace_map_context(map_context* new_mc)
|
||||
{
|
||||
boost::scoped_ptr<map_context> del(map_contexts_[current_context_index_]);
|
||||
const std::unique_ptr<map_context> del(map_contexts_[current_context_index_]);
|
||||
map_context_refresher mcr(*this, *new_mc);
|
||||
map_contexts_[current_context_index_] = new_mc;
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
|
||||
#include "terrain/type_data.hpp"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace editor {
|
||||
|
||||
editor_map_load_exception wrap_exc(const char* type, const std::string& e_msg, const std::string& filename)
|
||||
|
@ -44,13 +41,13 @@ editor_map_load_exception wrap_exc(const char* type, const std::string& e_msg, c
|
|||
}
|
||||
|
||||
editor_map::editor_map(const config& terrain_cfg)
|
||||
: gamemap(boost::make_shared<terrain_type_data>(terrain_cfg), "")
|
||||
: gamemap(std::make_shared<terrain_type_data>(terrain_cfg), "")
|
||||
, selection_()
|
||||
{
|
||||
}
|
||||
|
||||
editor_map::editor_map(const config& terrain_cfg, const std::string& data)
|
||||
: gamemap(boost::make_shared<terrain_type_data>(terrain_cfg), data)
|
||||
: gamemap(std::make_shared<terrain_type_data>(terrain_cfg), data)
|
||||
, selection_()
|
||||
{
|
||||
sanity_check();
|
||||
|
@ -70,7 +67,7 @@ editor_map editor_map::from_string(const config& terrain_cfg, const std::string&
|
|||
}
|
||||
|
||||
editor_map::editor_map(const config& terrain_cfg, size_t width, size_t height, const t_translation::t_terrain & filler)
|
||||
: gamemap(boost::make_shared<terrain_type_data>(terrain_cfg), t_translation::write_game_map(
|
||||
: gamemap(std::make_shared<terrain_type_data>(terrain_cfg), t_translation::write_game_map(
|
||||
t_translation::t_map(width + 2, t_translation::t_list(height + 2, filler))))
|
||||
, selection_()
|
||||
{
|
||||
|
|
|
@ -141,7 +141,7 @@ map_context::map_context(const config& game_config, const std::string& filename,
|
|||
}
|
||||
|
||||
// 1.0 Pure map data
|
||||
boost::regex rexpression_map_data("map_data\\s*=\\s*\"(.+?)\"");
|
||||
boost::regex rexpression_map_data(R"""(map_data\s*=\s*"(.+?)")""");
|
||||
boost::smatch matched_map_data;
|
||||
if (!boost::regex_search(file_string, matched_map_data, rexpression_map_data,
|
||||
boost::regex_constants::match_not_dot_null)) {
|
||||
|
@ -154,12 +154,12 @@ map_context::map_context(const config& game_config, const std::string& filename,
|
|||
|
||||
// 2.0 Embedded map
|
||||
const std::string& map_data = matched_map_data[1];
|
||||
boost::regex rexpression_macro("\\{(.+?)\\}");
|
||||
boost::regex rexpression_macro(R"""(\{(.+?)\})""");
|
||||
boost::smatch matched_macro;
|
||||
if (!boost::regex_search(map_data, matched_macro, rexpression_macro)) {
|
||||
// We have a map_data string but no macro ---> embedded or scenario
|
||||
|
||||
boost::regex rexpression_scenario("\\[scenario\\]|\\[test\\]|\\[multiplayer\\]");
|
||||
boost::regex rexpression_scenario(R"""(\[(scenario|test|multiplayer)\])""");
|
||||
if (!boost::regex_search(file_string, rexpression_scenario)) {
|
||||
LOG_ED << "Loading generated scenario file" << std::endl;
|
||||
// 4.0 editor generated scenario
|
||||
|
@ -542,7 +542,7 @@ bool map_context::save_map()
|
|||
filesystem::write_file(get_filename(), map_data);
|
||||
} else {
|
||||
std::string map_string = filesystem::read_file(get_filename());
|
||||
boost::regex rexpression_map_data("(.*map_data\\s*=\\s*\")(.+?)(\".*)");
|
||||
boost::regex rexpression_map_data(R"""((.*map_data\s*=\s*")(.+?)(".*))""");
|
||||
boost::smatch matched_map_data;
|
||||
if (boost::regex_search(map_string, matched_map_data, rexpression_map_data,
|
||||
boost::regex_constants::match_not_dot_null)) {
|
||||
|
@ -692,7 +692,7 @@ void map_context::partial_undo()
|
|||
}
|
||||
//a partial undo performs the first action form the current action's action_chain that would be normally performed
|
||||
//i.e. the *first* one.
|
||||
boost::scoped_ptr<editor_action> first_action_in_chain(undo_chain->pop_first_action());
|
||||
const std::unique_ptr<editor_action> first_action_in_chain(undo_chain->pop_first_action());
|
||||
if (undo_chain->empty()) {
|
||||
actions_since_save_--;
|
||||
delete undo_chain;
|
||||
|
@ -727,7 +727,7 @@ void map_context::clear_stack(action_stack& stack)
|
|||
void map_context::perform_action_between_stacks(action_stack& from, action_stack& to)
|
||||
{
|
||||
assert(!from.empty());
|
||||
boost::scoped_ptr<editor_action> action(from.back());
|
||||
const std::unique_ptr<editor_action> action(from.back());
|
||||
from.pop_back();
|
||||
editor_action* reverse_action = action->perform(*this);
|
||||
to.push_back(reverse_action);
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
#include "overlay.hpp"
|
||||
#include "display_context.hpp"
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
namespace editor {
|
||||
|
||||
|
@ -486,7 +485,7 @@ private:
|
|||
unit_map units_;
|
||||
std::vector<team> teams_;
|
||||
std::vector<std::string> lbl_categories_;
|
||||
boost::scoped_ptr<tod_manager> tod_manager_;
|
||||
std::unique_ptr<tod_manager> tod_manager_;
|
||||
mp_game_settings mp_settings_;
|
||||
game_classification game_classification_;
|
||||
|
||||
|
|
|
@ -80,11 +80,11 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
boost::scoped_ptr<terrain_palette> terrain_palette_;
|
||||
boost::scoped_ptr<unit_palette> unit_palette_;
|
||||
boost::scoped_ptr<empty_palette> empty_palette_;
|
||||
boost::scoped_ptr<item_palette> item_palette_;
|
||||
boost::scoped_ptr<location_palette> location_palette_;
|
||||
const std::unique_ptr<terrain_palette> terrain_palette_;
|
||||
const std::unique_ptr<unit_palette> unit_palette_;
|
||||
const std::unique_ptr<empty_palette> empty_palette_;
|
||||
const std::unique_ptr<item_palette> item_palette_;
|
||||
const std::unique_ptr<location_palette> location_palette_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include "editor/toolkit/brush.hpp"
|
||||
#include "hotkey/hotkey_command.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class config;
|
||||
|
||||
namespace editor {
|
||||
|
@ -87,7 +85,7 @@ private:
|
|||
|
||||
const CKey& key_;
|
||||
|
||||
boost::scoped_ptr<palette_manager> palette_manager_;
|
||||
std::unique_ptr<palette_manager> palette_manager_;
|
||||
|
||||
//Tools
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,9 +15,10 @@
|
|||
#ifndef FORMULA_CALLABLE_HPP_INCLUDED
|
||||
#define FORMULA_CALLABLE_HPP_INCLUDED
|
||||
|
||||
#include "reference_counted_object.hpp"
|
||||
#include "formula/variant.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace game_logic
|
||||
{
|
||||
|
||||
|
@ -31,7 +32,7 @@ struct formula_input {
|
|||
};
|
||||
|
||||
//interface for objects that can have formulae run on them
|
||||
class formula_callable : public reference_counted_object {
|
||||
class formula_callable {
|
||||
public:
|
||||
explicit formula_callable(bool has_self=true) : type_(FORMULA_C), has_self_(has_self)
|
||||
{}
|
||||
|
@ -102,14 +103,6 @@ private:
|
|||
bool has_self_;
|
||||
};
|
||||
|
||||
class formula_callable_no_ref_count : public formula_callable {
|
||||
public:
|
||||
formula_callable_no_ref_count() {
|
||||
turn_reference_counting_off();
|
||||
}
|
||||
virtual ~formula_callable_no_ref_count() {}
|
||||
};
|
||||
|
||||
class formula_callable_with_backup : public formula_callable {
|
||||
const formula_callable& main_;
|
||||
const formula_callable& backup_;
|
||||
|
@ -173,8 +166,8 @@ private:
|
|||
const formula_callable* fallback_;
|
||||
};
|
||||
|
||||
typedef boost::intrusive_ptr<map_formula_callable> map_formula_callable_ptr;
|
||||
typedef boost::intrusive_ptr<const map_formula_callable> const_map_formula_callable_ptr;
|
||||
typedef std::shared_ptr<map_formula_callable> map_formula_callable_ptr;
|
||||
typedef std::shared_ptr<const map_formula_callable> const_map_formula_callable_ptr;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,12 @@
|
|||
#ifndef FORMULA_CALLABLE_FWD_HPP_INCLUDED
|
||||
#define FORMULA_CALLABLE_FWD_HPP_INCLUDED
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
namespace game_logic {
|
||||
|
||||
class formula_callable;
|
||||
class formula_debugger;
|
||||
typedef boost::intrusive_ptr<formula_callable> formula_callable_ptr;
|
||||
typedef boost::intrusive_ptr<const formula_callable> const_formula_callable_ptr;
|
||||
typedef std::shared_ptr<formula_callable> formula_callable_ptr;
|
||||
typedef std::shared_ptr<const formula_callable> const_formula_callable_ptr;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "gui/dialogs/formula_debugger.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
static lg::log_domain log_formula_debugger("scripting/formula/debug");
|
||||
#define DBG_FDB LOG_STREAM(debug, log_formula_debugger)
|
||||
#define LOG_FDB LOG_STREAM(info, log_formula_debugger)
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class variant;
|
||||
|
||||
|
@ -39,7 +39,7 @@ class formula_callable;
|
|||
|
||||
class base_breakpoint;
|
||||
|
||||
typedef boost::shared_ptr<base_breakpoint> breakpoint_ptr;
|
||||
typedef std::shared_ptr<base_breakpoint> breakpoint_ptr;
|
||||
|
||||
formula_debugger* add_debug_info(formula_debugger *fdb, int arg_number, const std::string& f_name);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
#include "global.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
@ -549,7 +549,7 @@ private:
|
|||
};
|
||||
|
||||
typedef std::map<std::string,expression_ptr> expr_table;
|
||||
typedef boost::shared_ptr<expr_table> expr_table_ptr;
|
||||
typedef std::shared_ptr<expr_table> expr_table_ptr;
|
||||
typedef std::map<std::string, variant> exp_table_evaluated;
|
||||
|
||||
class where_variables: public formula_callable {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace game_logic
|
|||
class formula_callable;
|
||||
class formula_expression;
|
||||
class function_symbol_table;
|
||||
typedef boost::shared_ptr<formula_expression> expression_ptr;
|
||||
typedef std::shared_ptr<formula_expression> expression_ptr;
|
||||
|
||||
class formula {
|
||||
public:
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
#ifndef FORMULA_FWD_HPP_INCLUDED
|
||||
#define FORMULA_FWD_HPP_INCLUDED
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace game_logic {
|
||||
|
||||
class formula_debugger;
|
||||
|
||||
class formula;
|
||||
typedef boost::shared_ptr<formula> formula_ptr;
|
||||
typedef boost::shared_ptr<const formula> const_formula_ptr;
|
||||
typedef std::shared_ptr<formula> formula_ptr;
|
||||
typedef std::shared_ptr<const formula> const_formula_ptr;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -66,10 +66,10 @@ public:
|
|||
{}
|
||||
private:
|
||||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
boost::shared_ptr<formula_debugger> fdbp;
|
||||
std::shared_ptr<formula_debugger> fdbp;
|
||||
bool need_wrapper = false;
|
||||
if (fdb==nullptr) {
|
||||
fdbp = boost::shared_ptr<formula_debugger>(new formula_debugger());
|
||||
fdbp = std::shared_ptr<formula_debugger>(new formula_debugger());
|
||||
fdb = &*fdbp;
|
||||
need_wrapper = true;
|
||||
|
||||
|
@ -98,7 +98,6 @@ private:
|
|||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
variant var = args()[0]->evaluate(variables, fdb);
|
||||
const formula_callable* callable = var.as_callable();
|
||||
callable->add_ref();
|
||||
std::vector<formula_input> inputs = callable->inputs();
|
||||
std::vector<variant> res;
|
||||
for(size_t i=0; i<inputs.size(); ++i) {
|
||||
|
@ -319,7 +318,7 @@ private:
|
|||
speaker = args()[0]->evaluate(variables, fdb).string_cast();
|
||||
i_value = 1;
|
||||
}
|
||||
|
||||
|
||||
const variant value = args()[i_value]->evaluate(variables,fdb);
|
||||
long run_time = 0;
|
||||
for(int i = 1; i < 1000; i++) {
|
||||
|
@ -767,7 +766,6 @@ private:
|
|||
}
|
||||
} else {
|
||||
map_formula_callable self_callable;
|
||||
self_callable.add_ref();
|
||||
const std::string self = args()[1]->evaluate(variables,fdb).as_string();
|
||||
for(variant_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
self_callable.add(self, *it);
|
||||
|
@ -937,7 +935,6 @@ private:
|
|||
}
|
||||
} else {
|
||||
map_formula_callable self_callable;
|
||||
self_callable.add_ref();
|
||||
const std::string self = args()[1]->evaluate(variables,fdb).as_string();
|
||||
for(variant_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
self_callable.add(self, *it);
|
||||
|
@ -975,7 +972,6 @@ private:
|
|||
}
|
||||
} else {
|
||||
map_formula_callable self_callable;
|
||||
self_callable.add_ref();
|
||||
const std::string self = args()[1]->evaluate(variables,fdb).as_string();
|
||||
for(variant_iterator it = items.begin(); it != items.end(); ++it){
|
||||
self_callable.add(self, *it);
|
||||
|
@ -1011,7 +1007,6 @@ private:
|
|||
}
|
||||
} else {
|
||||
map_formula_callable self_callable;
|
||||
self_callable.add_ref();
|
||||
const std::string self = args()[1]->evaluate(variables,fdb).as_string();
|
||||
for(variant_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
self_callable.add(self, *it);
|
||||
|
@ -1117,7 +1112,6 @@ private:
|
|||
++it;
|
||||
}
|
||||
map_formula_callable self_callable;
|
||||
self_callable.add_ref();
|
||||
for(; it != items.end(); ++it) {
|
||||
self_callable.add("a", res);
|
||||
self_callable.add("b", *it);
|
||||
|
@ -1383,18 +1377,6 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class refcount_function : public function_expression {
|
||||
public:
|
||||
explicit refcount_function(const args_list& args)
|
||||
: function_expression("refcount", args, 1, 1)
|
||||
{}
|
||||
private:
|
||||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
return variant(args()[0]->evaluate(variables,fdb).refcount());
|
||||
}
|
||||
};
|
||||
|
||||
class loc_function : public function_expression {
|
||||
public:
|
||||
explicit loc_function(const args_list& args)
|
||||
|
@ -1427,7 +1409,7 @@ public:
|
|||
explicit distance_between_function(const args_list& args)
|
||||
: function_expression("distance_between", args, 2, 2)
|
||||
{}
|
||||
|
||||
|
||||
private:
|
||||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
const map_location loc1 = convert_variant<location_callable>(args()[0]->evaluate(variables,add_debug_info(fdb,0,"distance_between:location_A")))->loc();
|
||||
|
@ -1469,7 +1451,7 @@ void key_value_pair::get_inputs(std::vector<game_logic::formula_input>* inputs)
|
|||
inputs->push_back(game_logic::formula_input("value", game_logic::FORMULA_READ_ONLY));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void key_value_pair::serialize_to_string(std::string& str) const {
|
||||
str += "pair(";
|
||||
key_.serialize_to_string(str);
|
||||
|
@ -1594,7 +1576,6 @@ function_symbol_table& get_functions_map() {
|
|||
FUNCTION(sgn);
|
||||
FUNCTION(round);
|
||||
FUNCTION(as_decimal);
|
||||
FUNCTION(refcount);
|
||||
FUNCTION(pair);
|
||||
FUNCTION(loc);
|
||||
FUNCTION(distance_between);
|
||||
|
@ -1639,7 +1620,7 @@ expression_ptr create_function(const std::string& fn,
|
|||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
expression_ptr res(get_functions_map().create_function(fn, args));
|
||||
if(!res) {
|
||||
throw formula_error("Unknown function: " + fn, "", "", 0);
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
friend class formula_debugger;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<formula_expression> expression_ptr;
|
||||
typedef std::shared_ptr<formula_expression> expression_ptr;
|
||||
|
||||
class function_expression : public formula_expression {
|
||||
public:
|
||||
|
@ -95,7 +95,7 @@ private:
|
|||
int star_arg_;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<function_expression> function_expression_ptr;
|
||||
typedef std::shared_ptr<function_expression> function_expression_ptr;
|
||||
|
||||
class formula_function {
|
||||
protected:
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<formula_function> formula_function_ptr;
|
||||
typedef std::shared_ptr<formula_function> formula_function_ptr;
|
||||
typedef std::map<std::string, formula_function_ptr> functions_map;
|
||||
|
||||
class function_symbol_table {
|
||||
|
|
|
@ -54,16 +54,6 @@ std::string interpolate_variables_into_string(const std::string &str, const vari
|
|||
t_string interpolate_variables_into_tstring(const t_string &str, const variable_set& variables);
|
||||
|
||||
}
|
||||
/// An alias for boost::assign::map_list_of<std::string, std::string>
|
||||
inline boost::assign_detail::generic_list< std::pair
|
||||
<
|
||||
boost::assign_detail::assign_decay<std::string>::type,
|
||||
boost::assign_detail::assign_decay<std::string>::type
|
||||
> >
|
||||
string_map_of(const std::string& k, const std::string& v)
|
||||
{
|
||||
return boost::assign::map_list_of<std::string, std::string>(k, v);
|
||||
}
|
||||
|
||||
/** Handy wrappers around interpolate_variables_into_string and gettext. */
|
||||
std::string vgettext(const char* msgid, const utils::string_map& symbols);
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "formatter.hpp"
|
||||
#include "formula/callable.hpp"
|
||||
#include "formula/function.hpp"
|
||||
|
@ -249,86 +248,20 @@ bool variant_iterator::operator!=(const variant_iterator& that) const
|
|||
return true;
|
||||
}
|
||||
|
||||
struct variant_list {
|
||||
variant_list()
|
||||
: elements()
|
||||
, refcount(0)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<variant> elements;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
struct variant_string {
|
||||
variant_string()
|
||||
: str()
|
||||
, refcount(0)
|
||||
{
|
||||
}
|
||||
|
||||
std::string str;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
struct variant_map {
|
||||
variant_map()
|
||||
: elements()
|
||||
, refcount(0)
|
||||
{
|
||||
}
|
||||
|
||||
std::map<variant,variant> elements;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
void variant::increment_refcount()
|
||||
{
|
||||
switch(type_) {
|
||||
case TYPE_LIST:
|
||||
++list_->refcount;
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
++string_->refcount;
|
||||
break;
|
||||
case TYPE_MAP:
|
||||
++map_->refcount;
|
||||
break;
|
||||
case TYPE_CALLABLE:
|
||||
intrusive_ptr_add_ref(callable_);
|
||||
break;
|
||||
|
||||
// These are not used here, add them to silence a compiler warning.
|
||||
case TYPE_NULL:
|
||||
case TYPE_DECIMAL:
|
||||
case TYPE_INT :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void variant::release()
|
||||
{
|
||||
switch(type_) {
|
||||
case TYPE_LIST:
|
||||
if(--list_->refcount == 0) {
|
||||
delete list_;
|
||||
}
|
||||
delete list_;
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
if(--string_->refcount == 0) {
|
||||
delete string_;
|
||||
}
|
||||
delete string_;
|
||||
break;
|
||||
case TYPE_MAP:
|
||||
if(--map_->refcount == 0) {
|
||||
delete map_;
|
||||
}
|
||||
delete map_;
|
||||
break;
|
||||
case TYPE_CALLABLE:
|
||||
intrusive_ptr_release(callable_);
|
||||
break;
|
||||
|
||||
// These are not used here, add them to silence a compiler warning.
|
||||
case TYPE_CALLABLE:
|
||||
case TYPE_NULL:
|
||||
case TYPE_DECIMAL:
|
||||
case TYPE_INT :
|
||||
|
@ -352,9 +285,9 @@ variant::variant(int n, variant::DECIMAL_VARIANT_TYPE /*type*/) : type_(TYPE_DEC
|
|||
variant::variant(double n, variant::DECIMAL_VARIANT_TYPE /*type*/) : type_(TYPE_DECIMAL) {
|
||||
n *= 1000;
|
||||
decimal_value_ = static_cast<int>(n);
|
||||
|
||||
|
||||
n -= decimal_value_;
|
||||
|
||||
|
||||
if(n > 0.5)
|
||||
decimal_value_++;
|
||||
else if(n < -0.5)
|
||||
|
@ -365,40 +298,53 @@ variant::variant(const game_logic::formula_callable* callable)
|
|||
: type_(TYPE_CALLABLE), callable_(callable)
|
||||
{
|
||||
assert(callable_);
|
||||
increment_refcount();
|
||||
}
|
||||
|
||||
variant::variant(std::vector<variant>* array)
|
||||
: type_(TYPE_LIST)
|
||||
{
|
||||
assert(array);
|
||||
list_ = new variant_list;
|
||||
list_->elements.swap(*array);
|
||||
increment_refcount();
|
||||
list_ = new std::vector<variant>(*array);
|
||||
}
|
||||
|
||||
variant::variant(const std::string& str)
|
||||
: type_(TYPE_STRING)
|
||||
{
|
||||
string_ = new variant_string;
|
||||
string_->str = str;
|
||||
increment_refcount();
|
||||
string_ = new std::string(str);
|
||||
}
|
||||
|
||||
variant::variant(std::map<variant,variant>* map)
|
||||
: type_(TYPE_MAP)
|
||||
{
|
||||
assert(map);
|
||||
map_ = new variant_map;
|
||||
map_->elements.swap(*map);
|
||||
increment_refcount();
|
||||
map_ = new std::map<variant,variant>(*map);
|
||||
}
|
||||
|
||||
variant::variant(const variant& v)
|
||||
: type_(v.type_)
|
||||
{
|
||||
memcpy(this, &v, sizeof(v));
|
||||
increment_refcount();
|
||||
switch(type_) {
|
||||
case TYPE_INT:
|
||||
int_value_ = v.int_value_;
|
||||
break;
|
||||
case TYPE_DECIMAL:
|
||||
decimal_value_ = v.decimal_value_;
|
||||
break;
|
||||
case TYPE_LIST:
|
||||
list_ = new std::vector<variant>(*v.list_);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
string_ = new std::string(*v.string_);
|
||||
break;
|
||||
case TYPE_MAP:
|
||||
map_ = new std::map<variant,variant>(*v.map_);
|
||||
break;
|
||||
case TYPE_CALLABLE:
|
||||
callable_ = v.callable_;
|
||||
break;
|
||||
case TYPE_NULL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
variant::~variant()
|
||||
|
@ -409,9 +355,8 @@ variant::~variant()
|
|||
variant& variant::operator=(const variant& v)
|
||||
{
|
||||
if(&v != this) {
|
||||
release();
|
||||
memcpy(this, &v, sizeof(v));
|
||||
increment_refcount();
|
||||
this->~variant();
|
||||
new(this) variant(v);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -424,11 +369,11 @@ variant variant::operator[](size_t n) const
|
|||
|
||||
must_be(TYPE_LIST);
|
||||
assert(list_);
|
||||
if(n >= list_->elements.size()) {
|
||||
if(n >= list_->size()) {
|
||||
throw type_error("invalid index");
|
||||
}
|
||||
|
||||
return list_->elements[n];
|
||||
return (*list_)[n];
|
||||
}
|
||||
|
||||
variant variant::operator[](const variant& v) const
|
||||
|
@ -439,8 +384,8 @@ variant variant::operator[](const variant& v) const
|
|||
|
||||
if(type_ == TYPE_MAP) {
|
||||
assert(map_);
|
||||
std::map<variant,variant>::const_iterator i = map_->elements.find(v);
|
||||
if (i == map_->elements.end())
|
||||
std::map<variant,variant>::const_iterator i = map_->find(v);
|
||||
if (i == map_->end())
|
||||
{
|
||||
static variant null_variant;
|
||||
return null_variant;
|
||||
|
@ -449,7 +394,7 @@ variant variant::operator[](const variant& v) const
|
|||
} else if(type_ == TYPE_LIST) {
|
||||
if(v.is_list()) {
|
||||
std::vector<variant> slice;
|
||||
|
||||
|
||||
for(size_t i = 0; i < v.num_elements(); ++i) {
|
||||
slice.push_back( (*this)[v[i]] );
|
||||
}
|
||||
|
@ -470,7 +415,7 @@ variant variant::get_keys() const
|
|||
must_be(TYPE_MAP);
|
||||
assert(map_);
|
||||
std::vector<variant> tmp;
|
||||
for(std::map<variant,variant>::const_iterator i=map_->elements.begin(); i != map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i=map_->begin(); i != map_->end(); ++i) {
|
||||
tmp.push_back(i->first);
|
||||
}
|
||||
return variant(&tmp);
|
||||
|
@ -481,7 +426,7 @@ variant variant::get_values() const
|
|||
must_be(TYPE_MAP);
|
||||
assert(map_);
|
||||
std::vector<variant> tmp;
|
||||
for(std::map<variant,variant>::const_iterator i=map_->elements.begin(); i != map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i=map_->begin(); i != map_->end(); ++i) {
|
||||
tmp.push_back(i->second);
|
||||
}
|
||||
return variant(&tmp);
|
||||
|
@ -490,20 +435,20 @@ variant variant::get_values() const
|
|||
variant_iterator variant::begin() const
|
||||
{
|
||||
if(type_ == TYPE_LIST)
|
||||
return variant_iterator( list_->elements.begin() );
|
||||
return variant_iterator( list_->begin() );
|
||||
|
||||
if(type_ == TYPE_MAP)
|
||||
return variant_iterator( map_->elements.begin() );
|
||||
return variant_iterator( map_->begin() );
|
||||
|
||||
return variant_iterator();
|
||||
}
|
||||
variant_iterator variant::end() const
|
||||
{
|
||||
if(type_ == TYPE_LIST)
|
||||
return variant_iterator( list_->elements.end() );
|
||||
return variant_iterator( list_->end() );
|
||||
|
||||
if(type_ == TYPE_MAP)
|
||||
return variant_iterator( map_->elements.end() );
|
||||
return variant_iterator( map_->end() );
|
||||
|
||||
return variant_iterator();
|
||||
}
|
||||
|
@ -514,10 +459,10 @@ bool variant::is_empty() const
|
|||
return true;
|
||||
} else if (type_ == TYPE_LIST) {
|
||||
assert(list_);
|
||||
return list_->elements.empty();
|
||||
return list_->empty();
|
||||
} else if (type_ == TYPE_MAP) {
|
||||
assert(map_);
|
||||
return map_->elements.empty();
|
||||
return map_->empty();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -531,10 +476,10 @@ size_t variant::num_elements() const
|
|||
|
||||
if (type_ == TYPE_LIST) {
|
||||
assert(list_);
|
||||
return list_->elements.size();
|
||||
return list_->size();
|
||||
} else if (type_ == TYPE_MAP) {
|
||||
assert(map_);
|
||||
return map_->elements.size();
|
||||
return map_->size();
|
||||
} else {
|
||||
throw type_error((formatter() << "type error: "
|
||||
<< " expected a list or a map but found " << type_string()
|
||||
|
@ -589,11 +534,11 @@ bool variant::as_bool() const
|
|||
case TYPE_CALLABLE:
|
||||
return callable_ != nullptr;
|
||||
case TYPE_LIST:
|
||||
return !list_->elements.empty();
|
||||
return !list_->empty();
|
||||
case TYPE_MAP:
|
||||
return !map_->elements.empty();
|
||||
return !map_->empty();
|
||||
case TYPE_STRING:
|
||||
return !string_->str.empty();
|
||||
return !string_->empty();
|
||||
default:
|
||||
assert(false);
|
||||
return false;
|
||||
|
@ -604,21 +549,21 @@ const std::string& variant::as_string() const
|
|||
{
|
||||
must_be(TYPE_STRING);
|
||||
assert(string_);
|
||||
return string_->str;
|
||||
return *string_;
|
||||
}
|
||||
|
||||
const std::vector<variant>& variant::as_list() const
|
||||
{
|
||||
must_be(TYPE_LIST);
|
||||
assert(list_);
|
||||
return list_->elements;
|
||||
return *list_;
|
||||
}
|
||||
|
||||
const std::map<variant,variant>& variant::as_map() const
|
||||
{
|
||||
must_be(TYPE_MAP);
|
||||
assert(map_);
|
||||
return map_->elements;
|
||||
return *map_;
|
||||
}
|
||||
|
||||
variant variant::operator+(const variant& v) const
|
||||
|
@ -626,14 +571,14 @@ variant variant::operator+(const variant& v) const
|
|||
if(type_ == TYPE_LIST) {
|
||||
if(v.type_ == TYPE_LIST) {
|
||||
std::vector<variant> res;
|
||||
res.reserve(list_->elements.size() + v.list_->elements.size());
|
||||
for(size_t i = 0; i<list_->elements.size(); ++i) {
|
||||
const variant& var = list_->elements[i];
|
||||
res.reserve(list_->size() + v.list_->size());
|
||||
for(size_t i = 0; i<list_->size(); ++i) {
|
||||
const variant& var = (*list_)[i];
|
||||
res.push_back(var);
|
||||
}
|
||||
|
||||
for(size_t j = 0; j<v.list_->elements.size(); ++j) {
|
||||
const variant& var = v.list_->elements[j];
|
||||
for(size_t j = 0; j<v.list_->size(); ++j) {
|
||||
const variant& var = (*v.list_)[j];
|
||||
res.push_back(var);
|
||||
}
|
||||
|
||||
|
@ -642,9 +587,9 @@ variant variant::operator+(const variant& v) const
|
|||
}
|
||||
if(type_ == TYPE_MAP) {
|
||||
if(v.type_ == TYPE_MAP) {
|
||||
std::map<variant,variant> res(map_->elements);
|
||||
std::map<variant,variant> res(*map_);
|
||||
|
||||
for(std::map<variant,variant>::const_iterator i = v.map_->elements.begin(); i != v.map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i = v.map_->begin(); i != v.map_->end(); ++i) {
|
||||
res[i->first] = i->second;
|
||||
}
|
||||
|
||||
|
@ -731,7 +676,7 @@ variant variant::operator%(const variant& v) const
|
|||
if(denominator == 0) {
|
||||
throw type_error((formatter() << "divide by zero error").str());
|
||||
}
|
||||
|
||||
|
||||
return variant(numerator%denominator, DECIMAL_VARIANT);
|
||||
} else {
|
||||
const int numerator = as_int();
|
||||
|
@ -750,7 +695,7 @@ variant variant::operator^(const variant& v) const
|
|||
if( type_ == TYPE_DECIMAL || v.type_ == TYPE_DECIMAL ) {
|
||||
|
||||
double res = pow( as_decimal()/1000.0 , v.as_decimal()/1000.0 );
|
||||
|
||||
|
||||
if(res != res) return variant();
|
||||
|
||||
return variant(res, DECIMAL_VARIANT);
|
||||
|
@ -784,7 +729,7 @@ bool variant::operator==(const variant& v) const
|
|||
}
|
||||
|
||||
case TYPE_STRING: {
|
||||
return string_->str == v.string_->str;
|
||||
return *string_ == *v.string_;
|
||||
}
|
||||
|
||||
case TYPE_INT: {
|
||||
|
@ -810,7 +755,7 @@ bool variant::operator==(const variant& v) const
|
|||
}
|
||||
|
||||
case TYPE_MAP: {
|
||||
return map_->elements == v.map_->elements;
|
||||
return *map_ == *v.map_;
|
||||
}
|
||||
|
||||
case TYPE_CALLABLE: {
|
||||
|
@ -845,7 +790,7 @@ bool variant::operator<=(const variant& v) const
|
|||
}
|
||||
|
||||
case TYPE_STRING: {
|
||||
return string_->str <= v.string_->str;
|
||||
return *string_ <= *v.string_;
|
||||
}
|
||||
|
||||
case TYPE_INT: {
|
||||
|
@ -869,7 +814,7 @@ bool variant::operator<=(const variant& v) const
|
|||
}
|
||||
|
||||
case TYPE_MAP: {
|
||||
return map_->elements <= v.map_->elements;
|
||||
return *map_ <= *v.map_;
|
||||
}
|
||||
|
||||
case TYPE_CALLABLE: {
|
||||
|
@ -972,18 +917,18 @@ variant variant::concatenate(const variant& v) const
|
|||
{
|
||||
if(type_ == TYPE_LIST) {
|
||||
v.must_be(TYPE_LIST);
|
||||
|
||||
|
||||
std::vector< variant > res;
|
||||
res.reserve(num_elements() + v.num_elements());
|
||||
|
||||
|
||||
for(size_t i = 0; i < num_elements(); ++i) {
|
||||
res.push_back( (*this)[i] );
|
||||
}
|
||||
|
||||
|
||||
for(size_t i = 0; i < v.num_elements(); ++i) {
|
||||
res.push_back( v[i] );
|
||||
}
|
||||
|
||||
|
||||
return variant( &res );
|
||||
} else if(type_ == TYPE_STRING) {
|
||||
v.must_be(TYPE_STRING);
|
||||
|
@ -1001,17 +946,17 @@ variant variant::concatenate(const variant& v) const
|
|||
variant variant::build_range(const variant& v) const {
|
||||
must_be(TYPE_INT);
|
||||
v.must_be(TYPE_INT);
|
||||
|
||||
|
||||
int lhs = as_int(), rhs = v.as_int();
|
||||
int len = abs(rhs - lhs) + 1;
|
||||
|
||||
|
||||
std::vector< variant > res;
|
||||
res.reserve(len);
|
||||
|
||||
|
||||
for(size_t i = lhs; res.size() != res.capacity(); lhs < rhs ? ++i : --i) {
|
||||
res.push_back( variant(i) );
|
||||
}
|
||||
|
||||
|
||||
return variant( &res );
|
||||
}
|
||||
|
||||
|
@ -1023,13 +968,13 @@ bool variant::contains(const variant& v) const {
|
|||
<< variant_type_to_string(type_)
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
}
|
||||
|
||||
|
||||
if(type_ == TYPE_LIST) {
|
||||
variant_iterator iter = std::find(begin(), end(), v);
|
||||
return iter != end();
|
||||
} else {
|
||||
std::map<variant,variant>::const_iterator iter = map_->elements.find(v);
|
||||
return iter != map_->elements.end();
|
||||
std::map<variant,variant>::const_iterator iter = map_->find(v);
|
||||
return iter != map_->end();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1079,8 +1024,8 @@ void variant::serialize_to_string(std::string& str) const
|
|||
case TYPE_LIST: {
|
||||
str += "[";
|
||||
bool first_time = true;
|
||||
for(size_t i=0; i<list_->elements.size(); ++i) {
|
||||
const variant& var = list_->elements[i];
|
||||
for(size_t i=0; i<list_->size(); ++i) {
|
||||
const variant& var = (*list_)[i];
|
||||
if(!first_time) {
|
||||
str += ",";
|
||||
}
|
||||
|
@ -1093,7 +1038,7 @@ void variant::serialize_to_string(std::string& str) const
|
|||
case TYPE_MAP: {
|
||||
str += "[";
|
||||
bool first_time = true;
|
||||
for(std::map<variant,variant>::const_iterator i=map_->elements.begin(); i != map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i=map_->begin(); i != map_->end(); ++i) {
|
||||
if(!first_time) {
|
||||
str += ",";
|
||||
}
|
||||
|
@ -1102,7 +1047,7 @@ void variant::serialize_to_string(std::string& str) const
|
|||
str += "->";
|
||||
i->second.serialize_to_string(str);
|
||||
}
|
||||
if(map_->elements.empty()) {
|
||||
if(map_->empty()) {
|
||||
str += "->";
|
||||
}
|
||||
str += "]";
|
||||
|
@ -1110,7 +1055,7 @@ void variant::serialize_to_string(std::string& str) const
|
|||
}
|
||||
case TYPE_STRING:
|
||||
str += "'";
|
||||
for(std::string::iterator it = string_->str.begin(); it < string_->str.end(); ++it) {
|
||||
for(std::string::iterator it = string_->begin(); it < string_->end(); ++it) {
|
||||
switch(*it) {
|
||||
case '\'':
|
||||
str += "[']";
|
||||
|
@ -1142,26 +1087,6 @@ void variant::serialize_from_string(const std::string& str)
|
|||
}
|
||||
}
|
||||
|
||||
int variant::refcount() const
|
||||
{
|
||||
switch(type_) {
|
||||
case TYPE_LIST:
|
||||
return list_->refcount;
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
return string_->refcount;
|
||||
break;
|
||||
case TYPE_MAP:
|
||||
return map_->refcount;
|
||||
break;
|
||||
case TYPE_CALLABLE:
|
||||
return callable_->refcount();
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
std::string variant::string_cast() const
|
||||
{
|
||||
switch(type_) {
|
||||
|
@ -1194,8 +1119,8 @@ std::string variant::string_cast() const
|
|||
return "(object)";
|
||||
case TYPE_LIST: {
|
||||
std::string res = "";
|
||||
for(size_t i=0; i<list_->elements.size(); ++i) {
|
||||
const variant& var = list_->elements[i];
|
||||
for(size_t i=0; i<list_->size(); ++i) {
|
||||
const variant& var = (*list_)[i];
|
||||
if(!res.empty()) {
|
||||
res += ", ";
|
||||
}
|
||||
|
@ -1207,7 +1132,7 @@ std::string variant::string_cast() const
|
|||
}
|
||||
case TYPE_MAP: {
|
||||
std::string res = "";
|
||||
for(std::map<variant,variant>::const_iterator i=map_->elements.begin(); i != map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i=map_->begin(); i != map_->end(); ++i) {
|
||||
if(!res.empty()) {
|
||||
res += ",";
|
||||
}
|
||||
|
@ -1219,7 +1144,7 @@ std::string variant::string_cast() const
|
|||
}
|
||||
|
||||
case TYPE_STRING:
|
||||
return string_->str;
|
||||
return *string_;
|
||||
default:
|
||||
assert(false);
|
||||
return "invalid";
|
||||
|
@ -1306,7 +1231,7 @@ std::string variant::to_debug_string(std::vector<const game_logic::formula_calla
|
|||
case TYPE_MAP: {
|
||||
s << "[";
|
||||
bool first_time = true;
|
||||
for(std::map<variant,variant>::const_iterator i=map_->elements.begin(); i != map_->elements.end(); ++i) {
|
||||
for(std::map<variant,variant>::const_iterator i=map_->begin(); i != map_->end(); ++i) {
|
||||
if(!first_time) {
|
||||
s << ",";
|
||||
}
|
||||
|
@ -1319,7 +1244,7 @@ std::string variant::to_debug_string(std::vector<const game_logic::formula_calla
|
|||
break;
|
||||
}
|
||||
case TYPE_STRING: {
|
||||
s << "'" << string_->str << "'";
|
||||
s << "'" << *string_ << "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#ifndef VARIANT_HPP_INCLUDED
|
||||
#define VARIANT_HPP_INCLUDED
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
@ -39,9 +38,6 @@ struct call_stack_manager {
|
|||
}
|
||||
};
|
||||
|
||||
struct variant_list;
|
||||
struct variant_string;
|
||||
struct variant_map;
|
||||
class variant_iterator;
|
||||
|
||||
struct type_error : public game::error {
|
||||
|
@ -154,8 +150,6 @@ public:
|
|||
void serialize_to_string(std::string& str) const;
|
||||
void serialize_from_string(const std::string& str);
|
||||
|
||||
int refcount() const;
|
||||
|
||||
std::string string_cast() const;
|
||||
|
||||
std::string to_debug_string(std::vector<const game_logic::formula_callable*>* seen=nullptr, bool verbose = false) const;
|
||||
|
@ -168,12 +162,11 @@ private:
|
|||
int decimal_value_;
|
||||
const game_logic::formula_callable* callable_;
|
||||
game_logic::formula_callable* mutable_callable_;
|
||||
variant_list* list_;
|
||||
variant_string* string_;
|
||||
variant_map* map_;
|
||||
std::vector<variant>* list_;
|
||||
std::string* string_;
|
||||
std::map<variant,variant>* map_;
|
||||
};
|
||||
|
||||
void increment_refcount();
|
||||
void release();
|
||||
};
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include "units/id.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
@ -58,7 +56,7 @@ class game_board : public display_context
|
|||
std::vector<team> teams_;
|
||||
std::vector<std::string> labels_;
|
||||
|
||||
boost::scoped_ptr<gamemap> map_;
|
||||
std::unique_ptr<gamemap> map_;
|
||||
n_unit::id_manager unit_id_manager_;
|
||||
unit_map units_;
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#include "theme.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
static lg::log_domain log_config("config");
|
||||
#define ERR_CONFIG LOG_STREAM(err, log_config)
|
||||
#define WRN_CONFIG LOG_STREAM(warn, log_config)
|
||||
|
@ -296,7 +294,7 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload,
|
|||
set_unit_data();
|
||||
|
||||
terrain_builder::set_terrain_rules_cfg(game_config());
|
||||
tdata_ = boost::make_shared<terrain_type_data>(game_config_);
|
||||
tdata_ = std::make_shared<terrain_type_data>(game_config_);
|
||||
::init_strings(game_config());
|
||||
theme::set_known_themes(&game_config());
|
||||
} catch(game::error& e) {
|
||||
|
@ -518,7 +516,7 @@ void game_config_manager::load_game_config_for_game(
|
|||
game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest &&
|
||||
classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
|
||||
|
||||
typedef boost::shared_ptr<game_config::scoped_preproc_define> define;
|
||||
typedef std::shared_ptr<game_config::scoped_preproc_define> define;
|
||||
std::deque<define> extra_defines;
|
||||
for (const std::string& extra_define : classification.campaign_xtra_defines) {
|
||||
define new_define(new game_config::scoped_preproc_define(extra_define));
|
||||
|
@ -554,7 +552,7 @@ void game_config_manager::load_game_config_for_create(bool is_mp)
|
|||
///During an mp game the default difficuly define is also defined so better already load it now if we alreeady must reload config cache.
|
||||
game_config::scoped_preproc_define normal(DEFAULT_DIFFICULTY, !map_includes(old_defines_map_, cache_.get_preproc_map()));
|
||||
|
||||
typedef boost::shared_ptr<game_config::scoped_preproc_define> define;
|
||||
typedef std::shared_ptr<game_config::scoped_preproc_define> define;
|
||||
try{
|
||||
load_game_config_with_loadscreen(NO_INCLUDE_RELOAD);
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
#include "units/drawer.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
static lg::log_domain log_display("display");
|
||||
#define ERR_DP LOG_STREAM(err, log_display)
|
||||
#define LOG_DP LOG_STREAM(info, log_display)
|
||||
|
@ -68,7 +66,7 @@ std::vector<sdl::timage> footsteps_images(const map_location& loc, const pathfin
|
|||
std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
|
||||
#endif
|
||||
|
||||
game_display::game_display(game_board& board, CVideo& video, boost::weak_ptr<wb::manager> wb,
|
||||
game_display::game_display(game_board& board, CVideo& video, std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const tod_manager& tod,
|
||||
const config& theme_cfg,
|
||||
|
@ -96,10 +94,10 @@ game_display* game_display::create_dummy_display(CVideo& video)
|
|||
{
|
||||
static config dummy_cfg;
|
||||
static config dummy_cfg2;
|
||||
static game_board dummy_board(boost::make_shared<terrain_type_data>(dummy_cfg), dummy_cfg2);
|
||||
static game_board dummy_board(std::make_shared<terrain_type_data>(dummy_cfg), dummy_cfg2);
|
||||
static tod_manager dummy_tod(dummy_cfg);
|
||||
static reports rep_;
|
||||
return new game_display(dummy_board, video, boost::shared_ptr<wb::manager>(), rep_, dummy_tod,
|
||||
return new game_display(dummy_board, video, std::shared_ptr<wb::manager>(), rep_, dummy_tod,
|
||||
dummy_cfg, dummy_cfg, true);
|
||||
}
|
||||
|
||||
|
@ -249,7 +247,7 @@ void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force
|
|||
}
|
||||
|
||||
void game_display::pre_draw() {
|
||||
if (boost::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
if (std::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
w->pre_draw();
|
||||
}
|
||||
process_reachmap_changes();
|
||||
|
@ -262,7 +260,7 @@ void game_display::pre_draw() {
|
|||
|
||||
|
||||
void game_display::post_draw() {
|
||||
if (boost::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
if (std::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
w->post_draw();
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +373,7 @@ void game_display::draw_hex(const map_location& loc)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (boost::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
if (std::shared_ptr<wb::manager> w = wb_.lock()) {
|
||||
w->draw_hex(loc);
|
||||
|
||||
if (!(w->is_active() && w->has_temp_move()))
|
||||
|
@ -497,7 +495,7 @@ void game_display::draw_movement_info(const map_location& loc)
|
|||
// Search if there is a mark here
|
||||
pathfind::marked_route::mark_map::iterator w = route_.marks.find(loc);
|
||||
|
||||
boost::shared_ptr<wb::manager> wb = wb_.lock();
|
||||
std::shared_ptr<wb::manager> wb = wb_.lock();
|
||||
|
||||
// Don't use empty route or the first step (the unit will be there)
|
||||
if(w != route_.marks.end()
|
||||
|
|
|
@ -39,7 +39,7 @@ class game_display : public display
|
|||
{
|
||||
public:
|
||||
game_display(game_board& board, CVideo& video,
|
||||
boost::weak_ptr<wb::manager> wb,
|
||||
std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const tod_manager& tod_manager,
|
||||
const config& theme_cfg,
|
||||
|
@ -253,7 +253,7 @@ private:
|
|||
|
||||
bool first_turn_, in_game_;
|
||||
|
||||
boost::scoped_ptr<display_chat_manager> chat_man_;
|
||||
const std::unique_ptr<display_chat_manager> chat_man_;
|
||||
|
||||
tgame_mode game_mode_;
|
||||
|
||||
|
|
|
@ -66,8 +66,6 @@
|
|||
#include "wml_exception.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
|
@ -519,10 +517,10 @@ namespace {
|
|||
{
|
||||
//Do a regex check for the file format to prevent sending aribitary files to other clients.
|
||||
//Note: this allows only the new format.
|
||||
static const std::string s_simple_terrain = "[A-Za-z\\\\\\|\\/]{1,4}";
|
||||
static const std::string s_terrain = s_simple_terrain + "(\\^" + s_simple_terrain + ")?";
|
||||
static const std::string s_simple_terrain = R"""([A-Za-z\\|/]{1,4})""";
|
||||
static const std::string s_terrain = s_simple_terrain + R"""((\^)""" + s_simple_terrain + ")?";
|
||||
static const std::string s_sep = "(, |\\n)";
|
||||
static const std::string s_prefix = "(\\d+ )?";
|
||||
static const std::string s_prefix = R"""((\d+ )?)""";
|
||||
static const std::string s_all = "(" + s_prefix + s_terrain + s_sep + ")+";
|
||||
static const boost::regex r_all(s_all);
|
||||
|
||||
|
@ -697,7 +695,7 @@ WML_HANDLER_FUNCTION(set_variables,, cfg)
|
|||
for (const config &cfg : data) {
|
||||
merged_children.append(cfg);
|
||||
}
|
||||
data = boost::assign::list_of(merged_children).convert_to_container<std::vector<config> >();
|
||||
data = {merged_children};
|
||||
}
|
||||
dest.merge_array(data);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include "util.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define WRN_NG LOG_STREAM(warn, log_engine)
|
||||
|
||||
|
@ -171,8 +169,8 @@ namespace { // Support functions
|
|||
}
|
||||
|
||||
vconfig::all_children_iterator cond_end = cond.ordered_end();
|
||||
static const boost::container::flat_set<std::string> hard_coded = boost::assign::list_of("true")("false")("have_unit")("have_location")("variable")
|
||||
("then")("else")("elseif")("not")("and")("or")("do").convert_to_container<boost::container::flat_set<std::string> >();
|
||||
static const std::set<std::string> hard_coded =
|
||||
{"true", "false", "have_unit", "have_location", "variable", "then", "else", "elseif", "not", "and", "or", "do"};
|
||||
|
||||
assert(resources::lua_kernel);
|
||||
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
#include "config.hpp"
|
||||
#include "utils/smart_list.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
@ -44,7 +40,7 @@ namespace game_events
|
|||
class manager;
|
||||
|
||||
/// Shared pointer to handler objects.
|
||||
typedef boost::shared_ptr<event_handler> handler_ptr;
|
||||
typedef std::shared_ptr<event_handler> handler_ptr;
|
||||
/// Storage of event handlers.
|
||||
typedef std::vector<handler_ptr> handler_vec;
|
||||
|
||||
|
@ -88,7 +84,7 @@ namespace game_events
|
|||
class handler_list
|
||||
{
|
||||
/// The weak pointers that are used internally.
|
||||
typedef boost::weak_ptr<event_handler> internal_ptr;
|
||||
typedef std::weak_ptr<event_handler> internal_ptr;
|
||||
/// The underlying list.
|
||||
typedef utils::smart_list<internal_ptr> list_t;
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "game_events/wmi_container.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
@ -96,10 +94,10 @@ namespace game_events {
|
|||
game_data * gamedata_;
|
||||
};
|
||||
|
||||
boost::scoped_ptr<t_event_handlers> event_handlers_;
|
||||
const std::unique_ptr<t_event_handlers> event_handlers_;
|
||||
std::set<std::string> unit_wml_ids_;
|
||||
|
||||
boost::scoped_ptr<game_events::t_pump> pump_;
|
||||
const std::unique_ptr<game_events::t_pump> pump_;
|
||||
game_events::wmi_container wml_menu_items_;
|
||||
|
||||
public:
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "soundsource.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
|
|
@ -17,18 +17,14 @@
|
|||
|
||||
#include "game_events/handlers.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace game_events {
|
||||
|
||||
//t_event_handlers is essentially the implementation details of the manager
|
||||
class t_event_handlers {
|
||||
typedef boost::unordered_map<std::string, handler_list> map_t;
|
||||
typedef boost::unordered_map<std::string, boost::weak_ptr<event_handler> > id_map_t;
|
||||
typedef std::unordered_map<std::string, handler_list> map_t;
|
||||
typedef std::unordered_map<std::string, std::weak_ptr<event_handler> > id_map_t;
|
||||
|
||||
public:
|
||||
typedef handler_vec::iterator iterator;
|
||||
|
|
|
@ -57,17 +57,6 @@ static lg::log_domain log_wml("wml");
|
|||
static lg::log_domain log_event_handler("event_handler");
|
||||
#define DBG_EH LOG_STREAM(debug, log_event_handler)
|
||||
|
||||
// std::getline might be broken in Visual Studio so show a warning
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1300
|
||||
#ifndef GETLINE_PATCHED
|
||||
#pragma message("warning: the std::getline implementation in your compiler might be broken.")
|
||||
#pragma message(" http://support.microsoft.com/default.aspx?scid=kb;EN-US;q240015")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// This file is in the game_events namespace.
|
||||
namespace game_events {
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace game_events
|
|||
class manager;
|
||||
|
||||
class t_pump {
|
||||
boost::scoped_ptr<pump_impl> impl_;
|
||||
const std::unique_ptr<pump_impl> impl_;
|
||||
public:
|
||||
t_pump(manager &);
|
||||
~t_pump();
|
||||
|
|
|
@ -106,10 +106,10 @@ bool wmi_container::fire_item(const std::string & id, const map_location & hex,
|
|||
* @param[out] items Pointers to applicable menu items will be pushed onto @a items.
|
||||
* @param[out] descriptions Menu item text will be pushed onto @a descriptions (in the same order as @a items).
|
||||
*/
|
||||
std::vector<std::pair<boost::shared_ptr<const wml_menu_item>, std::string> > wmi_container::get_items(const map_location& hex,
|
||||
std::vector<std::pair<std::shared_ptr<const wml_menu_item>, std::string> > wmi_container::get_items(const map_location& hex,
|
||||
game_data & gamedata, filter_context & fc, unit_map & units, const_iterator start, const_iterator finish) const
|
||||
{
|
||||
std::vector<std::pair<boost::shared_ptr<const wml_menu_item>, std::string> > ret;
|
||||
std::vector<std::pair<std::shared_ptr<const wml_menu_item>, std::string> > ret;
|
||||
if ( empty() ) {
|
||||
// Nothing to do (skip setting game variables).
|
||||
return ret;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue