mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Converts the property messages to NetGameMsgs in PropertyMessages.{h,cpp}.
Sent: OpenPropertyVendor, OpenPropertyManagement, DownloadPropertyData
(replaces PropertyDataMessage, now with the client's PropertyData field
names), PropertyRentalResponse, PropertyEntranceBegin,
PropertySelectQuery (replaces PropertySelectQueryProperty with the
client's PropertyInfo), GetModelsOnProperty, PlaceModelResponse and
HandleUGCEquipPre/PostDeleteBasedOnEditMode. Received, registered in
GameMessageHandler's map: SetPropertyAccess,
UpdatePropertyOrModelForFilterCheck, QueryPropertyData,
PropertyEditorBegin/End, PropertyContentsFromClient,
ZonePropertyModelEquipped/Rotated, PlacePropertyModel,
UpdateModelFromClient, DeleteModelFromClient, ControlBehaviors,
PropertyEntranceSync, EnterProperty1, UpdatePropertyPerformanceCost,
ReportOffensiveModel/Property and GetHotPropertyData. The news screen's
NewsSendHotPropertiesInfoToClient moves here with the top properties
lookup; the dashboard's player reports now take the decoded text.
Handlers keep their logic and hand the work to PropertyManagementComponent,
PropertyVendorComponent, PropertyEntranceComponent and
MultiZoneEntranceComponent as before. Messages whose payload DLU ignored
(PropertyEditorBegin, PropertyContentsFromClient, ZonePropertyModel*)
now read it with the client's layout. The never-called
SendZonePropertyModelEquipped (which wrote no default flags) is gone.
No wire change and no change in recipients. Verified byte for byte
against a frozen verbatim copy of the old functions, PropertyDataMessage
and PropertySelectQueryProperty over an input grid (to one client and
broadcast), received messages compared with the old handlers' read
sequences with every truncated payload rejected, hand computed golden
bytes, round trips and a mutation check. Layouts confirmed against the
1.10.64 client in Ghidra. Known wire bug kept as is: PlaceModelResponse
writes response where the client reads a rotation quaternion
(PlaceModelResponse::Deserialize 0x00dc0170).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
#ifndef __PLAYERREPORTS__H__
|
|
#define __PLAYERREPORTS__H__
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <deque>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
class Entity;
|
|
|
|
/**
|
|
* Reports players send from the game's Report Abuse window (the help menu, or "Report" on another player's name), kept
|
|
* in player_reports for the dashboard. The client sends a report about another player as ReportBug naming the player
|
|
* (nOtherPlayerID), and one about a model or a property as ReportOffensiveModel / ReportOffensiveProperty.
|
|
*/
|
|
namespace PlayerReports {
|
|
/**
|
|
* How many reports one account may send from this world: a few a minute and a few dozen a day. Anything over is
|
|
* dropped (with a log line), so a player can't flood the table or the world's thread with 2000-character inserts.
|
|
* Times are unix seconds, passed in so it can be tested.
|
|
*/
|
|
class RateLimit {
|
|
public:
|
|
static constexpr size_t PER_MINUTE = 3;
|
|
static constexpr size_t PER_DAY = 20;
|
|
|
|
bool Allow(uint64_t reporter, int64_t now) {
|
|
auto& times = m_Sent[reporter];
|
|
while (!times.empty() && times.front() <= now - 24 * 60 * 60) times.pop_front();
|
|
const auto lastMinute = static_cast<size_t>(std::count_if(times.begin(), times.end(), [now](int64_t t) { return t > now - 60; }));
|
|
if (times.size() >= PER_DAY || lastMinute >= PER_MINUTE) return false;
|
|
times.push_back(now);
|
|
if (m_Sent.size() > 10000) std::erase_if(m_Sent, [now](const auto& entry) { return entry.second.empty() || entry.second.back() <= now - 24 * 60 * 60; });
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
std::map<uint64_t, std::deque<int64_t>> m_Sent;
|
|
};
|
|
|
|
// ReportBug with nOtherPlayerID set; body is what the player wrote
|
|
void ReportPlayer(Entity* reporter, LWOOBJID reportedId, const std::string& body);
|
|
|
|
// ReportOffensiveModel: what the player wrote, and the object they picked. Dropped if the text is too long.
|
|
void ReportOffensiveModel(Entity* reporter, const std::u16string& description, LWOOBJID objectId);
|
|
|
|
// ReportOffensiveProperty: what the player wrote, and the property's plaque. Dropped if the text is too long.
|
|
void ReportOffensiveProperty(Entity* reporter, const std::u16string& description, LWOOBJID plaqueId);
|
|
}
|
|
|
|
#endif //!__PLAYERREPORTS__H__
|