Skip to content

Commit

Permalink
feat: PipboyPrimitiveValue (#24)
Browse files Browse the repository at this point in the history
* feat: `PipboyPrimitiveValue` class.
  • Loading branch information
FlenarnTemp authored Nov 18, 2024
1 parent 74769a8 commit cc75a95
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
1 change: 1 addition & 0 deletions CommonLibF4/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ set(SOURCES
include/RE/Bethesda/PipboyMapData.h
include/RE/Bethesda/PipboyPerksData.h
include/RE/Bethesda/PipboyPlayerInfoData.h
include/RE/Bethesda/PipboyPrimitiveValue.h
include/RE/Bethesda/PipboyQuestData.h
include/RE/Bethesda/PipboyRadioData.h
include/RE/Bethesda/PipboySpecialData.h
Expand Down
72 changes: 72 additions & 0 deletions CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma once

#include "RE/Bethesda/PipboyValue.h"

namespace RE
{
template <class T>
class PipboyPrimitiveValue; // Forward declaration for specialization **only**

template <>
class __declspec(novtable) PipboyPrimitiveValue<std::uint32_t> : public PipboyValue
{
public:
virtual ~PipboyPrimitiveValue() {} // 00

// override
virtual void CleanDirtyToGame() override {} // 00
virtual void Serialize(Json::Value* a_json) override {} // 01
virtual void SerializeChanges(BSBinarySerializer& a_serializer, bool a_fullSerialization) override {} // 03
virtual SERIALIZATION_DATA_TYPE GetType() override { return SERIALIZATION_DATA_TYPE::kUint32; }

PipboyPrimitiveValue(std::uint32_t a_value, PipboyValue* a_parentValue)
: PipboyValue(a_parentValue), value(a_value) {}


void ctor(std::uint32_t a_value, PipboyValue* a_parentValue)
{
using func_t = decltype(&PipboyPrimitiveValue<std::uint32_t>::ctor);
REL::Relocation<func_t> func{ REL::ID(2225324) };
func(this, a_value, a_parentValue);
}

operator std::uint32_t() const {
return value;
}

// members
std::uint32_t value; // 18
};
static_assert(sizeof(PipboyPrimitiveValue<bool>) == 0x20);

template <>
class __declspec(novtable) PipboyPrimitiveValue<bool> : public PipboyValue
{
public:
virtual ~PipboyPrimitiveValue() {} // 00

// override
virtual void CleanDirtyToGame() override {} // 00
virtual void Serialize(Json::Value* a_json) override {} // 01
virtual void SerializeChanges(BSBinarySerializer& a_serializer, bool a_fullSerialization) override {} // 03
virtual SERIALIZATION_DATA_TYPE GetType() override { return SERIALIZATION_DATA_TYPE::kBool; }

PipboyPrimitiveValue(bool a_value, PipboyValue* a_parentValue)
: PipboyValue(a_parentValue), value(a_value) {}

void ctor(bool a_value, PipboyValue* a_parentValue)
{
using func_t = decltype(&PipboyPrimitiveValue<bool>::ctor);
REL::Relocation<func_t> func{ REL::ID(2225327) };
func(this, a_value, a_parentValue);
}

operator bool() const {
return value;
}

// members
bool value; // 18
};
static_assert(sizeof(PipboyPrimitiveValue<bool>) == 0x20);
}
14 changes: 13 additions & 1 deletion CommonLibF4/include/RE/Bethesda/PipboyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,26 @@ namespace RE
kObject = 0x8,
};

virtual ~PipboyValue(); // 00
virtual ~PipboyValue() = default; // 00

// add
virtual void CleanDirtyToGame(); // 01
virtual void Serialize(Json::Value* a_json) = 0; // 02
virtual void SerializeChanges(BSBinarySerializer& a_serializer, bool a_fullSerialize); // 03
virtual SERIALIZATION_DATA_TYPE GetType() = 0; // 04

PipboyValue(PipboyValue* a_parentValue)
{
ctor(a_parentValue);
};

void ctor(PipboyValue* a_parentValue)
{
using func_t = decltype(&PipboyValue::ctor);
REL::Relocation<func_t> func{ REL::ID(2225915) };
return func(this, a_parentValue);
}

// members
std::uint32_t id; // 08
bool isDirtyGame; // 0C
Expand Down
1 change: 1 addition & 0 deletions CommonLibF4/include/RE/Fallout.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
#include "RE/Bethesda/PipboyMapData.h"
#include "RE/Bethesda/PipboyPerksData.h"
#include "RE/Bethesda/PipboyPlayerInfoData.h"
#include "RE/Bethesda/PipboyPrimitiveValue.h"
#include "RE/Bethesda/PipboyQuestData.h"
#include "RE/Bethesda/PipboyRadioData.h"
#include "RE/Bethesda/PipboySpecialData.h"
Expand Down

0 comments on commit cc75a95

Please sign in to comment.