diff --git a/core/include/area_data.h b/core/include/area_data.h index b0cc75a..5040bae 100644 --- a/core/include/area_data.h +++ b/core/include/area_data.h @@ -220,6 +220,62 @@ class AreaData : public QObject { */ bool invite(int f_clientId); + int playerCount() const; + + QList timers() const; + + QString name() const; + + int index() const; + + QList charactersTaken() const; + + QList evidence() const; + + Status status() const; + + QList 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 notecards() const; + + TestimonyRecording testimonyRecording() const; + + QVector testimony() const; + + int statement() const; + + QStringList judgelog() const; + + QStringList lastICMessage() const; + + bool forceImmediate() const; + + bool toggleMusic() const; + private: /** * @brief The list of timers available in the area. diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp index 32d2ead..59bdb3b 100644 --- a/core/src/aoclient.cpp +++ b/core/src/aoclient.cpp @@ -107,34 +107,34 @@ void AOClient::changeArea(int new_area) sendServerMessage("You are already in area " + server->area_names[current_area]); 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."); return; } 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->areas[new_area]->m_playerCount++; - server->areas[current_area]->m_playerCount--; + server->areas[new_area]->playerCount()++; + server->areas[current_area]->playerCount()--; current_area = new_area; arup(ARUPType::PLAYER_COUNT, true); sendEvidenceList(server->areas[new_area]); - sendPacket("HP", {"1", QString::number(server->areas[new_area]->m_defHP)}); - sendPacket("HP", {"2", QString::number(server->areas[new_area]->m_proHP)}); - sendPacket("BN", {server->areas[new_area]->m_background}); - if (server->areas[current_area]->m_charactersTaken.contains(server->getCharID(current_char))) { + sendPacket("HP", {"1", QString::number(server->areas[new_area]->defHP())}); + sendPacket("HP", {"2", QString::number(server->areas[new_area]->proHP())}); + sendPacket("BN", {server->areas[new_area]->background()}); + if (server->areas[current_area]->charactersTaken().contains(server->getCharID(current_char))) { server->updateCharsTaken(server->areas[current_area]); current_char = ""; sendPacket("DONE"); } 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]); } - for (QTimer* timer : server->areas[current_area]->m_timer) { - int timer_id = server->areas[current_area]->m_timer.indexOf(timer) + 1; + for (QTimer* timer : server->areas[current_area]->timers()) { + int timer_id = server->areas[current_area]->timers().indexOf(timer) + 1; if (timer->isActive()) { 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())))}); @@ -144,7 +144,7 @@ void AOClient::changeArea(int new_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."); } @@ -160,16 +160,16 @@ bool AOClient::changeCharacter(int char_id) } if (current_char != "") { - area->m_charactersTaken.removeAll(server->getCharID(current_char)); + area->charactersTaken().removeAll(server->getCharID(current_char)); } if (char_id >= 0) { 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 == "") return false; - area->m_charactersTaken.append(char_id); + area->charactersTaken().append(char_id); current_char = char_selected; } else { @@ -214,20 +214,20 @@ void AOClient::arup(ARUPType type, bool broadcast) for (AreaData* area : server->areas) { switch(type) { case ARUPType::PLAYER_COUNT: { - arup_data.append(QString::number(area->m_playerCount)); + arup_data.append(QString::number(area->playerCount())); break; } 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); break; } case ARUPType::CM: { - if (area->m_owners.isEmpty()) + if (area->owners().isEmpty()) arup_data.append("FREE"); else { QStringList area_owners; - for (int owner_id : area->m_owners) { + for (int owner_id : area->owners()) { AOClient* owner = server->getClientByID(owner_id); area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char); } @@ -236,7 +236,7 @@ void AOClient::arup(ARUPType type, bool broadcast) break; } 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); break; } @@ -312,7 +312,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask) if (acl_mask != ACLFlags.value("NONE")) { if (acl_mask == ACLFlags.value("CM")) { AreaData* area = server->areas[current_area]; - if (area->m_owners.contains(id)) + if (area->owners().contains(id)) return true; } else if (!authenticated) { diff --git a/core/src/area_data.cpp b/core/src/area_data.cpp index 0c8f97f..2eb43c4 100644 --- a/core/src/area_data.cpp +++ b/core/src/area_data.cpp @@ -138,3 +138,138 @@ int AreaData::playerCount() const { return m_playerCount; } + +QList AreaData::timers() const +{ + return m_timers; +} + +QString AreaData::name() const +{ + return m_name; +} + +int AreaData::index() const +{ + return m_index; +} + +QList AreaData::charactersTaken() const +{ + return m_charactersTaken; +} + +QList AreaData::evidence() const +{ + return m_evidence; +} + +AreaData::Status AreaData::status() const +{ + return m_status; +} + +QList 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 AreaData::testimony() const +{ + return m_testimony; +} + +AreaData::TestimonyRecording AreaData::testimonyRecording() const +{ + return m_testimonyRecording; +} + +QMap 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; +} diff --git a/core/src/commands/area.cpp b/core/src/commands/area.cpp index 2740d31..61398b7 100644 --- a/core/src/commands/area.cpp +++ b/core/src/commands/area.cpp @@ -133,11 +133,11 @@ void AOClient::cmdUnInvite(int argc, QStringList argv) sendServerMessage("You cannot uninvite a CM!"); 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."); return; } - area->m_invited.removeAll(uninvited_id); + area->invited().removeAll(uninvited_id); sendServerMessage("You uninvited ID " + argv[0]); } @@ -149,10 +149,10 @@ void AOClient::cmdLock(int argc, QStringList argv) return; } sendServerMessageArea("This area is now locked."); - area->m_locked = AreaData::LockStatus::LOCKED; + area->locked() = AreaData::LockStatus::LOCKED; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { - area->m_invited.append(client->id); + area->invited().append(client->id); } } arup(ARUPType::LOCKED, true); @@ -166,10 +166,10 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) return; } sendServerMessageArea("This area is now spectatable."); - area->m_locked = AreaData::LockStatus::SPECTATABLE; + area->locked() = AreaData::LockStatus::SPECTATABLE; for (AOClient* client : server->clients) { if (client->current_area == current_area && client->joined) { - area->m_invited.append(client->id); + area->invited().append(client->id); } } arup(ARUPType::LOCKED, true); @@ -178,12 +178,12 @@ void AOClient::cmdSpectatable(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv) { 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."); return; } sendServerMessageArea("This area is now unlocked."); - area->m_locked = AreaData::LockStatus::FREE; + area->locked() = AreaData::LockStatus::FREE; arup(ARUPType::LOCKED, true); } @@ -235,9 +235,9 @@ void AOClient::cmdAreaKick(int argc, QStringList argv) void AOClient::cmdSetBackground(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (authenticated || !area->m_bgLocked) { + if (authenticated || !area->bgLocked()) { if (server->backgrounds.contains(argv[0])) { - area->m_background = argv[0]; + area->background() = argv[0]; server->broadcast(AOPacket("BN", {argv[0]}), current_area); 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) { 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); } void AOClient::cmdBgUnlock(int argc, QStringList argv) { 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); } @@ -269,17 +269,17 @@ void AOClient::cmdStatus(int argc, QStringList argv) AreaData* area = server->areas[current_area]; QString arg = argv[0].toLower(); if (arg == "idle") - area->m_status = AreaData::IDLE; + area->status() = AreaData::IDLE; else if (arg == "rp") - area->m_status = AreaData::RP; + area->status() = AreaData::RP; else if (arg == "casing") - area->m_status = AreaData::CASING; + area->status() = AreaData::CASING; 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") - area->m_status = AreaData::RECESS; + area->status() = AreaData::RECESS; else if (arg == "gaming") - area->m_status = AreaData::GAMING; + area->status() = AreaData::GAMING; else { sendServerMessage("That does not look like a valid status. Valid statuses are idle, rp, casing, lfp, recess, gaming"); return; @@ -291,11 +291,11 @@ void AOClient::cmdStatus(int argc, QStringList argv) void AOClient::cmdJudgeLog(int argc, QStringList argv) { 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."); 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 if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) { sendServerMessage(message); diff --git a/core/src/commands/authentication.cpp b/core/src/commands/authentication.cpp index d53b0dc..b4df7d2 100644 --- a/core/src/commands/authentication.cpp +++ b/core/src/commands/authentication.cpp @@ -40,7 +40,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." 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") { if (argc < 2) { @@ -61,7 +61,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful." 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 { qWarning() << "config.ini has an unrecognized auth_type!"; diff --git a/core/src/commands/casing.cpp b/core/src/commands/casing.cpp index 393ccbc..3bc708f 100644 --- a/core/src/commands/casing.cpp +++ b/core/src/commands/casing.cpp @@ -25,10 +25,10 @@ void AOClient::cmdDoc(int argc, QStringList argv) QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; if (argc == 0) { - sendServerMessage("Document: " + area->m_document); + sendServerMessage("Document: " + area->document()); } else { - area->m_document = argv.join(" "); + area->document() = argv.join(" "); sendServerMessageArea(sender_name + " changed the document."); } } @@ -37,7 +37,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - area->m_document = "No document."; + area->document() = "No document."; sendServerMessageArea(sender_name + " cleared the document."); } @@ -46,13 +46,13 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) AreaData* area = server->areas[current_area]; argv[0] = argv[0].toLower(); if (argv[0] == "cm") - area->m_eviMod = AreaData::EvidenceMod::CM; + area->eviMod() = AreaData::EvidenceMod::CM; else if (argv[0] == "mod") - area->m_eviMod = AreaData::EvidenceMod::MOD; + area->eviMod() = AreaData::EvidenceMod::MOD; else if (argv[0] == "hiddencm") - area->m_eviMod = AreaData::EvidenceMod::HIDDEN_CM; + area->eviMod() = AreaData::EvidenceMod::HIDDEN_CM; else if (argv[0] == "ffa") - area->m_eviMod = AreaData::EvidenceMod::FFA; + area->eviMod() = AreaData::EvidenceMod::FFA; else { sendServerMessage("Invalid evidence mod."); return; @@ -66,7 +66,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv) void AOClient::cmdEvidence_Swap(int argc, QStringList argv) { 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) { 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 area->evidence.swap(ev_id1, ev_id2); #else - area->m_evidence.swapItemsAt(ev_id1, ev_id2); + area->evidence().swapItemsAt(ev_id1, ev_id2); #endif sendEvidenceList(area); 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) { 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."); } else { clearTestimony(); - area->m_testimonyRecording = AreaData::TestimonyRecording::RECORDING; + area->testimonyRecording() = AreaData::TestimonyRecording::RECORDING; sendServerMessage("Started testimony recording."); } } @@ -115,15 +115,15 @@ void AOClient::cmdTestify(int argc, QStringList argv) void AOClient::cmdExamine(int argc, QStringList argv) { 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("MS", {area->m_testimony[0]}), current_area); - area->m_statement = 0; + server->broadcast(AOPacket("MS", {area->testimony()[0]}), current_area); + area->statement() = 0; return; } - if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) + if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) sendServerMessage("Unable to examine while another examination is running"); else 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) { 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."); return; } 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]; 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) { AreaData* area = server->areas[current_area]; - int c_statement = area->m_statement; - if (area->m_testimony.size() - 1 == 0) { + int c_statement = area->statement(); + if (area->testimony().size() - 1 == 0) { sendServerMessage("Unable to delete statement. No statements saved in this area."); } - if (c_statement > 0 && area->m_testimony.size() > 2) { - area->m_testimony.remove(c_statement); - area->m_statement = c_statement - 1; + if (c_statement > 0 && area->testimony().size() > 2) { + area->testimony().remove(c_statement); + area->statement() = c_statement - 1; sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony."); } } 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."); } void AOClient::cmdPauseTestimony(int argc, QStringList argv) { 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); sendServerMessage("Testimony has been stopped."); } void AOClient::cmdAddStatement(int argc, QStringList argv) { - if (server->areas[current_area]->m_statement < server->maximum_statements) { - server->areas[current_area]->m_testimonyRecording = AreaData::TestimonyRecording::ADD; + if (server->areas[current_area]->statement() < server->maximum_statements) { + server->areas[current_area]->testimonyRecording() = AreaData::TestimonyRecording::ADD; sendServerMessage("The next IC-Message will be inserted into the testimony."); } else @@ -196,7 +196,7 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv) if (permission_found) { 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."); return; } @@ -216,9 +216,9 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv) QTextStream out(&file); out.setCodec("UTF-8"); 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); testimony_saving = false; @@ -258,7 +258,7 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv) if (testimony_lines <= server->maximum_statements) { QString line = in.readLine(); QStringList packet = line.split("#"); - area->m_testimony.append(packet); + area->testimony().append(packet); testimony_lines = testimony_lines + 1; } else { diff --git a/core/src/commands/command_helper.cpp b/core/src/commands/command_helper.cpp index d9f77c3..a8af861 100644 --- a/core/src/commands/command_helper.cpp +++ b/core/src/commands/command_helper.cpp @@ -43,13 +43,13 @@ QStringList AOClient::buildAreaList(int area_idx) default: 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) { if (client->current_area == area_idx && client->joined) { QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char; if (client->current_char == "") char_entry += "Spectator"; - if (area->m_owners.contains(client->id)) + if (area->owners().contains(client->id)) char_entry.insert(0, "[CM] "); if (authenticated) char_entry += " (" + client->getIpid() + "): " + client->ooc_name; @@ -103,7 +103,7 @@ QString AOClient::getAreaTimer(int area_idx, int timer_idx) if (timer_idx == 0) timer = server->timer; else if (timer_idx > 0 && timer_idx <= 4) - timer = area->m_timer[timer_idx - 1]; + timer = area->timers()[timer_idx - 1]; else return "Invalid timer ID."; diff --git a/core/src/commands/messaging.cpp b/core/src/commands/messaging.cpp index 4e5b70f..e93bcae 100644 --- a/core/src/commands/messaging.cpp +++ b/core/src/commands/messaging.cpp @@ -106,7 +106,7 @@ void AOClient::cmdRandomChar(int argc, QStringList argv) bool taken = true; while (taken) { 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; } } @@ -423,7 +423,7 @@ void AOClient::cmdA(int argc, QStringList argv) } 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."); return; } @@ -441,7 +441,7 @@ void AOClient::cmdS(int argc, QStringList argv) QString ooc_message = argv.join(" "); 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); } } diff --git a/core/src/commands/moderation.cpp b/core/src/commands/moderation.cpp index 3330ea9..d813041 100644 --- a/core/src/commands/moderation.cpp +++ b/core/src/commands/moderation.cpp @@ -333,7 +333,7 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv) { QString sender_name = ooc_name; AreaData* area = server->areas[current_area]; - area->m_blankpostingAllowed = !area->m_blankpostingAllowed; + area->blankpostingAllowed() = !area->blankpostingAllowed(); if (area->blankpostingAllowed() == false) { 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) { AreaData* area = server->areas[current_area]; - area->m_forceImmediate = !area->m_forceImmediate; - QString state = area->m_forceImmediate ? "on." : "off."; + area->forceImmediate() = !area->forceImmediate(); + QString state = area->forceImmediate() ? "on." : "off."; sendServerMessage("Forced immediate text processing in this area is now " + state); } void AOClient::cmdAllowIniswap(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->m_iniswapAllowed = !area->m_iniswapAllowed; - QString state = area->m_iniswapAllowed ? "allowed." : "disallowed."; + area->iniswapAllowed() = !area->iniswapAllowed(); + QString state = area->iniswapAllowed() ? "allowed." : "disallowed."; sendServerMessage("Iniswapping in this area is now " + state); } diff --git a/core/src/commands/music.cpp b/core/src/commands/music.cpp index b8b6e35..fb4bcbc 100644 --- a/core/src/commands/music.cpp +++ b/core/src/commands/music.cpp @@ -28,8 +28,8 @@ void AOClient::cmdPlay(int argc, QStringList argv) } AreaData* area = server->areas[current_area]; QString song = argv.join(" "); - area->m_currentMusic = song; - area->m_musicPlayerBy = showname; + area->currentMusic() = song; + area->musicPlayerBy() = showname; AOPacket music_change("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); server->broadcast(music_change, current_area); } @@ -37,8 +37,8 @@ void AOClient::cmdPlay(int argc, QStringList argv) void AOClient::cmdCurrentMusic(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - if (area->m_currentMusic != "" && area->m_currentMusic != "~stop.mp3") // dummy track for stopping music - sendServerMessage("The current song is " + area->m_currentMusic + " played by " + area->m_musicPlayerBy); + if (area->currentMusic() != "" && area->currentMusic() != "~stop.mp3") // dummy track for stopping music + sendServerMessage("The current song is " + area->currentMusic() + " played by " + area->musicPlayerBy()); else sendServerMessage("There is no music playing."); } @@ -86,7 +86,7 @@ void AOClient::cmdUnBlockDj(int argc, QStringList argv) void AOClient::cmdToggleMusic(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; - area->m_toggleMusic = !area->m_toggleMusic; - QString state = area->m_toggleMusic ? "allowed." : "disallowed."; + area->toggleMusic() = !area->toggleMusic(); + QString state = area->toggleMusic() ? "allowed." : "disallowed."; sendServerMessage("Music in this area is now " + state); } diff --git a/core/src/commands/roleplay.cpp b/core/src/commands/roleplay.cpp index d401dc6..b364fb8 100644 --- a/core/src/commands/roleplay.cpp +++ b/core/src/commands/roleplay.cpp @@ -48,7 +48,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) QStringList timers; timers.append("Currently active timers:"); for (int i = 0; i <= 4; i++) { - timers.append(getAreaTimer(area->m_index, i)); + timers.append(getAreaTimer(area->index(), i)); } sendServerMessage(timers.join("\n")); return; @@ -65,7 +65,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) // Called with one argument // Shows the status of one timer if (argc == 1) { - sendServerMessage(getAreaTimer(area->m_index, timer_id)); + sendServerMessage(getAreaTimer(area->index(), timer_id)); return; } @@ -83,7 +83,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) requested_timer = server->timer; } 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 hide_timer("TI", {QString::number(timer_id), "3"}); diff --git a/core/src/packets.cpp b/core/src/packets.cpp index 9fec53d..9938348 100644 --- a/core/src/packets.cpp +++ b/core/src/packets.cpp @@ -96,19 +96,19 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack } server->player_count++; - area->m_playerCount++; + area->playerCount()++; joined = true; server->updateCharsTaken(area); arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player sendEvidenceList(area); - sendPacket("HP", {"1", QString::number(area->m_defHP)}); - sendPacket("HP", {"2", QString::number(area->m_proHP)}); + sendPacket("HP", {"1", QString::number(area->defHP())}); + sendPacket("HP", {"2", QString::number(area->proHP())}); sendPacket("FA", server->area_names); sendPacket("OPPASS", {"DEADBEEF"}); sendPacket("DONE"); - sendPacket("BN", {area->m_background}); + sendPacket("BN", {area->background()}); sendServerMessage("=== MOTD ===\r\n" + server->MOTD + "\r\n============="); @@ -120,8 +120,8 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack else { sendPacket("TI", {"0", "3"}); } - for (QTimer* timer : area->m_timer) { - int timer_id = area->m_timer.indexOf(timer) + 1; + for (QTimer* timer : area->timers()) { + int timer_id = area->timers().indexOf(timer) + 1; if (timer->isActive()) { 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())))}); @@ -164,10 +164,10 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa if (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); - area->m_lastICMessage.clear(); - area->m_lastICMessage.append(validated_packet.contents); + area->lastICMessage().clear(); + area->lastICMessage().append(validated_packet.contents); } 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); cmd_argv.removeFirst(); 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); } else { 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."); return; } - if (!area->m_toggleMusic && !checkAuth(ACLFlags.value("CM"))) { + if (!area->toggleMusic() && !checkAuth(ACLFlags.value("CM"))) { sendServerMessage("Music is disabled in this area."); return; } @@ -245,8 +245,8 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack else final_song = argument; AOPacket music_change("MC", {final_song, argv[1], showname, "1", "0", effects}); - area->m_currentMusic = final_song; - area->m_musicPlayerBy = showname; + area->currentMusic() = final_song; + area->musicPlayerBy() = showname; server->broadcast(music_change, current_area); return; } @@ -281,13 +281,13 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac return; } 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") { - 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", {"2", QString::number(area->m_proHP)}), area->m_index); + server->broadcast(AOPacket("HP", {"1", QString::number(area->defHP())}), area->index()); + server->broadcast(AOPacket("HP", {"2", QString::number(area->proHP())}), area->index()); updateJudgeLog(area, this, "updated the penalties"); } @@ -326,8 +326,8 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p if (client->authenticated) client->sendPacket(packet); } - area->m_logger->logModcall(this, &packet); - area->m_logger->flush(); + area->logger()->logModcall(this, &packet); + area->logger()->flush(); } 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)) return; AreaData::Evidence evi = {argv[0], argv[1], argv[2]}; - area->m_evidence.append(evi); + area->evidence().append(evi); sendEvidenceList(area); } @@ -345,8 +345,8 @@ void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOP return; bool is_int = false; int idx = argv[0].toInt(&is_int); - if (is_int && idx <= area->m_evidence.size() && idx >= 0) { - area->m_evidence.removeAt(idx); + if (is_int && idx <= area->evidence().size() && idx >= 0) { + area->evidence().removeAt(idx); } sendEvidenceList(area); } @@ -358,8 +358,8 @@ void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPac bool is_int = false; int idx = argv[0].toInt(&is_int); AreaData::Evidence evi = {argv[1], argv[2], argv[3]}; - if (is_int && idx <= area->m_evidence.size() && idx >= 0) { - area->m_evidence.replace(idx, evi); + if (is_int && idx <= area->evidence().size() && idx >= 0) { + area->evidence().replace(idx, evi); } sendEvidenceList(area); } @@ -430,8 +430,8 @@ void AOClient::updateEvidenceList(AreaData* area) QStringList evidence_list; QString evidence_format("%1&%2&%3"); - for (AreaData::Evidence evidence : area->m_evidence) { - if (!checkAuth(ACLFlags.value("CM")) && area->m_eviMod == AreaData::EvidenceMod::HIDDEN_CM) { + for (AreaData::Evidence evidence : area->evidence()) { + if (!checkAuth(ACLFlags.value("CM")) && area->eviMod() == AreaData::EvidenceMod::HIDDEN_CM) { QRegularExpression regex(""); QRegularExpressionMatch match = regex.match(evidence.description); if (match.hasMatch()) { @@ -466,7 +466,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // Spectators cannot use IC return invalid; 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 return invalid; @@ -491,7 +491,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) if (current_char != incoming_args[2].toString()) { // Selected char is different from supplied folder name // This means the user is INI-swapped - if (!area->m_iniswapAllowed) { + if (!area->iniswapAllowed()) { if (!server->characters.contains(incoming_args[2].toString())) return invalid; } @@ -509,12 +509,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) return invalid; QString incoming_msg = dezalgo(incoming_args[4].toString().trimmed()); - if (!area->m_lastICMessage.isEmpty() - && incoming_msg == area->m_lastICMessage[4] + if (!area->lastICMessage().isEmpty() + && incoming_msg == area->lastICMessage()[4] && incoming_msg != "") return invalid; - if (incoming_msg == "" && area->m_blankpostingAllowed == false) { + if (incoming_msg == "" && area->blankpostingAllowed() == false) { sendServerMessage("Blankposting has been forbidden in this area."); return invalid; } @@ -587,7 +587,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // evidence int evi_idx = incoming_args[11].toInt(); - if (evi_idx > area->m_evidence.length()) + if (evi_idx > area->evidence().length()) return invalid; args.append(QString::number(evi_idx)); @@ -680,7 +680,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) // immediate text processing int immediate = incoming_args[18].toInt(); - if (area->m_forceImmediate) + if (area->forceImmediate()) immediate = 1; if (immediate != 1 && immediate != 0) return invalid; @@ -714,10 +714,10 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) int additive = incoming_args[24].toInt(); if (additive != 0 && additive != 1) return invalid; - else if (area->m_lastICMessage.isEmpty()){ + else if (area->lastICMessage().isEmpty()){ additive = 0; } - else if (!(char_id == area->m_lastICMessage[8].toInt())) { + else if (!(char_id == area->lastICMessage()[8].toInt())) { additive = 0; } else if (additive == 1) { @@ -730,29 +730,29 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) } //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") return AOPacket("MS", args); - if (area->m_statement == -1) { + if (area->statement() == -1) { args[4] = "~~\\n-- " + args[4] + " --"; args[14] = "3"; server->broadcast(AOPacket("RT",{"testimony1"}), current_area); } addStatement(args); } - else if (area->m_testimonyRecording == AreaData::TestimonyRecording::UPDATE) { + else if (area->testimonyRecording() == AreaData::TestimonyRecording::UPDATE) { args = updateStatement(args); } - else if (area->m_testimonyRecording == AreaData::TestimonyRecording::PLAYBACK) { + else if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK) { if (args[4] == ">") { pos = "wit"; - area->m_statement = area->m_statement + 1; + area->statement() = area->statement() + 1; args = playTestimony(); } if (args[4] == "<") { pos = "wit"; - area->m_statement = area->m_statement - 1; + area->statement() = area->statement() - 1; args = playTestimony(); } 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); if (match.hasMatch()) { pos = "wit"; - area->m_statement = match.captured("int").toInt(); + area->statement() = match.captured("int").toInt(); args= playTestimony(); } } @@ -777,7 +777,7 @@ QString AOClient::dezalgo(QString p_text) bool AOClient::checkEvidenceAccess(AreaData *area) { - switch(area->m_eviMod) { + switch(area->eviMod()) { case AreaData::EvidenceMod::FFA: return true; case AreaData::EvidenceMod::CM: @@ -798,12 +798,12 @@ void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action) QString ipid = client->getIpid(); QString message = action; 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) { - area->m_judgelog.removeFirst(); - area->m_judgelog.append(logmessage); + area->judgelog().removeFirst(); + area->judgelog().append(logmessage); } - else area->m_judgelog.append(logmessage); + else area->judgelog().append(logmessage); } QString AOClient::decodeMessage(QString incoming_message) diff --git a/core/src/server.cpp b/core/src/server.cpp index 71b8c29..ca97b18 100644 --- a/core/src/server.cpp +++ b/core/src/server.cpp @@ -26,7 +26,7 @@ Server::Server(int p_port, int p_ws_port, QObject* parent) : server = new QTcpServer(this); connect(server, SIGNAL(newConnection()), this, SLOT(clientConnected())); - timer = new QTimer(); + timer = new Qtimers(); db_manager = new DBManager(); } @@ -160,7 +160,7 @@ void Server::updateCharsTaken(AreaData* area) { QStringList chars_taken; 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("0")); } @@ -168,7 +168,7 @@ void Server::updateCharsTaken(AreaData* area) AOPacket response_cc("CharsCheck", chars_taken); for (AOClient* client : clients) { - if (client->current_area == area->m_index){ + if (client->current_area == area->index()){ if (!client->is_charcursed) client->sendPacket(response_cc); else { @@ -272,7 +272,7 @@ void Server::loadServerConfig() if (!zalgo_tolerance_conversion_success) zalgo_tolerance = 3; 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) maximum_statements = 10; bool afk_timeout_conversion_success; diff --git a/core/src/testimony_recorder.cpp b/core/src/testimony_recorder.cpp index 12b83bf..d288334 100644 --- a/core/src/testimony_recorder.cpp +++ b/core/src/testimony_recorder.cpp @@ -22,30 +22,30 @@ void AOClient::addStatement(QStringList packet) { AreaData* area = server->areas[current_area]; - int c_statement = area->m_statement; + int c_statement = area->statement(); if (c_statement >= -1) { - if (area->m_testimonyRecording == AreaData::TestimonyRecording::RECORDING) { - if (c_statement <= server->maximum_statements) { + if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) { + if (c_statement <= server->maximum_statements()s) { if (c_statement == -1) packet[14] = "3"; else packet[14] = "1"; - area->m_statement = c_statement + 1; - area->m_testimony.append(packet); + area->statement() = c_statement + 1; + area->testimony().append(packet); return; } else { 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"; - area->m_testimony.insert(c_statement,packet); - area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; + area->testimony().insert(c_statement,packet); + area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK; } else { 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) { AreaData* area = server->areas[current_area]; - int c_statement = area->m_statement; - area->m_testimonyRecording = AreaData::TestimonyRecording::PLAYBACK; - if (c_statement <= 0 || area->m_testimony[c_statement].empty()) + int c_statement = area->statement(); + area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK; + if (c_statement <= 0 || area->testimony()[c_statement].empty()) sendServerMessage("Unable to update an empty statement. Please use /addtestimony."); else { packet[14] = "1"; - area->m_testimony.replace(c_statement, packet); + area->testimony().replace(c_statement, packet); sendServerMessage("Updated current statement."); - return area->m_testimony[c_statement]; + return area->testimony()[c_statement]; } return packet; } @@ -69,28 +69,28 @@ QStringList AOClient::updateStatement(QStringList packet) void AOClient::clearTestimony() { AreaData* area = server->areas[current_area]; - area->m_testimonyRecording = AreaData::TestimonyRecording::STOPPED; - area->m_statement = -1; - area->m_testimony.clear(); //!< Empty out the QVector - area->m_testimony.squeeze(); //!< Release memory. Good idea? God knows, I do not. + area->testimonyRecording() = AreaData::TestimonyRecording::STOPPED; + area->statement() = -1; + area->testimony().clear(); //!< Empty out the QVector + area->testimony().squeeze(); //!< Release memory. Good idea? God knows, I do not. } QStringList AOClient::playTestimony() { AreaData* area = server->areas[current_area]; - int c_statement = area->m_statement; - if (c_statement > area->m_testimony.size() - 1) { + int c_statement = area->statement(); + if (c_statement > area->testimony().size() - 1) { sendServerMessageArea("Last statement reached. Looping to first statement."); - area->m_statement = 1; - return area->m_testimony[area->m_statement]; + area->statement() = 1; + return area->testimony()[area->statement()]; } if (c_statement <= 0) { sendServerMessage("First statement reached."); - area->m_statement = 1; - return area->m_testimony[area->m_statement = 1]; + area->statement() = 1; + return area->testimony()[area->statement() = 1]; } else { - return area->m_testimony[c_statement]; + return area->testimony()[c_statement]; } }