Files
DarkflameServer/dDatabase/CDClientDatabase/CDClientTables/CDModularBuildComponentTable.h
Aaron Kimbrell b040058cc8 fix(ugc): give old cars and rockets a build id when a character loads
Cars and rockets built before builds were recorded have no subkey and no
ugc_modular_build row, so the client has no blueprint id to ask for their
icon with. When a character loads, such an item (a ModularBuildComponent
createdLOT with assemblyPartLOTs but no subkey) gets what a new build
gets: a persistent id as its subkey and a ugc_modular_build row with its
modules and owner. The next save keeps the subkey; nothing is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:31:14 -05:00

31 lines
1.2 KiB
C++

#pragma once
#include "CDTable.h"
#include "dCommonVars.h"
#include <optional>
#include <string_view>
// A modular build (rocket, car): ModularBuildComponent with what DLU needs from its xml
struct CDModularBuildComponent {
uint32_t id{};
int32_t buildType{};
LOT createdLOT{ LOT_NULL }; // the item the finished build becomes
uint32_t numberOfParts{}; // <topology><numberOfParts value>
LOT rootPartExampleLOT{ LOT_NULL }; // <Module><ExamplePartLOT> of the module whose PartCode is <rootPart value>
};
class CDModularBuildComponentTable : public CDTable<CDModularBuildComponentTable, std::vector<CDModularBuildComponent>> {
public:
void LoadValuesFromDatabase();
// The first build made of this many parts
std::optional<CDModularBuildComponent> GetByNumberOfParts(uint32_t numberOfParts) const;
// Whether a LOT is the item some build becomes (a car or rocket)
bool IsCreatedLot(LOT lot) const;
// Fills numberOfParts and rootPartExampleLOT from a ModularBuildComponent.xml
static void ParseXml(std::string_view xml, CDModularBuildComponent& build);
static std::optional<CDModularBuildComponent> FindByNumberOfParts(const std::vector<CDModularBuildComponent>& builds, uint32_t numberOfParts);
};