Skip to content

Commit

Permalink
Fix debug build issue.
Browse files Browse the repository at this point in the history
There were different predicates with the same names. In linux linker link them in wrong order. Now these predicates are replaced by lambdas.
  • Loading branch information
drug007 authored and eagleivg committed Nov 8, 2018
1 parent 4e6aa34 commit 75b413a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 53 deletions.
21 changes: 5 additions & 16 deletions src/xrGame/smart_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,15 @@ void cover::vertex(smart_cover::loophole const& loophole, smart_cover::loophole_
}
}

class id_predicate
{
shared_str m_id;

public:
IC id_predicate(shared_str const& id) : m_id(id) {}
IC bool operator()(cover::Vertex const& vertex) const { return (m_id._get() == vertex.first->id()._get()); }
IC bool operator()(smart_cover::loophole_data::Action const& action) const
{
return (m_id._get() == action.first._get());
}
};

u32 const& cover::action_level_vertex_id(smart_cover::loophole const& loophole, shared_str const& action_id) const
{
Vertices::const_iterator found = std::find_if(m_vertices.begin(), m_vertices.end(), id_predicate(loophole.id()));
auto found = std::find_if(m_vertices.begin(), m_vertices.end(),
[&loophole] (cover::Vertex const& vertex) { return loophole.id()._get() == vertex.first->id()._get(); });
VERIFY(found != m_vertices.end());

loophole_data::ActionVertices::const_iterator found2 = std::find_if(
found->second.m_action_vertices.begin(), found->second.m_action_vertices.end(), id_predicate(action_id));
auto found2 = std::find_if(
found->second.m_action_vertices.begin(), found->second.m_action_vertices.end(),
[action_id] (smart_cover::loophole_data::Action const& action) { return (action_id._get() == action.first._get()); });
VERIFY(found2 != found->second.m_action_vertices.end());
VERIFY(ai().level_graph().valid_vertex_id(found2->second));

Expand Down
17 changes: 3 additions & 14 deletions src/xrGame/smart_cover_description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ shared_str parse_vertex(luabind::object const& table, LPCSTR identifier, bool co
}
} // namespace smart_cover

class id_predicate
{
loophole const* m_loophole;

public:
IC id_predicate(loophole const& loophole) : m_loophole(&loophole) {}
IC bool operator()(loophole* const& loophole) const
{
VERIFY(loophole);
return (m_loophole->id()._get() == loophole->id()._get());
}
};

class enterable_predicate
{
public:
Expand Down Expand Up @@ -117,7 +104,9 @@ void description::load_loopholes(shared_str const& table_id)
}

smart_cover::loophole* loophole = new smart_cover::loophole(table);
VERIFY(std::find_if(m_loopholes.begin(), m_loopholes.end(), id_predicate(*loophole)) == m_loopholes.end());
VERIFY(m_loopholes.end() == std::find_if(m_loopholes.begin(), m_loopholes.end(),
[=](smart_cover::loophole* const lh) { return loophole->id()._get() == lh->id()._get(); }));

m_loopholes.push_back(loophole);
}

Expand Down
19 changes: 6 additions & 13 deletions src/xrGame/smart_cover_loophole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ shared_str transform_vertex(shared_str const& vertex_id, bool const& in);
shared_str parse_vertex(luabind::object const& table, LPCSTR identifier, bool const& in);
} // namespace smart_cover

class id_predicate
{
shared_str m_id;

public:
IC id_predicate(shared_str const& id) : m_id(id) {}
IC bool operator()(std::pair<shared_str, action*> const& other) const
{
return (m_id._get() == other.first._get());
}
};

loophole::loophole(luabind::object const& description) : m_fov(0.f), m_range(0.f)
{
VERIFY2(luabind::type(description) == LUA_TTABLE, "invalid loophole description passed");
Expand Down Expand Up @@ -108,7 +96,12 @@ void loophole::add_action(LPCSTR type, luabind::object const& table)
{
VERIFY(luabind::type(table) == LUA_TTABLE);
smart_cover::action* action = new smart_cover::action(table);
VERIFY(std::find_if(m_actions.begin(), m_actions.end(), id_predicate(type)) == m_actions.end());

shared_str id = shared_str(type);
VERIFY(m_actions.end() == std::find_if(m_actions.begin(), m_actions.end(),
[=](std::pair<shared_str, smart_cover::action*> const& other) {
return id._get() == other.first._get();
}));
m_actions.insert(std::make_pair(type, action));
}

Expand Down
12 changes: 2 additions & 10 deletions src/xrGame/smart_cover_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ using smart_cover::description;

typedef storage::DescriptionPtr DescriptionPtr;

struct id_predicate
{
shared_str m_id;

public:
IC id_predicate(shared_str const& id) : m_id(id) {}
IC bool operator()(::description* const& ptr) const { return (m_id._get() == ptr->table_id()._get()); }
};

DescriptionPtr storage::description(shared_str const& table_id)
{
collect_garbage();

Descriptions::iterator found = std::find_if(m_descriptions.begin(), m_descriptions.end(), id_predicate(table_id));
Descriptions::iterator found = std::find_if(m_descriptions.begin(), m_descriptions.end(),
[=](smart_cover::description* const& ptr) { return (table_id._get() == ptr->table_id()._get()); });

if (found != m_descriptions.end())
return (*found);
Expand Down

0 comments on commit 75b413a

Please sign in to comment.