aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 10:59:08 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 10:59:08 +0200
commite7fa2439c8f328ab146037628bce30894e36a32c (patch)
tree12676776098fc8a737d4917251391d0c37cef906 /src
parent40d6d3f59de802c6e2187540eb654248a5affc30 (diff)
downloadlanes-e7fa2439c8f328ab146037628bce30894e36a32c.tar.gz
lanes-e7fa2439c8f328ab146037628bce30894e36a32c.tar.bz2
lanes-e7fa2439c8f328ab146037628bce30894e36a32c.zip
Unify the value returned by linda:deep() and the string conversion of an unnamed Linda
Diffstat (limited to 'src')
-rw-r--r--src/linda.cpp4
-rw-r--r--src/linda.h7
2 files changed, 9 insertions, 2 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index 81926f9..4dc2162 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -87,7 +87,7 @@ template <bool OPT>
87 std::ignore = luaG_pushstring(L_, _lindaName); 87 std::ignore = luaG_pushstring(L_, _lindaName);
88 } else { 88 } else {
89 // obfuscate the pointer so that we can't read the value with our eyes out of a script 89 // obfuscate the pointer so that we can't read the value with our eyes out of a script
90 std::ignore = luaG_pushstring(L_, "%p", std::bit_cast<uintptr_t>(_linda) ^ kConfigRegKey.storage); 90 std::ignore = luaG_pushstring(L_, "%p", _linda->obfuscated());
91 } 91 }
92 lua_concat(L_, 2); 92 lua_concat(L_, 2);
93 return 1; 93 return 1;
@@ -344,7 +344,7 @@ LUAG_FUNC(linda_count)
344LUAG_FUNC(linda_deep) 344LUAG_FUNC(linda_deep)
345{ 345{
346 Linda* const _linda{ ToLinda<false>(L_, 1) }; 346 Linda* const _linda{ ToLinda<false>(L_, 1) };
347 lua_pushlightuserdata(L_, _linda); // just the address 347 lua_pushlightuserdata(L_, _linda->obfuscated<void*>()); // just the address
348 return 1; 348 return 1;
349} 349}
350 350
diff --git a/src/linda.h b/src/linda.h
index 3098161..6901a86 100644
--- a/src/linda.h
+++ b/src/linda.h
@@ -80,6 +80,13 @@ class Linda
80 [[nodiscard]] Keeper* acquireKeeper() const; 80 [[nodiscard]] Keeper* acquireKeeper() const;
81 [[nodiscard]] std::string_view getName() const; 81 [[nodiscard]] std::string_view getName() const;
82 [[nodiscard]] bool inKeeperOperation() const { return keeperOperationCount.load(std::memory_order_seq_cst) != 0; } 82 [[nodiscard]] bool inKeeperOperation() const { return keeperOperationCount.load(std::memory_order_seq_cst) != 0; }
83 template <typename T = uintptr_t>
84 [[nodiscard]] T obfuscated() const
85 {
86 // xxh64 of string "kObfuscator" generated at https://www.pelock.com/products/hash-calculator
87 static constexpr UniqueKey kObfuscator{ 0x7B8AA1F99A3BD782ull };
88 return std::bit_cast<T>(std::bit_cast<uintptr_t>(this) ^ kObfuscator.storage);
89 };
83 void releaseKeeper(Keeper* keeper_) const; 90 void releaseKeeper(Keeper* keeper_) const;
84 [[nodiscard]] static int ProtectedCall(lua_State* L_, lua_CFunction f_); 91 [[nodiscard]] static int ProtectedCall(lua_State* L_, lua_CFunction f_);
85 [[nodiscard]] KeeperOperationInProgress startKeeperOperation(lua_State* const L_) { return KeeperOperationInProgress{ *this, L_ }; }; 92 [[nodiscard]] KeeperOperationInProgress startKeeperOperation(lua_State* const L_) { return KeeperOperationInProgress{ *this, L_ }; };