176 lines
6.8 KiB
C++
Executable File
176 lines
6.8 KiB
C++
Executable File
/**
|
|
* Handler for player data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by gr, SLSE, 2017-02-20
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "point_helpers.h"
|
|
#include "dds_handler.h"
|
|
#include "handler_building_data.h"
|
|
|
|
#include <CentralEffectSimulation/logger.h>
|
|
#include <CentralEffectSimulation/svccesddscommon_export.h>
|
|
|
|
#include <LtsUtilsCore/outdated_position.h>
|
|
#include <LtsCoordinate/lts_coordinate.h>
|
|
|
|
#include <QObject>
|
|
#include <QtCore/QMap>
|
|
#include <QtCore/QHash>
|
|
#include <QtCore/QPointF>
|
|
#include <QtCore/QLineF>
|
|
#include <QtCore/QSet>
|
|
#include <QtGui/QPolygonF>
|
|
|
|
|
|
// AES-Handling for participants outside buildings
|
|
namespace CentralEffectSimulation
|
|
{
|
|
|
|
class SVCCESDDSCOMMON_EXPORT HandlerParticipant : public QObject
|
|
, protected TrainingAreaBase::Interface::Ftc::SendParticipantBeStillWarningReplyHandler
|
|
, protected ParticipantManagement::Interface::Ftc::ModifyStateReplyHandler
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
struct CesParticipantData : public ParticipantManagement::ParticipantPosition
|
|
{
|
|
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState_def::CombatReady;
|
|
Core::GeoPosition lastGeoPosition;
|
|
bool positionValid{false};
|
|
bool lastPositionValid{false};
|
|
bool notfightMode{false};
|
|
bool insideBuildingValue{false};
|
|
|
|
mutable LtsCoordTrans::LtsCoordinate m_ltsCoordinate;
|
|
|
|
|
|
bool insideWlsArea() const { return reportingSource() == Core::PositionReportingSource::Wls; }
|
|
bool insideBuilding() const { return insideBuildingValue; }
|
|
|
|
LtsCoordTrans::LtsCoordinate <sCoordinate()
|
|
{
|
|
return m_ltsCoordinate;
|
|
}
|
|
const LtsCoordTrans::LtsCoordinate <sCoordinate() const
|
|
{
|
|
return m_ltsCoordinate;
|
|
}
|
|
|
|
CesParticipantData() = default;
|
|
explicit CesParticipantData(const ParticipantManagement::ParticipantPosition &p)
|
|
: ParticipantManagement::ParticipantPosition(p)
|
|
, lastGeoPosition(p.pos())
|
|
, positionValid(true)
|
|
{}
|
|
}; // struct CesParticipantData
|
|
|
|
using POSITIONS_CONST_ITER = QHash<int, CesParticipantData>::const_iterator;
|
|
|
|
|
|
protected:
|
|
void onSendParticipantBeStillWarningReply(const Core::FunctionReplyObject &replyObject) override final;
|
|
void onModifyStateReply(const Core::FunctionReplyObject &reply) override final;
|
|
|
|
public:
|
|
explicit HandlerParticipant(const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<HandlerBuildingData> &handlerBuildingData,
|
|
int cheatingDistanceVehicle,
|
|
int cheatingDistanceSoldier,
|
|
QObject *parent = nullptr);
|
|
|
|
~HandlerParticipant();
|
|
|
|
/**
|
|
* Initialize the handler to manage information from player management
|
|
*/
|
|
bool init();
|
|
|
|
const QHash<int, CesParticipantData> &positions() const { return m_positionsMap; }
|
|
CesParticipantData position(int participantId) const { return m_positionsMap.value(participantId); }
|
|
ParticipantManagement::Participant participant(int participantId) const { return m_participantData.value(participantId); }
|
|
ParticipantManagement::TypeClass typeClassFromTypeId(int typeId) const { return m_typeMap.value(typeId); }
|
|
bool isOutdated(const CesParticipantData &pos) const
|
|
{
|
|
return LtsUtils::isPositionTimeOutdated(m_ddsHandler->currentPartitionTime(), pos.sampleTime());
|
|
}
|
|
|
|
QPolygonF getParticipantStep(int participantId, int zone) const;
|
|
QPointF getParticipantPositionUtm(int participantId, int zone) const;
|
|
HandlerParticipant::CesParticipantData getParticipantPosition(int participantId) const;
|
|
QHash<int, CesParticipantData> positionsAircraft() const;
|
|
QVector<int32_t> getParticipantsBuilding(const int32_t buildingId) const;
|
|
void setNotfightMode (const int participantId, const bool);
|
|
|
|
// Return Direction in [Degree]
|
|
long getDirection(int originatorParticipantId, int targetParticipantId);
|
|
|
|
// return Distance in [m]
|
|
long getDistance(int originatorParticipantId, int targetParticipantId);
|
|
|
|
int getParticipantId(int equipentNumber);
|
|
int getEquipmentNumber(int participantId) const;
|
|
|
|
signals:
|
|
void newIndoorPosition(const CesParticipantData &pos);
|
|
void newOutdoorPosition(const CesParticipantData &pos);
|
|
void participantLeavesBuilding(int participantId);
|
|
void newParticipantState(const CesParticipantData &pos);
|
|
void participantDecontaminated(const int participantId);
|
|
void newNotfightMode(const CesParticipantData &pos);
|
|
void restoreRadioReadinessChanged(const int participantId);
|
|
|
|
public slots:
|
|
void modifyStateRequest(
|
|
const int &participantId, const ProjectDataManagement::VulnerabilityState &state, const int &kind, const int &vitality
|
|
);
|
|
|
|
private slots:
|
|
/**
|
|
* Handle the signals from 'ParticipantManagement'
|
|
*/
|
|
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
|
void onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType);
|
|
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
|
void onTypeChanged(const ParticipantManagement::Type &data, DataModification modType);
|
|
void onRestoreRadioReadinessChanged(const TrainingAreaBase::RestoreRadioReadiness &data, DataModification modType);
|
|
void sendBeStillWarning(const int32_t participantId);
|
|
|
|
private: // methoden
|
|
bool handleCheating(const ParticipantManagement::TypeClass typeClass,
|
|
const ProjectDataManagement::VulnerabilityState newVulnerabilityState);
|
|
|
|
void checkCheating(const int participantId, const CesParticipantData &participantPosition,
|
|
const ProjectDataManagement::VulnerabilityState newVulnerabilityState);
|
|
void checkCheatingPosition(const int participantId);
|
|
|
|
|
|
|
|
private: // attributes
|
|
|
|
std::shared_ptr<DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
|
std::shared_ptr<HandlerBuildingData> m_handlerBuildingData;
|
|
|
|
QHash<int, CesParticipantData> m_positionsMap; ///key = participantId < Reference map participant (player) to room id (participantId, roomId) inside Building
|
|
QHash<int, ParticipantManagement::TypeClass> m_typeMap;
|
|
QHash<int, ParticipantManagement::Participant> m_participantData; /// key = participantId
|
|
QHash<int, CesParticipantData> m_positionsCheatingMap; ///key = participantId < Reference map participant for Cheating detection >
|
|
|
|
int m_cheatingDistanceVehicle; // Distance to hit-position from the vehicle
|
|
int m_cheatingDistanceSoldier; // Distance to hit-position from the soldier
|
|
|
|
|
|
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
|
};
|
|
|
|
SVCCESDDSCOMMON_EXPORT std::ostream &operator<< (std::ostream &stream,
|
|
const HandlerParticipant::CesParticipantData &value);
|
|
|
|
} // namespace CentralEffectSimulation2D
|
|
|