Formats minimally release source files based on former clang-format

This commit is contained in:
torsten committed 2026-10-14 13:28:01 +00:00
1 parent b662e4daf9
commit 5644914fe3
387 files changed
+37323 -38074

No files matched your search

@@ -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)