Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+237
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "line_of_sight.h"
|
||||
|
||||
#include <CentralEffectSimulation/logger.h>
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/aes_item_view_utm.h>
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <CentralEffectSimulation/proxy_building.h>
|
||||
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <AreaEffectSimulation/Utils/aes_helper.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <TrainingAreaBase/tab_ftc.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QVector>
|
||||
#include <QPolygonF>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
|
||||
// AES-Handling for Explosions
|
||||
|
||||
namespace CesExplosions
|
||||
{
|
||||
|
||||
enum class EffectType
|
||||
{
|
||||
Unknown = 0,
|
||||
EffectiveMineRangeEnter = 0xf0000 | 1, // AtMineAreaSingleMines = 15 = 0xf
|
||||
EffectiveMineRangeLeave = 0xf0000 | 2, // AtMineAreaSingleMines = 15 = 0xf
|
||||
NContaminationLeave = 0x10000 | 0, // AtNContamination = 1
|
||||
NContaminationEnterArea1 = 0x10000 | 1,
|
||||
NContaminationEnterArea2 = 0x10000 | 2,
|
||||
NContaminationDetonation = 0x10000 | 255,
|
||||
FunctionalAreaLeave = 0xc0000 | 0, // AtReconArea = 12 = 0xc
|
||||
FunctionalAreaEnter = 0xc0000 | 1,
|
||||
ExplosionArea = 0x30000 | 2, // AtExplosionArea = 3
|
||||
ExplosionSingle = 0x40000 | 3, // AtExplosionSingle = 4
|
||||
BCContaminationLeave = 0x20000 | 0, // AtBCContamination = 2
|
||||
BCContaminationEnterFloating = 0x20000 | 1,
|
||||
BCContaminationEnterResident = 0x20000 | 2,
|
||||
BCContaminationEnterFloatingArea = 0x20000 | 3,
|
||||
BeStillWarning = 11,
|
||||
};
|
||||
|
||||
struct ParticipantDistance
|
||||
{
|
||||
double squareDistance = 0;
|
||||
CentralEffectSimulation::HandlerParticipant::CesParticipantData participantPosition;
|
||||
};
|
||||
|
||||
enum class RANGE
|
||||
{
|
||||
LETHAL = 1,
|
||||
NON_LETHAL = 2,
|
||||
HAZARD_DISTANCE = 3,
|
||||
OUTSIDE = 4
|
||||
};
|
||||
QString toString(RANGE range);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helper class HandledImpactsStorage
|
||||
//------------------------------------------------------------------------------
|
||||
class EnteredHarzardDistanceStorage final
|
||||
{
|
||||
public:
|
||||
Q_DISABLE_COPY(EnteredHarzardDistanceStorage)
|
||||
|
||||
EnteredHarzardDistanceStorage();
|
||||
~EnteredHarzardDistanceStorage();
|
||||
|
||||
void participantEnteringArea(int participantId, int areaId);
|
||||
void participantLeavingArea(int participantId, int areaId);
|
||||
bool hasParticipantAlreadyEnteredArea(int participantId, int areaId) const; ///< or isWithinArea?
|
||||
void removeParticipant(int participantId);
|
||||
void removeArea(int aesItemId);
|
||||
|
||||
QVector<int> allParticipantIdsOfArea(int areaId) const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
/**
|
||||
* The private d->pointer to not break BC when changing internals of this class
|
||||
*/
|
||||
Private *d = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// class HandlerExplosions
|
||||
//------------------------------------------------------------------------------
|
||||
class HandlerExplosions : public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AES_ITEM_VIEW_UTM_CONST_ITER = QHash<int, CentralEffectSimulation::AesItemViewUtm>::const_iterator;
|
||||
|
||||
|
||||
explicit HandlerExplosions(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::ProxyBuilding> &proxyBuilding,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerExplosions();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
protected:
|
||||
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private slots:
|
||||
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
|
||||
void onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onEffectsChanged(const AreaEffectSimulation::Effects &effects, DataModification modType);
|
||||
void onNewParticipantCesPosition(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData);
|
||||
void onRestoreRadioReadinessChanged(const int participantId);
|
||||
void onChargeEffectChanged(const AreaEffectSimulation::ChargeEffect &data, DataModification modType);
|
||||
void onStartTimeReached();
|
||||
|
||||
private: // structs
|
||||
|
||||
|
||||
private: // methoden
|
||||
bool inBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemViewUtm,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
|
||||
void calculateSmartEffect(const AreaEffectSimulation::Effects &effects);
|
||||
void calculateSmartExplosion(const int32_t aesItemId,
|
||||
const AreaEffectSimulation::ChargeStruct &chargeStruct,
|
||||
int32_t partyId,
|
||||
const Core::GeoPosition2D &impactPosition,
|
||||
qint64 impactTime);
|
||||
void calculateImpact(const AreaEffectSimulation::ChargeEffect &data);
|
||||
|
||||
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
|
||||
void calculateImpacts(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const QVector<int> &impactsToCheck,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
|
||||
void calculateImpactsEffect(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const QVector<LtsCoordTrans::LtsCoordinate> &triggeredEffectsLtsCoord,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
Options lineOfSightOptions);
|
||||
|
||||
void calculateImpactsEffect_outdated(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const std::vector<Core::GeoPosition> &triggeredEffectsGeoPos,
|
||||
const QVector<QPointF> &triggeredEffectsUtmPos,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
Options lineOfSightOptions);
|
||||
|
||||
bool inCircle(const QPointF ¢erUtm, const double radius, const QPointF &pointUtm);
|
||||
|
||||
QVector<double> chargeRanges(const AreaEffectSimulation::ChargeStruct &chargeStruct) const;
|
||||
int iedClassToEffect(int iedClass) const;
|
||||
static RANGE getMostInnerRange(const QVector<double> &ranges, double currentDistance);
|
||||
RANGE getMostInnerRange(double currentDistance, const AreaEffectSimulation::ChargeStruct &chargeStruct, int &retEffect);
|
||||
|
||||
int checkPartEnterLeaveArea(HandlerExplosions::AES_ITEM_VIEW_UTM_CONST_ITER currentAreaIt,
|
||||
const AES_ITEM_VIEW_UTM_CONST_ITER &endingAreaIt,
|
||||
CentralEffectSimulation::HandlerParticipant::POSITIONS_CONST_ITER currentParticipantIt,
|
||||
const CentralEffectSimulation::HandlerParticipant::POSITIONS_CONST_ITER &endingParticipantIt);
|
||||
|
||||
void sendEffectTypeEvent(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
EffectType effectType,
|
||||
qint64 effectTime);
|
||||
void sendCesHitRequest(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
const qint64 effectTime,
|
||||
const int remaining,
|
||||
const ProjectDataManagement::EventType eventType);
|
||||
|
||||
double getSquareDistance(const QPointF ¢erUtm, const QPointF &pointUtm);
|
||||
void sendEnterHazardDistance(const int participantId, const int aesItemId);
|
||||
void sendLeaveHazardDistance(const int participantId, const int aesItemId, const int remaining);
|
||||
|
||||
void on_newHazardInfo(int participantId, int aesId);
|
||||
|
||||
void sendParticipantEvent(const CentralEffectSimulation::AesItemViewUtm &item,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
const ProjectDataManagement::EventType eventType);
|
||||
|
||||
void startTimer(int id, int msec);
|
||||
|
||||
|
||||
private: // attributes
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
||||
std::shared_ptr<CentralEffectSimulation::ProxyBuilding> m_proxyBuilding;
|
||||
|
||||
|
||||
// AES-Values
|
||||
|
||||
// m_aesItemViewsUtm enthält die übergeordneteten Daten (extent) der Wirkfelder (z.B. für bbox check)
|
||||
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViewsUtm; // key = aesItemId [GUEZE-2484]
|
||||
|
||||
// m_aesItemViewsImpactsUtm enthält die Coords für die Einschläge der ExplosionCluster / ClusterSingleExplosions
|
||||
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViewsImpactsUtm; // key = aesItemId only for HIT [GUEZE-2484]
|
||||
|
||||
QQueue<TrainingAreaBase::SendCesHitRequest> m_sendCesHitRequestQueue;
|
||||
|
||||
#ifdef ORIGINATOR_AT_SENDCESHITREQUEST
|
||||
// N. Thoden, 18.11.2024
|
||||
// Wurde bis ca. 2022 bei onExlosionAreaChanged 'gefüllt'.
|
||||
// Mit Umstellung auf ExplosionCluster (3D_wirksim in 2023/2024) scheinbar outdated.
|
||||
QHash<int32_t, int> m_aesItemId2partIdMap; // Key = aesItemId value= participantId
|
||||
#endif // ORIGINATOR_AT_SENDCESHITREQUEST
|
||||
|
||||
AreaEffectSimulation::HandledImpactsStorage m_handledImpactsStorage; // for ExplosionCluster and all former
|
||||
EnteredHarzardDistanceStorage m_enteredHazardDistanceStore; // which participant are in which areas (aesItemids)
|
||||
|
||||
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
QHash<int, AreaEffectSimulation::ChargeEffect> m_chargeEffects; // key = onChargeEffectChanged.id value ChargeEffect
|
||||
};
|
||||
|
||||
//Q_DECLARE_OPERATORS_FOR_FLAGS(Options)
|
||||
|
||||
} // namespace CesExplosions
|
||||
|
||||
Reference in new issue
Block a user