[Player Event Logs] Migrate and Deprecate QS Legacy Logging (#4542)

* First pass of player_event_loot_items

* Second pass of player_event_loot_items

* Third pass of player_event_loot_items

* Example without RecordDetailEvent template

* Cleanup the removal of the template

* Fourth Pass

Add retention for etl tables
Rename tables/fields to etl nomenclature
Combine database work to one atomic load

* Reposition to reduce db tasks

* Refactor etl processing for easier additions

* Add merchant purchase event
testing passed though appears that the event itself has a few bugs.  Will fix them in another commit

* Fix PlayerEventMerchantPurchase in client_packet.cpp

* WIP - Handin

* Handin Event added

* Cleanup

* All a rentention period of 0 days which deletes all current records.

* Updates

Cleanup and refactor a few items.

* Cleanup and Formatting

Cleanup and Formatting

* Add etl for
Playerevent::Trade
PlayerEvent::Speech (new event to mirror functionality of qs_speech

* Add etl for
Playerevent::KilledNPC, KilledNamedNPC and KilledRaidNPC

* Add etl for Playerevent::AA_purchase

Add etl for Playerevent::AA_purchase

* Cleanup before PR

* Review comment updates.

* Add world cli etl:settings to output a json on all player event details.

* Add reserve for all etl_queues
Correct a failed test case for improper next id for etl tables when table is first created.

* Potential solution for a dedicated database connection for player events.

* Simple thread for player_events.  Likely there is a better way to do this.

* Add zone to qs communications for recordplayerevents

First pass of enabling zone to qs direct transport to allow for PlayerEvents to bypass world.

* Cleanup a linux compile issue

* Add augments to LOOT ITEM and DESTROY ITEM

* Add augments to ITEMCREATION, FORAGESUCCESS, FISHSUCCESS, DESTROYITEM, LOOTITEM, DROPPEDITEM, TRADERPURCHASE, TRADERSELL, GUILDTRIBUTEDONATE and cleaned up the naming convention of augments

* Formatting fixes

* Swap out GetNextTableId

* Statically load counter

* Add counter.clear() since the counter is static

* Upload optional QS conversion scripts

* Remove all qs_tables and code referencing them

* Update database.cpp

* Simplify ProcessBatchQueue

* Simplify PorcessBatchQueue

* Simplify event truncation

* Build event truncation to bulk query by retention groups

* Post rebase

* Update player_events.h

* Fix build

* Update npc.cpp

* First pass of direct zone to qs sending for player events

* Remove keepalive logic

* Fix event ordering

* Cleanup

* Update player_event_logs.cpp

* Wipe event data after ETL processed

* Split up database connections, hot reload logs for QS

* Load rules from database vs qs_database

* Update player_event_logs.cpp

* Hot toggle queryserv connect

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Mitch Freeman
2025-02-05 04:02:16 -04:00
committed by GitHub
parent 21d27a1122
commit 8f4f8368df
99 changed files with 8156 additions and 2451 deletions
+80 -26
View File
@@ -1,27 +1,7 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "../common/opcodemgr.h"
#include "../common/rulesys.h"
#include "../common/servertalk.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "../common/strings.h"
@@ -31,16 +11,21 @@
#include "queryservconfig.h"
#include "lfguild.h"
#include "worldserver.h"
#include "../common/path_manager.h"
#include "../common/zone_store.h"
#include "../common/events/player_event_logs.h"
#include <list>
#include <signal.h>
#include <thread>
#include "../common/net/servertalk_server.h"
#include "../common/net/console_server.h"
#include "../queryserv/zonelist.h"
#include "../queryserv/zoneserver.h"
#include "../common/discord/discord_manager.h"
volatile bool RunLoops = true;
QSDatabase database;
QSDatabase qs_database;
Database database;
LFGuildManager lfguildmanager;
std::string WorldShortName;
const queryservconfig *Config;
@@ -49,6 +34,9 @@ EQEmuLogSys LogSys;
PathManager path;
ZoneStore zone_store;
PlayerEventLogs player_event_logs;
ZSList zs_list;
uint32 numzones = 0;
DiscordManager discord_manager;
void CatchSignal(int sig_num)
{
@@ -76,12 +64,22 @@ int main()
LogInfo("Connecting to MySQL");
/* MySQL Connection */
if (!database.Connect(
if (!qs_database.Connect(
Config->QSDatabaseHost.c_str(),
Config->QSDatabaseUsername.c_str(),
Config->QSDatabasePassword.c_str(),
Config->QSDatabaseDB.c_str(),
Config->QSDatabasePort
)) {
LogInfo("Cannot continue without a qs database connection");
return 1;
}
if (!database.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort
)) {
LogInfo("Cannot continue without a database connection");
return 1;
@@ -101,6 +99,61 @@ int main()
return 1;
}
//rules:
{
std::string tmp;
if (database.GetVariable("RuleSet", tmp)) {
LogInfo("Loading rule set [{}]", tmp.c_str());
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str(), false)) {
LogError("Failed to load ruleset [{}], falling back to defaults", tmp.c_str());
}
}
else {
if (!RuleManager::Instance()->LoadRules(&database, "default", false)) {
LogInfo("No rule set configured, using default rules");
}
}
EQ::InitializeDynamicLookups();
}
std::unique_ptr<EQ::Net::ConsoleServer> console;
EQ::Net::ServertalkServerOptions server_opts;
auto server_connection = std::make_unique<EQ::Net::ServertalkServer>();
server_opts.port = Config->QSPort;
server_opts.ipv6 = false;
server_opts.credentials = Config->SharedKey;
server_connection->Listen(server_opts);
LogInfo("Server (TCP) listener started on port [{}]", Config->QSPort);
server_connection->OnConnectionIdentified(
"Zone", [&console](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
numzones++;
zs_list.Add(new ZoneServer(connection, console.get()));
LogInfo(
"New Zone Server connection from [{}] at [{}:{}] zone_count [{}]",
connection->Handle()->RemoteIP(),
connection->Handle()->RemotePort(),
connection->GetUUID(),
numzones
);
}
);
server_connection->OnConnectionRemoved(
"Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
numzones--;
zs_list.Remove(connection->GetUUID());
LogInfo(
"Removed Zone Server connection from [{}] total zone_count [{}]",
connection->GetUUID(),
numzones
);
}
);
/* Initial Connection to Worldserver */
worldserver = new WorldServer;
worldserver->Connect();
@@ -109,9 +162,9 @@ int main()
lfguildmanager.LoadDatabase();
Timer player_event_process_timer(1000);
player_event_logs.SetDatabase(&database)->Init();
player_event_logs.SetDatabase(&qs_database)->Init();
auto loop_fn = [&](EQ::Timer* t) {
auto loop_fn = [&](EQ::Timer *t) {
Timer::SetCurrentTime();
if (!RunLoops) {
@@ -124,7 +177,7 @@ int main()
}
if (player_event_process_timer.Check()) {
player_event_logs.Process();
std::jthread player_event_thread(&PlayerEventLogs::Process, &player_event_logs);
}
};
@@ -133,6 +186,7 @@ int main()
EQ::EventLoop::Get().Run();
safe_delete(worldserver);
LogSys.CloseFileLogs();
}