Return ranges::subrange from robot_get_anim_state

This commit is contained in:
Kp 2022-12-31 16:21:47 +00:00
parent d3ffcb0dab
commit ca913240d0
4 changed files with 5 additions and 6 deletions

View file

@ -52,7 +52,7 @@ public:
b(b), e(e)
{
}
subrange(auto &r) :
subrange(auto &&r) :
b(std::ranges::begin(r)), e(std::ranges::end(r))
{
}

View file

@ -30,6 +30,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "pack.h"
#include "aistruct.h"
#include "backports-ranges.h"
#include "weapon_id.h"
#include "object.h"
#include "fwd-partial_range.h"
@ -225,7 +226,7 @@ struct d_level_shared_robot_joint_state : ::dcx::d_level_shared_robot_joint_stat
// On exit:
// Returns number of joints in list.
// jp_list_ptr is stuffed with a pointer to a static array of joint positions. This pointer is valid forever.
partial_range_t<const jointpos *> robot_get_anim_state(const d_robot_info_array &, const std::array<jointpos, MAX_ROBOT_JOINTS> &, unsigned robot_type, robot_gun_number gun_num, robot_animation_state state);
ranges::subrange<const jointpos *> robot_get_anim_state(const d_robot_info_array &, const std::array<jointpos, MAX_ROBOT_JOINTS> &, unsigned robot_type, robot_gun_number gun_num, robot_animation_state state);
/*
* reads n robot_info structs from a PHYSFS_File

View file

@ -882,10 +882,8 @@ static int do_silly_animation(const d_robot_info_array &Robot_info, object &objp
for (const uint8_t gun_num_idx : xrange(1u + num_guns))
{
const auto gun_num = robot_gun_number{gun_num_idx};
const auto &&ras = robot_get_anim_state(Robot_info, Robot_joints, robot_type, gun_num, robot_state);
auto &ail = aip.ail;
range_for (auto &jr, ras)
for (auto &jr : robot_get_anim_state(Robot_info, Robot_joints, robot_type, gun_num, robot_state))
{
unsigned jointnum = jr.jointnum;
auto &jp = jr.angles;

View file

@ -84,7 +84,7 @@ void calc_gun_point(const robot_info &r, vms_vector &gun_point, const object_bas
//fills in ptr to list of joints, and returns the number of joints in list
//takes the robot type (object id), gun number, and desired state
partial_range_t<const jointpos *> robot_get_anim_state(const d_robot_info_array &robot_info, const std::array<jointpos, MAX_ROBOT_JOINTS> &robot_joints, const unsigned robot_type, const robot_gun_number gun_num, const robot_animation_state state)
ranges::subrange<const jointpos *> robot_get_anim_state(const d_robot_info_array &robot_info, const std::array<jointpos, MAX_ROBOT_JOINTS> &robot_joints, const unsigned robot_type, const robot_gun_number gun_num, const robot_animation_state state)
{
auto &rirt = robot_info[robot_type];
auto &as = rirt.anim_states[gun_num][state];