VERY rough WIP

This commit is contained in:
Aaron Kimbre
2025-01-20 05:10:03 -06:00
parent e4c2eecbc7
commit 1b6c258901
8 changed files with 193 additions and 35 deletions

View File

@@ -12,6 +12,8 @@
#include "ChatPackets.h"
#include "dConfig.h"
#include "MessageType/Chat.h"
#include "json.hpp"
#include "ChatWebAPI.h"
void PlayerContainer::Initialize() {
m_MaxNumberOfBestFriends =
@@ -58,7 +60,17 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
m_PlayerCount++;
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
// Send to connected websockets
nlohmann::json wsdata;
wsdata["action"] = "character_update";
wsdata["type"] = "add";
wsdata["playerName"] = data.playerName;
wsdata["playerID"] = data.playerID;
auto& zoneID = wsdata["zone_id"];
zoneID["map_id"] = data.zoneID.GetMapID();
zoneID["instance_id"] = data.zoneID.GetInstanceID();
zoneID["clone_id"] = data.zoneID.GetCloneID();
Game::chatwebapi.SendWSMessage(wsdata.dump());
Database::Get()->UpdateActivityLog(data.playerID, eActivityType::PlayerLoggedIn, data.zoneID.GetMapID());
m_PlayersToRemove.erase(playerId);
}
@@ -113,6 +125,13 @@ void PlayerContainer::RemovePlayer(const LWOOBJID playerID) {
}
}
nlohmann::json wsdata;
wsdata["action"] = "character_update";
wsdata["type"] = "remove";
wsdata["playerName"] = player.playerName;
wsdata["playerID"] = player.playerID;
Game::chatwebapi.SendWSMessage(wsdata.dump());
m_PlayerCount--;
LOG("Removed user: %llu", playerID);
m_Players.erase(playerID);