From 43f479d6d81d189e1d0e0d234a51797b6d58748e Mon Sep 17 00:00:00 2001 From: Ivan Ushakov Date: Tue, 26 Sep 2023 19:21:53 +0300 Subject: [PATCH] bad_cast exception when use caterpillars --- MechoSoma/Xreal/Bubble.h | 2 +- MechoSoma/Xreal/LittleSpider.h | 2 +- MechoSoma/Xreal/OwnerProtection.h | 39 ++++++++++++++----------------- MechoSoma/Xreal/TitaniumBall.h | 2 +- MechoSoma/Xreal/Tomato.h | 2 +- MechoSoma/Xreal/Worm.h | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/MechoSoma/Xreal/Bubble.h b/MechoSoma/Xreal/Bubble.h index 3afb75ea..319a83f6 100644 --- a/MechoSoma/Xreal/Bubble.h +++ b/MechoSoma/Xreal/Bubble.h @@ -8,7 +8,7 @@ #pragma warning( disable : 4250 ) -class Bubble : virtual public Body, public GrowingBody, public OwnerProtection, ArcaneStatisticsService +class Bubble : public GrowingBody, public OwnerProtection, ArcaneStatisticsService { ShareHandle attractor; Vect3f F_wind; diff --git a/MechoSoma/Xreal/LittleSpider.h b/MechoSoma/Xreal/LittleSpider.h index c6b23aa6..c2512c67 100644 --- a/MechoSoma/Xreal/LittleSpider.h +++ b/MechoSoma/Xreal/LittleSpider.h @@ -7,7 +7,7 @@ #include "HydrophobicObject.h" #pragma warning( disable : 4250 ) -class LittleSpider : public CrawlingObject, public OwnerProtection, ArcaneStatisticsService, HydrophobicObject +class LittleSpider : public CrawlingObject, public OwnerProtection, ArcaneStatisticsService, public HydrophobicObject { DurationTimer target_timer; DurationTimer time_to_live; diff --git a/MechoSoma/Xreal/OwnerProtection.h b/MechoSoma/Xreal/OwnerProtection.h index 71eb046c..b71780f9 100644 --- a/MechoSoma/Xreal/OwnerProtection.h +++ b/MechoSoma/Xreal/OwnerProtection.h @@ -1,26 +1,21 @@ -// Author: @caiiiycuk -#ifndef OWNER_PROTECTION -#define OWNER_PROTECTION +////////////////////////////////////////////////////////////////// +// База для создания арканных объектов +// - защита хозяина +////////////////////////////////////////////////////////////////// +#ifndef __OwnerProtection_H__ +#define __OwnerProtection_H__ -class OwnerProtection { +class OwnerProtection +{ + enum { default_duration = 2000 }; + int owner_ID; + DurationTimer duration_; public: - int ID; - int time; - OwnerProtection(int ID): ID(ID) {} - OwnerProtection(): ID(0) {} - int owner() const { - return ID; - } - void reset_owner() { - ID = 0; - } - void set_owner(int ID, int time) { - this->ID = ID; - this->time = time; - } - int duration() { - return time; - } + OwnerProtection(int ID = 0) { owner_ID = ID; duration_.start(default_duration); } + virtual void set_owner(int ID, int duration__ = default_duration) { owner_ID = ID; duration_.start(duration__); } + void reset_owner() { owner_ID = 0; } + int owner() const { return duration_() ? owner_ID : 0; } + time_type duration(){ return duration_(); }; }; -#endif \ No newline at end of file +#endif //__OwnerProtection_H__ diff --git a/MechoSoma/Xreal/TitaniumBall.h b/MechoSoma/Xreal/TitaniumBall.h index 13f7f5bc..a22b1245 100644 --- a/MechoSoma/Xreal/TitaniumBall.h +++ b/MechoSoma/Xreal/TitaniumBall.h @@ -11,7 +11,7 @@ #pragma warning( disable : 4250 ) -class TitaniumBall : virtual public Body, GrowingBody, public OwnerProtection, ArcaneStatisticsService +class TitaniumBall : public GrowingBody, public OwnerProtection, ArcaneStatisticsService { public: TitaniumBall(const Vect3f& R_, const Vect3f& V_, float damage__, int owner_ID); diff --git a/MechoSoma/Xreal/Tomato.h b/MechoSoma/Xreal/Tomato.h index 14808af3..7e3e2b7e 100644 --- a/MechoSoma/Xreal/Tomato.h +++ b/MechoSoma/Xreal/Tomato.h @@ -10,7 +10,7 @@ #pragma warning( disable : 4250 ) -class Tomato : virtual public Body, GrowingBody, public OwnerProtection, ArcaneStatisticsService +class Tomato : public GrowingBody, public OwnerProtection, ArcaneStatisticsService { Vect3f R0; public: diff --git a/MechoSoma/Xreal/Worm.h b/MechoSoma/Xreal/Worm.h index e2996596..cfb0f3d4 100644 --- a/MechoSoma/Xreal/Worm.h +++ b/MechoSoma/Xreal/Worm.h @@ -16,7 +16,7 @@ class Worm : public CrawlingObject void body_overlap_reaction(Body& body); }; -class Caterpillar : public CrawlingObject, public OwnerProtection, ArcaneStatisticsService, HydrophobicObject +class Caterpillar : public CrawlingObject, public OwnerProtection, ArcaneStatisticsService, public HydrophobicObject { DurationTimer rudder_latency; DurationTimer time_to_live;