Skip to content

Commit

Permalink
Merge pull request #5 from powerof3/master
Browse files Browse the repository at this point in the history
merge upstream changes
  • Loading branch information
shad0wshayd3 authored May 4, 2024
2 parents b600303 + ea2381f commit 9e9111f
Show file tree
Hide file tree
Showing 61 changed files with 3,020 additions and 642 deletions.
10 changes: 9 additions & 1 deletion CommonLibF4/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(SOURCES
include/RE/Bethesda/BGSSynchronizedAnimationManager.h
include/RE/Bethesda/BGSTextureSet.h
include/RE/Bethesda/BSAnimationGraph.h
include/RE/Bethesda/BSAttachTechniques.h
include/RE/Bethesda/BSAudioManager.h
include/RE/Bethesda/BSAudioUtil.h
include/RE/Bethesda/BSBTreeFile.h
Expand All @@ -40,6 +41,7 @@ set(SOURCES
include/RE/Bethesda/BSExtraData.h
include/RE/Bethesda/BSFadeNode.h
include/RE/Bethesda/BSFixedString.h
include/RE/Bethesda/BSGeometry.h
include/RE/Bethesda/BSGraphics.h
include/RE/Bethesda/BSHavok.h
include/RE/Bethesda/BSInputDeviceManager.h
Expand Down Expand Up @@ -121,6 +123,8 @@ set(SOURCES
include/RE/Bethesda/BSScriptUtil.h
include/RE/Bethesda/BSSemaphore.h
include/RE/Bethesda/BSShader.h
include/RE/Bethesda/BSShaderMaterial.h
include/RE/Bethesda/BSShaderProperty.h
include/RE/Bethesda/BSSoundHandle.h
include/RE/Bethesda/BSSpring.h
include/RE/Bethesda/BSStorage.h
Expand All @@ -146,11 +150,12 @@ set(SOURCES
include/RE/Bethesda/BSTSmartPointer.h
include/RE/Bethesda/BSTTuple.h
include/RE/Bethesda/BSTempEffect.h
include/RE/Bethesda/BSTempEffectDebris.h
include/RE/Bethesda/BSTextureDB.h
include/RE/Bethesda/BSTextureSet.h
include/RE/Bethesda/BSTextureStreamer.h
include/RE/Bethesda/BSThread.h
include/RE/Bethesda/BSTimer.h
include/RE/Bethesda/BSVisit.h
include/RE/Bethesda/CELLJobs.h
include/RE/Bethesda/CRC.h
include/RE/Bethesda/Calendar.h
Expand Down Expand Up @@ -193,12 +198,14 @@ set(SOURCES
include/RE/Bethesda/PowerUtils.h
include/RE/Bethesda/ProcessLists.h
include/RE/Bethesda/Projectiles.h
include/RE/Bethesda/ReferenceEffectController.h
include/RE/Bethesda/SCRIPT_OUTPUT.h
include/RE/Bethesda/SDirectory2.h
include/RE/Bethesda/SWFToCodeFunctionHandler.h
include/RE/Bethesda/Script.h
include/RE/Bethesda/SendHUDMessage.h
include/RE/Bethesda/Settings.h
include/RE/Bethesda/Sky.h
include/RE/Bethesda/SplineUtils.h
include/RE/Bethesda/TESBoundAnimObjects.h
include/RE/Bethesda/TESBoundObjects.h
Expand Down Expand Up @@ -361,6 +368,7 @@ set(SOURCES
src/RE/Bethesda/BSScript/StructTypeInfo.cpp
src/RE/Bethesda/BSScript/TypeInfo.cpp
src/RE/Bethesda/BSScript/Variable.cpp
src/RE/Bethesda/BSVisit.cpp
src/RE/Bethesda/CRC.cpp
src/RE/Bethesda/Calendar.cpp
src/RE/Bethesda/FormComponents.cpp
Expand Down
54 changes: 54 additions & 0 deletions CommonLibF4/include/F4SE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,60 @@ namespace F4SE
return to;
}
}

[[nodiscard]] inline auto utf8_to_utf16(std::string_view a_in) noexcept
-> std::optional<std::wstring>
{
const auto cvt = [&](wchar_t* a_dst, std::size_t a_length) {
return WinAPI::MultiByteToWideChar(
WinAPI::CP_UTF8,
0,
a_in.data(),
static_cast<int>(a_in.length()),
a_dst,
static_cast<int>(a_length));
};

const auto len = cvt(nullptr, 0);
if (len == 0) {
return std::nullopt;
}

std::wstring out(len, '\0');
if (cvt(out.data(), out.length()) == 0) {
return std::nullopt;
}

return out;
}

[[nodiscard]] inline auto utf16_to_utf8(std::wstring_view a_in) noexcept
-> std::optional<std::string>
{
const auto cvt = [&](char* a_dst, std::size_t a_length) {
return WinAPI::WideCharToMultiByte(
WinAPI::CP_UTF8,
0,
a_in.data(),
static_cast<int>(a_in.length()),
a_dst,
static_cast<int>(a_length),
nullptr,
nullptr);
};

const auto len = cvt(nullptr, 0);
if (len == 0) {
return std::nullopt;
}

std::string out(len, '\0');
if (cvt(out.data(), out.length()) == 0) {
return std::nullopt;
}

return out;
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions CommonLibF4/include/F4SE/Impl/WinAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace F4SE::WinAPI
{
inline constexpr auto CP_UTF8{ static_cast<unsigned int>(65001) };
inline constexpr auto MAX_PATH{ 260u };
inline constexpr auto(MEM_RELEASE){ static_cast<std::uint32_t>(0x00008000) };
inline constexpr auto(PAGE_EXECUTE_READWRITE){ static_cast<std::uint32_t>(0x40) };

Expand Down Expand Up @@ -85,6 +87,14 @@ namespace F4SE::WinAPI
const wchar_t* a_caption,
unsigned int a_type) noexcept;

[[nodiscard]] int(MultiByteToWideChar)(
unsigned int a_codePage,
std::uint32_t a_flags,
const char* a_multiByteStr,
int a_multiByte,
wchar_t* a_wideCharStr,
int a_wideChar);

void(OutputDebugString)(
const char* a_outputString) noexcept;

Expand Down Expand Up @@ -123,6 +133,16 @@ namespace F4SE::WinAPI
std::size_t a_size,
std::uint32_t a_newProtect,
std::uint32_t* a_oldProtect) noexcept;

[[nodiscard]] int(WideCharToMultiByte)(
unsigned int a_codePage,
std::uint32_t a_flags,
const wchar_t* a_wideCharStr,
int a_wideChar,
char* a_multiByteStr,
int a_multiByte,
const char* a_defaultChar,
int* a_usedDefaultChar);
}

namespace RE
Expand Down
76 changes: 32 additions & 44 deletions CommonLibF4/include/RE/Bethesda/ActiveEffect.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "RE/Bethesda/BSSoundHandle.h"
#include "RE/Bethesda/ReferenceEffectController.h"
#include "RE/Bethesda/TESForms.h"

namespace RE
Expand All @@ -8,18 +10,14 @@ namespace RE
class EffectItem;
class MagicItem;
class MagicTarget;
class ReferenceEffect;
class TESForm;
class TESObjectREFR;

class ActiveEffectReferenceEffectController
namespace MagicSystem
{
public:
virtual ~ActiveEffectReferenceEffectController();

// void ** _vtbl; // 00
ActiveEffect* effect; // 08
// possibly more
};
enum class CastingSource;
}

class __declspec(novtable) ActiveEffect :
public BSIntrusiveRefCounted
Expand All @@ -29,13 +27,6 @@ namespace RE
static constexpr auto VTABLE{ VTABLE::ActiveEffect };
static constexpr auto FORM_ID{ ENUM_FORM_ID::kActiveEffect };

bool CheckDisplacementSpellOnTarget()
{
using func_t = decltype(&ActiveEffect::CheckDisplacementSpellOnTarget);
REL::Relocation<func_t> func{ REL::ID(1415178) };
return func(this);
}

enum class Flags : std::uint32_t
{
kNone = 0,
Expand Down Expand Up @@ -63,34 +54,31 @@ namespace RE

virtual ~ActiveEffect();

// void ** _vtbl; // 00
ActiveEffectReferenceEffectController controller;
std::int32_t unk20;
float unk24;
float unk28;
float unk2C;
std::int32_t unk30;
std::int8_t unk34;
std::int8_t pad35[3];
ObjectRefHandle target;
std::int32_t unk3C;
void* niNode;
MagicItem* item;
EffectItem* effect; // 50
MagicTarget* magicTarget;
TESForm* sourceItem;
std::int64_t unk68;
std::int64_t unk70;
float elapsed;
float duration;
float magnitude;
stl::enumeration<Flags, std::uint32_t> flags;
stl::enumeration<ConditionStatus, std::uint32_t> conditionStatus;
std::uint32_t uniqueID;
std::int32_t unk90;
std::int32_t pad94;
std::int32_t actorValue;
std::int32_t unk9C;
std::int64_t unkA0;
bool CheckDisplacementSpellOnTarget()
{
using func_t = decltype(&ActiveEffect::CheckDisplacementSpellOnTarget);
REL::Relocation<func_t> func{ REL::ID(1415178) };
return func(this);
}

// members
ActiveEffectReferenceEffectController hitEffectController; // 0C
BSSoundHandle persistentSound; // 30
ActorHandle caster; // 38
NiPointer<NiNode> sourceNode; // 40
MagicItem* spell; // 48
EffectItem* effect; // 50
MagicTarget* target; // 58
TESBoundObject* source; // 60
BSSimpleList<ReferenceEffect*>* hitEffects; // 68
MagicItem* displacementSpell; // 70
float elapsedSeconds; // 74
float duration; // 78
float magnitude; // 7C
stl::enumeration<Flags, std::uint32_t> flags; // 80
stl::enumeration<ConditionStatus, std::uint32_t> conditionStatus; // 84
std::uint16_t uniqueID; // 8C
stl::enumeration<MagicSystem::CastingSource, std::uint32_t> castingSource; // 90
};
static_assert(sizeof(ActiveEffect) == 0x98);
}
Loading

0 comments on commit 9e9111f

Please sign in to comment.