mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
The NexusDashboard-parity dashboard (dDashboardServer) and everything built on it on the experimental branch: accounts, characters, properties and moderation tools, permissions shared with in-game slash commands, economy reports, World 3D and property 3D views with client scenery, scheduled events (features, vanity changes, live events, announcements, restarts), vanity files and events, the CDClient browser, the message inspector with saved captures, chat filter tools, community challenges, live ops, the AI moderator helper, and the server-side changes they need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#ifndef __DATACHANGED__H__
|
|
#define __DATACHANGED__H__
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "BitStream.h"
|
|
#include "dCommonVars.h"
|
|
|
|
/**
|
|
* DATA_CHANGED payload: the tables and rows a game server just wrote. The dashboard turns each entry into a
|
|
* table_changed event so open pages refresh without waiting for its periodic database check.
|
|
*/
|
|
struct DataChanged {
|
|
struct Entry {
|
|
std::string table; // dashboard table name, e.g. "characters", "mail", "economy"
|
|
LWOOBJID id{}; // row the change is about, 0 for the table as a whole
|
|
};
|
|
|
|
static constexpr size_t MAX_ENTRIES = 1024;
|
|
static constexpr size_t MAX_TABLE_NAME = 32;
|
|
|
|
std::vector<Entry> entries;
|
|
|
|
void Serialize(RakNet::BitStream& stream) const {
|
|
const auto count = static_cast<uint16_t>(std::min(entries.size(), MAX_ENTRIES));
|
|
stream.Write(count);
|
|
for (size_t i = 0; i < count; i++) {
|
|
const auto& entry = entries[i];
|
|
const auto length = static_cast<uint8_t>(std::min(entry.table.size(), MAX_TABLE_NAME));
|
|
stream.Write(length);
|
|
stream.Write(entry.table.data(), length);
|
|
stream.Write(entry.id);
|
|
}
|
|
}
|
|
|
|
bool Deserialize(RakNet::BitStream& stream) {
|
|
uint16_t count{};
|
|
if (!stream.Read(count) || count > MAX_ENTRIES) return false;
|
|
entries.clear();
|
|
entries.reserve(count);
|
|
for (uint16_t i = 0; i < count; i++) {
|
|
uint8_t length{};
|
|
if (!stream.Read(length) || length > MAX_TABLE_NAME) return false;
|
|
Entry entry;
|
|
entry.table.resize(length);
|
|
if (length > 0 && !stream.Read(entry.table.data(), length)) return false;
|
|
if (!stream.Read(entry.id)) return false;
|
|
entries.push_back(std::move(entry));
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
|
|
#endif //!__DATACHANGED__H__
|