Corrected every error in the build
TODO: Documentation, test writing still.
This commit is contained in:
parent
08fd5896ba
commit
0a87f30287
@ -73,7 +73,7 @@ class AOClient : public QObject {
|
|||||||
*
|
*
|
||||||
* @see #ipid
|
* @see #ipid
|
||||||
*/
|
*/
|
||||||
QString getIpid();
|
QString getIpid() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates the client's IPID based on a hashed version of its IP.
|
* @brief Calculates the client's IPID based on a hashed version of its IP.
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
#ifndef AREA_DATA_H
|
#ifndef AREA_DATA_H
|
||||||
#define AREA_DATA_H
|
#define AREA_DATA_H
|
||||||
|
|
||||||
#include "include/logger.h"
|
#include "logger.h"
|
||||||
|
#include "aopacket.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -193,6 +194,8 @@ class AreaData : public QObject {
|
|||||||
PROSECUTOR,
|
PROSECUTOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const QMap<QString, AreaData::Status> map_statuses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A client in the area has left the area.
|
* @brief A client in the area has left the area.
|
||||||
*
|
*
|
||||||
@ -202,6 +205,8 @@ class AreaData : public QObject {
|
|||||||
*/
|
*/
|
||||||
void clientLeftArea(int f_charId);
|
void clientLeftArea(int f_charId);
|
||||||
|
|
||||||
|
void clientJoinedArea(int f_charId = -1);
|
||||||
|
|
||||||
QList<int> owners() const;
|
QList<int> owners() const;
|
||||||
|
|
||||||
void addOwner(int f_clientId);
|
void addOwner(int f_clientId);
|
||||||
@ -226,6 +231,12 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
LockStatus lockStatus() const;
|
LockStatus lockStatus() const;
|
||||||
|
|
||||||
|
void lock();
|
||||||
|
|
||||||
|
void unlock();
|
||||||
|
|
||||||
|
void spectatable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief invite
|
* @brief invite
|
||||||
* @param f_clientId
|
* @param f_clientId
|
||||||
@ -235,8 +246,6 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
int playerCount() const;
|
int playerCount() const;
|
||||||
|
|
||||||
void changePlayerCount(bool f_increase);
|
|
||||||
|
|
||||||
QList<QTimer *> timers() const;
|
QList<QTimer *> timers() const;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
@ -249,9 +258,9 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
Status status() const;
|
Status status() const;
|
||||||
|
|
||||||
QList<int> invited() const;
|
bool changeStatus(const QString& f_newStatus_r);
|
||||||
|
|
||||||
LockStatus locked() const;
|
QList<int> invited() const;
|
||||||
|
|
||||||
QString background() const;
|
QString background() const;
|
||||||
|
|
||||||
@ -263,6 +272,8 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
bool bgLocked() const;
|
bool bgLocked() const;
|
||||||
|
|
||||||
|
void toggleBgLock();
|
||||||
|
|
||||||
QString document() const;
|
QString document() const;
|
||||||
|
|
||||||
int defHP() const;
|
int defHP() const;
|
||||||
@ -283,6 +294,8 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
void setTestimonyRecording(const TestimonyRecording &testimonyRecording);
|
void setTestimonyRecording(const TestimonyRecording &testimonyRecording);
|
||||||
|
|
||||||
|
void restartTestimony();
|
||||||
|
|
||||||
void clearTestimony();
|
void clearTestimony();
|
||||||
|
|
||||||
QVector<QStringList> testimony() const;
|
QVector<QStringList> testimony() const;
|
||||||
@ -293,6 +306,8 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
void addStatement(int f_position, const QStringList& f_newStatement);
|
void addStatement(int f_position, const QStringList& f_newStatement);
|
||||||
|
|
||||||
|
void removeStatement(int f_statementNumber);
|
||||||
|
|
||||||
std::pair<QStringList, TestimonyProgress> advanceTestimony(bool f_forward = true);
|
std::pair<QStringList, TestimonyProgress> advanceTestimony(bool f_forward = true);
|
||||||
|
|
||||||
QStringList jumpToStatement(int f_statementNr);
|
QStringList jumpToStatement(int f_statementNr);
|
||||||
@ -311,6 +326,14 @@ class AreaData : public QObject {
|
|||||||
|
|
||||||
void toggleMusic();
|
void toggleMusic();
|
||||||
|
|
||||||
|
void log(const QString& f_clientName_r, const QString& f_clientIpid_r, const AOPacket& f_packet_r) const;
|
||||||
|
|
||||||
|
void logLogin(const QString &f_clientName_r, const QString &f_clientIpid_r, bool f_success, const QString& f_modname_r) const;
|
||||||
|
|
||||||
|
void flushLogs() const;
|
||||||
|
|
||||||
|
void setEviMod(const EvidenceMod &eviMod);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief The list of timers available in the area.
|
* @brief The list of timers available in the area.
|
||||||
|
@ -35,18 +35,18 @@ public:
|
|||||||
*
|
*
|
||||||
* @param f_max_length The maximum amount of entries the Logger can store at once.
|
* @param f_max_length The maximum amount of entries the Logger can store at once.
|
||||||
*/
|
*/
|
||||||
Logger(int f_max_length, const QString& f_logType_r) : m_maxLength(f_max_length), m_logType(f_logType_r) {};
|
Logger(QString f_area_name, int f_max_length, const QString& f_logType_r) :
|
||||||
|
m_areaName(f_area_name), m_maxLength(f_max_length), m_logType(f_logType_r) {};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief Logs an IC message.
|
* @brief Logs an IC message.
|
||||||
*
|
*
|
||||||
* @param f_areaName_r The name of the area where the event happened.
|
|
||||||
* @param f_charName_r The character name of the client who sent the IC message.
|
* @param f_charName_r The character name of the client who sent the IC message.
|
||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param f_message_r The text of the IC message.
|
* @param f_message_r The text of the IC message.
|
||||||
*/
|
*/
|
||||||
void logIC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r);
|
void logIC(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logs an OOC message.
|
* @brief Logs an OOC message.
|
||||||
@ -56,17 +56,16 @@ public slots:
|
|||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param f_message_r The text of the OOC message.
|
* @param f_message_r The text of the OOC message.
|
||||||
*/
|
*/
|
||||||
void logOOC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r);
|
void logOOC(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logs a mod call message.
|
* @brief Logs a mod call message.
|
||||||
*
|
*
|
||||||
* @param f_areaName_r The name of the area where the event happened.
|
|
||||||
* @param f_charName_r The character name of the client who sent the mod call.
|
* @param f_charName_r The character name of the client who sent the mod call.
|
||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param f_modcallReason_r The reason for the modcall.
|
* @param f_modcallReason_r The reason for the modcall.
|
||||||
*/
|
*/
|
||||||
void logModcall(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r);
|
void logModcall(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logs a command called in OOC.
|
* @brief Logs a command called in OOC.
|
||||||
@ -74,33 +73,26 @@ public slots:
|
|||||||
* @details If the command is not one of any of the 'special' ones, it defaults to logOOC().
|
* @details If the command is not one of any of the 'special' ones, it defaults to logOOC().
|
||||||
* The only thing that makes a command 'special' if it is handled differently in here.
|
* The only thing that makes a command 'special' if it is handled differently in here.
|
||||||
*
|
*
|
||||||
* @param f_areaName_r The name of the area where the event happened.
|
|
||||||
* @param f_charName_r The character name of the client who sent the command.
|
* @param f_charName_r The character name of the client who sent the command.
|
||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param f_oocMessage_r The text of the OOC message. Passed to logOOC() if the command is not 'special' (see details).
|
* @param f_oocMessage_r The text of the OOC message. Passed to logOOC() if the command is not 'special' (see details).
|
||||||
* @param f_cmd_r The command called in the OOC -- this is the first word after the `/` character.
|
|
||||||
* @param f_cmdArgs_r The arguments interpreted for the command, every word separated by a whitespace.
|
|
||||||
*/
|
*/
|
||||||
void logCmd(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r,
|
void logCmd(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_oocMessage_r);
|
||||||
const QString& f_oocMessage_r, const QString& f_cmd_r, const QStringList& f_cmdArgs_r);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logs a login attempt.
|
* @brief Logs a login attempt.
|
||||||
*
|
*
|
||||||
* @param f_areaName_r The name of the area where the event happened.
|
|
||||||
* @param f_charName_r The character name of the client that attempted to login.
|
* @param f_charName_r The character name of the client that attempted to login.
|
||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param success True if the client successfully authenticated as a mod.
|
* @param success True if the client successfully authenticated as a mod.
|
||||||
* @param f_modname_r If the client logged in with a modname, then this is it. Otherwise, it's `"moderator"`.
|
* @param f_modname_r If the client logged in with a modname, then this is it. Otherwise, it's `"moderator"`.
|
||||||
*/
|
*/
|
||||||
void logLogin(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r);
|
void logLogin(const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Appends the contents of #buffer into `config/server.log`, emptying the former.
|
* @brief Appends the contents of #buffer into `config/server.log`, emptying the former.
|
||||||
*
|
|
||||||
* @param f_areaName_r The name of the area where the event happened.
|
|
||||||
*/
|
*/
|
||||||
void flush(const QString& f_areaName_r);
|
void flush();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Contains entries that have not yet been flushed out into a log file.
|
* @brief Contains entries that have not yet been flushed out into a log file.
|
||||||
@ -114,13 +106,12 @@ private:
|
|||||||
* @details If the buffer's size is equal to #max_length, the first entry in the queue is removed,
|
* @details If the buffer's size is equal to #max_length, the first entry in the queue is removed,
|
||||||
* and the newest entry is added to the end.
|
* and the newest entry is added to the end.
|
||||||
*
|
*
|
||||||
* @param f_areaName_r The name of the area where the loggable entry happened.
|
|
||||||
* @param f_charName_r The character name of the client who 'caused' the source event for the entry to happen.
|
* @param f_charName_r The character name of the client who 'caused' the source event for the entry to happen.
|
||||||
* @param f_ipid_r The IPID of the aforementioned client.
|
* @param f_ipid_r The IPID of the aforementioned client.
|
||||||
* @param f_type_r The type of entry that is being built, something that uniquely identifies entries of similar being.
|
* @param f_type_r The type of entry that is being built, something that uniquely identifies entries of similar being.
|
||||||
* @param f_message_r Any additional information related to the entry.
|
* @param f_message_r Any additional information related to the entry.
|
||||||
*/
|
*/
|
||||||
void addEntry(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r,
|
void addEntry(const QString& f_charName_r, const QString& f_ipid_r,
|
||||||
const QString& f_type_r, const QString& f_message_r);
|
const QString& f_type_r, const QString& f_message_r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,6 +119,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
int m_maxLength;
|
int m_maxLength;
|
||||||
|
|
||||||
|
QString m_areaName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Determines what kind of logging happens, `"full"` or `"modcall"`.
|
* @brief Determines what kind of logging happens, `"full"` or `"modcall"`.
|
||||||
*
|
*
|
||||||
|
@ -107,7 +107,7 @@ 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]->locked == AreaData::LockStatus::LOCKED && !server->areas[new_area]->invited().contains(id)) {
|
if (server->areas[new_area]->lockStatus() == 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;
|
||||||
}
|
}
|
||||||
@ -116,8 +116,8 @@ void AOClient::changeArea(int new_area)
|
|||||||
server->areas[current_area]->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]->playerCount()++;
|
server->areas[new_area]->clientJoinedArea(char_id);
|
||||||
server->areas[current_area]->playerCount()--;
|
server->areas[current_area]->clientLeftArea(char_id);
|
||||||
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]);
|
||||||
@ -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]->locked == AreaData::LockStatus::SPECTATABLE)
|
if (server->areas[current_area]->lockStatus() == 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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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->locked()).toString();
|
QString lock_status = QVariant::fromValue(area->lockStatus()).toString();
|
||||||
arup_data.append(lock_status);
|
arup_data.append(lock_status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AOClient::getIpid() { return ipid; }
|
QString AOClient::getIpid() const { return ipid; }
|
||||||
|
|
||||||
Server* AOClient::getServer() { return server; }
|
Server* AOClient::getServer() { return server; }
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ AreaData::AreaData(QString p_name, int p_index) :
|
|||||||
config_ini.endGroup();
|
config_ini.endGroup();
|
||||||
if (log_size == 0)
|
if (log_size == 0)
|
||||||
log_size = 500;
|
log_size = 500;
|
||||||
m_logger = new Logger(log_size, l_logType);
|
m_logger = new Logger(m_name, log_size, l_logType);
|
||||||
QTimer* timer1 = new QTimer();
|
QTimer* timer1 = new QTimer();
|
||||||
m_timers.append(timer1);
|
m_timers.append(timer1);
|
||||||
QTimer* timer2 = new QTimer();
|
QTimer* timer2 = new QTimer();
|
||||||
@ -75,10 +75,32 @@ AreaData::AreaData(QString p_name, int p_index) :
|
|||||||
m_eviMod = EvidenceMod::FFA;
|
m_eviMod = EvidenceMod::FFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QMap<QString, AreaData::Status> AreaData::map_statuses = {
|
||||||
|
{"idle", AreaData::Status::IDLE },
|
||||||
|
{"rp", AreaData::Status::RP },
|
||||||
|
{"casing", AreaData::Status::CASING },
|
||||||
|
{"lfp", AreaData::Status::LOOKING_FOR_PLAYERS },
|
||||||
|
{"looking-for-players", AreaData::Status::LOOKING_FOR_PLAYERS },
|
||||||
|
{"recess", AreaData::Status::RECESS },
|
||||||
|
{"gaming", AreaData::Status::GAMING },
|
||||||
|
};
|
||||||
|
|
||||||
void AreaData::clientLeftArea(int f_charId)
|
void AreaData::clientLeftArea(int f_charId)
|
||||||
{
|
{
|
||||||
--m_playerCount;
|
--m_playerCount;
|
||||||
m_charactersTaken.removeAll(f_charId);
|
|
||||||
|
if (f_charId != -1) {
|
||||||
|
m_charactersTaken.removeAll(f_charId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::clientJoinedArea(int f_charId)
|
||||||
|
{
|
||||||
|
++m_playerCount;
|
||||||
|
|
||||||
|
if (f_charId != -1) {
|
||||||
|
m_charactersTaken.append(f_charId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> AreaData::owners() const
|
QList<int> AreaData::owners() const
|
||||||
@ -132,6 +154,21 @@ AreaData::LockStatus AreaData::lockStatus() const
|
|||||||
return m_locked;
|
return m_locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AreaData::lock()
|
||||||
|
{
|
||||||
|
m_locked = LockStatus::LOCKED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::unlock()
|
||||||
|
{
|
||||||
|
m_locked = LockStatus::FREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::spectatable()
|
||||||
|
{
|
||||||
|
m_locked = LockStatus::SPECTATABLE;
|
||||||
|
}
|
||||||
|
|
||||||
bool AreaData::invite(int f_clientId)
|
bool AreaData::invite(int f_clientId)
|
||||||
{
|
{
|
||||||
if (m_invited.contains(f_clientId)) {
|
if (m_invited.contains(f_clientId)) {
|
||||||
@ -147,11 +184,6 @@ int AreaData::playerCount() const
|
|||||||
return m_playerCount;
|
return m_playerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AreaData::changePlayerCount(bool f_increase)
|
|
||||||
{
|
|
||||||
f_increase ? m_playerCount++: m_playerCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QTimer *> AreaData::timers() const
|
QList<QTimer *> AreaData::timers() const
|
||||||
{
|
{
|
||||||
return m_timers;
|
return m_timers;
|
||||||
@ -182,16 +214,21 @@ AreaData::Status AreaData::status() const
|
|||||||
return m_status;
|
return m_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AreaData::changeStatus(const QString &f_newStatus_r)
|
||||||
|
{
|
||||||
|
if (AreaData::map_statuses.contains(f_newStatus_r)) {
|
||||||
|
m_status = AreaData::map_statuses[f_newStatus_r];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QList<int> AreaData::invited() const
|
QList<int> AreaData::invited() const
|
||||||
{
|
{
|
||||||
return m_invited;
|
return m_invited;
|
||||||
}
|
}
|
||||||
|
|
||||||
AreaData::LockStatus AreaData::locked() const
|
|
||||||
{
|
|
||||||
return m_locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AreaData::isMusicAllowed() const
|
bool AreaData::isMusicAllowed() const
|
||||||
{
|
{
|
||||||
return m_toggleMusic;
|
return m_toggleMusic;
|
||||||
@ -202,11 +239,45 @@ void AreaData::toggleMusic()
|
|||||||
m_toggleMusic = !m_toggleMusic;
|
m_toggleMusic = !m_toggleMusic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AreaData::log(const QString &f_clientName_r, const QString &f_clientIpid_r, const AOPacket &f_packet_r) const
|
||||||
|
{
|
||||||
|
auto l_header = f_packet_r.header;
|
||||||
|
|
||||||
|
if (l_header == "MS") {
|
||||||
|
m_logger->logIC(f_clientName_r, f_clientIpid_r, f_packet_r.contents.at(4));
|
||||||
|
} else if (l_header == "CT") {
|
||||||
|
m_logger->logCmd(f_clientName_r, f_clientIpid_r, f_packet_r.contents.at(1));
|
||||||
|
} else if (l_header == "ZZ") {
|
||||||
|
m_logger->logModcall(f_clientName_r, f_clientIpid_r, f_packet_r.contents.at(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::logLogin(const QString &f_clientName_r, const QString &f_clientIpid_r, bool f_success, const QString& f_modname_r) const
|
||||||
|
{
|
||||||
|
m_logger->logLogin(f_clientName_r, f_clientIpid_r, f_success, f_modname_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::flushLogs() const
|
||||||
|
{
|
||||||
|
m_logger->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaData::setEviMod(const EvidenceMod &eviMod)
|
||||||
|
{
|
||||||
|
m_eviMod = eviMod;
|
||||||
|
}
|
||||||
|
|
||||||
void AreaData::setTestimonyRecording(const TestimonyRecording &testimonyRecording)
|
void AreaData::setTestimonyRecording(const TestimonyRecording &testimonyRecording)
|
||||||
{
|
{
|
||||||
m_testimonyRecording = testimonyRecording;
|
m_testimonyRecording = testimonyRecording;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AreaData::restartTestimony()
|
||||||
|
{
|
||||||
|
m_testimonyRecording = TestimonyRecording::PLAYBACK;
|
||||||
|
m_statement = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void AreaData::clearTestimony()
|
void AreaData::clearTestimony()
|
||||||
{
|
{
|
||||||
m_testimonyRecording = AreaData::TestimonyRecording::STOPPED;
|
m_testimonyRecording = AreaData::TestimonyRecording::STOPPED;
|
||||||
@ -255,6 +326,12 @@ void AreaData::addStatement(int f_position, const QStringList &f_newStatement)
|
|||||||
m_testimony.insert(f_position, f_newStatement);
|
m_testimony.insert(f_position, f_newStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AreaData::removeStatement(int f_statementNumber)
|
||||||
|
{
|
||||||
|
m_testimony.remove(f_statementNumber);
|
||||||
|
--m_statement;
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<QStringList, AreaData::TestimonyProgress> AreaData::advanceTestimony(bool f_forward)
|
std::pair<QStringList, AreaData::TestimonyProgress> AreaData::advanceTestimony(bool f_forward)
|
||||||
{
|
{
|
||||||
f_forward ? m_statement++: m_statement--;
|
f_forward ? m_statement++: m_statement--;
|
||||||
@ -335,6 +412,11 @@ bool AreaData::bgLocked() const
|
|||||||
return m_bgLocked;
|
return m_bgLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AreaData::toggleBgLock()
|
||||||
|
{
|
||||||
|
m_bgLocked = !m_bgLocked;
|
||||||
|
}
|
||||||
|
|
||||||
bool AreaData::iniswapAllowed() const
|
bool AreaData::iniswapAllowed() const
|
||||||
{
|
{
|
||||||
return m_iniswapAllowed;
|
return m_iniswapAllowed;
|
||||||
|
@ -149,7 +149,7 @@ void AOClient::cmdLock(int argc, QStringList argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendServerMessageArea("This area is now locked.");
|
sendServerMessageArea("This area is now locked.");
|
||||||
area->locked() = AreaData::LockStatus::LOCKED;
|
area->lock();
|
||||||
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->invited().append(client->id);
|
area->invited().append(client->id);
|
||||||
@ -166,7 +166,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendServerMessageArea("This area is now spectatable.");
|
sendServerMessageArea("This area is now spectatable.");
|
||||||
area->locked() = AreaData::LockStatus::SPECTATABLE;
|
area->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->invited().append(client->id);
|
area->invited().append(client->id);
|
||||||
@ -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->locked() == AreaData::LockStatus::FREE) {
|
if (area->lockStatus() == 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->locked() = AreaData::LockStatus::FREE;
|
area->unlock();
|
||||||
arup(ARUPType::LOCKED, true);
|
arup(ARUPType::LOCKED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,14 +253,22 @@ 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->bgLocked() = true;
|
|
||||||
|
if (area->bgLocked() == false) {
|
||||||
|
area->toggleBgLock();
|
||||||
|
};
|
||||||
|
|
||||||
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->bgLocked() = false;
|
|
||||||
|
if (area->bgLocked() == true) {
|
||||||
|
area->toggleBgLock();
|
||||||
|
};
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,24 +276,14 @@ 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")
|
|
||||||
area->status() = AreaData::IDLE;
|
if (area->changeStatus(arg)) {
|
||||||
else if (arg == "rp")
|
arup(ARUPType::STATUS, true);
|
||||||
area->status() = AreaData::RP;
|
sendServerMessageArea(ooc_name + " changed status to " + arg);
|
||||||
else if (arg == "casing")
|
} else {
|
||||||
area->status() = AreaData::CASING;
|
sendServerMessage("That does not look like a valid status. Valid statuses are " + AreaData::map_statuses.keys().join(", "));
|
||||||
else if (arg == "looking-for-players" || arg == "lfp")
|
|
||||||
area->status() = AreaData::LOOKING_FOR_PLAYERS;
|
|
||||||
else if (arg == "recess")
|
|
||||||
area->status() = AreaData::RECESS;
|
|
||||||
else if (arg == "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;
|
return;
|
||||||
}
|
}
|
||||||
arup(ARUPType::STATUS, true);
|
|
||||||
sendServerMessageArea(ooc_name + " changed status to " + arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdJudgeLog(int argc, QStringList argv)
|
void AOClient::cmdJudgeLog(int argc, QStringList argv)
|
||||||
|
@ -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)->logger()->logLogin(this, authenticated, "moderator");
|
server->areas.value(current_area)->logLogin(current_char, ipid, 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)->logger()->logLogin(this, authenticated, username);
|
server->areas.value(current_area)->logLogin(current_char, ipid, authenticated, username);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qWarning() << "config.ini has an unrecognized auth_type!";
|
qWarning() << "config.ini has an unrecognized auth_type!";
|
||||||
|
@ -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->eviMod() = AreaData::EvidenceMod::CM;
|
area->setEviMod(AreaData::EvidenceMod::CM);
|
||||||
else if (argv[0] == "mod")
|
else if (argv[0] == "mod")
|
||||||
area->eviMod() = AreaData::EvidenceMod::MOD;
|
area->setEviMod(AreaData::EvidenceMod::MOD);
|
||||||
else if (argv[0] == "hiddencm")
|
else if (argv[0] == "hiddencm")
|
||||||
area->eviMod() = AreaData::EvidenceMod::HIDDEN_CM;
|
area->setEviMod(AreaData::EvidenceMod::HIDDEN_CM);
|
||||||
else if (argv[0] == "ffa")
|
else if (argv[0] == "ffa")
|
||||||
area->eviMod() = AreaData::EvidenceMod::FFA;
|
area->setEviMod(AreaData::EvidenceMod::FFA);
|
||||||
else {
|
else {
|
||||||
sendServerMessage("Invalid evidence mod.");
|
sendServerMessage("Invalid evidence mod.");
|
||||||
return;
|
return;
|
||||||
@ -107,7 +107,7 @@ void AOClient::cmdTestify(int argc, QStringList argv)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clearTestimony();
|
clearTestimony();
|
||||||
area->testimonyRecording() = AreaData::TestimonyRecording::RECORDING;
|
area->setTestimonyRecording(AreaData::TestimonyRecording::RECORDING);
|
||||||
sendServerMessage("Started testimony recording.");
|
sendServerMessage("Started testimony recording.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,10 +117,9 @@ void AOClient::cmdExamine(int argc, QStringList argv)
|
|||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->areas[current_area];
|
||||||
if (area->testimony().size() -1 > 0)
|
if (area->testimony().size() -1 > 0)
|
||||||
{
|
{
|
||||||
area->testimonyRecording() = AreaData::TestimonyRecording::PLAYBACK;
|
area->restartTestimony();
|
||||||
server->broadcast(AOPacket("RT",{"testimony2"}), current_area);
|
server->broadcast(AOPacket("RT",{"testimony2"}), current_area);
|
||||||
server->broadcast(AOPacket("MS", {area->testimony()[0]}), current_area);
|
server->broadcast(AOPacket("MS", {area->testimony()[0]}), current_area);
|
||||||
area->statement() = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK)
|
if (area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK)
|
||||||
@ -155,22 +154,21 @@ void AOClient::cmdDeleteStatement(int argc, QStringList argv)
|
|||||||
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->testimony().size() > 2) {
|
if (c_statement > 0 && area->testimony().size() > 2) {
|
||||||
area->testimony().remove(c_statement);
|
area->removeStatement(c_statement);
|
||||||
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]->testimonyRecording() = AreaData::TestimonyRecording::UPDATE;
|
server->areas[current_area]->setTestimonyRecording(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->testimonyRecording() = AreaData::TestimonyRecording::STOPPED;
|
area->setTestimonyRecording(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.");
|
||||||
}
|
}
|
||||||
@ -178,7 +176,7 @@ void AOClient::cmdPauseTestimony(int argc, QStringList argv)
|
|||||||
void AOClient::cmdAddStatement(int argc, QStringList argv)
|
void AOClient::cmdAddStatement(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
if (server->areas[current_area]->statement() < server->maximum_statements) {
|
if (server->areas[current_area]->statement() < server->maximum_statements) {
|
||||||
server->areas[current_area]->testimonyRecording() = AreaData::TestimonyRecording::ADD;
|
server->areas[current_area]->setTestimonyRecording(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
|
||||||
|
@ -32,7 +32,7 @@ QStringList AOClient::buildAreaList(int area_idx)
|
|||||||
QString area_name = server->area_names[area_idx];
|
QString area_name = server->area_names[area_idx];
|
||||||
AreaData* area = server->areas[area_idx];
|
AreaData* area = server->areas[area_idx];
|
||||||
entries.append("=== " + area_name + " ===");
|
entries.append("=== " + area_name + " ===");
|
||||||
switch (area->locked()) {
|
switch (area->lockStatus()) {
|
||||||
case AreaData::LockStatus::LOCKED:
|
case AreaData::LockStatus::LOCKED:
|
||||||
entries.append("[LOCKED]");
|
entries.append("[LOCKED]");
|
||||||
break;
|
break;
|
||||||
|
@ -20,48 +20,52 @@
|
|||||||
|
|
||||||
#include "include/logger.h"
|
#include "include/logger.h"
|
||||||
|
|
||||||
void Logger::logIC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r)
|
void Logger::logIC(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r)
|
||||||
{
|
{
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "IC", f_message_r);
|
addEntry(f_charName_r, f_ipid_r, "IC", f_message_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logOOC(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r)
|
void Logger::logOOC(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_message_r)
|
||||||
{
|
{
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "OOC", f_message_r);
|
addEntry(f_charName_r, f_ipid_r, "OOC", f_message_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logModcall(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r)
|
void Logger::logModcall(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_modcallReason_r)
|
||||||
{
|
{
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "MODCALL", f_modcallReason_r);
|
addEntry(f_charName_r, f_ipid_r, "MODCALL", f_modcallReason_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logCmd(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r,
|
void Logger::logCmd(const QString& f_charName_r, const QString& f_ipid_r, const QString& f_oocMessage_r)
|
||||||
const QString& f_oocMessage_r, const QString& f_cmd_r, const QStringList& f_cmdArgs_r)
|
|
||||||
{
|
{
|
||||||
|
// I don't like this, but oh well.
|
||||||
|
auto l_cmdArgs = f_oocMessage_r.split(" ", QString::SplitBehavior::SkipEmptyParts);
|
||||||
|
auto l_cmd = l_cmdArgs.at(0).trimmed().toLower();
|
||||||
|
l_cmd = l_cmd.right(l_cmd.length() - 1);
|
||||||
|
l_cmdArgs.removeFirst();
|
||||||
|
|
||||||
// Some commands contain sensitive data, like passwords
|
// Some commands contain sensitive data, like passwords
|
||||||
// These must be filtered out
|
// These must be filtered out
|
||||||
if (f_cmd_r == "login") {
|
if (l_cmd == "login") {
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "LOGIN", "Attempted login");
|
addEntry(f_charName_r, f_ipid_r, "LOGIN", "Attempted login");
|
||||||
}
|
}
|
||||||
else if (f_cmd_r == "rootpass") {
|
else if (l_cmd == "rootpass") {
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "USERS", "Root password created");
|
addEntry(f_charName_r, f_ipid_r, "USERS", "Root password created");
|
||||||
}
|
}
|
||||||
else if (f_cmd_r == "adduser" && !f_cmdArgs_r.isEmpty()) {
|
else if (l_cmd == "adduser" && !l_cmdArgs.isEmpty()) {
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "USERS", "Added user " + f_cmdArgs_r[0]);
|
addEntry(f_charName_r, f_ipid_r, "USERS", "Added user " + l_cmdArgs.at(0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logOOC(f_areaName_r, f_charName_r, f_ipid_r, f_oocMessage_r);
|
logOOC(f_charName_r, f_ipid_r, f_oocMessage_r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logLogin(const QString& f_areaName_r, const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r)
|
void Logger::logLogin(const QString& f_charName_r, const QString& f_ipid_r, bool success, const QString& f_modname_r)
|
||||||
{
|
{
|
||||||
QString l_message = success ? "Logged in as " + f_modname_r : "Failed to log in as " + f_modname_r;
|
QString l_message = success ? "Logged in as " + f_modname_r : "Failed to log in as " + f_modname_r;
|
||||||
addEntry(f_areaName_r, f_charName_r, f_ipid_r, "LOGIN", l_message);
|
addEntry(f_charName_r, f_ipid_r, "LOGIN", l_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::addEntry(
|
void Logger::addEntry(
|
||||||
const QString& f_areaName_r,
|
|
||||||
const QString& f_charName_r,
|
const QString& f_charName_r,
|
||||||
const QString& f_ipid_r,
|
const QString& f_ipid_r,
|
||||||
const QString& f_type_r,
|
const QString& f_type_r,
|
||||||
@ -70,13 +74,13 @@ void Logger::addEntry(
|
|||||||
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
|
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
|
||||||
|
|
||||||
QString l_logEntry = QStringLiteral("[%1][%2][%6] %3(%4): %5\n")
|
QString l_logEntry = QStringLiteral("[%1][%2][%6] %3(%4): %5\n")
|
||||||
.arg(l_time, f_areaName_r, f_charName_r, f_ipid_r, f_message_r, f_type_r);
|
.arg(l_time, m_areaName, f_charName_r, f_ipid_r, f_message_r, f_type_r);
|
||||||
|
|
||||||
if (m_buffer.length() < m_maxLength) {
|
if (m_buffer.length() < m_maxLength) {
|
||||||
m_buffer.enqueue(l_logEntry);
|
m_buffer.enqueue(l_logEntry);
|
||||||
|
|
||||||
if (m_logType == "full") {
|
if (m_logType == "full") {
|
||||||
flush(f_areaName_r);
|
flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -85,7 +89,7 @@ void Logger::addEntry(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::flush(const QString& f_areaName_r)
|
void Logger::flush()
|
||||||
{
|
{
|
||||||
QDir l_dir("logs/");
|
QDir l_dir("logs/");
|
||||||
if (!l_dir.exists()) {
|
if (!l_dir.exists()) {
|
||||||
@ -95,7 +99,7 @@ void Logger::flush(const QString& f_areaName_r)
|
|||||||
QFile l_logfile;
|
QFile l_logfile;
|
||||||
|
|
||||||
if (m_logType == "modcall") {
|
if (m_logType == "modcall") {
|
||||||
l_logfile.setFileName(QString("logs/report_%1_%2.log").arg(f_areaName_r, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss"))));
|
l_logfile.setFileName(QString("logs/report_%1_%2.log").arg(m_areaName, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss"))));
|
||||||
}
|
}
|
||||||
else if (m_logType == "full") {
|
else if (m_logType == "full") {
|
||||||
l_logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd")));
|
l_logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd")));
|
||||||
|
@ -96,7 +96,7 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
server->player_count++;
|
server->player_count++;
|
||||||
area->changePlayerCount(true);
|
area->clientJoinedArea();
|
||||||
joined = true;
|
joined = true;
|
||||||
server->updateCharsTaken(area);
|
server->updateCharsTaken(area);
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ 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->logger()->logIC(this, &validated_packet);
|
area->log(current_char, ipid, validated_packet);
|
||||||
server->broadcast(validated_packet, current_area);
|
server->broadcast(validated_packet, current_area);
|
||||||
area->updateLastICMessage(validated_packet.contents);
|
area->updateLastICMessage(validated_packet.contents);
|
||||||
}
|
}
|
||||||
@ -195,13 +195,13 @@ 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->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->logger()->logOOC(this, &final_packet);
|
|
||||||
}
|
}
|
||||||
|
area->log(current_char, ipid, final_packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
@ -329,8 +329,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->logger()->logModcall(this, &packet);
|
area->log(current_char, ipid, packet);
|
||||||
area->logger()->flush();
|
area->flushLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
@ -469,7 +469,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->locked() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(id))
|
if (area->lockStatus() == 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;
|
||||||
|
|
||||||
|
@ -13,17 +13,37 @@ class Area : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
AreaData* m_area;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
void init();
|
||||||
* @test Example test case 1.
|
void cleanup();
|
||||||
*/
|
|
||||||
void test_case1();
|
void clientJoinLeave();
|
||||||
};
|
};
|
||||||
|
|
||||||
void Area::test_case1()
|
void Area::init()
|
||||||
{
|
{
|
||||||
QFAIL("Guaranteed failure -- testing tests subdirs setup");
|
m_area = new AreaData("Test Area", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Area::cleanup()
|
||||||
|
{
|
||||||
|
delete m_area;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Area::clientJoinLeave()
|
||||||
|
{
|
||||||
|
m_area->clientJoinedArea(5);
|
||||||
|
|
||||||
|
// There must be exactly one client in the area, and it must have a charid of 5.
|
||||||
|
QCOMPARE(m_area->charactersTaken().size(), 1);
|
||||||
|
QCOMPARE(m_area->charactersTaken().at(0), 5);
|
||||||
|
|
||||||
|
m_area->clientLeftArea(5);
|
||||||
|
|
||||||
|
// No clients must be left in the area.
|
||||||
|
QCOMPARE(m_area->charactersTaken().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user