fix: Increase entity network limit to 16k entities (#1492)
This commit is contained in:
@@ -81,7 +81,7 @@ void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterva
|
|||||||
{
|
{
|
||||||
assert(false); // Entity already tracked
|
assert(false); // Entity already tracked
|
||||||
}
|
}
|
||||||
if( e->entityId >= 2048 )
|
if( e->entityId >= 16384 )
|
||||||
{
|
{
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,12 +147,12 @@ void ServerPlayer::flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFou
|
|||||||
{
|
{
|
||||||
*removedFound = true;
|
*removedFound = true;
|
||||||
// before this left 192 bytes uninitialized!!!!!
|
// before this left 192 bytes uninitialized!!!!!
|
||||||
memset(flags, 0, (2048 / 32) * sizeof(unsigned int));
|
memset(flags, 0, (16384 / 32) * sizeof(unsigned int));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int index : entitiesToRemove)
|
for(int index : entitiesToRemove)
|
||||||
{
|
{
|
||||||
if( index < 2048 )
|
if( index < 16384 )
|
||||||
{
|
{
|
||||||
unsigned int i = index / 32;
|
unsigned int i = index / 32;
|
||||||
unsigned int j = index % 32;
|
unsigned int j = index % 32;
|
||||||
|
|||||||
@@ -494,6 +494,7 @@ set(_MINECRAFT_SERVER_COMMON_ROOT
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/iob_shim.asm"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/iob_shim.asm"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/stdafx.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/stdafx.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/stubs.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/stubs.cpp"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.World/Entity.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.World/ConsoleSaveFileOriginal.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.World/ConsoleSaveFileOriginal.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.World/ConsoleSaveFileOriginal.h"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.World/ConsoleSaveFileOriginal.h"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/lce_filesystem/lce_filesystem.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../include/lce_filesystem/lce_filesystem.cpp"
|
||||||
|
|||||||
@@ -27,13 +27,17 @@
|
|||||||
|
|
||||||
const wstring Entity::RIDING_TAG = L"Riding";
|
const wstring Entity::RIDING_TAG = L"Riding";
|
||||||
|
|
||||||
int Entity::entityCounter = 2048; // 4J - changed initialiser to 2048, as we are using range 0 - 2047 as special unique smaller ids for things that need network tracked
|
//int Entity::entityCounter = 2048; // 4J - changed initialiser to 2048, as we are using range 0 - 2047 as special unique smaller ids for things that need network tracked
|
||||||
|
int Entity::entityCounter = 16384; //now using full range of 0 - 16383, limit is 32k but we shouldnt need that yet
|
||||||
DWORD Entity::tlsIdx = TlsAlloc();
|
DWORD Entity::tlsIdx = TlsAlloc();
|
||||||
|
|
||||||
// 4J - added getSmallId & freeSmallId methods
|
// 4J - added getSmallId & freeSmallId methods
|
||||||
unsigned int Entity::entityIdUsedFlags[2048/32] = {0};
|
//unsigned int Entity::entityIdUsedFlags[2048/32] = {0};
|
||||||
unsigned int Entity::entityIdWanderFlags[2048/32] = {0};
|
//unsigned int Entity::entityIdWanderFlags[2048/32] = {0};
|
||||||
unsigned int Entity::entityIdRemovingFlags[2048/32] = {0};
|
//unsigned int Entity::entityIdRemovingFlags[2048/32] = {0};
|
||||||
|
unsigned int Entity::entityIdUsedFlags[16384/32] = {0};
|
||||||
|
unsigned int Entity::entityIdWanderFlags[16384/32] = {0};
|
||||||
|
unsigned int Entity::entityIdRemovingFlags[16384/32] = {0};
|
||||||
int Entity::extraWanderIds[EXTRA_WANDER_MAX] = {0};
|
int Entity::extraWanderIds[EXTRA_WANDER_MAX] = {0};
|
||||||
int Entity::extraWanderTicks = 0;
|
int Entity::extraWanderTicks = 0;
|
||||||
int Entity::extraWanderCount = 0;
|
int Entity::extraWanderCount = 0;
|
||||||
@@ -65,7 +69,7 @@ int Entity::getSmallId()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < (2048 / 32 ); i++ )
|
for( int i = 0; i < (16384 / 32 ); i++ )
|
||||||
{
|
{
|
||||||
unsigned int uiFlags = *puiUsedFlags;
|
unsigned int uiFlags = *puiUsedFlags;
|
||||||
if( uiFlags != 0xffffffff )
|
if( uiFlags != 0xffffffff )
|
||||||
@@ -102,7 +106,7 @@ int Entity::getSmallId()
|
|||||||
|
|
||||||
if (entityCounter == 0x7ffffff)
|
if (entityCounter == 0x7ffffff)
|
||||||
{
|
{
|
||||||
entityCounter = 2048;
|
entityCounter = 16384;
|
||||||
}
|
}
|
||||||
return fallbackId;
|
return fallbackId;
|
||||||
#else
|
#else
|
||||||
@@ -116,7 +120,7 @@ void Entity::countFlagsForPIX()
|
|||||||
{
|
{
|
||||||
int freecount = 0;
|
int freecount = 0;
|
||||||
unsigned int *puiUsedFlags = entityIdUsedFlags;
|
unsigned int *puiUsedFlags = entityIdUsedFlags;
|
||||||
for( int i = 0; i < (2048 / 32 ); i++ )
|
for( int i = 0; i < (16384 / 32 ); i++ )
|
||||||
{
|
{
|
||||||
unsigned int uiFlags = *puiUsedFlags;
|
unsigned int uiFlags = *puiUsedFlags;
|
||||||
if( uiFlags != 0xffffffff )
|
if( uiFlags != 0xffffffff )
|
||||||
@@ -134,7 +138,7 @@ void Entity::countFlagsForPIX()
|
|||||||
puiUsedFlags++;
|
puiUsedFlags++;
|
||||||
}
|
}
|
||||||
PIXAddNamedCounter(freecount,"Small Ids free");
|
PIXAddNamedCounter(freecount,"Small Ids free");
|
||||||
PIXAddNamedCounter(2048 - freecount,"Small Ids used");
|
PIXAddNamedCounter(16384 - freecount,"Small Ids used");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::resetSmallId()
|
void Entity::resetSmallId()
|
||||||
@@ -149,7 +153,7 @@ void Entity::resetSmallId()
|
|||||||
void Entity::freeSmallId(int index)
|
void Entity::freeSmallId(int index)
|
||||||
{
|
{
|
||||||
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread
|
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread
|
||||||
if( index >= 2048 ) return; // Don't do anything if this isn't a short id
|
if( index >= 16384 ) return; // Don't do anything if this isn't a short id
|
||||||
|
|
||||||
unsigned int i = index / 32;
|
unsigned int i = index / 32;
|
||||||
unsigned int j = index % 32;
|
unsigned int j = index % 32;
|
||||||
@@ -172,7 +176,7 @@ void Entity::useSmallIds()
|
|||||||
void Entity::considerForExtraWandering(bool enable)
|
void Entity::considerForExtraWandering(bool enable)
|
||||||
{
|
{
|
||||||
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread
|
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread
|
||||||
if( entityId >= 2048 ) return; // Don't do anything if this isn't a short id
|
if( entityId >= 16384 ) return; // Don't do anything if this isn't a short id
|
||||||
|
|
||||||
unsigned int i = entityId / 32;
|
unsigned int i = entityId / 32;
|
||||||
unsigned int j = entityId % 32;
|
unsigned int j = entityId % 32;
|
||||||
@@ -192,7 +196,7 @@ void Entity::considerForExtraWandering(bool enable)
|
|||||||
bool Entity::isExtraWanderingEnabled()
|
bool Entity::isExtraWanderingEnabled()
|
||||||
{
|
{
|
||||||
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread
|
if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread
|
||||||
if( entityId >= 2048 ) return false; // Don't do anything if this isn't a short id
|
if( entityId >= 16384 ) return false; // Don't do anything if this isn't a short id
|
||||||
|
|
||||||
for( int i = 0; i < extraWanderCount; i++ )
|
for( int i = 0; i < extraWanderCount; i++ )
|
||||||
{
|
{
|
||||||
@@ -224,12 +228,12 @@ void Entity::tickExtraWandering()
|
|||||||
int entityId = 0;
|
int entityId = 0;
|
||||||
if( extraWanderCount )
|
if( extraWanderCount )
|
||||||
{
|
{
|
||||||
entityId = ( extraWanderIds[ extraWanderCount - 1 ] + 1 ) % 2048;
|
entityId = ( extraWanderIds[ extraWanderCount - 1 ] + 1 ) % 16384;
|
||||||
}
|
}
|
||||||
|
|
||||||
extraWanderCount = 0;
|
extraWanderCount = 0;
|
||||||
|
|
||||||
for( int k = 0; ( k < 2048 ) && ( extraWanderCount < EXTRA_WANDER_MAX); k++ )
|
for( int k = 0; ( k < 16384 ) && ( extraWanderCount < EXTRA_WANDER_MAX); k++ )
|
||||||
{
|
{
|
||||||
unsigned int i = entityId / 32;
|
unsigned int i = entityId / 32;
|
||||||
unsigned int j = entityId % 32;
|
unsigned int j = entityId % 32;
|
||||||
@@ -241,7 +245,7 @@ void Entity::tickExtraWandering()
|
|||||||
// printf("%d, ", entityId);
|
// printf("%d, ", entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
entityId = ( entityId + 1 ) % 2048;
|
entityId = ( entityId + 1 ) % 16384;
|
||||||
}
|
}
|
||||||
// printf("\n");
|
// printf("\n");
|
||||||
}
|
}
|
||||||
@@ -261,7 +265,7 @@ void Entity::_init(bool useSmallId, Level *level)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
entityId = Entity::entityCounter++;
|
entityId = Entity::entityCounter++;
|
||||||
if(entityCounter == 0x7ffffff ) entityCounter = 2048;
|
if(entityCounter == 0x7ffffff ) entityCounter = 16384;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewScale = 1.0;
|
viewScale = 1.0;
|
||||||
|
|||||||
@@ -382,9 +382,12 @@ private:
|
|||||||
|
|
||||||
int getSmallId();
|
int getSmallId();
|
||||||
void freeSmallId(int index);
|
void freeSmallId(int index);
|
||||||
static unsigned int entityIdUsedFlags[2048/32];
|
//static unsigned int entityIdUsedFlags[2048/32];
|
||||||
static unsigned int entityIdWanderFlags[2048/32];
|
//static unsigned int entityIdWanderFlags[2048/32];
|
||||||
static unsigned int entityIdRemovingFlags[2048/32];
|
//static unsigned int entityIdRemovingFlags[2048/32];
|
||||||
|
static unsigned int entityIdUsedFlags[16384/32];
|
||||||
|
static unsigned int entityIdWanderFlags[16384/32];
|
||||||
|
static unsigned int entityIdRemovingFlags[16384/32];
|
||||||
static int extraWanderIds[EXTRA_WANDER_MAX];
|
static int extraWanderIds[EXTRA_WANDER_MAX];
|
||||||
static int extraWanderCount;
|
static int extraWanderCount;
|
||||||
static int extraWanderTicks;
|
static int extraWanderTicks;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void MoveEntityPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
|
void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ MoveEntityPacketSmall::MoveEntityPacketSmall()
|
|||||||
|
|
||||||
MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
|
MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
@@ -42,7 +42,7 @@ void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
|
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
@@ -99,7 +99,7 @@ void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOExcept
|
|||||||
|
|
||||||
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
|
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
@@ -138,7 +138,7 @@ void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException
|
void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
@@ -176,7 +176,7 @@ void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
|
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
if( (id < 0 ) || (id >= 2048 ) )
|
if( (id < 0 ) || (id >= 16384 ) )
|
||||||
{
|
{
|
||||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
|
|||||||
Reference in New Issue
Block a user