Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Minecraft.Client/EntityTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterva
{
assert(false); // Entity already tracked
}
if( e->entityId >= 2048 )
if( e->entityId >= 16384 )
{
__debugbreak();
}
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/ServerPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ void ServerPlayer::flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFou
{
*removedFound = true;
// 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)
{
if( index < 2048 )
if( index < 16384 )
{
unsigned int i = index / 32;
unsigned int j = index % 32;
Expand Down
1 change: 1 addition & 0 deletions Minecraft.Server/cmake/sources/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ set(_MINECRAFT_SERVER_COMMON_ROOT
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/iob_shim.asm"
"${CMAKE_CURRENT_SOURCE_DIR}/../Minecraft.Client/stdafx.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.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../include/lce_filesystem/lce_filesystem.cpp"
Expand Down
34 changes: 19 additions & 15 deletions Minecraft.World/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@

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();

// 4J - added getSmallId & freeSmallId methods
unsigned int Entity::entityIdUsedFlags[2048/32] = {0};
unsigned int Entity::entityIdWanderFlags[2048/32] = {0};
unsigned int Entity::entityIdRemovingFlags[2048/32] = {0};
//unsigned int Entity::entityIdUsedFlags[2048/32] = {0};
//unsigned int Entity::entityIdWanderFlags[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::extraWanderTicks = 0;
int Entity::extraWanderCount = 0;
Expand Down Expand Up @@ -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;
if( uiFlags != 0xffffffff )
Expand Down Expand Up @@ -102,7 +106,7 @@ int Entity::getSmallId()

if (entityCounter == 0x7ffffff)
{
entityCounter = 2048;
entityCounter = 16384;
}
return fallbackId;
#else
Expand All @@ -116,7 +120,7 @@ void Entity::countFlagsForPIX()
{
int freecount = 0;
unsigned int *puiUsedFlags = entityIdUsedFlags;
for( int i = 0; i < (2048 / 32 ); i++ )
for( int i = 0; i < (16384 / 32 ); i++ )
{
unsigned int uiFlags = *puiUsedFlags;
if( uiFlags != 0xffffffff )
Expand All @@ -134,7 +138,7 @@ void Entity::countFlagsForPIX()
puiUsedFlags++;
}
PIXAddNamedCounter(freecount,"Small Ids free");
PIXAddNamedCounter(2048 - freecount,"Small Ids used");
PIXAddNamedCounter(16384 - freecount,"Small Ids used");
}

void Entity::resetSmallId()
Expand All @@ -149,7 +153,7 @@ void Entity::resetSmallId()
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( 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 j = index % 32;
Expand All @@ -172,7 +176,7 @@ void Entity::useSmallIds()
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( 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 j = entityId % 32;
Expand All @@ -192,7 +196,7 @@ void Entity::considerForExtraWandering(bool enable)
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( 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++ )
{
Expand Down Expand Up @@ -224,12 +228,12 @@ void Entity::tickExtraWandering()
int entityId = 0;
if( extraWanderCount )
{
entityId = ( extraWanderIds[ extraWanderCount - 1 ] + 1 ) % 2048;
entityId = ( extraWanderIds[ extraWanderCount - 1 ] + 1 ) % 16384;
}

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 j = entityId % 32;
Expand All @@ -241,7 +245,7 @@ void Entity::tickExtraWandering()
// printf("%d, ", entityId);
}

entityId = ( entityId + 1 ) % 2048;
entityId = ( entityId + 1 ) % 16384;
}
// printf("\n");
}
Expand All @@ -261,7 +265,7 @@ void Entity::_init(bool useSmallId, Level *level)
else
{
entityId = Entity::entityCounter++;
if(entityCounter == 0x7ffffff ) entityCounter = 2048;
if(entityCounter == 0x7ffffff ) entityCounter = 16384;
}

viewScale = 1.0;
Expand Down
9 changes: 6 additions & 3 deletions Minecraft.World/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,12 @@ class Entity : public enable_shared_from_this<Entity>

int getSmallId();
void freeSmallId(int index);
static unsigned int entityIdUsedFlags[2048/32];
static unsigned int entityIdWanderFlags[2048/32];
static unsigned int entityIdRemovingFlags[2048/32];
//static unsigned int entityIdUsedFlags[2048/32];
//static unsigned int entityIdWanderFlags[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 extraWanderCount;
static int extraWanderTicks;
Expand Down
2 changes: 1 addition & 1 deletion Minecraft.World/MoveEntityPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void MoveEntityPacket::read(DataInputStream *dis) //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
__debugbreak();
Expand Down
10 changes: 5 additions & 5 deletions Minecraft.World/MoveEntityPacketSmall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MoveEntityPacketSmall::MoveEntityPacketSmall()

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
__debugbreak();
Expand All @@ -42,7 +42,7 @@ void MoveEntityPacketSmall::read(DataInputStream *dis) //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
__debugbreak();
Expand Down Expand Up @@ -99,7 +99,7 @@ void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOExcept

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
__debugbreak();
Expand Down Expand Up @@ -138,7 +138,7 @@ void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //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
__debugbreak();
Expand Down Expand Up @@ -176,7 +176,7 @@ void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //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
__debugbreak();
Expand Down