From 92cad2bc688bb9e2381cae5f94dbbbbdf198de49 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 5 Dec 2024 14:42:33 +0300 Subject: [PATCH] fix incorrect virtual inventory id in scripting --- src/items/Inventories.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/items/Inventories.cpp b/src/items/Inventories.cpp index d3af607d8..4d2baa36d 100644 --- a/src/items/Inventories.cpp +++ b/src/items/Inventories.cpp @@ -20,7 +20,9 @@ std::shared_ptr Inventories::create(size_t size) { std::shared_ptr Inventories::createVirtual(size_t size) { int64_t id; do { - id = -std::max(1LL, std::llabs(random.rand64())); + // lua does not support long integers because Number is floating-point + // type. Changing int_consumer to use 64 bit integer does not change anything + id = -std::max(1LL, std::llabs(random.rand64() % 1000'000'000)); } while (map.find(id) != map.end()); auto inv = std::make_shared(id, size);