Fix name reuse issues for actors, and make luprex IDs more readable
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <ostream>
|
||||
|
||||
|
||||
// This is used in some unit tests to make sure that the deque contains the expected values.
|
||||
static bool ranges_equal(const eng::deque<int64_t> &dq, int64_t a, int64_t b, int64_t c) {
|
||||
if (dq.size() != 3) return false;
|
||||
if (dq[0] != a) return false;
|
||||
@@ -27,14 +28,14 @@ IdGlobalPool::~IdGlobalPool() {
|
||||
|
||||
void IdGlobalPool::init_master() {
|
||||
salvaged_.clear();
|
||||
next_batch_ = 0x0001000000000000;
|
||||
next_id_ = 0x0010000000000000;
|
||||
next_batch_ = 1000000000000000;
|
||||
next_id_ = 5000000000000000;
|
||||
}
|
||||
|
||||
void IdGlobalPool::init_synch() {
|
||||
salvaged_.clear();
|
||||
next_batch_ = 0;
|
||||
next_id_ = 0x001E000000000000;
|
||||
next_id_ = 8000000000000000;
|
||||
}
|
||||
|
||||
int64_t IdGlobalPool::get_one() {
|
||||
@@ -260,7 +261,7 @@ eng::string IdPlayerPool::debug_string() const {
|
||||
}
|
||||
|
||||
static int64_t nthbatch(int64_t n) {
|
||||
return int64_t(0x0001000000000000) + n*256;
|
||||
return int64_t(1000000000000000) + n*256;
|
||||
}
|
||||
|
||||
LuaDefine(unittests_idalloc, "", "some unit tests") {
|
||||
@@ -272,15 +273,15 @@ LuaDefine(unittests_idalloc, "", "some unit tests") {
|
||||
|
||||
// Synchronous pools produce IDs starting at 0x001E000000000000
|
||||
gp.init_synch();
|
||||
LuaAssert(L, gp.get_one() == 0x001E000000000000);
|
||||
LuaAssert(L, gp.get_one() == 0x001E000000000001);
|
||||
LuaAssert(L, gp.get_one() == 0x001E000000000002);
|
||||
LuaAssert(L, gp.get_one() == 8000000000000000);
|
||||
LuaAssert(L, gp.get_one() == 8000000000000001);
|
||||
LuaAssert(L, gp.get_one() == 8000000000000002);
|
||||
|
||||
// Master pools produce IDs starting at 0x0010000000000000
|
||||
gp.init_master();
|
||||
LuaAssert(L, gp.get_one() == 0x0010000000000000);
|
||||
LuaAssert(L, gp.get_one() == 0x0010000000000001);
|
||||
LuaAssert(L, gp.get_one() == 0x0010000000000002);
|
||||
LuaAssert(L, gp.get_one() == 5000000000000000);
|
||||
LuaAssert(L, gp.get_one() == 5000000000000001);
|
||||
LuaAssert(L, gp.get_one() == 5000000000000002);
|
||||
|
||||
// Synchronous pools produce only null batches.
|
||||
gp.init_synch();
|
||||
@@ -329,7 +330,7 @@ LuaDefine(unittests_idalloc, "", "some unit tests") {
|
||||
pp.set_fifo_capacity(3);
|
||||
pp.refill();
|
||||
LuaAssert(L, pp.size() == 0);
|
||||
LuaAssert(L, pp.get_one() == 0x001E000000000000);
|
||||
LuaAssert(L, pp.get_one() == 8000000000000000);
|
||||
LuaAssert(L, pp.size() == 0);
|
||||
|
||||
// In the master model, with fifo disabled. Fifo should remain
|
||||
@@ -339,7 +340,7 @@ LuaDefine(unittests_idalloc, "", "some unit tests") {
|
||||
pp.set_fifo_capacity(0);
|
||||
pp.refill();
|
||||
LuaAssert(L, pp.size() == 0);
|
||||
LuaAssert(L, pp.get_one() == 0x0010000000000000);
|
||||
LuaAssert(L, pp.get_one() == 5000000000000000);
|
||||
LuaAssert(L, pp.size() == 0);
|
||||
|
||||
// Test refill from master (with enabled fifo).
|
||||
@@ -370,13 +371,13 @@ LuaDefine(unittests_idalloc, "", "some unit tests") {
|
||||
// Serialize and deserialize a global pool.
|
||||
gp.init_master();
|
||||
gpds.init_master();
|
||||
LuaAssert(L, gp.get_one() == 0x0010000000000000);
|
||||
LuaAssert(L, gp.get_one() == 5000000000000000);
|
||||
LuaAssert(L, gp.get_batch() == nthbatch(0));
|
||||
gp.salvage(nthbatch(182));
|
||||
gp.salvage(nthbatch(183));
|
||||
gp.serialize(&sb);
|
||||
gpds.deserialize(&sb);
|
||||
LuaAssert(L, gpds.get_one() == 0x0010000000000001);
|
||||
LuaAssert(L, gpds.get_one() == 5000000000000001);
|
||||
LuaAssert(L, gpds.get_batch() == nthbatch(183));
|
||||
LuaAssert(L, gpds.get_batch() == nthbatch(182));
|
||||
LuaAssert(L, gpds.get_batch() == nthbatch(1));
|
||||
|
||||
Reference in New Issue
Block a user