Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
134 lines
3.5 KiB
C++
134 lines
3.5 KiB
C++
/*
|
|
* @RDE_HEADER@
|
|
* Worker for Tetra Simulation
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QtCore/QByteArray>
|
|
#include <QtCore/QMap>
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QPointF>
|
|
#include <QtCore/QMap>
|
|
#include <NGLLogger/INGLLogger.h>
|
|
#include <CoPrtCnv/CoPrtCnvCentralTelegram.hpp>
|
|
#include <CoPrtCnv/CoPrtCnvRadioTelegram.hpp>
|
|
#include <CoPrtCnv/CoPrtCnvTelegramConverter.hpp>
|
|
#include <TrainingAreaBase/training_area_telegrams.h>
|
|
#include "server.h"
|
|
|
|
|
|
class QTcpSocket;
|
|
class QTimer;
|
|
|
|
class Player
|
|
{
|
|
private:
|
|
void randomizeDeathTicks()
|
|
{
|
|
deathTicks = ((qrand() % (maximumDeathTicks - minimumDeathTicks + 1)) + minimumDeathTicks);
|
|
}
|
|
|
|
public:
|
|
// PU simulation vars:
|
|
uint32_t eqId;
|
|
uint32_t issi;
|
|
QPointF posUTM;
|
|
|
|
// PU login-state vars:
|
|
bool isLogin;
|
|
bool isValidBITE;
|
|
TrainingAreaBase::TetraIcd::VulnerabilityState vbg;
|
|
|
|
// pattern vars:
|
|
int patternInList; // >-| which pattern to take from the pattern list
|
|
int stepInPattern; // <-| which step we have in the current pattern (see "patternInList" above)
|
|
|
|
// x seconds, for a Player to respawn [maximum / mininum]
|
|
uint32_t deathTicks;
|
|
uint32_t minimumDeathTicks;
|
|
uint32_t maximumDeathTicks;
|
|
|
|
Player(int eqId_, int issi_, uint32_t minimumDeathTicks_, uint32_t maximumDeathTicks_, const QPointF &posUTM_)
|
|
: eqId(eqId_)
|
|
, issi(issi_)
|
|
, posUTM(posUTM_)
|
|
, isLogin(false)
|
|
, isValidBITE(false)
|
|
, vbg(TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady)
|
|
, patternInList(0)
|
|
, stepInPattern(1)
|
|
, deathTicks(0)
|
|
, minimumDeathTicks(minimumDeathTicks_)
|
|
, maximumDeathTicks(maximumDeathTicks_)
|
|
{
|
|
randomizeDeathTicks();
|
|
}
|
|
|
|
bool isEndOfTicks() // gives TRUE if deathTicks is lower than 1 and randomizes deathTicks again, so this function can be reused everytime
|
|
{
|
|
deathTicks--;
|
|
if (deathTicks < 1)
|
|
{
|
|
randomizeDeathTicks(); // randomize again
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
class TTWorker : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TTWorker(QTcpSocket *socket, const TTSArgs &ttsArgs);
|
|
|
|
bool init();
|
|
|
|
private Q_SLOTS:
|
|
void onReadyRead();
|
|
void onSendPlayerPositions(); // -> nur senden, wenn isLogin & isValidBite für tln ok
|
|
// wenn LoginOk von PrtCnv -> onSendBite(eqId)
|
|
void onSocketError();
|
|
void onSendNachforderungBroadcastTelegramm();
|
|
void onSendDeaktivierungEinzelminen();
|
|
|
|
protected:
|
|
void startExecution();
|
|
QVector<runningPattern> interpretPattern(QString pattern) const;
|
|
void movePlayer(Player *p);
|
|
void handleReceivedTelegram(const QByteArray &data);
|
|
void handleRegisterInd();
|
|
void handleDataIndReq(const QByteArray &data);
|
|
|
|
void sendTelegram(N_CoPrtCnv::CoPrtCnvRadioTelegram *radioTelegram, uint32_t issi);
|
|
template <typename T>
|
|
void sendTelegram(const T &tele, uint32_t issi)
|
|
{
|
|
N_CoPrtCnv::CoPrtCnvCentralTelegram ct(tele);
|
|
sendTelegram(N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToRadio(&ct), issi);
|
|
}
|
|
void sendLogin(uint32_t eqId, uint32_t issi);
|
|
void sendBITE(uint32_t eqId, uint32_t issi);
|
|
void sendTaktischerStatus(uint32_t eqId, uint32_t issi, TrainingAreaBase::TetraIcd::VulnerabilityState vbg);
|
|
void sendSanitationReport(uint32_t eqId, uint32_t issi);
|
|
//void sendSanitation(uint32_t eqId, uint32_t issi);
|
|
private:
|
|
QTcpSocket *m_socket;
|
|
QTimer *m_timer;
|
|
QByteArray m_buffer;
|
|
unsigned int m_counter;
|
|
bool m_toogle;
|
|
|
|
TTSArgs m_ttsArgs;
|
|
|
|
QVector<Player *> m_playerList;
|
|
QVector<runningPattern> m_patternList;
|
|
QPointF m_generalPosition;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|