diff --git a/common/include/valptridx.h b/common/include/valptridx.h index 34863dfab..80f5a2f3f 100644 --- a/common/include/valptridx.h +++ b/common/include/valptridx.h @@ -20,6 +20,12 @@ ((void)0) #endif +#ifdef DXX_HAVE_CXX11_REF_QUALIFIER +#define DXX_VALPTRIDX_REF_QUALIFIER_LVALUE & +#else +#define DXX_VALPTRIDX_REF_QUALIFIER_LVALUE +#endif + #define DXX_VALPTRIDX_CHECK(E,S,success,failure) \ ( \ DXX_VALPTRIDX_STATIC_CHECK(E,dxx_trap_##failure,S), \ @@ -90,8 +96,12 @@ public: p(p) { } - pointer_type operator->() const { return p; } - operator pointer_type() const { return p; } + pointer_type operator->() const DXX_VALPTRIDX_REF_QUALIFIER_LVALUE { return p; } + operator pointer_type() const DXX_VALPTRIDX_REF_QUALIFIER_LVALUE { return p; } +#ifdef DXX_HAVE_CXX11_REF_QUALIFIER + pointer_type operator->() const && = delete; + operator pointer_type() const && = delete; +#endif /* Only vvalptr_t can implicitly convert to reference */ operator reference() const = delete; bool operator==(const pointer_type &rhs) const { return p == rhs; } diff --git a/d2x-rebirth/main/escort.cpp b/d2x-rebirth/main/escort.cpp index c951492c8..c45dafd6c 100644 --- a/d2x-rebirth/main/escort.cpp +++ b/d2x-rebirth/main/escort.cpp @@ -1183,12 +1183,13 @@ void recreate_thief(object *objp) { segnum_t segnum; vms_vector center_point; - object *new_obj; segnum = choose_thief_recreation_segment(); compute_segment_center(¢er_point, &Segments[segnum]); - new_obj = create_morph_robot( &Segments[segnum], ¢er_point, objp->id); + auto new_obj = create_morph_robot( &Segments[segnum], ¢er_point, objp->id); + if (new_obj == object_none) + return; init_ai_object(new_obj, AIB_SNIPE, segment_none); Re_init_thief_time = GameTime64 + F1_0*10; // In 10 seconds, re-initialize thief. } diff --git a/similar/main/fireball.cpp b/similar/main/fireball.cpp index 219a92149..ba39af879 100644 --- a/similar/main/fireball.cpp +++ b/similar/main/fireball.cpp @@ -1400,9 +1400,8 @@ void drop_afterburner_blobs(object *obj, int count, fix size_scale, fix lifetime if (count > 1) { segnum = find_point_seg(&pos_right, obj->segnum); if (segnum != segment_none) { - object *blob_obj; - blob_obj = object_create_explosion(segnum, &pos_right, size_scale, VCLIP_AFTERBURNER_BLOB ); - if (lifetime != -1) + auto blob_obj = object_create_explosion(segnum, &pos_right, size_scale, VCLIP_AFTERBURNER_BLOB ); + if (lifetime != -1 && blob_obj != object_none) blob_obj->lifeleft = lifetime; } }