Skip to content

Commit

Permalink
Merge pull request #931 from psiberx/master
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
maximegmd committed Mar 1, 2024
2 parents 187594c + d685ab1 commit 2cbee2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/reverse/Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ constexpr uint32_t CInitializationState_OnTick = 2447710505UL;
constexpr uint32_t CPatches_BoundaryTeleport = 887623293UL;
constexpr uint32_t CPatches_IntroMovie = 4056423627UL;
constexpr uint32_t CPatches_Vignette = 1592528795UL;
constexpr uint32_t CPatches_OptionsInit = 2920158527UL;
constexpr uint32_t CPatches_OptionsInit = 4089777341UL; // Config::IConfigVar::Register
#pragma endregion

#pragma region CPhotoMode
constexpr uint32_t CPhotoMode_SetRecordID = 2826047827UL;
constexpr uint32_t CPhotoMode_SetRecordID = 4052428712UL;
#pragma endregion

#pragma region CRenderGlobal
Expand Down
12 changes: 3 additions & 9 deletions src/reverse/ResourceAsyncReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ ResourceAsyncReference::ResourceAsyncReference(

uint64_t ResourceAsyncReference::Hash(const std::string& aPath)
{
// Should probably be moved to RED4ext.SDK after fixing RED4ext::RaRef
// Needs normalization
// 1) all lower case
// 2) / becomes \
// 3) /\/\\ becomes \
return RED4ext::FNV1a64(aPath.c_str());
return RED4ext::ResourcePath(aPath.c_str());
}

RED4ext::ScriptInstance ResourceAsyncReference::GetHandle() const
{
return const_cast<RED4ext::ResourceAsyncReference<void>*>(&m_reference);
return nullptr;
}

RED4ext::ScriptInstance ResourceAsyncReference::GetValuePtr() const
Expand All @@ -46,7 +40,7 @@ sol::object ResourceAsyncReference::GetLuaHash() const

RED4ext::CStackType stackType;
stackType.type = s_uint64Type;
stackType.value = GetHandle();
stackType.value = const_cast<RED4ext::ResourceAsyncReference<void>*>(&m_reference);

return Converter::ToLua(stackType, lockedState);
}
20 changes: 5 additions & 15 deletions src/scripting/GameOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ void GameOptions::Set(const std::string& category, const std::string& name, cons
return;

const auto consoleLogger = spdlog::get("scripting");
if (option->Set(value))
consoleLogger->info(option->GetInfo());
else
if (!option->Set(value))
{
if (option->GetType() == GameOption::kString)
consoleLogger->error("Failed to set game option '{}/{}', can't set string options right now.", category, name);
Expand All @@ -238,9 +236,7 @@ void GameOptions::SetBool(const std::string& category, const std::string& name,
return;

const auto consoleLogger = spdlog::get("scripting");
if (option->SetBool(value))
consoleLogger->info(option->GetInfo());
else
if (!option->SetBool(value))
{
if (option->GetType() != GameOption::kBoolean)
consoleLogger->error("Failed to set game option '{}/{}', not a boolean.", category, name);
Expand All @@ -256,9 +252,7 @@ void GameOptions::SetInt(const std::string& category, const std::string& name, i
return;

const auto consoleLogger = spdlog::get("scripting");
if (option->SetInt(value))
consoleLogger->info(option->GetInfo());
else
if (!option->SetInt(value))
{
if (option->GetType() != GameOption::kInteger && option->GetType() != GameOption::kColor)
consoleLogger->error("Failed to set game option '{}/{}', not an integer.", category, name);
Expand All @@ -274,9 +268,7 @@ void GameOptions::SetFloat(const std::string& category, const std::string& name,
return;

const auto consoleLogger = spdlog::get("scripting");
if (option->SetFloat(value))
consoleLogger->info(option->GetInfo());
else
if (!option->SetFloat(value))
{
if (option->GetType() != GameOption::kFloat)
consoleLogger->error("Failed to set game option '{}/{}', not a float.", category, name);
Expand All @@ -292,9 +284,7 @@ void GameOptions::Toggle(const std::string& category, const std::string& name)
return;

const auto consoleLogger = spdlog::get("scripting");
if (option->Toggle())
consoleLogger->info(option->GetInfo());
else
if (!option->Toggle())
{
if (option->GetType() != GameOption::kBoolean)
consoleLogger->error("Failed to set game option '{}/{}', not a boolean.", category, name);
Expand Down

0 comments on commit 2cbee2c

Please sign in to comment.