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.
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
#include "ModelNormalizeMigration.h"
|
|
|
|
#include "Database.h"
|
|
#include "Lxfml.h"
|
|
#include "Sd0.h"
|
|
|
|
void ModelNormalizeMigration::Run() {
|
|
const auto oldCommit = Database::Get()->GetAutoCommit();
|
|
Database::Get()->SetAutoCommit(false);
|
|
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
|
const auto model = Database::Get()->GetModel(modelID);
|
|
// only BBB models (lot 14) and models with a position of NiPoint3::ZERO need to have their position fixed.
|
|
if (model.position != NiPoint3Constant::ZERO || model.lot != 14) continue;
|
|
|
|
Sd0 sd0(lxfmlData);
|
|
const auto asStr = sd0.GetAsStringUncompressed();
|
|
const auto [newLxfml, newCenter] = Lxfml::NormalizePosition(asStr);
|
|
if (newCenter == NiPoint3Constant::ZERO) {
|
|
LOG("Failed to update model %llu due to failure reading xml.");
|
|
continue;
|
|
}
|
|
|
|
LOG("Updated model %llu to have a center of %f %f %f", modelID, newCenter.x, newCenter.y, newCenter.z);
|
|
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
|
auto asStream = sd0.GetAsStream();
|
|
Database::Get()->UpdateModel(model.id, newCenter, model.rotation, model.behaviors);
|
|
Database::Get()->UpdateUgcModelData(id, asStream);
|
|
}
|
|
Database::Get()->SetAutoCommit(oldCommit);
|
|
}
|