Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
@@ -31,97 +31,77 @@ int main(int argc, char **argv)
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options(LtsCommandLineParser::LtsCommandLineParser::CustomConfigFile);
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("p") << QLatin1String("player")
|
||||
, QLatin1String("number of players to be simulated.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("5")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("p") << QLatin1String("player"),
|
||||
QLatin1String("number of players to be simulated."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("5")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("n") << QLatin1String("northing")
|
||||
, QLatin1String("initial position UTM north.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("77777")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("n") << QLatin1String("northing"),
|
||||
QLatin1String("initial position UTM north."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("77777")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("e") << QLatin1String("easting")
|
||||
, QLatin1String("initial position UTM east.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("99999")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("e") << QLatin1String("easting"),
|
||||
QLatin1String("initial position UTM east."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("99999")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("f") << QLatin1String("first-id")
|
||||
, QLatin1String("first equipment ID to use.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("1101")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("f") << QLatin1String("first-id"),
|
||||
QLatin1String("first equipment ID to use."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("1101")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("r") << QLatin1String("pprow")
|
||||
, QLatin1String("players per row.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("25")
|
||||
});
|
||||
options.addOption(
|
||||
{QStringList() << QLatin1String("r") << QLatin1String("pprow"), QLatin1String("players per row."), QLatin1String("Default value"), QLatin1String("25")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("s") << QLatin1String("pspacing")
|
||||
, QLatin1String("utm based spacing between the players.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("100")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("s") << QLatin1String("pspacing"),
|
||||
QLatin1String("utm based spacing between the players."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("100")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("z") << QLatin1String("issi")
|
||||
, QLatin1String("DestinationIssi / HostISSI")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("2")
|
||||
});
|
||||
options.addOption(
|
||||
{QStringList() << QLatin1String("z") << QLatin1String("issi"), QLatin1String("DestinationIssi / HostISSI"), QLatin1String("Default value"), QLatin1String("2")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("m") << QLatin1String("movements")
|
||||
, QLatin1String("how many movements per milliseconds to make.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("2000")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("m") << QLatin1String("movements"),
|
||||
QLatin1String("how many movements per milliseconds to make."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("2000")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("d") << QLatin1String("death")
|
||||
, QLatin1String("minimum times, after the movements timer is triggered, a dead player can revive.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("100")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("d") << QLatin1String("death"),
|
||||
QLatin1String("minimum times, after the movements timer is triggered, a dead player can revive."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("100")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("o") << QLatin1String("death-offset")
|
||||
, QLatin1String("maximum times, after the movements timer is triggered, a dead player can revive.")
|
||||
, QLatin1String("(0 -> identical to min)")
|
||||
, QLatin1String("0")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("o") << QLatin1String("death-offset"),
|
||||
QLatin1String("maximum times, after the movements timer is triggered, a dead player can revive."),
|
||||
QLatin1String("(0 -> identical to min)"),
|
||||
QLatin1String("0")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("t") << QLatin1String("pattern")
|
||||
, QLatin1String("pattern the player has to walk [enter pattern by hand or pattern alias-name from settings file]\r\nfor more info, enter '--pattern-help'.")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("3,30,20#3,30,-20#3,-30,-20#3,-30,20")
|
||||
});
|
||||
options.addOption(
|
||||
{QStringList() << QLatin1String("t") << QLatin1String("pattern"),
|
||||
QLatin1String("pattern the player has to walk [enter pattern by hand or pattern alias-name from settings file]\r\nfor more info, enter '--pattern-help'."),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("3,30,20#3,30,-20#3,-30,-20#3,-30,20")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("demand-old-broadcast-telegrams")
|
||||
, QLatin1String("player demand old broadcast telegrams starting at BCI <default value>")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("0")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("demand-old-broadcast-telegrams"),
|
||||
QLatin1String("player demand old broadcast telegrams starting at BCI <default value>"),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("0")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("deactivate-single-mines")
|
||||
, QLatin1String("the first player deactivates single mines with ids from minimum-mine-id to maximum-mine-id")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("deactivate-single-mines"),
|
||||
QLatin1String("the first player deactivates single mines with ids from minimum-mine-id to maximum-mine-id")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("minimum-mine-id")
|
||||
, QLatin1String("sets the value for minimum-mine-id used within deactivate-single-mines command")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("minimum-mine-id 2048")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("minimum-mine-id"),
|
||||
QLatin1String("sets the value for minimum-mine-id used within deactivate-single-mines command"),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("minimum-mine-id 2048")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("maximum-mine-id")
|
||||
, QLatin1String("sets the value for maximum-mine-Id used within deactivate-single-mines command")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("maximum-mine-id 2100")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("maximum-mine-id"),
|
||||
QLatin1String("sets the value for maximum-mine-Id used within deactivate-single-mines command"),
|
||||
QLatin1String("Default value"),
|
||||
QLatin1String("maximum-mine-id 2100")});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("pattern-help")
|
||||
, QLatin1String("help for the pattern interpreter.")
|
||||
});
|
||||
options.addOption({QStringList() << QLatin1String("pattern-help"), QLatin1String("help for the pattern interpreter.")});
|
||||
|
||||
|
||||
if (!options.init())
|
||||
@@ -166,8 +146,7 @@ int main(int argc, char **argv)
|
||||
WARNING_LOG(logger) << " ... DestinationIssi/HostIssi: " << ttsArgs.destIssi;
|
||||
WARNING_LOG(logger) << " ... on Position n/e: " << ttsArgs.position.y() << "/" << ttsArgs.position.x();
|
||||
WARNING_LOG(logger) << " ... first equipmentID is: " << ttsArgs.eqIdStart;
|
||||
WARNING_LOG(logger) << " ... player is reborn randomly after minimum " << ttsArgs.minimumDeathTicks
|
||||
<< " ticks and maximum " << ttsArgs.maximumDeathTicks << " ticks";
|
||||
WARNING_LOG(logger) << " ... player is reborn randomly after minimum " << ttsArgs.minimumDeathTicks << " ticks and maximum " << ttsArgs.maximumDeathTicks << " ticks";
|
||||
WARNING_LOG(logger) << " ... pattern = " << ttsArgs.pattern;
|
||||
WARNING_LOG(logger) << " ... max. " << ttsArgs.pprow << " players per row";
|
||||
WARNING_LOG(logger) << " ... spacing of '" << ttsArgs.pspacing << " UTM east' between players";
|
||||
@@ -177,8 +156,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (!s->listen(QHostAddress::Any, serverSettings.value(QLatin1String("Radio/Port"), 4200).toInt()))
|
||||
{
|
||||
ERROR_LOG(logger) << "Error listening on localhost:" << serverSettings.value(QLatin1String("Radio/Port"), 52010).toInt() << ": "
|
||||
<< s->errorString();
|
||||
ERROR_LOG(logger) << "Error listening on localhost:" << serverSettings.value(QLatin1String("Radio/Port"), 52010).toInt() << ": " << s->errorString();
|
||||
delete s;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
TTServer::TTServer(const TTSArgs &ttsArgs) : m_ttsArgs(ttsArgs)
|
||||
.getNGLLogger("TTServer")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
|
||||
connect(this, &TTServer::newConnection,
|
||||
this, &TTServer::onNewConnection);
|
||||
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
|
||||
{
|
||||
connect(this, &TTServer::newConnection, this, &TTServer::onNewConnection);
|
||||
}
|
||||
|
||||
void TTServer::onNewConnection()
|
||||
@@ -24,16 +24,13 @@ void TTServer::onNewConnection()
|
||||
QTcpSocket *sock = nextPendingConnection();
|
||||
if (!sock)
|
||||
return;
|
||||
NOTICE_LOG(m_logger) << "New incoming connection from "
|
||||
<< sock->peerName() << ":"
|
||||
<< sock->peerPort();
|
||||
NOTICE_LOG(m_logger) << "New incoming connection from " << sock->peerName() << ":" << sock->peerPort();
|
||||
|
||||
TTWorker *ttw = new TTWorker(sock, m_ttsArgs);
|
||||
if (!ttw->init())
|
||||
exit(5);
|
||||
|
||||
connect(sock, &QTcpSocket::disconnected,
|
||||
this, &TTServer::onDisconnect);
|
||||
connect(sock, &QTcpSocket::disconnected, this, &TTServer::onDisconnect);
|
||||
}
|
||||
|
||||
void TTServer::onDisconnect()
|
||||
|
||||
@@ -24,9 +24,9 @@ struct runningPattern
|
||||
|
||||
struct TTSArgs
|
||||
{
|
||||
QPointF position;
|
||||
QString pattern;
|
||||
QSettings *settings = nullptr;
|
||||
QPointF position;
|
||||
QString pattern;
|
||||
QSettings *settings = nullptr;
|
||||
int destIssi = 0;
|
||||
unsigned int cntPlayer = 0;
|
||||
unsigned int eqIdStart = 0;
|
||||
@@ -37,9 +37,9 @@ struct TTSArgs
|
||||
unsigned int movs_per_msec = ~0U;
|
||||
unsigned int minimumMineId = 0;
|
||||
unsigned int maximumMineId = 0;
|
||||
bool demandOldBraodcastTelegrams = false;
|
||||
int demandOldBraodcastTelegramsCounter = 0;
|
||||
bool deactivationSingleMines = false;
|
||||
bool demandOldBraodcastTelegrams = false;
|
||||
int demandOldBraodcastTelegramsCounter = 0;
|
||||
bool deactivationSingleMines = false;
|
||||
};
|
||||
|
||||
class TTServer : public QTcpServer
|
||||
@@ -53,7 +53,6 @@ protected Q_SLOTS:
|
||||
void onDisconnect();
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
NGL::INGLLogger &m_logger;
|
||||
TTSArgs m_ttsArgs;
|
||||
};
|
||||
@@ -33,14 +33,10 @@ TTWorker::TTWorker(QTcpSocket *socket, const TTSArgs &ttsArgs)
|
||||
|
||||
bool TTWorker::init()
|
||||
{
|
||||
connect(m_socket, &QTcpSocket::disconnected,
|
||||
this, &TTWorker::deleteLater);
|
||||
connect(m_socket, &QAbstractSocket::errorOccurred,
|
||||
this, &TTWorker::onSocketError);
|
||||
connect(m_socket, &QTcpSocket::readyRead,
|
||||
this, &TTWorker::onReadyRead);
|
||||
connect(m_timer, &QTimer::timeout,
|
||||
this, &TTWorker::onSendPlayerPositions);
|
||||
connect(m_socket, &QTcpSocket::disconnected, this, &TTWorker::deleteLater);
|
||||
connect(m_socket, &QAbstractSocket::errorOccurred, this, &TTWorker::onSocketError);
|
||||
connect(m_socket, &QTcpSocket::readyRead, this, &TTWorker::onReadyRead);
|
||||
connect(m_timer, &QTimer::timeout, this, &TTWorker::onSendPlayerPositions);
|
||||
|
||||
if (m_ttsArgs.movs_per_msec < 200)
|
||||
{
|
||||
@@ -74,9 +70,9 @@ void TTWorker::startExecution()
|
||||
if (m_ttsArgs.demandOldBraodcastTelegrams)
|
||||
QTimer::singleShot(1000, this, &TTWorker::onSendNachforderungBroadcastTelegramm);
|
||||
|
||||
// QTimer::singleShot(25000, this , &TTWorker::onSendNlosSimulatorDirection);
|
||||
// QTimer::singleShot(120000, this , &TTWorker::onSendNlosFireResult);
|
||||
}
|
||||
// QTimer::singleShot(25000, this , &TTWorker::onSendNlosSimulatorDirection);
|
||||
// QTimer::singleShot(120000, this , &TTWorker::onSendNlosFireResult);
|
||||
}
|
||||
|
||||
QVector<runningPattern> TTWorker::interpretPattern(QString pattern) const
|
||||
{
|
||||
@@ -106,11 +102,11 @@ QVector<runningPattern> TTWorker::interpretPattern(QString pattern) const
|
||||
if (pattern.at(pattern.count() - 1) == QLatin1Char('#')) // delete the character ';' if there is one at the end of string - because of strtok/split
|
||||
pattern.remove(pattern.count() - 1, 1);
|
||||
|
||||
QVector<runningPattern> newPatternList; // list we give back to replace the patternList in this class
|
||||
runningPattern rp; // pattern we use (and reuse) to add a new runningPattern instance to the patternList
|
||||
QVector<runningPattern> newPatternList; // list we give back to replace the patternList in this class
|
||||
runningPattern rp; // pattern we use (and reuse) to add a new runningPattern instance to the patternList
|
||||
QStringList strings = pattern.split(QLatin1Char('#')); // list of pattern (f.g. "1,2,3", "1,2,3");
|
||||
QStringList stringy; // list of pattern-ingredients ;) (f.g. "1", "2", "3")
|
||||
int i; // counter, global because of error message at the end of this function (see variable "strings")
|
||||
QStringList stringy; // list of pattern-ingredients ;) (f.g. "1", "2", "3")
|
||||
int i; // counter, global because of error message at the end of this function (see variable "strings")
|
||||
|
||||
for (i = 0; i < strings.count(); i++)
|
||||
{
|
||||
@@ -121,14 +117,20 @@ QVector<runningPattern> TTWorker::interpretPattern(QString pattern) const
|
||||
|
||||
bool ok = true;
|
||||
|
||||
rp.steps = stringy.at(0).toInt(&ok); if (!ok) break; // is not a number, so throw an error and exit this application
|
||||
rp.ethering = stringy.at(1).toInt(&ok); if (!ok) break; // ^
|
||||
rp.northering = stringy.at(2).toInt(&ok); if (!ok) break; // ^
|
||||
rp.steps = stringy.at(0).toInt(&ok);
|
||||
if (!ok)
|
||||
break; // is not a number, so throw an error and exit this application
|
||||
rp.ethering = stringy.at(1).toInt(&ok);
|
||||
if (!ok)
|
||||
break; // ^
|
||||
rp.northering = stringy.at(2).toInt(&ok);
|
||||
if (!ok)
|
||||
break; // ^
|
||||
|
||||
newPatternList.append(rp); // add a new instance to the list (i hope this will create an instance and does not use a reference !!1)
|
||||
|
||||
if (i == strings.count() - 1) // are we at the end of the strings.count ? if yes, then return the list - important to NOT throw a error message
|
||||
return newPatternList; // IMPORTANT! Or an wrong error message will be thrown
|
||||
return newPatternList; // IMPORTANT! Or an wrong error message will be thrown
|
||||
}
|
||||
|
||||
ERROR_LOG(m_logger) << "INVALID PATTERN: '" << strings.at(i) << "'. Cannot start without correct pattern!";
|
||||
@@ -158,16 +160,14 @@ void TTWorker::onReadyRead()
|
||||
|
||||
if (N_CoPrtCnv::CoPrtCnvRadioTelegram::MAGIC_NUMBER != header.m_MagicNumber)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Disconnect because radio-Telegram does not begin with magic-number A5: I got "
|
||||
<< header.m_MagicNumber;
|
||||
ERROR_LOG(m_logger) << "Disconnect because radio-Telegram does not begin with magic-number A5: I got " << header.m_MagicNumber;
|
||||
m_socket->disconnectFromHost();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!N_CoPrtCnv::CoPrtCnvRadioTelegram::isTelegramLengthOk(header.m_Length))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Radio-Telegram length to big: " << header.m_Length
|
||||
<< " - but I proceed with this telegram.";
|
||||
WARNING_LOG(m_logger) << "Radio-Telegram length to big: " << header.m_Length << " - but I proceed with this telegram.";
|
||||
}
|
||||
|
||||
// prepare data-bucket for entire telegram
|
||||
@@ -197,20 +197,19 @@ void TTWorker::handleReceivedTelegram(const QByteArray &data)
|
||||
// evaluate PDU-Type
|
||||
switch (data.at(4))
|
||||
{
|
||||
// response to register indication
|
||||
case N_CoPrtCnv::CoPrtCnvRadioTelegram::e_RegisterInd:
|
||||
handleRegisterInd();
|
||||
startExecution();
|
||||
break;
|
||||
// response to register indication
|
||||
case N_CoPrtCnv::CoPrtCnvRadioTelegram::e_RegisterInd:
|
||||
handleRegisterInd();
|
||||
startExecution();
|
||||
break;
|
||||
|
||||
case N_CoPrtCnv::CoPrtCnvRadioTelegram::e_DataIndReq:
|
||||
handleDataIndReq(data); // tele->getDestISSI() == ISSI an des angesprochenen Teilnehmers
|
||||
// data is deleted inside handleDataIndReq()
|
||||
break;
|
||||
default:
|
||||
INFO_LOG(m_logger) << "Radio-Telegram with PDU-Type=" << (int)data[4]
|
||||
<< " not implemented!";
|
||||
break;
|
||||
case N_CoPrtCnv::CoPrtCnvRadioTelegram::e_DataIndReq:
|
||||
handleDataIndReq(data); // tele->getDestISSI() == ISSI an des angesprochenen Teilnehmers
|
||||
// data is deleted inside handleDataIndReq()
|
||||
break;
|
||||
default:
|
||||
INFO_LOG(m_logger) << "Radio-Telegram with PDU-Type=" << (int)data[4] << " not implemented!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,15 +230,14 @@ void TTWorker::onSendNachforderungBroadcastTelegramm()
|
||||
|
||||
if (p->isLogin)
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvRadioTelegram tel(GEF_NACHFORDERUNG_BROADCAST_TELEGRAMME,
|
||||
10, p->eqId);
|
||||
N_CoPrtCnv::CoPrtCnvRadioTelegram tel(GEF_NACHFORDERUNG_BROADCAST_TELEGRAMME, 10, p->eqId);
|
||||
tel.setZaehler(0);
|
||||
tel.setBroadcastIndex(0);
|
||||
tel.setDestISSI(m_ttsArgs.destIssi);
|
||||
tel.setSrcISSI(p->issi);
|
||||
tel.setPayload4Byte(0); // gps_zeit
|
||||
tel.setPayload1Byte(0); // ruecksetzzaehler
|
||||
tel.setPayload2Byte(m_ttsArgs.demandOldBraodcastTelegramsCounter); // broadcast index
|
||||
tel.setPayload4Byte(0); // gps_zeit
|
||||
tel.setPayload1Byte(0); // ruecksetzzaehler
|
||||
tel.setPayload2Byte(m_ttsArgs.demandOldBraodcastTelegramsCounter); // broadcast index
|
||||
m_socket->write(tel.data());
|
||||
}
|
||||
else
|
||||
@@ -366,7 +364,6 @@ void TTWorker::sendSanitationReport(uint32_t eqId, uint32_t issi)
|
||||
mat.emplace_back(i);
|
||||
tele.sanitaryMaterialStock = mat;
|
||||
sendTelegram(tele, issi);
|
||||
|
||||
}
|
||||
|
||||
// void TTWorker::sendSanitation(uint32_t eqId, uint32_t issi)
|
||||
@@ -426,103 +423,105 @@ void TTWorker::handleDataIndReq(const QByteArray &data)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
case GEF_TAKTISCHER_STATUS: // just resend this one to answer the station's question
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
TrainingAreaBase::TetraIcd::StateChange sc = TrainingAreaBase::TetraIcd::StateChange::fromJson(tele->jsonData());
|
||||
delete tele;
|
||||
DEBUG_LOG(m_logger) << " Try to Resetnd State " << sc.header.equipmentNumber << " we got state: " << static_cast<int>(sc.vulnerabilityState) << " and this bits here: " << sc.vulnerabilityBits;
|
||||
|
||||
sc.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
case GEF_TAKTISCHER_STATUS: // just resend this one to answer the station's question
|
||||
{
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
TrainingAreaBase::TetraIcd::StateChange sc = TrainingAreaBase::TetraIcd::StateChange::fromJson(tele->jsonData());
|
||||
delete tele;
|
||||
DEBUG_LOG(m_logger) << " Try to Resetnd State " << sc.header.equipmentNumber << " we got state: " << static_cast<int>(sc.vulnerabilityState)
|
||||
<< " and this bits here: " << sc.vulnerabilityBits;
|
||||
|
||||
sc.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ERROR_LOG(m_logger) << " Try to Resetnd S2tate " << sc.header.equipmentNumber << " we got state: " << static_cast<int>(sc.vulnerabilityState)
|
||||
<< " and this bits here: " << sc.vulnerabilityBits;
|
||||
sendTelegram(sc, issi); // resend
|
||||
return;
|
||||
}
|
||||
|
||||
ERROR_LOG(m_logger) << " Try to Resetnd S2tate " << sc.header.equipmentNumber << " we got state: " << static_cast<int>(sc.vulnerabilityState) << " and this bits here: " << sc.vulnerabilityBits;
|
||||
sendTelegram(sc, issi); // resend
|
||||
return;
|
||||
}
|
||||
case GEF_SANITAETSDIENST_INSTANDSETZUNG_PVSAN:
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
TrainingAreaBase::TetraIcd::Sanitation sc = TrainingAreaBase::TetraIcd::Sanitation::fromJson(tele->jsonData());
|
||||
delete tele;
|
||||
|
||||
DEBUG_LOG(m_logger) << " Try to Resetnd State " << sc.header.equipmentNumber << " we got procedure: " << sc.proceduresTaken;
|
||||
|
||||
sc.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
case GEF_SANITAETSDIENST_INSTANDSETZUNG_PVSAN:
|
||||
{
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
TrainingAreaBase::TetraIcd::Sanitation sc = TrainingAreaBase::TetraIcd::Sanitation::fromJson(tele->jsonData());
|
||||
delete tele;
|
||||
|
||||
ERROR_LOG(m_logger) << " Try to Resetnd S2tate " << sc.header.equipmentNumber << " we got state: " << sc.proceduresTaken;
|
||||
sendTelegram(sc, issi); // resend
|
||||
return;
|
||||
}
|
||||
case GEF_TREFFER_AUSLOESUNG: // we have got a new status (f.g. wounded lying) and send back our new status
|
||||
case GEF_INIT: // ?? .. or just act like this is a treffer ausloesung ....... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
{
|
||||
TrainingAreaBase::TetraIcd::StateChange tele;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
DEBUG_LOG(m_logger) << " Try to Resetnd State " << sc.header.equipmentNumber << " we got procedure: " << sc.proceduresTaken;
|
||||
|
||||
sc.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
{
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ERROR_LOG(m_logger) << " Try to Resetnd S2tate " << sc.header.equipmentNumber << " we got state: " << sc.proceduresTaken;
|
||||
sendTelegram(sc, issi); // resend
|
||||
return;
|
||||
}
|
||||
case GEF_TREFFER_AUSLOESUNG: // we have got a new status (f.g. wounded lying) and send back our new status
|
||||
case GEF_INIT: // ?? .. or just act like this is a treffer ausloesung ....... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
{
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
TrainingAreaBase::TetraIcd::StateChange tele;
|
||||
uint32_t issi = 0;
|
||||
for (int i = 0; i < m_playerList.count(); i++) // get issi from player's eqId
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
if (radioTelegram->getIdentity() == m_playerList.at(i)->eqId)
|
||||
{
|
||||
issi = m_playerList.at(i)->issi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TrainingAreaBase::TetraIcd::VulnerabilityState state = (telID == GEF_TREFFER_AUSLOESUNG)
|
||||
? static_cast<TrainingAreaBase::TetraIcd::VulnerabilityState>(radioTelegram->getPayloadDataUInt8(7))
|
||||
: TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady; //get vbg from radio
|
||||
|
||||
tele.originatorType = TrainingAreaBase::TetraIcd::OriginatorType::Initialisation; //set origin
|
||||
tele.header.equipmentNumber = radioTelegram->getIdentity(); //set header
|
||||
tele.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t vulcomplete = radioTelegram->getPayloadDataUInt32(8, 2);
|
||||
uint32_t vitality = vulcomplete &= 0xF000;
|
||||
vitality >>= 12;
|
||||
|
||||
tele.tasVulnerabilityKindId = vulcomplete &= 0x0FFF;
|
||||
//including vitality
|
||||
tele.tasVulnerabilityKindId <<= 16;
|
||||
tele.tasVulnerabilityKindId |= 0xB1;
|
||||
|
||||
tele.tasVitality = (vitality - 1) * 10;
|
||||
if (tele.tasVitality < 0)
|
||||
tele.tasVitality = 100;
|
||||
|
||||
if (state == TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady && vitality > 0)
|
||||
tele.vulnerabilityState = TrainingAreaBase::TetraIcd::VulnerabilityState::MediumDamage;
|
||||
else
|
||||
tele.vulnerabilityState = state;
|
||||
|
||||
sendTelegram(tele, issi); // send new status
|
||||
return;
|
||||
}
|
||||
TrainingAreaBase::TetraIcd::VulnerabilityState state = (telID == GEF_TREFFER_AUSLOESUNG)
|
||||
? static_cast<TrainingAreaBase::TetraIcd::VulnerabilityState>(radioTelegram->getPayloadDataUInt8(7))
|
||||
: TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady; //get vbg from radio
|
||||
// case GEF_NLOS_DATENVERKEHR_TDS_GEF:
|
||||
// {
|
||||
// ERROR_LOG(m_logger) << "NlosTargetData empfangen";
|
||||
// N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
// TrainingAreaBase::TetraIcd::NlosTargetData sc = TrainingAreaBase::TetraIcd::NlosTargetData::fromJson(tele->jsonData());
|
||||
// delete tele;
|
||||
// QJsonDocument doc(sc.toJson());
|
||||
// ERROR_LOG(m_logger) << "Receive NlosTargetData Size: " << radioTelegram.data()->getSize() << "\n Structure: " << doc.toJson(QJsonDocument::Indented);
|
||||
// return;
|
||||
|
||||
tele.originatorType = TrainingAreaBase::TetraIcd::OriginatorType::Initialisation; //set origin
|
||||
tele.header.equipmentNumber = radioTelegram->getIdentity(); //set header
|
||||
tele.header.timeStamp = time(nullptr) * 1000;
|
||||
uint32_t vulcomplete = radioTelegram->getPayloadDataUInt32(8, 2);
|
||||
uint32_t vitality = vulcomplete &= 0xF000;
|
||||
vitality >>= 12;
|
||||
|
||||
tele.tasVulnerabilityKindId = vulcomplete &= 0x0FFF;
|
||||
//including vitality
|
||||
tele.tasVulnerabilityKindId <<= 16;
|
||||
tele.tasVulnerabilityKindId |= 0xB1;
|
||||
|
||||
tele.tasVitality = (vitality - 1) * 10;
|
||||
if (tele.tasVitality < 0)
|
||||
tele.tasVitality = 100;
|
||||
|
||||
if (state == TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady && vitality > 0)
|
||||
tele.vulnerabilityState = TrainingAreaBase::TetraIcd::VulnerabilityState::MediumDamage;
|
||||
else
|
||||
tele.vulnerabilityState = state;
|
||||
|
||||
sendTelegram(tele, issi); // send new status
|
||||
return;
|
||||
}
|
||||
// case GEF_NLOS_DATENVERKEHR_TDS_GEF:
|
||||
// {
|
||||
// ERROR_LOG(m_logger) << "NlosTargetData empfangen";
|
||||
// N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToCentral(radioTelegram.data());
|
||||
// TrainingAreaBase::TetraIcd::NlosTargetData sc = TrainingAreaBase::TetraIcd::NlosTargetData::fromJson(tele->jsonData());
|
||||
// delete tele;
|
||||
// QJsonDocument doc(sc.toJson());
|
||||
// ERROR_LOG(m_logger) << "Receive NlosTargetData Size: " << radioTelegram.data()->getSize() << "\n Structure: " << doc.toJson(QJsonDocument::Indented);
|
||||
// return;
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// miscellaneous messages..
|
||||
@@ -555,8 +554,7 @@ void TTWorker::handleDataIndReq(const QByteArray &data)
|
||||
|
||||
static void fillHeader(char *data, int len)
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvRadioTelegram::PrtCnvRadioGwHeader *hdr
|
||||
= (N_CoPrtCnv::CoPrtCnvRadioTelegram::PrtCnvRadioGwHeader *)data;
|
||||
N_CoPrtCnv::CoPrtCnvRadioTelegram::PrtCnvRadioGwHeader *hdr = (N_CoPrtCnv::CoPrtCnvRadioTelegram::PrtCnvRadioGwHeader *)data;
|
||||
hdr->m_MagicNumber = N_CoPrtCnv::CoPrtCnvRadioTelegram::MAGIC_NUMBER;
|
||||
hdr->m_Counter = 0;
|
||||
hdr->m_Length = len;
|
||||
@@ -582,12 +580,14 @@ void TTWorker::movePlayer(Player *p) // move the player like the pattern says
|
||||
// use all variables from the Player POINTER (do not use new instances)
|
||||
|
||||
if (p->patternInList > m_patternList.count() - 1) // if patternInList is HIGHER than the list-count is, then jump back to position 0 to start again
|
||||
p->patternInList = 0; // set to list-start
|
||||
p->patternInList = 0; // set to list-start
|
||||
else
|
||||
{
|
||||
if (p->stepInPattern > m_patternList.at(p->patternInList).steps) // if we have less steps than the stepInPattern says, then we have obsolved all wnted steps, so we can jump to the new pattern in the List
|
||||
if (p->stepInPattern >
|
||||
m_patternList.at(p->patternInList)
|
||||
.steps) // if we have less steps than the stepInPattern says, then we have obsolved all wnted steps, so we can jump to the new pattern in the List
|
||||
{
|
||||
p->stepInPattern = 1; // reset steps for the new pattern
|
||||
p->stepInPattern = 1; // reset steps for the new pattern
|
||||
if (p->patternInList == m_patternList.count() - 1) // if there is NOT a next pattern, then reset pattern counter to 0
|
||||
p->patternInList = 0;
|
||||
else
|
||||
@@ -595,10 +595,8 @@ void TTWorker::movePlayer(Player *p) // move the player like the pattern says
|
||||
}
|
||||
}
|
||||
|
||||
p->posUTM.setX(p->posUTM.x() +
|
||||
m_patternList.at(p->patternInList).northering); // increase northering as the pattern says
|
||||
p->posUTM.setY(p->posUTM.y() +
|
||||
m_patternList.at(p->patternInList).ethering); // ^^^^^^^^ ethering ^^^^^^^^^^^^^^^^^^^
|
||||
p->posUTM.setX(p->posUTM.x() + m_patternList.at(p->patternInList).northering); // increase northering as the pattern says
|
||||
p->posUTM.setY(p->posUTM.y() + m_patternList.at(p->patternInList).ethering); // ^^^^^^^^ ethering ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
p->stepInPattern++; // increase the step counter before we leave, so the player can be moved the next time!!
|
||||
}
|
||||
@@ -621,8 +619,13 @@ void TTWorker::onSendPlayerPositions()
|
||||
playerCount++;
|
||||
|
||||
// respawn :
|
||||
if (p->vbg != TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady && p->isEndOfTicks()) // only count to zero (isEndOfTicks = are the ticks running out ?) for respawn, if Player is NOT alive!
|
||||
sendTaktischerStatus(p->eqId, p->issi, TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady); // only give rebirth, do not kill //(unsigned short)!p->isAlive); // kill Player if he is alive, give rebirth to Player if he is dead
|
||||
if (p->vbg != TrainingAreaBase::TetraIcd::VulnerabilityState::CombatReady &&
|
||||
p->isEndOfTicks()) // only count to zero (isEndOfTicks = are the ticks running out ?) for respawn, if Player is NOT alive!
|
||||
sendTaktischerStatus(
|
||||
p->eqId,
|
||||
p->issi,
|
||||
TrainingAreaBase::TetraIcd::VulnerabilityState::
|
||||
CombatReady); // only give rebirth, do not kill //(unsigned short)!p->isAlive); // kill Player if he is alive, give rebirth to Player if he is dead
|
||||
|
||||
tele.header.equipmentNumber = p->eqId;
|
||||
if (m_toogle)
|
||||
|
||||
@@ -27,17 +27,14 @@ class QTimer;
|
||||
class Player
|
||||
{
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void randomizeDeathTicks()
|
||||
{
|
||||
deathTicks = ((qrand() % (maximumDeathTicks - minimumDeathTicks + 1)) + minimumDeathTicks);
|
||||
}
|
||||
NGL::INGLLogger &m_logger;
|
||||
void randomizeDeathTicks() { deathTicks = ((qrand() % (maximumDeathTicks - minimumDeathTicks + 1)) + minimumDeathTicks); }
|
||||
|
||||
public:
|
||||
// PU simulation vars:
|
||||
uint32_t eqId;
|
||||
uint32_t issi;
|
||||
QPointF posUTM;
|
||||
QPointF posUTM;
|
||||
|
||||
// PU login-state vars:
|
||||
bool isLogin;
|
||||
@@ -54,17 +51,17 @@ public:
|
||||
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_)
|
||||
: 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();
|
||||
}
|
||||
@@ -107,8 +104,7 @@ protected:
|
||||
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)
|
||||
template <typename T> void sendTelegram(const T &tele, uint32_t issi)
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram ct(tele);
|
||||
sendTelegram(N_CoPrtCnv::CoPrtCnvTelegramConverter::convertToRadio(&ct), issi);
|
||||
|
||||
Reference in new issue
Block a user