Inline guidebot search into create_buddy_bot
Remove use of a predicate/std::find_if, and switch to structured bindings to access the enumerated range.
This commit is contained in:
parent
7b12aac1bb
commit
eaf319ac4e
|
@ -2158,18 +2158,15 @@ void create_buddy_bot(void)
|
||||||
{
|
{
|
||||||
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
|
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
|
||||||
auto &Vertices = LevelSharedVertexState.get_vertices();
|
auto &Vertices = LevelSharedVertexState.get_vertices();
|
||||||
const auto &&range = enumerate(partial_const_range(LevelSharedRobotInfoState.Robot_info, LevelSharedRobotInfoState.N_robot_types));
|
for (auto &&[idx, ri] : enumerate(partial_const_range(LevelSharedRobotInfoState.Robot_info, LevelSharedRobotInfoState.N_robot_types)))
|
||||||
const auto &&predicate = [](const auto &ev) {
|
{
|
||||||
const robot_info &robptr = ev.value;
|
if (!ri.companion)
|
||||||
return robptr.companion;
|
continue;
|
||||||
};
|
|
||||||
const auto &&it = std::find_if(range.begin(), range.end(), predicate);
|
|
||||||
if (!(it != range.end()))
|
|
||||||
return;
|
|
||||||
const auto &&segp = vmsegptridx(ConsoleObject->segnum);
|
const auto &&segp = vmsegptridx(ConsoleObject->segnum);
|
||||||
auto &vcvertptr = Vertices.vcptr;
|
const auto &&object_pos = compute_segment_center(Vertices.vcptr, segp);
|
||||||
const auto &&object_pos = compute_segment_center(vcvertptr, segp);
|
create_morph_robot(segp, object_pos, idx);
|
||||||
create_morph_robot(segp, object_pos, (*it).idx);
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue