add all evidence mods EXCEPT hiddencm

This commit is contained in:
scatterflower 2021-03-11 02:05:38 -06:00
parent 5b328859cd
commit 1d4c1b8cda
6 changed files with 67 additions and 4 deletions

View File

@ -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
iniswap_allowed=true
evidence_mod=ffa

View File

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

View File

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

View File

@ -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;
}

View File

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

View File

@ -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;
}
}