Fix remaining clazy-writing-to-temporary issues

This commit is contained in:
Cerapter 2021-05-04 22:38:39 +02:00
parent 9b081a1ce4
commit 9423b25bf5
3 changed files with 38 additions and 11 deletions

View File

@ -253,6 +253,12 @@ class AreaData : public QObject {
void swapEvidence(int f_eviId1, int f_eviId2); void swapEvidence(int f_eviId1, int f_eviId2);
void appendEvidence(const Evidence& f_evi_r);
void deleteEvidence(int f_eviId);
void replaceEvidence(int f_eviId, const Evidence& f_newEvi_r);
Status status() const; Status status() const;
bool changeStatus(const QString& f_newStatus_r); bool changeStatus(const QString& f_newStatus_r);
@ -324,7 +330,9 @@ class AreaData : public QObject {
QStringList judgelog() const; QStringList judgelog() const;
QStringList lastICMessage() const; void appendJudgelog(const QString& f_newLog_r);
const QStringList& lastICMessage() const;
void updateLastICMessage(const QStringList& f_lastMessage); void updateLastICMessage(const QStringList& f_lastMessage);

View File

@ -240,6 +240,21 @@ void AreaData::swapEvidence(int f_eviId1, int f_eviId2)
#endif #endif
} }
void AreaData::appendEvidence(const AreaData::Evidence &f_evi_r)
{
m_evidence.append(f_evi_r);
}
void AreaData::deleteEvidence(int f_eviId)
{
m_evidence.removeAt(f_eviId);
}
void AreaData::replaceEvidence(int f_eviId, const AreaData::Evidence &f_newEvi_r)
{
m_evidence.replace(f_eviId, f_newEvi_r);
}
AreaData::Status AreaData::status() const AreaData::Status AreaData::status() const
{ {
return m_status; return m_status;
@ -331,7 +346,7 @@ void AreaData::toggleImmediate()
m_forceImmediate = !m_forceImmediate; m_forceImmediate = !m_forceImmediate;
} }
QStringList AreaData::lastICMessage() const const QStringList& AreaData::lastICMessage() const
{ {
return m_lastICMessage; return m_lastICMessage;
} }
@ -346,6 +361,15 @@ QStringList AreaData::judgelog() const
return m_judgelog; return m_judgelog;
} }
void AreaData::appendJudgelog(const QString &f_newLog_r)
{
if (m_judgelog.size() == 10) {
m_judgelog.removeFirst();
}
m_judgelog.append(f_newLog_r);
}
int AreaData::statement() const int AreaData::statement() const
{ {
return m_statement; return m_statement;

View File

@ -347,7 +347,7 @@ void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPack
if (!checkEvidenceAccess(area)) if (!checkEvidenceAccess(area))
return; return;
AreaData::Evidence evi = {argv[0], argv[1], argv[2]}; AreaData::Evidence evi = {argv[0], argv[1], argv[2]};
area->evidence().append(evi); area->appendEvidence(evi);
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -358,7 +358,7 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP
bool is_int = false; bool is_int = false;
int idx = argv[0].toInt(&is_int); int idx = argv[0].toInt(&is_int);
if (is_int && idx <= area->evidence().size() && idx >= 0) { if (is_int && idx <= area->evidence().size() && idx >= 0) {
area->evidence().removeAt(idx); area->deleteEvidence(idx);
} }
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -371,7 +371,7 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac
int idx = argv[0].toInt(&is_int); int idx = argv[0].toInt(&is_int);
AreaData::Evidence evi = {argv[1], argv[2], argv[3]}; AreaData::Evidence evi = {argv[1], argv[2], argv[3]};
if (is_int && idx <= area->evidence().size() && idx >= 0) { if (is_int && idx <= area->evidence().size() && idx >= 0) {
area->evidence().replace(idx, evi); area->replaceEvidence(idx, evi);
} }
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -828,12 +828,7 @@ void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action)
QString ipid = client->getIpid(); QString ipid = client->getIpid();
QString message = action; QString message = action;
QString logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(timestamp, uid, char_name, ipid, message); QString logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(timestamp, uid, char_name, ipid, message);
int size = area->judgelog().size(); area->appendJudgelog(logmessage);
if (size == 10) {
area->judgelog().removeFirst();
area->judgelog().append(logmessage);
}
else area->judgelog().append(logmessage);
} }
QString AOClient::decodeMessage(QString incoming_message) QString AOClient::decodeMessage(QString incoming_message)