feat(ugc): answer the client's UGC manifest requests without 3D services

With UGCUSE3DSERVICES=7:0 (the client's default) the client asks its world for
a blueprint file's MD5 and size (REQUEST_UGC_MANIFEST_INFO, world 27) and then
downloads BrickModels/UserMade/<id % 1000>/<id>.<ext>.sd0. Layouts checked in
the 1.10.64 client: the request is a u64 blueprint id and a u8 resource type;
the answer (UGC_MANIFEST_RESPONSE, client 60) repeats them and adds a u8 valid,
the u32 size and the 16 byte MD5 of the inflated file, 37 bytes after the 0x53
exactly or the client drops it.

- dNet: WorldPackets::RequestUgcManifestInfo, ClientPackets::UgcManifestResponse
  (eUgcResourceType), with byte tests against the client's layouts.
- Database: ugc_file_checksums (per model or module combination and file) and
  ugc_modular_build.combination_id (migrations 89 / 72), GetUgcFileChecksum
  looks a blueprint up as a model, else as a build through its combination.
- UGC server: every download is also written as .sd0 (Sd0::Compress); workers
  hand the checksums back and the main thread stores them; old items get their
  sd0 icon and checksum, and builds their combination id, once at start-up, a
  few per tick; serves <dir>/BrickModels/UserMade/<bucket>/<id>.<ext>.sd0 under
  client_path, /<folder>/UserBrickModels and the root (.hkx 404).
- World: UgcManifest answers on the main thread with one indexed query per
  request; files not made yet are answered when they are (looked at again
  every 5 seconds), and a model in its quiet period is made right away. No
  worker threads, HTTP or file reads in the world.

Off by default (ugc_manifest=0): checked in game, the client then downloads
from http://127.0.0.1:80/lwoclient/UserBrickModels/ whatever its boot.cfg says
and logs the player out when it can't connect, so icons need the UGC server on
port 80 of each player's machine. docs/UgcServer.md has the details.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 17:46:47 -05:00
parent ceec638e52
commit 79235702b3
33 changed files with 706 additions and 14 deletions

View File

@@ -484,6 +484,25 @@ bool ClientPackets::BlueprintLoadItemResponse::Deserialize(RakNet::BitStream& bi
return true;
}
void ClientPackets::UgcManifestResponse::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(blueprintId);
bitStream.Write(resourceType);
bitStream.Write<uint8_t>(valid ? 1 : 0);
bitStream.Write(fileSize);
for (const auto byte : md5) bitStream.Write(byte);
}
bool ClientPackets::UgcManifestResponse::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(blueprintId));
VALIDATE_READ(bitStream.Read(resourceType));
uint8_t validByte{};
VALIDATE_READ(bitStream.Read(validByte));
valid = validByte != 0;
VALIDATE_READ(bitStream.Read(fileSize));
for (auto& byte : md5) VALIDATE_READ(bitStream.Read(byte));
return true;
}
namespace {
// A zone ID as three fields: map (u16), instance (u16), clone (u32)
void WriteZone(RakNet::BitStream& bitStream, const LWOZONEID& zoneID) {

View File

@@ -6,6 +6,7 @@
#ifndef CLIENTPACKETS_H
#define CLIENTPACKETS_H
#include <array>
#include <cstdint>
#include <ctime>
#include <set>
@@ -18,6 +19,7 @@
#include "eAddFriendResponseType.h"
#include "eAddIgnoreResponse.h"
#include "eBlueprintSaveResponseType.h"
#include "eUgcResourceType.h"
#include "MessageType/Client.h"
#include "MessageType/Game.h"
#include "NiPoint3.h"
@@ -264,6 +266,23 @@ namespace ClientPackets {
LWOOBJID itemId{};
LWOOBJID destItemId{};
};
// Server -> client. The answer to REQUEST_UGC_MANIFEST_INFO: the MD5 and size of one of a blueprint's files as the
// client has it after downloading and inflating it (BrickModels/UserMade/<id % 1000>/<id>.<ext>.sd0 from the UGC
// server). The client checks a file it has against it and downloads the file when it differs; with valid 0 it uses
// a file it has as it is and downloads it only when it has none. The client ignores the answer unless it is exactly
// this long (37 bytes after the 0x53).
struct UgcManifestResponse : public LUBitStream {
UgcManifestResponse() : LUBitStream(ServiceType::CLIENT, MessageType::Client::UGC_MANIFEST_RESPONSE) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
LWOOBJID blueprintId{};
eUgcResourceType resourceType{};
bool valid{}; // A byte
uint32_t fileSize{}; // Of the inflated file
std::array<uint8_t, 16> md5{}; // Of the inflated file, as bytes
};
};
/**

View File

@@ -340,6 +340,17 @@ namespace WorldPackets {
return true;
}
void RequestUgcManifestInfo::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(blueprintId);
bitStream.Write(resourceType);
}
bool RequestUgcManifestInfo::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(blueprintId));
VALIDATE_READ(bitStream.Read(resourceType));
return true;
}
void UIHelpTop5::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(language);
}

View File

@@ -5,6 +5,7 @@
#include "ChatPackets.h"
#include "dCommonVars.h"
#include "eFunnessTypes.h"
#include "eUgcResourceType.h"
#include "MessageType/Game.h"
#include "MessageType/World.h"
#include "PositionUpdate.h"
@@ -201,6 +202,17 @@ namespace WorldPackets {
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server, when its UGCUSE3DSERVICES is off (the default): the MD5 and size of one of a blueprint's files
// (a player's model, or a car or rocket's build), answered with ClientPackets::UgcManifestResponse.
struct RequestUgcManifestInfo : public WorldLUBitStream {
LWOOBJID blueprintId{};
eUgcResourceType resourceType{};
RequestUgcManifestInfo() : WorldLUBitStream(MessageType::World::REQUEST_UGC_MANIFEST_INFO) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server. The help screen wants its top 5 issues.
struct UIHelpTop5 : public WorldLUBitStream {
int32_t language{}; // 0: en_US, 1: pl_US, 2: de_DE, 3: en_GB