Require integral index to Objects[]
This commit is contained in:
parent
229dbe1b47
commit
08546489c3
|
@ -41,6 +41,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "valptridx.h"
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include "compiler-type_traits.h"
|
||||
|
||||
struct segment;
|
||||
|
||||
|
@ -600,7 +601,17 @@ typedef array<collision_inner_array_t, MAX_OBJECT_TYPES> 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<object, MAX_OBJECTS> {};
|
||||
struct object_array_t : public array<object, MAX_OBJECTS>
|
||||
{
|
||||
typedef array<object, MAX_OBJECTS> array_t;
|
||||
template <typename T>
|
||||
typename tt::enable_if<tt::is_integral<T>::value, reference>::type operator[](T n)
|
||||
{
|
||||
return array_t::operator[](n);
|
||||
}
|
||||
template <typename T>
|
||||
typename tt::enable_if<!tt::is_integral<T>::value, reference>::type operator[](T) const DXX_CXX11_EXPLICIT_DELETE;
|
||||
};
|
||||
extern object_array_t Objects;
|
||||
|
||||
DEFINE_VALPTRIDX_SUBTYPE(objptridx, object, int16_t, Objects);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)]--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue