diff --git a/include/aoclient.h b/include/aoclient.h index f45c988..0efa315 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -139,6 +139,7 @@ class AOClient : public QObject { // Packet helper functions void sendEvidenceList(AreaData* area); + void updateEvidenceList(AreaData* area); AOPacket validateIcPacket(AOPacket packet); QString dezalgo(QString p_text); bool checkEvidenceAccess(AreaData* area); diff --git a/src/commands.cpp b/src/commands.cpp index 90d9c7e..4cb0c06 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -365,6 +365,7 @@ void AOClient::cmdLogout(int argc, QStringList argv) void AOClient::cmdPos(int argc, QStringList argv) { changePosition(argv[0]); + updateEvidenceList(server->areas[current_area]); } void AOClient::cmdForcePos(int argc, QStringList argv) @@ -699,6 +700,9 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) return; } sendServerMessage("Changed evidence mod."); + + // Resend evidence lists to everyone in the area + sendEvidenceList(area); } void AOClient::cmdArea(int argc, QStringList argv) diff --git a/src/packets.cpp b/src/packets.cpp index 8b3b64f..729d30f 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -302,18 +302,37 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac } void AOClient::sendEvidenceList(AreaData* area) +{ + for (AOClient* client : server->clients) { + if (client->current_area == current_area) + client->updateEvidenceList(area); + } +} + +void AOClient::updateEvidenceList(AreaData* area) { QStringList evidence_list; QString evidence_format("%1&%2&%3"); for (AreaData::Evidence evidence : area->evidence) { + if (!checkAuth(ACLFlags.value("CM")) && area->evi_mod == AreaData::EvidenceMod::HIDDEN_CM) { + QRegularExpression regex(""); + QRegularExpressionMatch match = regex.match(evidence.description); + if (match.hasMatch()) { + QStringList owners = match.captured(1).split(","); + if (!owners.contains("all", Qt::CaseSensitivity::CaseInsensitive) && !owners.contains(pos, Qt::CaseSensitivity::CaseInsensitive)) { + continue; + } + } + // no match = show it to all + } evidence_list.append(evidence_format - .arg(evidence.name) - .arg(evidence.description) - .arg(evidence.image)); + .arg(evidence.name) + .arg(evidence.description) + .arg(evidence.image)); } - server->broadcast(AOPacket("LE", evidence_list), current_area); + sendPacket(AOPacket("LE", evidence_list)); } AOPacket AOClient::validateIcPacket(AOPacket packet) @@ -381,6 +400,10 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // side // this is validated clientside so w/e args.append(incoming_args[5].toString()); + if (pos != incoming_args[5].toString()) { + pos = incoming_args[5].toString(); + updateEvidenceList(server->areas[current_area]); + } // sfx name args.append(incoming_args[6].toString());