Skip to content

Commit 75b413a

Browse files
drug007eagleivg
authored andcommitted
Fix debug build issue.
There were different predicates with the same names. In linux linker link them in wrong order. Now these predicates are replaced by lambdas.
1 parent 4e6aa34 commit 75b413a

File tree

4 files changed

+16
-53
lines changed

4 files changed

+16
-53
lines changed

src/xrGame/smart_cover.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,15 @@ void cover::vertex(smart_cover::loophole const& loophole, smart_cover::loophole_
115115
}
116116
}
117117

118-
class id_predicate
119-
{
120-
shared_str m_id;
121-
122-
public:
123-
IC id_predicate(shared_str const& id) : m_id(id) {}
124-
IC bool operator()(cover::Vertex const& vertex) const { return (m_id._get() == vertex.first->id()._get()); }
125-
IC bool operator()(smart_cover::loophole_data::Action const& action) const
126-
{
127-
return (m_id._get() == action.first._get());
128-
}
129-
};
130-
131118
u32 const& cover::action_level_vertex_id(smart_cover::loophole const& loophole, shared_str const& action_id) const
132119
{
133-
Vertices::const_iterator found = std::find_if(m_vertices.begin(), m_vertices.end(), id_predicate(loophole.id()));
120+
auto found = std::find_if(m_vertices.begin(), m_vertices.end(),
121+
[&loophole] (cover::Vertex const& vertex) { return loophole.id()._get() == vertex.first->id()._get(); });
134122
VERIFY(found != m_vertices.end());
135123

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

src/xrGame/smart_cover_description.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,6 @@ shared_str parse_vertex(luabind::object const& table, LPCSTR identifier, bool co
4646
}
4747
} // namespace smart_cover
4848

49-
class id_predicate
50-
{
51-
loophole const* m_loophole;
52-
53-
public:
54-
IC id_predicate(loophole const& loophole) : m_loophole(&loophole) {}
55-
IC bool operator()(loophole* const& loophole) const
56-
{
57-
VERIFY(loophole);
58-
return (m_loophole->id()._get() == loophole->id()._get());
59-
}
60-
};
61-
6249
class enterable_predicate
6350
{
6451
public:
@@ -117,7 +104,9 @@ void description::load_loopholes(shared_str const& table_id)
117104
}
118105

119106
smart_cover::loophole* loophole = new smart_cover::loophole(table);
120-
VERIFY(std::find_if(m_loopholes.begin(), m_loopholes.end(), id_predicate(*loophole)) == m_loopholes.end());
107+
VERIFY(m_loopholes.end() == std::find_if(m_loopholes.begin(), m_loopholes.end(),
108+
[=](smart_cover::loophole* const lh) { return loophole->id()._get() == lh->id()._get(); }));
109+
121110
m_loopholes.push_back(loophole);
122111
}
123112

src/xrGame/smart_cover_loophole.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ shared_str transform_vertex(shared_str const& vertex_id, bool const& in);
2424
shared_str parse_vertex(luabind::object const& table, LPCSTR identifier, bool const& in);
2525
} // namespace smart_cover
2626

27-
class id_predicate
28-
{
29-
shared_str m_id;
30-
31-
public:
32-
IC id_predicate(shared_str const& id) : m_id(id) {}
33-
IC bool operator()(std::pair<shared_str, action*> const& other) const
34-
{
35-
return (m_id._get() == other.first._get());
36-
}
37-
};
38-
3927
loophole::loophole(luabind::object const& description) : m_fov(0.f), m_range(0.f)
4028
{
4129
VERIFY2(luabind::type(description) == LUA_TTABLE, "invalid loophole description passed");
@@ -108,7 +96,12 @@ void loophole::add_action(LPCSTR type, luabind::object const& table)
10896
{
10997
VERIFY(luabind::type(table) == LUA_TTABLE);
11098
smart_cover::action* action = new smart_cover::action(table);
111-
VERIFY(std::find_if(m_actions.begin(), m_actions.end(), id_predicate(type)) == m_actions.end());
99+
100+
shared_str id = shared_str(type);
101+
VERIFY(m_actions.end() == std::find_if(m_actions.begin(), m_actions.end(),
102+
[=](std::pair<shared_str, smart_cover::action*> const& other) {
103+
return id._get() == other.first._get();
104+
}));
112105
m_actions.insert(std::make_pair(type, action));
113106
}
114107

src/xrGame/smart_cover_storage.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,12 @@ using smart_cover::description;
1818

1919
typedef storage::DescriptionPtr DescriptionPtr;
2020

21-
struct id_predicate
22-
{
23-
shared_str m_id;
24-
25-
public:
26-
IC id_predicate(shared_str const& id) : m_id(id) {}
27-
IC bool operator()(::description* const& ptr) const { return (m_id._get() == ptr->table_id()._get()); }
28-
};
29-
3021
DescriptionPtr storage::description(shared_str const& table_id)
3122
{
3223
collect_garbage();
3324

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

3628
if (found != m_descriptions.end())
3729
return (*found);

0 commit comments

Comments
 (0)