Playerlist and repository structure changes (#358)

This commit is contained in:
Leifa 2024-06-23 18:57:56 +02:00 committed by GitHub
parent d62121c236
commit 040f5a3216
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
122 changed files with 1044 additions and 855 deletions

View File

@ -45,7 +45,7 @@ jobs:
- name: qmake and build
run: |
cd $GITHUB_WORKSPACE
qmake
qmake project-akashi.pro
make
mv bin/config_sample bin/config
@ -62,52 +62,50 @@ jobs:
name: akashi-linux
path: bin/
coverage:
needs: build-linux
runs-on: ubuntu-latest
# coverage:
# runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# steps:
# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v2
- name: Install dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: qt5-qmake libqt5websockets5-dev g++ make
version: 1.0
# - name: Install dependencies
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: qt5-qmake libqt5websockets5-dev g++ make
# version: 1.0
# Runs a set of commands using the runners shell
- name: qmake and build
run: |
cd $GITHUB_WORKSPACE
qmake CONFIG+=coverage
make
# # Runs a set of commands using the runners shell
# - name: qmake and build
# run: |
# cd $GITHUB_WORKSPACE
# qmake CONFIG+=coverage project-akashi.pro
# make
- name: Run tests
run: |
cd ${{github.workspace}}/bin_tests/
for test in ./unittest_*; do
LD_LIBRARY_PATH=../bin:$LD_LIBRARY_PATH ./$test
done;
# - name: Run tests
# run: |
# cd ${{github.workspace}}/bin_tests/
# for test in ./unittest_*; do
# LD_LIBRARY_PATH=../bin:$LD_LIBRARY_PATH ./$test
# done;
- name: Copy coverage files
run: |
cd ${{github.workspace}}/core
gcov *.o
cd ..
mkdir coverage
cp core/*.gcov coverage/
# - name: Copy coverage files
# run: |
# mkdir coverage
# cd ${{github.workspace}}
# gcov *.o
# cp *.gcov ../coverage/
- name: Codecov
uses: codecov/codecov-action@v3.1.0
with:
files: coverage/*
# - name: Codecov
# uses: codecov/codecov-action@v3.1.0
# with:
# files: coverage/*
- name: Upload coverage files
uses: actions/upload-artifact@v2
with:
name: coverage statistics
path: coverage/
# - name: Upload coverage files
# uses: actions/upload-artifact@v2
# with:
# name: coverage statistics
# path: coverage/
build-windows:
needs: formatting-check
@ -132,7 +130,7 @@ jobs:
- name: Build
run: |
cd $Env:GITHUB_WORKSPACE
qmake "CONFIG += qtquickcompiler" akashi.pro
qmake "CONFIG += qtquickcompiler" project-akashi.pro
nmake
windeployqt bin\akashi.exe --release --no-opengl-sw
mv bin\config_sample bin\config

View File

@ -1,13 +1,33 @@
TEMPLATE = subdirs
QT += network websockets core sql
SUBDIRS += \
core \
akashi \
tests
TEMPLATE = app
akashi.subdirs = akashi
core.subdirs = core
core.tests = tests
CONFIG += c++2a console
# How to make subdirs not suck. Simple, use depends.
akashi.depends = core
coverage {
LIBS += -lgcov
}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
QMAKE_CXXFLAGS_WARN_OFF -= -Wunused-parameter
DESTDIR = $$PWD/bin
RC_ICONS = resource/icon/akashi.ico
INCLUDEPATH += src
SOURCES += \
src/main.cpp
LIBS += -L$$PWD/bin -lcore

View File

@ -1,38 +0,0 @@
QT += network websockets core sql
QT -= gui
TEMPLATE = app
unix:CONFIG += c++1z console
win32: CONFIG+=c++2a console
coverage {
LIBS += -lgcov
}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
QMAKE_CXXFLAGS_WARN_OFF -= -Wunused-parameter
DESTDIR = $$PWD/../bin
OBJECTS_DIR = $$PWD/../build
MOC_DIR = $$PWD/../build
RC_ICONS = resource/icon/akashi.ico
SOURCES += main.cpp
# Include the akashi library
win32: LIBS += -L$$PWD/../bin/ -lcore
else:unix: LIBS += -L$$PWD/../bin/ -lcore
INCLUDEPATH += $$PWD/../core
DEPENDPATH += $$PWD/../core

126
core.pro Normal file
View File

@ -0,0 +1,126 @@
QT += network websockets core sql
TEMPLATE = lib
# shared static is required by Windows.
CONFIG += shared static c++2a
coverage {
QMAKE_CXXFLAGS += --coverage -g -Og # -fprofile-arcs -ftest-coverage
LIBS += -lgcov
CONFIG -= static
}
# Needed so that Windows doesn't do `release/` and `debug/` subfolders
# in the output directory.
CONFIG -= \
copy_dir_files \
debug_and_release \
debug_and_release_target
DESTDIR = $$PWD/bin
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Enable this to print network messages to the console
# DEFINES += NET_DEBUG
INCLUDEPATH += src
SOURCES += \
src/acl_roles_handler.cpp \
src/aoclient.cpp \
src/network/aopacket.cpp \
src/network/network_socket.cpp \
src/area_data.cpp \
src/command_extension.cpp \
src/commands/area.cpp \
src/commands/authentication.cpp \
src/commands/casing.cpp \
src/commands/command_helper.cpp \
src/commands/messaging.cpp \
src/commands/moderation.cpp \
src/commands/music.cpp \
src/commands/roleplay.cpp \
src/config_manager.cpp \
src/db_manager.cpp \
src/discord.cpp \
src/packets.cpp \
src/playerstateobserver.cpp \
src/server.cpp \
src/testimony_recorder.cpp \
src/advertiser.cpp \
src/logger/u_logger.cpp \
src/logger/writer_modcall.cpp \
src/logger/writer_full.cpp \
src/music_manager.cpp \
src/packet/packet_factory.cpp \
src/packet/packet_generic.cpp \
src/packet/packet_hi.cpp \
src/packet/packet_id.cpp \
src/packet/packet_askchaa.cpp \
src/packet/packet_casea.cpp \
src/packet/packet_cc.cpp \
src/packet/packet_ch.cpp \
src/packet/packet_ct.cpp \
src/packet/packet_de.cpp \
src/packet/packet_ee.cpp \
src/packet/packet_hp.cpp \
src/packet/packet_mc.cpp \
src/packet/packet_ms.cpp \
src/packet/packet_pe.cpp \
src/packet/packet_pl.cpp \
src/packet/packet_pw.cpp \
src/packet/packet_rc.cpp \
src/packet/packet_rd.cpp \
src/packet/packet_rm.cpp \
src/packet/packet_rt.cpp \
src/packet/packet_setcase.cpp \
src/packet/packet_zz.cpp
HEADERS += src/aoclient.h \
src/acl_roles_handler.h \
src/akashidefs.h \
src/akashiutils.h \
src/network/aopacket.h \
src/network/network_socket.h \
src/area_data.h \
src/command_extension.h \
src/config_manager.h \
src/data_types.h \
src/db_manager.h \
src/discord.h \
src/playerstateobserver.h \
src/server.h \
src/typedefs.h \
src/advertiser.h \
src/logger/u_logger.h \
src/logger/writer_modcall.h \
src/logger/writer_full.h \
src/music_manager.h \
src/packet/packet_factory.h \
src/packet/packet_info.h \
src/packet/packet_generic.h \
src/packet/packet_hi.h \
src/packet/packet_id.h \
src/packet/packet_askchaa.h \
src/packet/packet_casea.h \
src/packet/packet_cc.h \
src/packet/packet_ch.h \
src/packet/packet_ct.h \
src/packet/packet_de.h \
src/packet/packet_ee.h \
src/packet/packet_hp.h \
src/packet/packet_mc.h \
src/packet/packet_ms.h \
src/packet/packet_pe.h \
src/packet/packet_pl.h \
src/packet/packet_pw.h \
src/packet/packet_rc.h \
src/packet/packet_rd.h \
src/packet/packet_rm.h \
src/packet/packet_rt.h \
src/packet/packet_setcase.h \
src/packet/packet_zz.h

View File

@ -1,124 +0,0 @@
QT += network websockets core sql
QT -= gui
TEMPLATE = lib
# Apparently, Windows needs a static config to make a dynamic library?
# Look, I dunno.
# Linux works just fine with `shared` only.
unix: CONFIG += shared static c++1z
win32: CONFIG+= shared static c++2a
coverage {
QMAKE_CXXFLAGS += --coverage -g -Og # -fprofile-arcs -ftest-coverage
LIBS += -lgcov
CONFIG -= static
}
# Needed so that Windows doesn't do `release/` and `debug/` subfolders
# in the output directory.
CONFIG -= \
copy_dir_files \
debug_and_release \
debug_and_release_target
DESTDIR = $$PWD/../bin
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Enable this to print network messages to the console
# DEFINES += NET_DEBUG
SOURCES += \
src/acl_roles_handler.cpp \
src/aoclient.cpp \
src/network/aopacket.cpp \
src/network/network_socket.cpp \
src/area_data.cpp \
src/command_extension.cpp \
src/commands/area.cpp \
src/commands/authentication.cpp \
src/commands/casing.cpp \
src/commands/command_helper.cpp \
src/commands/messaging.cpp \
src/commands/moderation.cpp \
src/commands/music.cpp \
src/commands/roleplay.cpp \
src/config_manager.cpp \
src/db_manager.cpp \
src/discord.cpp \
src/packets.cpp \
src/server.cpp \
src/testimony_recorder.cpp \
src/advertiser.cpp \
src/logger/u_logger.cpp \
src/logger/writer_modcall.cpp \
src/logger/writer_full.cpp \
src/music_manager.cpp \
src/packet/packet_factory.cpp \
src/packet/packet_generic.cpp \
src/packet/packet_hi.cpp \
src/packet/packet_id.cpp \
src/packet/packet_askchaa.cpp \
src/packet/packet_casea.cpp \
src/packet/packet_cc.cpp \
src/packet/packet_ch.cpp \
src/packet/packet_ct.cpp \
src/packet/packet_de.cpp \
src/packet/packet_ee.cpp \
src/packet/packet_hp.cpp \
src/packet/packet_mc.cpp \
src/packet/packet_ms.cpp \
src/packet/packet_pe.cpp \
src/packet/packet_pw.cpp \
src/packet/packet_rc.cpp \
src/packet/packet_rd.cpp \
src/packet/packet_rm.cpp \
src/packet/packet_rt.cpp \
src/packet/packet_setcase.cpp \
src/packet/packet_zz.cpp
HEADERS += include/aoclient.h \
include/acl_roles_handler.h \
include/akashidefs.h \
include/akashiutils.h \
include/network/aopacket.h \
include/network/network_socket.h \
include/area_data.h \
include/command_extension.h \
include/config_manager.h \
include/data_types.h \
include/db_manager.h \
include/discord.h \
include/server.h \
include/typedefs.h \
include/advertiser.h \
include/logger/u_logger.h \
include/logger/writer_modcall.h \
include/logger/writer_full.h \
include/music_manager.h \
include/packet/packet_factory.h \
include/packet/packet_info.h \
include/packet/packet_generic.h \
include/packet/packet_hi.h \
include/packet/packet_id.h \
include/packet/packet_askchaa.h \
include/packet/packet_casea.h \
include/packet/packet_cc.h \
include/packet/packet_ch.h \
include/packet/packet_ct.h \
include/packet/packet_de.h \
include/packet/packet_ee.h \
include/packet/packet_hp.h \
include/packet/packet_mc.h \
include/packet/packet_ms.h \
include/packet/packet_pe.h \
include/packet/packet_pw.h \
include/packet/packet_rc.h \
include/packet/packet_rd.h \
include/packet/packet_rm.h \
include/packet/packet_rt.h \
include/packet/packet_setcase.h \
include/packet/packet_zz.h

12
project-akashi.pro Normal file
View File

@ -0,0 +1,12 @@
TEMPLATE = subdirs
SUBDIRS += \
core \
akashi \
tests
core.file = core.pro
core.tests = tests
tests.depends = core
akashi.file = akashi.pro
akashi.depends = core

View File

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 716 B

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,4 +1,4 @@
#include "include/acl_roles_handler.h"
#include "acl_roles_handler.h"
#include <QDebug>
#include <QSettings>

View File

@ -15,9 +15,9 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/advertiser.h"
#include "advertiser.h"
#include "include/config_manager.h"
#include "config_manager.h"
Advertiser::Advertiser()
{

View File

@ -15,14 +15,13 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/command_extension.h"
#include "include/config_manager.h"
#include "include/db_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "command_extension.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
const QMap<QString, AOClient::CommandInfo> AOClient::COMMANDS{
{"login", {{ACLRole::NONE}, 0, &AOClient::cmdLogin}},
@ -156,25 +155,26 @@ void AOClient::clientDisconnected()
qDebug() << m_remote_ip.toString() << "disconnected";
#endif
if (m_joined) {
server->getAreaById(m_current_area)->clientLeftArea(server->getCharID(m_current_char), m_id);
server->getAreaById(areaId())
->removeClient(server->getCharID(character()), clientId());
arup(ARUPType::PLAYER_COUNT, true);
}
if (m_current_char != "") {
server->updateCharsTaken(server->getAreaById(m_current_area));
if (character() != "") {
server->updateCharsTaken(server->getAreaById(areaId()));
}
bool l_updateLocks = false;
const QVector<AreaData *> l_areas = server->getAreas();
for (AreaData *l_area : l_areas) {
l_updateLocks = l_updateLocks || l_area->removeOwner(m_id);
l_updateLocks = l_updateLocks || l_area->removeOwner(clientId());
}
if (l_updateLocks)
arup(ARUPType::LOCKED, true);
arup(ARUPType::CM, true);
emit clientSuccessfullyDisconnected(m_id);
emit clientSuccessfullyDisconnected(clientId());
}
void AOClient::handlePacket(AOPacket *packet)
@ -182,7 +182,7 @@ void AOClient::handlePacket(AOPacket *packet)
#ifdef NET_DEBUG
qDebug() << "Received packet:" << packet->getPacketInfo().header << ":" << packet->getContent() << "args length:" << packet->getContent().length();
#endif
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (packet->getContent().join("").size() > 16384) {
return;
@ -211,28 +211,30 @@ void AOClient::handlePacket(AOPacket *packet)
void AOClient::changeArea(int new_area)
{
if (m_current_area == new_area) {
sendServerMessage("You are already in area " + server->getAreaName(m_current_area));
if (areaId() == new_area) {
sendServerMessage("You are already in area " + server->getAreaName(areaId()));
return;
}
if (server->getAreaById(new_area)->lockStatus() == AreaData::LockStatus::LOCKED && !server->getAreaById(new_area)->invited().contains(m_id) && !checkPermission(ACLRole::BYPASS_LOCKS)) {
if (server->getAreaById(new_area)->lockStatus() == AreaData::LockStatus::LOCKED && !server->getAreaById(new_area)->invited().contains(clientId()) && !checkPermission(ACLRole::BYPASS_LOCKS)) {
sendServerMessage("Area " + server->getAreaName(new_area) + " is locked.");
return;
}
if (m_current_char != "") {
server->getAreaById(m_current_area)->changeCharacter(server->getCharID(m_current_char), -1);
server->updateCharsTaken(server->getAreaById(m_current_area));
if (character() != "") {
server->getAreaById(areaId())
->changeCharacter(server->getCharID(character()), -1);
server->updateCharsTaken(server->getAreaById(areaId()));
}
server->getAreaById(m_current_area)->clientLeftArea(m_char_id, m_id);
server->getAreaById(areaId())->removeClient(m_char_id, clientId());
bool l_character_taken = false;
if (server->getAreaById(new_area)->charactersTaken().contains(server->getCharID(m_current_char))) {
m_current_char = "";
if (server->getAreaById(new_area)->charactersTaken().contains(
server->getCharID(character()))) {
setCharacter("");
m_char_id = -1;
l_character_taken = true;
}
server->getAreaById(new_area)->clientJoinedArea(m_char_id, m_id);
m_current_area = new_area;
server->getAreaById(new_area)->addClient(m_char_id, clientId());
setAreaId(new_area);
arup(ARUPType::PLAYER_COUNT, true);
sendEvidenceList(server->getAreaById(new_area));
sendPacket("HP", {"1", QString::number(server->getAreaById(new_area)->defHP())});
@ -241,9 +243,9 @@ void AOClient::changeArea(int new_area)
if (l_character_taken) {
sendPacket("DONE");
}
const QList<QTimer *> l_timers = server->getAreaById(m_current_area)->timers();
const QList<QTimer *> l_timers = server->getAreaById(areaId())->timers();
for (QTimer *l_timer : l_timers) {
int l_timer_id = server->getAreaById(m_current_area)->timers().indexOf(l_timer) + 1;
int l_timer_id = server->getAreaById(areaId())->timers().indexOf(l_timer) + 1;
if (l_timer->isActive()) {
sendPacket("TI", {QString::number(l_timer_id), "2"});
sendPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_timer->remainingTime())))});
@ -252,17 +254,17 @@ void AOClient::changeArea(int new_area)
sendPacket("TI", {QString::number(l_timer_id), "3"});
}
}
sendServerMessage("You moved to area " + server->getAreaName(m_current_area));
if (server->getAreaById(m_current_area)->sendAreaMessageOnJoin())
sendServerMessage(server->getAreaById(m_current_area)->areaMessage());
sendServerMessage("You moved to area " + server->getAreaName(areaId()));
if (server->getAreaById(areaId())->sendAreaMessageOnJoin())
sendServerMessage(server->getAreaById(areaId())->areaMessage());
if (server->getAreaById(m_current_area)->lockStatus() == AreaData::LockStatus::SPECTATABLE)
sendServerMessage("Area " + server->getAreaName(m_current_area) + " is spectate-only; to chat IC you will need to be invited by the CM.");
if (server->getAreaById(areaId())->lockStatus() == AreaData::LockStatus::SPECTATABLE)
sendServerMessage("Area " + server->getAreaName(areaId()) + " is spectate-only; to chat IC you will need to be invited by the CM.");
}
bool AOClient::changeCharacter(int char_id)
{
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (char_id >= server->getCharacterCount())
return false;
@ -271,20 +273,21 @@ bool AOClient::changeCharacter(int char_id)
return false;
}
bool l_successfulChange = l_area->changeCharacter(server->getCharID(m_current_char), char_id);
bool l_successfulChange = l_area->changeCharacter(server->getCharID(character()),
char_id);
if (char_id < 0) {
m_current_char = "";
setCharacter("");
m_char_id = char_id;
setSpectator(true);
}
if (l_successfulChange == true) {
QString l_char_selected = server->getCharacterById(char_id);
m_current_char = l_char_selected;
setCharacter(l_char_selected);
m_pos = "";
server->updateCharsTaken(l_area);
sendPacket("PV", {QString::number(m_id), "CID", QString::number(char_id)});
sendPacket("PV", {QString::number(clientId()), "CID", QString::number(char_id)});
return true;
}
return false;
@ -366,7 +369,7 @@ void AOClient::arup(ARUPType type, bool broadcast)
const QList<int> l_owner_ids = l_area->owners();
for (int l_owner_id : l_owner_ids) {
AOClient *l_owner = server->getClientByID(l_owner_id);
l_area_owners.append("[" + QString::number(l_owner->m_id) + "] " + l_owner->m_current_char);
l_area_owners.append("[" + QString::number(l_owner->clientId()) + "] " + l_owner->character());
}
l_arup_data.append(l_area_owners.join(", "));
}
@ -400,9 +403,6 @@ void AOClient::fullArup()
void AOClient::sendPacket(AOPacket *packet)
{
#ifdef NET_DEBUG
qDebug() << "Sent packet:" << packet->getPacketInfo().header << ":" << packet->getContent();
#endif
m_socket->write(packet);
}
@ -438,7 +438,8 @@ void AOClient::sendServerMessage(QString message)
void AOClient::sendServerMessageArea(QString message)
{
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), message, "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), message, "1"}),
areaId());
}
void AOClient::sendServerBroadcast(QString message)
@ -452,7 +453,7 @@ bool AOClient::checkPermission(ACLRole::Permission f_permission) const
return true;
}
if ((f_permission == ACLRole::CM) && server->getAreaById(m_current_area)->owners().contains(m_id)) {
if ((f_permission == ACLRole::CM) && server->getAreaById(areaId())->owners().contains(clientId())) {
return true; // I'm sorry for this hack.
}
@ -490,6 +491,49 @@ bool AOClient::isAuthenticated() const
Server *AOClient::getServer() { return server; }
int AOClient::clientId() const
{
return m_id;
}
QString AOClient::name() const { return m_ooc_name; }
void AOClient::setName(const QString &f_name)
{
m_ooc_name = f_name;
Q_EMIT nameChanged(m_ooc_name);
}
int AOClient::areaId() const
{
return m_current_area;
}
void AOClient::setAreaId(const int f_area_id)
{
m_current_area = f_area_id;
Q_EMIT areaIdChanged(m_current_area);
}
QString AOClient::character() const
{
return m_current_char;
}
void AOClient::setCharacter(const QString &f_character)
{
m_current_char = f_character;
Q_EMIT characterChanged(m_current_char);
}
QString AOClient::characterName() const { return m_showname; }
void AOClient::setCharacterName(const QString &f_showname)
{
m_showname = f_showname;
Q_EMIT characterNameChanged(m_showname);
}
void AOClient::setSpectator(bool f_spectator)
{
m_is_spectator = f_spectator;
@ -507,17 +551,18 @@ void AOClient::onAfkTimeout()
m_is_afk = true;
}
AOClient::AOClient(Server *p_server, NetworkSocket *socket, QObject *parent, int user_id, MusicManager *p_manager) :
AOClient::AOClient(
Server *p_server, NetworkSocket *socket, QObject *parent, int user_id, MusicManager *p_manager) :
QObject(parent),
m_id(user_id),
m_remote_ip(socket->peerAddress()),
m_password(""),
m_joined(false),
m_current_area(0),
m_current_char(""),
m_socket(socket),
m_music_manager(p_manager),
m_last_wtce_time(0),
m_id(user_id),
m_current_area(0),
m_current_char(""),
server(p_server),
is_partial(false)
{

View File

@ -26,9 +26,9 @@
#include <QTimer>
#include <QtGlobal>
#include "include/acl_roles_handler.h"
#include "include/network/aopacket.h"
#include "include/network/network_socket.h"
#include "acl_roles_handler.h"
#include "network/aopacket.h"
#include "network/network_socket.h"
class AreaData;
class DBManager;
@ -141,10 +141,19 @@ class AOClient : public QObject
*/
Server *getServer();
/**
* @brief The user ID of the client.
*/
int m_id;
int clientId() const;
QString name() const;
void setName(const QString &f_name);
QString character() const;
void setCharacter(const QString &f_character);
QString characterName() const;
void setCharacterName(const QString &f_showname);
int areaId() const;
void setAreaId(const int f_area_id);
/**
* @brief The IP address of the client.
@ -167,16 +176,6 @@ class AOClient : public QObject
*/
bool m_joined;
/**
* @brief The ID of the area the client is currently in.
*/
int m_current_area;
/**
* @brief The internal name of the character the client is currently using.
*/
QString m_current_char;
/**
* @brief The internal name of the character the client is iniswapped to.
*
@ -651,7 +650,27 @@ class AOClient : public QObject
*/
void joined();
void nameChanged(const QString &);
void characterChanged(const QString &);
void characterNameChanged(const QString &);
void areaIdChanged(int);
private:
/**
* @brief The user ID of the client.
*/
int m_id;
/**
* @brief The ID of the area the client is currently in.
*/
int m_current_area;
/**
* @brief The internal name of the character the client is currently using.
*/
QString m_current_char;
/**
* @brief A pointer to the Server, used for updating server variables that depend on the client (e.g. amount of players in an area).
*/

View File

@ -18,10 +18,10 @@
#include <algorithm>
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/music_manager.h"
#include "include/packet/packet_factory.h"
#include "area_data.h"
#include "config_manager.h"
#include "music_manager.h"
#include "packet/packet_factory.h"
AreaData::AreaData(QString p_name, int p_index, MusicManager *p_music_manager = nullptr) :
m_index(p_index),
@ -89,7 +89,7 @@ const QMap<QString, AreaData::Status> AreaData::map_statuses = {
{"gaming", AreaData::Status::GAMING},
};
void AreaData::clientLeftArea(int f_charId, int f_userId)
void AreaData::removeClient(int f_charId, int f_userId)
{
--m_playerCount;
@ -99,7 +99,7 @@ void AreaData::clientLeftArea(int f_charId, int f_userId)
m_joined_ids.removeAll(f_userId);
}
void AreaData::clientJoinedArea(int f_charId, int f_userId)
void AreaData::addClient(int f_charId, int f_userId)
{
++m_playerCount;

View File

@ -26,7 +26,7 @@
#include <QString>
#include <QTimer>
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class ConfigManager;
class Logger;
@ -230,7 +230,7 @@ class AreaData : public QObject
* @param f_userId The user ID of the client who left. The default value is '-1', This ID is technically
* impossible.
*/
void clientLeftArea(int f_charId = -1, int f_userId = -1);
void removeClient(int f_charId = -1, int f_userId = -1);
/**
* @brief A client in the area joined recently.
@ -243,7 +243,7 @@ class AreaData : public QObject
* @param f_userId The user ID of the client who left. The default value is '-1', This ID is technically
* impossible.
*/
void clientJoinedArea(int f_charId = -1, int f_userId = -1);
void addClient(int f_charId = -1, int f_userId = -1);
/**
* @brief Returns a copy of the list of owners of this area.

View File

@ -1,9 +1,9 @@
#include "include/command_extension.h"
#include "command_extension.h"
#include <QDebug>
#include <QSettings>
#include "include/akashidefs.h"
#include "akashidefs.h"
CommandExtension::CommandExtension() {}

View File

@ -6,7 +6,7 @@
#include <QString>
#include <QVector>
#include "include/acl_roles_handler.h"
#include "acl_roles_handler.h"
class CommandExtension
{

View File

@ -15,30 +15,30 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for commands under the area category in aoclient.h
// Be sure to register the command in the header before adding it here!
void AOClient::cmdCM(int argc, QStringList argv)
{
QString l_sender_name = m_ooc_name;
AreaData *l_area = server->getAreaById(m_current_area);
QString l_sender_name = name();
AreaData *l_area = server->getAreaById(areaId());
if (l_area->isProtected()) {
sendServerMessage("This area is protected, you may not become CM.");
return;
}
else if (l_area->owners().isEmpty()) { // no one owns this area, and it's not protected
l_area->addOwner(m_id);
l_area->addOwner(clientId());
sendServerMessageArea(l_sender_name + " is now CM in this area.");
arup(ARUPType::CM, true);
}
else if (!l_area->owners().contains(m_id)) { // there is already a CM, and it isn't us
else if (!l_area->owners().contains(clientId())) { // there is already a CM, and it isn't us
sendServerMessage("You cannot become a CM in this area.");
}
else if (argc == 1) { // we are CM, and we want to make ID argv[0] also CM
@ -52,12 +52,12 @@ void AOClient::cmdCM(int argc, QStringList argv)
sendServerMessage("Unable to find client with ID " + argv[0] + ".");
return;
}
if (l_area->owners().contains(l_owner_candidate->m_id)) {
if (l_area->owners().contains(l_owner_candidate->clientId())) {
sendServerMessage("User is already a CM in this area.");
return;
}
l_area->addOwner(l_owner_candidate->m_id);
sendServerMessageArea(l_owner_candidate->m_ooc_name + " is now CM in this area.");
l_area->addOwner(l_owner_candidate->clientId());
sendServerMessageArea(l_owner_candidate->name() + " is now CM in this area.");
arup(ARUPType::CM, true);
}
else {
@ -67,7 +67,7 @@ void AOClient::cmdCM(int argc, QStringList argv)
void AOClient::cmdUnCM(int argc, QStringList argv)
{
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
int l_uid;
if (l_area->owners().isEmpty()) {
@ -75,7 +75,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
return;
}
else if (argc == 0) {
l_uid = m_id;
l_uid = clientId();
sendServerMessage("You are no longer CM in this area.");
}
else if (checkPermission(ACLRole::UNCM) && argc >= 1) {
@ -94,7 +94,7 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
sendServerMessage("No client with that ID found.");
return;
}
sendServerMessage(l_target->m_ooc_name + " was successfully unCMed.");
sendServerMessage(l_target->name() + " was successfully unCMed.");
l_target->sendServerMessage("You have been unCMed by a moderator.");
}
else {
@ -113,7 +113,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
bool ok;
int l_invited_id = argv[0].toInt(&ok);
if (!ok) {
@ -138,7 +138,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
bool ok;
int l_uninvited_id = argv[0].toInt(&ok);
if (!ok) {
@ -168,7 +168,7 @@ void AOClient::cmdLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *area = server->getAreaById(m_current_area);
AreaData *area = server->getAreaById(areaId());
if (area->lockStatus() == AreaData::LockStatus::LOCKED) {
sendServerMessage("This area is already locked.");
return;
@ -177,8 +177,8 @@ void AOClient::cmdLock(int argc, QStringList argv)
area->lock();
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area && l_client->hasJoined()) {
area->invite(l_client->m_id);
if (l_client->areaId() == areaId() && l_client->hasJoined()) {
area->invite(l_client->clientId());
}
}
arup(ARUPType::LOCKED, true);
@ -189,7 +189,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->lockStatus() == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("This area is already in spectate mode.");
return;
@ -198,8 +198,8 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
l_area->spectatable();
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area && l_client->hasJoined()) {
l_area->invite(l_client->m_id);
if (l_client->areaId() == areaId() && l_client->hasJoined()) {
l_area->invite(l_client->clientId());
}
}
arup(ARUPType::LOCKED, true);
@ -210,7 +210,7 @@ void AOClient::cmdUnLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->lockStatus() == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked.");
return;
@ -241,7 +241,7 @@ void AOClient::cmdGetArea(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
QStringList l_entries = buildAreaList(m_current_area);
QStringList l_entries = buildAreaList(areaId());
sendServerMessage(l_entries.join("\n"));
}
@ -262,7 +262,7 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
bool ok;
int l_idx = argv[0].toInt(&ok);
@ -270,7 +270,7 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
sendServerMessage("That does not look like a valid ID.");
return;
}
if (server->getAreaById(m_current_area)->owners().contains(l_idx)) {
if (server->getAreaById(areaId())->owners().contains(l_idx)) {
sendServerMessage("You cannot kick another CM!");
return;
}
@ -279,12 +279,12 @@ void AOClient::cmdAreaKick(int argc, QStringList argv)
sendServerMessage("No client with that ID found.");
return;
}
else if (l_client_to_kick->m_current_area != m_current_area) {
else if (l_client_to_kick->areaId() != areaId()) {
sendServerMessage("That client is not in this area.");
return;
}
l_client_to_kick->changeArea(0);
l_area->uninvite(l_client_to_kick->m_id);
l_area->uninvite(l_client_to_kick->clientId());
sendServerMessage("Client " + argv[0] + " kicked back to area 0.");
}
@ -294,19 +294,19 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
Q_UNUSED(argc);
QString f_background = argv.join(" ");
AreaData *area = server->getAreaById(m_current_area);
AreaData *area = server->getAreaById(areaId());
if (m_authenticated || !area->bgLocked()) {
if (server->getBackgrounds().contains(f_background, Qt::CaseInsensitive) || area->ignoreBgList() == true) {
area->setBackground(f_background);
server->broadcast(PacketFactory::createPacket("BN", {f_background}), m_current_area);
server->broadcast(PacketFactory::createPacket("BN", {f_background}), areaId());
QString ambience_name = ConfigManager::ambience()->value(f_background + "/ambience").toString();
if (ambience_name != "") {
server->broadcast(PacketFactory::createPacket("MC", {ambience_name, "-1", m_showname, "1", "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("MC", {ambience_name, "-1", characterName(), "1", "1"}), areaId());
}
else {
server->broadcast(PacketFactory::createPacket("MC", {"~stop.mp3", "-1", m_showname, "1", "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("MC", {"~stop.mp3", "-1", characterName(), "1", "1"}), areaId());
}
sendServerMessageArea(m_current_char + " changed the background to " + f_background);
sendServerMessageArea(character() + " changed the background to " + f_background);
}
else {
sendServerMessage("Invalid background name.");
@ -322,13 +322,13 @@ void AOClient::cmdBgLock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->bgLocked() == false) {
l_area->toggleBgLock();
};
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), m_current_char + " locked the background.", "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), character() + " locked the background.", "1"}), areaId());
}
void AOClient::cmdBgUnlock(int argc, QStringList argv)
@ -336,25 +336,25 @@ void AOClient::cmdBgUnlock(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->bgLocked() == true) {
l_area->toggleBgLock();
};
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), m_current_char + " unlocked the background.", "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), character() + " unlocked the background.", "1"}), areaId());
}
void AOClient::cmdStatus(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
QString l_arg = argv[0].toLower();
if (l_area->changeStatus(l_arg)) {
arup(ARUPType::STATUS, true);
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), m_current_char + " changed status to " + l_arg.toUpper(), "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("CT", {ConfigManager::serverName(), character() + " changed status to " + l_arg.toUpper(), "1"}), areaId());
}
else {
const QStringList keys = AreaData::map_statuses.keys();
@ -367,7 +367,7 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->judgelog().isEmpty()) {
sendServerMessage("There have been no judge actions in this area.");
return;
@ -388,7 +388,7 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleIgnoreBgList();
QString l_state = l_area->ignoreBgList() ? "ignored." : "enforced.";
sendServerMessage("BG list in this area is now " + l_state);
@ -396,7 +396,7 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
void AOClient::cmdAreaMessage(int argc, QStringList argv)
{
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (argc == 0) {
sendServerMessage(l_area->areaMessage());
return;
@ -413,7 +413,7 @@ void AOClient::cmdToggleAreaMessageOnJoin(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleAreaMessageJoin();
QString l_state = l_area->sendAreaMessageOnJoin() ? "enabled." : "disabled.";
sendServerMessage("Sending message on area join is now " + l_state);
@ -424,7 +424,7 @@ void AOClient::cmdToggleWtce(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleWtceAllowed();
QString l_state = l_area->isWtceAllowed() ? "enabled." : "disabled.";
sendServerMessage("Using testimony animations is now " + l_state);
@ -435,7 +435,7 @@ void AOClient::cmdToggleShouts(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleShoutAllowed();
QString l_state = l_area->isShoutAllowed() ? "enabled." : "disabled.";
sendServerMessage("Using shouts is now " + l_state);
@ -446,7 +446,7 @@ void AOClient::cmdClearAreaMessage(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->clearAreaMessage();
if (l_area->sendAreaMessageOnJoin()) // Turn off the automatic sending.
cmdToggleAreaMessageOnJoin(0, QStringList{}); // Dummy values.

View File

@ -15,12 +15,12 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/config_manager.h"
#include "include/crypto_helper.h"
#include "include/db_manager.h"
#include "include/server.h"
#include "config_manager.h"
#include "crypto_helper.h"
#include "db_manager.h"
#include "server.h"
// This file is for commands under the authentication category in aoclient.h
// Be sure to register the command in the header before adding it here!

View File

@ -15,20 +15,20 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for commands under the casing category in aoclient.h
// Be sure to register the command in the header before adding it here!
void AOClient::cmdDoc(int argc, QStringList argv)
{
QString l_sender_name = m_ooc_name;
AreaData *l_area = server->getAreaById(m_current_area);
QString l_sender_name = name();
AreaData *l_area = server->getAreaById(areaId());
if (argc == 0) {
sendServerMessage("Document: " + l_area->document());
}
@ -43,8 +43,8 @@ void AOClient::cmdClearDoc(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
AreaData *l_area = server->getAreaById(m_current_area);
QString l_sender_name = name();
AreaData *l_area = server->getAreaById(areaId());
l_area->changeDoc("No document.");
sendServerMessageArea(l_sender_name + " cleared the document.");
}
@ -53,7 +53,7 @@ void AOClient::cmdEvidenceMod(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
argv[0] = argv[0].toLower();
if (argv[0] == "cm")
l_area->setEviMod(AreaData::EvidenceMod::CM);
@ -77,7 +77,7 @@ void AOClient::cmdEvidence_Swap(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
int l_ev_size = l_area->evidence().size() - 1;
if (l_ev_size < 0) {
@ -111,7 +111,7 @@ void AOClient::cmdTestify(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING) {
sendServerMessage("Testimony recording is already in progress. Please stop it before starting a new one.");
}
@ -127,11 +127,11 @@ void AOClient::cmdExamine(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->testimony().size() - 1 > 0) {
l_area->restartTestimony();
server->broadcast(PacketFactory::createPacket("RT", {"testimony2"}), m_current_area);
server->broadcast(PacketFactory::createPacket("MS", {l_area->testimony()[0]}), m_current_area);
server->broadcast(PacketFactory::createPacket("RT", {"testimony2"}), areaId());
server->broadcast(PacketFactory::createPacket("MS", {l_area->testimony()[0]}), areaId());
return;
}
if (l_area->testimonyRecording() == AreaData::TestimonyRecording::PLAYBACK)
@ -145,7 +145,7 @@ void AOClient::cmdTestimony(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->testimony().size() - 1 < 1) {
sendServerMessage("Unable to display empty testimony.");
return;
@ -165,7 +165,7 @@ void AOClient::cmdDeleteStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
int l_c_statement = l_area->statement();
if (l_area->testimony().size() - 1 == 0) {
sendServerMessage("Unable to delete statement. No statements saved in this area.");
@ -181,7 +181,7 @@ void AOClient::cmdUpdateStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
server->getAreaById(m_current_area)->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE);
server->getAreaById(areaId())->setTestimonyRecording(AreaData::TestimonyRecording::UPDATE);
sendServerMessage("The next IC-Message will replace the last displayed replay message.");
}
@ -190,9 +190,9 @@ void AOClient::cmdPauseTestimony(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->setTestimonyRecording(AreaData::TestimonyRecording::STOPPED);
server->broadcast(PacketFactory::createPacket("RT", {"testimony1", "1"}), m_current_area);
server->broadcast(PacketFactory::createPacket("RT", {"testimony1", "1"}), areaId());
sendServerMessage("Testimony has been stopped.");
}
@ -201,8 +201,8 @@ void AOClient::cmdAddStatement(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
if (server->getAreaById(m_current_area)->statement() < ConfigManager::maxStatements()) {
server->getAreaById(m_current_area)->setTestimonyRecording(AreaData::TestimonyRecording::ADD);
if (server->getAreaById(areaId())->statement() < ConfigManager::maxStatements()) {
server->getAreaById(areaId())->setTestimonyRecording(AreaData::TestimonyRecording::ADD);
sendServerMessage("The next IC-Message will be inserted into the testimony.");
}
else
@ -221,7 +221,7 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
l_permission_found = true;
if (l_permission_found) {
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->testimony().size() - 1 <= 0) {
sendServerMessage("Can't save an empty testimony.");
return;
@ -259,7 +259,7 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
QDir l_dir_testimony("storage/testimony");
if (!l_dir_testimony.exists()) {
sendServerMessage("Unable to load testimonies. Testimony storage not found.");

View File

@ -15,12 +15,12 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for functions used by various commands, defined in the command helper function category in aoclient.h
// Be sure to register the command in the header before adding it here!
@ -54,16 +54,16 @@ QStringList AOClient::buildAreaList(int area_idx)
entries.append("[" + QString::number(area->playerCount()) + " users][" + QVariant::fromValue(area->status()).toString().replace("_", "-") + "]");
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == area_idx && l_client->hasJoined()) {
QString char_entry = "[" + QString::number(l_client->m_id) + "] " + l_client->m_current_char;
if (l_client->m_current_char == "")
if (l_client->areaId() == area_idx && l_client->hasJoined()) {
QString char_entry = "[" + QString::number(l_client->clientId()) + "] " + l_client->character();
if (l_client->character() == "")
char_entry += "Spectator";
if (l_client->m_showname != "")
char_entry += " (" + l_client->m_showname + ")";
if (area->owners().contains(l_client->m_id))
if (l_client->characterName() != "")
char_entry += " (" + l_client->characterName() + ")";
if (area->owners().contains(l_client->clientId()))
char_entry.insert(0, "[CM] ");
if (m_authenticated)
char_entry += " (" + l_client->getIpid() + "): " + l_client->m_ooc_name;
char_entry += " (" + l_client->getIpid() + "): " + l_client->name();
if (l_client->m_is_afk)
char_entry += " [AFK]";
entries.append(char_entry);
@ -103,9 +103,9 @@ void AOClient::diceThrower(int sides, int dice, bool p_roll, int roll_modifier)
return;
}
if (roll_modifier)
sendServerMessageArea(m_ooc_name + " rolled a " + QString::number(dice) + "d" + QString::number(sides) + "+" + QString::number(roll_modifier) + ". Results: " + total_results);
sendServerMessageArea(name() + " rolled a " + QString::number(dice) + "d" + QString::number(sides) + "+" + QString::number(roll_modifier) + ". Results: " + total_results);
else
sendServerMessageArea(m_ooc_name + " rolled a " + QString::number(dice) + "d" + QString::number(sides) + ". Results: " + total_results);
sendServerMessageArea(name() + " rolled a " + QString::number(dice) + "d" + QString::number(sides) + ". Results: " + total_results);
}
QString AOClient::getAreaTimer(int area_idx, int timer_idx)
@ -232,5 +232,5 @@ void AOClient::sendNotice(QString f_notice, bool f_global)
if (f_global)
server->broadcast(l_packet);
else
server->broadcast(l_packet, m_current_area);
server->broadcast(l_packet, areaId());
}

View File

@ -15,11 +15,11 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for commands under the messaging category in aoclient.h
// Be sure to register the command in the header before adding it here!
@ -29,7 +29,7 @@ void AOClient::cmdPos(int argc, QStringList argv)
Q_UNUSED(argc);
changePosition(argv[0]);
updateEvidenceList(server->getAreaById(m_current_area));
updateEvidenceList(server->getAreaById(areaId()));
}
void AOClient::cmdForcePos(int argc, QStringList argv)
@ -57,7 +57,7 @@ void AOClient::cmdForcePos(int argc, QStringList argv)
else if (argv[1] == "*") { // force all clients in the area
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area)
if (l_client->areaId() == areaId())
l_targets.append(l_client);
}
}
@ -73,8 +73,8 @@ void AOClient::cmdG(int argc, QStringList argv)
{
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_name = name();
QString l_sender_area = server->getAreaName(areaId());
QString l_sender_message = argv.join(" ");
// Better readability thanks to AwesomeAim.
AOPacket *l_mod_packet = PacketFactory::createPacket("CT", {"[G][" + m_ipid + "][" + l_sender_area + "]" + l_sender_name, l_sender_message});
@ -87,7 +87,7 @@ void AOClient::cmdNeed(int argc, QStringList argv)
{
Q_UNUSED(argc);
QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_area = server->getAreaName(areaId());
QString l_sender_message = argv.join(" ");
server->broadcast(PacketFactory::createPacket("CT", {"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message + "."}), Server::TARGET_TYPE::ADVERT);
}
@ -114,7 +114,7 @@ void AOClient::cmdRandomChar(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
int l_selected_char_id;
bool l_taken = true;
while (l_taken) {
@ -158,7 +158,7 @@ void AOClient::cmdPM(int argc, QStringList argv)
return;
}
QString l_message = argv.join(" "); //...which means it will not end up as part of the message
l_target_client->sendServerMessage("Message from " + m_ooc_name + " (" + QString::number(m_id) + "): " + l_message);
l_target_client->sendServerMessage("Message from " + name() + " (" + QString::number(clientId()) + "): " + l_message);
sendServerMessage("PM sent to " + QString::number(l_target_id) + ". Message: " + l_message);
}
@ -173,7 +173,7 @@ void AOClient::cmdM(int argc, QStringList argv)
{
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QString l_sender_message = argv.join(" ");
server->broadcast(PacketFactory::createPacket("CT", {"[M]" + l_sender_name, l_sender_message}), Server::TARGET_TYPE::MODCHAT);
}
@ -182,8 +182,8 @@ void AOClient::cmdGM(int argc, QStringList argv)
{
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
QString l_sender_area = server->getAreaName(m_current_area);
QString l_sender_name = name();
QString l_sender_area = server->getAreaName(areaId());
QString l_sender_message = argv.join(" ");
server->broadcast(PacketFactory::createPacket("CT", {"[G][" + l_sender_area + "]" + "[" + l_sender_name + "][M]", l_sender_message}), Server::TARGET_TYPE::MODCHAT);
}
@ -192,9 +192,9 @@ void AOClient::cmdLM(int argc, QStringList argv)
{
Q_UNUSED(argc);
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QString l_sender_message = argv.join(" ");
server->broadcast(PacketFactory::createPacket("CT", {"[" + l_sender_name + "][M]", l_sender_message}), m_current_area);
server->broadcast(PacketFactory::createPacket("CT", {"[" + l_sender_name + "][M]", l_sender_message}), areaId());
}
void AOClient::cmdGimp(int argc, QStringList argv)
@ -410,7 +410,7 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
}
if (argc == 1) {
l_target->m_charcurse_list.append(server->getCharID(l_target->m_current_char));
l_target->m_charcurse_list.append(server->getCharID(l_target->character()));
}
else {
argv.removeFirst();
@ -430,13 +430,13 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
l_target->m_is_charcursed = true;
// Kick back to char select screen
if (!l_target->m_charcurse_list.contains(server->getCharID(l_target->m_current_char))) {
if (!l_target->m_charcurse_list.contains(server->getCharID(l_target->character()))) {
l_target->changeCharacter(-1);
server->updateCharsTaken(server->getAreaById(m_current_area));
server->updateCharsTaken(server->getAreaById(areaId()));
l_target->sendPacket("DONE");
}
else {
server->updateCharsTaken(server->getAreaById(m_current_area));
server->updateCharsTaken(server->getAreaById(areaId()));
}
l_target->sendServerMessage("You have been charcursed!");
@ -467,7 +467,7 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv)
}
l_target->m_is_charcursed = false;
l_target->m_charcurse_list.clear();
server->updateCharsTaken(server->getAreaById(m_current_area));
server->updateCharsTaken(server->getAreaById(areaId()));
sendServerMessage("Uncharcursed player.");
l_target->sendServerMessage("You were uncharcursed.");
}
@ -516,13 +516,13 @@ void AOClient::cmdA(int argc, QStringList argv)
}
AreaData *l_area = server->getAreaById(l_area_id);
if (!l_area->owners().contains(m_id)) {
if (!l_area->owners().contains(clientId())) {
sendServerMessage("You are not CM in that area.");
return;
}
argv.removeAt(0);
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QString l_ooc_message = argv.join(" ");
server->broadcast(PacketFactory::createPacket("CT", {"[CM]" + l_sender_name, l_ooc_message}), l_area_id);
}
@ -532,11 +532,11 @@ void AOClient::cmdS(int argc, QStringList argv)
Q_UNUSED(argc);
int l_all_areas = server->getAreaCount() - 1;
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QString l_ooc_message = argv.join(" ");
for (int i = 0; i <= l_all_areas; i++) {
if (server->getAreaById(i)->owners().contains(m_id))
if (server->getAreaById(i)->owners().contains(clientId()))
server->broadcast(PacketFactory::createPacket("CT", {"[CM]" + l_sender_name, l_ooc_message}), i);
}
}

View File

@ -15,13 +15,13 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/command_extension.h"
#include "include/config_manager.h"
#include "include/db_manager.h"
#include "include/server.h"
#include "area_data.h"
#include "command_extension.h"
#include "config_manager.h"
#include "db_manager.h"
#include "server.h"
// This file is for commands under the moderation category in aoclient.h
// Be sure to register the command in the header before adding it here!
@ -146,10 +146,10 @@ void AOClient::cmdMods(int argc, QStringList argv)
l_entries << "Moderator: " + l_client->m_moderator_name;
l_entries << "Role:" << l_client->m_acl_role_id;
}
l_entries << "OOC name: " + l_client->m_ooc_name;
l_entries << "ID: " + QString::number(l_client->m_id);
l_entries << "Area: " + QString::number(l_client->m_current_area);
l_entries << "Character: " + l_client->m_current_char;
l_entries << "OOC name: " + l_client->name();
l_entries << "ID: " + QString::number(l_client->clientId());
l_entries << "Area: " + QString::number(l_client->areaId());
l_entries << "Character: " + l_client->character();
l_online_count++;
}
}
@ -441,8 +441,8 @@ void AOClient::cmdAllowBlankposting(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
AreaData *l_area = server->getAreaById(m_current_area);
QString l_sender_name = name();
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleBlankposting();
if (l_area->blankpostingAllowed() == false) {
sendServerMessageArea(l_sender_name + " has set blankposting in the area to forbidden.");
@ -508,7 +508,7 @@ void AOClient::cmdForceImmediate(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleImmediate();
QString l_state = l_area->forceImmediate() ? "on." : "off.";
sendServerMessage("Forced immediate text processing in this area is now " + l_state);
@ -519,7 +519,7 @@ void AOClient::cmdAllowIniswap(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleIniswap();
QString state = l_area->iniswapAllowed() ? "allowed." : "disallowed.";
sendServerMessage("Iniswapping in this area is now " + state);
@ -535,7 +535,7 @@ void AOClient::cmdPermitSaving(int argc, QStringList argv)
return;
}
l_client->m_testimony_saving = true;
sendServerMessage("Testimony saving has been enabled for client " + QString::number(l_client->m_id));
sendServerMessage("Testimony saving has been enabled for client " + QString::number(l_client->clientId()));
}
void AOClient::cmdKickUid(int argc, QStringList argv)
@ -623,7 +623,7 @@ void AOClient::cmdClearCM(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
foreach (int l_client_id, l_area->owners()) {
l_area->removeOwner(l_client_id);
}

View File

@ -15,12 +15,12 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/music_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "music_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for commands under the music category in aoclient.h
// Be sure to register the command in the header before adding it here!
@ -33,21 +33,21 @@ void AOClient::cmdPlay(int argc, QStringList argv)
sendServerMessage("You are blocked from changing the music.");
return;
}
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
const ACLRole l_role = server->getACLRolesHandler()->getRoleById(m_acl_role_id);
if (!l_area->owners().contains(m_id) && !l_area->isPlayEnabled() && !l_role.checkPermission(ACLRole::CM)) { // Make sure we have permission to play music
if (!l_area->owners().contains(clientId()) && !l_area->isPlayEnabled() && !l_role.checkPermission(ACLRole::CM)) { // Make sure we have permission to play music
sendServerMessage("Free music play is disabled in this area.");
return;
}
QString l_song = argv.join(" ");
if (m_showname.isEmpty()) {
l_area->changeMusic(m_current_char, l_song);
if (characterName().isEmpty()) {
l_area->changeMusic(character(), l_song);
}
else {
l_area->changeMusic(m_showname, l_song);
l_area->changeMusic(characterName(), l_song);
}
AOPacket *music_change = PacketFactory::createPacket("MC", {l_song, QString::number(server->getCharID(m_current_char)), m_showname, "1", "0"});
server->broadcast(music_change, m_current_area);
AOPacket *music_change = PacketFactory::createPacket("MC", {l_song, QString::number(server->getCharID(character())), characterName(), "1", "0"});
server->broadcast(music_change, areaId());
}
void AOClient::cmdPlayAmbience(int argc, QStringList argv)
@ -58,15 +58,15 @@ void AOClient::cmdPlayAmbience(int argc, QStringList argv)
sendServerMessage("You are blocked from changing the ambience.");
return;
}
AreaData *l_area = server->getAreaById(m_current_area);
if (!l_area->owners().contains(m_id) && !l_area->isPlayEnabled()) { // Make sure we have permission to play music
AreaData *l_area = server->getAreaById(areaId());
if (!l_area->owners().contains(clientId()) && !l_area->isPlayEnabled()) { // Make sure we have permission to play music
sendServerMessage("Free ambience play is disabled in this area.");
return;
}
QString l_song = argv.join(" ");
l_area->changeAmbience(l_song);
AOPacket *music_change = PacketFactory::createPacket("MC", {l_song, "-1", m_showname, "1", "1"});
server->broadcast(music_change, m_current_area);
AOPacket *music_change = PacketFactory::createPacket("MC", {l_song, "-1", characterName(), "1", "1"});
server->broadcast(music_change, areaId());
}
void AOClient::cmdCurrentMusic(int argc, QStringList argv)
@ -74,7 +74,7 @@ void AOClient::cmdCurrentMusic(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (!l_area->currentMusic().isEmpty() && !l_area->currentMusic().contains("~stop.mp3")) // dummy track for stopping music
sendServerMessage("The current song is " + l_area->currentMusic() + " played by " + l_area->musicPlayerBy());
else
@ -140,7 +140,7 @@ void AOClient::cmdToggleMusic(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleMusic();
QString l_state = l_area->isMusicAllowed() ? "allowed." : "disallowed.";
sendServerMessage("Music in this area is now " + l_state);
@ -151,7 +151,7 @@ void AOClient::cmdToggleJukebox(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
l_area->toggleJukebox();
QString l_state = l_area->isjukeboxEnabled() ? "enabled." : "disabled.";
sendServerMessageArea("The jukebox in this area has been " + l_state);
@ -172,13 +172,13 @@ void AOClient::cmdAddSong(int argc, QStringList argv)
bool l_success = false;
if (l_argv.size() == 1) {
QString l_song_name = l_argv.value(0);
l_success = m_music_manager->addCustomSong(l_song_name, l_song_name, 0, m_current_area);
l_success = m_music_manager->addCustomSong(l_song_name, l_song_name, 0, areaId());
}
if (l_argv.size() == 2) {
QString l_song_name = l_argv.value(0);
QString l_true_name = l_argv.value(1);
l_success = m_music_manager->addCustomSong(l_song_name, l_true_name, 0, m_current_area);
l_success = m_music_manager->addCustomSong(l_song_name, l_true_name, 0, areaId());
}
if (l_argv.size() == 3) {
@ -188,7 +188,7 @@ void AOClient::cmdAddSong(int argc, QStringList argv)
int l_song_duration = l_argv.value(2).toInt(&ok);
if (!ok)
l_song_duration = 0;
l_success = m_music_manager->addCustomSong(l_song_name, l_true_name, l_song_duration, m_current_area);
l_success = m_music_manager->addCustomSong(l_song_name, l_true_name, l_song_duration, areaId());
}
if (l_argv.size() >= 4) {
@ -203,7 +203,7 @@ void AOClient::cmdAddSong(int argc, QStringList argv)
void AOClient::cmdAddCategory(int argc, QStringList argv)
{
Q_UNUSED(argc);
bool l_success = m_music_manager->addCustomCategory(argv.join(" "), m_current_area);
bool l_success = m_music_manager->addCustomCategory(argv.join(" "), areaId());
QString l_message = l_success ? "succeeded." : "failed.";
sendServerMessage("The addition of the category has " + l_message);
}
@ -211,7 +211,7 @@ void AOClient::cmdAddCategory(int argc, QStringList argv)
void AOClient::cmdRemoveCategorySong(int argc, QStringList argv)
{
Q_UNUSED(argc);
bool l_success = m_music_manager->removeCategorySong(argv.join(" "), m_current_area);
bool l_success = m_music_manager->removeCategorySong(argv.join(" "), areaId());
QString l_message = l_success ? "succeeded." : "failed.";
sendServerMessage("The removal of the entry has " + l_message);
}
@ -220,7 +220,7 @@ void AOClient::cmdToggleRootlist(int argc, QStringList argv)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
bool l_status = m_music_manager->toggleRootEnabled(m_current_area);
bool l_status = m_music_manager->toggleRootEnabled(areaId());
QString l_message = (l_status) ? "enabled." : "disabled.";
sendServerMessage("Global musiclist has been " + l_message);
}
@ -229,7 +229,7 @@ void AOClient::cmdClearCustom(int argc, QStringList argv)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
m_music_manager->clearCustomList(m_current_area);
m_music_manager->clearCustomList(areaId());
sendServerMessage("Custom songs have been cleared.");
}
@ -238,12 +238,12 @@ void AOClient::cmdJukeboxSkip(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
QString l_name = m_current_char;
if (!m_showname.isEmpty()) {
l_name = m_showname;
QString l_name = character();
if (!characterName().isEmpty()) {
l_name = characterName();
}
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
if (l_area->isjukeboxEnabled()) {
if (l_area->getJukeboxQueueSize() >= 1) {

View File

@ -15,12 +15,12 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "area_data.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
// This file is for commands under the roleplay category in aoclient.h
// Be sure to register the command in the header before adding it here!
@ -30,7 +30,7 @@ void AOClient::cmdFlip(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QStringList l_faces = {"heads", "tails"};
QString l_face = l_faces[AOClient::genRand(0, 1)];
sendServerMessageArea(l_sender_name + " flipped a coin and got " + l_face + ".");
@ -150,7 +150,7 @@ void AOClient::cmdRollP(int argc, QStringList argv)
void AOClient::cmdTimer(int argc, QStringList argv)
{
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
// Called without arguments
// Shows a brief of all timers
@ -207,8 +207,8 @@ void AOClient::cmdTimer(int argc, QStringList argv)
l_requested_timer->start();
sendServerMessage("Set timer " + QString::number(l_timer_id) + " to " + argv[1] + ".");
AOPacket *l_update_timer = PacketFactory::createPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(l_requested_time))});
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area); // Show the timer
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, areaId()); // Show the timer
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, areaId());
return;
}
// Otherwise, update the state of the timer
@ -217,22 +217,22 @@ void AOClient::cmdTimer(int argc, QStringList argv)
l_requested_timer->start();
sendServerMessage("Started timer " + QString::number(l_timer_id) + ".");
AOPacket *l_update_timer = PacketFactory::createPacket("TI", {QString::number(l_timer_id), "0", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_requested_timer->remainingTime())))});
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, m_current_area);
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
l_is_global ? server->broadcast(l_show_timer) : server->broadcast(l_show_timer, areaId());
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, areaId());
}
else if (argv[1] == "pause" || argv[1] == "stop") {
l_requested_timer->setInterval(l_requested_timer->remainingTime());
l_requested_timer->stop();
sendServerMessage("Stopped timer " + QString::number(l_timer_id) + ".");
AOPacket *l_update_timer = PacketFactory::createPacket("TI", {QString::number(l_timer_id), "1", QString::number(QTime(0, 0).msecsTo(QTime(0, 0).addMSecs(l_requested_timer->interval())))});
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, m_current_area);
l_is_global ? server->broadcast(l_update_timer) : server->broadcast(l_update_timer, areaId());
}
else if (argv[1] == "hide" || argv[1] == "unset") {
l_requested_timer->setInterval(0);
l_requested_timer->stop();
sendServerMessage("Hid timer " + QString::number(l_timer_id) + ".");
// Hide the timer
l_is_global ? server->broadcast(l_hide_timer) : server->broadcast(l_hide_timer, m_current_area);
l_is_global ? server->broadcast(l_hide_timer) : server->broadcast(l_hide_timer, areaId());
}
}
}
@ -241,10 +241,10 @@ void AOClient::cmdNoteCard(int argc, QStringList argv)
{
Q_UNUSED(argc);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
QString l_notecard = argv.join(" ");
l_area->addNotecard(m_current_char, l_notecard);
sendServerMessageArea(m_current_char + " wrote a note card.");
l_area->addNotecard(character(), l_notecard);
sendServerMessageArea(character() + " wrote a note card.");
}
void AOClient::cmdNoteCardClear(int argc, QStringList argv)
@ -252,9 +252,9 @@ void AOClient::cmdNoteCardClear(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
if (!l_area->addNotecard(m_current_char, QString())) {
sendServerMessageArea(m_current_char + " erased their note card.");
AreaData *l_area = server->getAreaById(areaId());
if (!l_area->addNotecard(character(), QString())) {
sendServerMessageArea(character() + " erased their note card.");
}
}
@ -263,7 +263,7 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv)
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData *l_area = server->getAreaById(m_current_area);
AreaData *l_area = server->getAreaById(areaId());
const QStringList l_notecards = l_area->getNotecards();
if (l_notecards.isEmpty()) {
@ -287,7 +287,7 @@ void AOClient::cmd8Ball(int argc, QStringList argv)
}
else {
QString l_response = ConfigManager::magic8BallAnswers().at((genRand(1, ConfigManager::magic8BallAnswers().size() - 1)));
QString l_sender_name = m_ooc_name;
QString l_sender_name = name();
QString l_sender_message = argv.join(" ");
sendServerMessageArea(l_sender_name + " asked the magic 8-ball, \"" + l_sender_message + "\" and the answer is: " + l_response);
@ -301,7 +301,7 @@ void AOClient::cmdSubTheme(int argc, QStringList argv)
QString l_subtheme = argv.join(" ");
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area)
if (l_client->areaId() == areaId())
l_client->sendPacket("ST", {l_subtheme, "1"});
}
sendServerMessageArea("Subtheme was set to " + l_subtheme);

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/config_manager.h"
#include "config_manager.h"
#include <QSqlDatabase>
#include <QSqlQuery>

View File

@ -35,8 +35,8 @@
#include <QJsonDocument>
#include <QJsonObject>
#include "include/data_types.h"
#include "include/typedefs.h"
#include "data_types.h"
#include "typedefs.h"
/**
* @brief The config file handler class.

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/db_manager.h"
#include "db_manager.h"
DBManager::DBManager() :
DRIVER("QSQLITE")

View File

@ -28,8 +28,8 @@
#include <QSqlError>
#include <QSqlQuery>
#include "include/acl_roles_handler.h"
#include "include/crypto_helper.h"
#include "acl_roles_handler.h"
#include "crypto_helper.h"
/**
* @brief A class used to handle database interaction.

View File

@ -15,9 +15,9 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/discord.h"
#include "discord.h"
#include "include/config_manager.h"
#include "config_manager.h"
Discord::Discord(QObject *parent) :
QObject(parent)

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/u_logger.h"
#include "logger/u_logger.h"
ULogger::ULogger(QObject *parent) :
QObject(parent)

View File

@ -18,9 +18,9 @@
#ifndef U_LOGGER_H
#define U_LOGGER_H
#include "include/config_manager.h"
#include "include/logger/writer_full.h"
#include "include/logger/writer_modcall.h"
#include "config_manager.h"
#include "logger/writer_full.h"
#include "logger/writer_modcall.h"
#include <QDateTime>
#include <QMap>
#include <QObject>

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/writer_full.h"
#include "logger/writer_full.h"
WriterFull::WriterFull(QObject *parent) :
QObject(parent)

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/logger/writer_modcall.h"
#include "logger/writer_modcall.h"
WriterModcall::WriterModcall(QObject *parent) :
QObject(parent)

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include <include/config_manager.h>
#include <include/server.h>
#include "config_manager.h"
#include "server.h"
#include <cstdlib>

View File

@ -1,7 +1,7 @@
#include "include/music_manager.h"
#include "music_manager.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
MusicManager::MusicManager(QStringList f_cdns, MusicList f_root_list, QStringList f_root_ordered, QObject *parent) :
QObject(parent),

View File

@ -23,8 +23,8 @@
#include <QObject>
#include <QPair>
#include "include/network/aopacket.h"
#include "include/typedefs.h"
#include "network/aopacket.h"
#include "typedefs.h"
class ConfigManager;

View File

@ -15,29 +15,30 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/network/aopacket.h"
#include "network/aopacket.h"
#include "include/packet/packet_askchaa.h"
#include "include/packet/packet_casea.h"
#include "include/packet/packet_cc.h"
#include "include/packet/packet_ch.h"
#include "include/packet/packet_ct.h"
#include "include/packet/packet_de.h"
#include "include/packet/packet_ee.h"
#include "include/packet/packet_factory.h"
#include "include/packet/packet_hi.h"
#include "include/packet/packet_hp.h"
#include "include/packet/packet_id.h"
#include "include/packet/packet_mc.h"
#include "include/packet/packet_ms.h"
#include "include/packet/packet_pe.h"
#include "include/packet/packet_pw.h"
#include "include/packet/packet_rc.h"
#include "include/packet/packet_rd.h"
#include "include/packet/packet_rm.h"
#include "include/packet/packet_rt.h"
#include "include/packet/packet_setcase.h"
#include "include/packet/packet_zz.h"
#include "packet/packet_askchaa.h"
#include "packet/packet_casea.h"
#include "packet/packet_cc.h"
#include "packet/packet_ch.h"
#include "packet/packet_ct.h"
#include "packet/packet_de.h"
#include "packet/packet_ee.h"
#include "packet/packet_factory.h"
#include "packet/packet_hi.h"
#include "packet/packet_hp.h"
#include "packet/packet_id.h"
#include "packet/packet_mc.h"
#include "packet/packet_ms.h"
#include "packet/packet_pe.h"
#include "packet/packet_pl.h"
#include "packet/packet_pw.h"
#include "packet/packet_rc.h"
#include "packet/packet_rd.h"
#include "packet/packet_rm.h"
#include "packet/packet_rt.h"
#include "packet/packet_setcase.h"
#include "packet/packet_zz.h"
AOPacket::AOPacket(QStringList p_contents) :
m_content(p_contents),
@ -132,4 +133,7 @@ void AOPacket::registerPackets()
PacketFactory::registerClass<PacketRT>("RT");
PacketFactory::registerClass<PacketSetcase>("SETCASE");
PacketFactory::registerClass<PacketZZ>("ZZ");
PacketFactory::registerClass<PacketPL>("PL");
PacketFactory::registerClass<PacketPLU>("PLU");
PacketFactory::registerClass<PacketPU>("PU");
}

View File

@ -23,9 +23,9 @@
#include <QString>
#include <QStringList>
#include "include/aoclient.h"
#include "include/area_data.h"
#include "include/packet/packet_info.h"
#include "aoclient.h"
#include "area_data.h"
#include "packet/packet_info.h"
class AOClient;
@ -113,7 +113,6 @@ class AOPacket
virtual PacketInfo getPacketInfo() const = 0;
virtual void handlePacket(AreaData *area, AOClient &client) const = 0;
virtual bool validatePacket() const = 0;
static void registerPackets();

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/network/network_socket.h"
#include "include/packet/packet_factory.h"
#include "network/network_socket.h"
#include "packet/packet_factory.h"
NetworkSocket::NetworkSocket(QTcpSocket *f_socket, QObject *parent) :
QObject(parent)

View File

@ -23,7 +23,7 @@
#include <QTcpSocket>
#include <QWebSocket>
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class AOPacket;

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_askchaa.h"
#include "include/config_manager.h"
#include "include/server.h"
#include "packet/packet_askchaa.h"
#include "config_manager.h"
#include "server.h"
#include <QDebug>
@ -26,11 +26,3 @@ void PacketAskchaa::handlePacket(AreaData *area, AOClient &client) const
// Client only cares about what it gets from LE
client.sendPacket("SI", {QString::number(client.getServer()->getCharacterCount()), "0", QString::number(client.getServer()->getAreaCount() + client.getServer()->getMusicList().length())});
}
bool PacketAskchaa::validatePacket() const
{
if (m_content.size() > 0) { // Too many arguments.
return false;
}
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_ASKCHAA_H
#define PACKET_ASKCHAA_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketAskchaa : public AOPacket
{
@ -9,6 +9,5 @@ class PacketAskchaa : public AOPacket
PacketAskchaa(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_casea.h"
#include "include/akashiutils.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_casea.h"
#include "akashiutils.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -41,7 +41,7 @@ void PacketCasea::handlePacket(AreaData *area, AOClient &client) const
if (l_needed_roles.isEmpty())
return;
QString l_message = "=== Case Announcement ===\r\n" + (client.m_ooc_name == "" ? client.m_current_char : client.m_ooc_name) + " needs " + l_needed_roles.join(", ") + " for " + (l_case_title == "" ? "a case" : l_case_title) + "!";
QString l_message = "=== Case Announcement ===\r\n" + (client.name() == "" ? client.character() : client.name()) + " needs " + l_needed_roles.join(", ") + " for " + (l_case_title == "" ? "a case" : l_case_title) + "!";
QList<AOClient *> l_clients_to_alert;
// here lies morton, RIP
@ -70,13 +70,3 @@ void PacketCasea::handlePacket(AreaData *area, AOClient &client) const
// at least 7 arguments despite only using the first 6. Cera, i kneel. you have truly broken me.
}
}
bool PacketCasea::validatePacket() const
{
for (int i = 1; i < m_content.size(); i++) {
if (!AkashiUtils::checkArgType<int>(m_content.at(i))) {
return false;
}
}
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_CASEA_H
#define PACKET_CASEA_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketCasea : public AOPacket
{
@ -9,6 +9,5 @@ class PacketCasea : public AOPacket
PacketCasea(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_cc.h"
#include "include/akashiutils.h"
#include "include/config_manager.h"
#include "include/server.h"
#include "packet/packet_cc.h"
#include "akashiutils.h"
#include "config_manager.h"
#include "server.h"
#include <QDebug>
@ -46,8 +46,3 @@ void PacketCC::handlePacket(AreaData *area, AOClient &client) const
client.setSpectator(false);
}
}
bool PacketCC::validatePacket() const
{
return AkashiUtils::checkArgType<int>(m_content.at(1));
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_CC_H
#define PACKET_CC_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketCC : public AOPacket
{
@ -9,6 +9,5 @@ class PacketCC : public AOPacket
PacketCC(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_ch.h"
#include "include/akashiutils.h"
#include "include/server.h"
#include "packet/packet_ch.h"
#include "akashiutils.h"
#include "server.h"
#include <QDebug>
@ -26,8 +26,3 @@ void PacketCH::handlePacket(AreaData *area, AOClient &client) const
// It is now used for ping measurement
client.sendPacket("CHECK");
}
bool PacketCH::validatePacket() const
{
return AkashiUtils::checkArgType<int>(m_content.at(0));
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_CH_H
#define PACKET_CH_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketCH : public AOPacket
{
@ -9,6 +9,5 @@ class PacketCH : public AOPacket
PacketCH(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,8 +1,8 @@
#include "include/packet/packet_ct.h"
#include "include/akashidefs.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_ct.h"
#include "akashidefs.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -27,11 +27,11 @@ void PacketCT::handlePacket(AreaData *area, AOClient &client) const
return;
}
client.m_ooc_name = client.dezalgo(m_content[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here
if (client.m_ooc_name.isEmpty() || client.m_ooc_name == ConfigManager::serverName()) // impersonation & empty name protection
client.setName(client.dezalgo(m_content[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), "")); // no fucky wucky shit here
if (client.name().isEmpty() || client.name() == ConfigManager::serverName()) // impersonation & empty name protection
return;
if (client.m_ooc_name.length() > 30) {
if (client.name().length() > 30) {
client.sendServerMessage("Your name is too long! Please limit it to under 30 characters.");
return;
}
@ -44,7 +44,7 @@ void PacketCT::handlePacket(AreaData *area, AOClient &client) const
QString l_message = client.dezalgo(m_content[1]);
if (l_message.length() == 0 || l_message.length() > ConfigManager::maxCharacters())
return;
AOPacket *final_packet = PacketFactory::createPacket("CT", {client.m_ooc_name, l_message, "0"});
AOPacket *final_packet = PacketFactory::createPacket("CT", {client.name(), l_message, "0"});
if (l_message.at(0) == '/') {
QStringList l_cmd_argv = l_message.split(" ", akashi::SkipEmptyParts);
QString l_command = l_cmd_argv[0].trimmed().toLower();
@ -53,17 +53,11 @@ void PacketCT::handlePacket(AreaData *area, AOClient &client) const
int l_cmd_argc = l_cmd_argv.length();
client.handleCommand(l_command, l_cmd_argc, l_cmd_argv);
emit client.logCMD((client.m_current_char + " " + client.m_showname), client.m_ipid, client.m_ooc_name, l_command, l_cmd_argv, client.getServer()->getAreaById(client.m_current_area)->name());
emit client.logCMD((client.character() + " " + client.characterName()), client.m_ipid, client.name(), l_command, l_cmd_argv, client.getServer()->getAreaById(client.areaId())->name());
return;
}
else {
client.getServer()->broadcast(final_packet, client.m_current_area);
client.getServer()->broadcast(final_packet, client.areaId());
}
emit client.logOOC((client.m_current_char + " " + client.m_showname), client.m_ooc_name, client.m_ipid, area->name(), l_message);
}
bool PacketCT::validatePacket() const
{
// Nothing to validate.
return true;
emit client.logOOC((client.character() + " " + client.characterName()), client.name(), client.m_ipid, area->name(), l_message);
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_CT_H
#define PACKET_CT_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketCT : public AOPacket
{
@ -9,6 +9,5 @@ class PacketCT : public AOPacket
PacketCT(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_de.h"
#include "include/akashiutils.h"
#include "include/server.h"
#include "packet/packet_de.h"
#include "akashiutils.h"
#include "server.h"
#include <QDebug>
@ -29,8 +29,3 @@ void PacketDE::handlePacket(AreaData *area, AOClient &client) const
}
client.sendEvidenceList(area);
}
bool PacketDE::validatePacket() const
{
return AkashiUtils::checkArgType<int>(m_content.at(0));
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_DE_H
#define PACKET_DE_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketDE : public AOPacket
{
@ -9,6 +9,5 @@ class PacketDE : public AOPacket
PacketDE(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_ee.h"
#include "include/akashiutils.h"
#include "include/server.h"
#include "packet/packet_ee.h"
#include "akashiutils.h"
#include "server.h"
#include <QDebug>
@ -30,8 +30,3 @@ void PacketEE::handlePacket(AreaData *area, AOClient &client) const
}
client.sendEvidenceList(area);
}
bool PacketEE::validatePacket() const
{
return AkashiUtils::checkArgType<int>(m_content.at(0));
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_EE_H
#define PACKET_EE_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketEE : public AOPacket
{
@ -9,6 +9,5 @@ class PacketEE : public AOPacket
PacketEE(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_factory.h"
#include "include/packet/packet_generic.h"
#include "packet/packet_factory.h"
#include "packet/packet_generic.h"
AOPacket *PacketFactory::createPacket(QString header, QStringList contents)
{
@ -21,7 +21,7 @@ AOPacket *PacketFactory::createPacket(QString raw_packet)
}
if (raw_packet.at(0) == '#' || raw_packet.contains("%")) {
qDebug() << "FantaCrypt or otherwise invalid packet received";
qDebug() << "FantaCrypt or otherwise invalid packet received:" << raw_packet;
return PacketFactory::createPacket("Unknown", {"Unknown"});
}

View File

@ -1,4 +1,4 @@
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketFactory
{

View File

@ -1,4 +1,4 @@
#include "include/packet/packet_generic.h"
#include "packet/packet_generic.h"
#include <QDebug>
@ -24,8 +24,3 @@ void PacketGeneric::handlePacket(AreaData *area, AOClient &client) const
qDebug() << "ERROR: Cannot handle generic packet: " << header;
qDebug() << "Packet is either unimplemented, or is meant to be sent to client";
}
bool PacketGeneric::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_GENERIC_H
#define PACKET_GENERIC_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketGeneric : public AOPacket
{
@ -9,7 +9,6 @@ class PacketGeneric : public AOPacket
PacketGeneric(QString header, QStringList contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
private:
QString header;

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_hi.h"
#include "include/akashiutils.h"
#include "include/db_manager.h"
#include "include/server.h"
#include "packet/packet_hi.h"
#include "akashiutils.h"
#include "db_manager.h"
#include "server.h"
#include <QDebug>
@ -47,11 +47,5 @@ void PacketHI::handlePacket(AreaData *area, AOClient &client) const
return;
}
client.sendPacket("ID", {QString::number(client.m_id), "akashi", QCoreApplication::applicationVersion()});
}
bool PacketHI::validatePacket() const
{
// We can always convert a string to a string. No point in checking.
return true;
client.sendPacket("ID", {QString::number(client.clientId()), "akashi", QCoreApplication::applicationVersion()});
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_HI_H
#define PACKET_HI_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketHI : public AOPacket
{
@ -9,7 +9,6 @@ class PacketHI : public AOPacket
PacketHI(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
private:
QString header;

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_hp.h"
#include "include/akashiutils.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_hp.h"
#include "akashiutils.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -39,12 +39,3 @@ void PacketHP::handlePacket(AreaData *area, AOClient &client) const
client.updateJudgeLog(area, &client, "updated the penalties");
}
bool PacketHP::validatePacket() const
{
if (!AkashiUtils::checkArgType<int>(m_content.at(0)))
return false;
if (!AkashiUtils::checkArgType<int>(m_content.at(1)))
return false;
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_HP_H
#define PACKET_HP_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketHP : public AOPacket
{
@ -9,6 +9,5 @@ class PacketHP : public AOPacket
PacketHP(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_id.h"
#include "include/config_manager.h"
#include "include/server.h"
#include "packet/packet_id.h"
#include "config_manager.h"
#include "server.h"
#include <QDebug>
@ -69,8 +69,3 @@ void PacketID::handlePacket(AreaData *area, AOClient &client) const
client.sendPacket("ASS", {l_asset_url});
}
}
bool PacketID::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_ID_H
#define PACKET_ID_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketID : public AOPacket
{
@ -9,6 +9,5 @@ class PacketID : public AOPacket
PacketID(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,7 +1,7 @@
#ifndef PACKET_INFO_H
#define PACKET_INFO_H
#include "include/acl_roles_handler.h"
#include "acl_roles_handler.h"
/// Describes a packet's interpretation details.
class PacketInfo

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_mc.h"
#include "include/music_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_mc.h"
#include "music_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -29,7 +29,7 @@ void PacketMC::handlePacket(AreaData *area, AOClient &client) const
// argument is a valid song
QString l_argument = m_content[0];
if (client.getServer()->getMusicList().contains(l_argument) || client.m_music_manager->isCustom(client.m_current_area, l_argument) || l_argument == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
if (client.getServer()->getMusicList().contains(l_argument) || client.m_music_manager->isCustom(client.areaId(), l_argument) || l_argument == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
// We have a song here
if (client.m_is_spectator) {
@ -67,19 +67,19 @@ void PacketMC::handlePacket(AreaData *area, AOClient &client) const
if (l_final_song != "~stop.mp3") {
// We might have an aliased song. We check for its real songname and send it to the clients.
QPair<QString, float> l_song = client.m_music_manager->songInformation(l_final_song, client.m_current_area);
QPair<QString, float> l_song = client.m_music_manager->songInformation(l_final_song, client.areaId());
l_final_song = l_song.first;
}
AOPacket *l_music_change = PacketFactory::createPacket("MC", {l_final_song, m_content[1], client.m_showname, "1", "0", l_effects});
client.getServer()->broadcast(l_music_change, client.m_current_area);
AOPacket *l_music_change = PacketFactory::createPacket("MC", {l_final_song, m_content[1], client.characterName(), "1", "0", l_effects});
client.getServer()->broadcast(l_music_change, client.areaId());
// Since we can't ensure a user has their showname set, we check if its empty to prevent
//"played by ." in /currentmusic.
if (client.m_showname.isEmpty()) {
area->changeMusic(client.m_current_char, l_final_song);
if (client.characterName().isEmpty()) {
area->changeMusic(client.character(), l_final_song);
return;
}
area->changeMusic(client.m_showname, l_final_song);
area->changeMusic(client.characterName(), l_final_song);
return;
}
@ -91,8 +91,3 @@ void PacketMC::handlePacket(AreaData *area, AOClient &client) const
}
}
}
bool PacketMC::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_MC_H
#define PACKET_MC_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketMC : public AOPacket
{
@ -9,6 +9,5 @@ class PacketMC : public AOPacket
PacketMC(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_ms.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_ms.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -37,8 +37,8 @@ void PacketMS::handlePacket(AreaData *area, AOClient &client) const
if (client.m_pos != "")
validated_packet->setContentField(5, client.m_pos);
client.getServer()->broadcast(validated_packet, client.m_current_area);
emit client.logIC((client.m_current_char + " " + client.m_showname), client.m_ooc_name, client.m_ipid, client.getServer()->getAreaById(client.m_current_area)->name(), client.m_last_message);
client.getServer()->broadcast(validated_packet, client.areaId());
emit client.logIC((client.character() + " " + client.characterName()), client.name(), client.m_ipid, client.getServer()->getAreaById(client.areaId())->name(), client.m_last_message);
area->updateLastICMessage(validated_packet->getContent());
area->startMessageFloodguard(ConfigManager::messageFloodguard());
@ -59,11 +59,11 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
AOPacket *l_invalid = PacketFactory::createPacket("INVALID", {});
QStringList l_args;
if (client.isSpectator() || client.m_current_char.isEmpty() || !client.m_joined)
if (client.isSpectator() || client.character().isEmpty() || !client.m_joined)
// Spectators cannot use IC
return l_invalid;
AreaData *area = client.getServer()->getAreaById(client.m_current_area);
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(client.m_id) && !client.checkPermission(ACLRole::BYPASS_LOCKS))
AreaData *area = client.getServer()->getAreaById(client.areaId());
if (area->lockStatus() == AreaData::LockStatus::SPECTATABLE && !area->invited().contains(client.clientId()) && !client.checkPermission(ACLRole::BYPASS_LOCKS))
// Non-invited players cannot speak in spectatable areas
return l_invalid;
@ -100,7 +100,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
l_args.append(l_incoming_args[1].toString());
// char name
if (client.m_current_char.toLower() != l_incoming_args[2].toString().toLower()) {
if (client.character().toLower() != l_incoming_args[2].toString().toLower()) {
// Selected char is different from supplied folder name
// This means the user is INI-swapped
if (!area->iniswapAllowed()) {
@ -166,7 +166,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
if (client.m_pos != l_incoming_args[5].toString()) {
client.m_pos = l_incoming_args[5].toString();
client.m_pos.replace("../", "").replace("..\\", "");
client.updateEvidenceList(client.getServer()->getAreaById(client.m_current_area));
client.updateEvidenceList(client.getServer()->getAreaById(client.areaId()));
}
// sfx name
@ -246,7 +246,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
if (l_incoming_args.length() >= 19) {
// showname
QString l_incoming_showname = client.dezalgo(l_incoming_args[15].toString().trimmed());
if (!(l_incoming_showname == client.m_current_char || l_incoming_showname.isEmpty()) && !area->shownameAllowed()) {
if (!(l_incoming_showname == client.character() || l_incoming_showname.isEmpty()) && !area->shownameAllowed()) {
client.sendServerMessage("Shownames are not allowed in this area!");
return l_invalid;
}
@ -259,7 +259,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
if (l_incoming_showname.isEmpty() && !l_incoming_args[15].toString().isEmpty())
l_incoming_showname = " ";
l_args.append(l_incoming_showname);
client.m_showname = l_incoming_showname;
client.setCharacterName(l_incoming_showname);
// other char id
// things get a bit hairy here
@ -376,9 +376,9 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
}
// Testimony playback
QString client_name = client.m_ooc_name;
QString client_name = client.name();
if (client_name == "") {
client_name = client.m_current_char; // fallback in case of empty ooc name
client_name = client.character(); // fallback in case of empty ooc name
}
if (area->testimonyRecording() == AreaData::TestimonyRecording::RECORDING || area->testimonyRecording() == AreaData::TestimonyRecording::ADD) {
if (!l_args[5].startsWith("wit"))
@ -387,7 +387,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const
if (area->statement() == -1) {
l_args[4] = "~~-- " + l_args[4] + " --";
l_args[14] = "3";
client.getServer()->broadcast(PacketFactory::createPacket("RT", {"testimony1"}), client.m_current_area);
client.getServer()->broadcast(PacketFactory::createPacket("RT", {"testimony1"}), client.areaId());
}
client.addStatement(l_args);
}
@ -463,8 +463,3 @@ QRegularExpressionMatch PacketMS::isTestimonyJumpCommand(QString message) const
QRegularExpression jump("(?<arrow>>)(?<int>[0,1,2,3,4,5,6,7,8,9]+)");
return jump.match(message);
}
bool PacketMS::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_MS_H
#define PACKET_MS_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketMS : public AOPacket
{
@ -9,7 +9,6 @@ class PacketMS : public AOPacket
PacketMS(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
private:
AOPacket *validateIcPacket(AOClient &client) const;

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_pe.h"
#include "include/server.h"
#include "packet/packet_pe.h"
#include "server.h"
#include <QDebug>
@ -25,8 +25,3 @@ void PacketPE::handlePacket(AreaData *area, AOClient &client) const
area->appendEvidence(l_evi);
client.sendEvidenceList(area);
}
bool PacketPE::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_PE_H
#define PACKET_PE_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketPE : public AOPacket
{
@ -9,6 +9,5 @@ class PacketPE : public AOPacket
PacketPE(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

88
src/packet/packet_pl.cpp Normal file
View File

@ -0,0 +1,88 @@
#include "packet_pl.h"
#include <QJsonDocument>
PacketPL::PacketPL(QStringList &contents) :
AOPacket(contents)
{}
PacketPL::PacketPL(const QList<PlayerData> &f_player_list) :
AOPacket(QStringList{""})
{
QJsonArray player_list_json;
for (const PlayerData &player : f_player_list) {
QJsonObject player_json;
player_json["id"] = player.id;
player_json["name"] = player.name;
player_json["character"] = player.character;
player_json["character_name"] = player.character_name;
player_json["area_id"] = player.area_id;
player_list_json.append(player_json);
}
setContentField(0, QJsonDocument(player_list_json).toJson(QJsonDocument::Compact));
}
PacketInfo PacketPL::getPacketInfo() const { return PacketInfo{.acl_permission = ACLRole::NONE, .min_args = 1, .header = "PL"}; }
void PacketPL::handlePacket(AreaData *area, AOClient &client) const
{
Q_UNUSED(area);
Q_UNUSED(client);
}
PacketPLU::PacketPLU(QStringList &contents) :
AOPacket(contents)
{}
PacketPLU::PacketPLU(int f_id, UpdateType f_type) :
AOPacket(QStringList{""})
{
QJsonObject data_json;
data_json["id"] = f_id;
data_json["type"] = f_type;
setContentField(0, QJsonDocument(data_json).toJson(QJsonDocument::Compact));
}
PacketInfo PacketPLU::getPacketInfo() const { return PacketInfo{.acl_permission = ACLRole::NONE, .min_args = 1, .header = "PLU"}; }
void PacketPLU::handlePacket(AreaData *area, AOClient &client) const
{
Q_UNUSED(area);
Q_UNUSED(client);
}
PacketPU::PacketPU(QStringList &contents) :
AOPacket(contents)
{}
PacketPU::PacketPU(int f_id, DataType f_type, const QString &f_data) :
AOPacket(QStringList{""})
{
QJsonObject data_json;
data_json["id"] = f_id;
data_json["type"] = f_type;
data_json["data"] = f_data;
setContentField(0, QJsonDocument(data_json).toJson(QJsonDocument::Compact));
}
PacketPU::PacketPU(int f_id, DataType f_type, int f_data) :
PacketPU(f_id, f_type, QString::number(f_data))
{
}
PacketInfo PacketPU::getPacketInfo() const
{
return PacketInfo{.acl_permission = ACLRole::NONE, .min_args = 1, .header = "PU"};
}
void PacketPU::handlePacket(AreaData *area, AOClient &client) const
{
Q_UNUSED(area);
Q_UNUSED(client);
}

59
src/packet/packet_pl.h Normal file
View File

@ -0,0 +1,59 @@
#pragma once
#include "network/aopacket.h"
#include <QByteArray>
#include <QJsonArray>
#include <QJsonObject>
#include <QList>
class PacketPL : public AOPacket
{
public:
struct PlayerData
{
int id;
QString name;
QString character;
QString character_name;
int area_id = -1;
};
PacketPL(QStringList &contents);
PacketPL(const QList<PlayerData> &f_player_list);
PacketInfo getPacketInfo() const override;
void handlePacket(AreaData *area, AOClient &client) const override;
};
class PacketPLU : public AOPacket
{
public:
enum UpdateType
{
AddPlayerUpdate,
RemovePlayerUpdate,
};
PacketPLU(QStringList &contents);
PacketPLU(int f_id, UpdateType f_type);
PacketInfo getPacketInfo() const override;
void handlePacket(AreaData *area, AOClient &client) const override;
};
class PacketPU : public AOPacket
{
public:
enum DataType
{
NameData,
CharacterData,
CharacterNameData,
AreaIdData,
};
PacketPU(QStringList &contents);
PacketPU(int f_id, DataType f_type, const QString &f_data);
PacketPU(int f_id, DataType f_type, int f_data);
PacketInfo getPacketInfo() const override;
void handlePacket(AreaData *area, AOClient &client) const override;
};

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_pw.h"
#include "include/server.h"
#include "packet/packet_pw.h"
#include "server.h"
#include <QDebug>
@ -23,8 +23,3 @@ void PacketPW::handlePacket(AreaData *area, AOClient &client) const
client.m_password = m_content[0];
}
bool PacketPW::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_PW_H
#define PACKET_PW_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketPW : public AOPacket
{
@ -9,6 +9,5 @@ class PacketPW : public AOPacket
PacketPW(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_rc.h"
#include "include/server.h"
#include "packet/packet_rc.h"
#include "server.h"
#include <QDebug>
@ -23,8 +23,3 @@ void PacketRC::handlePacket(AreaData *area, AOClient &client) const
client.sendPacket("SC", client.getServer()->getCharacters());
}
bool PacketRC::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_RC_H
#define PACKET_RC_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketRC : public AOPacket
{
@ -9,6 +9,5 @@ class PacketRC : public AOPacket
PacketRC(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_rd.h"
#include "include/config_manager.h"
#include "include/server.h"
#include "packet/packet_rd.h"
#include "config_manager.h"
#include "server.h"
#include <QDebug>
@ -62,11 +62,6 @@ void PacketRD::handlePacket(AreaData *area, AOClient &client) const
}
}
emit client.joined();
area->clientJoinedArea(-1, client.m_id);
area->addClient(-1, client.clientId());
client.arup(client.ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player
}
bool PacketRD::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_RD_H
#define PACKET_RD_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketRD : public AOPacket
{
@ -9,6 +9,5 @@ class PacketRD : public AOPacket
PacketRD(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_rm.h"
#include "include/server.h"
#include "packet/packet_rm.h"
#include "server.h"
#include <QDebug>
@ -23,8 +23,3 @@ void PacketRM::handlePacket(AreaData *area, AOClient &client) const
client.sendPacket("SM", client.getServer()->getAreaNames() + client.getServer()->getMusicList());
}
bool PacketRM::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_RM_H
#define PACKET_RM_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketRM : public AOPacket
{
@ -9,6 +9,5 @@ class PacketRM : public AOPacket
PacketRM(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,6 +1,6 @@
#include "include/packet/packet_rt.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_rt.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QDebug>
@ -33,11 +33,6 @@ void PacketRT::handlePacket(AreaData *area, AOClient &client) const
if (QDateTime::currentDateTime().toSecsSinceEpoch() - client.m_last_wtce_time <= 5)
return;
client.m_last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch();
client.getServer()->broadcast(PacketFactory::createPacket("RT", m_content), client.m_current_area);
client.getServer()->broadcast(PacketFactory::createPacket("RT", m_content), client.areaId());
client.updateJudgeLog(area, &client, "WT/CE");
}
bool PacketRT::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_RT_H
#define PACKET_RT_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketRT : public AOPacket
{
@ -9,6 +9,5 @@ class PacketRT : public AOPacket
PacketRT(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,5 +1,5 @@
#include "include/packet/packet_setcase.h"
#include "include/server.h"
#include "packet/packet_setcase.h"
#include "server.h"
#include <QDebug>
@ -31,8 +31,3 @@ void PacketSetcase::handlePacket(AreaData *area, AOClient &client) const
}
client.m_casing_preferences = l_prefs_list;
}
bool PacketSetcase::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_SETCASE_H
#define PACKET_SETCASE_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketSetcase : public AOPacket
{
@ -9,6 +9,5 @@ class PacketSetcase : public AOPacket
PacketSetcase(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -1,7 +1,7 @@
#include "include/packet/packet_zz.h"
#include "include/config_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "packet/packet_zz.h"
#include "config_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
#include <QQueue>
@ -21,9 +21,9 @@ PacketInfo PacketZZ::getPacketInfo() const
void PacketZZ::handlePacket(AreaData *area, AOClient &client) const
{
QString l_name = client.m_ooc_name;
if (client.m_ooc_name.isEmpty())
l_name = client.m_current_char;
QString l_name = client.name();
if (client.name().isEmpty())
l_name = client.character();
QString l_areaName = area->name();
@ -39,19 +39,14 @@ void PacketZZ::handlePacket(AreaData *area, AOClient &client) const
if (l_client->m_authenticated)
l_client->sendPacket(PacketFactory::createPacket("ZZ", {l_modcallNotice}));
}
emit client.logModcall((client.m_current_char + " " + client.m_showname), client.m_ipid, client.m_ooc_name, client.getServer()->getAreaById(client.m_current_area)->name());
emit client.logModcall((client.character() + " " + client.characterName()), client.m_ipid, client.name(), client.getServer()->getAreaById(client.areaId())->name());
if (ConfigManager::discordModcallWebhookEnabled()) {
QString l_name = client.m_ooc_name;
if (client.m_ooc_name.isEmpty())
l_name = client.m_current_char;
QString l_name = client.name();
if (client.name().isEmpty())
l_name = client.character();
QString l_areaName = area->name();
emit client.getServer()->modcallWebhookRequest(l_name, l_areaName, m_content.value(0), client.getServer()->getAreaBuffer(l_areaName));
}
}
bool PacketZZ::validatePacket() const
{
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef PACKET_ZZ_H
#define PACKET_ZZ_H
#include "include/network/aopacket.h"
#include "network/aopacket.h"
class PacketZZ : public AOPacket
{
@ -9,6 +9,5 @@ class PacketZZ : public AOPacket
PacketZZ(QStringList &contents);
virtual PacketInfo getPacketInfo() const;
virtual void handlePacket(AreaData *area, AOClient &client) const;
virtual bool validatePacket() const;
};
#endif

View File

@ -15,23 +15,23 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/aoclient.h"
#include "aoclient.h"
#include <QQueue>
#include "include/akashidefs.h"
#include "include/area_data.h"
#include "include/config_manager.h"
#include "include/db_manager.h"
#include "include/music_manager.h"
#include "include/packet/packet_factory.h"
#include "include/server.h"
#include "akashidefs.h"
#include "area_data.h"
#include "config_manager.h"
#include "db_manager.h"
#include "music_manager.h"
#include "packet/packet_factory.h"
#include "server.h"
void AOClient::sendEvidenceList(AreaData *area) const
{
const QVector<AOClient *> l_clients = server->getClients();
for (AOClient *l_client : l_clients) {
if (l_client->m_current_area == m_current_area)
if (l_client->areaId() == areaId())
l_client->updateEvidenceList(area);
}
}
@ -85,8 +85,8 @@ bool AOClient::checkEvidenceAccess(AreaData *area)
void AOClient::updateJudgeLog(AreaData *area, AOClient *client, QString action)
{
QString l_timestamp = QTime::currentTime().toString("hh:mm:ss");
QString l_uid = QString::number(client->m_id);
QString l_char_name = client->m_current_char;
QString l_uid = QString::number(client->clientId());
QString l_char_name = client->character();
QString l_ipid = client->getIpid();
QString l_message = action;
QString l_logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(l_timestamp, l_uid, l_char_name, l_ipid, l_message);
@ -116,8 +116,8 @@ void AOClient::loginAttempt(QString message)
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
sendServerMessage("Incorrect password.");
}
emit logLogin((m_current_char + " " + m_showname), m_ooc_name, "Moderator",
m_ipid, server->getAreaById(m_current_area)->name(), m_authenticated);
emit logLogin((character() + " " + characterName()), name(), "Moderator",
m_ipid, server->getAreaById(areaId())->name(), m_authenticated);
break;
case DataTypes::AuthType::ADVANCED:
QStringList l_login = message.split(" ");
@ -142,8 +142,8 @@ void AOClient::loginAttempt(QString message)
sendPacket("AUTH", {"0"}); // Client: "Login unsuccessful."
sendServerMessage("Incorrect password.");
}
emit logLogin((m_current_char + " " + m_showname), m_ooc_name, username, m_ipid,
server->getAreaById(m_current_area)->name(), m_authenticated);
emit logLogin((character() + " " + characterName()), name(), username, m_ipid,
server->getAreaById(areaId())->name(), m_authenticated);
break;
}
sendServerMessage("Exiting login prompt.");

View File

@ -0,0 +1,81 @@
#include "playerstateobserver.h"
PlayerStateObserver::PlayerStateObserver(QObject *parent) :
QObject{parent}
{}
PlayerStateObserver::~PlayerStateObserver() {}
void PlayerStateObserver::registerClient(AOClient *client)
{
Q_ASSERT(!m_client_list.contains(client));
PacketPLU packet(client->clientId(), PacketPLU::AddPlayerUpdate);
sendToClientList(packet);
m_client_list.append(client);
connect(client, &AOClient::nameChanged, this, &PlayerStateObserver::notifyNameChanged);
connect(client, &AOClient::characterChanged, this, &PlayerStateObserver::notifyCharacterChanged);
connect(client, &AOClient::characterNameChanged, this, &PlayerStateObserver::notifyCharacterNameChanged);
connect(client, &AOClient::areaIdChanged, this, &PlayerStateObserver::notifyAreaIdChanged);
{ // provide the player list to the new client
QList<PacketPL::PlayerData> data_list;
for (AOClient *i_client : qAsConst(m_client_list)) {
PacketPL::PlayerData data;
data.id = i_client->clientId();
data.name = i_client->name();
data.character = i_client->character();
data.character_name = i_client->characterName();
data.area_id = i_client->areaId();
data_list.append(data);
}
PacketPL packet(data_list);
client->sendPacket(&packet);
}
}
void PlayerStateObserver::unregisterClient(AOClient *client)
{
Q_ASSERT(m_client_list.contains(client));
disconnect(client, nullptr, this, nullptr);
m_client_list.removeAll(client);
PacketPLU packet(client->clientId(), PacketPLU::RemovePlayerUpdate);
sendToClientList(packet);
}
void PlayerStateObserver::sendToClientList(const AOPacket &packet)
{
for (AOClient *client : qAsConst(m_client_list)) {
client->sendPacket(&const_cast<AOPacket &>(packet));
}
}
void PlayerStateObserver::notifyNameChanged(const QString &name)
{
qDebug() << "PlayerStateObserver::notifyNameChanged" << qobject_cast<AOClient *>(sender())->clientId() << name;
sendToClientList(PacketPU(qobject_cast<AOClient *>(sender())->clientId(), PacketPU::NameData, name));
}
void PlayerStateObserver::notifyCharacterChanged(const QString &character)
{
qDebug() << "PlayerStateObserver::notifyCharacterChanged" << qobject_cast<AOClient *>(sender())->clientId() << character;
sendToClientList(PacketPU(qobject_cast<AOClient *>(sender())->clientId(), PacketPU::CharacterData, character));
}
void PlayerStateObserver::notifyCharacterNameChanged(const QString &characterName)
{
qDebug() << "PlayerStateObserver::notifyCharacterNameChanged" << qobject_cast<AOClient *>(sender())->clientId() << characterName;
sendToClientList(PacketPU(qobject_cast<AOClient *>(sender())->clientId(), PacketPU::CharacterNameData, characterName));
}
void PlayerStateObserver::notifyAreaIdChanged(int areaId)
{
qDebug() << "PlayerStateObserver::notifyAreaIdChanged" << qobject_cast<AOClient *>(sender())->clientId() << areaId;
sendToClientList(PacketPU(qobject_cast<AOClient *>(sender())->clientId(), PacketPU::AreaIdData, areaId));
}

Some files were not shown because too many files have changed in this diff Show More