Skip to content

Commit

Permalink
Resolve appearance name from visual item record
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Jan 7, 2024
1 parent 9efa478 commit 5663d32
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
35 changes: 27 additions & 8 deletions src/App/Extensions/GarmentOverride/Module.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Module.hpp"
#include "Red/Entity.hpp"
#include "Red/ResourcePath.hpp"
#include "Red/TweakDB.hpp"

namespace
{
Expand Down Expand Up @@ -152,14 +153,23 @@ void App::GarmentOverrideModule::ConfigureTags()

void App::GarmentOverrideModule::OnLoadAppearanceResource(Red::ItemFactoryRequest* aRequest)
{
Raw::ItemFactoryRequest::Entity entityWeak(aRequest);
Raw::ItemFactoryRequest::EntityTemplate templateToken(aRequest);
Raw::ItemFactoryRequest::AppearanceName appearanceName(aRequest);
auto& entityWeak = Raw::ItemFactoryRequest::Entity::Ref(aRequest);
auto& templateToken = Raw::ItemFactoryRequest::EntityTemplate::Ref(aRequest);
auto& appearanceName = Raw::ItemFactoryRequest::AppearanceName::Ref(aRequest);

if (!appearanceName)
{
auto itemRecord = Raw::ItemFactoryRequest::ItemRecord::Ptr(aRequest);
if (itemRecord)
{
appearanceName = Red::GetFlatValue<Red::CName>({itemRecord->recordID, ".appearanceName"});
}
}

if (PrepareDynamicAppearanceName(entityWeak, templateToken, appearanceName))
{
std::unique_lock _(s_mutex);
if (auto& entityState = s_stateManager->GetEntityState(entityWeak->instance))
if (auto& entityState = s_stateManager->GetEntityState(entityWeak.instance))
{
#ifndef NDEBUG
LogDebug("|{}| [event=LoadAppearanceResource entity={}]", ModuleName, entityState->GetName());
Expand All @@ -171,14 +181,23 @@ void App::GarmentOverrideModule::OnLoadAppearanceResource(Red::ItemFactoryReques

void App::GarmentOverrideModule::OnChangeAppearanceResource(Red::ItemFactoryAppearanceChangeRequest* aRequest)
{
Raw::ItemFactoryAppearanceChangeRequest::Entity entityWeak(aRequest);
Raw::ItemFactoryAppearanceChangeRequest::EntityTemplate templateToken(aRequest);
Raw::ItemFactoryAppearanceChangeRequest::AppearanceName appearanceName(aRequest);
auto& entityWeak = Raw::ItemFactoryAppearanceChangeRequest::Entity::Ref(aRequest);
auto& templateToken = Raw::ItemFactoryAppearanceChangeRequest::EntityTemplate::Ref(aRequest);
auto& appearanceName = Raw::ItemFactoryAppearanceChangeRequest::AppearanceName::Ref(aRequest);

if (!appearanceName)
{
auto itemRecord = Raw::ItemFactoryAppearanceChangeRequest::ItemRecord::Ptr(aRequest);
if (itemRecord)
{
appearanceName = Red::GetFlatValue<Red::CName>({itemRecord->recordID, ".appearanceName"});
}
}

if (PrepareDynamicAppearanceName(entityWeak, templateToken, appearanceName))
{
std::unique_lock _(s_mutex);
if (auto& entityState = s_stateManager->GetEntityState(entityWeak->instance))
if (auto& entityState = s_stateManager->GetEntityState(entityWeak.instance))
{
#ifndef NDEBUG
LogDebug("|{}| [event=ChangeAppearanceResource entity={}]", ModuleName, entityState->GetName());
Expand Down
2 changes: 1 addition & 1 deletion src/App/Project.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ constexpr auto Author = "psiberx";
constexpr auto NameW = L"ArchiveXL";
constexpr auto AuthorW = L"psiberx";

constexpr auto Version = semver::from_string_noexcept("1.10.2").value();
constexpr auto Version = semver::from_string_noexcept("1.10.3").value();
}
8 changes: 4 additions & 4 deletions src/App/Version.rc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define VER_PRODUCTVERSION 1,10,2,0
#define VER_FILEVERSION 1,10,2,2312102217
#define VER_PRODUCTVERSION 1,10,3,0
#define VER_FILEVERSION 1,10,3,2401070822

#define VER_PRODUCTNAME_STR "ArchiveXL\0"
#define VER_PRODUCTVERSION_STR "1.10.2\0"
#define VER_FILEVERSION_STR "1.10.2.2312102217\0"
#define VER_PRODUCTVERSION_STR "1.10.3\0"
#define VER_FILEVERSION_STR "1.10.3.2401070822\0"

1 VERSIONINFO
FILEVERSION VER_FILEVERSION
Expand Down
2 changes: 2 additions & 0 deletions src/Red/AppearanceChanger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ using Entity = Core::OffsetPtr<0x28, Red::WeakHandle<Red::Entity>>;
using EntityTemplate = Core::OffsetPtr<0x138, Red::ResourceTokenPtr<Red::EntityTemplate>>;
using AppearanceToken = Core::OffsetPtr<0x148, Red::ResourceTokenPtr<Red::AppearanceResource>>;
using AppearanceName = Core::OffsetPtr<0x158, Red::CName>;
using ItemRecord = Core::OffsetPtr<0x160, Red::gamedataTweakDBRecord*>;

constexpr auto LoadAppearance = Core::RawFunc<
/* addr = */ Red::Addresses::ItemFactoryRequest_LoadAppearance,
Expand All @@ -113,6 +114,7 @@ using Entity = Core::OffsetPtr<0x80, Red::WeakHandle<Red::Entity>>;
using EntityTemplate = Core::OffsetPtr<0xA8, Red::ResourceTokenPtr<Red::EntityTemplate>>;
using AppearanceToken = Core::OffsetPtr<0xB8, Red::ResourceTokenPtr<Red::AppearanceResource>>;
using AppearanceName = Core::OffsetPtr<0x48, Red::CName>;
using ItemRecord = Core::OffsetPtr<0x100, Red::gamedataTweakDBRecord*>;

constexpr auto LoadTemplate = Core::RawFunc<
/* addr = */ Red::Addresses::ItemFactoryAppearanceChangeRequest_LoadTemplate,
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_xmakever("2.5.9")

set_project("ArchiveXL")
set_version("1.10.2", {build = "%y%m%d%H%M"})
set_version("1.10.3", {build = "%y%m%d%H%M"})

set_arch("x64")
set_languages("cxx20", "cxx2a")
Expand Down

0 comments on commit 5663d32

Please sign in to comment.