mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-05-09 16:11:17 +00:00

* Add utilities for formats * Normalize model positions when placing in the world Have tested that placing a small and very large model both place and are located at the correct position. * add migration * Update Logger.cpp * add some notes and remove some logs * change arguments and add eof check Revert "fix: buff station cycling and dying too soon" This reverts commit 1c6cb2921e10eb2000ac40007d0c2636ba2ac151. fix: buff station cycling and dying too soon Tested that the buff station now only cycles after it has been built and has been alive for 25 seconds.
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
#include "MySQLDatabase.h"
|
|
|
|
std::vector<IUgc::Model> MySQLDatabase::GetUgcModels(const LWOOBJID& propertyId) {
|
|
auto result = ExecuteSelect(
|
|
"SELECT lxfml, u.id as ugcID, pc.id as modelID FROM ugc AS u JOIN properties_contents AS pc ON u.id = pc.ugc_id WHERE lot = 14 AND property_id = ? AND pc.ugc_id IS NOT NULL;",
|
|
propertyId);
|
|
|
|
std::vector<IUgc::Model> toReturn;
|
|
|
|
while (result->next()) {
|
|
IUgc::Model model;
|
|
|
|
// blob is owned by the query, so we need to do a deep copy :/
|
|
std::unique_ptr<std::istream> blob(result->getBlob("lxfml"));
|
|
model.lxfmlData << blob->rdbuf();
|
|
model.id = result->getUInt64("ugcID");
|
|
model.modelID = result->getUInt64("modelID");
|
|
toReturn.push_back(std::move(model));
|
|
}
|
|
|
|
return toReturn;
|
|
}
|
|
|
|
std::vector<IUgc::Model> MySQLDatabase::GetAllUgcModels() {
|
|
auto result = ExecuteSelect("SELECT u.id AS ugcID, lxfml, pc.id AS modelID FROM ugc AS u JOIN properties_contents AS pc ON pc.ugc_id = u.id WHERE pc.lot = 14 AND pc.ugc_id IS NOT NULL;");
|
|
|
|
std::vector<IUgc::Model> models;
|
|
models.reserve(result->rowsCount());
|
|
while (result->next()) {
|
|
IUgc::Model model;
|
|
model.id = result->getInt64("ugcID");
|
|
model.modelID = result->getUInt64("modelID");
|
|
|
|
// blob is owned by the query, so we need to do a deep copy :/
|
|
std::unique_ptr<std::istream> blob(result->getBlob("lxfml"));
|
|
model.lxfmlData << blob->rdbuf();
|
|
models.push_back(std::move(model));
|
|
}
|
|
|
|
return models;
|
|
}
|
|
|
|
void MySQLDatabase::RemoveUnreferencedUgcModels() {
|
|
ExecuteDelete("DELETE FROM ugc WHERE id NOT IN (SELECT ugc_id FROM properties_contents WHERE ugc_id IS NOT NULL);");
|
|
}
|
|
|
|
void MySQLDatabase::InsertNewUgcModel(
|
|
std:: stringstream& sd0Data, // cant be const sad
|
|
const uint32_t blueprintId,
|
|
const uint32_t accountId,
|
|
const uint32_t characterId) {
|
|
const std::istream stream(sd0Data.rdbuf());
|
|
ExecuteInsert(
|
|
"INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`) VALUES (?,?,?,?,?,?,?)",
|
|
blueprintId,
|
|
accountId,
|
|
characterId,
|
|
0,
|
|
&stream,
|
|
false,
|
|
"weedeater.lxfml"
|
|
);
|
|
}
|
|
|
|
void MySQLDatabase::DeleteUgcModelData(const LWOOBJID& modelId) {
|
|
ExecuteDelete("DELETE FROM ugc WHERE id = ?;", modelId);
|
|
ExecuteDelete("DELETE FROM properties_contents WHERE ugc_id = ?;", modelId);
|
|
}
|
|
|
|
void MySQLDatabase::UpdateUgcModelData(const LWOOBJID& modelId, std::stringstream& lxfml) {
|
|
const std::istream stream(lxfml.rdbuf());
|
|
ExecuteUpdate("UPDATE ugc SET lxfml = ? WHERE id = ?;", &stream, modelId);
|
|
}
|