Files
DarkflameServer/dDatabase/ModularBuildIdMigration.h
Aaron Kimbrell 7ea0453a6c feat(ugc): migration gives old cars and rockets a build id
Cars and rockets built before builds were recorded were saved with
subkey 0 and have no ugc_modular_build row, so the client has no
blueprint id to ask for their icon with. The runtime fix only reaches
characters that load again.

Migrations mysql 98 and sqlite 81 (98/81 because the guilds work takes
97/80) run ModularBuildIdMigration after the SQL: every saved item with
modules (x@ma) and no subkey gets what a new build gets, as the
character-load fix does: a persistent id from object_id_tracker (with
the character bit) as its subkey and a ugc_modular_build row with its
modules and the character as owner. The XML is written with
UpdateCharacterXml. Tried on a copy of a server's database with a
couple of thousand such items: every one got an id and a build row, in
seconds.

Check: after the migration, old cars and rockets show their icons in the
backpack (the UGC server makes them like any build) and still work
(equip, race, launch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:22:07 -05:00

35 lines
1.2 KiB
C++

#ifndef MODULARBUILDIDMIGRATION_H
#define MODULARBUILDIDMIGRATION_H
#include <cstdint>
#include <functional>
#include <string>
#include <vector>
#include "dCommonVars.h"
namespace tinyxml2 {
class XMLDocument;
}
/**
* Cars and rockets built before builds were recorded: saved items with modules (x@ma, assemblyPartLOTs) and no subkey,
* so they have no ugc_modular_build row and the client has no blueprint id to ask for their icon with. The migration
* (dlu/mysql/98_modular_build_ids.sql, dlu/sqlite/81_modular_build_ids.sql) gives each what a new build gets
* (ModularBuildFinish) and what InventoryComponent gives one when its character loads: a persistent id as its subkey
* and a ugc_modular_build row with its modules and owner. Only modular builds have assemblyPartLOTs.
*/
namespace ModularBuildIdMigration {
struct NewBuild {
LWOOBJID id{};
std::string modules; // "1:8129+1:8130+...", as ugc_modular_build.ldf_config
};
// Gives every item of a character's saved XML with modules and no subkey the next id as its subkey; the builds to insert
std::vector<NewBuild> AssignIds(tinyxml2::XMLDocument& document, const std::function<LWOOBJID()>& nextId);
void Run();
};
#endif //!MODULARBUILDIDMIGRATION_H