akashi-esquizolandia/core/src/logger/writer_modcall.cpp
Leifa♥ b0555207d6 Privatization rework (#2)
* Add clang-format

* Multiple privatization changes

"Participation handshake" this refers to the moment that the user's client sends the `askchaa` packet.

* Server::m_clients is now private. Get a copy with Server::getClients()
* Server::m_player_count is now private. Get a copy with Server::getPlayerCount() (Additional logic was added to handle the player count.)
* AOClient::m_joined is now private. Get a copy with AOClient::hasJoined()
* Added signal AOClient::joined(); will be emitted when the client first complete the participation handshake.
* Renamed Server::updatePlayerCount to Server::playerCountUpdated

* Privatized Server

* Made Server members private: m_characters, m_areas, m_area_names
* Added Server methods: getCharacters(), getAreas(), getAreaById(f_area_id), getAreaByName(f_area_name), getAreaNames(), getAreaName(f_area_id), getMusicList
* Added Server helper methods: getCharacterCount(), getAreaCount()
- This reduce code repetition of the following example: server->getCharacters().length(), server->getAreas().size()

* Solved other merge conflicts

* Added Server methods, various fixes

* Added Server methods: getCharacterById(f_chr_id)
* Various optimizations

* More Server privatization changes

* Made Server members private: db_manager, next_message_timer, can_send_ic_messages
* Renamed Server members:
  * next_message_timer -> m_message_floodguard_timer
  * can_send_ic_message -> m_can_send_ic_message
Added Server methods: getDatabaseManager, isMessageAllowed, startMessageFloodguard(f_duration)
Made Server methods private: allowMessage

* Added new fields to load for AreaData

* Added fields: `area_message` (default: empty string) and `send_area_message_on_join` (default: false)

* Added Server::clearAreaMessage

* Cleaned up headers include (AOPacket excluded)

* Removed most project file includes, moved to source file (cpp)
  * AOPacket was excluded because some methods modify the copy

* Fix compile error when using MingW compiler

* Appease clang by using proper or and putting it in parentheses
* Remove extra semicolon
2022-06-15 17:52:27 -05:00

47 lines
2.2 KiB
C++

//////////////////////////////////////////////////////////////////////////////////////
// akashi - a server for Attorney Online 2 //
// Copyright (C) 2020 scatterflower //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// 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"
WriterModcall::WriterModcall(QObject *parent) :
QObject(parent)
{
l_dir.setPath("logs/");
if (!l_dir.exists()) {
l_dir.mkpath(".");
}
l_dir.setPath("logs/modcall");
if (!l_dir.exists()) {
l_dir.mkpath(".");
}
}
void WriterModcall::flush(const QString f_area_name, QQueue<QString> f_buffer)
{
l_logfile.setFileName(QString("logs/modcall/report_%1_%2.log").arg(f_area_name, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss"))));
if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) {
QTextStream file_stream(&l_logfile);
while (!f_buffer.isEmpty())
file_stream << f_buffer.dequeue();
}
l_logfile.close();
};