diff --git a/common/main/object.h b/common/main/object.h index 0e3767845..0726b5b1e 100644 --- a/common/main/object.h +++ b/common/main/object.h @@ -41,6 +41,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "valptridx.h" #include #include +#include "compiler-type_traits.h" struct segment; @@ -600,7 +601,17 @@ typedef array collision_outer_array_t extern const collision_outer_array_t CollisionResult; // ie CollisionResult[a][b]== what happens to a when it collides with b -struct object_array_t : public array {}; +struct object_array_t : public array +{ + typedef array array_t; + template + typename tt::enable_if::value, reference>::type operator[](T n) + { + return array_t::operator[](n); + } + template + typename tt::enable_if::value, reference>::type operator[](T) const DXX_CXX11_EXPLICIT_DELETE; +}; extern object_array_t Objects; DEFINE_VALPTRIDX_SUBTYPE(objptridx, object, int16_t, Objects); diff --git a/similar/main/fireball.cpp b/similar/main/fireball.cpp index 14b64c831..4816e1b41 100644 --- a/similar/main/fireball.cpp +++ b/similar/main/fireball.cpp @@ -107,7 +107,7 @@ static objptridx_t object_create_explosion_sub(objptridx_t objp, short segnum, v // blow up, blowing up all the children. So I remove it. MK, 09/11/94 if (parent != object_none) - if ((Objects[parent].type != OBJ_ROBOT) || (get_robot_id(&Objects[parent]) != obj0p->id)) + if ((parent->type != OBJ_ROBOT) || (get_robot_id(parent) != obj0p->id)) parent_check = 1; #if defined(DXX_BUILD_DESCENT_I) @@ -238,7 +238,7 @@ static objptridx_t object_create_explosion_sub(objptridx_t objp, short segnum, v } vforce2 = vforce; if (parent != object_none ) { - killer = &Objects[parent]; + killer = parent; if (killer != ConsoleObject) // if someone else whacks you, cut force by 2x vforce2.x /= 2; vforce2.y /= 2; vforce2.z /= 2; } diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index e23ad4573..6d9d4d572 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -2931,7 +2931,7 @@ void multi_send_kill(objptridx_t objnum) int killer_objnum; int count = 0; - Assert(get_player_id(&Objects[objnum]) == Player_num); + Assert(get_player_id(objnum) == Player_num); killer_objnum = Players[Player_num].killer_objnum; count += 1; @@ -2976,19 +2976,19 @@ void multi_send_remobj(objptridx_t objnum) sbyte obj_owner; short remote_objnum; - if (Objects[objnum].type==OBJ_POWERUP && (Game_mode & GM_NETWORK)) + if (objnum->type==OBJ_POWERUP && (Game_mode & GM_NETWORK)) { - if (multi_powerup_is_4pack (get_powerup_id(&Objects[objnum]))) + if (multi_powerup_is_4pack (get_powerup_id(objnum))) { - if (PowerupsInMine[Objects[objnum].id-1]-4<0) - PowerupsInMine[Objects[objnum].id-1]=0; + if (PowerupsInMine[objnum->id-1]-4<0) + PowerupsInMine[objnum->id-1]=0; else - PowerupsInMine[Objects[objnum].id-1]-=4; + PowerupsInMine[objnum->id-1]-=4; } else { - if (PowerupsInMine[get_powerup_id(&Objects[objnum])]>0) - PowerupsInMine[get_powerup_id(&Objects[objnum])]--; + if (PowerupsInMine[get_powerup_id(objnum)]>0) + PowerupsInMine[get_powerup_id(objnum)]--; } }