CharmedBaryon / CommonLibSSE-NG

This is a reverse engineered library for Skyrim Special Edition and Skyrim VR.
MIT License
142 stars 32 forks source link

Unresolved externals with `RE::ExtraRadius` #74

Open gememe opened 1 year ago

gememe commented 1 year ago

Trying to create a new RE::ExtraRadius results in 3 unresolved externals. ExtraRadius.cpp seems to be missing.

auto xRadius = new RE::ExtraRadius();
error LNK2019: unresolved external symbol "public: virtual __cdecl RE::ExtraRadius::~ExtraRadius(void)" (??1ExtraRadius@RE@@UEAA@XZ) referenced in function "public: virtual void * __cdecl RE::ExtraRadius::`scalar deleting destructor'(unsigned int)" (??_GExtraRadius@RE@@UEAAPEAXI@Z)
error LNK2001: unresolved external symbol "public: virtual enum RE::ExtraDataType __cdecl RE::ExtraRadius::GetType(void)const " (?GetType@ExtraRadius@RE@@UEBA?AW4ExtraDataType@2@XZ)
error LNK2001: unresolved external symbol "public: virtual bool __cdecl RE::ExtraRadius::IsNotEqual(class RE::BSExtraData const *)const " (?IsNotEqual@ExtraRadius@RE@@UEBA_NPEBVBSExtraData@2@@Z)

fatal error LNK1120: 3 unresolved externals
CustomPhase commented 1 year ago

@gememe I think we're meant to create extra data via RE::BSExtraData::Create\<T> method, i.e.:

auto newExtra = RE::BSExtraData::Create<RE::ExtraRadius>();

UPD: Just checked - it still doesnt work for ExtraRadius (and plenty of other Extra data types), just makes the game crash.

gememe commented 1 year ago

As a workaround, it's easy enough to just complete the definition of the constructor directly in the header file, like so:

ExtraRadius() : ExtraRadius(0) {}
ExtraRadius(float a_radius) : BSExtraData(), radius(a_radius), pad14(0) { stl::emplace_vtable(this); }
ExtraDataType GetType() const override { return ExtraDataType::kRadius; };
bool IsNotEqual(const BSExtraData* a_rhs) const override {
    auto rhs = static_cast<const ExtraRadius*>(a_rhs);
    return radius != rhs->radius;
};

Then, the the following works:

xRadius = new RE::ExtraRadius();
ref->extraList.Add(xRadius);