Cleanup some variable naming
+ move file reading operations into ConfigManager
This commit is contained in:
parent
90b9eaa665
commit
a4e8442657
@ -44,6 +44,53 @@ class ConfigManager {
|
|||||||
*/
|
*/
|
||||||
static bool verifyServerConfig();
|
static bool verifyServerConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the IP the TCP Server binds to.
|
||||||
|
*
|
||||||
|
* @return See short description
|
||||||
|
*/
|
||||||
|
static QString bindIP();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the character list of the server.
|
||||||
|
*
|
||||||
|
* @return See short description.
|
||||||
|
*/
|
||||||
|
static QStringList charlist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the a QStringList of the available backgrounds.
|
||||||
|
*
|
||||||
|
* @return See short description.
|
||||||
|
*/
|
||||||
|
static QStringList backgrounds();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a QStringlist of the available songs.
|
||||||
|
*
|
||||||
|
* @return See short description.
|
||||||
|
*/
|
||||||
|
static QStringList musiclist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the content of
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static QSettings *areaData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a sanitized QStringList of the areas.
|
||||||
|
*
|
||||||
|
* @return See short description.
|
||||||
|
*/
|
||||||
|
static QStringList sanitizedAreaNames();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the raw arealist
|
||||||
|
*
|
||||||
|
* @return See short description.
|
||||||
|
*/
|
||||||
|
static QStringList rawAreaNames();
|
||||||
/**
|
/**
|
||||||
* @brief Returns true if the server should advertise to the master server.
|
* @brief Returns true if the server should advertise to the master server.
|
||||||
*
|
*
|
||||||
@ -424,6 +471,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
static QSettings* m_discord;
|
static QSettings* m_discord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stores all of the area valus.
|
||||||
|
*/
|
||||||
|
static QSettings* m_areas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pointer to QElapsedTimer to track the uptime of the server.
|
* @brief Pointer to QElapsedTimer to track the uptime of the server.
|
||||||
*/
|
*/
|
||||||
|
@ -157,22 +157,22 @@ class Server : public QObject {
|
|||||||
/**
|
/**
|
||||||
* @brief The collection of all currently connected clients.
|
* @brief The collection of all currently connected clients.
|
||||||
*/
|
*/
|
||||||
QVector<AOClient*> clients;
|
QVector<AOClient*> m_clients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The overall player count in the server.
|
* @brief The overall player count in the server.
|
||||||
*/
|
*/
|
||||||
int player_count;
|
int m_player_count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The characters available on the server to use.
|
* @brief The characters available on the server to use.
|
||||||
*/
|
*/
|
||||||
QStringList characters;
|
QStringList m_characters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The areas on the server.
|
* @brief The areas on the server.
|
||||||
*/
|
*/
|
||||||
QVector<AreaData*> areas;
|
QVector<AreaData*> m_areas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The names of the areas on the server.
|
* @brief The names of the areas on the server.
|
||||||
@ -180,7 +180,7 @@ class Server : public QObject {
|
|||||||
* @details Equivalent to iterating over #areas and getting the area names individually, but grouped together
|
* @details Equivalent to iterating over #areas and getting the area names individually, but grouped together
|
||||||
* here for faster access.
|
* here for faster access.
|
||||||
*/
|
*/
|
||||||
QStringList area_names;
|
QStringList m_area_names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The available songs on the server.
|
* @brief The available songs on the server.
|
||||||
@ -188,12 +188,12 @@ class Server : public QObject {
|
|||||||
* @details Does **not** include the area names, the actual music list packet should be constructed from
|
* @details Does **not** include the area names, the actual music list packet should be constructed from
|
||||||
* #area_names and this combined.
|
* #area_names and this combined.
|
||||||
*/
|
*/
|
||||||
QStringList music_list;
|
QStringList m_music_list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The backgrounds on the server that may be used in areas.
|
* @brief The backgrounds on the server that may be used in areas.
|
||||||
*/
|
*/
|
||||||
QStringList backgrounds;
|
QStringList m_backgrounds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The database manager on the server, used to store users' bans and authorisation details.
|
* @brief The database manager on the server, used to store users' bans and authorisation details.
|
||||||
|
@ -53,18 +53,18 @@ void AOClient::clientDisconnected()
|
|||||||
qDebug() << remote_ip.toString() << "disconnected";
|
qDebug() << remote_ip.toString() << "disconnected";
|
||||||
#endif
|
#endif
|
||||||
if (joined) {
|
if (joined) {
|
||||||
server->player_count--;
|
server->m_player_count--;
|
||||||
server->areas[current_area]->clientLeftArea(server->getCharID(current_char));
|
server->m_areas[current_area]->clientLeftArea(server->getCharID(current_char));
|
||||||
arup(ARUPType::PLAYER_COUNT, true);
|
arup(ARUPType::PLAYER_COUNT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_char != "") {
|
if (current_char != "") {
|
||||||
server->updateCharsTaken(server->areas[current_area]);
|
server->updateCharsTaken(server->m_areas[current_area]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool l_updateLocks = false;
|
bool l_updateLocks = false;
|
||||||
|
|
||||||
for (AreaData* area : qAsConst(server->areas)) {
|
for (AreaData* area : qAsConst(server->m_areas)) {
|
||||||
l_updateLocks = l_updateLocks || area->removeOwner(id);
|
l_updateLocks = l_updateLocks || area->removeOwner(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ void AOClient::handlePacket(AOPacket packet)
|
|||||||
#ifdef NET_DEBUG
|
#ifdef NET_DEBUG
|
||||||
qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length();
|
qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length();
|
||||||
#endif
|
#endif
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
PacketInfo info = packets.value(packet.header, {false, 0, &AOClient::pktDefault});
|
PacketInfo info = packets.value(packet.header, {false, 0, &AOClient::pktDefault});
|
||||||
|
|
||||||
if (packet.contents.join("").size() > 16384) {
|
if (packet.contents.join("").size() > 16384) {
|
||||||
@ -109,38 +109,38 @@ void AOClient::handlePacket(AOPacket packet)
|
|||||||
void AOClient::changeArea(int new_area)
|
void AOClient::changeArea(int new_area)
|
||||||
{
|
{
|
||||||
if (current_area == new_area) {
|
if (current_area == new_area) {
|
||||||
sendServerMessage("You are already in area " + server->area_names[current_area]);
|
sendServerMessage("You are already in area " + server->m_area_names[current_area]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (server->areas[new_area]->lockStatus() == AreaData::LockStatus::LOCKED && !server->areas[new_area]->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) {
|
if (server->m_areas[new_area]->lockStatus() == AreaData::LockStatus::LOCKED && !server->m_areas[new_area]->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS"))) {
|
||||||
sendServerMessage("Area " + server->area_names[new_area] + " is locked.");
|
sendServerMessage("Area " + server->m_area_names[new_area] + " is locked.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_char != "") {
|
if (current_char != "") {
|
||||||
server->areas[current_area]->changeCharacter(server->getCharID(current_char), -1);
|
server->m_areas[current_area]->changeCharacter(server->getCharID(current_char), -1);
|
||||||
server->updateCharsTaken(server->areas[current_area]);
|
server->updateCharsTaken(server->m_areas[current_area]);
|
||||||
}
|
}
|
||||||
server->areas[current_area]->clientLeftArea(char_id);
|
server->m_areas[current_area]->clientLeftArea(char_id);
|
||||||
bool character_taken = false;
|
bool character_taken = false;
|
||||||
if (server->areas[new_area]->charactersTaken().contains(server->getCharID(current_char))) {
|
if (server->m_areas[new_area]->charactersTaken().contains(server->getCharID(current_char))) {
|
||||||
current_char = "";
|
current_char = "";
|
||||||
char_id = -1;
|
char_id = -1;
|
||||||
character_taken = true;
|
character_taken = true;
|
||||||
}
|
}
|
||||||
server->areas[new_area]->clientJoinedArea(char_id);
|
server->m_areas[new_area]->clientJoinedArea(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->m_areas[new_area]);
|
||||||
sendPacket("HP", {"1", QString::number(server->areas[new_area]->defHP())});
|
sendPacket("HP", {"1", QString::number(server->m_areas[new_area]->defHP())});
|
||||||
sendPacket("HP", {"2", QString::number(server->areas[new_area]->proHP())});
|
sendPacket("HP", {"2", QString::number(server->m_areas[new_area]->proHP())});
|
||||||
sendPacket("BN", {server->areas[new_area]->background()});
|
sendPacket("BN", {server->m_areas[new_area]->background()});
|
||||||
if (character_taken) {
|
if (character_taken) {
|
||||||
sendPacket("DONE");
|
sendPacket("DONE");
|
||||||
}
|
}
|
||||||
const QList<QTimer*> timers = server->areas[current_area]->timers();
|
const QList<QTimer*> timers = server->m_areas[current_area]->timers();
|
||||||
for (QTimer* timer : timers) {
|
for (QTimer* timer : timers) {
|
||||||
int timer_id = server->areas[current_area]->timers().indexOf(timer) + 1;
|
int timer_id = server->m_areas[current_area]->timers().indexOf(timer) + 1;
|
||||||
if (timer->isActive()) {
|
if (timer->isActive()) {
|
||||||
sendPacket("TI", {QString::number(timer_id), "2"});
|
sendPacket("TI", {QString::number(timer_id), "2"});
|
||||||
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
||||||
@ -149,16 +149,16 @@ void AOClient::changeArea(int new_area)
|
|||||||
sendPacket("TI", {QString::number(timer_id), "3"});
|
sendPacket("TI", {QString::number(timer_id), "3"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendServerMessage("You moved to area " + server->area_names[current_area]);
|
sendServerMessage("You moved to area " + server->m_area_names[current_area]);
|
||||||
if (server->areas[current_area]->lockStatus() == AreaData::LockStatus::SPECTATABLE)
|
if (server->m_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->m_area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AOClient::changeCharacter(int char_id)
|
bool AOClient::changeCharacter(int char_id)
|
||||||
{
|
{
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
|
|
||||||
if(char_id >= server->characters.length())
|
if(char_id >= server->m_characters.length())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (is_charcursed && !charcurse_list.contains(char_id)) {
|
if (is_charcursed && !charcurse_list.contains(char_id)) {
|
||||||
@ -172,7 +172,7 @@ bool AOClient::changeCharacter(int char_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l_successfulChange == true) {
|
if (l_successfulChange == true) {
|
||||||
QString char_selected = server->characters[char_id];
|
QString char_selected = server->m_characters[char_id];
|
||||||
current_char = char_selected;
|
current_char = char_selected;
|
||||||
pos = "";
|
pos = "";
|
||||||
server->updateCharsTaken(area);
|
server->updateCharsTaken(area);
|
||||||
@ -210,7 +210,7 @@ void AOClient::arup(ARUPType type, bool broadcast)
|
|||||||
{
|
{
|
||||||
QStringList arup_data;
|
QStringList arup_data;
|
||||||
arup_data.append(QString::number(type));
|
arup_data.append(QString::number(type));
|
||||||
for (AreaData* area : qAsConst(server->areas)) {
|
for (AreaData* area : qAsConst(server->m_areas)) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case ARUPType::PLAYER_COUNT: {
|
case ARUPType::PLAYER_COUNT: {
|
||||||
arup_data.append(QString::number(area->playerCount()));
|
arup_data.append(QString::number(area->playerCount()));
|
||||||
@ -319,7 +319,7 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
|
|||||||
#endif
|
#endif
|
||||||
if (acl_mask != ACLFlags.value("NONE")) {
|
if (acl_mask != ACLFlags.value("NONE")) {
|
||||||
if (acl_mask == ACLFlags.value("CM")) {
|
if (acl_mask == ACLFlags.value("CM")) {
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->owners().contains(id))
|
if (area->owners().contains(id))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -35,23 +35,20 @@ AreaData::AreaData(QString p_name, int p_index) :
|
|||||||
QStringList name_split = p_name.split(":");
|
QStringList name_split = p_name.split(":");
|
||||||
name_split.removeFirst();
|
name_split.removeFirst();
|
||||||
m_name = name_split.join(":");
|
m_name = name_split.join(":");
|
||||||
QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
|
QSettings* areas_ini = ConfigManager::areaData();
|
||||||
areas_ini.setIniCodec("UTF-8");
|
areas_ini->setIniCodec("UTF-8");
|
||||||
areas_ini.beginGroup(p_name);
|
areas_ini->beginGroup(p_name);
|
||||||
m_background = areas_ini.value("background", "gs4").toString();
|
m_background = areas_ini->value("background", "gs4").toString();
|
||||||
m_isProtected = areas_ini.value("protected_area", "false").toBool();
|
m_isProtected = areas_ini->value("protected_area", "false").toBool();
|
||||||
m_iniswapAllowed = areas_ini.value("iniswap_allowed", "true").toBool();
|
m_iniswapAllowed = areas_ini->value("iniswap_allowed", "true").toBool();
|
||||||
m_bgLocked = areas_ini.value("bg_locked", "false").toBool();
|
m_bgLocked = areas_ini->value("bg_locked", "false").toBool();
|
||||||
m_eviMod = QVariant(areas_ini.value("evidence_mod", "FFA").toString().toUpper()).value<EvidenceMod>();
|
m_eviMod = QVariant(areas_ini->value("evidence_mod", "FFA").toString().toUpper()).value<EvidenceMod>();
|
||||||
m_blankpostingAllowed = areas_ini.value("blankposting_allowed","true").toBool();
|
m_blankpostingAllowed = areas_ini->value("blankposting_allowed","true").toBool();
|
||||||
m_forceImmediate = areas_ini.value("force_immediate", "false").toBool();
|
m_forceImmediate = areas_ini->value("force_immediate", "false").toBool();
|
||||||
m_toggleMusic = areas_ini.value("toggle_music", "true").toBool();
|
m_toggleMusic = areas_ini->value("toggle_music", "true").toBool();
|
||||||
m_shownameAllowed = areas_ini.value("shownames_allowed", "true").toBool();
|
m_shownameAllowed = areas_ini->value("shownames_allowed", "true").toBool();
|
||||||
m_ignoreBgList = areas_ini.value("ignore_bglist", "false").toBool();
|
m_ignoreBgList = areas_ini->value("ignore_bglist", "false").toBool();
|
||||||
areas_ini.endGroup();
|
areas_ini->endGroup();
|
||||||
int log_size = ConfigManager::logBuffer();
|
|
||||||
if (log_size == 0)
|
|
||||||
log_size = 500;
|
|
||||||
QTimer* timer1 = new QTimer();
|
QTimer* timer1 = new QTimer();
|
||||||
m_timers.append(timer1);
|
m_timers.append(timer1);
|
||||||
QTimer* timer2 = new QTimer();
|
QTimer* timer2 = new QTimer();
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
void AOClient::cmdCM(int argc, QStringList argv)
|
void AOClient::cmdCM(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->isProtected()) {
|
if (area->isProtected()) {
|
||||||
sendServerMessage("This area is protected, you may not become CM.");
|
sendServerMessage("This area is protected, you may not become CM.");
|
||||||
return;
|
return;
|
||||||
@ -59,7 +59,7 @@ void AOClient::cmdCM(int argc, QStringList argv)
|
|||||||
|
|
||||||
void AOClient::cmdUnCM(int argc, QStringList argv)
|
void AOClient::cmdUnCM(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int uid;
|
int uid;
|
||||||
|
|
||||||
if (area->owners().isEmpty()) {
|
if (area->owners().isEmpty()) {
|
||||||
@ -104,7 +104,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
bool ok;
|
bool ok;
|
||||||
int invited_id = argv[0].toInt(&ok);
|
int invited_id = argv[0].toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -129,7 +129,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
bool ok;
|
bool ok;
|
||||||
int uninvited_id = argv[0].toInt(&ok);
|
int uninvited_id = argv[0].toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -159,14 +159,14 @@ void AOClient::cmdLock(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->lockStatus() == AreaData::LockStatus::LOCKED) {
|
if (area->lockStatus() == AreaData::LockStatus::LOCKED) {
|
||||||
sendServerMessage("This area is already locked.");
|
sendServerMessage("This area is already locked.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendServerMessageArea("This area is now locked.");
|
sendServerMessageArea("This area is now locked.");
|
||||||
area->lock();
|
area->lock();
|
||||||
for (AOClient* client : qAsConst(server->clients)) { // qAsConst here avoids detaching the container
|
for (AOClient* client : qAsConst(server->m_clients)) { // qAsConst here avoids detaching the container
|
||||||
if (client->current_area == current_area && client->joined) {
|
if (client->current_area == current_area && client->joined) {
|
||||||
area->invite(client->id);
|
area->invite(client->id);
|
||||||
}
|
}
|
||||||
@ -179,14 +179,14 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE) {
|
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE) {
|
||||||
sendServerMessage("This area is already in spectate mode.");
|
sendServerMessage("This area is already in spectate mode.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendServerMessageArea("This area is now spectatable.");
|
sendServerMessageArea("This area is now spectatable.");
|
||||||
area->spectatable();
|
area->spectatable();
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->current_area == current_area && client->joined) {
|
if (client->current_area == current_area && client->joined) {
|
||||||
area->invite(client->id);
|
area->invite(client->id);
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ void AOClient::cmdUnLock(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->lockStatus() == AreaData::LockStatus::FREE) {
|
if (area->lockStatus() == AreaData::LockStatus::FREE) {
|
||||||
sendServerMessage("This area is not locked.");
|
sendServerMessage("This area is not locked.");
|
||||||
return;
|
return;
|
||||||
@ -216,7 +216,7 @@ void AOClient::cmdGetAreas(int argc, QStringList argv)
|
|||||||
|
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
entries.append("== Area List ==");
|
entries.append("== Area List ==");
|
||||||
for (int i = 0; i < server->area_names.length(); i++) {
|
for (int i = 0; i < server->m_area_names.length(); i++) {
|
||||||
QStringList cur_area_lines = buildAreaList(i);
|
QStringList cur_area_lines = buildAreaList(i);
|
||||||
entries.append(cur_area_lines);
|
entries.append(cur_area_lines);
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ void AOClient::cmdArea(int argc, QStringList argv)
|
|||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int new_area = argv[0].toInt(&ok);
|
int new_area = argv[0].toInt(&ok);
|
||||||
if (!ok || new_area >= server->areas.size() || new_area < 0) {
|
if (!ok || new_area >= server->m_areas.size() || new_area < 0) {
|
||||||
sendServerMessage("That does not look like a valid area ID.");
|
sendServerMessage("That does not look like a valid area ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int idx = argv[0].toInt(&ok);
|
int idx = argv[0].toInt(&ok);
|
||||||
@ -257,7 +257,7 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
|
|||||||
sendServerMessage("That does not look like a valid ID.");
|
sendServerMessage("That does not look like a valid ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (server->areas[current_area]->owners().contains(idx)) {
|
if (server->m_areas[current_area]->owners().contains(idx)) {
|
||||||
sendServerMessage("You cannot kick another CM!");
|
sendServerMessage("You cannot kick another CM!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -281,9 +281,9 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
QString f_background = argv.join(" ");
|
QString f_background = argv.join(" ");
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (authenticated || !area->bgLocked()) {
|
if (authenticated || !area->bgLocked()) {
|
||||||
if (server->backgrounds.contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
|
if (server->m_backgrounds.contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
|
||||||
area->setBackground(f_background);
|
area->setBackground(f_background);
|
||||||
server->broadcast(AOPacket("BN", {f_background}), current_area);
|
server->broadcast(AOPacket("BN", {f_background}), current_area);
|
||||||
sendServerMessageArea(current_char + " changed the background to " + f_background);
|
sendServerMessageArea(current_char + " changed the background to " + f_background);
|
||||||
@ -302,7 +302,7 @@ void AOClient::cmdBgLock(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
|
|
||||||
if (area->bgLocked() == false) {
|
if (area->bgLocked() == false) {
|
||||||
area->toggleBgLock();
|
area->toggleBgLock();
|
||||||
@ -316,7 +316,7 @@ void AOClient::cmdBgUnlock(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
|
|
||||||
if (area->bgLocked() == true) {
|
if (area->bgLocked() == true) {
|
||||||
area->toggleBgLock();
|
area->toggleBgLock();
|
||||||
@ -329,7 +329,7 @@ void AOClient::cmdStatus(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
QString arg = argv[0].toLower();
|
QString arg = argv[0].toLower();
|
||||||
|
|
||||||
if (area->changeStatus(arg)) {
|
if (area->changeStatus(arg)) {
|
||||||
@ -346,7 +346,7 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->judgelog().isEmpty()) {
|
if (area->judgelog().isEmpty()) {
|
||||||
sendServerMessage("There have been no judge actions in this area.");
|
sendServerMessage("There have been no judge actions in this area.");
|
||||||
return;
|
return;
|
||||||
@ -367,7 +367,7 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->toggleIgnoreBgList();
|
area->toggleIgnoreBgList();
|
||||||
QString state = area->ignoreBgList() ? "ignored." : "enforced.";
|
QString state = area->ignoreBgList() ? "ignored." : "enforced.";
|
||||||
sendServerMessage("BG list in this area is now " + state);
|
sendServerMessage("BG list in this area is now " + state);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
void AOClient::cmdDoc(int argc, QStringList argv)
|
void AOClient::cmdDoc(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
sendServerMessage("Document: " + area->document());
|
sendServerMessage("Document: " + area->document());
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ void AOClient::cmdClearDoc(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->changeDoc("No document.");
|
area->changeDoc("No document.");
|
||||||
sendServerMessageArea(sender_name + " cleared the document.");
|
sendServerMessageArea(sender_name + " cleared the document.");
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
argv[0] = argv[0].toLower();
|
argv[0] = argv[0].toLower();
|
||||||
if (argv[0] == "cm")
|
if (argv[0] == "cm")
|
||||||
area->setEviMod(AreaData::EvidenceMod::CM);
|
area->setEviMod(AreaData::EvidenceMod::CM);
|
||||||
@ -72,7 +72,7 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int ev_size = area->evidence().size() -1;
|
int ev_size = area->evidence().size() -1;
|
||||||
|
|
||||||
if (ev_size < 0) {
|
if (ev_size < 0) {
|
||||||
@ -106,7 +106,7 @@ void AOClient::cmdTestify(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
|
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
|
||||||
sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one.");
|
sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one.");
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ void AOClient::cmdExamine(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->testimony().size() -1 > 0)
|
if (area->testimony().size() -1 > 0)
|
||||||
{
|
{
|
||||||
area->restartTestimony();
|
area->restartTestimony();
|
||||||
@ -141,7 +141,7 @@ void AOClient::cmdTestimony(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->testimony().size() -1 < 1) {
|
if (area->testimony().size() -1 < 1) {
|
||||||
sendServerMessage("Unable to display empty testimony.");
|
sendServerMessage("Unable to display empty testimony.");
|
||||||
return;
|
return;
|
||||||
@ -162,7 +162,7 @@ void AOClient::cmdDeleteStatement(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int c_statement = area->statement();
|
int c_statement = area->statement();
|
||||||
if (area->testimony().size() - 1 == 0) {
|
if (area->testimony().size() - 1 == 0) {
|
||||||
sendServerMessage("Unable to delete statement. No statements saved in this area.");
|
sendServerMessage("Unable to delete statement. No statements saved in this area.");
|
||||||
@ -178,7 +178,7 @@ void AOClient::cmdUpdateStatement(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
server->areas[current_area]->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE);
|
server->m_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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void AOClient::cmdPauseTestimony(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->setTestimonyRecording(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.");
|
||||||
@ -198,8 +198,8 @@ void AOClient::cmdAddStatement(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
if (server->areas[current_area]->statement() < ConfigManager::maxStatements()) {
|
if (server->m_areas[current_area]->statement() < ConfigManager::maxStatements()) {
|
||||||
server->areas[current_area]->setTestimonyRecording(AreaData::TestimonyRecording::ADD);
|
server->m_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
|
||||||
@ -218,7 +218,7 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
|
|||||||
permission_found = true;
|
permission_found = true;
|
||||||
|
|
||||||
if (permission_found) {
|
if (permission_found) {
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->testimony().size() -1 <= 0) {
|
if (area->testimony().size() -1 <= 0) {
|
||||||
sendServerMessage("Can't save an empty testimony.");
|
sendServerMessage("Can't save an empty testimony.");
|
||||||
return;
|
return;
|
||||||
@ -257,7 +257,7 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
QDir dir_testimony("storage/testimony");
|
QDir dir_testimony("storage/testimony");
|
||||||
if (!dir_testimony.exists()) {
|
if (!dir_testimony.exists()) {
|
||||||
sendServerMessage("Unable to load testimonies. Testimony storage not found.");
|
sendServerMessage("Unable to load testimonies. Testimony storage not found.");
|
||||||
|
@ -32,8 +32,8 @@ void AOClient::cmdDefault(int argc, QStringList argv)
|
|||||||
QStringList AOClient::buildAreaList(int area_idx)
|
QStringList AOClient::buildAreaList(int area_idx)
|
||||||
{
|
{
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
QString area_name = server->area_names[area_idx];
|
QString area_name = server->m_area_names[area_idx];
|
||||||
AreaData* area = server->areas[area_idx];
|
AreaData* area = server->m_areas[area_idx];
|
||||||
entries.append("=== " + area_name + " ===");
|
entries.append("=== " + area_name + " ===");
|
||||||
switch (area->lockStatus()) {
|
switch (area->lockStatus()) {
|
||||||
case AreaData::LockStatus::LOCKED:
|
case AreaData::LockStatus::LOCKED:
|
||||||
@ -47,7 +47,7 @@ QStringList AOClient::buildAreaList(int area_idx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]");
|
entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->current_area == area_idx && client->joined) {
|
if (client->current_area == area_idx && client->joined) {
|
||||||
QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char;
|
QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char;
|
||||||
if (client->current_char == "")
|
if (client->current_char == "")
|
||||||
@ -101,7 +101,7 @@ void AOClient::diceThrower(int argc, QStringList argv, bool p_roll)
|
|||||||
|
|
||||||
QString AOClient::getAreaTimer(int area_idx, int timer_idx)
|
QString AOClient::getAreaTimer(int area_idx, int timer_idx)
|
||||||
{
|
{
|
||||||
AreaData* area = server->areas[area_idx];
|
AreaData* area = server->m_areas[area_idx];
|
||||||
QTimer* timer;
|
QTimer* timer;
|
||||||
QString timer_name = (timer_idx == 0) ? "Global timer" : "Timer " + QString::number(timer_idx);
|
QString timer_name = (timer_idx == 0) ? "Global timer" : "Timer " + QString::number(timer_idx);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void AOClient::cmdPos(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
changePosition(argv[0]);
|
changePosition(argv[0]);
|
||||||
updateEvidenceList(server->areas[current_area]);
|
updateEvidenceList(server->m_areas[current_area]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdForcePos(int argc, QStringList argv)
|
void AOClient::cmdForcePos(int argc, QStringList argv)
|
||||||
@ -51,7 +51,7 @@ void AOClient::cmdForcePos(int argc, QStringList argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (argv[1] == "*") { // force all clients in the area
|
else if (argv[1] == "*") { // force all clients in the area
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->current_area == current_area)
|
if (client->current_area == current_area)
|
||||||
targets.append(client);
|
targets.append(client);
|
||||||
}
|
}
|
||||||
@ -69,9 +69,9 @@ void AOClient::cmdG(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
QString sender_area = server->area_names.value(current_area);
|
QString sender_area = server->m_area_names.value(current_area);
|
||||||
QString sender_message = argv.join(" ");
|
QString sender_message = argv.join(" ");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->global_enabled)
|
if (client->global_enabled)
|
||||||
client->sendPacket("CT", {"[G][" + sender_area + "]" + sender_name, sender_message});
|
client->sendPacket("CT", {"[G][" + sender_area + "]" + sender_name, sender_message});
|
||||||
}
|
}
|
||||||
@ -82,9 +82,9 @@ void AOClient::cmdNeed(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
QString sender_area = server->area_names.value(current_area);
|
QString sender_area = server->m_area_names.value(current_area);
|
||||||
QString sender_message = argv.join(" ");
|
QString sender_message = argv.join(" ");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->advert_enabled) {
|
if (client->advert_enabled) {
|
||||||
client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
|
client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ void AOClient::cmdRandomChar(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int selected_char_id;
|
int selected_char_id;
|
||||||
bool taken = true;
|
bool taken = true;
|
||||||
while (taken) {
|
while (taken) {
|
||||||
selected_char_id = genRand(0, server->characters.size() - 1);
|
selected_char_id = genRand(0, server->m_characters.size() - 1);
|
||||||
if (!area->charactersTaken().contains(selected_char_id)) {
|
if (!area->charactersTaken().contains(selected_char_id)) {
|
||||||
taken = false;
|
taken = false;
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ void AOClient::cmdM(int argc, QStringList argv)
|
|||||||
|
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
QString sender_message = argv.join(" ");
|
QString sender_message = argv.join(" ");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->checkAuth(ACLFlags.value("MODCHAT")))
|
if (client->checkAuth(ACLFlags.value("MODCHAT")))
|
||||||
client->sendPacket("CT", {"[M]" + sender_name, sender_message});
|
client->sendPacket("CT", {"[M]" + sender_name, sender_message});
|
||||||
}
|
}
|
||||||
@ -186,9 +186,9 @@ void AOClient::cmdGM(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
QString sender_area = server->area_names.value(current_area);
|
QString sender_area = server->m_area_names.value(current_area);
|
||||||
QString sender_message = argv.join(" ");
|
QString sender_message = argv.join(" ");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->global_enabled) {
|
if (client->global_enabled) {
|
||||||
client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message});
|
client->sendPacket("CT", {"[G][" + sender_area + "]" + "["+sender_name+"][M]", sender_message});
|
||||||
}
|
}
|
||||||
@ -439,11 +439,11 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
|
|||||||
//Kick back to char select screen
|
//Kick back to char select screen
|
||||||
if (!target->charcurse_list.contains(server->getCharID(target->current_char))) {
|
if (!target->charcurse_list.contains(server->getCharID(target->current_char))) {
|
||||||
target->changeCharacter(-1);
|
target->changeCharacter(-1);
|
||||||
server->updateCharsTaken(server->areas.value(current_area));
|
server->updateCharsTaken(server->m_areas.value(current_area));
|
||||||
target->sendPacket("DONE");
|
target->sendPacket("DONE");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
server->updateCharsTaken(server->areas.value(current_area));
|
server->updateCharsTaken(server->m_areas.value(current_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
target->sendServerMessage("You have been charcursed!");
|
target->sendServerMessage("You have been charcursed!");
|
||||||
@ -474,7 +474,7 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv)
|
|||||||
}
|
}
|
||||||
target->is_charcursed = false;
|
target->is_charcursed = false;
|
||||||
target->charcurse_list.clear();
|
target->charcurse_list.clear();
|
||||||
server->updateCharsTaken(server->areas.value(current_area));
|
server->updateCharsTaken(server->m_areas.value(current_area));
|
||||||
sendServerMessage("Uncharcursed player.");
|
sendServerMessage("Uncharcursed player.");
|
||||||
target->sendServerMessage("You were uncharcursed.");
|
target->sendServerMessage("You were uncharcursed.");
|
||||||
}
|
}
|
||||||
@ -517,7 +517,7 @@ void AOClient::cmdA(int argc, QStringList argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AreaData* area = server->areas[area_id];
|
AreaData* area = server->m_areas[area_id];
|
||||||
if (!area->owners().contains(id)) {
|
if (!area->owners().contains(id)) {
|
||||||
sendServerMessage("You are not CM in that area.");
|
sendServerMessage("You are not CM in that area.");
|
||||||
return;
|
return;
|
||||||
@ -533,12 +533,12 @@ void AOClient::cmdS(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
int all_areas = server->areas.size() - 1;
|
int all_areas = server->m_areas.size() - 1;
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
QString ooc_message = argv.join(" ");
|
QString ooc_message = argv.join(" ");
|
||||||
|
|
||||||
for (int i = 0; i <= all_areas; i++) {
|
for (int i = 0; i <= all_areas; i++) {
|
||||||
if (server->areas[i]->owners().contains(id))
|
if (server->m_areas[i]->owners().contains(id))
|
||||||
server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i);
|
server->broadcast(AOPacket("CT", {"[CM]" + sender_name, ooc_message}), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void AOClient::cmdMods(int argc, QStringList argv)
|
|||||||
|
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
int online_count = 0;
|
int online_count = 0;
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->authenticated) {
|
if (client->authenticated) {
|
||||||
entries << "---";
|
entries << "---";
|
||||||
if (ConfigManager::authType() != DataTypes::AuthType::SIMPLE)
|
if (ConfigManager::authType() != DataTypes::AuthType::SIMPLE)
|
||||||
@ -402,7 +402,7 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->toggleBlankposting();
|
area->toggleBlankposting();
|
||||||
if (area->blankpostingAllowed() == false) {
|
if (area->blankpostingAllowed() == false) {
|
||||||
sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden.");
|
sendServerMessageArea(sender_name + " has set blankposting in the area to forbidden.");
|
||||||
@ -470,7 +470,7 @@ void AOClient::cmdForceImmediate(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->toggleImmediate();
|
area->toggleImmediate();
|
||||||
QString state = area->forceImmediate() ? "on." : "off.";
|
QString state = area->forceImmediate() ? "on." : "off.";
|
||||||
sendServerMessage("Forced immediate text processing in this area is now " + state);
|
sendServerMessage("Forced immediate text processing in this area is now " + state);
|
||||||
@ -481,7 +481,7 @@ void AOClient::cmdAllowIniswap(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->toggleIniswap();
|
area->toggleIniswap();
|
||||||
QString state = area->iniswapAllowed() ? "allowed." : "disallowed.";
|
QString state = area->iniswapAllowed() ? "allowed." : "disallowed.";
|
||||||
sendServerMessage("Iniswapping in this area is now " + state);
|
sendServerMessage("Iniswapping in this area is now " + state);
|
||||||
|
@ -28,7 +28,7 @@ void AOClient::cmdPlay(int argc, QStringList argv)
|
|||||||
sendServerMessage("You are blocked from changing the music.");
|
sendServerMessage("You are blocked from changing the music.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
QString song = argv.join(" ");
|
QString song = argv.join(" ");
|
||||||
area->currentMusic() = song;
|
area->currentMusic() = song;
|
||||||
area->musicPlayerBy() = showname;
|
area->musicPlayerBy() = showname;
|
||||||
@ -41,7 +41,7 @@ void AOClient::cmdCurrentMusic(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->currentMusic() != "" && area->currentMusic() != "~stop.mp3") // dummy track for stopping music
|
if (area->currentMusic() != "" && area->currentMusic() != "~stop.mp3") // dummy track for stopping music
|
||||||
sendServerMessage("The current song is " + area->currentMusic() + " played by " + area->musicPlayerBy());
|
sendServerMessage("The current song is " + area->currentMusic() + " played by " + area->musicPlayerBy());
|
||||||
else
|
else
|
||||||
@ -107,7 +107,7 @@ void AOClient::cmdToggleMusic(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->toggleMusic();
|
area->toggleMusic();
|
||||||
QString state = area->isMusicAllowed() ? "allowed." : "disallowed.";
|
QString state = area->isMusicAllowed() ? "allowed." : "disallowed.";
|
||||||
sendServerMessage("Music in this area is now " + state);
|
sendServerMessage("Music in this area is now " + state);
|
||||||
|
@ -43,7 +43,7 @@ void AOClient::cmdRollP(int argc, QStringList argv)
|
|||||||
|
|
||||||
void AOClient::cmdTimer(int argc, QStringList argv)
|
void AOClient::cmdTimer(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
|
|
||||||
// Called without arguments
|
// Called without arguments
|
||||||
// Shows a brief of all timers
|
// Shows a brief of all timers
|
||||||
@ -134,7 +134,7 @@ void AOClient::cmdNoteCard(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
QString notecard = argv.join(" ");
|
QString notecard = argv.join(" ");
|
||||||
area->addNotecard(current_char, notecard);
|
area->addNotecard(current_char, notecard);
|
||||||
sendServerMessageArea(current_char + " wrote a note card.");
|
sendServerMessageArea(current_char + " wrote a note card.");
|
||||||
@ -145,7 +145,7 @@ void AOClient::cmdNoteCardClear(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (!area->addNotecard(current_char, QString())) {
|
if (!area->addNotecard(current_char, QString())) {
|
||||||
sendServerMessageArea(current_char + " erased their note card.");
|
sendServerMessageArea(current_char + " erased their note card.");
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
const QStringList l_notecards = area->getNotecards();
|
const QStringList l_notecards = area->getNotecards();
|
||||||
|
|
||||||
if (l_notecards.isEmpty()) {
|
if (l_notecards.isEmpty()) {
|
||||||
@ -192,7 +192,7 @@ void AOClient::cmdSubTheme(int argc, QStringList argv)
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
|
|
||||||
QString subtheme = argv.join(" ");
|
QString subtheme = argv.join(" ");
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->current_area == current_area)
|
if (client->current_area == current_area)
|
||||||
client->sendPacket("ST", {subtheme, "1"});
|
client->sendPacket("ST", {subtheme, "1"});
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
QSettings* ConfigManager::m_settings = new QSettings("config/config.ini", QSettings::IniFormat);
|
QSettings* ConfigManager::m_settings = new QSettings("config/config.ini", QSettings::IniFormat);
|
||||||
QSettings* ConfigManager::m_discord = new QSettings("config/discord.ini", QSettings::IniFormat);
|
QSettings* ConfigManager::m_discord = new QSettings("config/discord.ini", QSettings::IniFormat);
|
||||||
|
QSettings* ConfigManager::m_areas = new QSettings("config/areas.ini", QSettings::IniFormat);
|
||||||
ConfigManager::CommandSettings* ConfigManager::m_commands = new CommandSettings();
|
ConfigManager::CommandSettings* ConfigManager::m_commands = new CommandSettings();
|
||||||
QElapsedTimer* ConfigManager::m_uptimeTimer = new QElapsedTimer;
|
QElapsedTimer* ConfigManager::m_uptimeTimer = new QElapsedTimer;
|
||||||
|
|
||||||
@ -93,6 +94,75 @@ bool ConfigManager::verifyServerConfig()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ConfigManager::bindIP()
|
||||||
|
{
|
||||||
|
return m_settings->value("Options/bind_ip","all").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ConfigManager::charlist()
|
||||||
|
{
|
||||||
|
QStringList l_charlist;
|
||||||
|
QFile l_file("config/characters.txt");
|
||||||
|
l_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
while (!l_file.atEnd()) {
|
||||||
|
l_charlist.append(l_file.readLine().trimmed());
|
||||||
|
}
|
||||||
|
l_file.close();
|
||||||
|
|
||||||
|
return l_charlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ConfigManager::backgrounds()
|
||||||
|
{
|
||||||
|
QStringList l_backgrounds;
|
||||||
|
QFile l_file("config/backgrounds.txt");
|
||||||
|
l_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
while (!l_file.atEnd()) {
|
||||||
|
l_backgrounds.append(l_file.readLine().trimmed());
|
||||||
|
}
|
||||||
|
l_file.close();
|
||||||
|
|
||||||
|
return l_backgrounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ConfigManager::musiclist()
|
||||||
|
{
|
||||||
|
QStringList l_music_list;
|
||||||
|
QFile l_file("config/music.txt");
|
||||||
|
l_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
while (!l_file.atEnd()) {
|
||||||
|
l_music_list.append(l_file.readLine().trimmed());
|
||||||
|
}
|
||||||
|
l_file.close();
|
||||||
|
if(l_music_list[0].contains(".")) // Add a default category if none exists
|
||||||
|
l_music_list.insert(0, "==Music==");
|
||||||
|
return l_music_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings* ConfigManager::areaData()
|
||||||
|
{
|
||||||
|
return m_areas;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ConfigManager::sanitizedAreaNames()
|
||||||
|
{
|
||||||
|
QStringList l_area_names = m_areas->childGroups(); // invisibly does a lexicographical sort, because Qt is great like that
|
||||||
|
std::sort(l_area_names.begin(), l_area_names.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();});
|
||||||
|
QStringList l_sanitized_area_names;
|
||||||
|
for (const QString &areaName : qAsConst(l_area_names)) {
|
||||||
|
QStringList l_nameSplit = areaName.split(":");
|
||||||
|
l_nameSplit.removeFirst();
|
||||||
|
QString l_area_name_sanitized = l_nameSplit.join(":");
|
||||||
|
l_sanitized_area_names.append(l_area_name_sanitized);
|
||||||
|
}
|
||||||
|
return l_sanitized_area_names;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ConfigManager::rawAreaNames()
|
||||||
|
{
|
||||||
|
return m_areas->childGroups();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigManager::reloadSettings()
|
void ConfigManager::reloadSettings()
|
||||||
{
|
{
|
||||||
m_settings->sync();
|
m_settings->sync();
|
||||||
@ -102,12 +172,12 @@ void ConfigManager::reloadSettings()
|
|||||||
QStringList ConfigManager::loadConfigFile(const QString filename)
|
QStringList ConfigManager::loadConfigFile(const QString filename)
|
||||||
{
|
{
|
||||||
QStringList stringlist;
|
QStringList stringlist;
|
||||||
QFile file("config/text/" + filename + ".txt");
|
QFile l_file("config/text/" + filename + ".txt");
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
l_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
while (!(file.atEnd())) {
|
while (!(l_file.atEnd())) {
|
||||||
stringlist.append(file.readLine().trimmed());
|
stringlist.append(l_file.readLine().trimmed());
|
||||||
}
|
}
|
||||||
file.close();
|
l_file.close();
|
||||||
return stringlist;
|
return stringlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke
|
|||||||
version.minor = match.captured(3).toInt();
|
version.minor = match.captured(3).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPacket("PN", {QString::number(server->player_count), QString::number(ConfigManager::maxPlayers())});
|
sendPacket("PN", {QString::number(server->m_player_count), QString::number(ConfigManager::maxPlayers())});
|
||||||
sendPacket("FL", feature_list);
|
sendPacket("FL", feature_list);
|
||||||
|
|
||||||
if (ConfigManager::assetUrl().isValid()) {
|
if (ConfigManager::assetUrl().isValid()) {
|
||||||
@ -93,7 +93,7 @@ void AOClient::pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket
|
|||||||
// Evidence isn't loaded during this part anymore
|
// Evidence isn't loaded during this part anymore
|
||||||
// As a result, we can always send "0" for evidence length
|
// As a result, we can always send "0" for evidence length
|
||||||
// Client only cares about what it gets from LE
|
// Client only cares about what it gets from LE
|
||||||
sendPacket("SI", {QString::number(server->characters.length()), "0", QString::number(server->area_names.length() + server->music_list.length())});
|
sendPacket("SI", {QString::number(server->m_characters.length()), "0", QString::number(server->m_area_names.length() + server->m_music_list.length())});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktRequestChars(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktRequestChars(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
@ -103,7 +103,7 @@ void AOClient::pktRequestChars(AreaData* area, int argc, QStringList argv, AOPac
|
|||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
Q_UNUSED(packet);
|
Q_UNUSED(packet);
|
||||||
|
|
||||||
sendPacket("SC", server->characters);
|
sendPacket("SC", server->m_characters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
@ -113,7 +113,7 @@ void AOClient::pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPac
|
|||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
Q_UNUSED(packet);
|
Q_UNUSED(packet);
|
||||||
|
|
||||||
sendPacket("SM", server->area_names + server->music_list);
|
sendPacket("SM", server->m_area_names + server->m_music_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
@ -132,7 +132,7 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->player_count++;
|
server->m_player_count++;
|
||||||
area->clientJoinedArea();
|
area->clientJoinedArea();
|
||||||
joined = true;
|
joined = true;
|
||||||
server->updateCharsTaken(area);
|
server->updateCharsTaken(area);
|
||||||
@ -142,7 +142,7 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
|
|
||||||
sendPacket("HP", {"1", QString::number(area->defHP())});
|
sendPacket("HP", {"1", QString::number(area->defHP())});
|
||||||
sendPacket("HP", {"2", QString::number(area->proHP())});
|
sendPacket("HP", {"2", QString::number(area->proHP())});
|
||||||
sendPacket("FA", server->area_names);
|
sendPacket("FA", server->m_area_names);
|
||||||
//Here lies OPPASS, the genius of FanatSors who send the modpass to everyone in plain text.
|
//Here lies OPPASS, the genius of FanatSors who send the modpass to everyone in plain text.
|
||||||
sendPacket("DONE");
|
sendPacket("DONE");
|
||||||
sendPacket("BN", {area->background()});
|
sendPacket("BN", {area->background()});
|
||||||
@ -217,7 +217,7 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
|
|||||||
validated_packet.contents[5] = pos;
|
validated_packet.contents[5] = pos;
|
||||||
|
|
||||||
server->broadcast(validated_packet, current_area);
|
server->broadcast(validated_packet, current_area);
|
||||||
emit logIC((current_char + " " + showname), ooc_name,ipid,server->areas[current_area]->name(),last_message);
|
emit logIC((current_char + " " + showname), ooc_name,ipid,server->m_areas[current_area]->name(),last_message);
|
||||||
area->updateLastICMessage(validated_packet.contents);
|
area->updateLastICMessage(validated_packet.contents);
|
||||||
|
|
||||||
server->can_send_ic_messages = false;
|
server->can_send_ic_messages = false;
|
||||||
@ -264,7 +264,7 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
|
|||||||
int cmd_argc = cmd_argv.length();
|
int cmd_argc = cmd_argv.length();
|
||||||
|
|
||||||
handleCommand(command, cmd_argc, cmd_argv);
|
handleCommand(command, cmd_argc, cmd_argv);
|
||||||
emit logCMD((current_char + " " + showname),ipid, ooc_name,command,cmd_argv,server->areas[current_area]->name());
|
emit logCMD((current_char + " " + showname),ipid, ooc_name,command,cmd_argv,server->m_areas[current_area]->name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -298,7 +298,7 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
// argument is a valid song
|
// argument is a valid song
|
||||||
QString argument = argv[0];
|
QString argument = argv[0];
|
||||||
|
|
||||||
for (const QString &song : qAsConst(server->music_list)) {
|
for (const QString &song : qAsConst(server->m_music_list)) {
|
||||||
if (song == argument || song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
|
if (song == argument || song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
|
||||||
// We have a song here
|
// We have a song here
|
||||||
if (is_dj_blocked) {
|
if (is_dj_blocked) {
|
||||||
@ -327,8 +327,8 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < server->area_names.length(); i++) {
|
for (int i = 0; i < server->m_area_names.length(); i++) {
|
||||||
QString area = server->area_names[i];
|
QString area = server->m_area_names[i];
|
||||||
if(area == argument) {
|
if(area == argument) {
|
||||||
changeArea(i);
|
changeArea(i);
|
||||||
break;
|
break;
|
||||||
@ -398,7 +398,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
int multiclient_count = 0;
|
int multiclient_count = 0;
|
||||||
for (AOClient* joined_client : qAsConst(server->clients)) {
|
for (AOClient* joined_client : qAsConst(server->m_clients)) {
|
||||||
if (remote_ip.isEqual(joined_client->remote_ip))
|
if (remote_ip.isEqual(joined_client->remote_ip))
|
||||||
multiclient_count++;
|
multiclient_count++;
|
||||||
}
|
}
|
||||||
@ -415,11 +415,11 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p
|
|||||||
Q_UNUSED(argc);
|
Q_UNUSED(argc);
|
||||||
Q_UNUSED(argv);
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->authenticated)
|
if (client->authenticated)
|
||||||
client->sendPacket(packet);
|
client->sendPacket(packet);
|
||||||
}
|
}
|
||||||
emit logModcall((current_char + " " + showname),ipid, ooc_name, server->areas[current_area]->name());
|
emit logModcall((current_char + " " + showname),ipid, ooc_name, server->m_areas[current_area]->name());
|
||||||
|
|
||||||
if (ConfigManager::discordModcallWebhookEnabled()) {
|
if (ConfigManager::discordModcallWebhookEnabled()) {
|
||||||
QString name = ooc_name;
|
QString name = ooc_name;
|
||||||
@ -524,7 +524,7 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
|
|||||||
#else
|
#else
|
||||||
QSet<bool> needs_set = needs_list.toSet();
|
QSet<bool> needs_set = needs_list.toSet();
|
||||||
#endif
|
#endif
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
QSet<bool> matches(client->casing_preferences.begin(), client->casing_preferences.end());
|
QSet<bool> matches(client->casing_preferences.begin(), client->casing_preferences.end());
|
||||||
matches.intersect(needs_set);
|
matches.intersect(needs_set);
|
||||||
@ -546,7 +546,7 @@ void AOClient::pktAnnounceCase(AreaData* area, int argc, QStringList argv, AOPac
|
|||||||
|
|
||||||
void AOClient::sendEvidenceList(AreaData* area)
|
void AOClient::sendEvidenceList(AreaData* area)
|
||||||
{
|
{
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->current_area == current_area)
|
if (client->current_area == current_area)
|
||||||
client->updateEvidenceList(area);
|
client->updateEvidenceList(area);
|
||||||
}
|
}
|
||||||
@ -590,7 +590,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
if (current_char == "" || !joined)
|
if (current_char == "" || !joined)
|
||||||
// Spectators cannot use IC
|
// Spectators cannot use IC
|
||||||
return invalid;
|
return invalid;
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS")))
|
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(id) && !checkAuth(ACLFlags.value("BYPASS_LOCKS")))
|
||||||
// Non-invited players cannot speak in spectatable areas
|
// Non-invited players cannot speak in spectatable areas
|
||||||
return invalid;
|
return invalid;
|
||||||
@ -617,7 +617,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
// Selected char is different from supplied folder name
|
// Selected char is different from supplied folder name
|
||||||
// This means the user is INI-swapped
|
// This means the user is INI-swapped
|
||||||
if (!area->iniswapAllowed()) {
|
if (!area->iniswapAllowed()) {
|
||||||
if (!server->characters.contains(incoming_args[2].toString(), Qt::CaseInsensitive))
|
if (!server->m_characters.contains(incoming_args[2].toString(), Qt::CaseInsensitive))
|
||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
qDebug() << "INI swap detected from " << getIpid();
|
qDebug() << "INI swap detected from " << getIpid();
|
||||||
@ -670,7 +670,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
args.append(incoming_args[5].toString());
|
args.append(incoming_args[5].toString());
|
||||||
if (pos != incoming_args[5].toString()) {
|
if (pos != incoming_args[5].toString()) {
|
||||||
pos = incoming_args[5].toString();
|
pos = incoming_args[5].toString();
|
||||||
updateEvidenceList(server->areas[current_area]);
|
updateEvidenceList(server->m_areas[current_area]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sfx name
|
// sfx name
|
||||||
@ -770,7 +770,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
QString other_emote = "0";
|
QString other_emote = "0";
|
||||||
QString other_offset = "0";
|
QString other_offset = "0";
|
||||||
QString other_flip = "0";
|
QString other_flip = "0";
|
||||||
for (AOClient* client : qAsConst(server->clients)) {
|
for (AOClient* client : qAsConst(server->m_clients)) {
|
||||||
if (client->pairing_with == char_id
|
if (client->pairing_with == char_id
|
||||||
&& other_charid != char_id
|
&& other_charid != char_id
|
||||||
&& client->char_id == pairing_with
|
&& client->char_id == pairing_with
|
||||||
@ -990,7 +990,7 @@ void AOClient::loginAttempt(QString message)
|
|||||||
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
|
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
|
||||||
sendServerMessage("Incorrect password.");
|
sendServerMessage("Incorrect password.");
|
||||||
}
|
}
|
||||||
emit logLogin((current_char + " " + showname),ooc_name,"Moderator", ipid, server->areas.value(current_area)->name(),authenticated);
|
emit logLogin((current_char + " " + showname),ooc_name,"Moderator", ipid, server->m_areas.value(current_area)->name(),authenticated);
|
||||||
break;
|
break;
|
||||||
case DataTypes::AuthType::ADVANCED:
|
case DataTypes::AuthType::ADVANCED:
|
||||||
QStringList login = message.split(" ");
|
QStringList login = message.split(" ");
|
||||||
@ -1014,7 +1014,7 @@ void AOClient::loginAttempt(QString message)
|
|||||||
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
|
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
|
||||||
sendServerMessage("Incorrect password.");
|
sendServerMessage("Incorrect password.");
|
||||||
}
|
}
|
||||||
emit logLogin((current_char + " " + showname),ooc_name, username, ipid, server->areas.value(current_area)->name(),authenticated);
|
emit logLogin((current_char + " " + showname),ooc_name, username, ipid, server->m_areas.value(current_area)->name(),authenticated);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sendServerMessage("Exiting login prompt.");
|
sendServerMessage("Exiting login prompt.");
|
||||||
|
@ -19,24 +19,31 @@
|
|||||||
|
|
||||||
Server::Server(int p_port, int p_ws_port, QObject* parent) :
|
Server::Server(int p_port, int p_ws_port, QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
player_count(0),
|
m_player_count(0),
|
||||||
port(p_port),
|
port(p_port),
|
||||||
ws_port(p_ws_port)
|
ws_port(p_ws_port)
|
||||||
{
|
{
|
||||||
server = new QTcpServer(this);
|
server = new QTcpServer(this);
|
||||||
connect(server, SIGNAL(newConnection()), this, SLOT(clientConnected()));
|
connect(server, SIGNAL(newConnection()), this, SLOT(clientConnected()));
|
||||||
|
|
||||||
|
proxy = new WSProxy(port, ws_port, this);
|
||||||
|
if(ws_port != -1)
|
||||||
|
proxy->start();
|
||||||
timer = new QTimer();
|
timer = new QTimer();
|
||||||
|
|
||||||
db_manager = new DBManager();
|
db_manager = new DBManager();
|
||||||
|
|
||||||
|
//We create it, even if its not used later on.
|
||||||
|
discord = new Discord(this);
|
||||||
|
|
||||||
|
logger = new ULogger(this);
|
||||||
|
connect(this, &Server::logConnectionAttempt,
|
||||||
|
logger, &ULogger::logConnectionAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::start()
|
void Server::start()
|
||||||
{
|
{
|
||||||
QSettings config("config/config.ini", QSettings::IniFormat);
|
QString bind_ip = ConfigManager::bindIP();
|
||||||
config.beginGroup("Options");
|
|
||||||
QString bind_ip = config.value("ip", "all").toString();
|
|
||||||
QHostAddress bind_addr;
|
QHostAddress bind_addr;
|
||||||
if (bind_ip == "all")
|
if (bind_ip == "all")
|
||||||
bind_addr = QHostAddress::Any;
|
bind_addr = QHostAddress::Any;
|
||||||
@ -52,9 +59,10 @@ void Server::start()
|
|||||||
qDebug() << "Server listening on" << port;
|
qDebug() << "Server listening on" << port;
|
||||||
}
|
}
|
||||||
|
|
||||||
discord = new Discord(this);
|
//Checks if any Discord webhooks are enabled.
|
||||||
handleDiscordIntegration();
|
handleDiscordIntegration();
|
||||||
|
|
||||||
|
//Construct modern advertiser if enabled in config
|
||||||
if (ConfigManager::advertiseHTTPServer()) {
|
if (ConfigManager::advertiseHTTPServer()) {
|
||||||
httpAdvertiserTimer = new QTimer(this);
|
httpAdvertiserTimer = new QTimer(this);
|
||||||
httpAdvertiser = new HTTPAdvertiser();
|
httpAdvertiser = new HTTPAdvertiser();
|
||||||
@ -69,53 +77,24 @@ void Server::start()
|
|||||||
httpAdvertiserTimer->start(300000);
|
httpAdvertiserTimer->start(300000);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger = new ULogger(this);
|
//Get characters from config file
|
||||||
connect(this, &Server::logConnectionAttempt,
|
m_characters = ConfigManager::charlist();
|
||||||
logger, &ULogger::logConnectionAttempt);
|
|
||||||
|
|
||||||
proxy = new WSProxy(port, ws_port, this);
|
//Get musiclist from config file
|
||||||
if(ws_port != -1)
|
m_music_list = ConfigManager::musiclist();
|
||||||
proxy->start();
|
|
||||||
|
|
||||||
QFile char_list("config/characters.txt");
|
//Get backgrounds from config file
|
||||||
char_list.open(QIODevice::ReadOnly | QIODevice::Text);
|
m_backgrounds = ConfigManager::backgrounds();
|
||||||
while (!char_list.atEnd()) {
|
|
||||||
characters.append(char_list.readLine().trimmed());
|
|
||||||
}
|
|
||||||
char_list.close();
|
|
||||||
|
|
||||||
QFile music_file("config/music.txt");
|
//Assembles the area list
|
||||||
music_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
m_area_names = ConfigManager::sanitizedAreaNames();
|
||||||
while (!music_file.atEnd()) {
|
QStringList raw_area_names = ConfigManager::rawAreaNames();
|
||||||
music_list.append(music_file.readLine().trimmed());
|
|
||||||
}
|
|
||||||
music_file.close();
|
|
||||||
if(music_list[0].contains(".")) // Add a default category if none exists
|
|
||||||
music_list.insert(0, "==Music==");
|
|
||||||
|
|
||||||
QFile bg_file("config/backgrounds.txt");
|
|
||||||
bg_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
||||||
while (!bg_file.atEnd()) {
|
|
||||||
backgrounds.append(bg_file.readLine().trimmed());
|
|
||||||
}
|
|
||||||
bg_file.close();
|
|
||||||
|
|
||||||
QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
|
|
||||||
area_names = areas_ini.childGroups(); // invisibly does a lexicographical sort, because Qt is great like that
|
|
||||||
std::sort(area_names.begin(), area_names.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();});
|
|
||||||
QStringList sanitized_area_names;
|
|
||||||
QStringList raw_area_names = area_names;
|
|
||||||
for (const QString &area_name : qAsConst(area_names)) {
|
|
||||||
QStringList name_split = area_name.split(":");
|
|
||||||
name_split.removeFirst();
|
|
||||||
QString area_name_sanitized = name_split.join(":");
|
|
||||||
sanitized_area_names.append(area_name_sanitized);
|
|
||||||
}
|
|
||||||
area_names = sanitized_area_names;
|
|
||||||
for (int i = 0; i < raw_area_names.length(); i++) {
|
for (int i = 0; i < raw_area_names.length(); i++) {
|
||||||
QString area_name = raw_area_names[i];
|
QString area_name = raw_area_names[i];
|
||||||
areas.insert(i, new AreaData(area_name, i));
|
m_areas.insert(i, new AreaData(area_name, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Rate-Limiter for IC-Chat
|
||||||
connect(&next_message_timer, SIGNAL(timeout()), this, SLOT(allowMessage()));
|
connect(&next_message_timer, SIGNAL(timeout()), this, SLOT(allowMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,10 +103,10 @@ void Server::clientConnected()
|
|||||||
QTcpSocket* socket = server->nextPendingConnection();
|
QTcpSocket* socket = server->nextPendingConnection();
|
||||||
int user_id;
|
int user_id;
|
||||||
QList<int> user_ids;
|
QList<int> user_ids;
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
user_ids.append(client->id);
|
user_ids.append(client->id);
|
||||||
}
|
}
|
||||||
for (user_id = 0; user_id <= player_count; user_id++) {
|
for (user_id = 0; user_id <= m_player_count; user_id++) {
|
||||||
if (user_ids.contains(user_id))
|
if (user_ids.contains(user_id))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
@ -140,7 +119,7 @@ void Server::clientConnected()
|
|||||||
client->calculateIpid();
|
client->calculateIpid();
|
||||||
auto ban = db_manager->isIPBanned(client->getIpid());
|
auto ban = db_manager->isIPBanned(client->getIpid());
|
||||||
bool is_banned = ban.first;
|
bool is_banned = ban.first;
|
||||||
for (AOClient* joined_client : qAsConst(clients)) {
|
for (AOClient* joined_client : qAsConst(m_clients)) {
|
||||||
if (client->remote_ip.isEqual(joined_client->remote_ip))
|
if (client->remote_ip.isEqual(joined_client->remote_ip))
|
||||||
multiclient_count++;
|
multiclient_count++;
|
||||||
}
|
}
|
||||||
@ -160,11 +139,11 @@ void Server::clientConnected()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.append(client);
|
m_clients.append(client);
|
||||||
connect(socket, &QTcpSocket::disconnected, client,
|
connect(socket, &QTcpSocket::disconnected, client,
|
||||||
&AOClient::clientDisconnected);
|
&AOClient::clientDisconnected);
|
||||||
connect(socket, &QTcpSocket::disconnected, this, [=] {
|
connect(socket, &QTcpSocket::disconnected, this, [=] {
|
||||||
clients.removeAll(client);
|
m_clients.removeAll(client);
|
||||||
client->deleteLater();
|
client->deleteLater();
|
||||||
});
|
});
|
||||||
connect(socket, &QTcpSocket::readyRead, client, &AOClient::clientData);
|
connect(socket, &QTcpSocket::readyRead, client, &AOClient::clientData);
|
||||||
@ -182,7 +161,7 @@ void Server::clientConnected()
|
|||||||
void Server::updateCharsTaken(AreaData* area)
|
void Server::updateCharsTaken(AreaData* area)
|
||||||
{
|
{
|
||||||
QStringList chars_taken;
|
QStringList chars_taken;
|
||||||
for (const QString &cur_char : qAsConst(characters)) {
|
for (const QString &cur_char : qAsConst(m_characters)) {
|
||||||
chars_taken.append(area->charactersTaken().contains(getCharID(cur_char))
|
chars_taken.append(area->charactersTaken().contains(getCharID(cur_char))
|
||||||
? QStringLiteral("-1")
|
? QStringLiteral("-1")
|
||||||
: QStringLiteral("0"));
|
: QStringLiteral("0"));
|
||||||
@ -190,7 +169,7 @@ void Server::updateCharsTaken(AreaData* area)
|
|||||||
|
|
||||||
AOPacket response_cc("CharsCheck", chars_taken);
|
AOPacket response_cc("CharsCheck", chars_taken);
|
||||||
|
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
if (client->current_area == area->index()){
|
if (client->current_area == area->index()){
|
||||||
if (!client->is_charcursed)
|
if (!client->is_charcursed)
|
||||||
client->sendPacket(response_cc);
|
client->sendPacket(response_cc);
|
||||||
@ -217,7 +196,7 @@ QStringList Server::getCursedCharsTaken(AOClient* client, QStringList chars_take
|
|||||||
|
|
||||||
void Server::broadcast(AOPacket packet, int area_index)
|
void Server::broadcast(AOPacket packet, int area_index)
|
||||||
{
|
{
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
if (client->current_area == area_index)
|
if (client->current_area == area_index)
|
||||||
client->sendPacket(packet);
|
client->sendPacket(packet);
|
||||||
}
|
}
|
||||||
@ -225,7 +204,7 @@ void Server::broadcast(AOPacket packet, int area_index)
|
|||||||
|
|
||||||
void Server::broadcast(AOPacket packet)
|
void Server::broadcast(AOPacket packet)
|
||||||
{
|
{
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
client->sendPacket(packet);
|
client->sendPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +212,7 @@ void Server::broadcast(AOPacket packet)
|
|||||||
QList<AOClient*> Server::getClientsByIpid(QString ipid)
|
QList<AOClient*> Server::getClientsByIpid(QString ipid)
|
||||||
{
|
{
|
||||||
QList<AOClient*> return_clients;
|
QList<AOClient*> return_clients;
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
if (client->getIpid() == ipid)
|
if (client->getIpid() == ipid)
|
||||||
return_clients.append(client);
|
return_clients.append(client);
|
||||||
}
|
}
|
||||||
@ -242,7 +221,7 @@ QList<AOClient*> Server::getClientsByIpid(QString ipid)
|
|||||||
|
|
||||||
AOClient* Server::getClientByID(int id)
|
AOClient* Server::getClientByID(int id)
|
||||||
{
|
{
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
if (client->id == id)
|
if (client->id == id)
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
@ -251,9 +230,9 @@ AOClient* Server::getClientByID(int id)
|
|||||||
|
|
||||||
int Server::getCharID(QString char_name)
|
int Server::getCharID(QString char_name)
|
||||||
{
|
{
|
||||||
for (const QString &character : qAsConst(characters)) {
|
for (const QString &character : qAsConst(m_characters)) {
|
||||||
if (character.toLower() == char_name.toLower()) {
|
if (character.toLower() == char_name.toLower()) {
|
||||||
return characters.indexOf(QRegExp(character, Qt::CaseInsensitive));
|
return m_characters.indexOf(QRegExp(character, Qt::CaseInsensitive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; // character does not exist
|
return -1; // character does not exist
|
||||||
@ -336,7 +315,7 @@ void Server::hookupLogger(AOClient* client)
|
|||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
for (AOClient* client : qAsConst(clients)) {
|
for (AOClient* client : qAsConst(m_clients)) {
|
||||||
client->deleteLater();
|
client->deleteLater();
|
||||||
}
|
}
|
||||||
server->deleteLater();
|
server->deleteLater();
|
||||||
|
@ -24,7 +24,7 @@ void AOClient::addStatement(QStringList packet)
|
|||||||
if (checkTestimonySymbols(packet[4])) {
|
if (checkTestimonySymbols(packet[4])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int c_statement = area->statement();
|
int c_statement = area->statement();
|
||||||
if (c_statement >= -1) {
|
if (c_statement >= -1) {
|
||||||
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
|
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
|
||||||
@ -57,7 +57,7 @@ QStringList AOClient::updateStatement(QStringList packet)
|
|||||||
if (checkTestimonySymbols(packet[4])) {
|
if (checkTestimonySymbols(packet[4])) {
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
int c_statement = area->statement();
|
int c_statement = area->statement();
|
||||||
area->setTestimonyRecording(AreaData::TestimonyRecording::PLAYBACK);
|
area->setTestimonyRecording(AreaData::TestimonyRecording::PLAYBACK);
|
||||||
if (c_statement <= 0 || area->testimony()[c_statement].empty())
|
if (c_statement <= 0 || area->testimony()[c_statement].empty())
|
||||||
@ -73,7 +73,7 @@ QStringList AOClient::updateStatement(QStringList packet)
|
|||||||
|
|
||||||
void AOClient::clearTestimony()
|
void AOClient::clearTestimony()
|
||||||
{
|
{
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->m_areas[current_area];
|
||||||
area->clearTestimony();
|
area->clearTestimony();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user