diff --git a/bin/config_sample/areas.ini b/bin/config_sample/areas.ini index 98bd00d..3769b7b 100644 --- a/bin/config_sample/areas.ini +++ b/bin/config_sample/areas.ini @@ -2,8 +2,10 @@ background=gs4 protected_area=true iniswap_allowed=false +evidence_mod=cm [Courtroom 1] background=gs4 protected_area=false -iniswap_allowed=true \ No newline at end of file +iniswap_allowed=true +evidence_mod=ffa \ No newline at end of file diff --git a/include/aoclient.h b/include/aoclient.h index 4b33f53..f45c988 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -75,6 +75,7 @@ class AOClient : public QObject { {"MODIFY_USERS", 1ULL << 3}, {"CM", 1ULL << 4}, {"GLOBAL_TIMER", 1ULL << 5}, + {"CHANGE_EVI_MOD", 1ULL << 6}, {"SUPER", ~0ULL} }; @@ -97,9 +98,9 @@ class AOClient : public QObject { }; enum RollType { - ROLL, - ROLLP, - ROLLA + ROLL, + ROLLP, + ROLLA }; void handlePacket(AOPacket packet); @@ -140,6 +141,7 @@ class AOClient : public QObject { void sendEvidenceList(AreaData* area); AOPacket validateIcPacket(AOPacket packet); QString dezalgo(QString p_text); + bool checkEvidenceAccess(AreaData* area); // Packet helper global variables int char_id = -1; @@ -220,6 +222,7 @@ class AOClient : public QObject { void cmdDoc(int argc, QStringList argv); void cmdClearDoc(int argc, QStringList argv); void cmdTimer(int argc, QStringList argv); + void cmdEvidenceMod(int argc, QStringList argv); // Messaging/Client void cmdPos(int argc, QStringList argv); void cmdForcePos(int argc, QStringList argv); @@ -294,6 +297,7 @@ class AOClient : public QObject { {"forcepos", {ACLFlags.value("CM"), 2, &AOClient::cmdForcePos}}, {"currentmusic", {ACLFlags.value("NONE"), 0, &AOClient::cmdCurrentMusic}}, {"pm", {ACLFlags.value("NONE"), 2, &AOClient::cmdPM}}, + {"evidence_mod", {ACLFlags.value("CHANGE_EVI_MOD"), 1, &AOClient::cmdEvidenceMod}} }; QString partial_packet; diff --git a/include/area_data.h b/include/area_data.h index 2ea154b..a70553a 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -74,6 +74,13 @@ class AreaData : public QObject { QString current_music; QString music_played_by; Logger* logger; + enum EvidenceMod{ + FFA, + MOD, + CM, + HIDDEN_CM + }; + EvidenceMod evi_mod; }; #endif // AREA_DATA_H diff --git a/src/area_data.cpp b/src/area_data.cpp index 179a803..c85ea25 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -30,6 +30,7 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) is_protected = areas_ini.value("protected_area", "false").toBool(); iniswap_allowed = areas_ini.value("iniswap_allowed", "true").toBool(); bg_locked = areas_ini.value("bg_locked", "false").toBool(); + QString configured_evi_mod = areas_ini.value("evidence_mod", "FFA").toString().toLower(); areas_ini.endGroup(); player_count = 0; locked = FREE; @@ -52,4 +53,13 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) timers.append(timer3); QTimer* timer4 = new QTimer(); timers.append(timer4); + + if (configured_evi_mod == "cm") + evi_mod = EvidenceMod::CM; + else if (configured_evi_mod == "mod") + evi_mod = EvidenceMod::MOD; + else if (configured_evi_mod == "hiddencm") + evi_mod = EvidenceMod::HIDDEN_CM; + else + evi_mod = EvidenceMod::FFA; } diff --git a/src/commands.cpp b/src/commands.cpp index d568471..90d9c7e 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -682,6 +682,25 @@ void AOClient::cmdTimer(int argc, QStringList argv) } } +void AOClient::cmdEvidenceMod(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + argv[0] = argv[0].toLower(); + if (argv[0] == "cm") + area->evi_mod = AreaData::EvidenceMod::CM; + else if (argv[0] == "mod") + area->evi_mod = AreaData::EvidenceMod::MOD; + else if (argv[0] == "hiddencm") + area->evi_mod = AreaData::EvidenceMod::HIDDEN_CM; + else if (argv[0] == "ffa") + area->evi_mod = AreaData::EvidenceMod::FFA; + else { + sendServerMessage("Invalid evidence mod."); + return; + } + sendServerMessage("Changed evidence mod."); +} + void AOClient::cmdArea(int argc, QStringList argv) { bool ok; diff --git a/src/packets.cpp b/src/packets.cpp index 678342c..8b3b64f 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -269,6 +269,8 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (!checkEvidenceAccess(area)) + return; AreaData::Evidence evi = {argv[0], argv[1], argv[2]}; area->evidence.append(evi); sendEvidenceList(area); @@ -276,6 +278,8 @@ void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPack void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (!checkEvidenceAccess(area)) + return; bool is_int = false; int idx = argv[0].toInt(&is_int); if (is_int && idx <= area->evidence.size() && idx >= 0) { @@ -286,6 +290,8 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet) { + if (!checkEvidenceAccess(area)) + return; bool is_int = false; int idx = argv[0].toInt(&is_int); AreaData::Evidence evi = {argv[1], argv[2], argv[3]}; @@ -549,3 +555,18 @@ QString AOClient::dezalgo(QString p_text) QString filtered = p_text.replace(rxp, ""); return filtered; } + +bool AOClient::checkEvidenceAccess(AreaData *area) +{ + switch(area->evi_mod) { + case AreaData::EvidenceMod::FFA: + return true; + case AreaData::EvidenceMod::CM: + case AreaData::EvidenceMod::HIDDEN_CM: + return checkAuth(ACLFlags.value("CM")); + case AreaData::EvidenceMod::MOD: + return authenticated; + default: + return false; + } +}