Improve support for using exact_type with valptridx

This commit is contained in:
Kp 2015-09-15 02:48:04 +00:00
parent 1cdd4ac2ce
commit 2f927c68f9
6 changed files with 15 additions and 18 deletions

View file

@ -8,7 +8,7 @@ class exact_type
{
T *p;
public:
operator bool() = delete;
operator bool() const = delete;
// Conversion to void* variants is prohibited
operator void *() const = delete;
operator volatile void *() const = delete;

View file

@ -184,7 +184,7 @@ void valptridx<managed_type>::check_null_pointer(const_pointer_type p, const arr
template <typename managed_type>
void valptridx<managed_type>::check_implicit_index_range_ref(const managed_type &r, const array_managed_type &a)
{
check_explicit_index_range_ref(r, &r - &a.front(), a);
check_explicit_index_range_ref(r, static_cast<const_pointer_type>(&r) - static_cast<const_pointer_type>(&a.front()), a);
}
template <typename managed_type>
@ -561,7 +561,7 @@ public:
* vptr_type to avoid checking again.
*/
vptr_type((check_null_pointer(p, a), *p), a),
vidx_type(p - &a.front(), a)
vidx_type(p - static_cast<pointer_type>(&a.front()), a)
{
}
basic_ptridx(pointer_type p, index_type i, array_managed_type &a) :
@ -678,7 +678,7 @@ public:
constexpr valptridx<P>::basic_vptr_global_factory<v##prefix##ptridx_t> v##prefix##ptridx{}; \
static inline v##prefix##ptridx_t operator-(P Pconst *o, decltype(A) Pconst &O) \
{ \
return {o, static_cast<v##prefix##ptridx_t::integral_type>(const_cast<const P *>(o) - &(const_cast<const decltype(A) &>(O).front())), A}; \
return {o, static_cast<v##prefix##ptridx_t::integral_type>(const_cast<const P *>(o) - static_cast<const P *>(&(const_cast<const decltype(A) &>(O).front()))), A}; \
} \
#define DEFINE_VALPTRIDX_SUBTYPE(N,P,I,A) \

View file

@ -309,16 +309,15 @@ static void DrawMarkerNumber (automap *am, int num)
static void DropMarker (int player_marker_num)
{
int marker_num = (Player_num*2)+player_marker_num;
const auto playerp = &get_local_plrobj();
if (MarkerObject[marker_num] != object_none)
obj_delete(MarkerObject[marker_num]);
MarkerObject[marker_num] = drop_marker_object(playerp->pos,playerp->segnum,playerp->orient,marker_num);
const auto &playerp = get_local_plrobj();
MarkerObject[marker_num] = drop_marker_object(playerp.pos, playerp.segnum, playerp.orient, marker_num);
if (Game_mode & GM_MULTI)
multi_send_drop_marker (Player_num,playerp->pos,player_marker_num,MarkerMessage[marker_num]);
multi_send_drop_marker(Player_num, playerp.pos, player_marker_num, MarkerMessage[marker_num]);
}
void DropBuddyMarker(const vobjptr_t objp)

View file

@ -2352,7 +2352,6 @@ void multi_process_bigdata(const playernum_t pnum, const ubyte *buf, uint_fast32
void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_fired, objnum_t laser_track, const objptridx_t is_bomb_objnum)
{
const auto ownship = &get_local_plrobj();
static fix64 last_fireup_time = 0;
// provoke positional update if possible (20 times per second max. matches vulcan, the fastest firing weapon)
@ -2378,9 +2377,10 @@ void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_
multibuf[4] = (char)laser_flags;
multibuf[5] = (char)laser_fired;
PUT_INTEL_INT(multibuf+6 , ownship->orient.fvec.x);
PUT_INTEL_INT(multibuf+10, ownship->orient.fvec.y);
PUT_INTEL_INT(multibuf+14, ownship->orient.fvec.z);
const auto &ownship = get_local_plrobj();
PUT_INTEL_INT(multibuf+6 , ownship.orient.fvec.x);
PUT_INTEL_INT(multibuf+10, ownship.orient.fvec.y);
PUT_INTEL_INT(multibuf+14, ownship.orient.fvec.z);
/*
* If we fire a bomb, it's persistent. Let others know of it's objnum so host can track it's behaviour over clients (host-authority functions, D2 chaff ability).
@ -3609,8 +3609,7 @@ static void multi_do_drop_weapon (const playernum_t pnum, const ubyte *buf)
remote_objnum = GET_INTEL_SHORT(buf + 2);
ammo = GET_INTEL_SHORT(buf + 4);
seed = GET_INTEL_INT(buf + 6);
auto objp = &Objects[Players[pnum].objnum];
auto objnum = spit_powerup(objp, powerup_id, seed);
auto objnum = spit_powerup(vobjptr(Players[pnum].objnum), powerup_id, seed);
map_objnum_local_to_remote(objnum, remote_objnum, pnum);

View file

@ -1378,9 +1378,8 @@ void dead_player_frame(void)
// If unable to create camera at time of death, create now.
if (Dead_player_camera == Viewer_save) {
const auto player = &get_local_plrobj();
auto objnum = obj_create(OBJ_CAMERA, 0, player->segnum, player->pos, &player->orient, 0, CT_NONE, MT_NONE, RT_NONE);
const auto &player = get_local_plrobj();
auto objnum = obj_create(OBJ_CAMERA, 0, player.segnum, player.pos, &player.orient, 0, CT_NONE, MT_NONE, RT_NONE);
if (objnum != object_none)
Viewer = Dead_player_camera = objnum;

View file

@ -1070,7 +1070,7 @@ public:
{
range_for (const auto t, segstate.objects)
{
auto objp = &Objects[t.objnum];
const auto &&objp = vobjptr(t.objnum);
auto &e = (*this)[t.objnum];
#if defined(DXX_BUILD_DESCENT_II)
e.objp = objp;