mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
fix(ugc): answer the client's built-in UGC path, and document how it downloads
In the 1.10.64 client tested, 3D services ignore boot.cfg's UGC and patch server lines and ask http://127.0.0.1:80/lwoclient/UserBrickModels/...; the UGC server now answers that path too (useful when it runs on port 80), and the docs say to keep UGCUSE3DSERVICES=7:0 (the client builds the models from the world's LXFML; verified that property models load) until it can. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -228,23 +228,29 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegisterRoutes() {
|
void RegisterRoutes() {
|
||||||
const auto prefix = Segments(Lower(Game::config->GetValue("client_path").empty() ? "/ugc" : Game::config->GetValue("client_path")));
|
// The configured path, and the one the 1.10.64 client uses whatever its boot.cfg says (its built-in patch server
|
||||||
std::string base;
|
// folder, lwoclient/UserBrickModels; see docs/UgcServer.md)
|
||||||
for (const auto& segment : prefix) base += "/" + segment;
|
std::set<std::string> bases;
|
||||||
|
for (const auto& path : { Game::config->GetValue("client_path").empty() ? std::string("/ugc") : Game::config->GetValue("client_path"), std::string("/lwoclient/UserBrickModels") }) {
|
||||||
const auto clientRoute = [prefixSize = prefix.size()](HTTPReply& reply, const HTTPContext& context) {
|
const auto prefix = Segments(Lower(path));
|
||||||
auto segments = Segments(context.originalPath);
|
std::string base;
|
||||||
if (segments.size() <= prefixSize) {
|
for (const auto& segment : prefix) base += "/" + segment;
|
||||||
NotFound(reply);
|
if (!bases.insert(base).second) continue;
|
||||||
return;
|
const auto clientRoute = [prefixSize = prefix.size()](HTTPReply& reply, const HTTPContext& context) {
|
||||||
}
|
auto segments = Segments(context.originalPath);
|
||||||
segments.erase(segments.begin(), segments.begin() + static_cast<std::ptrdiff_t>(prefixSize));
|
if (segments.size() <= prefixSize) {
|
||||||
ServeClientDownload(reply, segments);
|
NotFound(reply);
|
||||||
// What the client asked for and what it got, to see how it loads models
|
return;
|
||||||
LOG("Client download %s -> %i%s", context.originalPath.c_str(), static_cast<int>(reply.status), reply.file.empty() ? "" : " (file)");
|
}
|
||||||
};
|
segments.erase(segments.begin(), segments.begin() + static_cast<std::ptrdiff_t>(prefixSize));
|
||||||
Game::web.RegisterHTTPRoute({ .path = base + "/:folder/:file", .method = eHTTPMethod::GET, .middleware = {}, .handle = clientRoute });
|
ServeClientDownload(reply, segments);
|
||||||
Game::web.RegisterHTTPRoute({ .path = base + "/:folder/:type/:file", .method = eHTTPMethod::GET, .middleware = {}, .handle = clientRoute });
|
// What the client asked for and what it got, to see how it loads models
|
||||||
|
LOG("Client download %s -> %i%s", context.originalPath.c_str(), static_cast<int>(reply.status), reply.file.empty() ? "" : " (file)");
|
||||||
|
};
|
||||||
|
Game::web.RegisterHTTPRoute({ .path = base + "/:folder/:file", .method = eHTTPMethod::GET, .middleware = {}, .handle = clientRoute });
|
||||||
|
Game::web.RegisterHTTPRoute({ .path = base + "/:folder/:type/:file", .method = eHTTPMethod::GET, .middleware = {}, .handle = clientRoute });
|
||||||
|
LOG("Serving the client's downloads under %s/UGCC<datacenter>/", base.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Previews for the dashboard
|
// Previews for the dashboard
|
||||||
Game::web.RegisterHTTPRoute({ .path = "/files/:kind/:id/:file", .method = eHTTPMethod::GET, .middleware = {},
|
Game::web.RegisterHTTPRoute({ .path = "/files/:kind/:id/:file", .method = eHTTPMethod::GET, .middleware = {},
|
||||||
@@ -361,7 +367,6 @@ namespace {
|
|||||||
reply.headers.push_back("Access-Control-Allow-Origin: *");
|
reply.headers.push_back("Access-Control-Allow-Origin: *");
|
||||||
reply.headers.push_back("Cache-Control: no-store");
|
reply.headers.push_back("Cache-Control: no-store");
|
||||||
} });
|
} });
|
||||||
LOG("Serving the client's downloads under %s/UGCC<datacenter>/", base.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path ResPath() {
|
std::filesystem::path ResPath() {
|
||||||
|
|||||||
Reference in New Issue
Block a user