Fix name reuse issues for actors, and make luprex IDs more readable
This commit is contained in:
@@ -107,7 +107,6 @@ public:
|
||||
|
||||
RunUnitTests() {
|
||||
world_.reset(new World(WORLD_TYPE_MASTER));
|
||||
stop_driver();
|
||||
rescan_lua_source(true);
|
||||
}
|
||||
|
||||
@@ -116,6 +115,7 @@ public:
|
||||
case AccessKind::INVOKE_LUA_SOURCE: {
|
||||
world_->update_source(datapk);
|
||||
world_->run_unittests();
|
||||
stop_driver();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -37,17 +37,19 @@
|
||||
//
|
||||
// THE NUMERIC RANGES
|
||||
//
|
||||
// The largest integer that can be stored losslessly in a lua_Number is:
|
||||
// Any 53-bit number can be losslessly stored in a lua_Number. In other
|
||||
// words, the largest integer that can be stored losslessly is:
|
||||
//
|
||||
// * 0x0020000000000000
|
||||
// * 0x001FFFFFFFFFFFFF
|
||||
//
|
||||
// In other words, any 53-bit number can be stored. We subdivide the range as
|
||||
// follows:
|
||||
// As it turns out, that's just barely larger than 9 quadrillion. We are
|
||||
// going to use IDs that are between 0 and 9 quadrillion. We divide the
|
||||
// range of possible IDs into several subsections:
|
||||
//
|
||||
// * 0x0000+ : manually created IDs.
|
||||
// * 0x0001+ : used by master model's IdGlobalPool to create batches.
|
||||
// * 0x0010+ : used by master model's IdGlobalPool to create individual IDs.
|
||||
// * 0x001E+ : used by sync model's IdGlobalPool to create individual IDs.
|
||||
// 0 quadrillion + : manually created IDs.
|
||||
// 1 quadrillion + : used by master model's IdGlobalPool to create batches.
|
||||
// 5 quadrillion + : used by master model's IdGlobalPool to create individual IDs.
|
||||
// 8 quadrillion + : used by sync model's IdGlobalPool to create individual IDs.
|
||||
//
|
||||
// If you exhaust the Master Model's invididual pool at a rate of 10,000,000 IDs
|
||||
// per second, the individual pool will last for 12 years.
|
||||
|
||||
@@ -393,7 +393,7 @@ LuaDefine(unittests_world3diffluatab, "", "some unit tests") {
|
||||
|
||||
// The data in the master model should now look like this:
|
||||
const char *expect_123 =
|
||||
"<tangible 123>{ "
|
||||
"<tan 123>{ "
|
||||
"bacon='crispy', "
|
||||
"inventory={ gold='wealthy' }, "
|
||||
"skills={ "
|
||||
@@ -402,7 +402,7 @@ LuaDefine(unittests_world3diffluatab, "", "some unit tests") {
|
||||
"} "
|
||||
"}";
|
||||
const char *expect_345 =
|
||||
"<tangible 345>{ "
|
||||
"<tan 345>{ "
|
||||
"inventory={ gold='poor' }, "
|
||||
"phone='867-5309' "
|
||||
"}";
|
||||
|
||||
Reference in New Issue
Block a user