Added more tests to ordered list, and fixed bug when inserting at end of list as client
This commit is contained in:
parent
06079f80cd
commit
df7ec9cb99
3 changed files with 63 additions and 27 deletions
|
|
@ -507,34 +507,38 @@ void World::scale_up(const WorldScalar& scaleUpAmount) {
|
|||
#ifdef ENABLE_ORDERED_LIST_TEST
|
||||
void World::list_debug_test_update() {
|
||||
if(std::chrono::steady_clock::now() < (listDebugTestTimeStart + std::chrono::minutes(1))) {
|
||||
bool isInsert;
|
||||
if(listDebugTest->size() > 70)
|
||||
isInsert = false;
|
||||
else if(listDebugTest->size() < 20)
|
||||
isInsert = true;
|
||||
else
|
||||
isInsert = Random::get().real_range(0.0f, 1.0f) > 0.5f;
|
||||
if(nextSendTime < std::chrono::steady_clock::now() - std::chrono::milliseconds(300)) {
|
||||
nextSendTime = std::chrono::steady_clock::now();
|
||||
|
||||
using namespace NetworkingObjects;
|
||||
if(isInsert) {
|
||||
std::vector<std::pair<NetObjOrderedListIterator<uint16_t>, NetObjOwnerPtr<uint16_t>>> toInsert;
|
||||
std::vector<uint32_t> randomIndices;
|
||||
uint32_t insertAmount = Random::get().int_range(5, 25);
|
||||
for(uint32_t i = 0; i < insertAmount; i++)
|
||||
randomIndices.emplace_back(Random::get().int_range<uint32_t>(0, listDebugTest->size() + 10));
|
||||
randomIndices[1] = randomIndices[0];
|
||||
std::sort(randomIndices.begin(), randomIndices.end());
|
||||
for(uint32_t index : randomIndices)
|
||||
toInsert.emplace_back(listDebugTest->at(index), netObjMan.make_obj_direct<uint16_t>(Random::get().int_range<uint32_t>(10, 100)));
|
||||
listDebugTest->insert_ordered_list_and_send_create(listDebugTest, toInsert);
|
||||
}
|
||||
else {
|
||||
std::vector<NetObjOrderedListIterator<uint16_t>> toErase;
|
||||
for(uint32_t i = 0; i < listDebugTest->size(); i++) {
|
||||
if(Random::get().real_range(0.0f, 1.0f) > 0.8f)
|
||||
toErase.emplace_back(listDebugTest->at(i));
|
||||
bool isInsert;
|
||||
if(listDebugTest->size() > 70)
|
||||
isInsert = false;
|
||||
else if(listDebugTest->size() < 20)
|
||||
isInsert = true;
|
||||
else
|
||||
isInsert = Random::get().real_range(0.0f, 1.0f) > 0.5f;
|
||||
|
||||
using namespace NetworkingObjects;
|
||||
if(isInsert) {
|
||||
std::vector<std::pair<NetObjOrderedListIterator<uint16_t>, NetObjOwnerPtr<uint16_t>>> toInsert;
|
||||
std::vector<uint32_t> randomIndices;
|
||||
uint32_t insertAmount = Random::get().int_range(5, 25);
|
||||
for(uint32_t i = 0; i < insertAmount; i++)
|
||||
randomIndices.emplace_back(Random::get().int_range<uint32_t>(0, listDebugTest->size() + 10));
|
||||
randomIndices[1] = randomIndices[0];
|
||||
std::sort(randomIndices.begin(), randomIndices.end());
|
||||
for(uint32_t index : randomIndices)
|
||||
toInsert.emplace_back(listDebugTest->at(index), netObjMan.make_obj_direct<uint16_t>(Random::get().int_range<uint32_t>(10, 100)));
|
||||
listDebugTest->insert_ordered_list_and_send_create(listDebugTest, toInsert);
|
||||
}
|
||||
else {
|
||||
std::vector<NetObjOrderedListIterator<uint16_t>> toErase;
|
||||
for(uint32_t i = 0; i < listDebugTest->size(); i++) {
|
||||
if(Random::get().real_range(0.0f, 1.0f) > 0.8f)
|
||||
toErase.emplace_back(listDebugTest->at(i));
|
||||
}
|
||||
listDebugTest->erase_list(listDebugTest, toErase);
|
||||
}
|
||||
listDebugTest->erase_list(listDebugTest, toErase);
|
||||
}
|
||||
}
|
||||
if(netServer && netServer->get_client_list().empty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue