Use v*ptr* factories with highest_valid
This commit is contained in:
parent
d479819931
commit
e8c34be843
|
@ -2,41 +2,39 @@
|
|||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
template <typename T, typename I = typename T::index_type>
|
||||
struct highest_valid_t
|
||||
template <typename T>
|
||||
struct highest_valid_factory
|
||||
{
|
||||
struct iterator : std::iterator<std::forward_iterator_tag, I>
|
||||
using I = typename T::result_type;
|
||||
struct iterator :
|
||||
std::iterator<std::forward_iterator_tag, I>,
|
||||
I
|
||||
{
|
||||
I i;
|
||||
iterator(I pos) : i(pos)
|
||||
iterator(I &&i) :
|
||||
I(static_cast<I &&>(i))
|
||||
{
|
||||
}
|
||||
iterator &operator++()
|
||||
{
|
||||
++ i;
|
||||
I::operator++();
|
||||
return *this;
|
||||
}
|
||||
I operator*() const
|
||||
{
|
||||
return i;
|
||||
}
|
||||
bool operator!=(const iterator &rhs) const
|
||||
{
|
||||
return i != rhs.i;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
T &m_container;
|
||||
I m_begin;
|
||||
highest_valid_t(T &t, I start) :
|
||||
m_container(t), m_begin(start)
|
||||
const iterator m_begin, m_end;
|
||||
highest_valid_factory(T &factory, const typename T::index_type start) :
|
||||
m_begin(factory(start)), m_end(++iterator(factory(factory.highest())))
|
||||
{
|
||||
}
|
||||
iterator begin() const { return m_begin; }
|
||||
iterator end() const { return m_container.highest + 1; }
|
||||
iterator end() const { return m_end; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
highest_valid_t<T> highest_valid(T &t, typename T::index_type start = 0)
|
||||
highest_valid_factory<T> highest_valid(T &t, const typename T::index_type start = 0)
|
||||
{
|
||||
return {t, start};
|
||||
}
|
||||
|
|
|
@ -287,6 +287,11 @@ public:
|
|||
}
|
||||
protected:
|
||||
index_type m_idx;
|
||||
basic_idx &operator++()
|
||||
{
|
||||
++ m_idx;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename managed_type>
|
||||
|
@ -438,6 +443,11 @@ public:
|
|||
bool operator>=(R) const = delete;
|
||||
protected:
|
||||
pointer_type m_ptr;
|
||||
basic_ptr &operator++()
|
||||
{
|
||||
++ m_ptr;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename managed_type>
|
||||
|
@ -525,6 +535,13 @@ public:
|
|||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
protected:
|
||||
basic_ptridx &operator++()
|
||||
{
|
||||
vptr_type::operator++();
|
||||
vidx_type::operator++();
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename managed_type>
|
||||
|
@ -564,6 +581,8 @@ class valptridx<managed_type>::basic_vptr_global_factory
|
|||
{
|
||||
using containing_type = valptridx<managed_type>;
|
||||
public:
|
||||
using index_type = typename containing_type::index_type;
|
||||
using result_type = P;
|
||||
basic_vptr_global_factory() = default;
|
||||
basic_vptr_global_factory(const basic_vptr_global_factory &) = delete;
|
||||
basic_vptr_global_factory &operator=(const basic_vptr_global_factory &) = delete;
|
||||
|
@ -578,10 +597,15 @@ public:
|
|||
return P(p, get_array(p));
|
||||
}
|
||||
__attribute_warn_unused_result
|
||||
P operator()(typename containing_type::index_type i) const
|
||||
P operator()(index_type i) const
|
||||
{
|
||||
return P(i, get_array());
|
||||
}
|
||||
__attribute_warn_unused_result
|
||||
index_type highest() const
|
||||
{
|
||||
return get_array().highest;
|
||||
}
|
||||
template <containing_type::integral_type v>
|
||||
__attribute_warn_unused_result
|
||||
P operator()(const containing_type::magic_constant<v> &m) const
|
||||
|
@ -604,6 +628,7 @@ class valptridx<managed_type>::basic_ptridx_global_factory
|
|||
{
|
||||
using containing_type = valptridx<managed_type>;
|
||||
public:
|
||||
using result_type = PI;
|
||||
basic_ptridx_global_factory() = default;
|
||||
basic_ptridx_global_factory(const basic_ptridx_global_factory &) = delete;
|
||||
basic_ptridx_global_factory &operator=(const basic_ptridx_global_factory &) = delete;
|
||||
|
@ -612,6 +637,11 @@ public:
|
|||
{
|
||||
return PI(i, get_array());
|
||||
}
|
||||
__attribute_warn_unused_result
|
||||
index_type highest() const
|
||||
{
|
||||
return get_array().highest;
|
||||
}
|
||||
template <containing_type::integral_type v>
|
||||
__attribute_warn_unused_result
|
||||
PI operator()(const containing_type::magic_constant<v> &m) const
|
||||
|
|
|
@ -428,9 +428,8 @@ static void thief_message(const char * format, ... )
|
|||
// Return true if marker #id has been placed.
|
||||
static int marker_exists_in_mine(int id)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_MARKER)
|
||||
if (get_marker_id(objp) == id)
|
||||
return 1;
|
||||
|
@ -512,9 +511,8 @@ void set_escort_special_goal(int special_key)
|
|||
// Return id of boss.
|
||||
static int get_boss_id(void)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
{
|
||||
const auto objp_id = get_robot_id(objp);
|
||||
|
@ -571,8 +569,11 @@ static segnum_t exists_fuelcen_in_mine(segnum_t start_seg)
|
|||
return *i;
|
||||
}
|
||||
{
|
||||
auto rh = highest_valid(Segments);
|
||||
if (std::find_if(rh.begin(), rh.end(), predicate) != rh.end())
|
||||
const auto &&rh = highest_valid(vcsegptr);
|
||||
const auto a = [](const vcsegptr_t &s) {
|
||||
return s->special == SEGMENT_IS_FUELCEN;
|
||||
};
|
||||
if (std::find_if(rh.begin(), rh.end(), a) != rh.end())
|
||||
return segment_exit;
|
||||
}
|
||||
return segment_none;
|
||||
|
@ -598,9 +599,9 @@ static objnum_t exists_in_mine(segnum_t start_seg, int objtype, int objid, int s
|
|||
// Couldn't find what we're looking for by looking at connectivity.
|
||||
// See if it's in the mine. It could be hidden behind a trigger or switch
|
||||
// which the buddybot doesn't understand.
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segnum, highest_valid(vcsegptridx))
|
||||
{
|
||||
auto objnum = exists_in_mine_2(vsegptridx(segnum), objtype, objid, special);
|
||||
auto objnum = exists_in_mine_2(segnum, objtype, objid, special);
|
||||
if (objnum != object_none)
|
||||
return object_guidebot_cannot_reach;
|
||||
}
|
||||
|
@ -613,12 +614,11 @@ static objnum_t exists_in_mine(segnum_t start_seg, int objtype, int objid, int s
|
|||
static segnum_t find_exit_segment(void)
|
||||
{
|
||||
// ---------- Find exit doors ----------
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
range_for (const auto j, segp->children)
|
||||
if (j == segment_exit)
|
||||
return i;
|
||||
return segp;
|
||||
}
|
||||
return segment_none;
|
||||
}
|
||||
|
@ -942,9 +942,9 @@ static void do_buddy_dude_stuff(void)
|
|||
|
||||
if (Buddy_last_missile_time + F1_0*2 < GameTime64) {
|
||||
// See if a robot potentially in view cone
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
const auto &&rh = highest_valid(vobjptridx);
|
||||
range_for (const auto &&objp, rh)
|
||||
{
|
||||
const auto objp = vobjptridx(i);
|
||||
if ((objp->type == OBJ_ROBOT) && !Robot_info[get_robot_id(objp)].companion)
|
||||
if (maybe_buddy_fire_mega(objp)) {
|
||||
Buddy_last_missile_time = GameTime64;
|
||||
|
@ -953,9 +953,8 @@ static void do_buddy_dude_stuff(void)
|
|||
}
|
||||
|
||||
// See if a robot near enough that buddy should fire smart missile
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, rh)
|
||||
{
|
||||
const auto objp = vobjptridx(i);
|
||||
if ((objp->type == OBJ_ROBOT) && !Robot_info[get_robot_id(objp)].companion)
|
||||
if (maybe_buddy_fire_smart(objp)) {
|
||||
Buddy_last_missile_time = GameTime64;
|
||||
|
|
|
@ -453,9 +453,8 @@ void ogl_cache_level_textures(void)
|
|||
ogl_cache_polymodel_textures(Player_ship->model_num);
|
||||
ogl_cache_vclipn_textures(Player_ship->expl_vclip_num);
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto objp = vcobjptridx(i);
|
||||
if (objp->type == OBJ_POWERUP && objp->render_type==RT_POWERUP)
|
||||
{
|
||||
ogl_cache_vclipn_textures(objp->rtype.vclip_info.vclip_num);
|
||||
|
|
|
@ -160,9 +160,8 @@ static void propagate_light_intensity(const vsegptr_t segp, int sidenum)
|
|||
// on user-defined light sources.
|
||||
int LightAmbientLighting()
|
||||
{
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(seg));
|
||||
for (int side=0;side<MAX_SIDES_PER_SEGMENT;side++)
|
||||
propagate_light_intensity(segp, side);
|
||||
}
|
||||
|
|
|
@ -277,9 +277,8 @@ static int compute_num_players(void)
|
|||
{
|
||||
int count = 0;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_PLAYER)
|
||||
count++;
|
||||
}
|
||||
|
@ -459,9 +458,8 @@ int ObjectDelete(void)
|
|||
// Return value: 0 = in mine, 1 = not in mine
|
||||
static int move_object_within_mine(const vobjptridx_t obj, const vms_vector &newpos)
|
||||
{
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto segp = vsegptridx(segnum);
|
||||
if (get_seg_masks(obj->pos, segp, 0).centermask == 0) {
|
||||
int fate;
|
||||
fvi_info hit_info;
|
||||
|
@ -479,7 +477,7 @@ static int move_object_within_mine(const vobjptridx_t obj, const vms_vector &new
|
|||
fate = find_vector_intersection(fq, hit_info);
|
||||
|
||||
if (fate != HIT_WALL) {
|
||||
if ( segnum != obj->segnum )
|
||||
if (segp != obj->segnum)
|
||||
obj_relink( obj, segp);
|
||||
obj->pos = newpos;
|
||||
return 0;
|
||||
|
|
|
@ -687,10 +687,9 @@ static int med_move_group(int delta_flag, const vsegptridx_t base_seg, int base_
|
|||
in_vertex_list[Segments[gs].verts[v]] = 1;
|
||||
|
||||
// For all segments which are not in GroupList[current_group].segments, mark all their vertices in the out list.
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(s));
|
||||
if (!GroupList[current_group].segments.contains(s))
|
||||
if (!GroupList[current_group].segments.contains(segp))
|
||||
{
|
||||
for (v=0; v < MAX_VERTICES_PER_SEGMENT; v++)
|
||||
out_vertex_list[segp->verts[v]] = 1;
|
||||
|
|
|
@ -189,9 +189,8 @@ int CreateAdjacentJointsAll()
|
|||
|
||||
med_combine_duplicate_vertices(Vertex_active);
|
||||
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(seg));
|
||||
for (int s=0; s<MAX_SIDES_PER_SEGMENT; s++)
|
||||
{
|
||||
segptridx_t adj_sp = segment_none;
|
||||
|
|
|
@ -52,17 +52,16 @@ static void validate_modified_segments(void)
|
|||
for (int v=0; v<Modified_vertex_index; v++) {
|
||||
v0 = Modified_vertices[v];
|
||||
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(seg));
|
||||
if (segp->segnum != segment_none)
|
||||
{
|
||||
if (modified_segments[seg])
|
||||
if (modified_segments[segp])
|
||||
continue;
|
||||
range_for (const auto w, segp->verts)
|
||||
if (w == v0)
|
||||
{
|
||||
modified_segments[seg] = true;
|
||||
modified_segments[segp] = true;
|
||||
validate_segment(segp);
|
||||
for (unsigned s=0; s<MAX_SIDES_PER_SEGMENT; s++) {
|
||||
Num_tilings = 1;
|
||||
|
|
|
@ -564,9 +564,8 @@ static void draw_mine_all(int automap_flag)
|
|||
|
||||
n_used = 0;
|
||||
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(s);
|
||||
if (segp->segnum != segment_none)
|
||||
{
|
||||
for (i=0; i<MAX_SIDES_PER_SEGMENT; i++)
|
||||
|
@ -625,9 +624,8 @@ static void draw_special_segments(void)
|
|||
ubyte color;
|
||||
|
||||
// Highlight matcens, fuelcens, etc.
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(seg));
|
||||
if (segp->segnum != segment_none)
|
||||
switch(segp->special)
|
||||
{
|
||||
|
|
|
@ -662,9 +662,8 @@ int wall_remove_side(const vsegptridx_t seg, short side)
|
|||
|
||||
Num_walls -= 2;
|
||||
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(s));
|
||||
if (segp->segnum != segment_none)
|
||||
for (int w=0;w<MAX_SIDES_PER_SEGMENT;w++)
|
||||
if (segp->sides[w].wall_num > lower_wallnum+1)
|
||||
|
@ -920,26 +919,23 @@ int check_walls()
|
|||
int matcen_num;
|
||||
|
||||
wall_count = 0;
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(seg));
|
||||
if (segp->segnum != segment_none) {
|
||||
// Check fuelcenters
|
||||
matcen_num = segp->matcen_num;
|
||||
if (matcen_num == 0)
|
||||
if (RobotCenters[0].segnum != seg) {
|
||||
if (RobotCenters[0].segnum != segp) {
|
||||
segp->matcen_num = -1;
|
||||
}
|
||||
|
||||
if (matcen_num > -1)
|
||||
if (RobotCenters[matcen_num].segnum != seg) {
|
||||
RobotCenters[matcen_num].segnum = seg;
|
||||
}
|
||||
RobotCenters[matcen_num].segnum = segp;
|
||||
|
||||
for (int side=0;side<MAX_SIDES_PER_SEGMENT;side++)
|
||||
if (segp->sides[side].wall_num != wall_none) {
|
||||
CountedWalls[wall_count].wallnum = segp->sides[side].wall_num;
|
||||
CountedWalls[wall_count].segnum = seg;
|
||||
CountedWalls[wall_count].segnum = segp;
|
||||
CountedWalls[wall_count].sidenum = side;
|
||||
wall_count++;
|
||||
}
|
||||
|
@ -989,9 +985,8 @@ int delete_all_walls()
|
|||
char Message[DIAGNOSTIC_MESSAGE_MAX];
|
||||
sprintf( Message, "Are you sure that walls are hosed so\n badly that you want them ALL GONE!?\n");
|
||||
if (ui_messagebox( -2, -2, 2, Message, "YES!", "No" )==1) {
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(seg));
|
||||
for (int side=0;side<MAX_SIDES_PER_SEGMENT;side++)
|
||||
segp->sides[side].wall_num = wall_none;
|
||||
}
|
||||
|
@ -1095,9 +1090,8 @@ void check_wall_validity(void)
|
|||
for (int i=0; i<MAX_WALLS; i++)
|
||||
wall_flags[i] = 0;
|
||||
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
if (segp->segnum != segment_none)
|
||||
for (int j=0; j<MAX_SIDES_PER_SEGMENT; j++) {
|
||||
// Check walls
|
||||
|
@ -1114,7 +1108,7 @@ void check_wall_validity(void)
|
|||
// Then do the usual /eip++;g
|
||||
}
|
||||
|
||||
if ((Walls[wall_num].segnum != i) || (Walls[wall_num].sidenum != j)) {
|
||||
if ((Walls[wall_num].segnum != segp) || (Walls[wall_num].sidenum != j)) {
|
||||
if (!Validate_walls)
|
||||
return;
|
||||
Int3(); // Error! Your mine has been invalidated!
|
||||
|
|
|
@ -571,9 +571,8 @@ static void change_vertex_occurrences(int dest, int src)
|
|||
g.vertices.replace(src, dest);
|
||||
|
||||
// now scan all segments, changing occurrences of src to dest
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(s));
|
||||
if (segp->segnum != segment_none)
|
||||
range_for (auto &v, segp->verts)
|
||||
if (v == src)
|
||||
|
@ -933,9 +932,8 @@ void set_vertex_counts(void)
|
|||
Vertex_active[v] = 0;
|
||||
|
||||
// Count number of occurrences of each vertex.
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(s));
|
||||
if (segp->segnum != segment_none)
|
||||
range_for (auto &v, segp->verts)
|
||||
{
|
||||
|
@ -1249,19 +1247,18 @@ int med_form_joint(const vsegptridx_t seg1, int side1, const vsegptridx_t seg2,
|
|||
validation_list[0] = seg2;
|
||||
|
||||
for (v=0; v<4; v++)
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(s));
|
||||
if (segp->segnum != segment_none)
|
||||
range_for (auto &sv, segp->verts)
|
||||
if (sv == lost_vertices[v]) {
|
||||
sv = remap_vertices[v];
|
||||
// Add segment to list of segments to be validated.
|
||||
for (s1=0; s1<nv; s1++)
|
||||
if (validation_list[s1] == s)
|
||||
if (validation_list[s1] == segp)
|
||||
break;
|
||||
if (s1 == nv)
|
||||
validation_list[nv++] = s;
|
||||
validation_list[nv++] = segp;
|
||||
Assert(nv < MAX_VALIDATIONS);
|
||||
}
|
||||
}
|
||||
|
@ -1606,10 +1603,9 @@ int med_find_adjacent_segment_side(const vsegptridx_t sp, int side, segptridx_t
|
|||
abs_verts[v] = sp->verts[Side_to_verts[side][v]];
|
||||
|
||||
// Scan all segments, looking for a segment which contains the four abs_verts
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(seg));
|
||||
if (seg != sp)
|
||||
if (segp != sp)
|
||||
{
|
||||
range_for (auto &v, abs_verts)
|
||||
{ // do for each vertex in abs_verts
|
||||
|
@ -1668,10 +1664,9 @@ int med_find_closest_threshold_segment_side(const vsegptridx_t sp, int side, seg
|
|||
closest_seg_dist = JOINT_THRESHOLD;
|
||||
|
||||
// Scan all segments, looking for a segment which contains the four abs_verts
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(seg));
|
||||
if (seg != sp)
|
||||
if (segp != sp)
|
||||
for (s=0;s<MAX_SIDES_PER_SEGMENT;s++) {
|
||||
if (!IS_CHILD(segp->children[s])) {
|
||||
const auto vtc = compute_center_point_on_side(segp, s);
|
||||
|
|
|
@ -70,14 +70,13 @@ static fix get_average_light_at_vertex(int vnum, segnum_t *segs)
|
|||
num_occurrences = 0;
|
||||
total_light = 0;
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(segnum));
|
||||
auto e = end(segp->verts);
|
||||
auto relvnum = std::distance(std::find(begin(segp->verts), e, vnum), e);
|
||||
if (relvnum < MAX_VERTICES_PER_SEGMENT) {
|
||||
|
||||
*segs++ = segnum;
|
||||
*segs++ = segp;
|
||||
Assert(segs - original_segs < MAX_LIGHT_SEGS);
|
||||
(void)original_segs;
|
||||
|
||||
|
@ -258,9 +257,8 @@ static void assign_default_lighting(const vsegptr_t segp)
|
|||
|
||||
void assign_default_lighting_all(void)
|
||||
{
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(seg));
|
||||
if (segp->segnum != segment_none)
|
||||
assign_default_lighting(segp);
|
||||
}
|
||||
|
@ -805,9 +803,8 @@ static void fix_bogus_uvs_seg(const vsegptridx_t segp)
|
|||
|
||||
int fix_bogus_uvs_all(void)
|
||||
{
|
||||
range_for (const auto seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(seg));
|
||||
if (segp->segnum != segment_none)
|
||||
fix_bogus_uvs_seg(segp);
|
||||
}
|
||||
|
@ -939,9 +936,8 @@ static void cast_light_from_side(const vsegptridx_t segp, int light_side, fix li
|
|||
// -- Old way, before 5/8/95 -- inverse_segment_magnitude = fixdiv(F1_0/5, vm_vec_mag(&vector_to_center));
|
||||
// -- Old way, before 5/8/95 -- vm_vec_scale_add(&light_location, &light_location, &vector_to_center, inverse_segment_magnitude);
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&rsegp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&rsegp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
fix dist_to_rseg;
|
||||
|
||||
for (i=0; i<FVI_HASH_SIZE; i++)
|
||||
|
@ -1063,9 +1059,8 @@ static void calim_zero_light_values(void)
|
|||
{
|
||||
int sidenum, vertnum;
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
|
||||
side *sidep = &segp->sides[sidenum];
|
||||
for (vertnum=0; vertnum<4; vertnum++)
|
||||
|
@ -1090,9 +1085,8 @@ static void cast_light_from_side_to_center(const vsegptridx_t segp, int light_si
|
|||
const auto vector_to_center = vm_vec_sub(segment_center, vert_light_location);
|
||||
const auto light_location = vm_vec_scale_add(vert_light_location, vector_to_center, F1_0/64);
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&rsegp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&rsegp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
fix dist_to_rseg;
|
||||
//if ((segp == &Segments[Bugseg]) && (rsegp == &Segments[Bugseg]))
|
||||
// Int3();
|
||||
|
@ -1159,9 +1153,8 @@ static void calim_process_all_lights(int quick_light)
|
|||
{
|
||||
int sidenum;
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(segnum));
|
||||
for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
|
||||
// if (!IS_CHILD(segp->children[sidenum])) {
|
||||
if (WALL_IS_DOORWAY(segp, sidenum) != WID_NO_WALL) {
|
||||
|
|
|
@ -267,9 +267,8 @@ void do_replacements(void)
|
|||
Assert(old_tmap_num >= 0);
|
||||
Assert(new_tmap_num >= 0);
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
for (int sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
|
||||
const auto sidep = &segp->sides[sidenum];
|
||||
if (sidep->tmap_num == old_tmap_num) {
|
||||
|
|
|
@ -506,9 +506,8 @@ void init_ai_objects(void)
|
|||
{
|
||||
Point_segs_free_ptr = Point_segs.begin();
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &o = vobjptr(static_cast<objnum_t>(i));
|
||||
if (o->type == OBJ_ROBOT && o->control_type == CT_AI)
|
||||
init_ai_object(o, o->ctype.ai_info.behavior, o->ctype.ai_info.hide_segment);
|
||||
}
|
||||
|
@ -1935,9 +1934,8 @@ static objptridx_t create_gated_robot(const vsegptridx_t segp, int object_id, co
|
|||
return object_none;
|
||||
#endif
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (objp->matcen_creator == BOSS_GATE_MATCEN_NUM)
|
||||
count++;
|
||||
|
@ -2083,12 +2081,11 @@ static void init_boss_segments(boss_special_segment_array_t &segptr, int size_ch
|
|||
#endif
|
||||
|
||||
// See if there is a boss. If not, quick out.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&objp = vobjptridx(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT && Robot_info[get_robot_id(objp)].boss_flag)
|
||||
{
|
||||
boss_objnum = i; // if != 1 then there is more than one boss here.
|
||||
boss_objnum = objp; // if != 1 then there is more than one boss here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3074,9 +3071,8 @@ void do_ai_frame(const vobjptridx_t obj)
|
|||
cobjptr_t min_obj = nullptr;
|
||||
fix min_dist = F1_0*200, cur_dist;
|
||||
|
||||
range_for (const auto ii, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptridx(static_cast<objnum_t>(ii));
|
||||
if (objp->type == OBJ_ROBOT && objp != obj)
|
||||
{
|
||||
cur_dist = vm_vec_dist_quick(obj->pos, objp->pos);
|
||||
|
@ -4253,9 +4249,8 @@ static void set_player_awareness_all(void)
|
|||
|
||||
process_awareness_events(New_awareness);
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT && objp->control_type == CT_AI)
|
||||
{
|
||||
auto &ailp = objp->ctype.ai_info.ail;
|
||||
|
@ -4304,9 +4299,8 @@ static void dump_ai_objects_all()
|
|||
if (Ai_error_message[0])
|
||||
fprintf(Ai_dump_file, "Error message: %s\n", Ai_error_message);
|
||||
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(objnum));
|
||||
ai_static *aip = &objp->ctype.ai_info;
|
||||
ai_local *ailp = &objp->ctype.ai_info.ail;
|
||||
fix dist_to_player;
|
||||
|
@ -4315,7 +4309,7 @@ static void dump_ai_objects_all()
|
|||
|
||||
if (objp->control_type == CT_AI) {
|
||||
fprintf(Ai_dump_file, "%3i: %3i %8.3f %8s %8s [%3i %4i]\n",
|
||||
objnum, objp->segnum, f2fl(dist_to_player), mode_text[ailp->mode], behavior_text[aip->behavior-0x80], aip->hide_index, aip->path_length);
|
||||
static_cast<uint16_t>(objp), objp->segnum, f2fl(dist_to_player), mode_text[ailp->mode], behavior_text[aip->behavior-0x80], aip->hide_index, aip->path_length);
|
||||
if (aip->path_length)
|
||||
total += aip->path_length;
|
||||
}
|
||||
|
@ -4368,9 +4362,8 @@ void do_ai_frame_all(void)
|
|||
// Clear if supposed misisle camera is not a weapon, or just every so often, just in case.
|
||||
if (((d_tick_count & 0x0f) == 0) || (Ai_last_missile_camera->type != OBJ_WEAPON)) {
|
||||
Ai_last_missile_camera = nullptr;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
objp->ctype.ai_info.SUB_FLAGS &= ~SUB_FLAGS_CAMERA_AWAKE;
|
||||
}
|
||||
|
@ -4379,9 +4372,8 @@ void do_ai_frame_all(void)
|
|||
|
||||
// (Moved here from do_boss_stuff() because that only gets called if robot aware of player.)
|
||||
if (Boss_dying) {
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&objp = vobjptridx(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (Robot_info[get_robot_id(objp)].boss_flag)
|
||||
do_boss_dying_frame(objp);
|
||||
|
|
|
@ -596,9 +596,8 @@ void validate_all_paths(void)
|
|||
{
|
||||
|
||||
#if PATH_VALIDATION
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT) {
|
||||
ai_static *aip = &objp->ctype.ai_info;
|
||||
if (objp->control_type == CT_AI) {
|
||||
|
@ -1333,9 +1332,8 @@ void ai_path_garbage_collect()
|
|||
validate_all_paths();
|
||||
#endif
|
||||
// Create a list of objects which have paths of length 1 or more.
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(objnum));
|
||||
if ((objp->type == OBJ_ROBOT) && ((objp->control_type == CT_AI)
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|| (objp->control_type == CT_MORPH)
|
||||
|
@ -1344,7 +1342,7 @@ void ai_path_garbage_collect()
|
|||
const auto &aip = objp->ctype.ai_info;
|
||||
if (aip.path_length) {
|
||||
object_list[num_path_objects].path_start = aip.hide_index;
|
||||
object_list[num_path_objects++].objnum = objnum;
|
||||
object_list[num_path_objects++].objnum = objp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1373,9 +1371,8 @@ void ai_path_garbage_collect()
|
|||
{
|
||||
force_dump_ai_objects_all("***** Finish ai_path_garbage_collect *****");
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
const auto &aip = objp->ctype.ai_info;
|
||||
|
||||
if (objp->type == OBJ_ROBOT && objp->control_type == CT_AI)
|
||||
|
@ -1418,9 +1415,8 @@ void maybe_ai_path_garbage_collect(void)
|
|||
// Should be called at the start of each level.
|
||||
void ai_reset_all_paths(void)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptridx(i);
|
||||
if (objp->type == OBJ_ROBOT && objp->control_type == CT_AI)
|
||||
{
|
||||
objp->ctype.ai_info.hide_index = -1;
|
||||
|
@ -1504,17 +1500,15 @@ static void test_create_all_paths(void)
|
|||
|
||||
Point_segs_free_ptr = Point_segs.begin();
|
||||
|
||||
range_for (const auto start_seg, highest_valid(Segments))
|
||||
range_for (const auto &&segp0, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp0 = vcsegptr(static_cast<segnum_t>(start_seg));
|
||||
if (segp0->segnum != segment_none)
|
||||
{
|
||||
range_for (const auto end_seg, highest_valid(Segments, start_seg))
|
||||
range_for (const auto &&segp1, highest_valid(vcsegptridx, segp0))
|
||||
{
|
||||
const auto &&segp1 = vcsegptr(static_cast<segnum_t>(end_seg));
|
||||
if (segp1->segnum != segment_none)
|
||||
{
|
||||
create_path_points(vobjptridx(object_first), start_seg, end_seg, Point_segs_free_ptr, &resultant_length, -1, 0, 0, segment_none);
|
||||
create_path_points(vobjptridx(object_first), segp0, segp1, Point_segs_free_ptr, &resultant_length, -1, 0, 0, segment_none);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -619,9 +619,8 @@ static void draw_automap(automap *am)
|
|||
}
|
||||
}
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&objp = vobjptridx(static_cast<objnum_t>(i));
|
||||
switch( objp->type ) {
|
||||
case OBJ_HOSTAGE:
|
||||
gr_setcolor(am->hostage_color);
|
||||
|
@ -1401,9 +1400,8 @@ void automap_build_edge_list(automap *am, int add_all_edges)
|
|||
|
||||
if (add_all_edges) {
|
||||
// Cheating, add all edges as visited
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptridx(static_cast<segnum_t>(s));
|
||||
#ifdef EDITOR
|
||||
if (segp->segnum != segment_none)
|
||||
#endif
|
||||
|
@ -1413,23 +1411,21 @@ void automap_build_edge_list(automap *am, int add_all_edges)
|
|||
}
|
||||
} else {
|
||||
// Not cheating, add visited edges, and then unvisited edges
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptridx(static_cast<segnum_t>(s));
|
||||
#ifdef EDITOR
|
||||
if (segp->segnum != segment_none)
|
||||
#endif
|
||||
if (Automap_visited[s]) {
|
||||
if (Automap_visited[segp]) {
|
||||
add_segment_edges(am, segp);
|
||||
}
|
||||
}
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptridx(static_cast<segnum_t>(s));
|
||||
#ifdef EDITOR
|
||||
if (segp->segnum != segment_none)
|
||||
#endif
|
||||
if (!Automap_visited[s]) {
|
||||
if (!Automap_visited[segp]) {
|
||||
add_unknown_segment_edges(am, segp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,18 +454,17 @@ void init_controlcen_for_level(void)
|
|||
{
|
||||
objptr_t cntrlcen_objnum = nullptr, boss_objnum = nullptr;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&objp = vobjptridx(i);
|
||||
if (objp->type == OBJ_CNTRLCEN)
|
||||
{
|
||||
if (cntrlcen_objnum == nullptr)
|
||||
cntrlcen_objnum = i;
|
||||
cntrlcen_objnum = objp;
|
||||
}
|
||||
|
||||
if ((objp->type == OBJ_ROBOT) && (Robot_info[get_robot_id(objp)].boss_flag)) {
|
||||
else if (objp->type == OBJ_ROBOT && (Robot_info[get_robot_id(objp)].boss_flag))
|
||||
{
|
||||
if (boss_objnum == nullptr)
|
||||
boss_objnum = i;
|
||||
boss_objnum = objp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -225,13 +225,12 @@ static void write_exit_text(PHYSFS_file *my_file)
|
|||
|
||||
// ---------- Find exit doors ----------
|
||||
count = 0;
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
for (j=0; j<MAX_SIDES_PER_SEGMENT; j++)
|
||||
if (segp->children[j] == segment_exit)
|
||||
{
|
||||
PHYSFSX_printf(my_file, "Segment %3hu, side %i is an exit door.\n", static_cast<uint16_t>(i), j);
|
||||
PHYSFSX_printf(my_file, "Segment %3hu, side %i is an exit door.\n", static_cast<uint16_t>(segp), j);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -321,22 +320,21 @@ static void write_key_text(PHYSFS_file *my_file)
|
|||
blue_count2 = 0;
|
||||
gold_count2 = 0;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_POWERUP)
|
||||
if (get_powerup_id(objp) == POW_KEY_BLUE) {
|
||||
PHYSFSX_printf(my_file, "The BLUE key is object %hu in segment %i\n", static_cast<uint16_t>(i), objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The BLUE key is object %hu in segment %i\n", static_cast<uint16_t>(objp), objp->segnum);
|
||||
blue_count2++;
|
||||
}
|
||||
if (objp->type == OBJ_POWERUP)
|
||||
if (get_powerup_id(objp) == POW_KEY_RED) {
|
||||
PHYSFSX_printf(my_file, "The RED key is object %hu in segment %i\n", static_cast<uint16_t>(i), objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The RED key is object %hu in segment %i\n", static_cast<uint16_t>(objp), objp->segnum);
|
||||
red_count2++;
|
||||
}
|
||||
if (objp->type == OBJ_POWERUP)
|
||||
if (get_powerup_id(objp) == POW_KEY_GOLD) {
|
||||
PHYSFSX_printf(my_file, "The GOLD key is object %hu in segment %i\n", static_cast<uint16_t>(i), objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The GOLD key is object %hu in segment %i\n", static_cast<uint16_t>(objp), objp->segnum);
|
||||
gold_count2++;
|
||||
}
|
||||
|
||||
|
@ -347,15 +345,15 @@ static void write_key_text(PHYSFS_file *my_file)
|
|||
switch (objp->contains_id)
|
||||
{
|
||||
case POW_KEY_BLUE:
|
||||
PHYSFSX_printf(my_file, "The BLUE key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(i), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The BLUE key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(objp), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
blue_count2 += objp->contains_count;
|
||||
break;
|
||||
case POW_KEY_GOLD:
|
||||
PHYSFSX_printf(my_file, "The GOLD key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(i), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The GOLD key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(objp), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
gold_count2 += objp->contains_count;
|
||||
break;
|
||||
case POW_KEY_RED:
|
||||
PHYSFSX_printf(my_file, "The RED key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(i), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
PHYSFSX_printf(my_file, "The RED key is contained in object %hu (a %s %s) in segment %i\n", static_cast<uint16_t>(objp), object_types(objp), Robot_names[get_robot_id(objp)], objp->segnum);
|
||||
red_count2 += objp->contains_count;
|
||||
break;
|
||||
default:
|
||||
|
@ -396,13 +394,12 @@ static void write_control_center_text(PHYSFS_file *my_file)
|
|||
PHYSFSX_printf(my_file, "Control Center stuff:\n");
|
||||
|
||||
count = 0;
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
if (segp->special == SEGMENT_IS_CONTROLCEN)
|
||||
{
|
||||
count++;
|
||||
PHYSFSX_printf(my_file, "Segment %3hu is a control center.\n", static_cast<uint16_t>(i));
|
||||
PHYSFSX_printf(my_file, "Segment %3hu is a control center.\n", static_cast<uint16_t>(segp));
|
||||
count2 = 0;
|
||||
range_for (const auto objp, objects_in(segp))
|
||||
{
|
||||
|
@ -443,10 +440,9 @@ static void write_segment_text(PHYSFS_file *my_file)
|
|||
PHYSFSX_printf(my_file, "-----------------------------------------------------------------------------\n");
|
||||
PHYSFSX_printf(my_file, "Segment stuff:\n");
|
||||
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
PHYSFSX_printf(my_file, "Segment %4hu: ", static_cast<uint16_t>(i));
|
||||
PHYSFSX_printf(my_file, "Segment %4hu: ", static_cast<uint16_t>(segp));
|
||||
if (segp->special != 0)
|
||||
PHYSFSX_printf(my_file, "special = %3i (%s), value = %3i ", segp->special, Special_names[segp->special], segp->value);
|
||||
if (segp->matcen_num != -1)
|
||||
|
@ -454,12 +450,11 @@ static void write_segment_text(PHYSFS_file *my_file)
|
|||
PHYSFSX_printf(my_file, "\n");
|
||||
}
|
||||
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
int depth;
|
||||
|
||||
PHYSFSX_printf(my_file, "Segment %4hu: ", static_cast<uint16_t>(i));
|
||||
PHYSFSX_printf(my_file, "Segment %4hu: ", static_cast<uint16_t>(segp));
|
||||
depth=0;
|
||||
PHYSFSX_printf(my_file, "Objects: ");
|
||||
range_for (const auto objp, objects_in(segp))
|
||||
|
@ -545,9 +540,8 @@ static void write_wall_text(PHYSFS_file *my_file)
|
|||
for (unsigned i=0; i<sizeof(wall_flags)/sizeof(wall_flags[0]); i++)
|
||||
wall_flags[i] = 0;
|
||||
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
for (j=0; j<MAX_SIDES_PER_SEGMENT; j++) {
|
||||
const auto sidep = &segp->sides[j];
|
||||
if (sidep->wall_num != wall_none)
|
||||
|
@ -569,13 +563,12 @@ static void write_player_text(PHYSFS_file *my_file)
|
|||
|
||||
PHYSFSX_printf(my_file, "-----------------------------------------------------------------------------\n");
|
||||
PHYSFSX_printf(my_file, "Players:\n");
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_PLAYER)
|
||||
{
|
||||
num_players++;
|
||||
PHYSFSX_printf(my_file, "Player %2i is object #%3hu in segment #%3i.\n", get_player_id(objp), static_cast<uint16_t>(i), objp->segnum);
|
||||
PHYSFSX_printf(my_file, "Player %2i is object #%3hu in segment #%3i.\n", get_player_id(objp), static_cast<uint16_t>(objp), objp->segnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -739,9 +732,8 @@ static void determine_used_textures_level(int load_level_flag, int shareware_fla
|
|||
load_level(Registered_level_names[level_num]);
|
||||
}
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(segnum));
|
||||
for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++)
|
||||
{
|
||||
const auto sidep = &segp->sides[sidenum];
|
||||
|
@ -802,9 +794,8 @@ static void determine_used_textures_level(int load_level_flag, int shareware_fla
|
|||
|
||||
|
||||
// Process robots.
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(objnum));
|
||||
if (objp->render_type == RT_POLYOBJ) {
|
||||
polymodel *po = &Polygon_models[objp->rtype.pobj_info.model_num];
|
||||
|
||||
|
@ -827,9 +818,8 @@ static void determine_used_textures_level(int load_level_flag, int shareware_fla
|
|||
Ignore_tmap_num2_error = 0;
|
||||
|
||||
// Process walls and segment sides.
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
|
||||
const auto sidep = &segp->sides[sidenum];
|
||||
if (sidep->wall_num != wall_none) {
|
||||
|
@ -994,14 +984,13 @@ static void say_totals(PHYSFS_file *my_file, const char *level_name)
|
|||
min_obj_val = 0x7fff0000;
|
||||
objnum_t min_objnum = object_none;
|
||||
|
||||
range_for (const auto j, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(j));
|
||||
if (!used_objects[j] && objp->type != OBJ_NONE)
|
||||
if (!used_objects[objp] && objp->type != OBJ_NONE)
|
||||
{
|
||||
cur_obj_val = objp->type * 1000 + objp->id;
|
||||
if (cur_obj_val < min_obj_val) {
|
||||
min_objnum = j;
|
||||
min_objnum = objp;
|
||||
min_obj_val = cur_obj_val;
|
||||
}
|
||||
}
|
||||
|
@ -1014,17 +1003,16 @@ static void say_totals(PHYSFS_file *my_file, const char *level_name)
|
|||
objtype = Objects[min_objnum].type;
|
||||
objid = Objects[min_objnum].id;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (!used_objects[i]) {
|
||||
if (!used_objects[objp]) {
|
||||
if ((objp->type == objtype && objp->id == objid) ||
|
||||
(objp->type == objtype && objtype == OBJ_PLAYER) ||
|
||||
(objp->type == objtype && objtype == OBJ_COOP) ||
|
||||
(objp->type == objtype && objtype == OBJ_HOSTAGE)) {
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
total_robots++;
|
||||
used_objects[i] = true;
|
||||
used_objects[objp] = true;
|
||||
objcount++;
|
||||
objects_processed++;
|
||||
}
|
||||
|
|
|
@ -311,9 +311,8 @@ void start_endlevel_sequence()
|
|||
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
// Dematerialize Buddy!
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (Robot_info[get_robot_id(objp)].companion) {
|
||||
object_create_explosion(objp->segnum, objp->pos, F1_0*7/2, VCLIP_POWERUP_DISAPPEARANCE );
|
||||
|
@ -1533,13 +1532,12 @@ try_again:
|
|||
//children == -2
|
||||
|
||||
exit_segnum = segment_none;
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(segnum));
|
||||
for (int sidenum=0;sidenum<6;sidenum++)
|
||||
if (segp->children[sidenum] == segment_exit)
|
||||
{
|
||||
exit_segnum = segnum;
|
||||
exit_segnum = segp;
|
||||
exit_side = sidenum;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -104,10 +104,8 @@ static objptridx_t object_create_explosion_sub(const objptridx_t objp, const vse
|
|||
fix damage;
|
||||
// -- now legal for badass explosions on a wall. Assert(objp != NULL);
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&obj0p, highest_valid(vobjptridx))
|
||||
{
|
||||
auto obj0p = vobjptridx(i);
|
||||
|
||||
// Weapons used to be affected by badass explosions, but this introduces serious problems.
|
||||
// When a smart bomb blows up, if one of its children goes right towards a nearby wall, it will
|
||||
// blow up, blowing up all the children. So I remove it. MK, 09/11/94
|
||||
|
|
|
@ -422,9 +422,8 @@ static void robotmaker_proc( FuelCenter * robotcen )
|
|||
int my_station_num = robotcen-Station;
|
||||
|
||||
// Make sure this robotmaker hasn't put out its max without having any of them killed.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if ((objp->matcen_creator ^ 0x80) == my_station_num)
|
||||
count++;
|
||||
|
|
|
@ -1313,9 +1313,8 @@ array<int, 2> Coop_view_player{{-1,-1}};
|
|||
//returns ptr to escort robot, or NULL
|
||||
objptridx_t find_escort()
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
auto o = vobjptridx(i);
|
||||
if (o->type == OBJ_ROBOT && Robot_info[get_robot_id(o)].companion)
|
||||
return objptridx_t(o);
|
||||
}
|
||||
|
@ -1549,9 +1548,8 @@ void GameProcessFrame(void)
|
|||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
void compute_slide_segs()
|
||||
{
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
uint8_t slide_textures = 0;
|
||||
for (int sidenum=0;sidenum<6;sidenum++) {
|
||||
const auto &side = segp->sides[sidenum];
|
||||
|
@ -1587,9 +1585,8 @@ static void update_uv(array<uvl, 4> &uvls, uvl &i, fix a)
|
|||
// -----------------------------------------------------------------------------
|
||||
static void slide_textures(void)
|
||||
{
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
if (const auto slide_seg = segp->slide_textures)
|
||||
{
|
||||
for (int sidenum=0;sidenum<6;sidenum++) {
|
||||
|
@ -1625,7 +1622,7 @@ static void flicker_lights()
|
|||
range_for (auto &rf, partial_range(Flickering_lights, Num_flickering_lights))
|
||||
{
|
||||
auto f = &rf;
|
||||
segment *segp = &Segments[f->segnum];
|
||||
const auto &&segp = vcsegptr(f->segnum);
|
||||
|
||||
//make sure this is actually a light
|
||||
if (! (WALL_IS_DOORWAY(segp, f->sidenum) & WID_RENDER_FLAG))
|
||||
|
@ -1837,13 +1834,12 @@ static int mark_player_path_to_segment(segnum_t segnum)
|
|||
int create_special_path(void)
|
||||
{
|
||||
// ---------- Find exit doors ----------
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
for (int j=0; j<MAX_SIDES_PER_SEGMENT; j++)
|
||||
if (segp->children[j] == segment_exit)
|
||||
{
|
||||
return mark_player_path_to_segment(i);
|
||||
return mark_player_path_to_segment(segp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1073,9 +1073,8 @@ static void kill_all_robots(void)
|
|||
//int boss_index = -1;
|
||||
|
||||
// Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
{
|
||||
if (!Robot_info[get_robot_id(objp)].companion && !Robot_info[get_robot_id(objp)].boss_flag) {
|
||||
|
@ -1094,9 +1093,8 @@ static void kill_all_robots(void)
|
|||
|
||||
// Toast the buddy if nothing else toasted!
|
||||
if (dead_count == 0)
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (Robot_info[get_robot_id(objp)].companion) {
|
||||
objp->flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
|
||||
|
@ -1119,9 +1117,8 @@ static void kill_and_so_forth(void)
|
|||
{
|
||||
HUD_init_message_literal(HM_DEFAULT, "Killing, awarding, etc.!");
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto o = vobjptridx(i);
|
||||
switch (o->type) {
|
||||
case OBJ_ROBOT:
|
||||
o->flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
|
||||
|
@ -1159,9 +1156,8 @@ static void kill_all_snipers(void)
|
|||
int dead_count=0;
|
||||
|
||||
// Kill all snipers.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (objp->ctype.ai_info.behavior == ai_behavior::AIB_SNIPE)
|
||||
{
|
||||
|
@ -1177,9 +1173,8 @@ static void kill_thief(void) __attribute_used;
|
|||
static void kill_thief(void)
|
||||
{
|
||||
// Kill thief.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (Robot_info[get_robot_id(objp)].thief)
|
||||
{
|
||||
|
@ -1193,9 +1188,8 @@ static void kill_buddy(void) __attribute_used;
|
|||
static void kill_buddy(void)
|
||||
{
|
||||
// Kill buddy.
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (Robot_info[get_robot_id(objp)].companion)
|
||||
{
|
||||
|
|
|
@ -704,9 +704,8 @@ int load_mine_data(PHYSFS_file *LoadFile)
|
|||
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
if (mine_top_fileinfo.fileinfo_version >= 20)
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(i));
|
||||
segment2_read(segp, LoadFile);
|
||||
fuelcen_activate(segp, segp->special);
|
||||
}
|
||||
|
|
|
@ -481,9 +481,8 @@ static bool choose_missile_viewer()
|
|||
/* Find new missile */
|
||||
objptridx_t local_player_missile = object_none, other_player_missile = object_none;
|
||||
const auto game_mode = Game_mode;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto o = vobjptridx(i);
|
||||
if (o->type != OBJ_WEAPON)
|
||||
continue;
|
||||
if (o->ctype.laser_info.parent_type != OBJ_PLAYER)
|
||||
|
|
|
@ -1108,13 +1108,12 @@ static int load_game_data(PHYSFS_file *LoadFile)
|
|||
if (game_top_fileinfo_version < 17) {
|
||||
int wallnum;
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(segnum));
|
||||
for (int sidenum=0;sidenum<6;sidenum++)
|
||||
if ((wallnum = segp->sides[sidenum].wall_num) != -1)
|
||||
{
|
||||
Walls[wallnum].segnum = segnum;
|
||||
Walls[wallnum].segnum = segp;
|
||||
Walls[wallnum].sidenum = sidenum;
|
||||
}
|
||||
}
|
||||
|
@ -1569,9 +1568,8 @@ static int save_game_data(PHYSFS_file *SaveFile)
|
|||
//==================== SAVE OBJECT INFO ===========================
|
||||
|
||||
object_offset = PHYSFS_tell(SaveFile);
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
write_object(objp, game_top_fileinfo_version, SaveFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -470,9 +470,8 @@ int check_segment_connections(void)
|
|||
{
|
||||
int errors=0;
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&seg, highest_valid(vcsegptridx))
|
||||
{
|
||||
auto seg = vcsegptridx(segnum);
|
||||
for (int sidenum=0;sidenum<6;sidenum++) {
|
||||
const auto v = create_abs_vertex_lists(seg, sidenum);
|
||||
const auto &num_faces = v.first;
|
||||
|
@ -625,9 +624,8 @@ segptridx_t find_point_seg(const vms_vector &p,const segptridx_t segnum)
|
|||
// slowing down lighting, and in about 98% of cases, it would just return -1 anyway.
|
||||
// Matt: This really should be fixed, though. We're probably screwing up our lighting in a few places.
|
||||
if (!Doing_lighting_hack_flag) {
|
||||
range_for (const auto newseg, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto segp = vsegptridx(newseg);
|
||||
if (get_seg_masks(p, segp, 0).centermask == 0)
|
||||
return segp;
|
||||
}
|
||||
|
@ -1490,9 +1488,8 @@ void validate_segment(const vsegptridx_t sp)
|
|||
// For all used segments (number <= Highest_segment_index), segnum field must be != -1.
|
||||
void validate_segment_all(void)
|
||||
{
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptridx(static_cast<segnum_t>(s));
|
||||
#ifdef EDITOR
|
||||
if (segp->segnum != segment_none)
|
||||
#endif
|
||||
|
@ -1696,9 +1693,8 @@ int add_light(const vsegptridx_t segnum, sidenum_fast_t sidenum)
|
|||
// Parse the Light_subtracted array, turning on or off all lights.
|
||||
void apply_all_changed_light(void)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto segp = vsegptridx(i);
|
||||
for (int j=0; j<MAX_SIDES_PER_SEGMENT; j++)
|
||||
if (segp->light_subtracted & (1 << j))
|
||||
change_light(segp, j, -1);
|
||||
|
@ -1740,9 +1736,8 @@ void apply_all_changed_light(void)
|
|||
// to change the status of static light in the mine.
|
||||
void clear_light_subtracted(void)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
segp->light_subtracted = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1793,9 +1788,8 @@ void set_ambient_sound_flags()
|
|||
// Now, all segments containing ambient lava or water sound makers are flagged.
|
||||
// Additionally flag all segments which are within range of them.
|
||||
// Mark all segments which are sources of the sound.
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
range_for (auto &s, sound_textures)
|
||||
{
|
||||
for (int j=0; j<MAX_SIDES_PER_SEGMENT; j++) {
|
||||
|
@ -1804,12 +1798,12 @@ void set_ambient_sound_flags()
|
|||
if (!(texture_flags & s.texture_flag))
|
||||
continue;
|
||||
if (!IS_CHILD(segp->children[j]) || (sidep->wall_num != wall_none)) {
|
||||
ambient_mark_bfs(vsegptridx(i), marked_segs, AMBIENT_SEGMENT_DEPTH, s.sound_flag);
|
||||
ambient_mark_bfs(segp, marked_segs, AMBIENT_SEGMENT_DEPTH, s.sound_flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
segp->s2_flags = (segp->s2_flags & ~(S2F_AMBIENT_LAVA | S2F_AMBIENT_WATER)) | marked_segs[i];
|
||||
segp->s2_flags = (segp->s2_flags & ~(S2F_AMBIENT_LAVA | S2F_AMBIENT_WATER)) | marked_segs[segp];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -177,9 +177,8 @@ static int count_number_of_robots()
|
|||
{
|
||||
int robot_count;
|
||||
robot_count = 0;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
robot_count++;
|
||||
}
|
||||
|
@ -192,9 +191,8 @@ static int count_number_of_hostages()
|
|||
{
|
||||
int count;
|
||||
count = 0;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_HOSTAGE)
|
||||
count++;
|
||||
}
|
||||
|
@ -212,9 +210,8 @@ static void gameseq_init_network_players()
|
|||
ConsoleObject = &Objects[0];
|
||||
k = 0;
|
||||
j = 0;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto o = vobjptridx(i);
|
||||
if (( o->type==OBJ_PLAYER ) || (o->type == OBJ_GHOST) || (o->type == OBJ_COOP))
|
||||
{
|
||||
if ( (!(Game_mode & GM_MULTI_COOP) && ((o->type == OBJ_PLAYER)||(o->type==OBJ_GHOST))) ||
|
||||
|
@ -224,7 +221,7 @@ static void gameseq_init_network_players()
|
|||
Player_init[k].pos = o->pos;
|
||||
Player_init[k].orient = o->orient;
|
||||
Player_init[k].segnum = o->segnum;
|
||||
Players[k].objnum = i;
|
||||
Players[k].objnum = o;
|
||||
set_player_id(o, k);
|
||||
k++;
|
||||
}
|
||||
|
@ -546,9 +543,8 @@ static void set_sound_sources()
|
|||
Dont_start_sound_objects = 1;
|
||||
#endif
|
||||
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&seg, highest_valid(vcsegptridx))
|
||||
{
|
||||
const auto &&seg = vcsegptridx(static_cast<segnum_t>(segnum));
|
||||
for (sidenum=0;sidenum<MAX_SIDES_PER_SEGMENT;sidenum++) {
|
||||
int tm,ec,sn;
|
||||
|
||||
|
@ -569,7 +565,7 @@ static void set_sound_sources()
|
|||
//does travel through wall, add sound for lower-numbered
|
||||
//segment.
|
||||
|
||||
if (IS_CHILD(csegnum) && csegnum < segnum) {
|
||||
if (IS_CHILD(csegnum) && csegnum < seg) {
|
||||
if (wid & (WID_FLY_FLAG|WID_RENDPAST_FLAG)) {
|
||||
const auto &&csegp = vcsegptr(seg->children[sidenum]);
|
||||
auto csidenum = find_connect_side(seg, csegp);
|
||||
|
@ -581,7 +577,7 @@ static void set_sound_sources()
|
|||
#endif
|
||||
|
||||
const auto pnt = compute_center_point_on_side(seg,sidenum);
|
||||
digi_link_sound_to_pos(sn,segnum,sidenum,pnt,1, F1_0/2);
|
||||
digi_link_sound_to_pos(sn, seg, sidenum, pnt, 1, F1_0/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1679,9 +1675,8 @@ namespace dsx {
|
|||
|
||||
static void filter_objects_from_level()
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto objp = vobjptridx(i);
|
||||
if (objp->type==OBJ_POWERUP)
|
||||
{
|
||||
const auto powerup_id = get_powerup_id(objp);
|
||||
|
@ -1943,9 +1938,8 @@ void copy_defaults_to_robot(const vobjptr_t objp)
|
|||
// This function should be called at level load time.
|
||||
static void copy_defaults_to_robot_all(void)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
copy_defaults_to_robot(objp);
|
||||
}
|
||||
|
|
|
@ -1145,11 +1145,10 @@ objptridx_t find_homing_object_complete(const vms_vector &curpos, const vobjptri
|
|||
#endif
|
||||
|
||||
objptridx_t best_objnum = object_none;
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&curobjp, highest_valid(vobjptridx))
|
||||
{
|
||||
int is_proximity = 0;
|
||||
fix dot;
|
||||
auto curobjp = vobjptridx(objnum);
|
||||
|
||||
if ((curobjp->type != track_obj_type1) && (curobjp->type != track_obj_type2))
|
||||
{
|
||||
|
@ -1164,7 +1163,7 @@ objptridx_t find_homing_object_complete(const vms_vector &curpos, const vobjptri
|
|||
continue;
|
||||
}
|
||||
|
||||
if (objnum == tracker->ctype.laser_info.parent_num) // Don't track shooter
|
||||
if (curobjp == tracker->ctype.laser_info.parent_num) // Don't track shooter
|
||||
continue;
|
||||
|
||||
// Don't track cloaked players.
|
||||
|
@ -2109,11 +2108,9 @@ static void create_smart_children(const vobjptridx_t objp, const uint_fast32_t n
|
|||
if (Game_mode & GM_MULTI)
|
||||
d_srand(8321L);
|
||||
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&curobjp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto &curobjp = vcobjptr(static_cast<objnum_t>(objnum));
|
||||
|
||||
if (((curobjp->type == OBJ_ROBOT && !curobjp->ctype.ai_info.CLOAKED) || curobjp->type == OBJ_PLAYER) && objnum != parent.num)
|
||||
if (((curobjp->type == OBJ_ROBOT && !curobjp->ctype.ai_info.CLOAKED) || curobjp->type == OBJ_PLAYER) && curobjp != parent.num)
|
||||
{
|
||||
if (curobjp->type == OBJ_PLAYER)
|
||||
{
|
||||
|
@ -2146,7 +2143,7 @@ static void create_smart_children(const vobjptridx_t objp, const uint_fast32_t n
|
|||
oovis = object_to_object_visibility(objp, curobjp, FQ_TRANSWALL);
|
||||
|
||||
if (oovis) {
|
||||
objlist[numobjs] = objnum;
|
||||
objlist[numobjs] = curobjp;
|
||||
numobjs++;
|
||||
if (numobjs >= MAX_OBJDISTS) {
|
||||
numobjs = MAX_OBJDISTS;
|
||||
|
|
|
@ -523,13 +523,12 @@ void set_dynamic_light(render_state_t &rstate)
|
|||
|
||||
cast_muzzle_flash_light(n_render_vertices, render_vertices, vert_segnum_list);
|
||||
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&obj, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&obj = vobjptridx(static_cast<objnum_t>(objnum));
|
||||
const auto &&obj_light_emission = compute_light_emission(obj);
|
||||
|
||||
if (((obj_light_emission.r+obj_light_emission.g+obj_light_emission.b)/3) > 0)
|
||||
apply_light(obj_light_emission, obj->segnum, obj->pos, n_render_vertices, render_vertices, vert_segnum_list, objnum);
|
||||
apply_light(obj_light_emission, obj->segnum, obj->pos, n_render_vertices, render_vertices, vert_segnum_list, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2715,9 +2715,8 @@ void multi_powcap_count_powerups_in_mine(void)
|
|||
void powerup_cap_state::recount()
|
||||
{
|
||||
m_powerups = {};
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&obj, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&obj = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (obj->type == OBJ_POWERUP)
|
||||
{
|
||||
inc_powerup_current(get_powerup_id(obj));
|
||||
|
@ -3532,9 +3531,8 @@ void multi_prep_level(void)
|
|||
unsigned inv_remaining = (AllowedItems & NETFLAG_DOINVUL) ? MAX_ALLOWED_INVULNERABILITY : 0;
|
||||
unsigned cloak_remaining = (AllowedItems & NETFLAG_DOCLOAK) ? MAX_ALLOWED_CLOAK : 0;
|
||||
update_item_state duplicates;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto o = vobjptridx(i);
|
||||
if ((o->type == OBJ_HOSTAGE) && !(Game_mode & GM_MULTI_COOP))
|
||||
{
|
||||
const auto objnum = obj_create(OBJ_POWERUP, POW_SHIELD_BOOST, o->segnum, o->pos, &vmd_identity_matrix, Powerup_info[POW_SHIELD_BOOST].size, CT_POWERUP, MT_PHYSICS, RT_POWERUP);
|
||||
|
@ -3634,9 +3632,8 @@ static void apply_segment_goal_texture(const vsegptr_t seg, ubyte team_mask)
|
|||
|
||||
void multi_apply_goal_textures()
|
||||
{
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&seg, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&seg = vsegptr(static_cast<segnum_t>(i));
|
||||
uint8_t team_mask;
|
||||
if (seg->special==SEGMENT_IS_GOAL_BLUE)
|
||||
{
|
||||
|
@ -3696,9 +3693,8 @@ int multi_delete_extra_objects()
|
|||
// This function also prints the total number of available multiplayer
|
||||
// positions in this level, even though this should always be 8 or more!
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto objp = vobjptridx(i);
|
||||
if ((objp->type==OBJ_PLAYER) || (objp->type==OBJ_GHOST))
|
||||
nnp++;
|
||||
else if ((objp->type==OBJ_ROBOT) && (Game_mode & GM_MULTI_ROBOTS))
|
||||
|
|
|
@ -202,9 +202,8 @@ multi_strip_robots(int playernum)
|
|||
multi_delete_controlled_robot(r);
|
||||
}
|
||||
|
||||
range_for (const auto i, highest_valid(Objects, 1))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr, 1))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT && objp->ctype.ai_info.REMOTE_OWNER == playernum)
|
||||
{
|
||||
Assert(objp->control_type == CT_AI || objp->control_type == CT_NONE || objp->control_type == CT_MORPH);
|
||||
|
@ -402,16 +401,15 @@ void multi_send_thief_frame()
|
|||
if (!(Game_mode & GM_MULTI_ROBOTS))
|
||||
return;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
{
|
||||
if (robot_is_thief(&Robot_info[get_robot_id(objp)]))
|
||||
{
|
||||
if ((multi_i_am_master() && objp->ctype.ai_info.REMOTE_OWNER == -1) || objp->ctype.ai_info.REMOTE_OWNER == Player_num)
|
||||
{
|
||||
multi_send_robot_position_sub(i,1);
|
||||
multi_send_robot_position_sub(objp,1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1768,9 +1768,8 @@ static void net_udp_process_monitor_vector(uint32_t vector)
|
|||
{
|
||||
if (!vector)
|
||||
return;
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&seg, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&seg = vsegptr(static_cast<segnum_t>(i));
|
||||
int tm, ec, bm;
|
||||
range_for (auto &j, seg->sides)
|
||||
{
|
||||
|
@ -1838,9 +1837,8 @@ static int net_udp_create_monitor_vector(void)
|
|||
}
|
||||
}
|
||||
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&seg, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&seg = vsegptr(static_cast<segnum_t>(i));
|
||||
int tm, ec;
|
||||
range_for (auto &j, seg->sides)
|
||||
{
|
||||
|
@ -2014,9 +2012,8 @@ static int net_udp_verify_objects(int remote, int local)
|
|||
if ((remote-local) > 10)
|
||||
return(2);
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_PLAYER || objp->type == OBJ_GHOST)
|
||||
nplayers++;
|
||||
}
|
||||
|
@ -5379,11 +5376,10 @@ void net_udp_read_pdata_packet(UDP_frame_info *pd)
|
|||
static void net_udp_send_smash_lights (const playernum_t pnum)
|
||||
{
|
||||
// send the lights that have been blown out
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
if (segp->light_subtracted)
|
||||
multi_send_light_specific(pnum, i, segp->light_subtracted);
|
||||
multi_send_light_specific(pnum, segp, segp->light_subtracted);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -305,9 +305,8 @@ static typename tt::enable_if<tt::is_integral<T>::value, int>::type newdemo_read
|
|||
|
||||
cobjptridx_t newdemo_find_object(object_signature_t signature)
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptridx))
|
||||
{
|
||||
const auto objp = vcobjptridx(i);
|
||||
if ( (objp->type != OBJ_NONE) && (objp->signature == signature))
|
||||
return objp;
|
||||
}
|
||||
|
@ -1891,9 +1890,8 @@ static int newdemo_read_frame_information(int rewrite)
|
|||
done = 0;
|
||||
|
||||
if (Newdemo_vcr_state != ND_STATE_PAUSED)
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
segp->objects = object_none;
|
||||
}
|
||||
|
||||
|
@ -3391,9 +3389,8 @@ static void interpolate_frame(fix d_play, fix d_recorded)
|
|||
if (InterpolStep <= 0)
|
||||
{
|
||||
range_for (auto &i, partial_range(cur_objs, 1 + num_cur_objs)) {
|
||||
range_for (const auto j, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(j));
|
||||
if (i.signature == objp->signature) {
|
||||
sbyte render_type = i.render_type;
|
||||
fix delta_x, delta_y, delta_z;
|
||||
|
@ -3601,9 +3598,8 @@ void newdemo_playback_one_frame()
|
|||
// interpolated position and orientation can be preserved.
|
||||
|
||||
range_for (auto &i, partial_range(cur_objs, 1 + num_objs)) {
|
||||
range_for (const auto j, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(j));
|
||||
if (i.signature == objp->signature) {
|
||||
objp->orient = i.orient;
|
||||
objp->pos = i.pos;
|
||||
|
|
|
@ -119,7 +119,7 @@ void object_goto_next_viewer()
|
|||
objnum_t start_obj;
|
||||
start_obj = Viewer - Objects; //get viewer object number
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&i, highest_valid(vcobjptr))
|
||||
{
|
||||
(void)i;
|
||||
start_obj++;
|
||||
|
@ -140,9 +140,8 @@ void object_goto_next_viewer()
|
|||
|
||||
objptridx_t obj_find_first_of_type(int type)
|
||||
{
|
||||
range_for (const auto o, highest_valid(Objects))
|
||||
range_for (const auto &&i, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto i = vobjptridx(o);
|
||||
if (i->type==type)
|
||||
return i;
|
||||
}
|
||||
|
@ -905,7 +904,7 @@ object_signature_t obj_get_signature()
|
|||
{
|
||||
static short sig = 0; // Yes! Short! a) We do not need higher values b) the demo system only stores shorts
|
||||
uint_fast32_t lsig = sig;
|
||||
for (const auto &range = highest_valid(Objects);;)
|
||||
for (const auto &&range = highest_valid(vcobjptridx);;)
|
||||
{
|
||||
if (unlikely(lsig == std::numeric_limits<decltype(sig)>::max()))
|
||||
lsig = 0;
|
||||
|
@ -950,9 +949,8 @@ objptridx_t obj_allocate()
|
|||
|
||||
{
|
||||
Unused_object_slots=0;
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type == OBJ_NONE)
|
||||
Unused_object_slots++;
|
||||
}
|
||||
|
@ -996,9 +994,8 @@ static void free_object_slots(uint_fast32_t num_used)
|
|||
if (MAX_OBJECTS - num_already_free < num_used)
|
||||
return;
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->flags & OF_SHOULD_BE_DEAD)
|
||||
{
|
||||
num_already_free++;
|
||||
|
@ -1555,9 +1552,8 @@ static void obj_delete_all_that_should_be_dead()
|
|||
objnum_t local_dead_player_object=object_none;
|
||||
|
||||
// Move all objects
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
auto objp = vobjptridx(i);
|
||||
if ((objp->type!=OBJ_NONE) && (objp->flags&OF_SHOULD_BE_DEAD) ) {
|
||||
Assert(!(objp->type==OBJ_FIREBALL && objp->ctype.expl_info.delete_time!=-1));
|
||||
if (objp->type==OBJ_PLAYER) {
|
||||
|
@ -1588,15 +1584,13 @@ void obj_relink(const vobjptridx_t objnum,const vsegptridx_t newsegnum)
|
|||
// for getting out of messed up linking situations (i.e. caused by demo playback)
|
||||
void obj_relink_all(void)
|
||||
{
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
segp->objects = object_none;
|
||||
}
|
||||
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&obj, highest_valid(vobjptridx))
|
||||
{
|
||||
auto obj = vobjptridx(objnum);
|
||||
if (obj->type != OBJ_NONE)
|
||||
{
|
||||
auto segnum = exchange(obj->segnum, segment_none);
|
||||
|
@ -1871,9 +1865,8 @@ void object_move_all()
|
|||
ConsoleObject->mtype.phys_info.flags &= ~PF_LEVELLING;
|
||||
|
||||
// Move all objects
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto objp = vobjptridx(i);
|
||||
if ( (objp->type != OBJ_NONE) && (!(objp->flags&OF_SHOULD_BE_DEAD)) ) {
|
||||
object_move_one( objp );
|
||||
}
|
||||
|
@ -1991,9 +1984,8 @@ void set_powerup_id(object &o, powerup_type_t id)
|
|||
//go through all objects and make sure they have the correct segment numbers
|
||||
void fix_object_segs()
|
||||
{
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&o, highest_valid(vobjptridx))
|
||||
{
|
||||
const auto o = vobjptridx(i);
|
||||
if (o->type != OBJ_NONE)
|
||||
if (update_object_seg(o) == 0) {
|
||||
const auto pos = o->pos;
|
||||
|
@ -2053,9 +2045,8 @@ static int object_is_clearable_weapon(const vcobjptr_t obj, int clear_all)
|
|||
//if clear_all is set, clear even proximity bombs
|
||||
void clear_transient_objects(int clear_all)
|
||||
{
|
||||
range_for (const auto objnum, highest_valid(Objects))
|
||||
range_for (const auto &&obj, highest_valid(vobjptridx))
|
||||
{
|
||||
auto obj = vobjptridx(objnum);
|
||||
if (object_is_clearable_weapon(obj, clear_all) ||
|
||||
obj->type == OBJ_FIREBALL ||
|
||||
obj->type == OBJ_DEBRIS ||
|
||||
|
|
|
@ -322,9 +322,8 @@ void paging_touch_all()
|
|||
#if defined(DXX_BUILD_DESCENT_I)
|
||||
show_boxed_message(TXT_LOADING, 0);
|
||||
#endif
|
||||
range_for (const auto s, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(s));
|
||||
paging_touch_segment(segp);
|
||||
}
|
||||
paging_touch_walls();
|
||||
|
|
|
@ -997,9 +997,8 @@ int state_save_all_sub(const char *filename, const char *desc)
|
|||
#endif
|
||||
|
||||
//Finish all morph objects
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
if (objp->type != OBJ_NONE && objp->render_type == RT_MORPH)
|
||||
{
|
||||
morph_data *md;
|
||||
|
@ -1023,9 +1022,8 @@ int state_save_all_sub(const char *filename, const char *desc)
|
|||
i = Highest_object_index+1;
|
||||
PHYSFS_write(fp, &i, sizeof(int), 1);
|
||||
//PHYSFS_write(fp, Objects, sizeof(object), i);
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vcobjptr))
|
||||
{
|
||||
const auto &&objp = vcobjptr(static_cast<objnum_t>(i));
|
||||
object_rw obj_rw;
|
||||
state_object_to_object_rw(objp, &obj_rw);
|
||||
PHYSFS_write(fp, &obj_rw, sizeof(obj_rw), 1);
|
||||
|
@ -1071,9 +1069,8 @@ int state_save_all_sub(const char *filename, const char *desc)
|
|||
trigger_write(fp, t);
|
||||
|
||||
//Save tmap info
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
range_for (const auto &j, segp->sides)
|
||||
segment_side_wall_tmap_write(fp, j);
|
||||
}
|
||||
|
@ -1161,9 +1158,8 @@ int state_save_all_sub(const char *filename, const char *desc)
|
|||
PHYSFS_write(fp, &PaletteBlueAdd, sizeof(int), 1);
|
||||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vcsegptr))
|
||||
{
|
||||
const auto &&segp = vcsegptr(static_cast<segnum_t>(i));
|
||||
PHYSFSX_writeU8(fp, segp->light_subtracted);
|
||||
}
|
||||
}
|
||||
|
@ -1478,9 +1474,8 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
Do_appearance_effect = 0; // Don't do this for middle o' game stuff.
|
||||
|
||||
//Clear out all the objects from the lvl file
|
||||
range_for (const auto segnum, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(segnum));
|
||||
segp->objects = object_none;
|
||||
}
|
||||
reset_objects(1);
|
||||
|
@ -1489,18 +1484,16 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
i = PHYSFSX_readSXE32(fp, swap);
|
||||
Highest_object_index = i-1;
|
||||
//object_read_n_swap(Objects, i, swap, fp);
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&objp, highest_valid(vobjptr))
|
||||
{
|
||||
const auto &&objp = vobjptr(static_cast<objnum_t>(i));
|
||||
object_rw obj_rw;
|
||||
PHYSFS_read(fp, &obj_rw, sizeof(obj_rw), 1);
|
||||
object_rw_swap(&obj_rw, swap);
|
||||
state_object_rw_to_object(&obj_rw, objp);
|
||||
}
|
||||
|
||||
range_for (const auto i, highest_valid(Objects))
|
||||
range_for (const auto &&obj, highest_valid(vobjptridx))
|
||||
{
|
||||
auto obj = vobjptridx(i);
|
||||
obj->rtype.pobj_info.alt_textures = -1;
|
||||
auto segnum = exchange(obj->segnum, segment_none);
|
||||
obj->next = obj->prev = object_none;
|
||||
|
@ -1576,13 +1569,12 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
trigger_read(fp, t);
|
||||
|
||||
//Restore tmap info (to temp values so we can use compiled-in tmap info to compute static_light
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
for (j=0; j<6; j++ ) {
|
||||
segp->sides[j].wall_num = PHYSFSX_readSXE16(fp, swap);
|
||||
TempTmapNum[i][j] = PHYSFSX_readSXE16(fp, swap);
|
||||
TempTmapNum2[i][j] = PHYSFSX_readSXE16(fp, swap);
|
||||
TempTmapNum[segp][j] = PHYSFSX_readSXE16(fp, swap);
|
||||
TempTmapNum2[segp][j] = PHYSFSX_readSXE16(fp, swap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1713,9 +1705,8 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
if (version >= 16) {
|
||||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
PHYSFS_read(fp, &segp->light_subtracted, sizeof(segp->light_subtracted), 1);
|
||||
}
|
||||
}
|
||||
|
@ -1729,9 +1720,8 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
}
|
||||
apply_all_changed_light();
|
||||
} else {
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptr))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
segp->light_subtracted = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1755,12 +1745,11 @@ int state_restore_all_sub(const char *filename, const secret_restore secret)
|
|||
#endif
|
||||
|
||||
// static_light should now be computed - now actually set tmap info
|
||||
range_for (const auto i, highest_valid(Segments))
|
||||
range_for (const auto &&segp, highest_valid(vsegptridx))
|
||||
{
|
||||
const auto &&segp = vsegptr(static_cast<segnum_t>(i));
|
||||
for (j=0; j<6; j++ ) {
|
||||
segp->sides[j].tmap_num = TempTmapNum[i][j];
|
||||
segp->sides[j].tmap_num2 = TempTmapNum2[i][j];
|
||||
segp->sides[j].tmap_num = TempTmapNum[segp][j];
|
||||
segp->sides[j].tmap_num2 = TempTmapNum2[segp][j];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1139,11 +1139,10 @@ void process_super_mines_frame(void)
|
|||
continue;
|
||||
const auto parent_num = io->ctype.laser_info.parent_num;
|
||||
const auto &bombpos = io->pos;
|
||||
range_for (const auto j, highest_valid(Objects))
|
||||
range_for (const auto &&jo, highest_valid(vobjptridx))
|
||||
{
|
||||
if (unlikely(j == parent_num))
|
||||
if (unlikely(jo == parent_num))
|
||||
continue;
|
||||
const auto jo = vobjptridx(j);
|
||||
if (jo->type != OBJ_PLAYER && jo->type != OBJ_ROBOT)
|
||||
continue;
|
||||
const auto dist_squared = vm_vec_dist2(bombpos, jo->pos);
|
||||
|
|
Loading…
Reference in a new issue