diff --git a/bin/config_sample/config.ini b/bin/config_sample/config.ini index 6fb4481..68a128a 100644 --- a/bin/config_sample/config.ini +++ b/bin/config_sample/config.ini @@ -16,6 +16,7 @@ auth=simple modpass=changeme logbuffer=500 logging=modcall +maximum_statements=5 [Dice] max_value=100 diff --git a/include/aoclient.h b/include/aoclient.h index 647f5b7..e513b1b 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -1305,39 +1305,49 @@ class AOClient : public QObject { void cmdNoteCardClear(int argc, QStringList argv); /** - * @brief [Insert description here] + * @brief Sets are to PLAYBACK mode * - * @details [Insert explanation here] + * @details Enables control over the stored testimony, prevent new messages to be added and + * allows people to navigate trough it using > and <. */ void cmdExamine(int argc, QStringList argv); /** - * @brief [Insert description here] + * @brief Enables the testimony recording functionality. * - * @details [Insert explanation here] + * @details Any IC-Message send after this command is issues will be recorded by the testimony recorder. */ void cmdTestify(int argc, QStringList argv); /** - * @brief [Insert description here] + * @brief Allows user to update the currently displayed IC-Message from the testimony replay. * - * @details [Insert explanation here] + * @details Using this command replaces the content of the current statement entirely. It does not append information. */ void cmdUpdateStatement(int argc, QStringList argv); /** - * @brief [Insert description here] + * @brief Deletes a statement from the testimony. * - * @details [Insert explanation here] + * @details Using this deletes the entire entry in the QVector and resizes it appropriately to prevent empty record indices. */ void cmdDeleteStatement(int argc, QStringList argv); /** - * @brief [Insert description here] + * @brief Pauses testimony playback. * - * @details [Insert explanation here] + * @details Disables the testimony playback controls. */ void cmdPauseTestimony(int argc, QStringList argv); + + + /** + * @brief + * + * @details + * + */ + void cmdAddStatement(int argc, QStringList argv); // Messaging/Client @@ -1540,12 +1550,35 @@ class AOClient : public QObject { long long parseTime(QString input); QString getReprimand(bool positive = false); + /** + * @brief Adds the last send IC-Message to QVector of the respective area. + * + * @details This one pulls double duty to both append IC-Messages to the QVector or insert them, depending on the current recorder enum. + * + * @param packet The MS-Packet being recorded with their color changed to green. + */ void addStatement(QStringList packet); - QStringList updateStatement(QStringList packet); - void deleteStatement(); + + /** + * @brief Clears QVector of the current area. + * + * @details It clears both its content and trims it back to size 0 + * + */ void clearTestimony(); + + /** + * @brief Updates the currently displayed IC-Message with the next one send + * @param packet The IC-Message that will overwrite the currently stored one. + * @return Returns the updated IC-Message to be send to the other users. It also changes the color to green. + */ + QStringList updateStatement(QStringList packet); + + /** + * @brief Called when area enum is set to PLAYBACK. Sends the IC-Message stored at the current statement. + * @return IC-Message stored in the QVector. + */ QStringList playTestimony(); - void pauseTestimony(); ///@} /** diff --git a/include/server.h b/include/server.h index 96cba1a..225c5fc 100644 --- a/include/server.h +++ b/include/server.h @@ -211,6 +211,11 @@ class Server : public QObject { */ QString MOTD; + /** + * @brief The Maximum amounts of IC-Messages an area is allowed to store. + */ + int maximum_statements; + /** * @brief The server-wide global timer. */ diff --git a/src/commands.cpp b/src/commands.cpp index e1ecb03..f5804eb 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1360,7 +1360,7 @@ void AOClient::cmdTestify(int argc, QStringList argv) { AreaData* area = server->areas[current_area]; if (area->test_rec == AreaData::TestimonyRecording::RECORDING) { - sendServerMessage("Examination already in progress."); + sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one."); } else { clearTestimony(); @@ -1389,18 +1389,39 @@ void AOClient::cmdExamine(int argc, QStringList argv) void AOClient::cmdDeleteStatement(int argc, QStringList argv) { - deleteStatement(); + AreaData* area = server->areas[current_area]; + int c_statement = area->statement; + if (area->test_rec == AreaData::TestimonyRecording::STOPPED) { + sendServerMessage("Unable to delete statement. There is currently no examination running."); + } + if (c_statement > 0 && area->test_rec == AreaData::TestimonyRecording::PLAYBACK) { + area->testimony.remove(c_statement); + 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]->test_rec = AreaData::TestimonyRecording::UPDATE; - sendServerMessage("Recording updated statement."); + sendServerMessage("The next IC-Message will replace the last displayed replay message."); } void AOClient::cmdPauseTestimony(int argc, QStringList argv) { - pauseTestimony(); + AreaData* area = server->areas[current_area]; + area->test_rec = AreaData::TestimonyRecording::STOPPED; + sendServerMessage("Testimony has been stopped."); +} + +void AOClient::cmdAddStatement(int argc, QStringList argv) +{ + if (server->areas[current_area]->statement < server->maximum_statements) { + server->areas[current_area]->test_rec = AreaData::TestimonyRecording::ADD; + sendServerMessage("The next IC-Message will be inserted into the testimony."); + } + else + sendServerMessage("Unable to add anymore statements. Please remove any unused ones."); } QStringList AOClient::buildAreaList(int area_idx) diff --git a/src/server.cpp b/src/server.cpp index 5bf4403..7d7b1b2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -53,6 +53,8 @@ void Server::start() MOTD = config.value("motd","MOTD is not set.").toString(); + maximum_statements = config.value("maximum_statements", 50).toInt(); + proxy = new WSProxy(port, ws_port, this); if(ws_port != -1) proxy->start(); diff --git a/src/testimony_recorder.cpp b/src/testimony_recorder.cpp index 2ca6f7a..3c6897d 100644 --- a/src/testimony_recorder.cpp +++ b/src/testimony_recorder.cpp @@ -25,7 +25,7 @@ void AOClient::addStatement(QStringList packet) int c_statement = area->statement; if (c_statement >= 0) { if (area->test_rec == AreaData::TestimonyRecording::RECORDING) { - if (c_statement <= 50) { //Make this configurable once Mangos ConfigManager changes get merged + if (c_statement <= server->maximum_statements) { if (c_statement == 0) packet[14] = "3"; else @@ -39,7 +39,6 @@ void AOClient::addStatement(QStringList packet) } } else if (area->test_rec == AreaData::TestimonyRecording::ADD) { - if (c_statement < 50) { //Make this configurable once Mangos ConfigManager changes get merged area->testimony.insert(c_statement,packet); area->test_rec = AreaData::TestimonyRecording::PLAYBACK; } @@ -47,10 +46,7 @@ void AOClient::addStatement(QStringList packet) sendServerMessage("Unable to add more statements. The maximum amount of statements has been reached."); area->test_rec = AreaData::TestimonyRecording::PLAYBACK; } - } } - - } QStringList AOClient::updateStatement(QStringList packet) @@ -69,17 +65,6 @@ QStringList AOClient::updateStatement(QStringList packet) return packet; } -void AOClient::deleteStatement() -{ - AreaData* area = server->areas[current_area]; - int c_statement = area->statement; - if ((c_statement > 0 && !(area->testimony[c_statement].isEmpty()))) { - area->testimony.remove(c_statement); - sendServerMessage("The statement with id " + QString::number(c_statement) + " has been deleted from the testimony."); - } - server->areas[current_area]->test_rec = AreaData::TestimonyRecording::PLAYBACK; -} - void AOClient::clearTestimony() { AreaData* area = server->areas[current_area]; @@ -107,9 +92,3 @@ QStringList AOClient::playTestimony() } } -void AOClient::pauseTestimony() -{ - AreaData* area = server->areas[current_area]; - area->test_rec = AreaData::TestimonyRecording::STOPPED; - sendServerMessage("Testimony has been stopped."); -}