Change all accesses to getters

This commit is contained in:
Cerapter 2021-05-01 16:05:50 +02:00
parent 5a0c291825
commit 85cc9af73a
14 changed files with 363 additions and 172 deletions

View File

@ -220,6 +220,62 @@ class AreaData : public QObject {
*/ */
bool invite(int f_clientId); bool invite(int f_clientId);
int playerCount() const;
QList<QTimer *> timers() const;
QString name() const;
int index() const;
QList<int> charactersTaken() const;
QList<Evidence> evidence() const;
Status status() const;
QList<int> invited() const;
LockStatus locked() const;
QString background() const;
bool shownameAllowed() const;
bool iniswapAllowed() const;
bool bgLocked() const;
QString document() const;
int defHP() const;
int proHP() const;
QString currentMusic() const;
QString musicPlayerBy() const;
Logger *logger() const;
EvidenceMod eviMod() const;
QMap<QString, QString> notecards() const;
TestimonyRecording testimonyRecording() const;
QVector<QStringList> testimony() const;
int statement() const;
QStringList judgelog() const;
QStringList lastICMessage() const;
bool forceImmediate() const;
bool toggleMusic() const;
private: private:
/** /**
* @brief The list of timers available in the area. * @brief The list of timers available in the area.

View File

@ -107,34 +107,34 @@ void AOClient::changeArea(int new_area)
sendServerMessage("You are already in area " + server->area_names[current_area]); sendServerMessage("You are already in area " + server->area_names[current_area]);
return; return;
} }
if (server->areas[new_area]->m_locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->m_invited.contains(id)) { if (server->areas[new_area]->locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->invited().contains(id)) {
sendServerMessage("Area " + server->area_names[new_area] + " is locked."); sendServerMessage("Area " + server->area_names[new_area] + " is locked.");
return; return;
} }
if (current_char != "") { if (current_char != "") {
server->areas[current_area]->m_charactersTaken.removeAll(server->getCharID(current_char)); server->areas[current_area]->charactersTaken().removeAll(server->getCharID(current_char));
server->updateCharsTaken(server->areas[current_area]); server->updateCharsTaken(server->areas[current_area]);
} }
server->areas[new_area]->m_playerCount++; server->areas[new_area]->playerCount()++;
server->areas[current_area]->m_playerCount--; server->areas[current_area]->playerCount()--;
current_area = new_area; current_area = new_area;
arup(ARUPType::PLAYER_COUNT, true); arup(ARUPType::PLAYER_COUNT, true);
sendEvidenceList(server->areas[new_area]); sendEvidenceList(server->areas[new_area]);
sendPacket("HP", {"1", QString::number(server->areas[new_area]->m_defHP)}); sendPacket("HP", {"1", QString::number(server->areas[new_area]->defHP())});
sendPacket("HP", {"2", QString::number(server->areas[new_area]->m_proHP)}); sendPacket("HP", {"2", QString::number(server->areas[new_area]->proHP())});
sendPacket("BN", {server->areas[new_area]->m_background}); sendPacket("BN", {server->areas[new_area]->background()});
if (server->areas[current_area]->m_charactersTaken.contains(server->getCharID(current_char))) { if (server->areas[current_area]->charactersTaken().contains(server->getCharID(current_char))) {
server->updateCharsTaken(server->areas[current_area]); server->updateCharsTaken(server->areas[current_area]);
current_char = ""; current_char = "";
sendPacket("DONE"); sendPacket("DONE");
} }
else { else {
server->areas[current_area]->m_charactersTaken.append(server->getCharID(current_char)); server->areas[current_area]->charactersTaken().append(server->getCharID(current_char));
server->updateCharsTaken(server->areas[current_area]); server->updateCharsTaken(server->areas[current_area]);
} }
for (QTimer* timer : server->areas[current_area]->m_timer) { for (QTimer* timer : server->areas[current_area]->timers()) {
int timer_id = server->areas[current_area]->m_timer.indexOf(timer) + 1; int timer_id = server->areas[current_area]->timers().indexOf(timer) + 1;
if (timer->isActive()) { if (timer->isActive()) {
sendPacket("TI", {QString::number(timer_id), "2"}); sendPacket("TI", {QString::number(timer_id), "2"});
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
@ -144,7 +144,7 @@ void AOClient::changeArea(int new_area)
} }
} }
sendServerMessage("You moved to area " + server->area_names[current_area]); sendServerMessage("You moved to area " + server->area_names[current_area]);
if (server->areas[current_area]->m_locked == AreaData::LockStatus::SPECTATABLE) if (server->areas[current_area]->locked == AreaData::LockStatus::SPECTATABLE)
sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
} }
@ -160,16 +160,16 @@ bool AOClient::changeCharacter(int char_id)
} }
if (current_char != "") { if (current_char != "") {
area->m_charactersTaken.removeAll(server->getCharID(current_char)); area->charactersTaken().removeAll(server->getCharID(current_char));
} }
if (char_id >= 0) { if (char_id >= 0) {
QString char_selected = server->characters[char_id]; QString char_selected = server->characters[char_id];
bool taken = area->m_charactersTaken.contains(char_id); bool taken = area->charactersTaken().contains(char_id);
if (taken || char_selected == "") if (taken || char_selected == "")
return false; return false;
area->m_charactersTaken.append(char_id); area->charactersTaken().append(char_id);
current_char = char_selected; current_char = char_selected;
} }
else { else {
@ -214,20 +214,20 @@ void AOClient::arup(ARUPType type, bool broadcast)
for (AreaData* area : server->areas) { for (AreaData* area : server->areas) {
switch(type) { switch(type) {
case ARUPType::PLAYER_COUNT: { case ARUPType::PLAYER_COUNT: {
arup_data.append(QString::number(area->m_playerCount)); arup_data.append(QString::number(area->playerCount()));
break; break;
} }
case ARUPType::STATUS: { case ARUPType::STATUS: {
QString area_status = QVariant::fromValue(area->m_status).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS QString area_status = QVariant::fromValue(area->status()).toString().replace("_", "-"); // LOOKING_FOR_PLAYERS to LOOKING-FOR-PLAYERS
arup_data.append(area_status); arup_data.append(area_status);
break; break;
} }
case ARUPType::CM: { case ARUPType::CM: {
if (area->m_owners.isEmpty()) if (area->owners().isEmpty())
arup_data.append("FREE"); arup_data.append("FREE");
else { else {
QStringList area_owners; QStringList area_owners;
for (int owner_id : area->m_owners) { for (int owner_id : area->owners()) {
AOClient* owner = server->getClientByID(owner_id); AOClient* owner = server->getClientByID(owner_id);
area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char);
} }
@ -236,7 +236,7 @@ void AOClient::arup(ARUPType type, bool broadcast)
break; break;
} }
case ARUPType::LOCKED: { case ARUPType::LOCKED: {
QString lock_status = QVariant::fromValue(area->m_locked).toString(); QString lock_status = QVariant::fromValue(area->locked).toString();
arup_data.append(lock_status); arup_data.append(lock_status);
break; break;
} }
@ -312,7 +312,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
if (acl_mask != ACLFlags.value("NONE")) { if (acl_mask != ACLFlags.value("NONE")) {
if (acl_mask == ACLFlags.value("CM")) { if (acl_mask == ACLFlags.value("CM")) {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_owners.contains(id)) if (area->owners().contains(id))
return true; return true;
} }
else if (!authenticated) { else if (!authenticated) {

View File

@ -138,3 +138,138 @@ int AreaData::playerCount() const
{ {
return m_playerCount; return m_playerCount;
} }
QList<QTimer *> AreaData::timers() const
{
return m_timers;
}
QString AreaData::name() const
{
return m_name;
}
int AreaData::index() const
{
return m_index;
}
QList<int> AreaData::charactersTaken() const
{
return m_charactersTaken;
}
QList<AreaData::Evidence> AreaData::evidence() const
{
return m_evidence;
}
AreaData::Status AreaData::status() const
{
return m_status;
}
QList<int> AreaData::invited() const
{
return m_invited;
}
AreaData::LockStatus AreaData::locked() const
{
return m_locked;
}
bool AreaData::toggleMusic() const
{
return m_toggleMusic;
}
bool AreaData::forceImmediate() const
{
return m_forceImmediate;
}
QStringList AreaData::lastICMessage() const
{
return m_lastICMessage;
}
QStringList AreaData::judgelog() const
{
return m_judgelog;
}
int AreaData::statement() const
{
return m_statement;
}
QVector<QStringList> AreaData::testimony() const
{
return m_testimony;
}
AreaData::TestimonyRecording AreaData::testimonyRecording() const
{
return m_testimonyRecording;
}
QMap<QString, QString> AreaData::notecards() const
{
return m_notecards;
}
AreaData::EvidenceMod AreaData::eviMod() const
{
return m_eviMod;
}
Logger *AreaData::logger() const
{
return m_logger;
}
QString AreaData::musicPlayerBy() const
{
return m_musicPlayerBy;
}
QString AreaData::currentMusic() const
{
return m_currentMusic;
}
int AreaData::proHP() const
{
return m_proHP;
}
int AreaData::defHP() const
{
return m_defHP;
}
QString AreaData::document() const
{
return m_document;
}
bool AreaData::bgLocked() const
{
return m_bgLocked;
}
bool AreaData::iniswapAllowed() const
{
return m_iniswapAllowed;
}
bool AreaData::shownameAllowed() const
{
return m_shownameAllowed;
}
QString AreaData::background() const
{
return m_background;
}

View File

@ -133,11 +133,11 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
sendServerMessage("You cannot uninvite a CM!"); sendServerMessage("You cannot uninvite a CM!");
return; return;
} }
else if (!area->m_invited.contains(uninvited_id)) { else if (!area->invited().contains(uninvited_id)) {
sendServerMessage("That ID is not on the invite list."); sendServerMessage("That ID is not on the invite list.");
return; return;
} }
area->m_invited.removeAll(uninvited_id); area->invited().removeAll(uninvited_id);
sendServerMessage("You uninvited ID " + argv[0]); sendServerMessage("You uninvited ID " + argv[0]);
} }
@ -149,10 +149,10 @@ void AOClient::cmdLock(int argc, QStringList argv)
return; return;
} }
sendServerMessageArea("This area is now locked."); sendServerMessageArea("This area is now locked.");
area->m_locked = AreaData::LockStatus::LOCKED; area->locked() = AreaData::LockStatus::LOCKED;
for (AOClient* client : server->clients) { for (AOClient* client : server->clients) {
if (client->current_area == current_area && client->joined) { if (client->current_area == current_area && client->joined) {
area->m_invited.append(client->id); area->invited().append(client->id);
} }
} }
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
@ -166,10 +166,10 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
return; return;
} }
sendServerMessageArea("This area is now spectatable."); sendServerMessageArea("This area is now spectatable.");
area->m_locked = AreaData::LockStatus::SPECTATABLE; area->locked() = AreaData::LockStatus::SPECTATABLE;
for (AOClient* client : server->clients) { for (AOClient* client : server->clients) {
if (client->current_area == current_area && client->joined) { if (client->current_area == current_area && client->joined) {
area->m_invited.append(client->id); area->invited().append(client->id);
} }
} }
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
@ -178,12 +178,12 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
void AOClient::cmdUnLock(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_locked == AreaData::LockStatus::FREE) { if (area->locked() == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked."); sendServerMessage("This area is not locked.");
return; return;
} }
sendServerMessageArea("This area is now unlocked."); sendServerMessageArea("This area is now unlocked.");
area->m_locked = AreaData::LockStatus::FREE; area->locked() = AreaData::LockStatus::FREE;
arup(ARUPType::LOCKED, true); arup(ARUPType::LOCKED, true);
} }
@ -235,9 +235,9 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
void AOClient::cmdSetBackground(int argc, QStringList argv) void AOClient::cmdSetBackground(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (authenticated || !area->m_bgLocked) { if (authenticated || !area->bgLocked()) {
if (server->backgrounds.contains(argv[0])) { if (server->backgrounds.contains(argv[0])) {
area->m_background = argv[0]; area->background() = argv[0];
server->broadcast(AOPacket("BN", {argv[0]}), current_area); server->broadcast(AOPacket("BN", {argv[0]}), current_area);
sendServerMessageArea(current_char + " changed the background to " + argv[0]); sendServerMessageArea(current_char + " changed the background to " + argv[0]);
} }
@ -253,14 +253,14 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
void AOClient::cmdBgLock(int argc, QStringList argv) void AOClient::cmdBgLock(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_bgLocked = true; area->bgLocked() = true;
server->broadcast(AOPacket("CT", {"Server", current_char + " locked the background.", "1"}), current_area); server->broadcast(AOPacket("CT", {"Server", current_char + " locked the background.", "1"}), current_area);
} }
void AOClient::cmdBgUnlock(int argc, QStringList argv) void AOClient::cmdBgUnlock(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_bgLocked = false; area->bgLocked() = false;
server->broadcast(AOPacket("CT", {"Server", current_char + " unlocked the background.", "1"}), current_area); server->broadcast(AOPacket("CT", {"Server", current_char + " unlocked the background.", "1"}), current_area);
} }
@ -269,17 +269,17 @@ void AOClient::cmdStatus(int argc, QStringList argv)
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
QString arg = argv[0].toLower(); QString arg = argv[0].toLower();
if (arg == "idle") if (arg == "idle")
area->m_status = AreaData::IDLE; area->status() = AreaData::IDLE;
else if (arg == "rp") else if (arg == "rp")
area->m_status = AreaData::RP; area->status() = AreaData::RP;
else if (arg == "casing") else if (arg == "casing")
area->m_status = AreaData::CASING; area->status() = AreaData::CASING;
else if (arg == "looking-for-players" || arg == "lfp") else if (arg == "looking-for-players" || arg == "lfp")
area->m_status = AreaData::LOOKING_FOR_PLAYERS; area->status() = AreaData::LOOKING_FOR_PLAYERS;
else if (arg == "recess") else if (arg == "recess")
area->m_status = AreaData::RECESS; area->status() = AreaData::RECESS;
else if (arg == "gaming") else if (arg == "gaming")
area->m_status = AreaData::GAMING; area->status() = AreaData::GAMING;
else { else {
sendServerMessage("That does not look like a valid status. Valid statuses are idle, rp, casing, lfp, recess, gaming"); sendServerMessage("That does not look like a valid status. Valid statuses are idle, rp, casing, lfp, recess, gaming");
return; return;
@ -291,11 +291,11 @@ void AOClient::cmdStatus(int argc, QStringList argv)
void AOClient::cmdJudgeLog(int argc, QStringList argv) void AOClient::cmdJudgeLog(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_judgelog.isEmpty()) { if (area->judgelog().isEmpty()) {
sendServerMessage("There have been no judge actions in this area."); sendServerMessage("There have been no judge actions in this area.");
return; return;
} }
QString message = area->m_judgelog.join("\n"); QString message = area->judgelog().join("\n");
//Judgelog contains an IPID, so we shouldn't send that unless the caller has appropriate permissions //Judgelog contains an IPID, so we shouldn't send that unless the caller has appropriate permissions
if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) { if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) {
sendServerMessage(message); sendServerMessage(message);

View File

@ -40,7 +40,7 @@ void AOClient::cmdLogin(int argc, QStringList argv)
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
sendServerMessage("Incorrect password."); sendServerMessage("Incorrect password.");
} }
server->areas.value(current_area)->m_logger->logLogin(this, authenticated, "moderator"); server->areas.value(current_area)->logger()->logLogin(this, authenticated, "moderator");
} }
else if (server->auth_type == "advanced") { else if (server->auth_type == "advanced") {
if (argc < 2) { if (argc < 2) {
@ -61,7 +61,7 @@ void AOClient::cmdLogin(int argc, QStringList argv)
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
sendServerMessage("Incorrect password."); sendServerMessage("Incorrect password.");
} }
server->areas.value(current_area)->m_logger->logLogin(this, authenticated, username); server->areas.value(current_area)->logger()->logLogin(this, authenticated, username);
} }
else { else {
qWarning() << "config.ini has an unrecognized auth_type!"; qWarning() << "config.ini has an unrecognized auth_type!";

View File

@ -25,10 +25,10 @@ void AOClient::cmdDoc(int argc, QStringList argv)
QString sender_name = ooc_name; QString sender_name = ooc_name;
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (argc == 0) { if (argc == 0) {
sendServerMessage("Document: " + area->m_document); sendServerMessage("Document: " + area->document());
} }
else { else {
area->m_document = argv.join(" "); area->document() = argv.join(" ");
sendServerMessageArea(sender_name + " changed the document."); sendServerMessageArea(sender_name + " changed the document.");
} }
} }
@ -37,7 +37,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv)
{ {
QString sender_name = ooc_name; QString sender_name = ooc_name;
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_document = "No document."; area->document() = "No document.";
sendServerMessageArea(sender_name + " cleared the document."); sendServerMessageArea(sender_name + " cleared the document.");
} }
@ -46,13 +46,13 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv)
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
argv[0] = argv[0].toLower(); argv[0] = argv[0].toLower();
if (argv[0] == "cm") if (argv[0] == "cm")
area->m_eviMod = AreaData::EvidenceMod::CM; area->eviMod() = AreaData::EvidenceMod::CM;
else if (argv[0] == "mod") else if (argv[0] == "mod")
area->m_eviMod = AreaData::EvidenceMod::MOD; area->eviMod() = AreaData::EvidenceMod::MOD;
else if (argv[0] == "hiddencm") else if (argv[0] == "hiddencm")
area->m_eviMod = AreaData::EvidenceMod::HIDDEN_CM; area->eviMod() = AreaData::EvidenceMod::HIDDEN_CM;
else if (argv[0] == "ffa") else if (argv[0] == "ffa")
area->m_eviMod = AreaData::EvidenceMod::FFA; area->eviMod() = AreaData::EvidenceMod::FFA;
else { else {
sendServerMessage("Invalid evidence mod."); sendServerMessage("Invalid evidence mod.");
return; return;
@ -66,7 +66,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv)
void AOClient::cmdEvidence_Swap(int argc, QStringList argv) void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int ev_size = area->m_evidence.size() -1; int ev_size = area->evidence().size() -1;
if (ev_size < 0) { if (ev_size < 0) {
sendServerMessage("No evidence in area."); sendServerMessage("No evidence in area.");
@ -89,7 +89,7 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
//swapItemsAt does not exist in Qt older than 5.13 //swapItemsAt does not exist in Qt older than 5.13
area->evidence.swap(ev_id1, ev_id2); area->evidence.swap(ev_id1, ev_id2);
#else #else
area->m_evidence.swapItemsAt(ev_id1, ev_id2); area->evidence().swapItemsAt(ev_id1, ev_id2);
#endif #endif
sendEvidenceList(area); sendEvidenceList(area);
sendServerMessage("The evidence " + QString::number(ev_id1) + " and " + QString::number(ev_id2) + " have been swapped."); sendServerMessage("The evidence " + QString::number(ev_id1) + " and " + QString::number(ev_id2) + " have been swapped.");
@ -102,12 +102,12 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
void AOClient::cmdTestify(int argc, QStringList argv) void AOClient::cmdTestify(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING) { if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one."); sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one.");
} }
else { else {
clearTestimony(); clearTestimony();
area->m_testimonyRecording = AreaData::TestimonyRecording::RECORDING; area->testimonyRecording() = AreaData::TestimonyRecording::RECORDING;
sendServerMessage("Started testimony recording."); sendServerMessage("Started testimony recording.");
} }
} }
@ -115,15 +115,15 @@ void AOClient::cmdTestify(int argc, QStringList argv)
void AOClient::cmdExamine(int argc, QStringList argv) void AOClient::cmdExamine(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_testimony.size() -1 > 0) if (area->testimony().size() -1 > 0)
{ {
area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK;
server->broadcast(AOPacket("RT",{"testimony2"}), current_area); server->broadcast(AOPacket("RT",{"testimony2"}), current_area);
server->broadcast(AOPacket("MS", {area->m_testimony[0]}), current_area); server->broadcast(AOPacket("MS", {area->testimony()[0]}), current_area);
area->m_statement = 0; area->statement() = 0;
return; return;
} }
if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK)
sendServerMessage("Unable to examine while another examination is running"); sendServerMessage("Unable to examine while another examination is running");
else else
sendServerMessage("Unable to start replay without prior examination."); sendServerMessage("Unable to start replay without prior examination.");
@ -132,15 +132,15 @@ void AOClient::cmdExamine(int argc, QStringList argv)
void AOClient::cmdTestimony(int argc, QStringList argv) void AOClient::cmdTestimony(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_testimony.size() -1 < 1) { if (area->testimony().size() -1 < 1) {
sendServerMessage("Unable to display empty testimony."); sendServerMessage("Unable to display empty testimony.");
return; return;
} }
QString ooc_message; QString ooc_message;
for (int i = 1; i <= area->m_testimony.size() -1; i++) for (int i = 1; i <= area->testimony().size() -1; i++)
{ {
QStringList packet = area->m_testimony.at(i); QStringList packet = area->testimony().at(i);
QString ic_message = packet[4]; QString ic_message = packet[4];
ooc_message.append( "[" + QString::number(i) + "]" + ic_message + "\n"); ooc_message.append( "[" + QString::number(i) + "]" + ic_message + "\n");
} }
@ -150,35 +150,35 @@ void AOClient::cmdTestimony(int argc, QStringList argv)
void AOClient::cmdDeleteStatement(int argc, QStringList argv) void AOClient::cmdDeleteStatement(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int c_statement = area->m_statement; int c_statement = area->statement();
if (area->m_testimony.size() - 1 == 0) { if (area->testimony().size() - 1 == 0) {
sendServerMessage("Unable to delete statement. No statements saved in this area."); sendServerMessage("Unable to delete statement. No statements saved in this area.");
} }
if (c_statement > 0 && area->m_testimony.size() > 2) { if (c_statement > 0 && area->testimony().size() > 2) {
area->m_testimony.remove(c_statement); area->testimony().remove(c_statement);
area->m_statement = c_statement - 1; area->statement() = c_statement - 1;
sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony."); sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony.");
} }
} }
void AOClient::cmdUpdateStatement(int argc, QStringList argv) void AOClient::cmdUpdateStatement(int argc, QStringList argv)
{ {
server->areas[current_area]->m_testimonyRecording = AreaData::TestimonyRecording::UPDATE; server->areas[current_area]->testimonyRecording() = AreaData::TestimonyRecording::UPDATE;
sendServerMessage("The next IC-Message will replace the last displayed replay message."); sendServerMessage("The next IC-Message will replace the last displayed replay message.");
} }
void AOClient::cmdPauseTestimony(int argc, QStringList argv) void AOClient::cmdPauseTestimony(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_testimonyRecording = AreaData::TestimonyRecording::STOPPED; area->testimonyRecording() = AreaData::TestimonyRecording::STOPPED;
server->broadcast(AOPacket("RT",{"testimony1#1"}), current_area); server->broadcast(AOPacket("RT",{"testimony1#1"}), current_area);
sendServerMessage("Testimony has been stopped."); sendServerMessage("Testimony has been stopped.");
} }
void AOClient::cmdAddStatement(int argc, QStringList argv) void AOClient::cmdAddStatement(int argc, QStringList argv)
{ {
if (server->areas[current_area]->m_statement < server->maximum_statements) { if (server->areas[current_area]->statement() < server->maximum_statements) {
server->areas[current_area]->m_testimonyRecording = AreaData::TestimonyRecording::ADD; server->areas[current_area]->testimonyRecording() = AreaData::TestimonyRecording::ADD;
sendServerMessage("The next IC-Message will be inserted into the testimony."); sendServerMessage("The next IC-Message will be inserted into the testimony.");
} }
else else
@ -196,7 +196,7 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
if (permission_found) { if (permission_found) {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_testimony.size() -1 <= 0) { if (area->testimony().size() -1 <= 0) {
sendServerMessage("Can't save an empty testimony."); sendServerMessage("Can't save an empty testimony.");
return; return;
} }
@ -216,9 +216,9 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
QTextStream out(&file); QTextStream out(&file);
out.setCodec("UTF-8"); out.setCodec("UTF-8");
if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
for (int i = 0; i <= area->m_testimony.size() -1; i++) for (int i = 0; i <= area->testimony().size() -1; i++)
{ {
out << area->m_testimony.at(i).join("#") << "\n"; out << area->testimony().at(i).join("#") << "\n";
} }
sendServerMessage("Testimony saved. To load it use /loadtestimony " + testimony_name); sendServerMessage("Testimony saved. To load it use /loadtestimony " + testimony_name);
testimony_saving = false; testimony_saving = false;
@ -258,7 +258,7 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv)
if (testimony_lines <= server->maximum_statements) { if (testimony_lines <= server->maximum_statements) {
QString line = in.readLine(); QString line = in.readLine();
QStringList packet = line.split("#"); QStringList packet = line.split("#");
area->m_testimony.append(packet); area->testimony().append(packet);
testimony_lines = testimony_lines + 1; testimony_lines = testimony_lines + 1;
} }
else { else {

View File

@ -43,13 +43,13 @@ QStringList AOClient::buildAreaList(int area_idx)
default: default:
break; break;
} }
entries.append("[" + QString::number(area->m_playerCount) + " users][" + QVariant::fromValue(area->m_status).toString().replace("_", "-") + "]"); entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]");
for (AOClient* client : server->clients) { for (AOClient* client : server->clients) {
if (client->current_area == area_idx && client->joined) { if (client->current_area == area_idx && client->joined) {
QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char;
if (client->current_char == "") if (client->current_char == "")
char_entry += "Spectator"; char_entry += "Spectator";
if (area->m_owners.contains(client->id)) if (area->owners().contains(client->id))
char_entry.insert(0, "[CM] "); char_entry.insert(0, "[CM] ");
if (authenticated) if (authenticated)
char_entry += " (" + client->getIpid() + "): " + client->ooc_name; char_entry += " (" + client->getIpid() + "): " + client->ooc_name;
@ -103,7 +103,7 @@ QString AOClient::getAreaTimer(int area_idx, int timer_idx)
if (timer_idx == 0) if (timer_idx == 0)
timer = server->timer; timer = server->timer;
else if (timer_idx > 0 && timer_idx <= 4) else if (timer_idx > 0 && timer_idx <= 4)
timer = area->m_timer[timer_idx - 1]; timer = area->timers()[timer_idx - 1];
else else
return "Invalid timer ID."; return "Invalid timer ID.";

View File

@ -106,7 +106,7 @@ void AOClient::cmdRandomChar(int argc, QStringList argv)
bool taken = true; bool taken = true;
while (taken) { while (taken) {
selected_char_id = genRand(0, server->characters.size() - 1); selected_char_id = genRand(0, server->characters.size() - 1);
if (!area->m_charactersTaken.contains(selected_char_id)) { if (!area->charactersTaken().contains(selected_char_id)) {
taken = false; taken = false;
} }
} }
@ -423,7 +423,7 @@ void AOClient::cmdA(int argc, QStringList argv)
} }
AreaData* area = server->areas[area_id]; AreaData* area = server->areas[area_id];
if (!area->m_owners.contains(id)) { if (!area->owners().contains(id)) {
sendServerMessage("You are not CM in that area."); sendServerMessage("You are not CM in that area.");
return; return;
} }
@ -441,7 +441,7 @@ void AOClient::cmdS(int argc, QStringList argv)
QString ooc_message = argv.join(" "); QString ooc_message = argv.join(" ");
for (int i = 0; i <= all_areas; i++) { for (int i = 0; i <= all_areas; i++) {
if (server->areas[i]->m_owners.contains(id)) if (server->areas[i]->owners().contains(id))
server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i); server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i);
} }
} }

View File

@ -333,7 +333,7 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv)
{ {
QString sender_name = ooc_name; QString sender_name = ooc_name;
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_blankpostingAllowed = !area->m_blankpostingAllowed; area->blankpostingAllowed() = !area->blankpostingAllowed();
if (area->blankpostingAllowed() == false) { if (area->blankpostingAllowed() == false) {
sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden."); sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden.");
} }
@ -391,16 +391,16 @@ void AOClient::cmdReload(int argc, QStringList argv)
void AOClient::cmdForceImmediate(int argc, QStringList argv) void AOClient::cmdForceImmediate(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_forceImmediate = !area->m_forceImmediate; area->forceImmediate() = !area->forceImmediate();
QString state = area->m_forceImmediate ? "on." : "off."; QString state = area->forceImmediate() ? "on." : "off.";
sendServerMessage("Forced immediate text processing in this area is now " + state); sendServerMessage("Forced immediate text processing in this area is now " + state);
} }
void AOClient::cmdAllowIniswap(int argc, QStringList argv) void AOClient::cmdAllowIniswap(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_iniswapAllowed = !area->m_iniswapAllowed; area->iniswapAllowed() = !area->iniswapAllowed();
QString state = area->m_iniswapAllowed ? "allowed." : "disallowed."; QString state = area->iniswapAllowed() ? "allowed." : "disallowed.";
sendServerMessage("Iniswapping in this area is now " + state); sendServerMessage("Iniswapping in this area is now " + state);
} }

View File

@ -28,8 +28,8 @@ void AOClient::cmdPlay(int argc, QStringList argv)
} }
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
QString song = argv.join(" "); QString song = argv.join(" ");
area->m_currentMusic = song; area->currentMusic() = song;
area->m_musicPlayerBy = showname; area->musicPlayerBy() = showname;
AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"});
server->broadcast(music_change, current_area); server->broadcast(music_change, current_area);
} }
@ -37,8 +37,8 @@ void AOClient::cmdPlay(int argc, QStringList argv)
void AOClient::cmdCurrentMusic(int argc, QStringList argv) void AOClient::cmdCurrentMusic(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_currentMusic != "" && area->m_currentMusic != "~stop.mp3") // dummy track for stopping music if (area->currentMusic() != "" && area->currentMusic() != "~stop.mp3") // dummy track for stopping music
sendServerMessage("The current song is " + area->m_currentMusic + " played by " + area->m_musicPlayerBy); sendServerMessage("The current song is " + area->currentMusic() + " played by " + area->musicPlayerBy());
else else
sendServerMessage("There is no music playing."); sendServerMessage("There is no music playing.");
} }
@ -86,7 +86,7 @@ void AOClient::cmdUnBlockDj(int argc, QStringList argv)
void AOClient::cmdToggleMusic(int argc, QStringList argv) void AOClient::cmdToggleMusic(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_toggleMusic = !area->m_toggleMusic; area->toggleMusic() = !area->toggleMusic();
QString state = area->m_toggleMusic ? "allowed." : "disallowed."; QString state = area->toggleMusic() ? "allowed." : "disallowed.";
sendServerMessage("Music in this area is now " + state); sendServerMessage("Music in this area is now " + state);
} }

View File

@ -48,7 +48,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
QStringList timers; QStringList timers;
timers.append("Currently active timers:"); timers.append("Currently active timers:");
for (int i = 0; i <= 4; i++) { for (int i = 0; i <= 4; i++) {
timers.append(getAreaTimer(area->m_index, i)); timers.append(getAreaTimer(area->index(), i));
} }
sendServerMessage(timers.join("\n")); sendServerMessage(timers.join("\n"));
return; return;
@ -65,7 +65,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
// Called with one argument // Called with one argument
// Shows the status of one timer // Shows the status of one timer
if (argc == 1) { if (argc == 1) {
sendServerMessage(getAreaTimer(area->m_index, timer_id)); sendServerMessage(getAreaTimer(area->index(), timer_id));
return; return;
} }
@ -83,7 +83,7 @@ void AOClient::cmdTimer(int argc, QStringList argv)
requested_timer = server->timer; requested_timer = server->timer;
} }
else else
requested_timer = area->m_timers[timer_id - 1]; requested_timer = area->timers()s[timer_id - 1];
AOPacket show_timer("TI", {QString::number(timer_id), "2"}); AOPacket show_timer("TI", {QString::number(timer_id), "2"});
AOPacket hide_timer("TI", {QString::number(timer_id), "3"}); AOPacket hide_timer("TI", {QString::number(timer_id), "3"});

View File

@ -96,19 +96,19 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
} }
server->player_count++; server->player_count++;
area->m_playerCount++; area->playerCount()++;
joined = true; joined = true;
server->updateCharsTaken(area); server->updateCharsTaken(area);
arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player
sendEvidenceList(area); sendEvidenceList(area);
sendPacket("HP", {"1", QString::number(area->m_defHP)}); sendPacket("HP", {"1", QString::number(area->defHP())});
sendPacket("HP", {"2", QString::number(area->m_proHP)}); sendPacket("HP", {"2", QString::number(area->proHP())});
sendPacket("FA", server->area_names); sendPacket("FA", server->area_names);
sendPacket("OPPASS", {"DEADBEEF"}); sendPacket("OPPASS", {"DEADBEEF"});
sendPacket("DONE"); sendPacket("DONE");
sendPacket("BN", {area->m_background}); sendPacket("BN", {area->background()});
sendServerMessage("=== MOTD ===\r\n" + server->MOTD + "\r\n============="); sendServerMessage("=== MOTD ===\r\n" + server->MOTD + "\r\n=============");
@ -120,8 +120,8 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
else { else {
sendPacket("TI", {"0", "3"}); sendPacket("TI", {"0", "3"});
} }
for (QTimer* timer : area->m_timer) { for (QTimer* timer : area->timers()) {
int timer_id = area->m_timer.indexOf(timer) + 1; int timer_id = area->timers().indexOf(timer) + 1;
if (timer->isActive()) { if (timer->isActive()) {
sendPacket("TI", {QString::number(timer_id), "2"}); sendPacket("TI", {QString::number(timer_id), "2"});
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
@ -164,10 +164,10 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
if (pos != "") if (pos != "")
validated_packet.contents[5] = pos; validated_packet.contents[5] = pos;
area->m_logger->logIC(this, &validated_packet); area->logger()->logIC(this, &validated_packet);
server->broadcast(validated_packet, current_area); server->broadcast(validated_packet, current_area);
area->m_lastICMessage.clear(); area->lastICMessage().clear();
area->m_lastICMessage.append(validated_packet.contents); area->lastICMessage().append(validated_packet.contents);
} }
void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
@ -196,12 +196,12 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
command = command.right(command.length() - 1); command = command.right(command.length() - 1);
cmd_argv.removeFirst(); cmd_argv.removeFirst();
int cmd_argc = cmd_argv.length(); int cmd_argc = cmd_argv.length();
area->m_logger->logCmd(this, &final_packet, command, cmd_argv); area->logger()->logCmd(this, &final_packet, command, cmd_argv);
handleCommand(command, cmd_argc, cmd_argv); handleCommand(command, cmd_argc, cmd_argv);
} }
else { else {
server->broadcast(final_packet, current_area); server->broadcast(final_packet, current_area);
area->m_logger->logOOC(this, &final_packet); area->logger()->logOOC(this, &final_packet);
} }
} }
@ -230,7 +230,7 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
sendServerMessage("You are blocked from changing the music."); sendServerMessage("You are blocked from changing the music.");
return; return;
} }
if (!area->m_toggleMusic && !checkAuth(ACLFlags.value("CM"))) { if (!area->toggleMusic() && !checkAuth(ACLFlags.value("CM"))) {
sendServerMessage("Music is disabled in this area."); sendServerMessage("Music is disabled in this area.");
return; return;
} }
@ -245,8 +245,8 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
else else
final_song = argument; final_song = argument;
AOPacket music_change("MC", {final_song, argv[1], showname, "1", "0", effects}); AOPacket music_change("MC", {final_song, argv[1], showname, "1", "0", effects});
area->m_currentMusic = final_song; area->currentMusic() = final_song;
area->m_musicPlayerBy = showname; area->musicPlayerBy() = showname;
server->broadcast(music_change, current_area); server->broadcast(music_change, current_area);
return; return;
} }
@ -281,13 +281,13 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac
return; return;
} }
if (argv[0] == "1") { if (argv[0] == "1") {
area->m_defHP = std::min(std::max(0, argv[1].toInt()), 10); area->defHP() = std::min(std::max(0, argv[1].toInt()), 10);
} }
else if (argv[0] == "2") { else if (argv[0] == "2") {
area->m_proHP = std::min(std::max(0, argv[1].toInt()), 10); area->proHP() = std::min(std::max(0, argv[1].toInt()), 10);
} }
server->broadcast(AOPacket("HP", {"1", QString::number(area->m_defHP)}), area->m_index); server->broadcast(AOPacket("HP", {"1", QString::number(area->defHP())}), area->index());
server->broadcast(AOPacket("HP", {"2", QString::number(area->m_proHP)}), area->m_index); server->broadcast(AOPacket("HP", {"2", QString::number(area->proHP())}), area->index());
updateJudgeLog(area, this, "updated the penalties"); updateJudgeLog(area, this, "updated the penalties");
} }
@ -326,8 +326,8 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p
if (client->authenticated) if (client->authenticated)
client->sendPacket(packet); client->sendPacket(packet);
} }
area->m_logger->logModcall(this, &packet); area->logger()->logModcall(this, &packet);
area->m_logger->flush(); area->logger()->flush();
} }
void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
@ -335,7 +335,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->m_evidence.append(evi); area->evidence().append(evi);
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -345,8 +345,8 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP
return; return;
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->m_evidence.size() && idx >= 0) { if (is_int && idx <= area->evidence().size() && idx >= 0) {
area->m_evidence.removeAt(idx); area->evidence().removeAt(idx);
} }
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -358,8 +358,8 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac
bool is_int = false; bool is_int = false;
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->m_evidence.size() && idx >= 0) { if (is_int && idx <= area->evidence().size() && idx >= 0) {
area->m_evidence.replace(idx, evi); area->evidence().replace(idx, evi);
} }
sendEvidenceList(area); sendEvidenceList(area);
} }
@ -430,8 +430,8 @@ void AOClient::updateEvidenceList(AreaData* area)
QStringList evidence_list; QStringList evidence_list;
QString evidence_format("%1&%2&%3"); QString evidence_format("%1&%2&%3");
for (AreaData::Evidence evidence : area->m_evidence) { for (AreaData::Evidence evidence : area->evidence()) {
if (!checkAuth(ACLFlags.value("CM")) && area->m_eviMod == AreaData::EvidenceMod::HIDDEN_CM) { if (!checkAuth(ACLFlags.value("CM")) && area->eviMod() == AreaData::EvidenceMod::HIDDEN_CM) {
QRegularExpression regex("<owner=(.*?)>"); QRegularExpression regex("<owner=(.*?)>");
QRegularExpressionMatch match = regex.match(evidence.description); QRegularExpressionMatch match = regex.match(evidence.description);
if (match.hasMatch()) { if (match.hasMatch()) {
@ -466,7 +466,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
// Spectators cannot use IC // Spectators cannot use IC
return invalid; return invalid;
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (area->m_locked == AreaData::LockStatus::SPECTATABLE && !area->m_invited.contains(id)) if (area->locked() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(id))
// Non-invited players cannot speak in spectatable areas // Non-invited players cannot speak in spectatable areas
return invalid; return invalid;
@ -491,7 +491,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
if (current_char != incoming_args[2].toString()) { if (current_char != incoming_args[2].toString()) {
// Selected char is different from supplied folder name // Selected char is different from supplied folder name
// This means the user is INI-swapped // This means the user is INI-swapped
if (!area->m_iniswapAllowed) { if (!area->iniswapAllowed()) {
if (!server->characters.contains(incoming_args[2].toString())) if (!server->characters.contains(incoming_args[2].toString()))
return invalid; return invalid;
} }
@ -509,12 +509,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
return invalid; return invalid;
QString incoming_msg = dezalgo(incoming_args[4].toString().trimmed()); QString incoming_msg = dezalgo(incoming_args[4].toString().trimmed());
if (!area->m_lastICMessage.isEmpty() if (!area->lastICMessage().isEmpty()
&& incoming_msg == area->m_lastICMessage[4] && incoming_msg == area->lastICMessage()[4]
&& incoming_msg != "") && incoming_msg != "")
return invalid; return invalid;
if (incoming_msg == "" && area->m_blankpostingAllowed == false) { if (incoming_msg == "" && area->blankpostingAllowed() == false) {
sendServerMessage("Blankposting has been forbidden in this area."); sendServerMessage("Blankposting has been forbidden in this area.");
return invalid; return invalid;
} }
@ -587,7 +587,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
// evidence // evidence
int evi_idx = incoming_args[11].toInt(); int evi_idx = incoming_args[11].toInt();
if (evi_idx > area->m_evidence.length()) if (evi_idx > area->evidence().length())
return invalid; return invalid;
args.append(QString::number(evi_idx)); args.append(QString::number(evi_idx));
@ -680,7 +680,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
// immediate text processing // immediate text processing
int immediate = incoming_args[18].toInt(); int immediate = incoming_args[18].toInt();
if (area->m_forceImmediate) if (area->forceImmediate())
immediate = 1; immediate = 1;
if (immediate != 1 && immediate != 0) if (immediate != 1 && immediate != 0)
return invalid; return invalid;
@ -714,10 +714,10 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
int additive = incoming_args[24].toInt(); int additive = incoming_args[24].toInt();
if (additive != 0 && additive != 1) if (additive != 0 && additive != 1)
return invalid; return invalid;
else if (area->m_lastICMessage.isEmpty()){ else if (area->lastICMessage().isEmpty()){
additive = 0; additive = 0;
} }
else if (!(char_id == area->m_lastICMessage[8].toInt())) { else if (!(char_id == area->lastICMessage()[8].toInt())) {
additive = 0; additive = 0;
} }
else if (additive == 1) { else if (additive == 1) {
@ -730,29 +730,29 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
} }
//Testimony playback //Testimony playback
if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING || area->m_testimonyRecording == AreaData::TestimonyRecording::ADD) { if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING || area->testimonyRecording() == AreaData::TestimonyRecording::ADD) {
if (args[5] != "wit") if (args[5] != "wit")
return AOPacket("MS", args); return AOPacket("MS", args);
if (area->m_statement == -1) { if (area->statement() == -1) {
args[4] = "~~\\n-- " + args[4] + " --"; args[4] = "~~\\n-- " + args[4] + " --";
args[14] = "3"; args[14] = "3";
server->broadcast(AOPacket("RT",{"testimony1"}), current_area); server->broadcast(AOPacket("RT",{"testimony1"}), current_area);
} }
addStatement(args); addStatement(args);
} }
else if (area->m_testimonyRecording == AreaData::TestimonyRecording::UPDATE) { else if (area->testimonyRecording() == AreaData::TestimonyRecording::UPDATE) {
args = updateStatement(args); args = updateStatement(args);
} }
else if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) { else if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) {
if (args[4] == ">") { if (args[4] == ">") {
pos = "wit"; pos = "wit";
area->m_statement = area->m_statement + 1; area->statement() = area->statement() + 1;
args = playTestimony(); args = playTestimony();
} }
if (args[4] == "<") { if (args[4] == "<") {
pos = "wit"; pos = "wit";
area->m_statement = area->m_statement - 1; area->statement() = area->statement() - 1;
args = playTestimony(); args = playTestimony();
} }
QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first. QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first.
@ -760,7 +760,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
QRegularExpressionMatch match = jump.match(decoded_message); QRegularExpressionMatch match = jump.match(decoded_message);
if (match.hasMatch()) { if (match.hasMatch()) {
pos = "wit"; pos = "wit";
area->m_statement = match.captured("int").toInt(); area->statement() = match.captured("int").toInt();
args= playTestimony(); args= playTestimony();
} }
} }
@ -777,7 +777,7 @@ QString AOClient::dezalgo(QString p_text)
bool AOClient::checkEvidenceAccess(AreaData *area) bool AOClient::checkEvidenceAccess(AreaData *area)
{ {
switch(area->m_eviMod) { switch(area->eviMod()) {
case AreaData::EvidenceMod::FFA: case AreaData::EvidenceMod::FFA:
return true; return true;
case AreaData::EvidenceMod::CM: case AreaData::EvidenceMod::CM:
@ -798,12 +798,12 @@ 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->m_judgelog.size(); int size = area->judgelog().size();
if (size == 10) { if (size == 10) {
area->m_judgelog.removeFirst(); area->judgelog().removeFirst();
area->m_judgelog.append(logmessage); area->judgelog().append(logmessage);
} }
else area->m_judgelog.append(logmessage); else area->judgelog().append(logmessage);
} }
QString AOClient::decodeMessage(QString incoming_message) QString AOClient::decodeMessage(QString incoming_message)

View File

@ -26,7 +26,7 @@ Server::Server(int p_port, int p_ws_port, QObject* parent) :
server = new QTcpServer(this); server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()), this, SLOT(clientConnected())); connect(server, SIGNAL(newConnection()), this, SLOT(clientConnected()));
timer = new QTimer(); timer = new Qtimers();
db_manager = new DBManager(); db_manager = new DBManager();
} }
@ -160,7 +160,7 @@ void Server::updateCharsTaken(AreaData* area)
{ {
QStringList chars_taken; QStringList chars_taken;
for (QString cur_char : characters) { for (QString cur_char : characters) {
chars_taken.append(area->m_charactersTaken.contains(getCharID(cur_char)) chars_taken.append(area->charactersTaken().contains(getCharID(cur_char))
? QStringLiteral("-1") ? QStringLiteral("-1")
: QStringLiteral("0")); : QStringLiteral("0"));
} }
@ -168,7 +168,7 @@ void Server::updateCharsTaken(AreaData* area)
AOPacket response_cc("CharsCheck", chars_taken); AOPacket response_cc("CharsCheck", chars_taken);
for (AOClient* client : clients) { for (AOClient* client : clients) {
if (client->current_area == area->m_index){ if (client->current_area == area->index()){
if (!client->is_charcursed) if (!client->is_charcursed)
client->sendPacket(response_cc); client->sendPacket(response_cc);
else { else {
@ -272,7 +272,7 @@ void Server::loadServerConfig()
if (!zalgo_tolerance_conversion_success) if (!zalgo_tolerance_conversion_success)
zalgo_tolerance = 3; zalgo_tolerance = 3;
bool maximum_statements_conversion_success; bool maximum_statements_conversion_success;
maximum_statements = config.value("maximum_statements", "10").toInt(&maximum_statements_conversion_success); maximum_statements = config.value("maximustatement()s", "10").toInt(&maximum_statements_conversion_success);
if (!maximum_statements_conversion_success) if (!maximum_statements_conversion_success)
maximum_statements = 10; maximum_statements = 10;
bool afk_timeout_conversion_success; bool afk_timeout_conversion_success;

View File

@ -22,30 +22,30 @@
void AOClient::addStatement(QStringList packet) void AOClient::addStatement(QStringList packet)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int c_statement = area->m_statement; int c_statement = area->statement();
if (c_statement >= -1) { if (c_statement >= -1) {
if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING) { if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
if (c_statement <= server->maximum_statements) { if (c_statement <= server->maximum_statements()s) {
if (c_statement == -1) if (c_statement == -1)
packet[14] = "3"; packet[14] = "3";
else else
packet[14] = "1"; packet[14] = "1";
area->m_statement = c_statement + 1; area->statement() = c_statement + 1;
area->m_testimony.append(packet); area->testimony().append(packet);
return; return;
} }
else { else {
sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached."); sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached.");
} }
} }
else if (area->m_testimonyRecording == AreaData::TestimonyRecording::ADD) { else if (area->testimonyRecording() == AreaData::TestimonyRecording::ADD) {
packet[14] = "1"; packet[14] = "1";
area->m_testimony.insert(c_statement,packet); area->testimony().insert(c_statement,packet);
area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK;
} }
else { else {
sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached."); sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached.");
area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK;
} }
} }
} }
@ -53,15 +53,15 @@ void AOClient::addStatement(QStringList packet)
QStringList AOClient::updateStatement(QStringList packet) QStringList AOClient::updateStatement(QStringList packet)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int c_statement = area->m_statement; int c_statement = area->statement();
area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK;
if (c_statement <= 0 || area->m_testimony[c_statement].empty()) if (c_statement <= 0 || area->testimony()[c_statement].empty())
sendServerMessage("Unable to update an empty statement. Please use /addtestimony."); sendServerMessage("Unable to update an empty statement. Please use /addtestimony.");
else { else {
packet[14] = "1"; packet[14] = "1";
area->m_testimony.replace(c_statement, packet); area->testimony().replace(c_statement, packet);
sendServerMessage("Updated current statement."); sendServerMessage("Updated current statement.");
return area->m_testimony[c_statement]; return area->testimony()[c_statement];
} }
return packet; return packet;
} }
@ -69,28 +69,28 @@ QStringList AOClient::updateStatement(QStringList packet)
void AOClient::clearTestimony() void AOClient::clearTestimony()
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
area->m_testimonyRecording = AreaData::TestimonyRecording::STOPPED; area->testimonyRecording() = AreaData::TestimonyRecording::STOPPED;
area->m_statement = -1; area->statement() = -1;
area->m_testimony.clear(); //!< Empty out the QVector area->testimony().clear(); //!< Empty out the QVector
area->m_testimony.squeeze(); //!< Release memory. Good idea? God knows, I do not. area->testimony().squeeze(); //!< Release memory. Good idea? God knows, I do not.
} }
QStringList AOClient::playTestimony() QStringList AOClient::playTestimony()
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int c_statement = area->m_statement; int c_statement = area->statement();
if (c_statement > area->m_testimony.size() - 1) { if (c_statement > area->testimony().size() - 1) {
sendServerMessageArea("Last statement reached. Looping to first statement."); sendServerMessageArea("Last statement reached. Looping to first statement.");
area->m_statement = 1; area->statement() = 1;
return area->m_testimony[area->m_statement]; return area->testimony()[area->statement()];
} }
if (c_statement <= 0) { if (c_statement <= 0) {
sendServerMessage("First statement reached."); sendServerMessage("First statement reached.");
area->m_statement = 1; area->statement() = 1;
return area->m_testimony[area->m_statement = 1]; return area->testimony()[area->statement() = 1];
} }
else { else {
return area->m_testimony[c_statement]; return area->testimony()[c_statement];
} }
} }